diff options
author | Clark Scheff <clark@cyngn.com> | 2015-01-13 16:54:36 -0800 |
---|---|---|
committer | Clark Scheff <clark@cyngn.com> | 2015-01-15 09:18:05 -0800 |
commit | 914950a5d70c6e3ea4c0488ed0384449a0c91270 (patch) | |
tree | bb9ff9468a696bd79efc719cfc9394b5da074bbc /src/com | |
parent | c6d36f0b58294bd5e7ca7b2fb1022a8399685c66 (diff) | |
download | packages_apps_ThemeChooser-914950a5d70c6e3ea4c0488ed0384449a0c91270.tar.gz packages_apps_ThemeChooser-914950a5d70c6e3ea4c0488ed0384449a0c91270.tar.bz2 packages_apps_ThemeChooser-914950a5d70c6e3ea4c0488ed0384449a0c91270.zip |
Add legacy theme tag and warning message
This adds a tag at the top of any theme that is designed for
an older version of CM and presents the user with a message
in the apply overlay when they go to apply a theme designed
for an older version of CM.
Change-Id: I7d60f14cbfc376890e06dbf1358745e4490be961
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/cyngn/theme/chooser/ThemeFragment.java | 24 | ||||
-rw-r--r-- | src/com/cyngn/theme/widget/ThemeTagLayout.java | 12 |
2 files changed, 36 insertions, 0 deletions
diff --git a/src/com/cyngn/theme/chooser/ThemeFragment.java b/src/com/cyngn/theme/chooser/ThemeFragment.java index a835f03..12046f3 100644 --- a/src/com/cyngn/theme/chooser/ThemeFragment.java +++ b/src/com/cyngn/theme/chooser/ThemeFragment.java @@ -32,6 +32,7 @@ import android.media.MediaPlayer; import android.media.RingtoneManager; import android.net.Uri; import android.os.AsyncTask; +import android.os.Build; import android.os.Bundle; import android.os.FileUtils; import android.os.Handler; @@ -103,6 +104,8 @@ import static android.provider.ThemesContract.ThemesColumns.MODIFIES_NAVIGATION_ import static android.provider.ThemesContract.ThemesColumns.MODIFIES_ICONS; import static android.provider.ThemesContract.ThemesColumns.MODIFIES_FONTS; +import static android.content.pm.ThemeUtils.SYSTEM_TARGET_API; + public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallbacks<Cursor>, ThemeManager.ThemeChangeListener, ThemeManager.ThemeProcessingListener { private static final String TAG = ThemeFragment.class.getSimpleName(); @@ -270,6 +273,8 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb protected boolean mProcessingResources; protected boolean mApplyThemeOnPopulated; + protected boolean mIsLegacyTheme; + protected enum CustomizeResetAction { Customize, Reset, @@ -1202,6 +1207,7 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb ThemesColumns.AUTHOR, ThemesColumns.WALLPAPER_URI, ThemesColumns.HOMESCREEN_URI, + ThemesColumns.TARGET_API, // Theme abilities ThemesColumns.MODIFIES_LAUNCHER, ThemesColumns.MODIFIES_LOCKSCREEN, @@ -1328,6 +1334,7 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb mProcessingResources = false; hideProcessingOverlay(); } + loadLegacyThemeInfo(c); populateSupportedComponents(c); loadWallpaper(c, false); loadStatusBar(c, false); @@ -1483,6 +1490,16 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb return pkg != null && pkg.equals(mPkgName); } + protected void loadLegacyThemeInfo(Cursor c) { + int targetApiIdx = c.getColumnIndex(ThemesColumns.TARGET_API); + // If this is being called for a MyThemeFragment the index will be -1 so set to + // SYSTEM_TARGET_API so we don't display the tag. If the user applied a legacy theme + // then they should have already been warned. + int targetApi = targetApiIdx < 0 ? SYSTEM_TARGET_API : c.getInt(targetApiIdx); + mIsLegacyTheme = targetApi != SYSTEM_TARGET_API && targetApi <= Build.VERSION_CODES.KITKAT; + mThemeTagLayout.setLegacyTagEnabled(mIsLegacyTheme); + } + protected void loadTitle(Cursor c) { int titleIdx = c.getColumnIndex(ThemesColumns.TITLE); int authorIdx = c.getColumnIndex(ThemesColumns.AUTHOR); @@ -2291,6 +2308,13 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb anim.setDuration(ANIMATE_APPLY_LAYOUT_DURATION); anim.alpha(1f).start(); + if (mIsLegacyTheme) { + // Display cm11 theme warning message + TextView tv = (TextView) mConfirmCancelOverlay.findViewById(R.id.warning_message); + tv.setVisibility(View.VISIBLE); + tv.setText(String.format(getString(R.string.legacy_theme_warning), mTitle.getText())); + } + disableActionButtons(); mClickableView.setSoundEffectsEnabled(false); } diff --git a/src/com/cyngn/theme/widget/ThemeTagLayout.java b/src/com/cyngn/theme/widget/ThemeTagLayout.java index cf25fe1..18635a4 100644 --- a/src/com/cyngn/theme/widget/ThemeTagLayout.java +++ b/src/com/cyngn/theme/widget/ThemeTagLayout.java @@ -17,6 +17,7 @@ public class ThemeTagLayout extends LinearLayout { private TextView mCustomizedTag; private TextView mUpdatedTag; private TextView mDefaultTag; + private TextView mLegacyTag; public ThemeTagLayout(Context context) { this(context, null); @@ -39,6 +40,7 @@ public class ThemeTagLayout extends LinearLayout { mCustomizedTag = (TextView) inflater.inflate(R.layout.tag_customized, this, false); mUpdatedTag = (TextView) inflater.inflate(R.layout.tag_updated, this, false); mDefaultTag = (TextView) inflater.inflate(R.layout.tag_default, this, false); + mLegacyTag = (TextView) inflater.inflate(R.layout.tag_legacy, this, false); } public void setAppliedTagEnabled(boolean enabled) { @@ -110,4 +112,14 @@ public class ThemeTagLayout extends LinearLayout { removeView(mDefaultTag); } } + + public void setLegacyTagEnabled(boolean enabled) { + if (enabled) { + if (findViewById(R.id.tag_legacy) != null) return; + addView(mLegacyTag); + } else { + if (findViewById(R.id.tag_legacy) == null) return; + removeView(mLegacyTag); + } + } } |