Add theme color API
parent
01d4bd8489
commit
942a1eee2e
|
@ -1,6 +1,12 @@
|
||||||
package gallery.memories;
|
package gallery.memories;
|
||||||
|
|
||||||
|
import static android.view.WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.Window;
|
||||||
import android.webkit.JavascriptInterface;
|
import android.webkit.JavascriptInterface;
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
|
|
||||||
|
@ -27,6 +33,23 @@ public class NativeX {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JavascriptInterface
|
||||||
|
public void setThemeColor(final String color, final boolean isDark) {
|
||||||
|
Window window = mActivity.getWindow();
|
||||||
|
|
||||||
|
mActivity.setTheme(isDark
|
||||||
|
? android.R.style.Theme_Black
|
||||||
|
: android.R.style.Theme_Light);
|
||||||
|
window.setNavigationBarColor(Color.parseColor(color));
|
||||||
|
window.setStatusBarColor(Color.parseColor(color));
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||||
|
window.getInsetsController().setSystemBarsAppearance(isDark ? 0 : APPEARANCE_LIGHT_STATUS_BARS, APPEARANCE_LIGHT_STATUS_BARS);
|
||||||
|
} else {
|
||||||
|
window.getDecorView().setSystemUiVisibility(isDark ? 0 : View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@JavascriptInterface
|
@JavascriptInterface
|
||||||
public void getLocalDays(final String call, final long _ignore) {
|
public void getLocalDays(final String call, final long _ignore) {
|
||||||
mJsService.runAsync(call, () -> mQuery.getDays().toString().getBytes());
|
mJsService.runAsync(call, () -> mQuery.getDays().toString().getBytes());
|
||||||
|
|
Loading…
Reference in New Issue