@@ -1686,56 +1686,21 @@ private void removeShortcut(String id, CallbackContext callback) {
16861686 }
16871687
16881688 private void setUiTheme (
1689- final String systemBarColor ,
1690- final JSONObject scheme ,
1691- final CallbackContext callback
1689+ final String systemBarColor ,
1690+ final JSONObject scheme ,
1691+ final CallbackContext callback
16921692 ) {
1693- this .systemBarColor = Color .parseColor (systemBarColor );
1694- preferences .set ("BackgroundColor" , String .format ("0x%08X" , this .systemBarColor ));
1695- this .theme = new Theme (scheme );
1696-
1697- final Window window = activity .getWindow ();
1698-
1699- // Method and constants not available on all SDKs but we want to be able to compile this code with any SDK
1700- window .clearFlags (0x04000000 ); // SDK 19: WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
1701- window .addFlags (0x80000000 ); // SDK 21: WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
17021693 try {
1703- // Using reflection makes sure any 5.0+ device will work without having to compile with SDK level 21
1704-
1705- window
1706- .getClass ()
1707- .getMethod ("setNavigationBarColor" , int .class )
1708- .invoke (window , this .systemBarColor );
1709-
1710- window
1711- .getClass ()
1712- .getMethod ("setStatusBarColor" , int .class )
1713- .invoke (window , this .systemBarColor );
1694+ this .systemBarColor = Color .parseColor (systemBarColor );
1695+ this .theme = new Theme (scheme );
1696+
1697+ preferences .set ("BackgroundColor" , String .format ("0x%08X" , this .systemBarColor ));
17141698
1715- window . getDecorView ().setBackgroundColor ( this . systemBarColor );
1699+ webView . getPluginManager ().postMessage ( "updateSystemBars" , null );
17161700
1717- if (Build .VERSION .SDK_INT < 30 ) {
1718- setStatusBarStyle (window );
1719- setNavigationBarStyle (window );
1720- } else {
1721- String themeType = theme .getType ();
1722- WindowInsetsController controller = window .getInsetsController ();
1723- int appearance =
1724- WindowInsetsController .APPEARANCE_LIGHT_STATUS_BARS |
1725- WindowInsetsController .APPEARANCE_LIGHT_NAVIGATION_BARS ;
1726-
1727- if (themeType .equals ("light" )) {
1728- controller .setSystemBarsAppearance (appearance , appearance );
1729- } else {
1730- controller .setSystemBarsAppearance (0 , appearance );
1731- }
1732- }
1733-
1734- callback .success ("OK" );
1735- } catch (IllegalArgumentException error ) {
1736- callback .error (error .toString ());
1737- } catch (Exception error ) {
1738- callback .error (error .toString ());
1701+ callback .success ();
1702+ } catch (IllegalArgumentException e ) {
1703+ callback .error ("Invalid color: " + systemBarColor );
17391704 }
17401705 }
17411706
0 commit comments