Backed out changeset 59ef0d1d8616 (bug 884075) for Android 2.2 robocop-2 exceptions
authorEd Morley <emorley@mozilla.com>
Tue, 16 Jul 2013 12:00:26 +0100
changeset 138659 3b73e496a5c8b51e7dd1e690090c26ed6589f488
parent 138658 a5cd81c55a7a62b2ade9e1d6bc2f9833b62f10a8
child 138660 b1228ac77d92c9d9f84ddefc03c8229464bd07ef
push id24964
push userryanvm@gmail.com
push dateTue, 16 Jul 2013 20:04:09 +0000
treeherderautoland@fd10ead17ace [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs884075
milestone25.0a1
backs out59ef0d1d861667e99cc2edcd0af7a5e492e39f98
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset 59ef0d1d8616 (bug 884075) for Android 2.2 robocop-2 exceptions
mobile/android/base/BrowserApp.java
mobile/android/base/widget/ButtonToast.java
--- a/mobile/android/base/BrowserApp.java
+++ b/mobile/android/base/BrowserApp.java
@@ -390,17 +390,24 @@ abstract public class BrowserApp extends
     @Override
     public void onCreate(Bundle savedInstanceState) {
         mAboutHomeStartupTimer = new Telemetry.Timer("FENNEC_STARTUP_TIME_ABOUTHOME");
 
         super.onCreate(savedInstanceState);
 
         mBrowserToolbar = (BrowserToolbar) findViewById(R.id.browser_toolbar);
 
-        mToast = new ButtonToast(findViewById(R.id.toast));
+        mToast = new ButtonToast(findViewById(R.id.toast), new ButtonToast.ToastListener() {
+            @Override
+            public void onButtonClicked(CharSequence token) {
+                if (ADD_SHORTCUT_TOAST.equals(token)) {
+                    showBookmarkDialog();
+                }
+            }
+        });
 
         ((GeckoApp.MainLayout) mMainLayout).setTouchEventInterceptor(new HideTabsTouchListener());
         ((GeckoApp.MainLayout) mMainLayout).setMotionEventInterceptor(new MotionEventInterceptor() {
             @Override
             public boolean onInterceptMotionEvent(View view, MotionEvent event) {
                 // If we get a gamepad panning MotionEvent while the focus is not on the layerview,
                 // put the focus on the layerview and carry on
                 if (mLayerView != null && !mLayerView.hasFocus() && GamepadUtils.isPanningControl(event)) {
@@ -1687,25 +1694,20 @@ abstract public class BrowserApp extends
                 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();
                         mToast.show(false,
-                            getResources().getString(R.string.bookmark_added),
-                            getResources().getString(R.string.bookmark_options),
-                            0,
-                            new ButtonToast.ToastListener() {
-                                @Override
-                                public void onButtonClicked() {
-                                    showBookmarkDialog();
-                                }
-                            });
+                                    getResources().getString(R.string.bookmark_added),
+                                    getResources().getString(R.string.bookmark_options),
+                                    0,
+                                    ADD_SHORTCUT_TOAST);
                         item.setIcon(R.drawable.ic_menu_bookmark_remove);
                     }
                 }
                 return true;
             case R.id.share:
                 shareCurrentUrl();
                 return true;
             case R.id.reload:
--- a/mobile/android/base/widget/ButtonToast.java
+++ b/mobile/android/base/widget/ButtonToast.java
@@ -45,57 +45,56 @@ public class ButtonToast {
     private Toast mCurrentToast;
 
     // State objects
     private static class Toast {
         public final CharSequence token;
         public final CharSequence buttonMessage;
         public final int buttonIcon;
         public final CharSequence message;
-        public ToastListener listener;
 
-        public Toast(CharSequence aMessage, CharSequence aButtonMessage, int aIcon, ToastListener aListener) {
+        public Toast(CharSequence aMessage, CharSequence aButtonMessage, int aIcon, CharSequence aToken) {
             message = aMessage;
             buttonMessage = aButtonMessage;
             buttonIcon = aIcon;
-            listener = aListener;
-            token = "";
+            token = aToken;
         }
     }
 
     public interface ToastListener {
-        void onButtonClicked();
+        void onButtonClicked(CharSequence token);
     }
 
-    public ButtonToast(View view) {
+    public ButtonToast(View view, ToastListener listener) {
         mView = view;
-        mListener = null;
+        mListener = listener;
+
         mMessageView = (TextView) mView.findViewById(R.id.toast_message);
         mButton = (Button) mView.findViewById(R.id.toast_button);
         mButton.setOnClickListener(new View.OnClickListener() {
                     @Override
                     public void onClick(View view) {
                         Toast t = mCurrentToast;
                         if (t == null)
                             return;
 
                         hide(false);
-                        if (t.listener != null) {
-                            t.listener.onButtonClicked();
+                        if (mListener != null) {
+                            mListener.onButtonClicked(t.token);
                         }
                     }
                 });
 
         hide(true);
     }
 
     public void show(boolean immediate, CharSequence message,
                      CharSequence buttonMessage, int buttonIcon,
-                     ToastListener listener) {
-        Toast t = new Toast(message, buttonMessage, buttonIcon, listener);
+                     CharSequence token) {
+        Toast t = new Toast(message, buttonMessage, buttonIcon, token);
         show(t, immediate);
     }
 
     private void show(Toast t, boolean immediate) {
         // If we're already showing a toast, add this one to the queue to show later
         if (mView.getVisibility() == View.VISIBLE) {
             mQueue.offer(t);
             return;