Add monet theme engine to WebAPI

pull/27/head
DerGoogler 3 years ago
parent 7757f6f892
commit b9058ef996

@ -11,6 +11,7 @@ import android.widget.Button;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.Keep; import androidx.annotation.Keep;
import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
import androidx.core.graphics.ColorUtils; import androidx.core.graphics.ColorUtils;
@ -479,6 +480,26 @@ public class AndroidacyWebAPI {
return typedValue.data; return typedValue.data;
} }
/**
* Return current hex string of monet theme
*/
@RequiresApi(api = Build.VERSION_CODES.M)
@JavascriptInterface
public String getMonetColor(String id) {
int nameResourceID = this.activity.getResources().getIdentifier("@android:color/" + id,
"color", this.activity.getApplicationInfo().packageName);
if (nameResourceID == 0) {
throw new IllegalArgumentException(
"No resource string found with name " + id);
} else {
int color = this.activity.getColor(nameResourceID);
int red = Color.red(color);
int blue = Color.blue(color);
int green = Color.green(color);
return String.format("#%02x%02x%02x", red, green, blue);
}
}
// Androidacy feature level declaration method // Androidacy feature level declaration method
@JavascriptInterface @JavascriptInterface

Loading…
Cancel
Save