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

Commit 3d334645 authored by Santiago Etchebehere's avatar Santiago Etchebehere
Browse files

Add battery icon to the theme cover page

Use battery icon if available, but don't crash if not
present

Bug: 130758661
Change-Id: I81e497ca33dd1d67a957ebe061aca9991ef919a3
parent 2803b61f
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -84,7 +84,8 @@ public interface ResourceConstants {
            "ic_qs_flashlight",
            "ic_qs_auto_rotate",
            "ic_qs_airplane",
            "ic_signal_cellular_3_4_bar"
            "ic_signal_cellular_3_4_bar",
            "ic_battery_80_24dp"
    };

    ArrayList<String> sTargetPackages = new ArrayList<>();
+9 −4
Original line number Diff line number Diff line
@@ -82,7 +82,7 @@ abstract class ThemePreviewPage extends PreviewPage {
         * Maps which icon from ResourceConstants#ICONS_FOR_PREVIEW to use for each icon in the
         * top bar (fake "status bar") of the cover page.
         */
        private static final int [] sTopBarIconToPreviewIcon = new int [] { 0, 6, 2 };
        private static final int [] sTopBarIconToPreviewIcon = new int [] { 0, 6, 7 };

        private final Typeface mHeadlineFont;
        private final List<Drawable> mIcons;
@@ -194,9 +194,14 @@ abstract class ThemePreviewPage extends PreviewPage {
            ViewGroup iconsContainer = card.findViewById(R.id.theme_preview_top_bar_icons);

            for (int i = 0; i < iconsContainer.getChildCount(); i++) {
                int iconIndex = sTopBarIconToPreviewIcon[i];
                if (iconIndex < mIcons.size()) {
                    ((ImageView) iconsContainer.getChildAt(i))
                        .setImageDrawable(mIcons.get(sTopBarIconToPreviewIcon[i]).getConstantState()
                            .setImageDrawable(mIcons.get(iconIndex).getConstantState()
                                    .newDrawable().mutate());
                } else {
                    iconsContainer.getChildAt(i).setVisibility(View.GONE);
                }
            }

            ViewGroup body = card.findViewById(R.id.theme_preview_card_body_container);