codeplay-common 1.3.0 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.gitattributes CHANGED
@@ -1,2 +1,2 @@
1
- # Auto detect text files and perform LF normalization
2
- * text=auto
1
+ # Auto detect text files and perform LF normalization
2
+ * text=auto
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Merbin Joe
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Merbin Joe
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,12 +1,12 @@
1
- # codeplay-common
2
- Everything automatted in Capacitor apps, easy to maintain many apps in capacitor. It will reduce your 40% of work, with common file code.
3
-
4
-
5
- Easy add splashscreen and set animation
6
- Admob id automatically from capacitor.config.json file
7
- Make three build file for different store as per our requirement
8
- Based on store install various IAP plugins
9
- Make it to ionic project
10
-
11
- Donate to get full code including many common functions
1
+ # codeplay-common
2
+ Everything automatted in Capacitor apps, easy to maintain many apps in capacitor. It will reduce your 40% of work, with common file code.
3
+
4
+
5
+ Easy add splashscreen and set animation
6
+ Admob id automatically from capacitor.config.json file
7
+ Make three build file for different store as per our requirement
8
+ Based on store install various IAP plugins
9
+ Make it to ionic project
10
+
11
+ Donate to get full code including many common functions
12
12
  https://ko-fi.com/codeplay
File without changes
@@ -4,6 +4,19 @@ const plist = require('plist');
4
4
 
5
5
 
6
6
 
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
7
20
  //Check codeplay-common latest version installed or not Start
8
21
  const { execSync } = require('child_process');
9
22
 
