Bug 1390454 - Make Banner dialog status bar transparent. r?maliu draft
authorNevin Chen <cnevinchen@gmail.com>
Tue, 14 Nov 2017 15:06:18 +0800
changeset 698059 6182dca6b8ef5dbe7cd67ce4ba11a61be0cc022e
parent 698058 6f23f37839f3e33836b3ad33108ad95db3106989
child 698060 f4f9efef5a66125509e383295487460f3819d3a2
push id89188
push userbmo:cnevinchen@gmail.com
push dateWed, 15 Nov 2017 07:01:45 +0000
reviewersmaliu
bugs1390454
milestone58.0a1
Bug 1390454 - Make Banner dialog status bar transparent. r?maliu I didn't check if currently the app is using dark theme(LightweightTheme) or not. Cause that requires some hacky injection to let Leanplum SDK knows the status bar corlor or dark theme or not. MozReview-Commit-ID: 4Twe59Gw6mS
mobile/android/thirdparty/com/leanplum/messagetemplates/BaseMessageDialog.java
--- a/mobile/android/thirdparty/com/leanplum/messagetemplates/BaseMessageDialog.java
+++ b/mobile/android/thirdparty/com/leanplum/messagetemplates/BaseMessageDialog.java
@@ -27,16 +27,17 @@ import android.app.Dialog;
 import android.content.Context;
 import android.graphics.Color;
 import android.graphics.Point;
 import android.graphics.Typeface;
 import android.graphics.drawable.ShapeDrawable;
 import android.graphics.drawable.shapes.RoundRectShape;
 import android.graphics.drawable.shapes.Shape;
 import android.os.Build;
+import android.os.Bundle;
 import android.os.Handler;
 import android.text.TextUtils;
 import android.util.TypedValue;
 import android.view.Display;
 import android.view.Gravity;
 import android.view.MotionEvent;
 import android.view.View;
 import android.view.ViewGroup.LayoutParams;
@@ -79,16 +80,30 @@ public class BaseMessageDialog extends D
   protected HTMLOptions htmlOptions;
   protected Activity activity;
   protected WebView webView;
 
   private boolean isWeb = false;
   private boolean isHtml = false;
   private boolean isClosing = false;
 
+  @Override
+  protected void onCreate(Bundle savedInstanceState) {
+    super.onCreate(savedInstanceState);
+    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+      final Window window = getWindow();
+      window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
+      window.setStatusBarColor(Color.TRANSPARENT);
+
+      int flags = window.getDecorView().getSystemUiVisibility();
+      flags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
+      window.getDecorView().setSystemUiVisibility(flags);
+    }
+  }
+
   protected BaseMessageDialog(Activity activity, boolean fullscreen, BaseMessageOptions options,
       WebInterstitialOptions webOptions, HTMLOptions htmlOptions) {
     super(activity, getTheme(activity));
 
     SizeUtil.init(activity);
     this.activity = activity;
     this.options = options;
     this.webOptions = webOptions;