From d23b0fcb5f2be06951676d85aa5cae50c6abd9a0 Mon Sep 17 00:00:00 2001 From: Clark Scheff Date: Wed, 18 Feb 2015 16:15:29 -0800 Subject: Themes: Enhanced theming capabilities [1/3] This patch includes a new class, ThemeChangeRequest, which will be used to facilitate theme changes. This class includes a builder that will be used to create a ThemeChangeRequest. Change-Id: I60144f8a6505aefcc570feb15ccc50e77bcb1114 --- cmds/tm/src/com/android/commands/tm/Tm.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'cmds') diff --git a/cmds/tm/src/com/android/commands/tm/Tm.java b/cmds/tm/src/com/android/commands/tm/Tm.java index 14101f7..af1ac75 100644 --- a/cmds/tm/src/com/android/commands/tm/Tm.java +++ b/cmds/tm/src/com/android/commands/tm/Tm.java @@ -23,6 +23,7 @@ import android.content.pm.PackageInfo; import android.content.pm.ParceledListSlice; import android.content.pm.ThemeUtils; import android.content.res.IThemeService; +import android.content.res.ThemeChangeRequest; import android.os.RemoteException; import android.os.ServiceManager; import android.os.UserHandle; @@ -54,13 +55,14 @@ public class Tm extends BaseCommand { StringBuilder sb = new StringBuilder(); sb.append("usage: tm [subcommand] [options]\n"); sb.append(" tm list\n"); - sb.append(" tm apply [-c [-c ] ...]\n"); + sb.append(" tm apply [-r] [-c [-c ] ...]\n"); sb.append(" tm rebuild\n"); sb.append(" tm process \n"); sb.append("\n"); sb.append("tm list: return a list of theme packages.\n"); sb.append("\n"); sb.append("tm apply: applies the components for the theme specified by PACKAGE_NAME.\n"); + sb.append(" -r: remove per app themes\n"); sb.append(" [-c [-c ] ...]\n"); sb.append(" if no components are specified all components will be applied.\n"); sb.append(" Valid components are:\n"); @@ -143,22 +145,27 @@ public class Tm extends BaseCommand { } } - Map componentMap = new HashMap(); + boolean removePerAppThemes = false; + + ThemeChangeRequest.Builder builder = new ThemeChangeRequest.Builder(); String opt; while ((opt=nextOption()) != null) { if (opt.equals("-c")) { - componentMap.put(nextArgRequired(), pkgName); + builder.setComponent(nextArgRequired(), pkgName); + } else if (opt.equals("-r")) { + removePerAppThemes = true; } } // No components specified so let's just try and apply EVERYTHING! + Map componentMap = builder.build().getThemeComponentsMap(); if (componentMap.size() == 0) { List components = ThemeUtils.getAllComponents(); for (String component : components) { - componentMap.put(component, pkgName); + builder.setComponent(component, pkgName); } } - mTs.requestThemeChange(componentMap); + mTs.requestThemeChange(builder.build(), removePerAppThemes); } private void runRebuildResourceCache() throws Exception { -- cgit v1.1