Bug 1190301 - Use compound drawables instead of ImageButton views for tab audio indicator. r=mhaigh
authorMargaret Leibovic <margaret.leibovic@gmail.com>
Mon, 24 Aug 2015 10:12:06 -0600
changeset 293198 fb806fe87320661d533633e80299505d2d7b5f21
parent 293197 8056ee3e5b83258cb1efd6938461be1651002cf4
child 293199 b14eba602eaea000a759997a82abb61780ed5614
child 293295 b5ef40e401b6329e2bb1f8ffa4d54fdeda439ac2
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmhaigh
bugs1190301
milestone43.0a1
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
Bug 1190301 - Use compound drawables instead of ImageButton views for tab audio indicator. r=mhaigh
mobile/android/base/resources/layout-large-v11/tab_strip_item_view.xml
mobile/android/base/resources/layout/tabs_layout_item_view.xml
mobile/android/base/tabs/TabStripItemView.java
mobile/android/base/tabs/TabsLayoutItemView.java
--- a/mobile/android/base/resources/layout-large-v11/tab_strip_item_view.xml
+++ b/mobile/android/base/resources/layout-large-v11/tab_strip_item_view.xml
@@ -15,36 +15,26 @@
         android:duplicateParentState="true"/>
 
     <org.mozilla.gecko.widget.FadedSingleColorTextView
         android:id="@+id/title"
         android:layout_width="0dip"
         android:layout_height="match_parent"
         android:layout_weight="1.0"
         android:layout_marginRight="-5dp"
+        android:drawablePadding="6dp"
         android:gravity="center_vertical"
         android:textSize="14sp"
         android:ellipsize="end"
         android:textColor="@color/tab_strip_item_title"
         android:maxLines="1"
         gecko:fadeWidth="30dip"
         android:duplicateParentState="true"/>
 
     <org.mozilla.gecko.widget.themed.ThemedImageButton
-        android:id="@+id/audio_playing"
-        android:visibility="gone"
-        android:layout_width="20dip"
-        android:layout_height="match_parent"
-        android:layout_marginRight="-15dp"
-        android:background="@drawable/action_bar_button_inverse"
-        android:scaleType="center"
-        android:contentDescription="@string/tab_audio_playing"
-        android:src="@drawable/tab_audio_playing"/>
-
-    <org.mozilla.gecko.widget.themed.ThemedImageButton
         android:id="@+id/close"
         android:layout_width="40dip"
         android:layout_height="match_parent"
         android:background="@android:color/transparent"
         android:scaleType="center"
         android:contentDescription="@string/close_tab"
         android:src="@drawable/tab_close"
         android:duplicateParentState="true"/>
--- a/mobile/android/base/resources/layout/tabs_layout_item_view.xml
+++ b/mobile/android/base/resources/layout/tabs_layout_item_view.xml
@@ -26,26 +26,18 @@
                android:layout_height="wrap_content"
                android:layout_weight="1.0"
                style="@style/TabLayoutItemTextAppearance"
                android:textSize="14sp"
                android:textColor="@color/tab_item_title"
                android:singleLine="true"
                android:duplicateParentState="true"
                gecko:fadeWidth="15dp"
-               android:paddingRight="5dp"/>
-
-          <ImageButton android:id="@+id/audio_playing"
-                       android:visibility="gone"
-                       android:layout_width="20dip"
-                       android:layout_height="20dip"
-                       android:background="@drawable/action_bar_button_inverse"
-                       android:scaleType="center"
-                       android:contentDescription="@string/tab_audio_playing"
-                       android:src="@drawable/tab_audio_playing"/>
+               android:paddingRight="5dp"
+               android:drawablePadding="6dp"/>
 
         <!-- Use of baselineAlignBottom only supported from API 11+ - if this needs to work on lower API versions
              we'll need to override getBaseLine() and return image height, but we assume this won't happen -->
         <ImageView android:id="@+id/close"
                      style="@style/TabsItemClose"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:scaleType="center"
--- a/mobile/android/base/tabs/TabStripItemView.java
+++ b/mobile/android/base/tabs/TabStripItemView.java
@@ -44,17 +44,16 @@ public class TabStripItemView extends Th
     };
 
     private int id = -1;
     private boolean checked;
 
     private final ImageView faviconView;
     private final ThemedTextView titleView;
     private final ThemedImageButton closeView;
-    private final ThemedImageButton audioPlayingView;
 
     private final ResizablePathDrawable backgroundDrawable;
     private final Region tabRegion;
     private final Region tabClipRegion;
     private boolean tabRegionNeedsUpdate;
 
     private final int faviconSize;
     private Bitmap lastFavicon;
