Merge "Fixed jarring touch ripple effect when turning on/off battery saver from quick settings" into qt-dev

This commit is contained in:
Shawn Lin
2019-04-10 06:49:12 +00:00
committed by Android (Google) Code Review
3 changed files with 24 additions and 3 deletions

View File

@@ -117,6 +117,7 @@ public interface QSTile {
public String expandedAccessibilityClassName;
public SlashState slash;
public boolean handlesLongClick = true;
public boolean showRippleEffect = true;
public boolean copyTo(State other) {
if (other == null) throw new IllegalArgumentException();
@@ -135,7 +136,8 @@ public interface QSTile {
|| !Objects.equals(other.isTransient, isTransient)
|| !Objects.equals(other.dualTarget, dualTarget)
|| !Objects.equals(other.slash, slash)
|| !Objects.equals(other.handlesLongClick, handlesLongClick);
|| !Objects.equals(other.handlesLongClick, handlesLongClick)
|| !Objects.equals(other.showRippleEffect, showRippleEffect);
other.icon = icon;
other.iconSupplier = iconSupplier;
other.label = label;
@@ -149,6 +151,7 @@ public interface QSTile {
other.isTransient = isTransient;
other.slash = slash != null ? slash.copy() : null;
other.handlesLongClick = handlesLongClick;
other.showRippleEffect = showRippleEffect;
return changed;
}

View File

@@ -40,7 +40,6 @@ import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
import android.widget.Switch;
import com.android.settingslib.Utils;
@@ -63,6 +62,7 @@ public class QSTileBaseView extends com.android.systemui.plugins.qs.QSTileView {
private boolean mTileState;
private boolean mCollapsedView;
private boolean mClicked;
private boolean mShowRippleEffect = true;
private final ImageView mBg;
private final int mColorActive;
@@ -209,6 +209,7 @@ public class QSTileBaseView extends com.android.systemui.plugins.qs.QSTileView {
mCircleColor = circleColor;
}
mShowRippleEffect = state.showRippleEffect;
setClickable(state.state != Tile.STATE_UNAVAILABLE);
setLongClickable(state.handlesLongClick);
mIcon.setIcon(state, allowAnimations);
@@ -254,7 +255,7 @@ public class QSTileBaseView extends com.android.systemui.plugins.qs.QSTileView {
@Override
public void setClickable(boolean clickable) {
super.setClickable(clickable);
setBackground(clickable ? mRipple : null);
setBackground(clickable && mShowRippleEffect ? mRipple : null);
}
@Override

View File

@@ -16,6 +16,7 @@
package com.android.systemui.qs.tiles;
import android.content.Intent;
import android.provider.Settings.Secure;
import android.service.quicksettings.Tile;
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.plugins.qs.QSTile.BooleanState;
import com.android.systemui.qs.QSHost;
import com.android.systemui.qs.SecureSetting;
import com.android.systemui.qs.tileimpl.QSTileImpl;
import com.android.systemui.statusbar.policy.BatteryController;
@@ -32,6 +34,7 @@ public class BatterySaverTile extends QSTileImpl<BooleanState> implements
BatteryController.BatteryStateChangeCallback {
private final BatteryController mBatteryController;
private final SecureSetting mSetting;
private int mLevel;
private boolean mPowerSave;
@@ -45,6 +48,12 @@ public class BatterySaverTile extends QSTileImpl<BooleanState> implements
super(host);
mBatteryController = batteryController;
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
@@ -52,6 +61,12 @@ public class BatterySaverTile extends QSTileImpl<BooleanState> implements
return new BooleanState();
}
@Override
protected void handleDestroy() {
super.handleDestroy();
mSetting.setListening(false);
}
@Override
public int getMetricsCategory() {
return MetricsEvent.QS_BATTERY_TILE;
@@ -59,6 +74,7 @@ public class BatterySaverTile extends QSTileImpl<BooleanState> implements
@Override
public void handleSetListening(boolean listening) {
mSetting.setListening(listening);
}
@Override
@@ -88,6 +104,7 @@ public class BatterySaverTile extends QSTileImpl<BooleanState> implements
state.contentDescription = state.label;
state.value = mPowerSave;
state.expandedAccessibilityClassName = Switch.class.getName();
state.showRippleEffect = mSetting.getValue() == 0;
}
@Override