* commit 'df80f1c92be7446895b98f28e1c1d7c7649ba399': QS: Create the tile background once per tile.
This commit is contained in:
@@ -63,6 +63,7 @@ public class QSTileView extends ViewGroup {
|
|||||||
private boolean mDual;
|
private boolean mDual;
|
||||||
private OnClickListener mClickPrimary;
|
private OnClickListener mClickPrimary;
|
||||||
private OnClickListener mClickSecondary;
|
private OnClickListener mClickSecondary;
|
||||||
|
private Drawable mTileBackground;
|
||||||
private RippleDrawable mRipple;
|
private RippleDrawable mRipple;
|
||||||
|
|
||||||
public QSTileView(Context context) {
|
public QSTileView(Context context) {
|
||||||
@@ -75,6 +76,7 @@ public class QSTileView extends ViewGroup {
|
|||||||
mTilePaddingBelowIconPx = res.getDimensionPixelSize(R.dimen.qs_tile_padding_below_icon);
|
mTilePaddingBelowIconPx = res.getDimensionPixelSize(R.dimen.qs_tile_padding_below_icon);
|
||||||
mDualTileVerticalPaddingPx =
|
mDualTileVerticalPaddingPx =
|
||||||
res.getDimensionPixelSize(R.dimen.qs_dual_tile_padding_vertical);
|
res.getDimensionPixelSize(R.dimen.qs_dual_tile_padding_vertical);
|
||||||
|
mTileBackground = newTileBackground();
|
||||||
recreateLabel();
|
recreateLabel();
|
||||||
setClipChildren(false);
|
setClipChildren(false);
|
||||||
|
|
||||||
@@ -175,22 +177,21 @@ public class QSTileView extends ViewGroup {
|
|||||||
if (changed) {
|
if (changed) {
|
||||||
recreateLabel();
|
recreateLabel();
|
||||||
}
|
}
|
||||||
Drawable tileBackground = getTileBackground();
|
if (mTileBackground instanceof RippleDrawable) {
|
||||||
if (tileBackground instanceof RippleDrawable) {
|
setRipple((RippleDrawable) mTileBackground);
|
||||||
setRipple((RippleDrawable) tileBackground);
|
|
||||||
}
|
}
|
||||||
if (dual) {
|
if (dual) {
|
||||||
mTopBackgroundView.setOnClickListener(mClickPrimary);
|
mTopBackgroundView.setOnClickListener(mClickPrimary);
|
||||||
setOnClickListener(null);
|
setOnClickListener(null);
|
||||||
setClickable(false);
|
setClickable(false);
|
||||||
setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
|
setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
|
||||||
mTopBackgroundView.setBackground(tileBackground);
|
mTopBackgroundView.setBackground(mTileBackground);
|
||||||
} else {
|
} else {
|
||||||
mTopBackgroundView.setOnClickListener(null);
|
mTopBackgroundView.setOnClickListener(null);
|
||||||
mTopBackgroundView.setClickable(false);
|
mTopBackgroundView.setClickable(false);
|
||||||
setOnClickListener(mClickPrimary);
|
setOnClickListener(mClickPrimary);
|
||||||
setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
|
setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
|
||||||
setBackground(tileBackground);
|
setBackground(mTileBackground);
|
||||||
}
|
}
|
||||||
mTopBackgroundView.setFocusable(dual);
|
mTopBackgroundView.setFocusable(dual);
|
||||||
setFocusable(!dual);
|
setFocusable(!dual);
|
||||||
@@ -217,7 +218,7 @@ public class QSTileView extends ViewGroup {
|
|||||||
return icon;
|
return icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Drawable getTileBackground() {
|
private Drawable newTileBackground() {
|
||||||
final int[] attrs = new int[] { android.R.attr.selectableItemBackgroundBorderless };
|
final int[] attrs = new int[] { android.R.attr.selectableItemBackgroundBorderless };
|
||||||
final TypedArray ta = mContext.obtainStyledAttributes(attrs);
|
final TypedArray ta = mContext.obtainStyledAttributes(attrs);
|
||||||
final Drawable d = ta.getDrawable(0);
|
final Drawable d = ta.getDrawable(0);
|
||||||
|
|||||||
Reference in New Issue
Block a user