Skip to content

Commit 3a78ad2

Browse files
authored
Update ads plugin and fix some issues of free version (#1683)
* Update AdMob plugin and build preferences Upgraded admob-plus-cordova to version 2.0.0-alpha.19 and updated PLAY_SERVICES_VERSION to 23.2.0 in utils/config.js. Changed the clean command from 'yarn clean' to 'npm run clean'. Added GradlePluginKotlinEnabled preference to config.xml for improved Android build compatibility. * fix: system theme on free version * Add dynamic resource resolution for styles and icons
1 parent b12eec6 commit 3a78ad2

File tree

5 files changed

+42
-17
lines changed

5 files changed

+42
-17
lines changed

config.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@
3232
<preference name="AndroidLaunchMode" value="singleTask" />
3333
<preference name="prerendered-icon" value="false" />
3434
<preference name="androidxEnabled" value="true" />
35+
<preference name="GradlePluginKotlinEnabled" value="true" />
3536
<preference name="android-targetSdkVersion" value="35" />
3637

37-
38+
3839
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
3940
<application android:networkSecurityConfig="@xml/network_security_config" />
4041
<application android:hardwareAccelerated="true" />

src/lib/settings.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,10 @@ class Settings {
185185
if (this.#initialized) return;
186186
this.settingsFile = Url.join(DATA_STORAGE, "settings.json");
187187

188-
if (!IS_FREE_VERSION) {
189-
this.#defaultSettings.appTheme = "system";
190-
this.#defaultSettings.editorTheme = getSystemEditorTheme(
191-
isDeviceDarkTheme(),
192-
);
193-
}
188+
this.#defaultSettings.appTheme = "system";
189+
this.#defaultSettings.editorTheme = getSystemEditorTheme(
190+
isDeviceDarkTheme(),
191+
);
194192

195193
this.#initialized = true;
196194

src/plugins/terminal/src/android/AlpineDocumentProvider.java

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import java.util.Collections;
2020
import java.util.LinkedList;
2121
import java.util.Locale;
22-
import com.foxdebug.acode.R;
2322

2423
public class AlpineDocumentProvider extends DocumentsProvider {
2524

@@ -60,7 +59,7 @@ public Cursor queryRoots(String[] projection) {
6059
MatrixCursor result = new MatrixCursor(
6160
projection != null ? projection : DEFAULT_ROOT_PROJECTION
6261
);
63-
String applicationName = "Acode";
62+
String applicationName = getApplicationLabel();
6463

6564
MatrixCursor.RowBuilder row = result.newRow();
6665
row.add(DocumentsContract.Root.COLUMN_ROOT_ID, getDocIdForFile(BASE_DIR));
@@ -75,7 +74,7 @@ public Cursor queryRoots(String[] projection) {
7574
row.add(DocumentsContract.Root.COLUMN_TITLE, applicationName);
7675
row.add(DocumentsContract.Root.COLUMN_MIME_TYPES, ALL_MIME_TYPES);
7776
row.add(DocumentsContract.Root.COLUMN_AVAILABLE_BYTES, BASE_DIR.getFreeSpace());
78-
row.add(DocumentsContract.Root.COLUMN_ICON, R.mipmap.ic_launcher);
77+
row.add(DocumentsContract.Root.COLUMN_ICON, resolveLauncherIcon());
7978
return result;
8079
}
8180

@@ -364,4 +363,22 @@ private static String getMimeType(File file) {
364363
return "application/octet-stream";
365364
}
366365
}
366+
private int resolveLauncherIcon() {
367+
Context context = getContext();
368+
if (context == null) return android.R.mipmap.sym_def_app_icon;
369+
int icon = context.getResources().getIdentifier("ic_launcher", "mipmap", context.getPackageName());
370+
return icon != 0 ? icon : android.R.mipmap.sym_def_app_icon;
371+
}
372+
373+
private String getApplicationLabel() {
374+
Context context = getContext();
375+
if (context == null) return "Acode";
376+
PackageManager pm = context.getPackageManager();
377+
try {
378+
CharSequence label = pm.getApplicationLabel(context.getApplicationInfo());
379+
return label != null ? label.toString() : "Acode";
380+
} catch (Exception ignored) {
381+
return "Acode";
382+
}
383+
}
367384
}

src/plugins/terminal/src/android/TerminalService.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import android.os.PowerManager;
1717
import android.os.RemoteException;
1818
import androidx.core.app.NotificationCompat;
19-
import com.foxdebug.acode.R;
2019
import java.io.BufferedReader;
2120
import java.io.IOException;
2221
import java.io.InputStream;
@@ -360,13 +359,15 @@ private void updateNotification() {
360359
String contentText = "Executor service" + (isWakeLockHeld ? " (wakelock held)" : "");
361360
String wakeLockButtonText = isWakeLockHeld ? "Release Wake Lock" : "Acquire Wake Lock";
362361

362+
int notificationIcon = resolveDrawableId("ic_notification", "ic_launcher_foreground", "ic_launcher");
363+
363364
Notification notification = new NotificationCompat.Builder(this, CHANNEL_ID)
364365
.setContentTitle("Acode Service")
365366
.setContentText(contentText)
366-
.setSmallIcon(R.drawable.ic_launcher_foreground)
367+
.setSmallIcon(notificationIcon)
367368
.setOngoing(true)
368-
.addAction(R.drawable.ic_launcher_foreground, wakeLockButtonText, wakeLockPendingIntent)
369-
.addAction(R.drawable.ic_launcher_foreground, "Exit", exitPendingIntent)
369+
.addAction(notificationIcon, wakeLockButtonText, wakeLockPendingIntent)
370+
.addAction(notificationIcon, "Exit", exitPendingIntent)
370371
.build();
371372

372373
startForeground(1, notification);
@@ -390,4 +391,12 @@ public void onDestroy() {
390391
clientMessengers.clear();
391392
threadPool.shutdown();
392393
}
393-
}
394+
395+
private int resolveDrawableId(String... names) {
396+
for (String name : names) {
397+
int id = getResources().getIdentifier(name, "drawable", getPackageName());
398+
if (id != 0) return id;
399+
}
400+
return android.R.drawable.sym_def_app_icon;
401+
}
402+
}

utils/config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ const exec = promisify(require("node:child_process").exec);
8585
`cordova plugin add cordova-plugin-consent@2.4.0 --save`,
8686
);
8787
await exec(
88-
`cordova plugin add admob-plus-cordova@1.28.0 --save --variable APP_ID_ANDROID="${AD_APP_ID}" --variable PLAY_SERVICES_VERSION="21.5.0"`,
88+
`cordova plugin add admob-plus-cordova@2.0.0-alpha.19 --save --variable APP_ID_ANDROID="${AD_APP_ID}" --variable PLAY_SERVICES_VERSION="23.2.0"`,
8989
);
9090
console.log("DONE! Installing admob-plus-cordova");
9191
} else {
@@ -96,7 +96,7 @@ const exec = promisify(require("node:child_process").exec);
9696
}
9797

9898
console.log(`|--- Reinstalling platform ---|`);
99-
const { stderr } = await exec(`yarn clean`);
99+
const { stderr } = await exec(`npm run clean`);
100100
if (stderr) console.error(stderr);
101101
else console.log("DONE! Reinstalling platform");
102102
})(),

0 commit comments

Comments
 (0)