[automerger] Theme updates for dark text: am: 337fcb7983
Change-Id: Ib43cca83d5cc0e02a6f5cab4b20ecf325361b08b
This commit is contained in:
commit
a4feb0c385
|
@ -45,10 +45,6 @@ import com.android.launcher3.views.ScrimView;
|
|||
*/
|
||||
public class ShelfScrimView extends ScrimView {
|
||||
|
||||
private static final int THRESHOLD_ALPHA_DARK = 102;
|
||||
private static final int THRESHOLD_ALPHA_LIGHT = 46;
|
||||
private static final int THRESHOLD_ALPHA_SUPER_LIGHT = 128;
|
||||
|
||||
// In transposed layout, we simply draw a flat color.
|
||||
private boolean mDrawingFlatColor;
|
||||
|
||||
|
@ -77,13 +73,7 @@ public class ShelfScrimView extends ScrimView {
|
|||
mMaxScrimAlpha = OVERVIEW.getWorkspaceScrimAlpha(mLauncher);
|
||||
|
||||
mEndAlpha = Color.alpha(mEndScrim);
|
||||
if (Themes.getAttrBoolean(mLauncher, R.attr.isMainColorDark)) {
|
||||
mThresholdAlpha = THRESHOLD_ALPHA_DARK;
|
||||
} else if (Themes.getAttrBoolean(mLauncher, R.attr.isWorkspaceDarkText)) {
|
||||
mThresholdAlpha = THRESHOLD_ALPHA_SUPER_LIGHT;
|
||||
} else {
|
||||
mThresholdAlpha = THRESHOLD_ALPHA_LIGHT;
|
||||
}
|
||||
mThresholdAlpha = Themes.getAttrInteger(context, R.attr.allAppsInterimScrimAlpha);
|
||||
mRadius = mLauncher.getResources().getDimension(R.dimen.shelf_surface_radius);
|
||||
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ import android.graphics.Matrix;
|
|||
import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.Shader;
|
||||
import android.support.v4.graphics.ColorUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.FloatProperty;
|
||||
import android.util.Property;
|
||||
|
@ -37,8 +38,10 @@ import android.view.View;
|
|||
import com.android.launcher3.BaseActivity;
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.util.SystemUiController;
|
||||
import com.android.launcher3.util.Themes;
|
||||
import com.android.quickstep.TaskOverlayFactory;
|
||||
import com.android.quickstep.TaskOverlayFactory.TaskOverlay;
|
||||
import com.android.systemui.shared.recents.model.Task;
|
||||
|
@ -50,6 +53,7 @@ import com.android.systemui.shared.recents.model.ThumbnailData;
|
|||
public class TaskThumbnailView extends View {
|
||||
|
||||
private static final LightingColorFilter[] sDimFilterCache = new LightingColorFilter[256];
|
||||
private static final LightingColorFilter[] sHighlightFilterCache = new LightingColorFilter[256];
|
||||
|
||||
public static final Property<TaskThumbnailView, Float> DIM_ALPHA_MULTIPLIER =
|
||||
new FloatProperty<TaskThumbnailView>("dimAlphaMultiplier") {
|
||||
|
@ -68,6 +72,7 @@ public class TaskThumbnailView extends View {
|
|||
|
||||
private final BaseActivity mActivity;
|
||||
private final TaskOverlay mOverlay;
|
||||
private final boolean mIsDarkTextTheme;
|
||||
private final Paint mPaint = new Paint();
|
||||
private final Paint mBackgroundPaint = new Paint();
|
||||
|
||||
|
@ -97,6 +102,7 @@ public class TaskThumbnailView extends View {
|
|||
mPaint.setFilterBitmap(true);
|
||||
mBackgroundPaint.setColor(Color.WHITE);
|
||||
mActivity = BaseActivity.fromContext(context);
|
||||
mIsDarkTextTheme = Themes.getAttrBoolean(mActivity, R.attr.isWorkspaceDarkText);
|
||||
}
|
||||
|
||||
public void bind() {
|
||||
|
@ -198,7 +204,7 @@ public class TaskThumbnailView extends View {
|
|||
private void updateThumbnailPaintFilter() {
|
||||
int mul = (int) ((1 - mDimAlpha * mDimAlphaMultiplier) * 255);
|
||||
if (mBitmapShader != null) {
|
||||
LightingColorFilter filter = getLightingColorFilter(mul);
|
||||
LightingColorFilter filter = getDimmingColorFilter(mul, mIsDarkTextTheme);
|
||||
mPaint.setColorFilter(filter);
|
||||
mBackgroundPaint.setColorFilter(filter);
|
||||
} else {
|
||||
|
@ -287,16 +293,25 @@ public class TaskThumbnailView extends View {
|
|||
updateThumbnailMatrix();
|
||||
}
|
||||
|
||||
private static LightingColorFilter getLightingColorFilter(int dimColor) {
|
||||
if (dimColor < 0) {
|
||||
dimColor = 0;
|
||||
} else if (dimColor > 255) {
|
||||
dimColor = 255;
|
||||
private static LightingColorFilter getDimmingColorFilter(int intensity, boolean shouldLighten) {
|
||||
intensity = Utilities.boundToRange(intensity, 0, 255);
|
||||
if (intensity == 255) {
|
||||
return null;
|
||||
}
|
||||
if (sDimFilterCache[dimColor] == null) {
|
||||
sDimFilterCache[dimColor] =
|
||||
new LightingColorFilter(Color.argb(255, dimColor, dimColor, dimColor), 0);
|
||||
if (shouldLighten) {
|
||||
if (sHighlightFilterCache[intensity] == null) {
|
||||
int colorAdd = 255 - intensity;
|
||||
sHighlightFilterCache[intensity] = new LightingColorFilter(
|
||||
Color.argb(255, intensity, intensity, intensity),
|
||||
Color.argb(255, colorAdd, colorAdd, colorAdd));
|
||||
}
|
||||
return sHighlightFilterCache[intensity];
|
||||
} else {
|
||||
if (sDimFilterCache[intensity] == null) {
|
||||
sDimFilterCache[intensity] = new LightingColorFilter(
|
||||
Color.argb(255, intensity, intensity, intensity), 0);
|
||||
}
|
||||
return sDimFilterCache[intensity];
|
||||
}
|
||||
return sDimFilterCache[dimColor];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
<!-- Attributes used for launcher theme -->
|
||||
<attr name="allAppsScrimColor" format="color" />
|
||||
<attr name="allAppsInterimScrimAlpha" format="integer" />
|
||||
<attr name="allAppsNavBarScrimColor" format="color" />
|
||||
<attr name="popupColorPrimary" format="color" />
|
||||
<attr name="popupColorSecondary" format="color" />
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
<style name="BaseLauncherThemeWithCustomAttrs" parent="@style/BaseLauncherTheme">
|
||||
<item name="allAppsScrimColor">#EAFFFFFF</item>
|
||||
<item name="allAppsInterimScrimAlpha">46</item>
|
||||
<item name="allAppsNavBarScrimColor">#66FFFFFF</item>
|
||||
<item name="popupColorPrimary">#FFF</item>
|
||||
<item name="popupColorSecondary">#F5F5F5</item> <!-- Gray 100 -->
|
||||
|
@ -47,6 +48,7 @@
|
|||
|
||||
<style name="LauncherTheme.DarkText" parent="@style/LauncherTheme">
|
||||
<item name="workspaceTextColor">#FF212121</item>
|
||||
<item name="allAppsInterimScrimAlpha">128</item>
|
||||
<item name="workspaceShadowColor">@android:color/transparent</item>
|
||||
<item name="workspaceAmbientShadowColor">@android:color/transparent</item>
|
||||
<item name="workspaceKeyShadowColor">@android:color/transparent</item>
|
||||
|
@ -62,6 +64,7 @@
|
|||
<item name="android:colorControlHighlight">#A0FFFFFF</item>
|
||||
<item name="android:colorPrimary">#FF212121</item>
|
||||
<item name="allAppsScrimColor">#EA212121</item>
|
||||
<item name="allAppsInterimScrimAlpha">102</item>
|
||||
<item name="allAppsNavBarScrimColor">#80000000</item>
|
||||
<item name="popupColorPrimary">?android:attr/colorPrimary</item>
|
||||
<item name="popupColorSecondary">#424242</item> <!-- Gray 800 -->
|
||||
|
@ -71,6 +74,7 @@
|
|||
</style>
|
||||
|
||||
<style name="LauncherThemeDark.DarKText" parent="@style/LauncherThemeDark">
|
||||
<item name="allAppsInterimScrimAlpha">25</item>
|
||||
<item name="workspaceTextColor">#FF212121</item>
|
||||
<item name="workspaceShadowColor">@android:color/transparent</item>
|
||||
<item name="workspaceAmbientShadowColor">@android:color/transparent</item>
|
||||
|
|
|
@ -52,6 +52,13 @@ public class Themes {
|
|||
return value;
|
||||
}
|
||||
|
||||
public static int getAttrInteger(Context context, int attr) {
|
||||
TypedArray ta = context.obtainStyledAttributes(new int[]{attr});
|
||||
int value = ta.getInteger(0, 0);
|
||||
ta.recycle();
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the alpha corresponding to the theme attribute {@param attr}, in the range [0, 255].
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue