summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authord34d <clark@cyngn.com>2016-02-05 18:05:44 -0800
committerGerrit Code Review <gerrit@cyngn.com>2016-02-08 17:32:15 +0000
commit665db50a84ed134e2fd094ccacba324183d33495 (patch)
tree2685731a39ad2db1219ca4d78b75c9d42c6787cb
parent8884b35c3bf762e721f3f7fec8f699b26b4c54f3 (diff)
downloadpackages_apps_ThemeChooser-665db50a84ed134e2fd094ccacba324183d33495.zip
packages_apps_ThemeChooser-665db50a84ed134e2fd094ccacba324183d33495.tar.gz
packages_apps_ThemeChooser-665db50a84ed134e2fd094ccacba324183d33495.tar.bz2
Stop using ThemeUtils.getDefaultThemePackageName
ThemeUtils still uses Settings instead of CMSettings, and it can't since it is in frameworks core :( Change-Id: Ia504fdb8b5648db672d455ec0d214ad25b7ba24d Ticket: CYNGNOS-1912
-rw-r--r--src/com/cyngn/theme/chooser/AppReceiver.java5
-rw-r--r--src/com/cyngn/theme/chooser/ComponentSelector.java2
-rw-r--r--src/com/cyngn/theme/chooser/MyThemeFragment.java4
-rw-r--r--src/com/cyngn/theme/chooser/ThemeFragment.java8
-rw-r--r--src/com/cyngn/theme/util/PreferenceUtils.java2
-rw-r--r--src/com/cyngn/theme/util/Utils.java20
6 files changed, 31 insertions, 10 deletions
diff --git a/src/com/cyngn/theme/chooser/AppReceiver.java b/src/com/cyngn/theme/chooser/AppReceiver.java
index 3b56397..b220bb7 100644
--- a/src/com/cyngn/theme/chooser/AppReceiver.java
+++ b/src/com/cyngn/theme/chooser/AppReceiver.java
@@ -14,6 +14,7 @@ import android.provider.ThemesContract;
import android.text.TextUtils;
import com.cyngn.theme.util.NotificationHelper;
import com.cyngn.theme.util.PreferenceUtils;
+import com.cyngn.theme.util.Utils;
public class AppReceiver extends BroadcastReceiver {
@@ -24,7 +25,7 @@ public class AppReceiver extends BroadcastReceiver {
String action = intent.getAction();
if (ThemesContract.Intent.ACTION_THEME_INSTALLED.equals(action)) {
- if (!pkgName.equals(ThemeUtils.getDefaultThemePackageName(context))) {
+ if (!pkgName.equals(Utils.getDefaultThemePackageName(context))) {
NotificationHelper.postThemeInstalledNotification(context, pkgName);
}
} else if (ThemesContract.Intent.ACTION_THEME_REMOVED.equals(action)) {
@@ -36,7 +37,7 @@ public class AppReceiver extends BroadcastReceiver {
String appliedBaseTheme = PreferenceUtils.getAppliedBaseTheme(context);
if (!TextUtils.isEmpty(appliedBaseTheme) && appliedBaseTheme.equals(pkgName)) {
PreferenceUtils.setAppliedBaseTheme(context,
- ThemeUtils.getDefaultThemePackageName(context));
+ Utils.getDefaultThemePackageName(context));
}
NotificationHelper.cancelNotifications(context);
} else if (ThemesContract.Intent.ACTION_THEME_UPDATED.equals(action)) {
diff --git a/src/com/cyngn/theme/chooser/ComponentSelector.java b/src/com/cyngn/theme/chooser/ComponentSelector.java
index d21a8e1..0176cb9 100644
--- a/src/com/cyngn/theme/chooser/ComponentSelector.java
+++ b/src/com/cyngn/theme/chooser/ComponentSelector.java
@@ -805,7 +805,7 @@ public class ComponentSelector extends LinearLayout
if (cmpntIdIndex >= 0) {
cmpntId = cursor.getLong(cmpntIdIndex);
}
- if (ThemeUtils.getDefaultThemePackageName(mContext).equals(pkgName)) {
+ if (Utils.getDefaultThemePackageName(mContext).equals(pkgName)) {
titleView.setText(mContext.getString(R.string.default_tag_text));
titleView.setTypeface(titleView.getTypeface(), Typeface.BOLD);
} else {
diff --git a/src/com/cyngn/theme/chooser/MyThemeFragment.java b/src/com/cyngn/theme/chooser/MyThemeFragment.java
index f9292d0..c674c2a 100644
--- a/src/com/cyngn/theme/chooser/MyThemeFragment.java
+++ b/src/com/cyngn/theme/chooser/MyThemeFragment.java
@@ -100,7 +100,7 @@ public class MyThemeFragment extends ThemeFragment {
Bundle savedInstanceState) {
View v = super.onCreateView(inflater, container, savedInstanceState);
mThemeTagLayout.setAppliedTagEnabled(true);
- if (mBaseThemePkgName.equals(ThemeUtils.getDefaultThemePackageName(getActivity()))) {
+ if (mBaseThemePkgName.equals(Utils.getDefaultThemePackageName(getActivity()))) {
mThemeTagLayout.setDefaultTagEnabled(true);
}
if (PreferenceUtils.hasThemeBeenUpdated(getActivity(), mBaseThemePkgName)) {
@@ -311,7 +311,7 @@ public class MyThemeFragment extends ThemeFragment {
private void setCustomizedTagIfCustomized() {
boolean isDefault =
- mBaseThemePkgName.equals(ThemeUtils.getDefaultThemePackageName(getActivity()));
+ mBaseThemePkgName.equals(Utils.getDefaultThemePackageName(getActivity()));
if (isDefault) {
// The default theme could be a mix of the system default theme and holo so lets check
// that. i.e. Hexo with holo for the components not found in Hexo
diff --git a/src/com/cyngn/theme/chooser/ThemeFragment.java b/src/com/cyngn/theme/chooser/ThemeFragment.java
index 8458637..c895204 100644
--- a/src/com/cyngn/theme/chooser/ThemeFragment.java
+++ b/src/com/cyngn/theme/chooser/ThemeFragment.java
@@ -442,7 +442,7 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb
Menu menu = popupmenu.getMenu();
if (CURRENTLY_APPLIED_THEME.equals(mPkgName) ||
- mPkgName.equals(ThemeUtils.getDefaultThemePackageName(getActivity())) ||
+ mPkgName.equals(Utils.getDefaultThemePackageName(getActivity())) ||
mPkgName.equals(ThemeConfig.SYSTEM_DEFAULT)) {
menu.findItem(R.id.menu_delete).setEnabled(false);
}
@@ -475,7 +475,7 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb
showDeleteThemeOverlay();
}
});
- if (ThemeUtils.getDefaultThemePackageName(getActivity()).equals(mPkgName) ||
+ if (Utils.getDefaultThemePackageName(getActivity()).equals(mPkgName) ||
ThemeConfig.SYSTEM_DEFAULT.equals(mPkgName)) {
mDelete.setVisibility(View.GONE);
}
@@ -515,7 +515,7 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb
mProcessingThemeLayout = v.findViewById(R.id.processing_theme_layout);
- if (mPkgName.equals(ThemeUtils.getDefaultThemePackageName(getActivity()))) {
+ if (mPkgName.equals(Utils.getDefaultThemePackageName(getActivity()))) {
mThemeTagLayout.setDefaultTagEnabled(true);
}
if (PreferenceUtils.hasThemeBeenUpdated(getActivity(), mPkgName)) {
@@ -1910,7 +1910,7 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb
protected void setCardTitle(ComponentCardView card, String pkgName, String title) {
TextView tv = (TextView) card.findViewById(R.id.label);
- if (ThemeUtils.getDefaultThemePackageName(getActivity()).equals(pkgName)) {
+ if (Utils.getDefaultThemePackageName(getActivity()).equals(pkgName)) {
tv.setText(getString(R.string.default_tag_text) + " " + title);
} else {
tv.setText(title);
diff --git a/src/com/cyngn/theme/util/PreferenceUtils.java b/src/com/cyngn/theme/util/PreferenceUtils.java
index b2cc552..c8d26bb 100644
--- a/src/com/cyngn/theme/util/PreferenceUtils.java
+++ b/src/com/cyngn/theme/util/PreferenceUtils.java
@@ -37,7 +37,7 @@ public class PreferenceUtils {
String appliedTheme = config != null ? config.getOverlayPkgName() : null;
return prefs.getString(PREF_APPLIED_BASE_THEME,
(!TextUtils.isEmpty(appliedTheme)) ? appliedTheme :
- ThemeUtils.getDefaultThemePackageName(context));
+ Utils.getDefaultThemePackageName(context));
}
public static void setAppliedBaseTheme(Context context, String pkgName) {
diff --git a/src/com/cyngn/theme/util/Utils.java b/src/com/cyngn/theme/util/Utils.java
index acefa39..8301b77 100644
--- a/src/com/cyngn/theme/util/Utils.java
+++ b/src/com/cyngn/theme/util/Utils.java
@@ -49,6 +49,8 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import static android.content.res.ThemeConfig.SYSTEM_DEFAULT;
+
public class Utils {
private static final String TAG = Utils.class.getSimpleName();
private static final boolean DEBUG = false;
@@ -685,4 +687,22 @@ public class Utils {
.putExtra(KeyguardExternalView.EXTRA_PERMISSION_LIST, permissionList);
return permissionIntent;
}
+
+ public static String getDefaultThemePackageName(Context context) {
+ final String defaultThemePkg = CMSettings.Secure.getString(context.getContentResolver(),
+ CMSettings.Secure.DEFAULT_THEME_PACKAGE);
+ if (!TextUtils.isEmpty(defaultThemePkg)) {
+ PackageManager pm = context.getPackageManager();
+ try {
+ if (pm.getPackageInfo(defaultThemePkg, 0) != null) {
+ return defaultThemePkg;
+ }
+ } catch (PackageManager.NameNotFoundException e) {
+ // doesn't exist so system will be default
+ Log.w(TAG, "Default theme " + defaultThemePkg + " not found", e);
+ }
+ }
+
+ return SYSTEM_DEFAULT;
+ }
}