MediaRouter: Adjust padding of the volume item to comply with the spec
Bug: 23942670
Change-Id: I7dfb18ec5bd1b81be54861027c6b974fac7654ae
diff --git a/v7/mediarouter/res/layout/mr_controller_volume_item.xml b/v7/mediarouter/res/layout/mr_controller_volume_item.xml
index ba1b8b4..dc539eb 100644
--- a/v7/mediarouter/res/layout/mr_controller_volume_item.xml
+++ b/v7/mediarouter/res/layout/mr_controller_volume_item.xml
@@ -19,8 +19,7 @@
android:layout_height="@dimen/mr_controller_volume_group_list_item_height"
android:paddingLeft="24dp"
android:paddingRight="60dp"
- android:paddingTop="8dp"
- android:paddingBottom="8dp">
+ android:paddingTop="16dp" >
<TextView android:id="@+id/mr_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -32,9 +31,8 @@
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginTop="12dp"
- android:src="?attr/mediaRouteAudioTrackDrawable"
android:layout_below="@id/mr_name"
- android:layout_gravity="center_vertical" />
+ android:src="?attr/mediaRouteAudioTrackDrawable" />
<SeekBar android:id="@+id/mr_volume_slider"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
diff --git a/v7/mediarouter/res/values/dimens.xml b/v7/mediarouter/res/values/dimens.xml
index 866f6b8..77656f4 100644
--- a/v7/mediarouter/res/values/dimens.xml
+++ b/v7/mediarouter/res/values/dimens.xml
@@ -27,4 +27,6 @@
<!-- Height of MediaRouteController's volume group item.
TODO: Define value for landscape once we know how to adjust SeekBar height. -->
<dimen name="mr_controller_volume_group_list_item_height">75dp</dimen>
+
+ <dimen name="mr_controller_volume_group_list_padding_bottom">8dp</dimen>
</resources>
diff --git a/v7/mediarouter/src/android/support/v7/app/MediaRouteControllerDialog.java b/v7/mediarouter/src/android/support/v7/app/MediaRouteControllerDialog.java
index 5476f48..05a3adb 100644
--- a/v7/mediarouter/src/android/support/v7/app/MediaRouteControllerDialog.java
+++ b/v7/mediarouter/src/android/support/v7/app/MediaRouteControllerDialog.java
@@ -128,6 +128,8 @@
private boolean mVolumeSliderTouched;
private int mVolumeSliderColor;
private final int mVolumeGroupListItemHeight;
+ private final int mVolumeGroupListMaxHeight;
+ private final int mVolumeGroupListPaddingBottom;
private MediaControllerCompat mMediaController;
private MediaControllerCallback mControllerCallback;
@@ -154,6 +156,10 @@
setMediaSession(mRouter.getMediaSessionToken());
mVolumeGroupListItemHeight = context.getResources().getDimensionPixelSize(
R.dimen.mr_controller_volume_group_list_item_height);
+ mVolumeGroupListMaxHeight = context.getResources().getDimensionPixelSize(
+ R.dimen.mr_controller_volume_group_list_max_height);
+ mVolumeGroupListPaddingBottom = context.getResources().getDimensionPixelSize(
+ R.dimen.mr_controller_volume_group_list_padding_bottom);
}
/**
@@ -501,14 +507,10 @@
int mainControllerHeight = getMainControllerHeight(isPlaybackControlAvailable());
int volumeGroupListCount = mVolumeGroupList.getVisibility() == View.VISIBLE
? mVolumeGroupList.getAdapter().getCount() : 0;
- int volumeGroupHeight = 0;
- if (0 < volumeGroupListCount && volumeGroupListCount <= 2) {
- volumeGroupHeight = mVolumeGroupListItemHeight * 2;
- } else if (volumeGroupListCount >= 3) {
- volumeGroupHeight = Math.min(mVolumeGroupListItemHeight * volumeGroupListCount,
- getContext().getResources().getDimensionPixelSize(
- R.dimen.mr_controller_volume_group_list_max_height));
- }
+ int volumeGroupHeight = mVolumeGroupListItemHeight * volumeGroupListCount
+ + mVolumeGroupListPaddingBottom;
+ volumeGroupHeight = Math.min(volumeGroupHeight, mVolumeGroupListMaxHeight);
+
int desiredControlLayoutHeight =
Math.max(artViewHeight, volumeGroupHeight) + mainControllerHeight;
Rect visibleRect = new Rect();
@@ -780,6 +782,8 @@
setVolumeSliderColor(getContext(), (SeekBar) v.findViewById(R.id.mr_volume_slider),
mVolumeSliderColor);
}
+ setViewPaddingBottom(v, position == getCount() - 1 ? mVolumeGroupListPaddingBottom : 0);
+
MediaRouter.RouteInfo route = getItem(position);
if (route != null) {
boolean isEnabled = route.isEnabled();
@@ -816,6 +820,13 @@
}
}
+ private static void setViewPaddingBottom(View view, int bottom) {
+ int left = view.getPaddingLeft();
+ int top = view.getPaddingTop();
+ int right = view.getPaddingRight();
+ view.setPadding(left, top, right, bottom);
+ }
+
private class FetchArtTask extends AsyncTask<Void, Void, Bitmap> {
final Bitmap mIconBitmap;
final Uri mIconUri;