|
11 | 11 | import android.widget.Toast; |
12 | 12 |
|
13 | 13 | import androidx.annotation.Keep; |
| 14 | +import androidx.annotation.RequiresApi; |
14 | 15 | import androidx.appcompat.app.AlertDialog; |
15 | 16 | import androidx.core.graphics.ColorUtils; |
16 | 17 |
|
@@ -58,7 +59,7 @@ void forceQuitRaw(String error) { |
58 | 59 | } |
59 | 60 |
|
60 | 61 | void openNativeModuleDialogRaw(String moduleUrl, String installTitle, |
61 | | - String checksum, boolean canInstall) { |
| 62 | + String checksum, boolean canInstall) { |
62 | 63 | this.downloadMode = false; |
63 | 64 | RepoModule repoModule = RepoManager.getINSTANCE() |
64 | 65 | .getAndroidacyRepoData().moduleHashMap.get(installTitle); |
@@ -210,7 +211,7 @@ public boolean canInstall() { |
210 | 211 | * install a module via url, with the file checked with the md5 checksum value. |
211 | 212 | */ |
212 | 213 | @JavascriptInterface |
213 | | - public void install(String moduleUrl, String installTitle,String checksum) { |
| 214 | + public void install(String moduleUrl, String installTitle, String checksum) { |
214 | 215 | // If compat mode is 0, this means Androidacy didn't implemented a download mode yet |
215 | 216 | if (this.consumedAction || (this.effectiveCompatMode >= 1 && !this.canInstall())) { |
216 | 217 | return; |
@@ -479,6 +480,26 @@ public int getBackgroundColor() { |
479 | 480 | return typedValue.data; |
480 | 481 | } |
481 | 482 |
|
| 483 | + /** |
| 484 | + * Return current hex string of monet theme |
| 485 | + */ |
| 486 | + @RequiresApi(api = Build.VERSION_CODES.M) |
| 487 | + @JavascriptInterface |
| 488 | + public String getMonetColor(String id) { |
| 489 | + int nameResourceID = this.activity.getResources().getIdentifier("@android:color/" + id, |
| 490 | + "color", this.activity.getApplicationInfo().packageName); |
| 491 | + if (nameResourceID == 0) { |
| 492 | + throw new IllegalArgumentException( |
| 493 | + "No resource string found with name " + id); |
| 494 | + } else { |
| 495 | + int color = this.activity.getColor(nameResourceID); |
| 496 | + int red = Color.red(color); |
| 497 | + int blue = Color.blue(color); |
| 498 | + int green = Color.green(color); |
| 499 | + return String.format("#%02x%02x%02x", red, green, blue); |
| 500 | + } |
| 501 | + } |
| 502 | + |
482 | 503 | // Androidacy feature level declaration method |
483 | 504 |
|
484 | 505 | @JavascriptInterface |
|
0 commit comments