@@ -101,18 +100,16 @@ public class TabStripItemView extends Th
                 if (id < 0) {
                     throw new IllegalStateException("Invalid tab id:" + id);
                 }
 
                 final Tabs tabs = Tabs.getInstance();
                 tabs.closeTab(tabs.getTab(id), true);
             }
         });
-
-        audioPlayingView = (ThemedImageButton) findViewById(R.id.audio_playing);
     }
 
     @Override
     protected void onSizeChanged(int width, int height, int oldWidth, int oldHeight) {
         super.onSizeChanged(width, height, oldWidth, oldHeight);
 
         // Queue a tab region update in the next draw() call. We don't
         // update it immediately here because we need the new path from
@@ -194,30 +191,35 @@ public class TabStripItemView extends Th
             return;
         }
 
         id = tab.getId();
 
         updateTitle(tab);
         updateFavicon(tab.getFavicon());
         setPrivateMode(tab.isPrivate());
-        audioPlayingView.setVisibility(tab.isAudioPlaying() ? View.VISIBLE : View.GONE);
     }
 
     private void updateTitle(Tab tab) {
         final String title;
 
         // Avoid flickering the about:home URL on every load given how often
         // this page is used in the UI.
         if (AboutPages.isAboutHome(tab.getURL())) {
             titleView.setText(R.string.home_title);
         } else {
             titleView.setText(tab.getDisplayTitle());
         }
 
+        // TODO: Set content description to indicate audio is playing.
+        if (tab.isAudioPlaying()) {
+            titleView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.tab_audio_playing, 0, 0, 0);
+        } else {
+            titleView.setCompoundDrawables(null, null, null, null);
+        }
     }
 
     private void updateFavicon(final Bitmap favicon) {
         if (favicon == null) {
             lastFavicon = null;
             faviconView.setImageResource(R.drawable.toolbar_favicon_default);
             return;
         }
--- a/mobile/android/base/tabs/TabsLayoutItemView.java
+++ b/mobile/android/base/tabs/TabsLayoutItemView.java
@@ -33,17 +33,16 @@ public class TabsLayoutItemView extends 
     private static final String LOGTAG = "Gecko" + TabsLayoutItemView.class.getSimpleName();
     private static final int[] STATE_CHECKED = { android.R.attr.state_checked };
     private boolean mChecked;
 
     private int mTabId;
     private TextView mTitle;
     private TabsPanelThumbnailView mThumbnail;
     private ImageView mCloseButton;
-    private ImageView mAudioPlayingButton;
     private TabThumbnailWrapper mThumbnailWrapper;
 
     public TabsLayoutItemView(Context context, AttributeSet attrs) {
         super(context, attrs);
     }
 
     @Override
     public int[] onCreateDrawableState(int extraSpace) {
@@ -94,17 +93,16 @@ public class TabsLayoutItemView extends 
     }
 
     @Override
     protected void onFinishInflate() {
         super.onFinishInflate();
         mTitle = (TextView) findViewById(R.id.title);
         mThumbnail = (TabsPanelThumbnailView) findViewById(R.id.thumbnail);
         mCloseButton = (ImageView) findViewById(R.id.close);
-        mAudioPlayingButton = (ImageView) findViewById(R.id.audio_playing);
         mThumbnailWrapper = (TabThumbnailWrapper) findViewById(R.id.wrapper);
 
         growCloseButtonHitArea();
     }
 
     private void growCloseButtonHitArea() {
         getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
             @Override
@@ -140,17 +138,23 @@ public class TabsLayoutItemView extends 
 
         mThumbnail.setPrivateMode(tab.isPrivate());
 
         if (mThumbnailWrapper != null) {
             mThumbnailWrapper.setRecording(tab.isRecording());
         }
         mTitle.setText(tab.getDisplayTitle());
         mCloseButton.setTag(this);
-        mAudioPlayingButton.setVisibility(tab.isAudioPlaying() ? View.VISIBLE : View.GONE);
+
+        // TODO: Set content description to indicate audio is playing.
+        if (tab.isAudioPlaying()) {
+            mTitle.setCompoundDrawablesWithIntrinsicBounds(R.drawable.tab_audio_playing, 0, 0, 0);
+        } else {
+            mTitle.setCompoundDrawables(null, null, null, null);
+        }
     }
 
     public int getTabId() {
         return mTabId;
     }
 
     public void setThumbnail(Drawable thumbnail) {
         mThumbnail.setImageDrawable(thumbnail);