Bug 1293595 - Make doorhanger overlay visible by default, and retrieve it during onCreate r?sebastian
Retrieving the doorhanger during onAttachedToWindow seems to be unreliable, resulting in NPE's when
it doesn't work (the only logical explanation would be that onCreate hasn't been called yet, meaning
we don't have a layout yet). We should instead findViewById() it during onCreate, where the layout
is guaranteed to exist.
Since we show the overlay on all devices now, we can make it visible by default, whereas in the past
we had a condition to only enable it on > 2.3 devices.
MozReview-Commit-ID: 1DGVAPSX0mi
--- a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
@@ -670,16 +670,18 @@ public class BrowserApp extends GeckoApp
mBrowserSearch.setUserVisibleHint(false);
}
setBrowserToolbarListeners();
mFindInPageBar = (FindInPageBar) findViewById(R.id.find_in_page);
mMediaCastingBar = (MediaCastingBar) findViewById(R.id.media_casting);
+ mDoorhangerOverlay = findViewById(R.id.doorhanger_overlay);
+
EventDispatcher.getInstance().registerGeckoThreadListener((GeckoEventListener)this,
"Gecko:DelayedStartup",
"Menu:Open",
"Menu:Update",
"LightweightTheme:Update",
"Search:Keyword",
"Prompt:ShowTop",
"Video:Play");
@@ -965,19 +967,16 @@ public class BrowserApp extends GeckoApp
return;
}
super.onBackPressed();
}
@Override
public void onAttachedToWindow() {
- mDoorhangerOverlay = findViewById(R.id.doorhanger_overlay);
- mDoorhangerOverlay.setVisibility(View.VISIBLE);
-
// We can't show the first run experience until Gecko has finished initialization (bug 1077583).
checkFirstrun(this, new SafeIntent(getIntent()));
}
@Override
protected void processTabQueue() {
if (TabQueueHelper.TAB_QUEUE_ENABLED && mInitialized) {
ThreadUtils.postToBackgroundThread(new Runnable() {
--- a/mobile/android/base/resources/layout/gecko_app.xml
+++ b/mobile/android/base/resources/layout/gecko_app.xml
@@ -83,17 +83,16 @@
android:layout_height="match_parent"/>
</FrameLayout>
<View android:id="@+id/doorhanger_overlay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/dark_transparent_overlay"
- android:visibility="gone"
android:alpha="0"
android:layerType="hardware"/>
</RelativeLayout>
<org.mozilla.gecko.FindInPageBar android:id="@+id/find_in_page"
android:layout_width="match_parent"
android:layout_height="wrap_content"