summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authord34d <clark@cyngn.com>2016-03-28 10:09:22 -0700
committerd34d <clark@cyngn.com>2016-03-28 10:09:22 -0700
commitb0d064ed980e5525232390a561e4221069343b3f (patch)
treeb98a9a07edbb08c2eb9c3ccd76bc26dfbde7f2b7 /src
parenta8da1f0e15abcd1f5a3af57e2c9c095512b5e8bf (diff)
downloadpackages_apps_ThemeChooser-b0d064ed980e5525232390a561e4221069343b3f.tar.gz
packages_apps_ThemeChooser-b0d064ed980e5525232390a561e4221069343b3f.tar.bz2
packages_apps_ThemeChooser-b0d064ed980e5525232390a561e4221069343b3f.zip
Add ModLock option in lock screen picker
This will intent out to the live lock screen settings so the user can pick a live lock screen (ModLock) Change-Id: Ia5bf5a6961ca2a50032cea2da5355e3fae7ae37a TICKET: CYNGNOS-2301
Diffstat (limited to 'src')
-rw-r--r--src/com/cyngn/theme/chooser/ComponentSelector.java24
-rw-r--r--src/com/cyngn/theme/chooser/ThemeFragment.java14
2 files changed, 31 insertions, 7 deletions
diff --git a/src/com/cyngn/theme/chooser/ComponentSelector.java b/src/com/cyngn/theme/chooser/ComponentSelector.java
index 92397f0..5347250 100644
--- a/src/com/cyngn/theme/chooser/ComponentSelector.java
+++ b/src/com/cyngn/theme/chooser/ComponentSelector.java
@@ -79,8 +79,12 @@ public class ComponentSelector extends LinearLayout
public static final String EXTERNAL_WALLPAPER = "external";
+ public static final String MOD_LOCK = "mod_lock";
+
private static final int EXTRA_WALLPAPER_COMPONENTS = 2;
+ private static final int EXTRA_LOCK_SCREEN_WALLPAPER_COMPONENTS = 3;
+
protected static final long DEFAULT_COMPONENT_ID = 0;
private Context mContext;
@@ -530,7 +534,8 @@ public class ComponentSelector extends LinearLayout
}
if (MODIFIES_LAUNCHER.equals(mComponentType)) {
return newWallpapersView(cursor, container, position,
- cursor.getColumnIndex(PreviewColumns.WALLPAPER_THUMBNAIL), false);
+ cursor.getColumnIndex(PreviewColumns.WALLPAPER_THUMBNAIL), false,
+ EXTRA_WALLPAPER_COMPONENTS);
}
if (MODIFIES_BOOT_ANIM.equals(mComponentType)) {
return newBootanimationView(cursor, container, position);
@@ -542,8 +547,8 @@ public class ComponentSelector extends LinearLayout
}
if (MODIFIES_LOCKSCREEN.equals(mComponentType)) {
boolean isLiveLockScreen = false;
- if (position >= EXTRA_WALLPAPER_COMPONENTS) {
- cursor.moveToPosition(position - EXTRA_WALLPAPER_COMPONENTS);
+ if (position >= EXTRA_LOCK_SCREEN_WALLPAPER_COMPONENTS) {
+ cursor.moveToPosition(position - EXTRA_LOCK_SCREEN_WALLPAPER_COMPONENTS);
int liveLockIndex = cursor.getColumnIndex(MODIFIES_LIVE_LOCK_SCREEN);
isLiveLockScreen = liveLockIndex >= 0 &&
cursor.getInt(liveLockIndex) == 1;
@@ -551,7 +556,8 @@ public class ComponentSelector extends LinearLayout
int index = isLiveLockScreen
? cursor.getColumnIndex(PreviewColumns.LIVE_LOCK_SCREEN_THUMBNAIL)
: cursor.getColumnIndex(PreviewColumns.LOCK_WALLPAPER_THUMBNAIL);
- return newWallpapersView(cursor, container, position, index, isLiveLockScreen);
+ return newWallpapersView(cursor, container, position, index, isLiveLockScreen,
+ EXTRA_LOCK_SCREEN_WALLPAPER_COMPONENTS);
}
return null;
}
@@ -650,7 +656,7 @@ public class ComponentSelector extends LinearLayout
}
private View newWallpapersView(Cursor cursor, ViewGroup parent, int position,
- int wallpaperIndex, boolean isLiveLockScreen) {
+ int wallpaperIndex, boolean isLiveLockScreen, int numExtraComponents) {
View v = mInflater.inflate(R.layout.wallpaper_component_selection_item, parent,
false);
ImageView iv = (ImageView) v.findViewById(R.id.icon);
@@ -663,8 +669,14 @@ public class ComponentSelector extends LinearLayout
v.setTag(R.id.tag_key_package_name, EXTERNAL_WALLPAPER);
((TextView) v.findViewById(R.id.title))
.setText(R.string.wallpaper_external_title);
+ } else if (numExtraComponents == EXTRA_LOCK_SCREEN_WALLPAPER_COMPONENTS && position == 2) {
+ // TODO: update drawable once the asset is provided by design
+ iv.setImageResource(android.R.drawable.ic_lock_lock);
+ v.setTag(R.id.tag_key_package_name, MOD_LOCK);
+ ((TextView) v.findViewById(R.id.title))
+ .setText(R.string.mod_lock_title);
} else {
- cursor.moveToPosition(position - EXTRA_WALLPAPER_COMPONENTS);
+ cursor.moveToPosition(position - numExtraComponents);
int pkgNameIndex = cursor.getColumnIndex(ThemesContract.ThemesColumns.PKG_NAME);
int cmpntIdIndex = cursor.getColumnIndex(PreviewColumns.COMPONENT_ID);
long cmpntId = (cmpntIdIndex >= 0) ?
diff --git a/src/com/cyngn/theme/chooser/ThemeFragment.java b/src/com/cyngn/theme/chooser/ThemeFragment.java
index 7bf983a..103dca0 100644
--- a/src/com/cyngn/theme/chooser/ThemeFragment.java
+++ b/src/com/cyngn/theme/chooser/ThemeFragment.java
@@ -12,6 +12,7 @@ import android.animation.ValueAnimator;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.WallpaperManager;
+import android.content.ActivityNotFoundException;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
@@ -2085,7 +2086,7 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb
getString(R.string.wallpaper_label));
}
};
- requestPermissions(new String[] {READ_EXTERNAL_STORAGE},
+ requestPermissions(new String[]{READ_EXTERNAL_STORAGE},
PERMISSION_REQUEST);
} else {
getChooserActivity().pickExternalWallpaper();
@@ -2131,6 +2132,8 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb
setCardTitle(mLockScreenCard, WALLPAPER_NONE,
getString(R.string.lockscreen_label));
}
+ } else if (ComponentSelector.MOD_LOCK.equals(pkgName)) {
+ startLiveLockScreenSettings();
} else {
if (MODIFIES_LIVE_LOCK_SCREEN.equals(component)) {
loaderId = LOADER_ID_LIVE_LOCK_SCREEN;
@@ -2924,6 +2927,15 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb
}, SHOW_LOCK_SCREEN_CARD_DELAY);
}
+ protected void startLiveLockScreenSettings() {
+ Intent intent = new Intent(cyanogenmod.content.Intent.ACTION_OPEN_LIVE_LOCKSCREEN_SETTINGS);
+ try {
+ startActivity(intent);
+ } catch (ActivityNotFoundException e) {
+ // TODO: inform user that this action failed (Toast?)
+ }
+ }
+
class AnimationLoader extends AsyncTask<Void, Void, Boolean> {
Context mContext;
String mPkgName;