summaryrefslogtreecommitdiff
path: root/src/com/android/customization/model/theme
diff options
context:
space:
mode:
authorWesley.CW Wang <wesleycwwang@google.com>2020-10-30 20:06:06 +0800
committerWesley.CW Wang <wesleycwwang@google.com>2020-11-02 16:27:27 +0800
commitb51de81a49bbb120b55060a4b66551a4ad755ecf (patch)
tree71a30100c457b8c236dc222b221496be8349d63b /src/com/android/customization/model/theme
parent7813b07e150841e42f52330d3383c43021ee1cab (diff)
downloadThemePicker-b51de81a49bbb120b55060a4b66551a4ad755ecf.tar.gz
Adjust custom theme flow preview icon
- Change custom icon page thumbnail icon to widget icon, make it can load the drawable from Launcher package - Change preview icon(airplane mode) to battery icon Screenshot: https://screenshot.googleplex.com/9fp9tpW7hbTeA5s.png Bug: 159376354 Test: Manually, make full rom with ag/12947502, install local WPPG and check visually Change-Id: Iba98e8bed43ca0c7a393be42061beba78e5fed9d
Diffstat (limited to 'src/com/android/customization/model/theme')
-rw-r--r--src/com/android/customization/model/theme/custom/ThemeComponentOption.java31
1 files changed, 25 insertions, 6 deletions
diff --git a/src/com/android/customization/model/theme/custom/ThemeComponentOption.java b/src/com/android/customization/model/theme/custom/ThemeComponentOption.java
index 5922f5cb..3db4bad5 100644
--- a/src/com/android/customization/model/theme/custom/ThemeComponentOption.java
+++ b/src/com/android/customization/model/theme/custom/ThemeComponentOption.java
@@ -23,11 +23,14 @@ import static com.android.customization.model.ResourceConstants.OVERLAY_CATEGORY
import static com.android.customization.model.ResourceConstants.OVERLAY_CATEGORY_ICON_SYSUI;
import static com.android.customization.model.ResourceConstants.OVERLAY_CATEGORY_ICON_THEMEPICKER;
import static com.android.customization.model.ResourceConstants.OVERLAY_CATEGORY_SHAPE;
+import static com.android.customization.model.ResourceConstants.getLauncherPackage;
import android.content.Context;
+import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.ColorStateList;
import android.content.res.Configuration;
import android.content.res.Resources;
+import android.content.res.Resources.NotFoundException;
import android.content.res.Resources.Theme;
import android.content.res.TypedArray;
import android.graphics.Path;
@@ -36,6 +39,7 @@ import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.StateListDrawable;
+import android.text.TextUtils;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
@@ -141,7 +145,7 @@ public abstract class ThemeComponentOption implements CustomizationOption<ThemeC
container.setContentDescription(
container.getContext().getString(R.string.font_preview_content_description));
- bindPreviewHeader(container, R.string.preview_name_font, R.drawable.ic_font);
+ bindPreviewHeader(container, R.string.preview_name_font, R.drawable.ic_font, null);
ViewGroup cardBody = container.findViewById(R.id.theme_preview_card_body_container);
if (cardBody.getChildCount() == 0) {
@@ -165,12 +169,24 @@ public abstract class ThemeComponentOption implements CustomizationOption<ThemeC
}
void bindPreviewHeader(ViewGroup container, @StringRes int headerTextResId,
- @DrawableRes int headerIcon) {
+ @DrawableRes int headerIcon, String drawableName) {
TextView header = container.findViewById(R.id.theme_preview_card_header);
header.setText(headerTextResId);
Context context = container.getContext();
- Drawable icon = context.getResources().getDrawable(headerIcon, context.getTheme());
+ Drawable icon;
+ if (!TextUtils.isEmpty(drawableName)) {
+ try {
+ Resources resources = context.getPackageManager()
+ .getResourcesForApplication(getLauncherPackage(context));
+ icon = resources.getDrawable(resources.getIdentifier(
+ drawableName, "drawable", getLauncherPackage(context)), null);
+ } catch (NameNotFoundException | NotFoundException e) {
+ icon = context.getResources().getDrawable(headerIcon, context.getTheme());
+ }
+ } else {
+ icon = context.getResources().getDrawable(headerIcon, context.getTheme());
+ }
int size = context.getResources().getDimensionPixelSize(R.dimen.card_header_icon_size);
icon.setBounds(0, 0, size, size);
@@ -231,7 +247,8 @@ public abstract class ThemeComponentOption implements CustomizationOption<ThemeC
container.setContentDescription(
container.getContext().getString(R.string.icon_preview_content_description));
- bindPreviewHeader(container, R.string.preview_name_icon, R.drawable.ic_wifi_24px);
+ bindPreviewHeader(container, R.string.preview_name_icon, R.drawable.ic_widget,
+ "ic_widget");
ViewGroup cardBody = container.findViewById(R.id.theme_preview_card_body_container);
if (cardBody.getChildCount() == 0) {
@@ -364,7 +381,8 @@ public abstract class ThemeComponentOption implements CustomizationOption<ThemeC
container.setContentDescription(
container.getContext().getString(R.string.color_preview_content_description));
- bindPreviewHeader(container, R.string.preview_name_color, R.drawable.ic_colorize_24px);
+ bindPreviewHeader(container, R.string.preview_name_color, R.drawable.ic_colorize_24px,
+ null);
ViewGroup cardBody = container.findViewById(R.id.theme_preview_card_body_container);
if (cardBody.getChildCount() == 0) {
@@ -507,7 +525,8 @@ public abstract class ThemeComponentOption implements CustomizationOption<ThemeC
container.setContentDescription(
container.getContext().getString(R.string.shape_preview_content_description));
- bindPreviewHeader(container, R.string.preview_name_shape, R.drawable.ic_shapes_24px);
+ bindPreviewHeader(container, R.string.preview_name_shape, R.drawable.ic_shapes_24px,
+ null);
ViewGroup cardBody = container.findViewById(R.id.theme_preview_card_body_container);
if (cardBody.getChildCount() == 0) {