Skip to content

Commit 99444bd

Browse files
committed
Shade: Replace TextView replacement by simple style copy again
1 parent 32ddf53 commit 99444bd

File tree

1 file changed

+33
-6
lines changed

1 file changed

+33
-6
lines changed

shade/src/amirz/shade/views/ThemedSmartspaceHostView.java

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import android.graphics.Bitmap;
55
import android.graphics.BlurMaskFilter;
66
import android.graphics.Canvas;
7+
import android.graphics.Color;
78
import android.graphics.drawable.BitmapDrawable;
89
import android.graphics.drawable.Drawable;
910
import android.util.Log;
@@ -27,6 +28,7 @@
2728

2829
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
2930
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
31+
import static com.android.launcher3.icons.GraphicsUtils.setColorAlphaBound;
3032

3133
public class ThemedSmartspaceHostView extends SmartspaceHostView {
3234
private static final String TAG = "ThemedSmartspaceHostView";
@@ -123,9 +125,33 @@ private void overrideLayout(LinearLayout l) {
123125
}
124126

125127
private TextView replaceTextView(TextView tv) {
126-
return mDstv == null
127-
? tv
128-
: mDstv.cloneTextView(tv);
128+
if (mDstv != null) {
129+
int textAlpha = Color.alpha(tv.getCurrentTextColor());
130+
if (Themes.getAttrBoolean(getContext(), R.attr.isWorkspaceDarkText)) {
131+
tv.getPaint().clearShadowLayer();
132+
} else {
133+
tv.getPaint().setShadowLayer(mDstv.mShadowInfo.ambientShadowBlur, 0, 0,
134+
setColorAlphaBound(mDstv.mShadowInfo.ambientShadowColor, textAlpha));
135+
}
136+
tv.setLetterSpacing(mDstv.getLetterSpacing());
137+
tv.setTextColor(mDstv.getTextColors());
138+
tv.setMaxLines(mDstv.getMaxLines());
139+
tv.setEllipsize(mDstv.getEllipsize());
140+
tv.setTypeface(mDstv.getTypeface());
141+
}
142+
143+
int minPadding = getContext().getResources()
144+
.getDimensionPixelSize(R.dimen.text_vertical_padding);
145+
tv.setPadding(tv.getPaddingLeft(), Math.max(tv.getPaddingTop(), minPadding),
146+
tv.getPaddingRight(), Math.max(tv.getPaddingBottom(), minPadding));
147+
tv.setHorizontallyScrolling(true);
148+
149+
return tv;
150+
151+
// We do not have to clone the textView, since we are not using the double shadow.
152+
//return mDstv == null
153+
// ? tv
154+
// : mDstv.cloneTextView(tv);
129155
}
130156

131157
private void overrideView(View v, int textColor, int maxDividerSize) {
@@ -138,9 +164,10 @@ private void overrideView(View v, int textColor, int maxDividerSize) {
138164
for (int i = 0; i < vg.getChildCount(); i++) {
139165
View vc = vg.getChildAt(i);
140166
if (vc instanceof TextView) {
141-
ViewGroup.LayoutParams lp = vc.getLayoutParams();
142-
vg.removeViewAt(i);
143-
vg.addView(replaceTextView((TextView) vc), i, lp);
167+
replaceTextView((TextView) vc);
168+
//ViewGroup.LayoutParams lp = vc.getLayoutParams();
169+
//vg.removeViewAt(i);
170+
//vg.addView(replaceTextView((TextView) vc), i, lp);
144171
} else if (vc instanceof ImageView) {
145172
ImageView iv = (ImageView) vc;
146173
ViewGroup.LayoutParams lp = iv.getLayoutParams();

0 commit comments

Comments
 (0)