Merge "Quick settings touch feedback tweaks."
This commit is contained in:
committed by
Android (Google) Code Review
commit
1cd74ddece
@@ -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>
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user