Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b51de81a authored by Wesley.CW Wang's avatar Wesley.CW Wang
Browse files

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
parent 7813b07e
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
<!--
     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>
+1 −1
Original line number Diff line number Diff line
@@ -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"
    };
+25 −6
Original line number Diff line number Diff line
@@ -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) {