@@ -60,22 +73,54 @@ try {
60
73
 
61
74
 
62
75
 
76
+ // Run package version check before executing the main script
77
+ try {
78
+ checkPackageVersion();
79
+ } catch (error) {
80
+ console.error(error.message);
81
+ process.exit(1);
82
+ }
83
+
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+ // Clean up AppleDouble files (._*) created by macOS START
92
+ try {
93
+ console.log('🧹 Cleaning up AppleDouble files (._*)...');
94
+ execSync(`find . -name '._*' -delete`);
95
+ console.log('✅ AppleDouble files removed.');
96
+ } catch (err) {
97
+ console.warn('⚠️ Failed to remove AppleDouble files:', err.message);
98
+ }
99
+
100
+ // Clean up AppleDouble files (._*) created by macOS END
101
+
102
+
103
+
104
+
105
+
106
+
63
107
 
64
108
  //In routes.js file check static import START
109
+
65
110
  const routesPath = path.join(process.cwd(), 'src', 'js', 'routes.js');
66
111
  const routesContent = fs.readFileSync(routesPath, 'utf-8');
67
112
 
68
- // Track whether we're inside a block comment
69
113
  let inBlockComment = false;
70
114
  const lines = routesContent.split('\n');
71
115
 
116
+ const allowedImport = `import HomePage from '../pages/home.f7';`;
72
117
  const badImportRegex = /^[ \t]*import\s+[\w{}*,\s]*\s+from\s+['"].+\.f7['"]\s*;/;
73
118
  const badImports = [];
74
119
 
75
120
  lines.forEach((line, index) => {
76
121
  const trimmed = line.trim();
77
122
 
78
- // Check block comment start/end
123
+ // Handle block comment start and end
79
124
  if (trimmed.startsWith('/*')) inBlockComment = true;
80
125
  if (inBlockComment && trimmed.endsWith('*/')) {
81
126
  inBlockComment = false;
@@ -85,28 +130,38 @@ lines.forEach((line, index) => {
85
130
  // Skip if inside block comment or line comment
86
131
  if (inBlockComment || trimmed.startsWith('//')) return;
87
132
 
88
- // Match static import
89
- if (badImportRegex.test(trimmed)) {
133
+ // Match static .f7 import
134
+ if (badImportRegex.test(trimmed) && trimmed !== allowedImport) {
90
135
  badImports.push({ line: trimmed, number: index + 1 });
91
136
  }
92
137
  });
93
138
 
94
139
  if (badImports.length > 0) {
95
- console.error('\n❌ ERROR: Detected static imports of .f7 files in routes.js\n');
96
- console.error(`⚠️ Please convert the following lines to
140
+ console.error('\n❌ ERROR: Detected disallowed static imports of .f7 files in routes.js\n');
141
+ console.error(`⚠️ Only this static import is allowed:\n ${allowedImport}\n`);
142
+ console.error(`🔧 Please convert other imports to async dynamic imports like this:\n`);
143
+ console.error(`
144
+
145
+ import HomePage from '../pages/home.f7';
146
+
97
147
  const routes = [
98
148
  {
99
149
  path: '/',
150
+ component:HomePage,
151
+ },
152
+ {
153
+ path: '/ProfilePage/',
100
154
  async async({ resolve }) {
101
- const page = await import('../pages/home.f7');
155
+ const page = await import('../pages/profile.f7');
102
156
  resolve({ component: page.default });
103
157
  },
104
- }
105
- ]
106
- \n`);
158
+ }]
159
+ `);
160
+
107
161
  badImports.forEach(({ line, number }) => {
108
162
  console.error(`${number}: ${line}`);
109
163
  });
164
+
110
165
  process.exit(1);
111
166
  } else {
112
167
  console.log('✅ routes.js passed the .f7 import check.');
@@ -1,36 +1,36 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
-
4
- // Path to the plugin.xml file
5
- const pluginXmlPath = path.join('node_modules', 'emi-indo-cordova-plugin-admob', 'plugin.xml');
6
-
7
- // Get the store ID from the environment variable
8
- const storeId = process.env.VITE_STORE_ID || '1';
9
-
10
- // Determine the framework to use based on storeId
11
- const framework = storeId === '7'
12
- ? '<framework src="com.google.android.gms:play-services-ads:$PLAY_SERVICES_VERSION" />'
13
- : '<framework src="com.google.android.gms:play-services-ads-lite:$PLAY_SERVICES_VERSION" />';
14
-
15
- // Read and modify the plugin.xml file
16
- fs.readFile(pluginXmlPath, 'utf8', (err, data) => {
17
- if (err) {
18
- console.error('Error reading plugin.xml:', err);
19
- process.exit(1);
20
- }
21
-
22
- // Replace the existing framework line with the selected one
23
- const modifiedData = data.replace(
24
- /<framework src="com.google.android.gms:play-services-ads.*" \/>\n/,
25
- `${framework}\n`
26
- );
27
-
28
- // Write the modified content back to plugin.xml
29
- fs.writeFile(pluginXmlPath, modifiedData, 'utf8', (err) => {
30
- if (err) {
31
- console.error('Error writing plugin.xml:', err);
32
- process.exit(1);
33
- }
34
- console.log('plugin.xml updated successfully.');
35
- });
36
- });
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+
4
+ // Path to the plugin.xml file
5
+ const pluginXmlPath = path.join('node_modules', 'emi-indo-cordova-plugin-admob', 'plugin.xml');
6
+
7
+ // Get the store ID from the environment variable
8
+ const storeId = process.env.VITE_STORE_ID || '1';
9
+
10
+ // Determine the framework to use based on storeId
11
+ const framework = storeId === '7'
12
+ ? '<framework src="com.google.android.gms:play-services-ads:$PLAY_SERVICES_VERSION" />'
13
+ : '<framework src="com.google.android.gms:play-services-ads-lite:$PLAY_SERVICES_VERSION" />';
14
+
15
+ // Read and modify the plugin.xml file
16
+ fs.readFile(pluginXmlPath, 'utf8', (err, data) => {
17
+ if (err) {
18
+ console.error('Error reading plugin.xml:', err);
19
+ process.exit(1);
20
+ }
21
+
22
+ // Replace the existing framework line with the selected one
23
+ const modifiedData = data.replace(
24
+ /<framework src="com.google.android.gms:play-services-ads.*" \/>\n/,
25
+ `${framework}\n`
26
+ );
27
+
28
+ // Write the modified content back to plugin.xml
29
+ fs.writeFile(pluginXmlPath, modifiedData, 'utf8', (err) => {
30
+ if (err) {
31
+ console.error('Error writing plugin.xml:', err);
32
+ process.exit(1);
33
+ }
34
+ console.log('plugin.xml updated successfully.');
35
+ });
36
+ });
@@ -1,167 +1,167 @@
1
- const fs = require('fs');
2
- const readline = require('readline');
3
- const path = require('path');
4
-
5
- // Define the root directory of the project (adjust if needed)
6
- const projectRoot = path.join('android/app/src/main');
7
-
8
- // Animation options
9
- const animations = [
10
- { id: 1, name: 'Ripple Effect', code: `.scaleX(1.2f).scaleY(1.2f).alpha(0.3f)` }, //Okay super
11
- { id: 2, name: 'Pop Out', code: `.scaleX(1.2f).scaleY(1.2f).alpha(0f)` }, //Okay super
12
- { id: 3, name: 'Super Zoom', code: `.scaleX(1.5f).scaleY(1.5f).alpha(1f)` }, //Okay super
13
-
14
-
15
- { id: 4, name: 'Flip and Fade', code: `.scaleX(0f).scaleY(0f).rotation(180f).alpha(0f)` }, //Okay
16
- { id: 5, name: 'Wipe Away', code: `.translationX(splashScreenView.getWidth()).alpha(0f)` }, //Okay
17
- { id: 6, name: 'Bounce in Spiral', code: `.scaleX(0.5f).scaleY(0.5f).alpha(0.5f).rotation(360f)` }, //Okay
18
- { id: 7, name: 'Fade and Slide', code: `.alpha(0f).translationY(splashScreenView.getHeight())` }, //Okay
19
- { id: 8, name: 'Zoom Out with Bounce', code: `.scaleX(0f).scaleY(0f).alpha(0f).translationY(splashScreenView.getHeight())` }, //Okay
20
- { id: 9, name: 'Twist', code: `.rotation(720f).alpha(0f)` }, //Okay
21
- { id: 10, name: 'Rotate Back', code: `.rotation(-360f).alpha(1f)` }, //Okay
22
- { id: 11, name: 'Stretch In', code: `.scaleX(1.5f).scaleY(1.5f).alpha(1f)` }, //Okay
23
- { id: 12, name: 'Fade and Scale', code: `.alpha(0f).scaleX(0f).scaleY(0f)` }, //Okay
24
- { id: 13, name: 'Slide Left and Fade', code: `.translationX(-splashScreenView.getWidth()).alpha(0f)` }, //Okay
25
-
26
-
27
- { id: 14, name: 'Fade Out', code: `.alpha(0f)` },
28
- { id: 15, name: 'Slide Down', code: `.translationY(splashScreenView.getHeight())` },
29
- { id: 16, name: 'Zoom Out', code: `.scaleX(0f).scaleY(0f).alpha(0f)` },
30
- { id: 17, name: 'Rotate Out', code: `.rotation(360f).alpha(0f)` },
31
- { id: 18, name: 'Slide Up', code: `.translationY(-splashScreenView.getHeight()).alpha(0f)` },
32
- { id: 19, name: 'Bounce Effect', code: `.translationY(splashScreenView.getHeight())` },
33
- { id: 20, name: 'Flip Out', code: `.scaleX(0f).alpha(0f)` },
34
- { id: 21, name: 'Diagonal Slide and Fade Out', code: `.translationX(splashScreenView.getWidth()).translationY(splashScreenView.getHeight()).alpha(0f)` },
35
- { id: 22, name: 'Scale Down with Bounce', code: `.scaleX(0f).scaleY(0f)` },
36
- { id: 23, name: 'Slide Left', code: `.translationX(-splashScreenView.getWidth()).alpha(0f)` },
37
- { id: 24, name: 'Slide Right', code: `.translationX(splashScreenView.getWidth()).alpha(0f)` },
38
- { id: 25, name: 'Scale Up', code: `.scaleX(1f).scaleY(1f).alpha(1f)` },
39
- { id: 26, name: 'Rotate In', code: `.rotation(180f).alpha(1f)` },
40
- { id: 27, name: 'Bounce Up', code: `.translationY(-100f).setInterpolator(new BounceInterpolator())` },
41
- { id: 28, name: 'Flip Horizontal', code: `.scaleX(-1f).alpha(1f)` },
42
- { id: 29, name: 'Zoom In', code: `.scaleX(1f).scaleY(1f).alpha(1f)` },
43
- { id: 30, name: 'Wobble', code: `.translationX(10f).translationX(-10f).translationX(10f)` },
44
- { id: 31, name: 'Vertical Shake', code: `.translationY(10f).translationY(-10f).translationY(10f)` },
45
- { id: 32, name: 'Bounce Down', code: `.translationY(100f).setInterpolator(new BounceInterpolator())` },
46
- { id: 33, name: 'Swing', code: `.rotation(15f).translationX(-10f).rotation(-15f).translationX(10f)` },
47
- { id: 34, name: 'Elastic Bounce', code: `.translationX(30f).translationX(-30f).translationX(15f).translationX(-15f)` },
48
- { id: 35, name: 'Pulse', code: `.scaleX(1.1f).scaleY(1.1f).alpha(1f).setRepeatMode(ValueAnimator.REVERSE).setRepeatCount(ValueAnimator.INFINITE)` },
49
- { id: 36, name: 'Skew', code: `.setRotationX(30f).setRotationY(30f).alpha(0.5f)` },
50
- { id: 37, name: 'Vibrate', code: `.translationX(5f).translationX(-5f).translationX(5f).translationX(-5f)` },
51
- { id: 38, name: 'Speed Out', code: `.alpha(0f).setDuration(300)` },
52
- { id: 39, name: 'Wave', code: `.translationX(20f).translationX(-20f).translationX(20f).translationX(-20f)` },
53
- { id: 40, name: 'Swing Bounce', code: `.rotation(15f).translationX(10f).translationX(-10f)` },
54
- ];
55
-
56
-
57
- // Function to find the package name from capacitor.config.json
58
- function findPackageName() {
59
- const configPath = path.join('capacitor.config.json');
60
- if (!fs.existsSync(configPath)) {
61
- console.error('capacitor.config.json not found. Ensure this is a valid Capacitor project.');
62
- process.exit(1);
63
- }
64
-
65
- const configContent = JSON.parse(fs.readFileSync(configPath, 'utf8'));
66
- return configContent.appId;
67
- }
68
-
69
- // Function to construct the MainActivity.java path
70
- function constructMainActivityPath(packageName) {
71
- const packagePath = packageName.replace(/\./g, '/'); // Convert package name to path
72
- const mainActivityPath = path.join('android', 'app', 'src', 'main', 'java', packagePath, 'MainActivity.java');
73
-
74
- console.log('MainActivity path:', mainActivityPath); // Output for debugging
75
- return mainActivityPath;
76
- }
77
-
78
- // Find package name and MainActivity.java path
79
- const packageName = findPackageName();
80
- if (!packageName) {
81
- console.error('Failed to extract the package name from capacitor.config.json.');
82
- process.exit(1);
83
- }
84
-
85
- const mainActivityPath = constructMainActivityPath(packageName);
86
-
87
- // Display animation options
88
- /* const rl = readline.createInterface({
89
- input: process.stdin,
90
- output: process.stdout,
91
- }); */
92
-
93
- console.log('Select an animation type for the splash screen:');
94
- animations.forEach((animation) => {
95
- //console.log(`${animation.id}. ${animation.name}`);
96
- });
97
-
98
- // Prompt user for animation selection
99
- //rl.question('Enter the number of the animation type: ', (answer) => {
100
-
101
- const answer=1;
102
-
103
- const selectedAnimation = animations.find((anim) => anim.id === parseInt(answer, 10));
104
-
105
- if (!selectedAnimation) {
106
- console.log('Invalid selection. Please run the script again.');
107
- //rl.close();
108
- return;
109
- }
110
-
111
- console.log(`Selected: ${selectedAnimation.name}`);
112
-
113
- // Read the MainActivity.java file
114
- fs.readFile(mainActivityPath, 'utf8', (err, data) => {
115
- if (err) {
116
- console.error(`Error reading MainActivity.java: ${err.message}`);
117
- //rl.close();
118
- return;
119
- }
120
-
121
- // New logic for removing existing code and adding new splash screen animation code
122
- const newMainActivityCode =
123
- `package ${findPackageName()};
124
-
125
- import android.os.Build;
126
- import android.os.Bundle;
127
- import com.getcapacitor.BridgeActivity;
128
-
129
-
130
- public class MainActivity extends BridgeActivity {
131
- @Override
132
- protected void onCreate(Bundle savedInstanceState) {
133
- super.onCreate(savedInstanceState);
134
-
135
- // Handle custom splash screen exit animation
136
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
137
- getSplashScreen().setOnExitAnimationListener(splashScreenView -> {
138
- // Add your custom animation here (e.g., fade out)
139
- splashScreenView.setAlpha(1f);
140
- splashScreenView.animate()
141
- ${selectedAnimation.code} // Apply selected animation
142
- .setDuration(1000) // Animation duration (1000ms)
143
- .withEndAction(splashScreenView::remove) // Remove splash screen
144
- .start();
145
- });
146
- }
147
- }
148
- }
149
- `;
150
-
151
- // Write the new MainActivity.java content
152
- writeMainActivity(newMainActivityCode);
153
- });
154
-
155
- //rl.close();
156
- //});
157
-
158
- // Write updated data to MainActivity.java
159
- function writeMainActivity(updatedData) {
160
- fs.writeFile(mainActivityPath, updatedData, 'utf8', (err) => {
161
- if (err) {
162
- console.error(`Error writing to MainActivity.java: ${err.message}`);
163
- return;
164
- }
165
- console.log('MainActivity.java updated successfully!');
166
- });
167
- }
1
+ const fs = require('fs');
2
+ const readline = require('readline');
3
+ const path = require('path');
4
+
5
+ // Define the root directory of the project (adjust if needed)
6
+ const projectRoot = path.join('android/app/src/main');
7
+
8
+ // Animation options
9
+ const animations = [
10
+ { id: 1, name: 'Ripple Effect', code: `.scaleX(1.2f).scaleY(1.2f).alpha(0.3f)` }, //Okay super
11
+ { id: 2, name: 'Pop Out', code: `.scaleX(1.2f).scaleY(1.2f).alpha(0f)` }, //Okay super
12
+ { id: 3, name: 'Super Zoom', code: `.scaleX(1.5f).scaleY(1.5f).alpha(1f)` }, //Okay super
13
+
14
+
15
+ { id: 4, name: 'Flip and Fade', code: `.scaleX(0f).scaleY(0f).rotation(180f).alpha(0f)` }, //Okay
16
+ { id: 5, name: 'Wipe Away', code: `.translationX(splashScreenView.getWidth()).alpha(0f)` }, //Okay
17
+ { id: 6, name: 'Bounce in Spiral', code: `.scaleX(0.5f).scaleY(0.5f).alpha(0.5f).rotation(360f)` }, //Okay
18
+ { id: 7, name: 'Fade and Slide', code: `.alpha(0f).translationY(splashScreenView.getHeight())` }, //Okay
19
+ { id: 8, name: 'Zoom Out with Bounce', code: `.scaleX(0f).scaleY(0f).alpha(0f).translationY(splashScreenView.getHeight())` }, //Okay
20
+ { id: 9, name: 'Twist', code: `.rotation(720f).alpha(0f)` }, //Okay
21
+ { id: 10, name: 'Rotate Back', code: `.rotation(-360f).alpha(1f)` }, //Okay
22
+ { id: 11, name: 'Stretch In', code: `.scaleX(1.5f).scaleY(1.5f).alpha(1f)` }, //Okay
23
+ { id: 12, name: 'Fade and Scale', code: `.alpha(0f).scaleX(0f).scaleY(0f)` }, //Okay
24
+ { id: 13, name: 'Slide Left and Fade', code: `.translationX(-splashScreenView.getWidth()).alpha(0f)` }, //Okay
25
+
26
+
27
+ { id: 14, name: 'Fade Out', code: `.alpha(0f)` },
28
+ { id: 15, name: 'Slide Down', code: `.translationY(splashScreenView.getHeight())` },
29
+ { id: 16, name: 'Zoom Out', code: `.scaleX(0f).scaleY(0f).alpha(0f)` },
30
+ { id: 17, name: 'Rotate Out', code: `.rotation(360f).alpha(0f)` },
31
+ { id: 18, name: 'Slide Up', code: `.translationY(-splashScreenView.getHeight()).alpha(0f)` },
32
+ { id: 19, name: 'Bounce Effect', code: `.translationY(splashScreenView.getHeight())` },
33
+ { id: 20, name: 'Flip Out', code: `.scaleX(0f).alpha(0f)` },
34
+ { id: 21, name: 'Diagonal Slide and Fade Out', code: `.translationX(splashScreenView.getWidth()).translationY(splashScreenView.getHeight()).alpha(0f)` },
35
+ { id: 22, name: 'Scale Down with Bounce', code: `.scaleX(0f).scaleY(0f)` },
36
+ { id: 23, name: 'Slide Left', code: `.translationX(-splashScreenView.getWidth()).alpha(0f)` },
37
+ { id: 24, name: 'Slide Right', code: `.translationX(splashScreenView.getWidth()).alpha(0f)` },
38
+ { id: 25, name: 'Scale Up', code: `.scaleX(1f).scaleY(1f).alpha(1f)` },
39
+ { id: 26, name: 'Rotate In', code: `.rotation(180f).alpha(1f)` },
40
+ { id: 27, name: 'Bounce Up', code: `.translationY(-100f).setInterpolator(new BounceInterpolator())` },
41
+ { id: 28, name: 'Flip Horizontal', code: `.scaleX(-1f).alpha(1f)` },
42
+ { id: 29, name: 'Zoom In', code: `.scaleX(1f).scaleY(1f).alpha(1f)` },
43
+ { id: 30, name: 'Wobble', code: `.translationX(10f).translationX(-10f).translationX(10f)` },
44
+ { id: 31, name: 'Vertical Shake', code: `.translationY(10f).translationY(-10f).translationY(10f)` },
45
+ { id: 32, name: 'Bounce Down', code: `.translationY(100f).setInterpolator(new BounceInterpolator())` },
46
+ { id: 33, name: 'Swing', code: `.rotation(15f).translationX(-10f).rotation(-15f).translationX(10f)` },
47
+ { id: 34, name: 'Elastic Bounce', code: `.translationX(30f).translationX(-30f).translationX(15f).translationX(-15f)` },
48
+ { id: 35, name: 'Pulse', code: `.scaleX(1.1f).scaleY(1.1f).alpha(1f).setRepeatMode(ValueAnimator.REVERSE).setRepeatCount(ValueAnimator.INFINITE)` },
49
+ { id: 36, name: 'Skew', code: `.setRotationX(30f).setRotationY(30f).alpha(0.5f)` },
50
+ { id: 37, name: 'Vibrate', code: `.translationX(5f).translationX(-5f).translationX(5f).translationX(-5f)` },
51
+ { id: 38, name: 'Speed Out', code: `.alpha(0f).setDuration(300)` },
52
+ { id: 39, name: 'Wave', code: `.translationX(20f).translationX(-20f).translationX(20f).translationX(-20f)` },
53
+ { id: 40, name: 'Swing Bounce', code: `.rotation(15f).translationX(10f).translationX(-10f)` },
54
+ ];
55
+
56
+
57
+ // Function to find the package name from capacitor.config.json
58
+ function findPackageName() {
59
+ const configPath = path.join('capacitor.config.json');
60
+ if (!fs.existsSync(configPath)) {
61
+ console.error('capacitor.config.json not found. Ensure this is a valid Capacitor project.');
62
+ process.exit(1);
63
+ }
64
+
65
+ const configContent = JSON.parse(fs.readFileSync(configPath, 'utf8'));
66
+ return configContent.appId;
67
+ }
68
+
69
+ // Function to construct the MainActivity.java path
70
+ function constructMainActivityPath(packageName) {
71
+ const packagePath = packageName.replace(/\./g, '/'); // Convert package name to path
72
+ const mainActivityPath = path.join('android', 'app', 'src', 'main', 'java', packagePath, 'MainActivity.java');
73
+
74
+ console.log('MainActivity path:', mainActivityPath); // Output for debugging
75
+ return mainActivityPath;
76
+ }
77
+
78
+ // Find package name and MainActivity.java path
79
+ const packageName = findPackageName();
80
+ if (!packageName) {
81
+ console.error('Failed to extract the package name from capacitor.config.json.');
82
+ process.exit(1);
83
+ }
84
+
85
+ const mainActivityPath = constructMainActivityPath(packageName);
86
+
87
+ // Display animation options
88
+ /* const rl = readline.createInterface({
89
+ input: process.stdin,
90
+ output: process.stdout,
91
+ }); */
92
+
93
+ console.log('Select an animation type for the splash screen:');
94
+ animations.forEach((animation) => {
95
+ //console.log(`${animation.id}. ${animation.name}`);
96
+ });
97
+
98
+ // Prompt user for animation selection
99
+ //rl.question('Enter the number of the animation type: ', (answer) => {
100
+
101
+ const answer=1;
102
+
103
+ const selectedAnimation = animations.find((anim) => anim.id === parseInt(answer, 10));
104
+
105
+ if (!selectedAnimation) {
106
+ console.log('Invalid selection. Please run the script again.');
107
+ //rl.close();
108
+ return;
109
+ }
110
+
111
+ console.log(`Selected: ${selectedAnimation.name}`);
112
+
113
+ // Read the MainActivity.java file
114
+ fs.readFile(mainActivityPath, 'utf8', (err, data) => {
115
+ if (err) {
116
+ console.error(`Error reading MainActivity.java: ${err.message}`);
117
+ //rl.close();
118
+ return;
119
+ }
120
+
121
+ // New logic for removing existing code and adding new splash screen animation code
122
+ const newMainActivityCode =
123
+ `package ${findPackageName()};
124
+
125
+ import android.os.Build;
126
+ import android.os.Bundle;
127
+ import com.getcapacitor.BridgeActivity;
128
+
129
+
130
+ public class MainActivity extends BridgeActivity {
131
+ @Override
132
+ protected void onCreate(Bundle savedInstanceState) {
133
+ super.onCreate(savedInstanceState);
134
+
135
+ // Handle custom splash screen exit animation
136
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
137
+ getSplashScreen().setOnExitAnimationListener(splashScreenView -> {
138
+ // Add your custom animation here (e.g., fade out)
139
+ splashScreenView.setAlpha(1f);
140
+ splashScreenView.animate()
141
+ ${selectedAnimation.code} // Apply selected animation
142
+ .setDuration(1000) // Animation duration (1000ms)
143
+ .withEndAction(splashScreenView::remove) // Remove splash screen
144
+ .start();
145
+ });
146
+ }
147
+ }
148
+ }
149
+ `;
150
+
151
+ // Write the new MainActivity.java content
152
+ writeMainActivity(newMainActivityCode);
153
+ });
154
+
155
+ //rl.close();
156
+ //});
157
+
158
+ // Write updated data to MainActivity.java
159
+ function writeMainActivity(updatedData) {
160
+ fs.writeFile(mainActivityPath, updatedData, 'utf8', (err) => {
161
+ if (err) {
162
+ console.error(`Error writing to MainActivity.java: ${err.message}`);
163
+ return;
164
+ }
165
+ console.log('MainActivity.java updated successfully!');
166
+ });
167
+ }
@@ -1,11 +1,11 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <resources>
3
- <color name="splashscreen_background">#FFFFFF</color>
4
-
5
- <style name="Theme.Codeplay.SplashScreen" parent="Theme.SplashScreen.IconBackground">
6
- <item name="windowSplashScreenBackground">@color/splashscreen_background</item>
7
- <item name="windowSplashScreenAnimatedIcon">@drawable/splash_icon</item>
8
- <item name="windowSplashScreenAnimationDuration">10000</item>
9
- <item name="postSplashScreenTheme">@style/Theme.AppCompat.NoActionBar</item>
10
- </style>
11
- </resources>
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <resources>
3
+ <color name="splashscreen_background">#FFFFFF</color>
4
+
5
+ <style name="Theme.Codeplay.SplashScreen" parent="Theme.SplashScreen.IconBackground">
6
+ <item name="windowSplashScreenBackground">@color/splashscreen_background</item>
7
+ <item name="windowSplashScreenAnimatedIcon">@drawable/splash_icon</item>
8
+ <item name="windowSplashScreenAnimationDuration">10000</item>
9
+ <item name="postSplashScreenTheme">@style/Theme.AppCompat.NoActionBar</item>
10
+ </style>
11
+ </resources>