codeplay-common 4.11.12 → 4.11.15

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.
Files changed (33) hide show
  1. package/CHANGELOG.md +114 -101
  2. package/LICENSE +21 -21
  3. package/README.md +274 -229
  4. package/RELEASE_NOTES.md +110 -97
  5. package/files/buildCodeplay/add-splash-screen.js +256 -255
  6. package/files/buildCodeplay/apk-store-builder.js +97 -97
  7. package/files/buildCodeplay/codeplayBeforeBuild.js +98 -52
  8. package/files/buildCodeplay/fix-onesignal-plugin.js +96 -96
  9. package/files/buildCodeplay/fix-optimize-builld/android-r8-rules.cjs +31 -31
  10. package/files/buildCodeplay/fix-optimize-builld/ffmpeg-jni-rules.cjs +28 -28
  11. package/files/buildCodeplay/fix-optimize-builld/fix-optimize-build.gradle +9 -9
  12. package/files/buildCodeplay/fix-optimize-builld/restore-android-r8-rules.cjs +30 -30
  13. package/files/buildCodeplay/ios-emi-admob-modification.js +24 -24
  14. package/files/buildCodeplay/manifestModification.js +38 -38
  15. package/files/buildCodeplay/release-sync.config.json +4 -4
  16. package/files/buildCodeplay/setSplashAnimation.js +228 -226
  17. package/files/buildCodeplay/splash-setup.cjs +88 -0
  18. package/files/buildCodeplay/splashxml/codeplay_splashScreen.xml +1 -1
  19. package/files/buildCodeplay/sync-admob-nextgen.js +219 -219
  20. package/files/buildCodeplay/versions.json +27 -27
  21. package/files/finalrelease +1263 -1263
  22. package/files/generate-ai-promo-video.js +23 -23
  23. package/files/ionic.config.json +6 -6
  24. package/files/scripts-common/run-codeplay-sync-after.js +21 -21
  25. package/files/scripts-common/screenshot/background-decorations.js +120 -120
  26. package/files/scripts-common/screenshot/frame-samples.js +117 -117
  27. package/files/scripts-common/setup-baseline-profile.js +291 -291
  28. package/files/take-screen-video.js +644 -644
  29. package/package.json +28 -27
  30. package/runtime/splash-ready.mjs +52 -0
  31. package/scripts/splash-setup.test.cjs +142 -0
  32. package/scripts/sync-files.js +114 -113
  33. package/scripts/uninstall.js +2 -2
