Merge "Fixing stroked qs tile" into rvc-dev

This commit is contained in:
Jay Aliomer
2020-05-08 02:48:35 +00:00
committed by Android (Google) Code Review
4 changed files with 39 additions and 2 deletions

View File

@@ -559,6 +559,10 @@
<dimen name="resolver_max_width">480dp</dimen>
<!-- Tile Stroke width -->
<dimen name="config_qsTileStrokeWidthActive">-1dp</dimen>
<dimen name="config_qsTileStrokeWidthInactive">-1dp</dimen>
<!-- Amount to reduce the size of the circular mask by (to compensate for
aliasing effects). This is only used on circular displays. -->
<dimen name="circular_display_mask_thickness">1px</dimen>

View File

@@ -361,6 +361,8 @@
<java-symbol type="bool" name="config_disableUsbPermissionDialogs"/>
<java-symbol type="dimen" name="config_highResTaskSnapshotScale" />
<java-symbol type="dimen" name="config_lowResTaskSnapshotScale" />
<java-symbol type="dimen" name="config_qsTileStrokeWidthInactive" />
<java-symbol type="dimen" name="config_qsTileStrokeWidthActive" />
<java-symbol type="bool" name="config_use16BitTaskSnapshotPixelFormat" />
<java-symbol type="bool" name="config_hasRecents" />
<java-symbol type="string" name="config_recentsComponentName" />

View File

@@ -18,8 +18,10 @@ import static com.android.systemui.qs.tileimpl.QSIconViewImpl.QS_ANIM_LENGTH;
import android.animation.ValueAnimator;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.drawable.AdaptiveIconDrawable;
import android.graphics.drawable.Drawable;
@@ -64,6 +66,8 @@ public class QSTileBaseView extends com.android.systemui.plugins.qs.QSTileView {
private boolean mTileState;
private boolean mCollapsedView;
private boolean mShowRippleEffect = true;
private float mStrokeWidthActive;
private float mStrokeWidthInactive;
private final ImageView mBg;
private final TextView mDetailText;
@@ -83,6 +87,10 @@ public class QSTileBaseView extends com.android.systemui.plugins.qs.QSTileView {
// Default to Quick Tile padding, and QSTileView will specify its own padding.
int padding = context.getResources().getDimensionPixelSize(R.dimen.qs_quick_tile_padding);
mIconFrame = new FrameLayout(context);
mStrokeWidthActive = context.getResources()
.getDimension(com.android.internal.R.dimen.config_qsTileStrokeWidthActive);
mStrokeWidthInactive = context.getResources()
.getDimension(com.android.internal.R.dimen.config_qsTileStrokeWidthInactive);
int size = context.getResources().getDimensionPixelSize(R.dimen.qs_quick_tile_size);
addView(mIconFrame, new LayoutParams(size, size));
mBg = new ImageView(getContext());
@@ -206,7 +214,31 @@ public class QSTileBaseView extends com.android.systemui.plugins.qs.QSTileView {
mHandler.obtainMessage(H.STATE_CHANGED, state).sendToTarget();
}
private void updateStrokeShapeWidth(QSTile.State state) {
Resources resources = getContext().getResources();
if (!(mBg.getDrawable() instanceof ShapeDrawable)) {
return;
}
ShapeDrawable d = (ShapeDrawable) mBg.getDrawable();
d.getPaint().setStyle(Paint.Style.FILL);
switch (state.state) {
case Tile.STATE_INACTIVE:
if (mStrokeWidthInactive >= 0) {
d.getPaint().setStyle(Paint.Style.STROKE);
d.getPaint().setStrokeWidth(mStrokeWidthInactive);
}
break;
case Tile.STATE_ACTIVE:
if (mStrokeWidthActive >= 0) {
d.getPaint().setStyle(Paint.Style.STROKE);
d.getPaint().setStrokeWidth(mStrokeWidthActive);
}
break;
}
}
protected void handleStateChanged(QSTile.State state) {
updateStrokeShapeWidth(state);
int circleColor = getCircleColor(state.state);
boolean allowAnimations = animationsEnabled();
if (circleColor != mCircleColor) {

View File

@@ -24,6 +24,5 @@
<!-- Corner radius for bottom sheet system dialogs -->
<dimen name="config_bottomDialogCornerRadius">0dp</dimen>
<!-- Tile stroke width -->
<dimen name="config_qsTileStrokeWidthInactive">10dp</dimen>
<dimen name="config_qsTileStrokeWidthInactive">1dp</dimen>
</resources>