Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d47a3f3b authored by John Spurlock's avatar John Spurlock
Browse files

Quick settings touch feedback tweaks.

Change-Id: I76a28c023fd6f006ba96063680842a4f89ae8c83
parent a25a1603
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -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>
+1 −1
Original line number Diff line number Diff line
@@ -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;
+30 −10
Original line number Diff line number Diff line
@@ -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);
    }
+7 −2
Original line number Diff line number Diff line
@@ -57,9 +57,14 @@ public class BugreportTile extends QSTile<QSTile.State> {

    @Override
    protected void handleClick() {
        mHandler.postDelayed(new Runnable() {
            @Override
            public void run() {
                mHost.collapsePanels();
                mUiHandler.post(mShowDialog);
            }
        }, FEEDBACK_START_DELAY);
    }

    @Override
    protected void handleUpdateState(State state, Object pushArg) {
+6 −2
Original line number Diff line number Diff line
@@ -65,9 +65,13 @@ public class CastTile extends QSTile<QSTile.BooleanState> {

    @Override
    protected void handleClick() {
        mHandler.postDelayed(new Runnable() {
            public void run() {
                mHost.collapsePanels();
                mUiHandler.post(mShowDialog);
            }
        }, FEEDBACK_START_DELAY);
    }

    @Override
    protected void handleUpdateState(BooleanState state, Object arg) {
Loading