From 0ed01deb2fc99603a33f968044703a740673c7b3 Mon Sep 17 00:00:00 2001 From: Jorim Jaggi Date: Thu, 11 Dec 2014 21:00:12 +0100 Subject: Limit item count in QS detail - Introduce a maximum number of items to be shown in QS detail view depending on the device configuration. - For Wifi and Cast, make the panel exactly that height as we would show the maximum count of items, in order to prevent that the buttons jump around. Bug: 18665311 Change-Id: I7c0c383a902d295f1b486b8a074e15b990fbe562 --- packages/SystemUI/res/layout/qs_detail_items.xml | 4 ++++ packages/SystemUI/res/values-h560dp/config.xml | 23 ++++++++++++++++++++++ packages/SystemUI/res/values/config.xml | 3 +++ .../src/com/android/systemui/qs/QSDetailItems.java | 20 ++++++++++++++++++- .../android/systemui/qs/tiles/BluetoothTile.java | 1 + 5 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 packages/SystemUI/res/values-h560dp/config.xml diff --git a/packages/SystemUI/res/layout/qs_detail_items.xml b/packages/SystemUI/res/layout/qs_detail_items.xml index f61a43c..c22e42c 100644 --- a/packages/SystemUI/res/layout/qs_detail_items.xml +++ b/packages/SystemUI/res/layout/qs_detail_items.xml @@ -49,4 +49,8 @@ android:textAppearance="@style/TextAppearance.QS.DetailEmpty" /> + \ No newline at end of file diff --git a/packages/SystemUI/res/values-h560dp/config.xml b/packages/SystemUI/res/values-h560dp/config.xml new file mode 100644 index 0000000..f210d7b --- /dev/null +++ b/packages/SystemUI/res/values-h560dp/config.xml @@ -0,0 +1,23 @@ + + + + + + + 8 + + diff --git a/packages/SystemUI/res/values/config.xml b/packages/SystemUI/res/values/config.xml index 4d76f38..5b18b24 100644 --- a/packages/SystemUI/res/values/config.xml +++ b/packages/SystemUI/res/values/config.xml @@ -131,6 +131,9 @@ 2000 4000 + + 7 + 10 diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSDetailItems.java b/packages/SystemUI/src/com/android/systemui/qs/QSDetailItems.java index a311d6e..9155102 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSDetailItems.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSDetailItems.java @@ -51,8 +51,10 @@ public class QSDetailItems extends FrameLayout { private boolean mItemsVisible = true; private LinearLayout mItems; private View mEmpty; + private View mMinHeightSpacer; private TextView mEmptyText; private ImageView mEmptyIcon; + private int mMaxItems; public QSDetailItems(Context context, AttributeSet attrs) { super(context, attrs); @@ -77,6 +79,12 @@ public class QSDetailItems extends FrameLayout { mEmpty.setVisibility(GONE); mEmptyText = (TextView) mEmpty.findViewById(android.R.id.title); mEmptyIcon = (ImageView) mEmpty.findViewById(android.R.id.icon); + mMinHeightSpacer = findViewById(R.id.min_height_spacer); + + // By default, a detail item view has fixed size. + mMaxItems = getResources().getInteger( + R.integer.quick_settings_detail_max_item_count); + setMinHeightInItems(mMaxItems); } @Override @@ -102,6 +110,16 @@ public class QSDetailItems extends FrameLayout { mEmptyText.setText(text); } + /** + * Set the minimum height of this detail view, in item count. + */ + public void setMinHeightInItems(int minHeightInItems) { + ViewGroup.LayoutParams lp = mMinHeightSpacer.getLayoutParams(); + lp.height = minHeightInItems * getResources().getDimensionPixelSize( + R.dimen.qs_detail_item_height); + mMinHeightSpacer.setLayoutParams(lp); + } + @Override protected void onAttachedToWindow() { super.onAttachedToWindow(); @@ -135,7 +153,7 @@ public class QSDetailItems extends FrameLayout { } private void handleSetItems(Item[] items) { - final int itemCount = items != null ? items.length : 0; + final int itemCount = items != null ? Math.min(items.length, mMaxItems) : 0; mEmpty.setVisibility(itemCount == 0 ? VISIBLE : GONE); mItems.setVisibility(itemCount == 0 ? GONE : VISIBLE); for (int i = mItems.getChildCount() - 1; i >= itemCount; i--) { diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java index 1bc1d77..c15566f 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java @@ -185,6 +185,7 @@ public class BluetoothTile extends QSTile { mItems.setEmptyState(R.drawable.ic_qs_bluetooth_detail_empty, R.string.quick_settings_bluetooth_detail_empty_text); mItems.setCallback(this); + mItems.setMinHeightInItems(0); updateItems(); setItemsVisible(mState.value); return mItems; -- cgit v1.1