diff --git a/doric-android/doric/src/main/java/pub/doric/navbar/BaseDoricNavBar.java b/doric-android/doric/src/main/java/pub/doric/navbar/BaseDoricNavBar.java index 70d8bc3b..e2580df7 100644 --- a/doric-android/doric/src/main/java/pub/doric/navbar/BaseDoricNavBar.java +++ b/doric-android/doric/src/main/java/pub/doric/navbar/BaseDoricNavBar.java @@ -17,18 +17,22 @@ package pub.doric.navbar; import android.app.Activity; import android.content.Context; +import android.graphics.Color; +import android.os.Build; import android.text.Layout; import android.text.StaticLayout; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.view.WindowManager; import android.widget.FrameLayout; import android.widget.TextView; import androidx.annotation.AttrRes; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; import pub.doric.R; @@ -84,6 +88,17 @@ public class BaseDoricNavBar extends FrameLayout implements IDoricNavBar { @Override public void setHidden(boolean b) { setVisibility(b ? GONE : VISIBLE); + AppCompatActivity activity = (AppCompatActivity) getContext(); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + if (b) { + activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + activity.getWindow().setStatusBarColor(Color.TRANSPARENT); + } + } else { + activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); + } + } } @Override diff --git a/doric-android/doric/src/main/java/pub/doric/plugin/NavBarPlugin.java b/doric-android/doric/src/main/java/pub/doric/plugin/NavBarPlugin.java index c771df8a..4cc0af15 100644 --- a/doric-android/doric/src/main/java/pub/doric/plugin/NavBarPlugin.java +++ b/doric-android/doric/src/main/java/pub/doric/plugin/NavBarPlugin.java @@ -72,16 +72,6 @@ public class NavBarPlugin extends DoricJavaPlugin { JSObject jsObject = jsDecoder.decode().asObject(); boolean hidden = jsObject.getProperty("hidden").asBoolean().value(); navBar.setHidden(hidden); - - AppCompatActivity activity = ((AppCompatActivity) getDoricContext().getContext()); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - if (hidden) { - activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); - } else { - activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); - } - } - promise.resolve(); } catch (ArchiveException e) { e.printStackTrace();