1 /* 2 * Copyright (C) 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.android.customization.model; 17 18 import android.content.Context; 19 import android.content.res.Resources; 20 import android.provider.Settings.Secure; 21 22 import com.android.wallpaper.R; 23 24 import java.util.ArrayList; 25 import java.util.Arrays; 26 27 /** 28 * Holds common strings used to reference system resources. 29 */ 30 public interface ResourceConstants { 31 32 /** 33 * Package name for android platform resources. 34 */ 35 String ANDROID_PACKAGE = "android"; 36 37 /** 38 * Package name for android settings resources. 39 */ 40 String SETTINGS_PACKAGE = "com.android.settings"; 41 42 /** 43 * Package name for android sysui resources. 44 */ 45 String SYSUI_PACKAGE = "com.android.systemui"; 46 47 /** 48 * Name of the system resource for icon mask 49 */ 50 String CONFIG_ICON_MASK = "config_icon_mask"; 51 52 /** 53 * Name of the system resource for dialog corner radius 54 */ 55 String CONFIG_CORNERRADIUS = "config_bottomDialogCornerRadius"; 56 57 /** 58 * Overlay Categories that theme picker handles. 59 */ 60 String OVERLAY_CATEGORY_COLOR = "android.theme.customization.accent_color"; 61 String OVERLAY_CATEGORY_FONT = "android.theme.customization.font"; 62 String OVERLAY_CATEGORY_SHAPE = "android.theme.customization.adaptive_icon_shape"; 63 String OVERLAY_CATEGORY_ICON_ANDROID = "android.theme.customization.icon_pack.android"; 64 String OVERLAY_CATEGORY_ICON_SETTINGS = "android.theme.customization.icon_pack.settings"; 65 String OVERLAY_CATEGORY_ICON_SYSUI = "android.theme.customization.icon_pack.systemui"; 66 String OVERLAY_CATEGORY_ICON_LAUNCHER = "android.theme.customization.icon_pack.launcher"; 67 String OVERLAY_CATEGORY_ICON_THEMEPICKER = "android.theme.customization.icon_pack.themepicker"; 68 69 /** 70 * Global Android theme category (default theme prebundled with the OS) 71 */ 72 String OVERLAY_CATEGORY_ANDROID_THEME = "android.theme"; 73 74 /** 75 * Secure Setting used to store the currently set theme. 76 */ 77 String THEME_SETTING = Secure.THEME_CUSTOMIZATION_OVERLAY_PACKAGES; 78 String CONFIG_BODY_FONT_FAMILY = "config_bodyFontFamily"; 79 String CONFIG_HEADLINE_FONT_FAMILY = "config_headlineFontFamily"; 80 String[] ICONS_FOR_PREVIEW = { 81 "ic_wifi_signal_3", 82 "ic_qs_bluetooth", 83 "ic_qs_dnd", 84 "ic_qs_flashlight", 85 "ic_qs_auto_rotate", 86 "ic_qs_battery_saver", 87 "ic_signal_cellular_3_4_bar", 88 "ic_battery_80_24dp" 89 }; 90 91 ArrayList<String> sTargetPackages = new ArrayList<>(); 92 String ACCENT_COLOR_LIGHT_NAME = "accent_device_default_light"; 93 String ACCENT_COLOR_DARK_NAME = "accent_device_default_dark"; 94 95 float PATH_SIZE = 100f; 96 getPackagesToOverlay(Context context)97 static String[] getPackagesToOverlay(Context context) { 98 if (sTargetPackages.isEmpty()) { 99 sTargetPackages.addAll(Arrays.asList(ANDROID_PACKAGE, SETTINGS_PACKAGE, 100 SYSUI_PACKAGE)); 101 sTargetPackages.add(getLauncherPackage(context)); 102 sTargetPackages.add(context.getPackageName()); 103 } 104 return sTargetPackages.toArray(new String[0]); 105 } 106 getLauncherPackage(Context context)107 static String getLauncherPackage(Context context) { 108 return context.getString(R.string.launcher_overlayable_package); 109 } 110 111 /** 112 * @return the value CONFIG_ICON_MASK for the given package name using the given Resources 113 */ getIconMask(Resources res, String packageName)114 static String getIconMask(Resources res, String packageName) { 115 return res.getString(res.getIdentifier(CONFIG_ICON_MASK, "string", packageName)); 116 } 117 } 118