Merge "Fixed jarring touch ripple effect when turning on/off battery saver from quick settings" into qt-dev
This commit is contained in:
@@ -117,6 +117,7 @@ public interface QSTile {
|
|||||||
public String expandedAccessibilityClassName;
|
public String expandedAccessibilityClassName;
|
||||||
public SlashState slash;
|
public SlashState slash;
|
||||||
public boolean handlesLongClick = true;
|
public boolean handlesLongClick = true;
|
||||||
|
public boolean showRippleEffect = true;
|
||||||
|
|
||||||
public boolean copyTo(State other) {
|
public boolean copyTo(State other) {
|
||||||
if (other == null) throw new IllegalArgumentException();
|
if (other == null) throw new IllegalArgumentException();
|
||||||
@@ -135,7 +136,8 @@ public interface QSTile {
|
|||||||
|| !Objects.equals(other.isTransient, isTransient)
|
|| !Objects.equals(other.isTransient, isTransient)
|
||||||
|| !Objects.equals(other.dualTarget, dualTarget)
|
|| !Objects.equals(other.dualTarget, dualTarget)
|
||||||
|| !Objects.equals(other.slash, slash)
|
|| !Objects.equals(other.slash, slash)
|
||||||
|| !Objects.equals(other.handlesLongClick, handlesLongClick);
|
|| !Objects.equals(other.handlesLongClick, handlesLongClick)
|
||||||
|
|| !Objects.equals(other.showRippleEffect, showRippleEffect);
|
||||||
other.icon = icon;
|
other.icon = icon;
|
||||||
other.iconSupplier = iconSupplier;
|
other.iconSupplier = iconSupplier;
|
||||||
other.label = label;
|
other.label = label;
|
||||||
@@ -149,6 +151,7 @@ public interface QSTile {
|
|||||||
other.isTransient = isTransient;
|
other.isTransient = isTransient;
|
||||||
other.slash = slash != null ? slash.copy() : null;
|
other.slash = slash != null ? slash.copy() : null;
|
||||||
other.handlesLongClick = handlesLongClick;
|
other.handlesLongClick = handlesLongClick;
|
||||||
|
other.showRippleEffect = showRippleEffect;
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ import android.view.accessibility.AccessibilityEvent;
|
|||||||
import android.view.accessibility.AccessibilityNodeInfo;
|
import android.view.accessibility.AccessibilityNodeInfo;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.ImageView.ScaleType;
|
|
||||||
import android.widget.Switch;
|
import android.widget.Switch;
|
||||||
|
|
||||||
import com.android.settingslib.Utils;
|
import com.android.settingslib.Utils;
|
||||||
@@ -63,6 +62,7 @@ public class QSTileBaseView extends com.android.systemui.plugins.qs.QSTileView {
|
|||||||
private boolean mTileState;
|
private boolean mTileState;
|
||||||
private boolean mCollapsedView;
|
private boolean mCollapsedView;
|
||||||
private boolean mClicked;
|
private boolean mClicked;
|
||||||
|
private boolean mShowRippleEffect = true;
|
||||||
|
|
||||||
private final ImageView mBg;
|
private final ImageView mBg;
|
||||||
private final int mColorActive;
|
private final int mColorActive;
|
||||||
@@ -209,6 +209,7 @@ public class QSTileBaseView extends com.android.systemui.plugins.qs.QSTileView {
|
|||||||
mCircleColor = circleColor;
|
mCircleColor = circleColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mShowRippleEffect = state.showRippleEffect;
|
||||||
setClickable(state.state != Tile.STATE_UNAVAILABLE);
|
setClickable(state.state != Tile.STATE_UNAVAILABLE);
|
||||||
setLongClickable(state.handlesLongClick);
|
setLongClickable(state.handlesLongClick);
|
||||||
mIcon.setIcon(state, allowAnimations);
|
mIcon.setIcon(state, allowAnimations);
|
||||||
@@ -254,7 +255,7 @@ public class QSTileBaseView extends com.android.systemui.plugins.qs.QSTileView {
|
|||||||
@Override
|
@Override
|
||||||
public void setClickable(boolean clickable) {
|
public void setClickable(boolean clickable) {
|
||||||
super.setClickable(clickable);
|
super.setClickable(clickable);
|
||||||
setBackground(clickable ? mRipple : null);
|
setBackground(clickable && mShowRippleEffect ? mRipple : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
package com.android.systemui.qs.tiles;
|
package com.android.systemui.qs.tiles;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.provider.Settings.Secure;
|
||||||
import android.service.quicksettings.Tile;
|
import android.service.quicksettings.Tile;
|
||||||
import android.widget.Switch;
|
import android.widget.Switch;
|
||||||
|
|
||||||
@@ -23,6 +24,7 @@ import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
|||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
import com.android.systemui.plugins.qs.QSTile.BooleanState;
|
import com.android.systemui.plugins.qs.QSTile.BooleanState;
|
||||||
import com.android.systemui.qs.QSHost;
|
import com.android.systemui.qs.QSHost;
|
||||||
|
import com.android.systemui.qs.SecureSetting;
|
||||||
import com.android.systemui.qs.tileimpl.QSTileImpl;
|
import com.android.systemui.qs.tileimpl.QSTileImpl;
|
||||||
import com.android.systemui.statusbar.policy.BatteryController;
|
import com.android.systemui.statusbar.policy.BatteryController;
|
||||||
|
|
||||||
@@ -32,6 +34,7 @@ public class BatterySaverTile extends QSTileImpl<BooleanState> implements
|
|||||||
BatteryController.BatteryStateChangeCallback {
|
BatteryController.BatteryStateChangeCallback {
|
||||||
|
|
||||||
private final BatteryController mBatteryController;
|
private final BatteryController mBatteryController;
|
||||||
|
private final SecureSetting mSetting;
|
||||||
|
|
||||||
private int mLevel;
|
private int mLevel;
|
||||||
private boolean mPowerSave;
|
private boolean mPowerSave;
|
||||||
@@ -45,6 +48,12 @@ public class BatterySaverTile extends QSTileImpl<BooleanState> implements
|
|||||||
super(host);
|
super(host);
|
||||||
mBatteryController = batteryController;
|
mBatteryController = batteryController;
|
||||||
mBatteryController.observe(getLifecycle(), this);
|
mBatteryController.observe(getLifecycle(), this);
|
||||||
|
mSetting = new SecureSetting(mContext, mHandler, Secure.LOW_POWER_WARNING_ACKNOWLEDGED) {
|
||||||
|
@Override
|
||||||
|
protected void handleValueChanged(int value, boolean observedChange) {
|
||||||
|
handleRefreshState(null);
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -52,6 +61,12 @@ public class BatterySaverTile extends QSTileImpl<BooleanState> implements
|
|||||||
return new BooleanState();
|
return new BooleanState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void handleDestroy() {
|
||||||
|
super.handleDestroy();
|
||||||
|
mSetting.setListening(false);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMetricsCategory() {
|
public int getMetricsCategory() {
|
||||||
return MetricsEvent.QS_BATTERY_TILE;
|
return MetricsEvent.QS_BATTERY_TILE;
|
||||||
@@ -59,6 +74,7 @@ public class BatterySaverTile extends QSTileImpl<BooleanState> implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleSetListening(boolean listening) {
|
public void handleSetListening(boolean listening) {
|
||||||
|
mSetting.setListening(listening);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -88,6 +104,7 @@ public class BatterySaverTile extends QSTileImpl<BooleanState> implements
|
|||||||
state.contentDescription = state.label;
|
state.contentDescription = state.label;
|
||||||
state.value = mPowerSave;
|
state.value = mPowerSave;
|
||||||
state.expandedAccessibilityClassName = Switch.class.getName();
|
state.expandedAccessibilityClassName = Switch.class.getName();
|
||||||
|
state.showRippleEffect = mSetting.getValue() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user