Loading core/java/android/content/pm/ThemeUtils.java +46 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,8 @@ import android.os.FileUtils; import android.os.SystemProperties; import android.provider.MediaStore; import android.provider.Settings; import android.provider.ThemesContract; import android.provider.ThemesContract.ThemesColumns; import android.text.TextUtils; import android.util.DisplayMetrics; import android.util.Log; Loading @@ -44,6 +46,8 @@ import java.io.InputStream; import java.io.OutputStream; import java.io.InputStreamReader; import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.List; import java.util.zip.CRC32; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; Loading Loading @@ -556,4 +560,46 @@ public class ThemeUtils { return mPackageName; } } // Returns a mutable list of all theme components public static List<String> getAllComponents() { List<String> components = new ArrayList<String>(9); components.add(ThemesColumns.MODIFIES_FONTS); components.add(ThemesColumns.MODIFIES_LAUNCHER); components.add(ThemesColumns.MODIFIES_ALARMS); components.add(ThemesColumns.MODIFIES_BOOT_ANIM); components.add(ThemesColumns.MODIFIES_ICONS); components.add(ThemesColumns.MODIFIES_LOCKSCREEN); components.add(ThemesColumns.MODIFIES_NOTIFICATIONS); components.add(ThemesColumns.MODIFIES_OVERLAYS); components.add(ThemesColumns.MODIFIES_RINGTONES); components.add(ThemesColumns.MODIFIES_STATUS_BAR); components.add(ThemesColumns.MODIFIES_NAVIGATION_BAR); return components; } /** * Returns a mutable list of all the theme components supported by a given package * NOTE: This queries the themes content provider. If there isn't a provider installed * or if it is too early in the boot process this method will not work. */ public static List<String> getSupportedComponents(Context context, String pkgName) { List<String> supportedComponents = new ArrayList<String>(); String selection = ThemesContract.ThemesColumns.PKG_NAME + "= ?"; String[] selectionArgs = new String[]{ pkgName }; Cursor c = context.getContentResolver().query(ThemesContract.ThemesColumns.CONTENT_URI, null, selection, selectionArgs, null); if (c != null && c.moveToFirst()) { List<String> allComponents = getAllComponents(); for(String component : allComponents) { int index = c.getColumnIndex(component); if (c.getInt(index) == 1) { supportedComponents.add(component); } } } return supportedComponents; } } core/java/android/content/res/ThemeManager.java +13 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package android.content.res; import android.content.Context; import android.content.pm.ThemeUtils; import android.os.Handler; import android.os.Looper; import android.os.RemoteException; Loading Loading @@ -115,6 +116,18 @@ public class ThemeManager { removeClient(pkgName); } /** * Convenience method. Applies the entire theme. */ public void requestThemeChange(String pkgName) { try { List<String> components = ThemeUtils.getSupportedComponents(mContext, pkgName); mService.requestThemeChange(pkgName, components); } catch (RemoteException e) { Log.w(TAG, "Unable to access ThemeService", e); } } public void requestThemeChange(String pkgName, List<String> components) { try { mService.requestThemeChange(pkgName, components); Loading services/java/com/android/server/ThemeService.java +1 −10 Original line number Diff line number Diff line Loading @@ -239,16 +239,7 @@ public class ThemeService extends IThemeService.Stub { Settings.Secure.DEFAULT_THEME_COMPONENTS); List<String> components; if (TextUtils.isEmpty(defaultThemeComponents)) { components = new ArrayList<String>(9); components.add(ThemesContract.ThemesColumns.MODIFIES_FONTS); components.add(ThemesContract.ThemesColumns.MODIFIES_LAUNCHER); components.add(ThemesContract.ThemesColumns.MODIFIES_ALARMS); components.add(ThemesContract.ThemesColumns.MODIFIES_BOOT_ANIM); components.add(ThemesContract.ThemesColumns.MODIFIES_ICONS); components.add(ThemesContract.ThemesColumns.MODIFIES_LOCKSCREEN); components.add(ThemesContract.ThemesColumns.MODIFIES_NOTIFICATIONS); components.add(ThemesContract.ThemesColumns.MODIFIES_OVERLAYS); components.add(ThemesContract.ThemesColumns.MODIFIES_RINGTONES); components = ThemeUtils.getAllComponents(); } else { components = new ArrayList<String>( Arrays.asList(defaultThemeComponents.split("\\|"))); Loading Loading
core/java/android/content/pm/ThemeUtils.java +46 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,8 @@ import android.os.FileUtils; import android.os.SystemProperties; import android.provider.MediaStore; import android.provider.Settings; import android.provider.ThemesContract; import android.provider.ThemesContract.ThemesColumns; import android.text.TextUtils; import android.util.DisplayMetrics; import android.util.Log; Loading @@ -44,6 +46,8 @@ import java.io.InputStream; import java.io.OutputStream; import java.io.InputStreamReader; import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.List; import java.util.zip.CRC32; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; Loading Loading @@ -556,4 +560,46 @@ public class ThemeUtils { return mPackageName; } } // Returns a mutable list of all theme components public static List<String> getAllComponents() { List<String> components = new ArrayList<String>(9); components.add(ThemesColumns.MODIFIES_FONTS); components.add(ThemesColumns.MODIFIES_LAUNCHER); components.add(ThemesColumns.MODIFIES_ALARMS); components.add(ThemesColumns.MODIFIES_BOOT_ANIM); components.add(ThemesColumns.MODIFIES_ICONS); components.add(ThemesColumns.MODIFIES_LOCKSCREEN); components.add(ThemesColumns.MODIFIES_NOTIFICATIONS); components.add(ThemesColumns.MODIFIES_OVERLAYS); components.add(ThemesColumns.MODIFIES_RINGTONES); components.add(ThemesColumns.MODIFIES_STATUS_BAR); components.add(ThemesColumns.MODIFIES_NAVIGATION_BAR); return components; } /** * Returns a mutable list of all the theme components supported by a given package * NOTE: This queries the themes content provider. If there isn't a provider installed * or if it is too early in the boot process this method will not work. */ public static List<String> getSupportedComponents(Context context, String pkgName) { List<String> supportedComponents = new ArrayList<String>(); String selection = ThemesContract.ThemesColumns.PKG_NAME + "= ?"; String[] selectionArgs = new String[]{ pkgName }; Cursor c = context.getContentResolver().query(ThemesContract.ThemesColumns.CONTENT_URI, null, selection, selectionArgs, null); if (c != null && c.moveToFirst()) { List<String> allComponents = getAllComponents(); for(String component : allComponents) { int index = c.getColumnIndex(component); if (c.getInt(index) == 1) { supportedComponents.add(component); } } } return supportedComponents; } }
core/java/android/content/res/ThemeManager.java +13 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package android.content.res; import android.content.Context; import android.content.pm.ThemeUtils; import android.os.Handler; import android.os.Looper; import android.os.RemoteException; Loading Loading @@ -115,6 +116,18 @@ public class ThemeManager { removeClient(pkgName); } /** * Convenience method. Applies the entire theme. */ public void requestThemeChange(String pkgName) { try { List<String> components = ThemeUtils.getSupportedComponents(mContext, pkgName); mService.requestThemeChange(pkgName, components); } catch (RemoteException e) { Log.w(TAG, "Unable to access ThemeService", e); } } public void requestThemeChange(String pkgName, List<String> components) { try { mService.requestThemeChange(pkgName, components); Loading
services/java/com/android/server/ThemeService.java +1 −10 Original line number Diff line number Diff line Loading @@ -239,16 +239,7 @@ public class ThemeService extends IThemeService.Stub { Settings.Secure.DEFAULT_THEME_COMPONENTS); List<String> components; if (TextUtils.isEmpty(defaultThemeComponents)) { components = new ArrayList<String>(9); components.add(ThemesContract.ThemesColumns.MODIFIES_FONTS); components.add(ThemesContract.ThemesColumns.MODIFIES_LAUNCHER); components.add(ThemesContract.ThemesColumns.MODIFIES_ALARMS); components.add(ThemesContract.ThemesColumns.MODIFIES_BOOT_ANIM); components.add(ThemesContract.ThemesColumns.MODIFIES_ICONS); components.add(ThemesContract.ThemesColumns.MODIFIES_LOCKSCREEN); components.add(ThemesContract.ThemesColumns.MODIFIES_NOTIFICATIONS); components.add(ThemesContract.ThemesColumns.MODIFIES_OVERLAYS); components.add(ThemesContract.ThemesColumns.MODIFIES_RINGTONES); components = ThemeUtils.getAllComponents(); } else { components = new ArrayList<String>( Arrays.asList(defaultThemeComponents.split("\\|"))); Loading