|
@@ -8,12 +8,15 @@ import android.view.View;
|
|
|
import android.view.Window;
|
|
|
import android.webkit.ValueCallback;
|
|
|
import android.webkit.WebView;
|
|
|
-
|
|
|
+import com.getcapacitor.PluginCall;
|
|
|
+import com.getcapacitor.JSObject;
|
|
|
import com.getcapacitor.BridgeActivity;
|
|
|
|
|
|
import java.util.Timer;
|
|
|
import java.util.TimerTask;
|
|
|
|
|
|
+import ee.forgr.capacitor_navigation_bar.NavigationBarPlugin;
|
|
|
+
|
|
|
public class MainActivity extends BridgeActivity {
|
|
|
@Override
|
|
|
public void onCreate(Bundle savedInstanceState) {
|
|
@@ -26,7 +29,7 @@ public class MainActivity extends BridgeActivity {
|
|
|
webView.getSettings().setUseWideViewPort(true);
|
|
|
webView.getSettings().setLoadWithOverviewMode(true);
|
|
|
|
|
|
- setNavigationBarColorBasedOnTheme();
|
|
|
+ // initNavigationBarBgColor();
|
|
|
|
|
|
new Timer().schedule(new TimerTask() {
|
|
|
@Override
|
|
@@ -41,6 +44,15 @@ public class MainActivity extends BridgeActivity {
|
|
|
}, 5000);
|
|
|
}
|
|
|
|
|
|
+ public void initNavigationBarBgColor() {
|
|
|
+ NavigationBarPlugin navigationBarPlugin = new NavigationBarPlugin();
|
|
|
+ JSObject data = new JSObject();
|
|
|
+ data.put("color", "transparent");
|
|
|
+
|
|
|
+ PluginCall call = new PluginCall(null, null, null, "t", data);
|
|
|
+ navigationBarPlugin.setNavigationBarColor(call);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void onPause() {
|
|
|
overridePendingTransition(0, R.anim.byebye);
|
|
@@ -62,22 +74,4 @@ public class MainActivity extends BridgeActivity {
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- private void setNavigationBarColorBasedOnTheme() {
|
|
|
- Window window = getWindow();
|
|
|
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { // API 26及以上支持
|
|
|
- // 根据主题选择颜色
|
|
|
- int navBarColor = isDarkMode()
|
|
|
- ? getResources().getColor(R.color.colorPrimaryDark, getTheme())
|
|
|
- : getResources().getColor(R.color.colorPrimary, getTheme());
|
|
|
-
|
|
|
- // 设置导航栏颜色
|
|
|
- window.setNavigationBarColor(navBarColor);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private boolean isDarkMode() {
|
|
|
- int nightModeFlags = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
|
|
|
- return nightModeFlags == Configuration.UI_MODE_NIGHT_YES;
|
|
|
- }
|
|
|
}
|