diff options
author | John Spurlock <jspurlock@google.com> | 2014-05-18 23:16:56 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-05-18 23:16:57 +0000 |
commit | 1cd74ddecece721cebf63434f611ce372aafec8d (patch) | |
tree | a998a982f7527d35321ad156547c3ec69b76da96 | |
parent | 4b0b0391d5b3ef289e00423ec701b450ac2a0eb3 (diff) | |
parent | d47a3f3bbe5264061bf0c506976efafa0d0f2957 (diff) | |
download | frameworks_base-1cd74ddecece721cebf63434f611ce372aafec8d.zip frameworks_base-1cd74ddecece721cebf63434f611ce372aafec8d.tar.gz frameworks_base-1cd74ddecece721cebf63434f611ce372aafec8d.tar.bz2 |
Merge "Quick settings touch feedback tweaks."
7 files changed, 54 insertions, 20 deletions
diff --git a/packages/SystemUI/res/values/styles.xml b/packages/SystemUI/res/values/styles.xml index 9536b12..19888a8 100644 --- a/packages/SystemUI/res/values/styles.xml +++ b/packages/SystemUI/res/values/styles.xml @@ -193,4 +193,9 @@ </style> <style name="QSBorderless" parent="@android:style/Widget.Quantum.Button.Borderless" /> + + <style name="QSBorderless.Tiny"> + <item name="android:minHeight">12dip</item> + <item name="android:minWidth">12dip</item> + </style> </resources> diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSTile.java b/packages/SystemUI/src/com/android/systemui/qs/QSTile.java index 2be364b..835a5c4 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSTile.java @@ -19,7 +19,6 @@ package com.android.systemui.qs; import android.content.Context; import android.content.Intent; import android.graphics.drawable.Drawable; -import android.graphics.drawable.VectorDrawable; import android.os.Handler; import android.os.Looper; import android.os.Message; @@ -50,6 +49,7 @@ import java.util.Objects; public abstract class QSTile<TState extends State> implements Listenable { protected final String TAG = "QSTile." + getClass().getSimpleName(); protected static final boolean DEBUG = false; + public static final int FEEDBACK_START_DELAY = 400; protected final Host mHost; protected final Context mContext; diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java b/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java index 31aefe9..4cfb636 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java @@ -25,6 +25,7 @@ import android.os.Handler; import android.os.Looper; import android.os.Message; import android.util.TypedValue; +import android.view.ContextThemeWrapper; import android.view.Gravity; import android.view.View; import android.view.ViewGroup; @@ -44,9 +45,9 @@ public class QSTileView extends ViewGroup { protected final Context mContext; private final View mIcon; private final View mDivider; - private final TextView mLabel; private final H mHandler = new H(); + private TextView mLabel; private boolean mDual; private OnClickListener mClickPrimary; private OnClickListener mClickSecondary; @@ -56,14 +57,7 @@ public class QSTileView extends ViewGroup { mContext = context; final Resources res = context.getResources(); - mLabel = new TextView(mContext); - mLabel.setId(android.R.id.title); - mLabel.setTextColor(res.getColor(R.color.quick_settings_tile_text)); - mLabel.setGravity(Gravity.CENTER); - mLabel.setTypeface(CONDENSED); - mLabel.setTextSize(TypedValue.COMPLEX_UNIT_PX, - res.getDimensionPixelSize(R.dimen.quick_settings_tile_text_size)); - addView(mLabel); + recreateLabel(); setClipChildren(false); mIcon = createIcon(); @@ -79,8 +73,33 @@ public class QSTileView extends ViewGroup { setBackground(getSelectableBackground()); } + private void recreateLabel() { + CharSequence labelText = null; + if (mLabel != null) { + labelText = mLabel.getText(); + removeView(mLabel); + } + final Resources res = mContext.getResources(); + mLabel = new TextView(mDual ? new ContextThemeWrapper(mContext, R.style.QSBorderless_Tiny) + : mContext); + mLabel.setId(android.R.id.title); + mLabel.setTextColor(res.getColor(R.color.quick_settings_tile_text)); + mLabel.setGravity(Gravity.CENTER); + mLabel.setTypeface(CONDENSED); + mLabel.setTextSize(TypedValue.COMPLEX_UNIT_PX, + res.getDimensionPixelSize(R.dimen.quick_settings_tile_text_size)); + if (labelText != null) { + mLabel.setText(labelText); + } + addView(mLabel); + } + public void setDual(boolean dual) { + final boolean changed = dual != mDual; mDual = dual; + if (changed) { + recreateLabel(); + } if (mDual) { setOnClickListener(mClickPrimary); mLabel.setClickable(true); @@ -121,9 +140,10 @@ public class QSTileView extends ViewGroup { final int iconSpec = exactly((int)mLabel.getTextSize() * 2); mIcon.measure(iconSpec, iconSpec); mLabel.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(h, MeasureSpec.AT_MOST)); - mLabel.measure(widthMeasureSpec, exactly(mLabel.getMeasuredHeight() + p * 2)); if (mDual) { mDivider.measure(widthMeasureSpec, exactly(mDivider.getLayoutParams().height)); + } else { + mLabel.measure(widthMeasureSpec, exactly(mLabel.getMeasuredHeight() + p * 2)); } setMeasuredDimension(w, h); } diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/BugreportTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/BugreportTile.java index 81ea0eb..bfd416d 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/BugreportTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/BugreportTile.java @@ -57,8 +57,13 @@ public class BugreportTile extends QSTile<QSTile.State> { @Override protected void handleClick() { - mHost.collapsePanels(); - mUiHandler.post(mShowDialog); + mHandler.postDelayed(new Runnable() { + @Override + public void run() { + mHost.collapsePanels(); + mUiHandler.post(mShowDialog); + } + }, FEEDBACK_START_DELAY); } @Override diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/CastTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/CastTile.java index d0a1246..907c77e 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/CastTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/CastTile.java @@ -65,8 +65,12 @@ public class CastTile extends QSTile<QSTile.BooleanState> { @Override protected void handleClick() { - mHost.collapsePanels(); - mUiHandler.post(mShowDialog); + mHandler.postDelayed(new Runnable() { + public void run() { + mHost.collapsePanels(); + mUiHandler.post(mShowDialog); + } + }, FEEDBACK_START_DELAY); } @Override diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index f56dadd..a685073 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -2565,13 +2565,13 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, || (mDisabled & StatusBarManager.DISABLE_SEARCH) != 0; } - public void postStartSettingsActivity(final Intent intent) { - mHandler.post(new Runnable() { + public void postStartSettingsActivity(final Intent intent, int delay) { + mHandler.postDelayed(new Runnable() { @Override public void run() { handleStartSettingsActivity(intent, true /*onlyProvisioned*/); } - }); + }, delay); } private void handleStartSettingsActivity(Intent intent, boolean onlyProvisioned) { @@ -2587,7 +2587,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, } public void startSettingsActivity(String action) { - postStartSettingsActivity(new Intent(action)); + postStartSettingsActivity(new Intent(action), 0); } private static class FastColorDrawable extends Drawable { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QSTileHost.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QSTileHost.java index 34d143a..7029898 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QSTileHost.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QSTileHost.java @@ -112,7 +112,7 @@ public class QSTileHost implements QSTile.Host { @Override public void startSettingsActivity(final Intent intent) { - mStatusBar.postStartSettingsActivity(intent); + mStatusBar.postStartSettingsActivity(intent, QSTile.FEEDBACK_START_DELAY); } @Override |