Implement 3 shades of folder icon/container fill color

Bug: 130451254

Change-Id: I36d885a2b0247f1bb84cb98073459853ae723331
This commit is contained in:
Hyunyoung Song 2019-05-13 23:23:05 -07:00
parent c857ad8049
commit e751d90c44
11 changed files with 92 additions and 7 deletions

View File

@ -35,6 +35,10 @@ import java.util.ArrayList;
@TargetApi(Build.VERSION_CODES.P)
public class WallpaperColorInfo implements OnColorsChangedListener {
private static final int MAIN_COLOR_LIGHT = 0xffdadce0;
private static final int MAIN_COLOR_DARK = 0xff202124;
private static final int MAIN_COLOR_REGULAR = 0xff000000;
private static final Object sInstanceLock = new Object();
private static WallpaperColorInfo sInstance;
@ -79,6 +83,10 @@ public class WallpaperColorInfo implements OnColorsChangedListener {
return mExtractionInfo.supportsDarkText;
}
public boolean isMainColorDark() {
return mExtractionInfo.mainColor == MAIN_COLOR_DARK;
}
@Override
public void onColorsChanged(WallpaperColors colors, int which) {
if ((which & FLAG_SYSTEM) != 0) {

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2019 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="?attr/folderFillColor" />
<corners android:radius="?android:attr/dialogCornerRadius" />
</shape>

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2019 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="?attr/folderFillColor" />
<corners android:radius="@dimen/bg_round_rect_radius" />
</shape>

View File

@ -18,5 +18,6 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:launcher="http://schemas.android.com/apk/res-auto"
style="@style/BaseIcon"
android:textColor="?attr/folderTextColor"
android:includeFontPadding="false"
launcher:iconDisplay="folder" />

View File

@ -18,7 +18,7 @@
xmlns:launcher="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/round_rect_primary"
android:background="@drawable/round_rect_folder"
android:elevation="5dp"
android:orientation="vertical" >

View File

@ -36,8 +36,10 @@
<attr name="loadingIconColor" format="color" />
<attr name="folderDotColor" format="color" />
<attr name="folderFillColor" format="color" />
<attr name="folderIconRadius" format="float" />
<attr name="folderIconBorderColor" format="color" />
<attr name="folderTextColor" format="color" />
<!-- BubbleTextView specific attributes. -->
<declare-styleable name="BubbleTextView">
@ -55,7 +57,7 @@
<!-- BubbleTextView specific attributes. -->
<declare-styleable name="FolderIconPreview">
<attr name="android:colorPrimary" />
<attr name="folderFillColor" />
<attr name="folderIconBorderColor" />
<attr name="folderDotColor" />
</declare-styleable>

View File

@ -26,6 +26,7 @@
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowShowWallpaper">true</item>
<item name="folderTextColor">?attr/workspaceTextColor</item>
</style>
<style name="LauncherTheme" parent="@style/BaseLauncherTheme">
@ -44,7 +45,9 @@
<item name="workspaceStatusBarScrim">@drawable/workspace_bg</item>
<item name="widgetsTheme">@style/WidgetContainerTheme</item>
<item name="folderDotColor">?android:attr/colorPrimary</item>
<item name="folderFillColor">#CDFFFFFF</item>
<item name="folderIconBorderColor">?android:attr/colorPrimary</item>
<item name="folderTextColor">#FF212121</item>
<item name="loadingIconColor">#CCFFFFFF</item>
<item name="android:windowTranslucentStatus">false</item>
@ -54,6 +57,11 @@
<item name="android:navigationBarColor">#00000000</item>
</style>
<style name="LauncherTheme.DarkMainColor" parent="@style/LauncherTheme">
<item name="folderFillColor">#FF3C4043</item> <!-- 100% GM2 800 -->
<item name="folderTextColor">?attr/workspaceTextColor</item>
</style>
<style name="LauncherTheme.DarkText" parent="@style/LauncherTheme">
<item name="workspaceTextColor">#FF212121</item>
<item name="allAppsInterimScrimAlpha">128</item>
@ -63,7 +71,9 @@
<item name="isWorkspaceDarkText">true</item>
<item name="workspaceStatusBarScrim">@null</item>
<item name="folderDotColor">#FF464646</item>
<item name="folderFillColor">#CDFFFFFF</item>
<item name="folderIconBorderColor">#FF80868B</item>
<item name="folderTextColor">?attr/workspaceTextColor</item>
</style>
<style name="LauncherTheme.Dark" parent="@style/LauncherTheme">
@ -81,13 +91,22 @@
<item name="popupColorTertiary">#757575</item> <!-- Gray 600 -->
<item name="widgetsTheme">@style/WidgetContainerTheme.Dark</item>
<item name="folderDotColor">#FF464646</item>
<item name="folderFillColor">#DD3C4043</item> <!-- 87% GM2 800 -->
<item name="folderIconBorderColor">#FF80868B</item>
<item name="folderTextColor">@android:color/white</item>
<item name="isMainColorDark">true</item>
<item name="loadingIconColor">#99FFFFFF</item>
</style>
<style name="LauncherTheme.Dark.DarkMainColor" parent="@style/LauncherTheme.Dark">
<item name="folderFillColor">#FF3C4043</item> <!-- 100% GM2 800 -->
<item name="folderTextColor">@android:color/white</item>
</style>
<style name="LauncherTheme.Dark.DarkText" parent="@style/LauncherTheme.Dark">
<item name="allAppsInterimScrimAlpha">25</item>
<item name="folderFillColor">#CDFFFFFF</item>
<item name="folderTextColor">?attr/workspaceTextColor</item>
<item name="workspaceTextColor">#FF212121</item>
<item name="workspaceShadowColor">@android:color/transparent</item>
<item name="workspaceAmbientShadowColor">@android:color/transparent</item>
@ -99,8 +118,11 @@
<!-- A derivative project can extend these themes to customize the application theme without
affecting the base theme -->
<style name="AppTheme" parent="@style/LauncherTheme" />
<style name="AppTheme.DarkMainColor" parent="@style/LauncherTheme.DarkMainColor" />
<style name="AppTheme.DarkText" parent="@style/LauncherTheme.DarkText" />
<style name="AppTheme.Dark" parent="@style/LauncherTheme.Dark" />
<style name="AppTheme.Dark.DarkMainColor" parent="@style/LauncherTheme.Dark.DarkMainColor" />
<style name="AppTheme.Dark.DarkText" parent="@style/LauncherTheme.Dark.DarkText" />
<style name="AppItemActivityTheme" parent="@android:style/Theme.Material.Light.Dialog.Alert">
@ -157,7 +179,7 @@
<item name="android:shadowRadius">0</item>
</style>
<!-- Icon displayed on the worksapce -->
<!-- Icon displayed on the workspace -->
<style name="BaseIcon.Workspace" >
<item name="android:shadowRadius">2.0</item>
<item name="android:shadowColor">?attr/workspaceShadowColor</item>

View File

@ -152,7 +152,7 @@ public class FolderAnimationManager {
final float yDistance = initialY - lp.y;
// Set up the Folder background.
final int finalColor = Themes.getAttrColor(mContext, android.R.attr.colorPrimary);
final int finalColor = Themes.getAttrColor(mContext, R.attr.folderFillColor);
final int initialColor = setColorAlphaBound(
finalColor, mPreviewBackground.getBackgroundAlpha());
mFolderBackground.mutate();

View File

@ -131,7 +131,7 @@ public class PreviewBackground {
TypedArray ta = context.getTheme().obtainStyledAttributes(R.styleable.FolderIconPreview);
mDotColor = ta.getColor(R.styleable.FolderIconPreview_folderDotColor, 0);
mStrokeColor = ta.getColor(R.styleable.FolderIconPreview_folderIconBorderColor, 0);
mBgColor = ta.getColor(R.styleable.FolderIconPreview_android_colorPrimary, 0);
mBgColor = ta.getColor(R.styleable.FolderIconPreview_folderFillColor, 0);
ta.recycle();
DeviceProfile grid = activity.getWallpaperDeviceProfile();

View File

@ -48,10 +48,12 @@ public class Themes {
if (darkTheme) {
return wallpaperColorInfo.supportsDarkText() ?
R.style.AppTheme_Dark_DarkText : R.style.AppTheme_Dark;
R.style.AppTheme_Dark_DarkText : wallpaperColorInfo.isMainColorDark() ?
R.style.AppTheme_Dark_DarkMainColor : R.style.AppTheme_Dark;
} else {
return wallpaperColorInfo.supportsDarkText() ?
R.style.AppTheme_DarkText : R.style.AppTheme;
R.style.AppTheme_DarkText : wallpaperColorInfo.isMainColorDark() ?
R.style.AppTheme_DarkMainColor : R.style.AppTheme;
}
}

View File

@ -30,6 +30,10 @@ import static android.app.WallpaperManager.FLAG_SYSTEM;
public class WallpaperColorInfo implements WallpaperManagerCompat.OnColorsChangedListenerCompat {
private static final int MAIN_COLOR_LIGHT = 0xffdadce0;
private static final int MAIN_COLOR_DARK = 0xff202124;
private static final int MAIN_COLOR_REGULAR = 0xff000000;
private static final int FALLBACK_COLOR = Color.WHITE;
private static final Object sInstanceLock = new Object();
private static WallpaperColorInfo sInstance;
@ -76,6 +80,10 @@ public class WallpaperColorInfo implements WallpaperManagerCompat.OnColorsChange
return mSupportsDarkText;
}
public boolean isMainColorDark() {
return mMainColor == MAIN_COLOR_DARK;
}
@Override
public void onColorsChanged(WallpaperColorsCompat colors, int which) {
if ((which & FLAG_SYSTEM) != 0) {