@@ -1,226 +1,228 @@
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 android.view.View;
128
- import android.webkit.WebView;
129
- import com.getcapacitor.BridgeActivity;
130
- import com.getcapacitor.CapConfig;
131
- import com.getcapacitor.WebViewListener;
132
- import org.json.JSONException;
133
- import java.util.Locale;
134
-
135
- import androidx.activity.EdgeToEdge;
136
- import androidx.core.graphics.Insets;
137
- import androidx.core.view.ViewCompat;
138
- import androidx.core.view.WindowInsetsCompat;
139
-
140
- public class MainActivity extends BridgeActivity {
141
- @Override
142
- protected void load() {
143
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.VANILLA_ICE_CREAM) {
144
- config = CapConfig.loadDefault(this);
145
- try {
146
- config.getPluginConfiguration("SystemBars").getConfigJSON().put("insetsHandling", "disable");
147
- } catch (JSONException e) {
148
- throw new IllegalStateException("Unable to configure system bars", e);
149
- }
150
- }
151
- super.load();
152
- }
153
-
154
- @Override
155
- protected void onCreate(Bundle savedInstanceState) {
156
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.VANILLA_ICE_CREAM) {
157
- bridgeBuilder.addWebViewListener(new WebViewListener() {
158
- @Override
159
- public void onPageCommitVisible(WebView webView, String url) {
160
- ViewCompat.requestApplyInsets(getWindow().getDecorView());
161
- }
162
- });
163
- }
164
- super.onCreate(savedInstanceState);
165
-
166
- EdgeToEdge.enable(this);
167
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.VANILLA_ICE_CREAM) {
168
- View decorView = getWindow().getDecorView();
169
- ViewCompat.setOnApplyWindowInsetsListener(decorView, (view, insets) -> {
170
- Insets bars = insets.getInsets(WindowInsetsCompat.Type.systemBars() | WindowInsetsCompat.Type.displayCutout());
171
- float density = getResources().getDisplayMetrics().density;
172
- int top = Math.round(bars.top / density);
173
- int right = Math.round(bars.right / density);
174
- int bottom = insets.isVisible(WindowInsetsCompat.Type.ime()) ? 0 : Math.round(bars.bottom / density);
175
- int left = Math.round(bars.left / density);
176
-
177
- if (bridge != null && bridge.getWebView() != null) {
178
- String script = String.format(Locale.US, """
179
- try {
180
- const root = document.documentElement;
181
- root.style.setProperty('--android-system-bar-top', '%dpx');
182
- root.style.setProperty('--android-system-bar-right', '%dpx');
183
- root.style.setProperty('--android-system-bar-bottom', '%dpx');
184
- root.style.setProperty('--android-system-bar-left', '%dpx');
185
- } catch (e) {}
186
- """, top, right, bottom, left);
187
- bridge.getWebView().evaluateJavascript(script, null);
188
- }
189
- return insets;
190
- });
191
- ViewCompat.requestApplyInsets(decorView);
192
- }
193
-
194
- // Handle custom splash screen exit animation
195
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
196
- getSplashScreen().setOnExitAnimationListener(splashScreenView -> {
197
- // Add your custom animation here (e.g., fade out)
198
- splashScreenView.setAlpha(1f);
199
- splashScreenView.animate()
200
- ${selectedAnimation.code} // Apply selected animation
201
- .setDuration(1000) // Animation duration (1000ms)
202
- .withEndAction(splashScreenView::remove) // Remove splash screen
203
- .start();
204
- });
205
- }
206
- }
207
- }
208
- `;
209
-
210
- // Write the new MainActivity.java content
211
- writeMainActivity(newMainActivityCode);
212
- });
213
-
214
- //rl.close();
215
- //});
216
-
217
- // Write updated data to MainActivity.java
218
- function writeMainActivity(updatedData) {
219
- fs.writeFile(mainActivityPath, updatedData, 'utf8', (err) => {
220
- if (err) {
221
- console.error(`Error writing to MainActivity.java: ${err.message}`);
222
- return;
223
- }
224
- console.log('MainActivity.java updated successfully!');
225
- });
226
- }
1
+ const fs = require('fs');
2
+ const readline = require('readline');
3
+ const path = require('path');
4
+ const { readSplashOptions } = require('./splash-setup.cjs');
5
+ const splashOptions = readSplashOptions(JSON.parse(fs.readFileSync('capacitor.config.json', 'utf8')));
6
+
7
+ // Define the root directory of the project (adjust if needed)
8
+ const projectRoot = path.join('android/app/src/main');
9
+
10
+ // Animation options
11
+ const animations = [
12
+ { id: 1, name: 'Ripple Effect', code: `.scaleX(1.2f).scaleY(1.2f).alpha(0.3f)` }, //Okay super
13
+ { id: 2, name: 'Pop Out', code: `.scaleX(1.2f).scaleY(1.2f).alpha(0f)` }, //Okay super
14
+ { id: 3, name: 'Super Zoom', code: `.scaleX(1.5f).scaleY(1.5f).alpha(1f)` }, //Okay super
15
+
16
+
17
+ { id: 4, name: 'Flip and Fade', code: `.scaleX(0f).scaleY(0f).rotation(180f).alpha(0f)` }, //Okay
18
+ { id: 5, name: 'Wipe Away', code: `.translationX(splashScreenView.getWidth()).alpha(0f)` }, //Okay
19
+ { id: 6, name: 'Bounce in Spiral', code: `.scaleX(0.5f).scaleY(0.5f).alpha(0.5f).rotation(360f)` }, //Okay
20
+ { id: 7, name: 'Fade and Slide', code: `.alpha(0f).translationY(splashScreenView.getHeight())` }, //Okay
21
+ { id: 8, name: 'Zoom Out with Bounce', code: `.scaleX(0f).scaleY(0f).alpha(0f).translationY(splashScreenView.getHeight())` }, //Okay
22
+ { id: 9, name: 'Twist', code: `.rotation(720f).alpha(0f)` }, //Okay
23
+ { id: 10, name: 'Rotate Back', code: `.rotation(-360f).alpha(1f)` }, //Okay
24
+ { id: 11, name: 'Stretch In', code: `.scaleX(1.5f).scaleY(1.5f).alpha(1f)` }, //Okay
25
+ { id: 12, name: 'Fade and Scale', code: `.alpha(0f).scaleX(0f).scaleY(0f)` }, //Okay
26
+ { id: 13, name: 'Slide Left and Fade', code: `.translationX(-splashScreenView.getWidth()).alpha(0f)` }, //Okay
27
+
28
+
29
+ { id: 14, name: 'Fade Out', code: `.alpha(0f)` },
30
+ { id: 15, name: 'Slide Down', code: `.translationY(splashScreenView.getHeight())` },
31
+ { id: 16, name: 'Zoom Out', code: `.scaleX(0f).scaleY(0f).alpha(0f)` },
32
+ { id: 17, name: 'Rotate Out', code: `.rotation(360f).alpha(0f)` },
33
+ { id: 18, name: 'Slide Up', code: `.translationY(-splashScreenView.getHeight()).alpha(0f)` },
34
+ { id: 19, name: 'Bounce Effect', code: `.translationY(splashScreenView.getHeight())` },
35
+ { id: 20, name: 'Flip Out', code: `.scaleX(0f).alpha(0f)` },
36
+ { id: 21, name: 'Diagonal Slide and Fade Out', code: `.translationX(splashScreenView.getWidth()).translationY(splashScreenView.getHeight()).alpha(0f)` },
37
+ { id: 22, name: 'Scale Down with Bounce', code: `.scaleX(0f).scaleY(0f)` },
38
+ { id: 23, name: 'Slide Left', code: `.translationX(-splashScreenView.getWidth()).alpha(0f)` },
39
+ { id: 24, name: 'Slide Right', code: `.translationX(splashScreenView.getWidth()).alpha(0f)` },
40
+ { id: 25, name: 'Scale Up', code: `.scaleX(1f).scaleY(1f).alpha(1f)` },
41
+ { id: 26, name: 'Rotate In', code: `.rotation(180f).alpha(1f)` },
42
+ { id: 27, name: 'Bounce Up', code: `.translationY(-100f).setInterpolator(new BounceInterpolator())` },
43
+ { id: 28, name: 'Flip Horizontal', code: `.scaleX(-1f).alpha(1f)` },
44
+ { id: 29, name: 'Zoom In', code: `.scaleX(1f).scaleY(1f).alpha(1f)` },
45
+ { id: 30, name: 'Wobble', code: `.translationX(10f).translationX(-10f).translationX(10f)` },
46
+ { id: 31, name: 'Vertical Shake', code: `.translationY(10f).translationY(-10f).translationY(10f)` },
47
+ { id: 32, name: 'Bounce Down', code: `.translationY(100f).setInterpolator(new BounceInterpolator())` },
48
+ { id: 33, name: 'Swing', code: `.rotation(15f).translationX(-10f).rotation(-15f).translationX(10f)` },
49
+ { id: 34, name: 'Elastic Bounce', code: `.translationX(30f).translationX(-30f).translationX(15f).translationX(-15f)` },
50
+ { id: 35, name: 'Pulse', code: `.scaleX(1.1f).scaleY(1.1f).alpha(1f).setRepeatMode(ValueAnimator.REVERSE).setRepeatCount(ValueAnimator.INFINITE)` },
51
+ { id: 36, name: 'Skew', code: `.setRotationX(30f).setRotationY(30f).alpha(0.5f)` },
52
+ { id: 37, name: 'Vibrate', code: `.translationX(5f).translationX(-5f).translationX(5f).translationX(-5f)` },
53
+ { id: 38, name: 'Speed Out', code: `.alpha(0f).setDuration(300)` },
54
+ { id: 39, name: 'Wave', code: `.translationX(20f).translationX(-20f).translationX(20f).translationX(-20f)` },
55
+ { id: 40, name: 'Swing Bounce', code: `.rotation(15f).translationX(10f).translationX(-10f)` },
56
+ ];
57
+
58
+
59
+ // Function to find the package name from capacitor.config.json
60
+ function findPackageName() {
61
+ const configPath = path.join('capacitor.config.json');
62
+ if (!fs.existsSync(configPath)) {
63
+ console.error('capacitor.config.json not found. Ensure this is a valid Capacitor project.');
64
+ process.exit(1);
65
+ }
66
+
67
+ const configContent = JSON.parse(fs.readFileSync(configPath, 'utf8'));
68
+ return configContent.appId;
69
+ }
70
+
71
+ // Function to construct the MainActivity.java path
72
+ function constructMainActivityPath(packageName) {
73
+ const packagePath = packageName.replace(/\./g, '/'); // Convert package name to path
74
+ const mainActivityPath = path.join('android', 'app', 'src', 'main', 'java', packagePath, 'MainActivity.java');
75
+
76
+ console.log('MainActivity path:', mainActivityPath); // Output for debugging
77
+ return mainActivityPath;
78
+ }
79
+
80
+ // Find package name and MainActivity.java path
81
+ const packageName = findPackageName();
82
+ if (!packageName) {
83
+ console.error('Failed to extract the package name from capacitor.config.json.');
84
+ process.exit(1);
85
+ }
86
+
87
+ const mainActivityPath = constructMainActivityPath(packageName);
88
+
89
+ // Display animation options
90
+ /* const rl = readline.createInterface({
91
+ input: process.stdin,
92
+ output: process.stdout,
93
+ }); */
94
+
95
+ console.log('Select an animation type for the splash screen:');
96
+ animations.forEach((animation) => {
97
+ //console.log(`${animation.id}. ${animation.name}`);
98
+ });
99
+
100
+ // Prompt user for animation selection
101
+ //rl.question('Enter the number of the animation type: ', (answer) => {
102
+
103
+ const answer=1;
104
+
105
+ const selectedAnimation = animations.find((anim) => anim.id === parseInt(answer, 10));
106
+
107
+ if (!selectedAnimation) {
108
+ console.log('Invalid selection. Please run the script again.');
109
+ //rl.close();
110
+ return;
111
+ }
112
+
113
+ console.log(`Selected: ${selectedAnimation.name}`);
114
+
115
+ // Read the MainActivity.java file
116
+ fs.readFile(mainActivityPath, 'utf8', (err, data) => {
117
+ if (err) {
118
+ console.error(`Error reading MainActivity.java: ${err.message}`);
119
+ //rl.close();
120
+ return;
121
+ }
122
+
123
+ // New logic for removing existing code and adding new splash screen animation code
124
+ const newMainActivityCode =
125
+ `package ${findPackageName()};
126
+
127
+ import android.os.Build;
128
+ import android.os.Bundle;
129
+ import android.view.View;
130
+ import android.webkit.WebView;
131
+ import com.getcapacitor.BridgeActivity;
132
+ import com.getcapacitor.CapConfig;
133
+ import com.getcapacitor.WebViewListener;
134
+ import org.json.JSONException;
135
+ import java.util.Locale;
136
+
137
+ import androidx.activity.EdgeToEdge;
138
+ import androidx.core.graphics.Insets;
139
+ import androidx.core.view.ViewCompat;
140
+ import androidx.core.view.WindowInsetsCompat;
141
+
142
+ public class MainActivity extends BridgeActivity {
143
+ @Override
144
+ protected void load() {
145
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.VANILLA_ICE_CREAM) {
146
+ config = CapConfig.loadDefault(this);
147
+ try {
148
+ config.getPluginConfiguration("SystemBars").getConfigJSON().put("insetsHandling", "disable");
149
+ } catch (JSONException e) {
150
+ throw new IllegalStateException("Unable to configure system bars", e);
151
+ }
152
+ }
153
+ super.load();
154
+ }
155
+
156
+ @Override
157
+ protected void onCreate(Bundle savedInstanceState) {
158
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.VANILLA_ICE_CREAM) {
159
+ bridgeBuilder.addWebViewListener(new WebViewListener() {
160
+ @Override
161
+ public void onPageCommitVisible(WebView webView, String url) {
162
+ ViewCompat.requestApplyInsets(getWindow().getDecorView());
163
+ }
164
+ });
165
+ }
166
+ super.onCreate(savedInstanceState);
167
+
168
+ EdgeToEdge.enable(this);
169
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.VANILLA_ICE_CREAM) {
170
+ View decorView = getWindow().getDecorView();
171
+ ViewCompat.setOnApplyWindowInsetsListener(decorView, (view, insets) -> {
172
+ Insets bars = insets.getInsets(WindowInsetsCompat.Type.systemBars() | WindowInsetsCompat.Type.displayCutout());
173
+ float density = getResources().getDisplayMetrics().density;
174
+ int top = Math.round(bars.top / density);
175
+ int right = Math.round(bars.right / density);
176
+ int bottom = insets.isVisible(WindowInsetsCompat.Type.ime()) ? 0 : Math.round(bars.bottom / density);
177
+ int left = Math.round(bars.left / density);
178
+
179
+ if (bridge != null && bridge.getWebView() != null) {
180
+ String script = String.format(Locale.US, """
181
+ try {
182
+ const root = document.documentElement;
183
+ root.style.setProperty('--android-system-bar-top', '%dpx');
184
+ root.style.setProperty('--android-system-bar-right', '%dpx');
185
+ root.style.setProperty('--android-system-bar-bottom', '%dpx');
186
+ root.style.setProperty('--android-system-bar-left', '%dpx');
187
+ } catch (e) {}
188
+ """, top, right, bottom, left);
189
+ bridge.getWebView().evaluateJavascript(script, null);
190
+ }
191
+ return insets;
192
+ });
193
+ ViewCompat.requestApplyInsets(decorView);
194
+ }
195
+
196
+ // Handle custom splash screen exit animation
197
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
198
+ getSplashScreen().setOnExitAnimationListener(splashScreenView -> {
199
+ // Add your custom animation here (e.g., fade out)
200
+ splashScreenView.setAlpha(1f);
201
+ splashScreenView.animate()
202
+ ${selectedAnimation.code} // Apply selected animation
203
+ .setDuration(${splashOptions.duration}) // Configured splash exit duration
204
+ .withEndAction(splashScreenView::remove) // Remove splash screen
205
+ .start();
206
+ });
207
+ }
208
+ }
209
+ }
210
+ `;
211
+
212
+ // Write the new MainActivity.java content
213
+ writeMainActivity(newMainActivityCode);
214
+ });
215
+
216
+ //rl.close();
217
+ //});
218
+
219
+ // Write updated data to MainActivity.java
220
+ function writeMainActivity(updatedData) {
221
+ fs.writeFile(mainActivityPath, updatedData, 'utf8', (err) => {
222
+ if (err) {
223
+ console.error(`Error writing to MainActivity.java: ${err.message}`);
224
+ return;
225
+ }
226
+ console.log('MainActivity.java updated successfully!');
227
+ });
228
+ }
@@ -0,0 +1,88 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const crypto = require('crypto');
4
+ const runtimeImport = "import { hideSplashWhenReady } from 'codeplay-common/runtime/splash-ready.mjs';";
5
+ const knownReadyHash = '451fd2e0ca63712e0f771ee0ed03ae5bd3a379f0ca1e75e971cd7acee0802a2b';
6
+
7
+ function readSplashOptions(config) {
8
+ const options = config.plugins?.CodeplaySplashScreen || {};
9
+ const duration = options.exitAnimationDuration ?? 1000;
10
+ const timeout = options.readinessTimeout ?? 8000;
11
+ const imageSelector = options.readyImageSelector ?? '[data-splash-ready], .t-film-art img';
12
+ if (!Number.isInteger(duration) || duration < 0 || duration > 10000) throw new Error('CodeplaySplashScreen.exitAnimationDuration must be an integer from0 to10000.');
13
+ if (!Number.isInteger(timeout) || timeout < 1 || timeout > 60000) throw new Error('CodeplaySplashScreen.readinessTimeout must be an integer from1 to60000.');
14
+ if (typeof imageSelector !== 'string') throw new Error('CodeplaySplashScreen.readyImageSelector must be a string.');
15
+ if (options.migrateLegacyReadiness !== undefined && typeof options.migrateLegacyReadiness !== 'boolean') throw new Error('CodeplaySplashScreen.migrateLegacyReadiness must be boolean.');
16
+ return { duration, timeout, imageSelector, migrateLegacy: options.migrateLegacyReadiness === true };
17
+ }
18
+
19
+ function migrateSplashTheme(content) {
20
+ // Repair only the known package default; preserve custom themes and styling.
21
+ return content.replace(/(<item\s+name=["']postSplashScreenTheme["']\s*>\s*)@style\/Theme\.AppCompat\.NoActionBar(\s*<\/item>)/g,
22
+ '$1@style/Theme.AppCompat.DayNight.NoActionBar$2');
23
+ }
24
+
25
+ function migrateReadinessSource(source, options) {
26
+ if (!/\b(?:var|let|const)\s+capacitorApp\s*=/.test(source)) return { source, status: 'unsupported' };
27
+ const handler = / handleSplashscreen:\s*function\s*\(\)\s*\{([\s\S]*?)\r?\n \},/;
28
+ const match = source.match(handler);
29
+ if (!match) return { source, status: 'unsupported' };
30
+ const body = match[1].replace(/\s+/g, '');
31
+ const isReady = crypto.createHash('sha256').update(body).digest('hex') === knownReadyHash;
32
+ const isManaged = /^if\(!window\.Capacitor\)return;returnhideSplashWhenReady\(\{f7:capacitorApp\.f7,hide:\(\)=>SplashScreen\.hide\(\),imageSelector:"(?:\\.|[^"\\])*",timeout:\d+\}\);$/.test(body)
33
+ && source.includes(runtimeImport);
34
+ const isLegacy = body === "if(!window.Capacitor)return;setTimeout(()=>{if(window.Capacitor.Plugins?.SplashScreen)window.Capacitor.Plugins.SplashScreen.hide();},2000);"
35
+ || body === "if(!window.Capacitor)return;setTimeout(()=>{if(window.Capacitor.Plugins&&window.Capacitor.Plugins.SplashScreen){window.Capacitor.Plugins.SplashScreen.hide();}},2000);";
36
+ if (!isReady && !isManaged && !(isLegacy && options.migrateLegacy)) return { source, status: isLegacy ? 'opt-in-required' : 'custom-preserved' };
37
+ const newline = source.includes('\r\n') ? '\r\n' : '\n';
38
+ const method = [
39
+ ' handleSplashscreen: function () {',
40
+ ' if (!window.Capacitor) return;',
41
+ ' return hideSplashWhenReady({',
42
+ ' f7: capacitorApp.f7,',
43
+ ' hide: () => SplashScreen.hide(),',
44
+ ` imageSelector: ${JSON.stringify(options.imageSelector)},`,
45
+ ` timeout: ${options.timeout}`, ' });', ' },'
46
+ ].join(newline);
47
+ let updated = source.replace(handler, () => method);
48
+ if (!updated.includes(runtimeImport)) updated = runtimeImport + newline + updated;
49
+ if (!/import\s*\{[^}]*\bSplashScreen\b[^}]*\}\s*from\s*['"]@capacitor\/splash-screen['"]/.test(updated)) {
50
+ updated = "import { SplashScreen } from '@capacitor/splash-screen';" + newline + updated;
51
+ }
52
+ return { source: updated, status: 'managed' };
53
+ }
54
+
55
+ function syncSplashSetup(projectRoot, { log = console.log } = {}) {
56
+ const configPath = path.join(projectRoot, 'capacitor.config.json');
57
+ if (!fs.existsSync(configPath)) return;
58
+ const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
59
+ const options = readSplashOptions(config);
60
+ const theme = path.join(projectRoot, 'buildCodeplay/splashxml/codeplay_splashScreen.xml');
61
+ if (fs.existsSync(theme)) {
62
+ const content = fs.readFileSync(theme, 'utf8');
63
+ const updated = migrateSplashTheme(content);
64
+ if (updated !== content) { fs.writeFileSync(theme, updated); log('codeplay-common: repaired legacy splash DayNight theme template; Android sync applies it.'); }
65
+ }
66
+ const app = path.join(projectRoot, 'src/js/capacitor-app.js');
67
+ if (!fs.existsSync(app)) return;
68
+ const source = fs.readFileSync(app, 'utf8');
69
+ const migrated = migrateReadinessSource(source, options);
70
+ if (migrated.status === 'managed') {
71
+ if (source !== migrated.source) {
72
+ const launch = config.plugins?.SplashScreen;
73
+ if (launch?.launchAutoHide !== true || !(launch.launchShowDuration >= options.timeout)) {
74
+ log('codeplay-common: readiness migration skipped; set SplashScreen.launchAutoHide=true and launchShowDuration>=readinessTimeout for the native fallback.');
75
+ return;
76
+ }
77
+ const dependency = JSON.parse(fs.readFileSync(path.join(projectRoot, 'package.json'), 'utf8'));
78
+ if (!dependency.dependencies?.['@capacitor/splash-screen'] && !dependency.devDependencies?.['@capacitor/splash-screen']) {
79
+ log('codeplay-common: readiness migration skipped; @capacitor/splash-screen must be installed.');
80
+ return;
81
+ }
82
+ fs.writeFileSync(app, migrated.source);
83
+ log('codeplay-common: connected supported startup handler to shared splash readiness.');
84
+ }
85
+ } else log(`codeplay-common: splash readiness ${migrated.status}; app startup preserved. See shared splash setup in README.`);
86
+ }
87
+
88
+ module.exports = { readSplashOptions, migrateSplashTheme, migrateReadinessSource, syncSplashSetup };
@@ -6,6 +6,6 @@
6
6
  <item name="windowSplashScreenBackground">@color/splashscreen_background</item>
7
7
  <item name="windowSplashScreenAnimatedIcon">@drawable/splash_icon</item>
8
8
  <item name="windowSplashScreenAnimationDuration">10000</item>
9
- <item name="postSplashScreenTheme">@style/Theme.AppCompat.NoActionBar</item>
9
+ <item name="postSplashScreenTheme">@style/Theme.AppCompat.DayNight.NoActionBar</item>
10
10
  </style>
11
11
  </resources>