Bug 1190301 - Use compound drawables instead of ImageButton views for tab audio indicator. r=mhaigh

--HG--
extra : commitid : gRtKCFje0R
extra : rebase_source : 8a94567769beda2ac2af6c819f30c482445ae2d7
This commit is contained in:
Margaret Leibovic 2015-08-24 10:12:06 -06:00
Родитель 5c61f9dd46
Коммит bc418f1775
4 изменённых файлов: 16 добавлений и 28 удалений

Просмотреть файл

@ -20,6 +20,7 @@
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"
@ -28,17 +29,6 @@
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"

Просмотреть файл

@ -31,16 +31,8 @@
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 -->

Просмотреть файл

@ -49,7 +49,6 @@ public class TabStripItemView extends ThemedLinearLayout
private final ImageView faviconView;
private final ThemedTextView titleView;
private final ThemedImageButton closeView;
private final ThemedImageButton audioPlayingView;
private final ResizablePathDrawable backgroundDrawable;
private final Region tabRegion;
@ -106,8 +105,6 @@ public class TabStripItemView extends ThemedLinearLayout
tabs.closeTab(tabs.getTab(id), true);
}
});
audioPlayingView = (ThemedImageButton) findViewById(R.id.audio_playing);
}
@Override
@ -199,7 +196,6 @@ public class TabStripItemView extends ThemedLinearLayout
updateTitle(tab);
updateFavicon(tab.getFavicon());
setPrivateMode(tab.isPrivate());
audioPlayingView.setVisibility(tab.isAudioPlaying() ? View.VISIBLE : View.GONE);
}
private void updateTitle(Tab tab) {
@ -213,6 +209,12 @@ public class TabStripItemView extends ThemedLinearLayout
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) {

Просмотреть файл

@ -38,7 +38,6 @@ public class TabsLayoutItemView extends LinearLayout
private TextView mTitle;
private TabsPanelThumbnailView mThumbnail;
private ImageView mCloseButton;
private ImageView mAudioPlayingButton;
private TabThumbnailWrapper mThumbnailWrapper;
public TabsLayoutItemView(Context context, AttributeSet attrs) {
@ -99,7 +98,6 @@ public class TabsLayoutItemView extends LinearLayout
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();
@ -145,7 +143,13 @@ public class TabsLayoutItemView extends LinearLayout
}
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() {