Bug 1130203 - Remove retry button in share overlay retry toast. r=margaret a=sylvestre
authorMichael Comella <michael.l.comella@gmail.com>
Tue, 24 Mar 2015 17:16:00 -0700
changeset 258355 d49aaecd32a3
parent 258354 994526939c21
child 258356 3eb3b25437dd
push id4648
push usermichael.l.comella@gmail.com
push date2015-04-08 16:26 +0000
treeherdermozilla-beta@e399294c9df3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmargaret, sylvestre
bugs1130203, 20698525, 1145434
milestone38.0
Bug 1130203 - Remove retry button in share overlay retry toast. r=margaret a=sylvestre Toasts are unclickable (http://stackoverflow.com/a/20698525) so this button never actually did anything. If we want to add this functionality, we'd have to use a new toasting API (dialog was suggested) and potentially create a new Activity (so it can be shown over another underlying Activity). We could implement this but it'd be better to spend time creating system notifications to show tab sending progress (bug 1145434).
mobile/android/base/overlays/service/OverlayActionService.java
mobile/android/base/overlays/ui/OverlayToastHelper.java
mobile/android/base/resources/layout/overlay_share_toast.xml
--- a/mobile/android/base/overlays/service/OverlayActionService.java
+++ b/mobile/android/base/overlays/service/OverlayActionService.java
@@ -114,27 +114,17 @@ public class OverlayActionService extend
                 final ShareMethod.Result result = shareMethod.handle(shareData);
                 // Dispatch the share to the targeted ShareMethod.
                 switch (result) {
                     case SUCCESS:
                         // \o/
                         OverlayToastHelper.showSuccessToast(getApplicationContext(), shareMethod.getSuccessMessage());
                         break;
                     case TRANSIENT_FAILURE:
-                        // An OnClickListener to do this share again.
-                        View.OnClickListener retryListener = new View.OnClickListener() {
-                            @Override
-                            public void onClick(View view) {
-                                handleShare(intent);
-                            }
-                        };
-
-                        // Show a failure toast with a retry button.
-                        OverlayToastHelper.showFailureToast(getApplicationContext(), shareMethod.getFailureMessage(), retryListener);
-                        break;
+                        // Fall-through
                     case PERMANENT_FAILURE:
                         // Show a failure toast without a retry button.
                         OverlayToastHelper.showFailureToast(getApplicationContext(), shareMethod.getFailureMessage());
                         break;
                     default:
                         Assert.fail("Unknown share method result code: " + result);
                         break;
                 }
--- a/mobile/android/base/overlays/ui/OverlayToastHelper.java
+++ b/mobile/android/base/overlays/ui/OverlayToastHelper.java
@@ -1,71 +1,56 @@
 /* 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/. */
 
 package org.mozilla.gecko.overlays.ui;
 
 import android.content.Context;
-import android.view.Gravity;
 import android.view.LayoutInflater;
 import android.view.View;
-import android.widget.Button;
 import android.widget.TextView;
 import android.widget.Toast;
 
 import org.mozilla.gecko.R;
 
 /**
  * Static helper class for generating toasts for share events.
  *
  * The overlay toasts come in a variety of flavours: success (rectangle with happy green tick,
  * failure (no tick, a retry button), and success-with-tutorial (as success, but with a pretty
  * picture of some description to educate the user on how to use the feature) TODO: Bug 1048645.
  */
 public class OverlayToastHelper {
+
     /**
      * Show a toast indicating a failure to share.
      * @param context Context in which to inflate the toast.
      * @param failureMessage String to display in the toast.
-     * @param isTransient Should a retry button be presented?
-     * @param retryListener Listener to fire when the retry button is pressed.
      */
-    public static void showFailureToast(Context context, String failureMessage, View.OnClickListener retryListener) {
-        showToast(context, failureMessage, false, retryListener);
-    }
     public static void showFailureToast(Context context, String failureMessage) {
-        showFailureToast(context, failureMessage, null);
+        showToast(context, failureMessage, false);
     }
 
     /**
      * Show a toast indicating a successful share.
      * @param successMessage Message to show in the toast.
      */
     public static void showSuccessToast(Context context, String successMessage) {
-        showToast(context, successMessage, true, null);
+        showToast(context, successMessage, true);
     }
 
-    private static void showToast(Context context, String message, boolean success, View.OnClickListener retryListener) {
+    private static void showToast(Context context, String message, boolean success) {
         LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
 
         View layout = inflater.inflate(R.layout.overlay_share_toast, null);
 
         TextView text = (TextView) layout.findViewById(R.id.overlay_toast_message);
         text.setText(message);
 
-        if (retryListener == null) {
-            // Hide the retry button.
-            layout.findViewById(R.id.overlay_toast_retry_btn).setVisibility(View.GONE);
-        } else {
-            // Set up the button to perform a retry.
-            Button retryBtn = (Button) layout.findViewById(R.id.overlay_toast_retry_btn);
-            retryBtn.setOnClickListener(retryListener);
-        }
-
         if (!success) {
             // Hide the happy green tick.
             text.setCompoundDrawables(null, null, null, null);
         }
 
         Toast toast = new Toast(context);
         toast.setDuration(Toast.LENGTH_SHORT);
         toast.setView(layout);
--- a/mobile/android/base/resources/layout/overlay_share_toast.xml
+++ b/mobile/android/base/resources/layout/overlay_share_toast.xml
@@ -6,38 +6,21 @@
 
 <FrameLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:background="@drawable/dropshadow"
     android:padding="3dp">
 
-    <LinearLayout
+    <TextView
+        android:id="@+id/overlay_toast_message"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
+        android:layout_gravity="center_vertical"
+        android:padding="20dp"
         android:background="@drawable/toolbar_grey_round"
-        android:orientation="horizontal"
-        android:padding="20dp">
+        android:textColor="@color/text_and_tabs_tray_grey"
+        android:textSize="14sp"
+        android:drawablePadding="15dp"
+        android:drawableLeft="@drawable/overlay_check"/>
 
-        <TextView
-            android:id="@+id/overlay_toast_message"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_gravity="center_vertical"
-            android:layout_weight="2"
-            android:layout_marginRight="10dp"
-            android:textColor="@color/text_and_tabs_tray_grey"
-            android:textSize="14sp"
-            android:drawablePadding="15dp"
-            android:drawableLeft="@drawable/overlay_check"/>
-
-        <!-- Retry button -->
-        <Button
-            android:id="@+id/overlay_toast_retry_btn"
-            android:layout_height="wrap_content"
-            android:layout_width="wrap_content"
-            android:layout_weight="1"
-            android:text="@string/overlay_share_retry"
-            android:onClick="selfDestruct" />
-
-    </LinearLayout>
 </FrameLayout>