Bug 1130203 - Reset the first item background drawable state onResume. r=mhaigh a=sylvestre
authorMichael Comella <michael.l.comella@gmail.com>
Thu, 19 Mar 2015 18:08:48 -0700
changeset 258351 dd5f8068b392
parent 258350 8a05ce8c5ff7
child 258352 ce7199dbb0af
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)
reviewersmhaigh, sylvestre
bugs1130203, 1137928
milestone38.0
Bug 1130203 - Reset the first item background drawable state onResume. r=mhaigh a=sylvestre The Activity can be re-used in Android L (bug 1137928) so we have to reset any changed state.
mobile/android/base/overlays/ui/SendTabDeviceListArrayAdapter.java
mobile/android/base/overlays/ui/ShareDialog.java
mobile/android/base/resources/layout/overlay_share_send_tab_item.xml
--- a/mobile/android/base/overlays/ui/SendTabDeviceListArrayAdapter.java
+++ b/mobile/android/base/overlays/ui/SendTabDeviceListArrayAdapter.java
@@ -93,16 +93,18 @@ public class SendTabDeviceListArrayAdapt
         OverlayDialogButton row = (OverlayDialogButton) convertView;
         if (row == null) {
             row = (OverlayDialogButton) View.inflate(context, R.layout.overlay_share_send_tab_item, null);
         }
 
         // The first view in the list has a unique style.
         if (position == 0) {
             row.setBackgroundResource(R.drawable.overlay_share_button_background_first);
+        } else {
+            row.setBackgroundResource(R.drawable.overlay_share_button_background);
         }
 
         if (currentState != State.LIST) {
             // If we're in a special "Button-like" state, use the override string and a generic icon.
             final Drawable sendTabIcon = context.getResources().getDrawable(R.drawable.overlay_send_tab_icon);
             row.setEnabledLabelAndIcon(dummyRecordName, sendTabIcon);
         }
 
--- a/mobile/android/base/overlays/ui/ShareDialog.java
+++ b/mobile/android/base/overlays/ui/ShareDialog.java
@@ -66,16 +66,19 @@ public class ShareDialog extends Locales
     private static final int MAXIMUM_INLINE_DEVICES = 2;
 
     private State state;
 
     private SendTabList sendTabList;
     private OverlayDialogButton readingListButton;
     private OverlayDialogButton bookmarkButton;
 
+    // The reading list drawable set from XML - we need this to reset state.
+    private Drawable readingListButtonDrawable;
+
     private String url;
     private String title;
 
     // The override intent specified by SendTab (if any). See SendTab.java.
     private Intent sendTabOverrideIntent;
 
     // Flag set during animation to prevent animation multiple-start.
     private boolean isAnimating;
@@ -179,16 +182,18 @@ public class ShareDialog extends Locales
         // Register ourselves as both the listener and the context for the Adapter.
         final SendTabDeviceListArrayAdapter adapter = new SendTabDeviceListArrayAdapter(this, this);
         sendTabList.setAdapter(adapter);
         sendTabList.setSendTabTargetSelectedListener(this);
 
         bookmarkButton = (OverlayDialogButton) findViewById(R.id.overlay_share_bookmark_btn);
         readingListButton = (OverlayDialogButton) findViewById(R.id.overlay_share_reading_list_btn);
 
+        readingListButtonDrawable = readingListButton.getBackground();
+
         final Resources resources = getResources();
         final String bookmarkEnabledLabel = resources.getString(R.string.overlay_share_bookmark_btn_label);
         final Drawable bookmarkEnabledIcon = resources.getDrawable(R.drawable.overlay_bookmark_icon);
         bookmarkButton.setEnabledLabelAndIcon(bookmarkEnabledLabel, bookmarkEnabledIcon);
 
         final String bookmarkDisabledLabel = resources.getString(R.string.overlay_share_bookmark_btn_label_already);
         final Drawable bookmarkDisabledIcon = resources.getDrawable(R.drawable.overlay_bookmarked_already_icon);
         bookmarkButton.setDisabledLabelAndIcon(bookmarkDisabledLabel, bookmarkDisabledIcon);
@@ -223,16 +228,17 @@ public class ShareDialog extends Locales
         final Intent intent = getIntent();
 
         state = intent.getBooleanExtra(INTENT_EXTRA_DEVICES_ONLY, false) ?
                 State.DEVICES_ONLY : State.DEFAULT;
 
         // If the Activity is being reused, we need to reset the state. Ideally, we create a
         // new instance for each call, but Android L breaks this (bug 1137928).
         sendTabList.switchState(SendTabList.State.LOADING);
+        readingListButton.setBackgroundDrawable(readingListButtonDrawable);
 
         // The URL is usually hiding somewhere in the extra text. Extract it.
         final String extraText = ContextUtils.getStringExtra(intent, Intent.EXTRA_TEXT);
         if (TextUtils.isEmpty(extraText)) {
             abortDueToNoURL();
             return;
         }
 
--- a/mobile/android/base/resources/layout/overlay_share_send_tab_item.xml
+++ b/mobile/android/base/resources/layout/overlay_share_send_tab_item.xml
@@ -1,6 +1,9 @@
 <?xml version="1.0" encoding="utf-8"?>
+
+<!-- The first item's background is unique and these views are reused
+     so the background is set dynamically. -->
 <org.mozilla.gecko.overlays.ui.OverlayDialogButton xmlns:android="http://schemas.android.com/apk/res/android"
     style="@style/ShareOverlayRow"
     android:id="@+id/overlay_send_tab_item"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"/>