Backed out changeset 3761b11b90f0 (
bug 970247) for robocop NPEs (again).
CLOSED TREE
--- a/mobile/android/base/BrowserApp.java
+++ b/mobile/android/base/BrowserApp.java
@@ -2252,17 +2252,17 @@ abstract public class BrowserApp extends
tab = Tabs.getInstance().getSelectedTab();
if (tab != null) {
if (item.isChecked()) {
tab.removeBookmark();
Toast.makeText(this, R.string.bookmark_removed, Toast.LENGTH_SHORT).show();
item.setIcon(R.drawable.ic_menu_bookmark_add);
} else {
tab.addBookmark();
- getButtonToast().show(false,
+ mToast.show(false,
getResources().getString(R.string.bookmark_added),
getResources().getString(R.string.bookmark_options),
null,
new ButtonToast.ToastListener() {
@Override
public void onButtonClicked() {
showBookmarkDialog();
}
--- a/mobile/android/base/GeckoApp.java
+++ b/mobile/android/base/GeckoApp.java
@@ -88,17 +88,16 @@ import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.OrientationEventListener;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.TextureView;
import android.view.View;
import android.view.ViewGroup;
-import android.view.ViewStub;
import android.view.Window;
import android.view.WindowManager;
import android.widget.AbsoluteLayout;
import android.widget.FrameLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.SimpleAdapter;
import android.widget.TextView;
@@ -817,36 +816,25 @@ public abstract class GeckoApp
} else {
toast = Toast.makeText(GeckoApp.this, message, Toast.LENGTH_SHORT);
}
toast.show();
}
});
}
- protected ButtonToast getButtonToast() {
- if (mToast != null) {
- return mToast;
- }
-
- ViewStub toastStub = (ViewStub) findViewById(R.id.toast_stub);
- mToast = new ButtonToast(toastStub.inflate());
-
- return mToast;
- }
-
void showButtonToast(final String message, final String buttonText,
final String buttonIcon, final String buttonId) {
BitmapUtils.getDrawable(GeckoApp.this, buttonIcon, new BitmapUtils.BitmapLoader() {
public void onBitmapFound(final Drawable d) {
ThreadUtils.postToUiThread(new Runnable() {
@Override
public void run() {
- getButtonToast().show(false, message, buttonText, d, new ButtonToast.ToastListener() {
+ mToast.show(false, message, buttonText, d, new ButtonToast.ToastListener() {
@Override
public void onButtonClicked() {
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Toast:Click", buttonId));
}
@Override
public void onToastHidden(ButtonToast.ReasonHidden reason) {
if (reason == ButtonToast.ReasonHidden.TIMEOUT) {
@@ -1255,16 +1243,18 @@ public abstract class GeckoApp
mOrientation = getResources().getConfiguration().orientation;
setContentView(getLayout());
// Set up Gecko layout.
mGeckoLayout = (RelativeLayout) findViewById(R.id.gecko_layout);
mMainLayout = (RelativeLayout) findViewById(R.id.main_layout);
+ mToast = new ButtonToast(findViewById(R.id.toast));
+
// Determine whether we should restore tabs.
mShouldRestore = getSessionRestoreState(savedInstanceState);
if (mShouldRestore && savedInstanceState != null) {
boolean wasInBackground =
savedInstanceState.getBoolean(SAVED_STATE_IN_BACKGROUND, false);
// Don't log OOM-kills if only one activity was destroyed. (For example
// from "Don't keep activities" on ICS)
deleted file mode 100644
--- a/mobile/android/base/resources/layout/button_toast.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- This Source Code Form is subject to the terms of the Mozilla Public
- - License, v. 2.0. If a copy of the MPL was not distributed with this
- - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/toast"
- style="@style/Toast">
-
- <TextView android:id="@+id/toast_message"
- style="@style/ToastMessage" />
-
- <ImageView android:id="@+id/toast_divider"
- style="@style/ToastDivider" />
-
- <Button android:id="@+id/toast_button"
- style="@style/ToastButton" />
-
-</LinearLayout>
--- a/mobile/android/base/resources/layout/gecko_app.xml
+++ b/mobile/android/base/resources/layout/gecko_app.xml
@@ -93,13 +93,23 @@
android:layout_height="fill_parent"
android:layout_width="fill_parent"
style="@style/GeckoActionBar"/>
</org.mozilla.gecko.widget.GeckoViewFlipper>
</view>
- <ViewStub android:id="@+id/toast_stub"
- android:layout="@layout/button_toast"
- style="@style/Toast"/>
+ <LinearLayout android:id="@+id/toast"
+ style="@style/Toast">
+
+ <TextView android:id="@+id/toast_message"
+ style="@style/ToastMessage" />
+
+ <ImageView android:id="@+id/toast_divider"
+ style="@style/ToastDivider" />
+
+ <Button android:id="@+id/toast_button"
+ style="@style/ToastButton" />
+
+ </LinearLayout>
</RelativeLayout>
--- a/mobile/android/base/resources/layout/web_app.xml
+++ b/mobile/android/base/resources/layout/web_app.xml
@@ -48,13 +48,23 @@
android:layout_alignParentBottom="true"
android:paddingBottom="30dip"
android:visibility="gone"/>
</RelativeLayout>
</RelativeLayout>
- <ViewStub android:id="@+id/toast_stub"
- android:layout="@layout/button_toast"
- style="@style/Toast"/>
+ <LinearLayout android:id="@+id/toast"
+ style="@style/Toast">
+
+ <TextView android:id="@+id/toast_message"
+ style="@style/ToastMessage" />
+
+ <ImageView android:id="@+id/toast_divider"
+ style="@style/ToastDivider" />
+
+ <Button android:id="@+id/toast_button"
+ style="@style/ToastButton" />
+
+ </LinearLayout>
</RelativeLayout>