codeplay-common 4.11.35 → 4.11.38

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 (63) hide show
  1. package/CHANGELOG.md +115 -115
  2. package/LICENSE +21 -21
  3. package/README.md +408 -374
  4. package/RELEASE_NOTES.md +97 -97
  5. package/files/buildCodeplay/HUAWEI-PRIVACY.md +9 -9
  6. package/files/buildCodeplay/add-splash-screen.js +255 -255
  7. package/files/buildCodeplay/apk-store-builder.js +97 -97
  8. package/files/buildCodeplay/codeplayBeforeBuild.js +4793 -4793
  9. package/files/buildCodeplay/disabled-ads.mjs +53 -53
  10. package/files/buildCodeplay/ensure-current-build.cjs +42 -42
  11. package/files/buildCodeplay/fix-onesignal-plugin.js +96 -96
  12. package/files/buildCodeplay/huawei-privacy-entry.js +135 -135
  13. package/files/buildCodeplay/huawei-privacy.cjs +102 -92
  14. package/files/buildCodeplay/huawei-privacy.css +22 -22
  15. package/files/buildCodeplay/iap-alias.cjs +116 -116
  16. package/files/buildCodeplay/ios-ad-consent.cjs +56 -56
  17. package/files/buildCodeplay/ios-emi-admob-modification.js +49 -49
  18. package/files/buildCodeplay/manifestModification.js +38 -38
  19. package/files/buildCodeplay/migrate-system-bars.cjs +122 -122
  20. package/files/buildCodeplay/newly added.txt +89 -89
  21. package/files/buildCodeplay/non-google-billing.pro +3 -3
  22. package/files/buildCodeplay/packageidBaseModification.js +528 -528
  23. package/files/buildCodeplay/project-scripts.cjs +69 -69
  24. package/files/buildCodeplay/release-sync.config.json +4 -4
  25. package/files/buildCodeplay/remove-force-kotlin-disable.js +43 -43
  26. package/files/buildCodeplay/ruads.cjs +220 -211
  27. package/files/buildCodeplay/saf-mediastore-dependency.cjs +21 -21
  28. package/files/buildCodeplay/setSplashAnimation.js +226 -226
  29. package/files/buildCodeplay/setup-ruads.cjs +62 -55
  30. package/files/buildCodeplay/splashxml/codeplay_splashScreen.xml +11 -11
  31. package/files/buildCodeplay/store-billing.cjs +43 -43
  32. package/files/buildCodeplay/sync-admob-nextgen.js +219 -219
  33. package/files/buildCodeplay/tests/huawei-live-reload.test.cjs +60 -0
  34. package/files/buildCodeplay/tests/huawei-multiple-entries.test.cjs +80 -0
  35. package/files/buildCodeplay/tests/huawei-privacy.test.cjs +49 -49
  36. package/files/buildCodeplay/tests/huawei-vite.test.cjs +38 -35
  37. package/files/buildCodeplay/versions.json +28 -28
  38. package/files/finalrelease +1365 -1365
  39. package/files/generate-ai-promo-video.js +23 -23
  40. package/files/ionic.config.json +6 -6
  41. package/files/scripts-common/collect-startup-profile.js +134 -0
  42. package/files/scripts-common/generate-baseline-profile.js +194 -22
  43. package/files/scripts-common/run-codeplay-sync-after.js +21 -21
  44. package/files/scripts-common/screenshot/background-decorations.js +120 -120
  45. package/files/scripts-common/screenshot/frame-samples.js +117 -117
  46. package/files/scripts-common/setup-baseline-profile.js +291 -291
  47. package/files/take-screen-image.js +4414 -4414
  48. package/files/take-screen-video.js +644 -644
  49. package/package.json +29 -29
  50. package/runtime/vk-ads/vk-ad-configuration.json +39 -39
  51. package/scripts/baseline-profile.test.cjs +189 -0
  52. package/scripts/ensure-current-build.test.cjs +76 -76
  53. package/scripts/iap-alias.test.cjs +117 -117
  54. package/scripts/ios-ad-consent.test.cjs +99 -99
  55. package/scripts/ruads-install.test.cjs +197 -180
  56. package/scripts/ruads-policy.test.cjs +174 -174
  57. package/scripts/saf-mediastore-dependency.test.cjs +44 -44
  58. package/scripts/squeezeback-config.test.cjs +78 -78
  59. package/scripts/sync-files.js +120 -120
  60. package/scripts/system-bars-package.test.cjs +38 -38
  61. package/scripts/system-bars.test.cjs +93 -93
  62. package/scripts/uninstall.js +2 -2
  63. package/scripts/vite-build-settings.test.cjs +93 -92
@@ -1,228 +1,228 @@
1
- const fs = require('fs');
2
- const readline = require('readline');
1
+ const fs = require('fs');
2
+ const readline = require('readline');
3
3
  const path = require('path');
