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

Unverified Commit 67eed7f9 authored by Ido Ben-Hur's avatar Ido Ben-Hur Committed by Michael Bestas
Browse files

SystemUI: Allow disabling QS tiles long click effect for specific tiles

and disable it for tiles that launch nothing

Change-Id: I0792d980ddc5643afb69f2021aff74cc27231216
parent 128e2343
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -203,6 +203,7 @@ public interface QSTile {
        public String expandedAccessibilityClassName;
        public boolean handlesLongClick = true;
        public boolean handlesSecondaryClick = false;
        public boolean hasLongClickEffect = true;
        @Nullable
        public Drawable sideViewCustomDrawable;
        public String spec;
@@ -250,6 +251,7 @@ public interface QSTile {
                    || !Objects.equals(other.dualTarget, dualTarget)
                    || !Objects.equals(other.handlesLongClick, handlesLongClick)
                    || !Objects.equals(other.handlesSecondaryClick, handlesSecondaryClick)
                    || !Objects.equals(other.hasLongClickEffect, hasLongClickEffect)
                    || !Objects.equals(other.sideViewCustomDrawable, sideViewCustomDrawable);
            other.spec = spec;
            other.icon = icon;
@@ -266,6 +268,7 @@ public interface QSTile {
            other.isTransient = isTransient;
            other.handlesLongClick = handlesLongClick;
            other.handlesSecondaryClick = handlesSecondaryClick;
            other.hasLongClickEffect = hasLongClickEffect;
            other.sideViewCustomDrawable = sideViewCustomDrawable;
            return changed;
        }
@@ -292,6 +295,7 @@ public interface QSTile {
            sb.append(",dualTarget=").append(dualTarget);
            sb.append(",isTransient=").append(isTransient);
            sb.append(",handlesSecondaryClick=").append(handlesSecondaryClick);
            sb.append(",hasLongClickEffect=").append(hasLongClickEffect);
            sb.append(",state=").append(state);
            sb.append(",sideViewCustomDrawable=").append(sideViewCustomDrawable);
            return sb.append(']');
+7 −4
Original line number Diff line number Diff line
@@ -98,6 +98,7 @@ constructor(

    private val icon: QSIconViewImpl = QSIconViewImpl(context)
    private var position: Int = INVALID
    private var hasLongClickEffect: Boolean = true

    override fun setPosition(position: Int) {
        this.position = position
@@ -346,7 +347,7 @@ constructor(
    }

    private fun maybeUpdateLongPressEffectWidth(width: Float) {
        if (!isLongClickable || longPressEffect == null) return
        if (!isLongClickable || longPressEffect == null || !hasLongClickEffect) return

        initialLongPressProperties?.width = width
        finalLongPressProperties?.width = LONG_PRESS_EFFECT_WIDTH_SCALE * width
@@ -357,7 +358,7 @@ constructor(
    }

    private fun maybeUpdateLongPressEffectHeight(height: Float) {
        if (!isLongClickable || longPressEffect == null) return
        if (!isLongClickable || longPressEffect == null || !hasLongClickEffect) return

        initialLongPressProperties?.height = height
        finalLongPressProperties?.height = LONG_PRESS_EFFECT_HEIGHT_SCALE * height
@@ -650,6 +651,7 @@ constructor(
        val allowAnimations = animationsEnabled()
        isClickable = state.state != Tile.STATE_UNAVAILABLE
        isLongClickable = state.handlesLongClick
        hasLongClickEffect = (state.handlesLongClick && state.hasLongClickEffect)
        icon.setIcon(state, allowAnimations)
        contentDescription = state.contentDescription

@@ -779,7 +781,8 @@ constructor(
            return

        longPressEffect.qsTile?.state?.handlesLongClick = handlesLongClick
        if (handlesLongClick && longPressEffect.initializeEffect(longPressEffectDuration)) {
        if (hasLongClickEffect && handlesLongClick &&
                longPressEffect.initializeEffect(longPressEffectDuration)) {
            showRippleEffect = false
            longPressEffect.qsTile?.state?.state = lastState // Store the tile's state
            longPressEffect.resetState()
@@ -938,7 +941,7 @@ constructor(
        }

    fun updateLongPressEffectProperties(effectProgress: Float) {
        if (!isLongClickable || longPressEffect == null) return
        if (!isLongClickable || longPressEffect == null || !hasLongClickEffect) return

        if (haveLongPressPropertiesBeenReset) haveLongPressPropertiesBeenReset = false

+1 −0
Original line number Diff line number Diff line
@@ -148,6 +148,7 @@ public class AODTile extends QSTileImpl<BooleanState> implements
        state.icon = mIcon;
        state.value = enable;
        state.label = mContext.getString(R.string.quick_settings_aod_label);
        state.hasLongClickEffect = false;
        if (mBatteryController.isAodPowerSave()) {
            state.state = Tile.STATE_UNAVAILABLE;
        } else {
+1 −0
Original line number Diff line number Diff line
@@ -218,6 +218,7 @@ public class CaffeineTile extends QSTileImpl<BooleanState> {
        state.value = mWakeLock.isHeld();
        state.icon = mIcon;
        state.label = mContext.getString(R.string.quick_settings_caffeine_label);
        state.hasLongClickEffect = false;
        if (state.value) {
            state.secondaryLabel = formatValueWithRemainingTime();
            state.contentDescription =  mContext.getString(
+1 −0
Original line number Diff line number Diff line
@@ -191,6 +191,7 @@ public class PowerShareTile extends QSTileImpl<BooleanState>
        }

        state.icon = ResourceIcon.get(R.drawable.ic_qs_powershare);
        state.hasLongClickEffect = false;
        try {
            state.value = mPowerShare.isEnabled();
        } catch (Exception ex) {