summaryrefslogtreecommitdiff
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
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
-rw-r--r--res/drawable/ic_widget.xml24
-rw-r--r--src/com/android/customization/model/ResourceConstants.java2
-rw-r--r--src/com/android/customization/model/theme/custom/ThemeComponentOption.java31
3 files changed, 50 insertions, 7 deletions
diff --git a/res/drawable/ic_widget.xml b/res/drawable/ic_widget.xml
new file mode 100644
index 00000000..7d91d2bc
--- /dev/null
+++ b/res/drawable/ic_widget.xml
@@ -0,0 +1,24 @@
+<!--
+ Copyright (C) 2020 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.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+ <path
+ android:fillColor="#FF000000"
+ android:pathData="M16.66,4.52l2.83,2.83l-2.83,2.83l-2.83,-2.83L16.66,4.52M9,5v4H5V5H9M19,15v4h-4v-4H19M9,15v4H5v-4H9M16.66,1.69L11,7.34L16.66,13l5.66,-5.66L16.66,1.69L16.66,1.69zM11,3H3v8h8V7.34V3L11,3zM21,13h-4.34H13v8h8V13L21,13zM11,13H3v8h8V13L11,13z"/>
+</vector>
diff --git a/src/com/android/customization/model/ResourceConstants.java b/src/com/android/customization/model/ResourceConstants.java
index 0b1dec22..86eb7f4b 100644
--- a/src/com/android/customization/model/ResourceConstants.java
+++ b/src/com/android/customization/model/ResourceConstants.java
@@ -83,7 +83,7 @@ public interface ResourceConstants {
"ic_qs_dnd",
"ic_qs_flashlight",
"ic_qs_auto_rotate",
- "ic_qs_airplane",
+ "ic_qs_battery_saver",
"ic_signal_cellular_3_4_bar",
"ic_battery_80_24dp"
};
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) {