diff --git a/ShoppingList/src/main/java/org/openintents/shopping/ui/PreferenceActivity.java b/ShoppingList/src/main/java/org/openintents/shopping/ui/PreferenceActivity.java
index 3e42e2c..175b8b4 100644
--- a/ShoppingList/src/main/java/org/openintents/shopping/ui/PreferenceActivity.java
+++ b/ShoppingList/src/main/java/org/openintents/shopping/ui/PreferenceActivity.java
@@ -69,6 +69,8 @@ public class PreferenceActivity extends android.preference.PreferenceActivity
public static final boolean PREFS_SHOW_PRIORITY_DEFAULT = true;
public static final String PREFS_SCREENLOCK = "screenlock";
public static final boolean PREFS_SCREENLOCK_DEFAULT = false;
+ public static final String PREFS_SHOWINLOCKSCREEN = "showinlockscreen";
+ public static final boolean PREFS_SHOWINLOCKSCREEN_DEFAULT = false;
public static final String PREFS_RESETQUANTITY = "resetquantity";
public static final boolean PREFS_RESETQUANTITY_DEFAULT = false;
public static final String PREFS_ADDFORBARCODE = "addforbarcode";
@@ -546,6 +548,8 @@ public void onClick(DialogInterface dialog,
PREFS_ADDFORBARCODE_DEFAULT);
editor.putBoolean(PREFS_SCREENLOCK,
PREFS_SCREENLOCK_DEFAULT);
+ editor.putBoolean(PREFS_SHOWINLOCKSCREEN,
+ PREFS_SHOWINLOCKSCREEN_DEFAULT);
editor.putBoolean(PREFS_QUICKEDITMODE,
PREFS_QUICKEDITMODE_DEFAULT);
editor.putBoolean(PREFS_USE_FILTERS,
diff --git a/ShoppingList/src/main/java/org/openintents/shopping/ui/ShoppingActivity.java b/ShoppingList/src/main/java/org/openintents/shopping/ui/ShoppingActivity.java
index 8fa2d9d..ccbc45e 100644
--- a/ShoppingList/src/main/java/org/openintents/shopping/ui/ShoppingActivity.java
+++ b/ShoppingList/src/main/java/org/openintents/shopping/ui/ShoppingActivity.java
@@ -538,6 +538,14 @@ public void onCreate(Bundle icicle) {
toggleBoughtInputMethod = ((ShoppingApplication) getApplication()).dependencies().getToggleBoughtInputMethod(this, mItemsView);
}
+ private void showInLockScreen(boolean enable) {
+ if (enable) {
+ getWindow().setFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED, - WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
+ } else {
+ getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
+ }
+ }
+
private Uri buildDefaultShoppingListUri(final int defaultShoppingList) {
return Uri.withAppendedPath(Lists.CONTENT_URI,
String.valueOf(defaultShoppingList));
@@ -637,6 +645,9 @@ private void initFromPreferences() {
.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
+ showInLockScreen(sp.getBoolean(PreferenceActivity.PREFS_SHOWINLOCKSCREEN,
+ PreferenceActivity.PREFS_SHOWINLOCKSCREEN_DEFAULT));
+
if (mItemsView != null) {
if (sp.getBoolean(PreferenceActivity.PREFS_SHOW_PRICE,
PreferenceActivity.PREFS_SHOW_PRICE_DEFAULT)) {
diff --git a/ShoppingList/src/main/res/values/strings.xml b/ShoppingList/src/main/res/values/strings.xml
index c446f6a..85b44bb 100644
--- a/ShoppingList/src/main/res/values/strings.xml
+++ b/ShoppingList/src/main/res/values/strings.xml
@@ -212,6 +212,8 @@
Keep track of separate prices for each item at each store.
Disable screen lock
Prevents the screen to be locked when checked.
+ Show in lockscreen
+ Show the app when the screen is locked.
Filters
Lists can be filtered by tags or stores.
Limit item name completion
diff --git a/ShoppingList/src/main/res/xml/preferences.xml b/ShoppingList/src/main/res/xml/preferences.xml
index 925d943..3d15764 100644
--- a/ShoppingList/src/main/res/xml/preferences.xml
+++ b/ShoppingList/src/main/res/xml/preferences.xml
@@ -91,6 +91,11 @@
android:key="screenlock"
android:summary="@string/preference_screenlock_summary"
android:title="@string/preference_screenlock_title" />
+