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

Commit ca9f8dc

Browse files
committed
Make getMonetColor compatible with all Android versions.
1 parent 7f9adf4 commit ca9f8dc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import androidx.annotation.Keep;
1414
import androidx.annotation.RequiresApi;
1515
import androidx.appcompat.app.AlertDialog;
16+
import androidx.core.content.ContextCompat;
1617
import androidx.core.graphics.ColorUtils;
1718

1819
import com.fox2code.mmm.BuildConfig;
@@ -483,7 +484,6 @@ public int getBackgroundColor() {
483484
/**
484485
* Return current hex string of monet theme
485486
*/
486-
@RequiresApi(api = Build.VERSION_CODES.M)
487487
@JavascriptInterface
488488
public String getMonetColor(String id) {
489489
int nameResourceID = this.activity.getResources().getIdentifier("@android:color/" + id,
@@ -492,7 +492,7 @@ public String getMonetColor(String id) {
492492
throw new IllegalArgumentException(
493493
"No resource string found with name " + id);
494494
} else {
495-
int color = this.activity.getColor(nameResourceID);
495+
int color = ContextCompat.getColor(this.activity, nameResourceID);
496496
int red = Color.red(color);
497497
int blue = Color.blue(color);
498498
int green = Color.green(color);

0 commit comments

Comments
 (0)