Skip to content
This repository was archived by the owner on May 4, 2023. It is now read-only.

Commit b9058ef

Browse files
author
DerGoogler
committed
Add monet theme engine to WebAPI
1 parent 7757f6f commit b9058ef

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

app/src/main/java/com/fox2code/mmm/androidacy/AndroidacyWebAPI.java

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import android.widget.Toast;
1212

1313
import androidx.annotation.Keep;
14+
import androidx.annotation.RequiresApi;
1415
import androidx.appcompat.app.AlertDialog;
1516
import androidx.core.graphics.ColorUtils;
1617

@@ -58,7 +59,7 @@ void forceQuitRaw(String error) {
5859
}
5960

6061
void openNativeModuleDialogRaw(String moduleUrl, String installTitle,
61-
String checksum, boolean canInstall) {
62+
String checksum, boolean canInstall) {
6263
this.downloadMode = false;
6364
RepoModule repoModule = RepoManager.getINSTANCE()
6465
.getAndroidacyRepoData().moduleHashMap.get(installTitle);
@@ -210,7 +211,7 @@ public boolean canInstall() {
210211
* install a module via url, with the file checked with the md5 checksum value.
211212
*/
212213
@JavascriptInterface
213-
public void install(String moduleUrl, String installTitle,String checksum) {
214+
public void install(String moduleUrl, String installTitle, String checksum) {
214215
// If compat mode is 0, this means Androidacy didn't implemented a download mode yet
215216
if (this.consumedAction || (this.effectiveCompatMode >= 1 && !this.canInstall())) {
216217
return;
@@ -479,6 +480,26 @@ public int getBackgroundColor() {
479480
return typedValue.data;
480481
}
481482

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+
482503
// Androidacy feature level declaration method
483504

484505
@JavascriptInterface

0 commit comments

Comments
 (0)