summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLuis Vidal <lvidal@cyngn.com>2016-02-10 12:43:12 -0800
committerLuis Vidal <lvidal@cyngn.com>2016-02-10 12:43:12 -0800
commit94ee92a4532da3727a1604500b2f57d91329a74b (patch)
tree4e0cbf6a2b0caa926816ac34f82639e72de7dbd4 /src
parent665db50a84ed134e2fd094ccacba324183d33495 (diff)
downloadpackages_apps_ThemeChooser-94ee92a4532da3727a1604500b2f57d91329a74b.zip
packages_apps_ThemeChooser-94ee92a4532da3727a1604500b2f57d91329a74b.tar.gz
packages_apps_ThemeChooser-94ee92a4532da3727a1604500b2f57d91329a74b.tar.bz2
Enable Live Lock screen if Animated lock screen is applied
Live lock screen will be enabled if user picks an animated lock screen from the chooser. User will be presented with a dialog to enable LLS. If user decides not to enable LLS, the animated lock screen won't be applied. Change-Id: I5d14dd138e3e3f0e83e1dd08d75c8543131cc430 TICKET: CYNGNOS-1932
Diffstat (limited to 'src')
-rw-r--r--src/com/cyngn/theme/chooser/ThemeFragment.java104
1 files changed, 102 insertions, 2 deletions
diff --git a/src/com/cyngn/theme/chooser/ThemeFragment.java b/src/com/cyngn/theme/chooser/ThemeFragment.java
index c895204..5f1e8ac 100644
--- a/src/com/cyngn/theme/chooser/ThemeFragment.java
+++ b/src/com/cyngn/theme/chooser/ThemeFragment.java
@@ -11,9 +11,11 @@ import android.animation.IntEvaluator;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.app.Activity;
+import android.app.AlertDialog;
import android.app.WallpaperManager;
import android.content.ComponentName;
import android.content.Context;
+import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ThemeUtils;
@@ -93,6 +95,7 @@ import com.cyngn.theme.widget.LockableScrollView;
import com.cyngn.theme.widget.ThemeTagLayout;
import cyanogenmod.app.ThemeVersion;
+import cyanogenmod.providers.CMSettings;
import org.cyanogenmod.internal.util.CmLockPatternUtils;
import java.io.File;
@@ -138,6 +141,8 @@ import static com.cyngn.theme.util.CursorLoaderHelper.LOADER_ID_NOTIFICATION;
import static com.cyngn.theme.util.CursorLoaderHelper.LOADER_ID_ALARM;
import static com.cyngn.theme.util.CursorLoaderHelper.LOADER_ID_LIVE_LOCK_SCREEN;
+import static cyanogenmod.providers.CMSettings.Secure.LIVE_LOCK_SCREEN_ENABLED;
+
import static android.content.pm.ThemeUtils.SYSTEM_TARGET_API;
public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallbacks<Cursor>,
@@ -2286,13 +2291,108 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb
}
};
+ class RestoreLockScreenCardRunnable implements Runnable {
+
+ final private boolean mWasShowingNone;
+ private String mCurrentLockScreenPkgName;
+
+ public RestoreLockScreenCardRunnable(boolean w, String pkgName) {
+ mWasShowingNone = w;
+ mCurrentLockScreenPkgName = pkgName;
+ }
+
+ @Override
+ public void run() {
+ if (!TextUtils.isEmpty(mCurrentLockScreenPkgName)) {
+ loadComponentFromPackage(mCurrentLockScreenPkgName,
+ MODIFIES_LOCKSCREEN, 0);
+ } else if (mWasShowingNone) {
+ mLockScreenCard.setWallpaper(null);
+ TextView none = (TextView) mLockScreenCard.findViewById(
+ R.id.none);
+ if (none != null) {
+ none.setVisibility(View.VISIBLE);
+ }
+ mLockScreenCard.setEmptyViewEnabled(false);
+ } else {
+ mLockScreenCard.clearWallpaper();
+ TextView none = (TextView) mLockScreenCard.findViewById(
+ R.id.none);
+ if (none != null) {
+ none.setVisibility(View.GONE);
+ }
+ mLockScreenCard.setEmptyViewEnabled(true);
+ setAddComponentTitle(mLockScreenCard, getString(R.string.lockscreen_label));
+ }
+ }
+ }
+
protected void applyTheme() {
if (mExternalWallpaperUri == null && mExternalLockscreenUri == null &&
(mSelectedComponentsMap == null || mSelectedComponentsMap.size() <= 0)) {
return;
}
- getChooserActivity().themeChangeStart();
- animateProgressIn(mApplyThemeRunnable);
+ final Map<String,String> componentsToApply = getComponentsToApply();
+ boolean isLLSEnabled = CMSettings.Secure.getInt(getActivity().getContentResolver(),
+ LIVE_LOCK_SCREEN_ENABLED, 0) == 1;
+ if (!TextUtils.isEmpty(componentsToApply.get(MODIFIES_LIVE_LOCK_SCREEN)) && !isLLSEnabled) {
+ AlertDialog d = new AlertDialog.Builder(getActivity(),
+ android.R.style.Theme_Material_Dialog)
+ .setTitle(R.string.enable_live_lock_screen_dialog_title)
+ .setMessage(R.string.enable_live_lock_screen_dialog_message)
+ .setPositiveButton(R.string.enable_live_lock_screen_dialog_positive_btn_text,
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ CMSettings.Secure.putInt(getActivity().getContentResolver(),
+ LIVE_LOCK_SCREEN_ENABLED, 1);
+ getChooserActivity().themeChangeStart();
+ animateProgressIn(mApplyThemeRunnable);
+ }
+ })
+ .setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ mSelectedComponentsMap.remove(MODIFIES_LIVE_LOCK_SCREEN);
+ boolean wasNone = false;
+ if (TextUtils.equals("", mSelectedComponentsMap.get(
+ MODIFIES_LOCKSCREEN))) {
+ if (!TextUtils.isEmpty(mCurrentTheme.get(MODIFIES_LOCKSCREEN))) {
+ //The map entry was set to empty string because there's a
+ //lockscreen currently applied and setting this entry to empty
+ //would instruct the ThemeManager to clear the currently applied
+ //lockscreen, but the user decided not to enable LLS so we need
+ //to abort this change
+ mSelectedComponentsMap.put(MODIFIES_LOCKSCREEN,
+ mCurrentTheme.get(MODIFIES_LOCKSCREEN));
+ } else {
+ wasNone = true;
+ }
+ }
+ //Restore the lockscreen card to its previous state
+ mHandler.post(new RestoreLockScreenCardRunnable(wasNone,
+ mCurrentTheme.get(MODIFIES_LOCKSCREEN)));
+
+ //Did the user make more changes?
+ boolean modLLS = componentsToApply.containsKey(
+ MODIFIES_LIVE_LOCK_SCREEN);
+ boolean modLockscreen = componentsToApply.containsKey(
+ MODIFIES_LOCKSCREEN);
+ if (modLLS && ((modLockscreen && componentsToApply.size() > 2) ||
+ (!modLockscreen && componentsToApply.size() > 1))) {
+ getChooserActivity().themeChangeStart();
+ animateProgressIn(mApplyThemeRunnable);
+ }
+ }
+ })
+ .setCancelable(false)
+ .create();
+ d.setCanceledOnTouchOutside(false);
+ d.show();
+ } else {
+ getChooserActivity().themeChangeStart();
+ animateProgressIn(mApplyThemeRunnable);
+ }
}
/**