4
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
- }
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
+ }
@@ -1,55 +1,62 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
-
4
- function syncRuAdsSetup(projectRoot, { runtimeRoot } = {}) {
5
- const config = JSON.parse(fs.readFileSync(path.join(projectRoot, 'capacitor.config.json')));
6
- const vite = ['vite.config.mjs', 'vite.config.js'].map(name => path.join(projectRoot, name)).find(file => fs.existsSync(file));
7
- if (vite) {
8
- const source = fs.readFileSync(vite, 'utf8');
9
- if (!source.includes('ruAdsBuild.controllerPath(') && !source.includes('codeplayOriginalViteConfig')) {
10
- if (!/^[ \t]*export\s+default\s+/m.test(source)) throw new Error('Cannot configure RuAds: Vite must have a default configuration export.');
11
- const wrapped = source.replace(/^[ \t]*export\s+default\s+/m, 'const codeplayOriginalViteConfig = ');
12
- fs.writeFileSync(vite, `import ruAdsBuild from './buildCodeplay/ruads.cjs';
13
- import { readFileSync as codeplayReadConfig } from 'node:fs';
14
- import { resolve as codeplayResolve } from 'node:path';
15
- ${wrapped}
16
- export default async (environment) => {
17
- const base = await (typeof codeplayOriginalViteConfig === 'function'
18
- ? codeplayOriginalViteConfig(environment) : codeplayOriginalViteConfig);
19
- const settings = JSON.parse(codeplayReadConfig(codeplayResolve('capacitor.config.json'), 'utf8'));
20
- const storeId = process.env.VITE_STORE_ID || '1';
21
- const platform = process.env.CODEPLAY_BUILD_PLATFORM || (storeId === '6' ? 'ios' : 'android');
22
- const aliases = base.resolve?.alias || {};
23
- const current = Array.isArray(aliases) ? aliases.find(item => item.find === '@admob')?.replacement : aliases['@admob'];
24
- const provider = ruAdsBuild.getAdProvider(settings, storeId, platform);
25
- if (!current && provider === 'vk') {
26
- throw new Error('VK ads requires the shared @admob alias. Update this app integration first.');
27
- }
28
- const selected = current && (provider === 'admob' ? current : codeplayResolve(ruAdsBuild.controllerPath(settings, storeId, platform, current)));
29
- const alias = !selected ? aliases : Array.isArray(aliases)
30
- ? aliases.map(item => item.find === '@admob' ? { ...item, replacement: selected } : item)
31
- : { ...aliases, '@admob': selected };
32
- return { ...base, plugins: [...(base.plugins || []), ruAdsBuild.admobConfigPlugin(provider)], resolve: { ...base.resolve, alias }, define: { ...base.define,
33
- 'import.meta.env.VITE_STORE_ID': JSON.stringify(storeId),
34
- 'import.meta.env.VITE_RUADS_ENABLED': JSON.stringify(provider === 'vk') } };
35
- };
36
- `);
37
- }
38
- const current = fs.readFileSync(vite, 'utf8');
39
- if (current.includes('codeplayOriginalViteConfig') && !current.includes('ruAdsBuild.admobConfigPlugin(')) {
40
- const updated = current.replace('return { ...base, resolve:', 'return { ...base, plugins: [...(base.plugins || []), ruAdsBuild.admobConfigPlugin(provider)], resolve:');
41
- if (updated === current) throw new Error('Cannot install store AdMob config filtering in the Vite wrapper.');
42
- fs.writeFileSync(vite, updated);
43
- }
44
- }
45
- const ru = config.plugins?.RuAds;
46
- if (ru?.VK_ADS_ENABLED !== true || !(ru.STORE_IDS || []).some(id => [4, 10].includes(Number(id)))) return;
47
- const ads = path.join(projectRoot, 'src/js/Ads');
48
- const configuration = path.join(ads, 'vk-ad-configuration.json');
49
- if (fs.existsSync(configuration)) return;
50
- const runtime = runtimeRoot || path.join(projectRoot, 'node_modules/codeplay-common/runtime/vk-ads');
51
- fs.mkdirSync(ads, { recursive: true });
52
- fs.copyFileSync(path.join(runtime, 'vk-ad-configuration.json'), configuration);
53
- }
54
-
55
- module.exports = { syncRuAdsSetup };
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+
4
+ function syncRuAdsSetup(projectRoot, { runtimeRoot } = {}) {
5
+ const config = JSON.parse(fs.readFileSync(path.join(projectRoot, 'capacitor.config.json')));
6
+ const vite = ['vite.config.mjs', 'vite.config.js'].map(name => path.join(projectRoot, name)).find(file => fs.existsSync(file));
7
+ if (vite) {
8
+ const source = fs.readFileSync(vite, 'utf8');
9
+ if (!source.includes('ruAdsBuild.controllerPath(') && !source.includes('codeplayOriginalViteConfig')) {
10
+ if (!/^[ \t]*export\s+default\s+/m.test(source)) throw new Error('Cannot configure RuAds: Vite must have a default configuration export.');
11
+ const wrapped = source.replace(/^[ \t]*export\s+default\s+/m, 'const codeplayOriginalViteConfig = ');
12
+ fs.writeFileSync(vite, `import ruAdsBuild from './buildCodeplay/ruads.cjs';
13
+ import { readFileSync as codeplayReadConfig } from 'node:fs';
14
+ import { resolve as codeplayResolve } from 'node:path';
15
+ ${wrapped}
16
+ export default async (environment) => {
17
+ const base = await (typeof codeplayOriginalViteConfig === 'function'
18
+ ? codeplayOriginalViteConfig(environment) : codeplayOriginalViteConfig);
19
+ const settings = JSON.parse(codeplayReadConfig(codeplayResolve('capacitor.config.json'), 'utf8'));
20
+ const storeId = process.env.VITE_STORE_ID || '1';
21
+ const platform = process.env.CODEPLAY_BUILD_PLATFORM || (storeId === '6' ? 'ios' : 'android');
22
+ const aliases = ruAdsBuild.withBuildCodeplayAlias(base.resolve?.alias || {}, codeplayResolve('buildCodeplay'));
23
+ const current = Array.isArray(aliases) ? aliases.find(item => item.find === '@admob')?.replacement : aliases['@admob'];
24
+ const provider = ruAdsBuild.getAdProvider(settings, storeId, platform);
25
+ if (!current && provider === 'vk') {
26
+ throw new Error('VK ads requires the shared @admob alias. Update this app integration first.');
27
+ }
28
+ const selected = current && (provider === 'admob' ? current : codeplayResolve(ruAdsBuild.controllerPath(settings, storeId, platform, current)));
29
+ const alias = !selected ? aliases : Array.isArray(aliases)
30
+ ? aliases.map(item => item.find === '@admob' ? { ...item, replacement: selected } : item)
31
+ : { ...aliases, '@admob': selected };
32
+ return { ...base, plugins: [...(base.plugins || []), ruAdsBuild.admobConfigPlugin(provider)], resolve: { ...base.resolve, alias }, define: { ...base.define,
33
+ 'import.meta.env.VITE_STORE_ID': JSON.stringify(storeId),
34
+ 'import.meta.env.VITE_RUADS_ENABLED': JSON.stringify(provider === 'vk') } };
35
+ };
36
+ `);
37
+ }
38
+ let current = fs.readFileSync(vite, 'utf8');
39
+ if (current.includes('codeplayOriginalViteConfig') && !current.includes('ruAdsBuild.withBuildCodeplayAlias(')) {
40
+ const updated = current.replace('const aliases = base.resolve?.alias || {};',
41
+ "const aliases = ruAdsBuild.withBuildCodeplayAlias(base.resolve?.alias || {}, codeplayResolve('buildCodeplay'));");
42
+ if (updated === current) throw new Error('Cannot install Huawei Live Reload path mapping in the Vite wrapper.');
43
+ fs.writeFileSync(vite, updated);
44
+ current = updated;
45
+ }
46
+ if (current.includes('codeplayOriginalViteConfig') && !current.includes('ruAdsBuild.admobConfigPlugin(')) {
47
+ const updated = current.replace('return { ...base, resolve:', 'return { ...base, plugins: [...(base.plugins || []), ruAdsBuild.admobConfigPlugin(provider)], resolve:');
48
+ if (updated === current) throw new Error('Cannot install store AdMob config filtering in the Vite wrapper.');
49
+ fs.writeFileSync(vite, updated);
50
+ }
51
+ }
52
+ const ru = config.plugins?.RuAds;
53
+ if (ru?.VK_ADS_ENABLED !== true || !(ru.STORE_IDS || []).some(id => [4, 10].includes(Number(id)))) return;
54
+ const ads = path.join(projectRoot, 'src/js/Ads');
55
+ const configuration = path.join(ads, 'vk-ad-configuration.json');
56
+ if (fs.existsSync(configuration)) return;
57
+ const runtime = runtimeRoot || path.join(projectRoot, 'node_modules/codeplay-common/runtime/vk-ads');
58
+ fs.mkdirSync(ads, { recursive: true });
59
+ fs.copyFileSync(path.join(runtime, 'vk-ad-configuration.json'), configuration);
60
+ }
61
+
62
+ module.exports = { syncRuAdsSetup };
@@ -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.DayNight.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.DayNight.NoActionBar</item>
10
+ </style>
11
+ </resources>