summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authord34d <clark@cyngn.com>2016-02-23 21:52:57 (GMT)
committerd34d <clark@cyngn.com>2016-03-01 17:48:56 (GMT)
commit43532deae99d7a95af98d053c65af5bdf98b2a41 (patch)
tree7fe847ba6e9b0cc4c7b6ecf8c782d3d21f749fd3
parenta163818d70f14ec08766aa1bfbeee770ed7a4ef1 (diff)
downloadandroid_packages_providers_ThemesProvider-43532deae99d7a95af98d053c65af5bdf98b2a41.zip
android_packages_providers_ThemesProvider-43532deae99d7a95af98d053c65af5bdf98b2a41.tar.gz
android_packages_providers_ThemesProvider-43532deae99d7a95af98d053c65af5bdf98b2a41.tar.bz2
Themes: Refactor themes to CMSDK [4/6]
Change-Id: Ie078b20539e982cd124163da8816fb106c52b927 TICKET: CYNGNOS-2126
-rw-r--r--AndroidManifest.xml2
-rw-r--r--src/org/cyanogenmod/themes/provider/PreviewGenerationService.java6
-rw-r--r--src/org/cyanogenmod/themes/provider/ThemePackageHelper.java21
-rw-r--r--src/org/cyanogenmod/themes/provider/ThemesOpenHelper.java12
-rw-r--r--src/org/cyanogenmod/themes/provider/ThemesProvider.java20
-rw-r--r--src/org/cyanogenmod/themes/provider/util/ProviderUtils.java41
-rw-r--r--src/org/cyanogenmod/themes/provider/util/WallpaperPreviewGenerator.java6
7 files changed, 56 insertions, 52 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 0a106e2..eaf0007 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -5,7 +5,7 @@
android:versionCode="2"
android:versionName="2.0" >
- <uses-permission android:name="android.permission.ACCESS_THEME_MANAGER" />
+ <uses-permission android:name="cyanogenmod.permission.ACCESS_THEME_MANAGER" />
<application
android:allowBackup="true"
diff --git a/src/org/cyanogenmod/themes/provider/PreviewGenerationService.java b/src/org/cyanogenmod/themes/provider/PreviewGenerationService.java
index fd33308..99b40f5 100644
--- a/src/org/cyanogenmod/themes/provider/PreviewGenerationService.java
+++ b/src/org/cyanogenmod/themes/provider/PreviewGenerationService.java
@@ -27,9 +27,11 @@ import android.database.Cursor;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.FileUtils;
-import android.provider.ThemesContract.ThemesColumns;
-import android.provider.ThemesContract.PreviewColumns;
import android.util.Log;
+
+import cyanogenmod.providers.ThemesContract.ThemesColumns;
+import cyanogenmod.providers.ThemesContract.PreviewColumns;
+
import org.cyanogenmod.themes.provider.util.BootAnimationPreviewGenerator;
import org.cyanogenmod.themes.provider.util.IconPreviewGenerator;
import org.cyanogenmod.themes.provider.util.IconPreviewGenerator.IconItems;
diff --git a/src/org/cyanogenmod/themes/provider/ThemePackageHelper.java b/src/org/cyanogenmod/themes/provider/ThemePackageHelper.java
index 2716b65..06020a1 100644
--- a/src/org/cyanogenmod/themes/provider/ThemePackageHelper.java
+++ b/src/org/cyanogenmod/themes/provider/ThemePackageHelper.java
@@ -22,21 +22,22 @@ import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ThemeInfo;
-import android.content.pm.ThemeUtils;
import android.content.res.AssetManager;
import android.content.res.Configuration;
-import android.content.res.ThemeChangeRequest;
-import android.content.res.ThemeChangeRequest.RequestType;
import android.content.res.ThemeConfig;
-import android.content.res.ThemeManager;
import android.database.Cursor;
-import android.provider.ThemesContract;
-import android.provider.ThemesContract.MixnMatchColumns;
-import android.provider.ThemesContract.ThemesColumns;
-import android.provider.ThemesContract.ThemesColumns.InstallState;
import android.util.Log;
+import cyanogenmod.providers.ThemesContract;
+import cyanogenmod.providers.ThemesContract.MixnMatchColumns;
+import cyanogenmod.providers.ThemesContract.ThemesColumns;
+import cyanogenmod.providers.ThemesContract.ThemesColumns.InstallState;
+import cyanogenmod.themes.ThemeManager;
+import cyanogenmod.themes.ThemeChangeRequest;
+import cyanogenmod.themes.ThemeChangeRequest.RequestType;
+
import org.cyanogenmod.internal.util.CmLockPatternUtils;
+import org.cyanogenmod.internal.util.ThemeUtils;
import org.cyanogenmod.themes.provider.util.ProviderUtils;
import java.io.IOException;
@@ -275,7 +276,7 @@ public class ThemePackageHelper {
mixnmatch.close();
builder.setRequestType(RequestType.THEME_REMOVED);
- ThemeManager manager = (ThemeManager) context.getSystemService(Context.THEME_SERVICE);
+ ThemeManager manager = ThemeManager.getInstance();
manager.requestThemeChange(builder.build(), false);
// Delete the theme from the db
@@ -409,7 +410,7 @@ public class ThemePackageHelper {
}
builder.setRequestType(RequestType.THEME_UPDATED);
- ThemeManager manager = (ThemeManager) context.getSystemService(Context.THEME_SERVICE);
+ ThemeManager manager = ThemeManager.getInstance();
manager.requestThemeChange(builder.build(), false);
}
}
diff --git a/src/org/cyanogenmod/themes/provider/ThemesOpenHelper.java b/src/org/cyanogenmod/themes/provider/ThemesOpenHelper.java
index b2960d3..d70ad50 100644
--- a/src/org/cyanogenmod/themes/provider/ThemesOpenHelper.java
+++ b/src/org/cyanogenmod/themes/provider/ThemesOpenHelper.java
@@ -20,19 +20,21 @@ import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
-import android.content.pm.ThemeUtils;
import android.content.res.ThemeConfig;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.database.sqlite.SQLiteOpenHelper;
import android.os.Build;
-import android.provider.ThemesContract;
-import android.provider.ThemesContract.ThemesColumns;
-import android.provider.ThemesContract.MixnMatchColumns;
-import android.provider.ThemesContract.PreviewColumns;
import android.util.Log;
+import cyanogenmod.providers.ThemesContract;
+import cyanogenmod.providers.ThemesContract.ThemesColumns;
+import cyanogenmod.providers.ThemesContract.MixnMatchColumns;
+import cyanogenmod.providers.ThemesContract.PreviewColumns;
+
+import org.cyanogenmod.internal.util.ThemeUtils;
+
public class ThemesOpenHelper extends SQLiteOpenHelper {
private static final String TAG = ThemesOpenHelper.class.getName();
diff --git a/src/org/cyanogenmod/themes/provider/ThemesProvider.java b/src/org/cyanogenmod/themes/provider/ThemesProvider.java
index 1dec10b..12ea396 100644
--- a/src/org/cyanogenmod/themes/provider/ThemesProvider.java
+++ b/src/org/cyanogenmod/themes/provider/ThemesProvider.java
@@ -26,22 +26,23 @@ import android.content.SharedPreferences.Editor;
import android.content.UriMatcher;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
-import android.content.pm.ThemeUtils;
-import android.content.res.ThemeChangeRequest;
-import android.content.res.ThemeChangeRequest.RequestType;
-import android.content.res.ThemeManager;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteQueryBuilder;
import android.net.Uri;
import android.os.Handler;
import android.preference.PreferenceManager;
-import android.provider.ThemesContract;
-import android.provider.ThemesContract.MixnMatchColumns;
-import android.provider.ThemesContract.PreviewColumns;
-import android.provider.ThemesContract.ThemesColumns;
import android.util.Log;
+import cyanogenmod.providers.ThemesContract;
+import cyanogenmod.providers.ThemesContract.MixnMatchColumns;
+import cyanogenmod.providers.ThemesContract.PreviewColumns;
+import cyanogenmod.providers.ThemesContract.ThemesColumns;
+import cyanogenmod.themes.ThemeManager;
+import cyanogenmod.themes.ThemeChangeRequest;
+import cyanogenmod.themes.ThemeChangeRequest.RequestType;
+
+import org.cyanogenmod.internal.util.ThemeUtils;
import org.cyanogenmod.themes.provider.ThemesOpenHelper.MixnMatchTable;
import org.cyanogenmod.themes.provider.ThemesOpenHelper.PreviewsTable;
import org.cyanogenmod.themes.provider.ThemesOpenHelper.ThemesTable;
@@ -596,8 +597,7 @@ public class ThemesProvider extends ContentProvider {
builder.setRequestType(RequestType.THEME_REMOVED);
ThemeChangeRequest request = builder.build();
if (request.getNumChangesRequested() > 0) {
- ThemeManager mService = (ThemeManager) getContext().getSystemService(
- Context.THEME_SERVICE);
+ ThemeManager mService = ThemeManager.getInstance();
mService.requestThemeChange(request, false);
}
diff --git a/src/org/cyanogenmod/themes/provider/util/ProviderUtils.java b/src/org/cyanogenmod/themes/provider/util/ProviderUtils.java
index 59b3d2e..d5771f3 100644
--- a/src/org/cyanogenmod/themes/provider/util/ProviderUtils.java
+++ b/src/org/cyanogenmod/themes/provider/util/ProviderUtils.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015 The CyanogenMod Project
+ * Copyright (C) 2015-2016 The CyanogenMod Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,19 +15,18 @@
*/
package org.cyanogenmod.themes.provider.util;
-import android.Manifest;
import android.content.Context;
import android.content.Intent;
-import android.content.res.ThemeManager;
import android.database.Cursor;
-import android.database.sqlite.SQLiteDatabase;
import android.net.Uri;
-import android.provider.ThemesContract;
-import android.provider.ThemesContract.MixnMatchColumns;
-import android.provider.ThemesContract.PreviewColumns;
-import android.provider.ThemesContract.ThemesColumns;
import android.text.TextUtils;
-import org.cyanogenmod.themes.provider.ThemesOpenHelper;
+
+import cyanogenmod.platform.Manifest;
+import cyanogenmod.providers.ThemesContract;
+import cyanogenmod.providers.ThemesContract.MixnMatchColumns;
+import cyanogenmod.providers.ThemesContract.PreviewColumns;
+import cyanogenmod.providers.ThemesContract.ThemesColumns;
+import cyanogenmod.themes.ThemeManager;
import java.util.ArrayList;
import java.util.Arrays;
@@ -58,14 +57,14 @@ public class ProviderUtils {
}
/**
- * Queries the {@link android.content.res.ThemeManager} to check if the theme is currently
- * being processed by {@link com.android.server.ThemeService}
+ * Queries the {@link ThemeManager} to check if the theme is currently
+ * being processed by {@link org.cyanogenmod.platform.internal.ThemeManagerService}
* @param context
* @param pkgName
* @return True if the theme is being processed or queued up for processing
*/
public static boolean isThemeBeingProcessed(Context context, String pkgName) {
- ThemeManager tm = (ThemeManager) context.getSystemService(Context.THEME_SERVICE);
+ ThemeManager tm = ThemeManager.getInstance();
return tm.isThemeBeingProcessed(pkgName);
}
@@ -209,35 +208,35 @@ public class ProviderUtils {
}
/**
- * Sends the {@link android.provider.ThemesContract.Intent#ACTION_THEME_INSTALLED} action
+ * Sends the {@link cyanogenmod.content.Intent#ACTION_THEME_INSTALLED} action
* @param context
* @param pkgName
*/
public static void sendThemeInstalledBroadcast(Context context, String pkgName) {
- Intent intent = new Intent(ThemesContract.Intent.ACTION_THEME_INSTALLED,
- Uri.fromParts(ThemesContract.Intent.URI_SCHEME_PACKAGE, pkgName, null));
+ Intent intent = new Intent(cyanogenmod.content.Intent.ACTION_THEME_INSTALLED,
+ Uri.fromParts(cyanogenmod.content.Intent.URI_SCHEME_PACKAGE, pkgName, null));
context.sendBroadcast(intent, Manifest.permission.READ_THEMES);
}
/**
- * Sends the {@link android.provider.ThemesContract.Intent#ACTION_THEME_UPDATED} action
+ * Sends the {@link cyanogenmod.content.Intent#ACTION_THEME_UPDATED} action
* @param context
* @param pkgName
*/
public static void sendThemeUpdatedBroadcast(Context context, String pkgName) {
- Intent intent = new Intent(ThemesContract.Intent.ACTION_THEME_UPDATED,
- Uri.fromParts(ThemesContract.Intent.URI_SCHEME_PACKAGE, pkgName, null));
+ Intent intent = new Intent(cyanogenmod.content.Intent.ACTION_THEME_UPDATED,
+ Uri.fromParts(cyanogenmod.content.Intent.URI_SCHEME_PACKAGE, pkgName, null));
context.sendBroadcast(intent, Manifest.permission.READ_THEMES);
}
/**
- * Sends the {@link android.provider.ThemesContract.Intent#ACTION_THEME_REMOVED} action
+ * Sends the {@link cyanogenmod.content.Intent#ACTION_THEME_REMOVED} action
* @param context
* @param pkgName
*/
public static void sendThemeRemovedBroadcast(Context context, String pkgName) {
- Intent intent = new Intent(ThemesContract.Intent.ACTION_THEME_REMOVED,
- Uri.fromParts(ThemesContract.Intent.URI_SCHEME_PACKAGE, pkgName, null));
+ Intent intent = new Intent(cyanogenmod.content.Intent.ACTION_THEME_REMOVED,
+ Uri.fromParts(cyanogenmod.content.Intent.URI_SCHEME_PACKAGE, pkgName, null));
context.sendBroadcast(intent, Manifest.permission.READ_THEMES);
}
}
diff --git a/src/org/cyanogenmod/themes/provider/util/WallpaperPreviewGenerator.java b/src/org/cyanogenmod/themes/provider/util/WallpaperPreviewGenerator.java
index f1a040c..6b87d0b 100644
--- a/src/org/cyanogenmod/themes/provider/util/WallpaperPreviewGenerator.java
+++ b/src/org/cyanogenmod/themes/provider/util/WallpaperPreviewGenerator.java
@@ -18,17 +18,17 @@ package org.cyanogenmod.themes.provider.util;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
-import android.content.pm.ThemeUtils;
import android.content.res.AssetManager;
import android.content.res.Resources;
import android.content.res.ThemeConfig;
import android.graphics.Bitmap;
-import android.provider.ThemesContract.PreviewColumns;
import android.text.TextUtils;
+import cyanogenmod.providers.ThemesContract.PreviewColumns;
+
+import org.cyanogenmod.internal.util.ThemeUtils;
import org.cyanogenmod.themes.provider.R;
-import java.io.File;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;