diff --git a/briar-android/src/main/java/org/briarproject/briar/android/AndroidNotificationManagerImpl.java b/briar-android/src/main/java/org/briarproject/briar/android/AndroidNotificationManagerImpl.java
index 003c77ee7..7d774721a 100644
--- a/briar-android/src/main/java/org/briarproject/briar/android/AndroidNotificationManagerImpl.java
+++ b/briar-android/src/main/java/org/briarproject/briar/android/AndroidNotificationManagerImpl.java
@@ -61,6 +61,7 @@ import static android.content.Context.NOTIFICATION_SERVICE;
import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP;
import static android.support.v4.app.NotificationCompat.CATEGORY_MESSAGE;
import static android.support.v4.app.NotificationCompat.CATEGORY_SOCIAL;
+import static android.support.v4.app.NotificationCompat.VISIBILITY_PRIVATE;
import static android.support.v4.app.NotificationCompat.VISIBILITY_SECRET;
import static java.util.logging.Level.WARNING;
import static org.briarproject.briar.android.activity.BriarActivity.GROUP_ID;
@@ -327,7 +328,12 @@ class AndroidNotificationManagerImpl implements AndroidNotificationManager,
}
if (Build.VERSION.SDK_INT >= 21) {
b.setCategory(CATEGORY_MESSAGE);
- b.setVisibility(VISIBILITY_SECRET);
+ boolean showOnLockScreen =
+ settings.getBoolean(PREF_NOTIFY_LOCK_SCREEN, false);
+ if (showOnLockScreen)
+ b.setVisibility(VISIBILITY_PRIVATE);
+ else
+ b.setVisibility(VISIBILITY_SECRET);
}
Object o = appContext.getSystemService(NOTIFICATION_SERVICE);
NotificationManager nm = (NotificationManager) o;
@@ -347,17 +353,6 @@ class AndroidNotificationManagerImpl implements AndroidNotificationManager,
return defaults;
}
- @Override
- public void clearAllContactNotifications() {
- androidExecutor.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- clearContactNotification();
- clearIntroductionSuccessNotification();
- }
- });
- }
-
@UiThread
private void showGroupMessageNotification(final GroupId g) {
androidExecutor.runOnUiThread(new Runnable() {
@@ -432,7 +427,12 @@ class AndroidNotificationManagerImpl implements AndroidNotificationManager,
}
if (Build.VERSION.SDK_INT >= 21) {
b.setCategory(CATEGORY_SOCIAL);
- b.setVisibility(VISIBILITY_SECRET);
+ boolean showOnLockScreen =
+ settings.getBoolean(PREF_NOTIFY_LOCK_SCREEN, false);
+ if (showOnLockScreen)
+ b.setVisibility(VISIBILITY_PRIVATE);
+ else
+ b.setVisibility(VISIBILITY_SECRET);
}
Object o = appContext.getSystemService(NOTIFICATION_SERVICE);
NotificationManager nm = (NotificationManager) o;
@@ -440,16 +440,6 @@ class AndroidNotificationManagerImpl implements AndroidNotificationManager,
}
}
- @Override
- public void clearAllGroupMessageNotifications() {
- androidExecutor.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- clearGroupMessageNotification();
- }
- });
- }
-
@UiThread
private void showForumPostNotification(final GroupId g) {
androidExecutor.runOnUiThread(new Runnable() {
@@ -524,7 +514,12 @@ class AndroidNotificationManagerImpl implements AndroidNotificationManager,
}
if (Build.VERSION.SDK_INT >= 21) {
b.setCategory(CATEGORY_SOCIAL);
- b.setVisibility(VISIBILITY_SECRET);
+ boolean showOnLockScreen =
+ settings.getBoolean(PREF_NOTIFY_LOCK_SCREEN, false);
+ if (showOnLockScreen)
+ b.setVisibility(VISIBILITY_PRIVATE);
+ else
+ b.setVisibility(VISIBILITY_SECRET);
}
Object o = appContext.getSystemService(NOTIFICATION_SERVICE);
NotificationManager nm = (NotificationManager) o;
@@ -532,16 +527,6 @@ class AndroidNotificationManagerImpl implements AndroidNotificationManager,
}
}
- @Override
- public void clearAllForumPostNotifications() {
- androidExecutor.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- clearForumPostNotification();
- }
- });
- }
-
@UiThread
private void showBlogPostNotification(final GroupId g) {
androidExecutor.runOnUiThread(new Runnable() {
@@ -602,7 +587,12 @@ class AndroidNotificationManagerImpl implements AndroidNotificationManager,
b.setContentIntent(t.getPendingIntent(nextRequestId++, 0));
if (Build.VERSION.SDK_INT >= 21) {
b.setCategory(CATEGORY_SOCIAL);
- b.setVisibility(VISIBILITY_SECRET);
+ boolean showOnLockScreen =
+ settings.getBoolean(PREF_NOTIFY_LOCK_SCREEN, false);
+ if (showOnLockScreen)
+ b.setVisibility(VISIBILITY_PRIVATE);
+ else
+ b.setVisibility(VISIBILITY_SECRET);
}
Object o = appContext.getSystemService(NOTIFICATION_SERVICE);
NotificationManager nm = (NotificationManager) o;
@@ -610,16 +600,6 @@ class AndroidNotificationManagerImpl implements AndroidNotificationManager,
}
}
- @Override
- public void clearAllBlogPostNotifications() {
- androidExecutor.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- clearBlogPostNotification();
- }
- });
- }
-
private void showIntroductionNotification() {
androidExecutor.runOnUiThread(new Runnable() {
@Override
@@ -658,7 +638,12 @@ class AndroidNotificationManagerImpl implements AndroidNotificationManager,
b.setContentIntent(t.getPendingIntent(nextRequestId++, 0));
if (Build.VERSION.SDK_INT >= 21) {
b.setCategory(CATEGORY_MESSAGE);
- b.setVisibility(VISIBILITY_SECRET);
+ boolean showOnLockScreen =
+ settings.getBoolean(PREF_NOTIFY_LOCK_SCREEN, false);
+ if (showOnLockScreen)
+ b.setVisibility(VISIBILITY_PRIVATE);
+ else
+ b.setVisibility(VISIBILITY_SECRET);
}
Object o = appContext.getSystemService(NOTIFICATION_SERVICE);
NotificationManager nm = (NotificationManager) o;
@@ -704,87 +689,4 @@ class AndroidNotificationManagerImpl implements AndroidNotificationManager,
}
});
}
-
- @Override
- public void blockAllContactNotifications() {
- androidExecutor.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- blockContacts = true;
- blockIntroductions = true;
- }
- });
- }
-
- @Override
- public void unblockAllContactNotifications() {
- androidExecutor.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- blockContacts = false;
- blockIntroductions = false;
- }
- });
- }
-
- @Override
- public void blockAllGroupMessageNotifications() {
- androidExecutor.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- blockGroups = true;
- }
- });
- }
-
- @Override
- public void unblockAllGroupMessageNotifications() {
- androidExecutor.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- blockGroups = false;
- }
- });
- }
-
- @Override
- public void blockAllForumPostNotifications() {
- androidExecutor.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- blockForums = true;
- }
- });
- }
-
- @Override
- public void unblockAllForumPostNotifications() {
- androidExecutor.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- blockForums = false;
- }
- });
- }
-
- @Override
- public void blockAllBlogPostNotifications() {
- androidExecutor.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- blockBlogs = true;
- }
- });
- }
-
- @Override
- public void unblockAllBlogPostNotifications() {
- androidExecutor.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- blockBlogs = false;
- }
- });
- }
-
}
diff --git a/briar-android/src/main/java/org/briarproject/briar/android/blog/FeedControllerImpl.java b/briar-android/src/main/java/org/briarproject/briar/android/blog/FeedControllerImpl.java
index 1d02c8fdc..84b3c0739 100644
--- a/briar-android/src/main/java/org/briarproject/briar/android/blog/FeedControllerImpl.java
+++ b/briar-android/src/main/java/org/briarproject/briar/android/blog/FeedControllerImpl.java
@@ -53,14 +53,11 @@ class FeedControllerImpl extends BaseControllerImpl
public void onStart() {
super.onStart();
if (listener == null) throw new IllegalStateException();
- notificationManager.blockAllBlogPostNotifications();
- notificationManager.clearAllBlogPostNotifications();
}
@Override
public void onStop() {
super.onStop();
- notificationManager.unblockAllBlogPostNotifications();
}
@Override
diff --git a/briar-android/src/main/java/org/briarproject/briar/android/contact/ContactListFragment.java b/briar-android/src/main/java/org/briarproject/briar/android/contact/ContactListFragment.java
index 3ce6e7f1f..d52915fce 100644
--- a/briar-android/src/main/java/org/briarproject/briar/android/contact/ContactListFragment.java
+++ b/briar-android/src/main/java/org/briarproject/briar/android/contact/ContactListFragment.java
@@ -178,8 +178,6 @@ public class ContactListFragment extends BaseFragment implements EventListener {
@Override
public void onStart() {
super.onStart();
- notificationManager.blockAllContactNotifications();
- notificationManager.clearAllContactNotifications();
eventBus.addListener(this);
loadContacts();
list.startPeriodicUpdate();
@@ -189,7 +187,6 @@ public class ContactListFragment extends BaseFragment implements EventListener {
public void onStop() {
super.onStop();
eventBus.removeListener(this);
- notificationManager.unblockAllContactNotifications();
adapter.clear();
list.showProgressBar();
list.stopPeriodicUpdate();
diff --git a/briar-android/src/main/java/org/briarproject/briar/android/forum/ForumListFragment.java b/briar-android/src/main/java/org/briarproject/briar/android/forum/ForumListFragment.java
index daf83ac12..42f22288d 100644
--- a/briar-android/src/main/java/org/briarproject/briar/android/forum/ForumListFragment.java
+++ b/briar-android/src/main/java/org/briarproject/briar/android/forum/ForumListFragment.java
@@ -119,8 +119,6 @@ public class ForumListFragment extends BaseEventFragment implements
@Override
public void onStart() {
super.onStart();
- notificationManager.blockAllForumPostNotifications();
- notificationManager.clearAllForumPostNotifications();
loadForums();
loadAvailableForums();
list.startPeriodicUpdate();
@@ -129,7 +127,6 @@ public class ForumListFragment extends BaseEventFragment implements
@Override
public void onStop() {
super.onStop();
- notificationManager.unblockAllForumPostNotifications();
adapter.clear();
list.showProgressBar();
list.stopPeriodicUpdate();
diff --git a/briar-android/src/main/java/org/briarproject/briar/android/privategroup/list/GroupListControllerImpl.java b/briar-android/src/main/java/org/briarproject/briar/android/privategroup/list/GroupListControllerImpl.java
index 4c0febda6..6cde4e955 100644
--- a/briar-android/src/main/java/org/briarproject/briar/android/privategroup/list/GroupListControllerImpl.java
+++ b/briar-android/src/main/java/org/briarproject/briar/android/privategroup/list/GroupListControllerImpl.java
@@ -79,15 +79,12 @@ class GroupListControllerImpl extends DbControllerImpl
throw new IllegalStateException(
"GroupListListener needs to be attached");
eventBus.addListener(this);
- notificationManager.blockAllGroupMessageNotifications();
- notificationManager.clearAllGroupMessageNotifications();
}
@Override
@CallSuper
public void onStop() {
eventBus.removeListener(this);
- notificationManager.unblockAllGroupMessageNotifications();
}
@Override
diff --git a/briar-android/src/main/java/org/briarproject/briar/android/settings/SettingsFragment.java b/briar-android/src/main/java/org/briarproject/briar/android/settings/SettingsFragment.java
index 0f627bb40..98afedd52 100644
--- a/briar-android/src/main/java/org/briarproject/briar/android/settings/SettingsFragment.java
+++ b/briar-android/src/main/java/org/briarproject/briar/android/settings/SettingsFragment.java
@@ -6,6 +6,7 @@ import android.content.Intent;
import android.media.Ringtone;
import android.media.RingtoneManager;
import android.net.Uri;
+import android.os.Build;
import android.os.Bundle;
import android.support.v7.preference.CheckBoxPreference;
import android.support.v7.preference.ListPreference;
@@ -54,6 +55,7 @@ import static org.briarproject.briar.android.activity.RequestCodes.REQUEST_RINGT
import static org.briarproject.briar.api.android.AndroidNotificationManager.PREF_NOTIFY_BLOG;
import static org.briarproject.briar.api.android.AndroidNotificationManager.PREF_NOTIFY_FORUM;
import static org.briarproject.briar.api.android.AndroidNotificationManager.PREF_NOTIFY_GROUP;
+import static org.briarproject.briar.api.android.AndroidNotificationManager.PREF_NOTIFY_LOCK_SCREEN;
import static org.briarproject.briar.api.android.AndroidNotificationManager.PREF_NOTIFY_PRIVATE;
import static org.briarproject.briar.api.android.AndroidNotificationManager.PREF_NOTIFY_RINGTONE_NAME;
import static org.briarproject.briar.api.android.AndroidNotificationManager.PREF_NOTIFY_RINGTONE_URI;
@@ -81,6 +83,8 @@ public class SettingsFragment extends PreferenceFragmentCompat
private CheckBoxPreference notifyForumPosts;
private CheckBoxPreference notifyBlogPosts;
private CheckBoxPreference notifyVibration;
+ private CheckBoxPreference notifyLockscreen;
+
private Preference notifySound;
// Fields that are accessed from background threads must be volatile
@@ -114,6 +118,8 @@ public class SettingsFragment extends PreferenceFragmentCompat
"pref_key_notify_blog_posts");
notifyVibration = (CheckBoxPreference) findPreference(
"pref_key_notify_vibration");
+ notifyLockscreen = (CheckBoxPreference) findPreference(
+ "pref_key_notify_lock_screen");
notifySound = findPreference("pref_key_notify_sound");
enableBluetooth.setOnPreferenceChangeListener(this);
@@ -123,7 +129,10 @@ public class SettingsFragment extends PreferenceFragmentCompat
notifyForumPosts.setOnPreferenceChangeListener(this);
notifyBlogPosts.setOnPreferenceChangeListener(this);
notifyVibration.setOnPreferenceChangeListener(this);
-
+ if (Build.VERSION.SDK_INT >= 21) {
+ notifyLockscreen.setVisible(true);
+ notifyLockscreen.setOnPreferenceChangeListener(this);
+ }
notifySound.setOnPreferenceClickListener(
new Preference.OnPreferenceClickListener() {
@Override
@@ -234,6 +243,9 @@ public class SettingsFragment extends PreferenceFragmentCompat
notifyVibration.setChecked(settings.getBoolean(
PREF_NOTIFY_VIBRATION, true));
+ notifyLockscreen.setChecked(settings.getBoolean(
+ PREF_NOTIFY_LOCK_SCREEN, false));
+
String text;
if (settings.getBoolean(PREF_NOTIFY_SOUND, true)) {
String ringtoneName =
@@ -290,6 +302,10 @@ public class SettingsFragment extends PreferenceFragmentCompat
Settings s = new Settings();
s.putBoolean(PREF_NOTIFY_VIBRATION, (Boolean) o);
storeSettings(s);
+ } else if (preference == notifyLockscreen) {
+ Settings s = new Settings();
+ s.putBoolean(PREF_NOTIFY_LOCK_SCREEN, (Boolean) o);
+ storeSettings(s);
}
return true;
}
diff --git a/briar-android/src/main/java/org/briarproject/briar/api/android/AndroidNotificationManager.java b/briar-android/src/main/java/org/briarproject/briar/api/android/AndroidNotificationManager.java
index 869869c2e..865e7d77f 100644
--- a/briar-android/src/main/java/org/briarproject/briar/api/android/AndroidNotificationManager.java
+++ b/briar-android/src/main/java/org/briarproject/briar/api/android/AndroidNotificationManager.java
@@ -18,23 +18,16 @@ public interface AndroidNotificationManager {
String PREF_NOTIFY_RINGTONE_NAME = "notifyRingtoneName";
String PREF_NOTIFY_RINGTONE_URI = "notifyRingtoneUri";
String PREF_NOTIFY_VIBRATION = "notifyVibration";
+ String PREF_NOTIFY_LOCK_SCREEN = "notifyLockScreen";
void clearContactNotification(ContactId c);
- void clearAllContactNotifications();
-
void clearGroupMessageNotification(GroupId g);
- void clearAllGroupMessageNotifications();
-
void clearForumPostNotification(GroupId g);
- void clearAllForumPostNotifications();
-
void clearBlogPostNotification(GroupId g);
- void clearAllBlogPostNotifications();
-
void blockContactNotification(ContactId c);
void unblockContactNotification(ContactId c);
@@ -42,20 +35,4 @@ public interface AndroidNotificationManager {
void blockNotification(GroupId g);
void unblockNotification(GroupId g);
-
- void blockAllContactNotifications();
-
- void unblockAllContactNotifications();
-
- void blockAllGroupMessageNotifications();
-
- void unblockAllGroupMessageNotifications();
-
- void blockAllForumPostNotifications();
-
- void unblockAllForumPostNotifications();
-
- void blockAllBlogPostNotifications();
-
- void unblockAllBlogPostNotifications();
}
diff --git a/briar-android/src/main/res/values/strings.xml b/briar-android/src/main/res/values/strings.xml
index 8a652f477..bb1288d6f 100644
--- a/briar-android/src/main/res/values/strings.xml
+++ b/briar-android/src/main/res/values/strings.xml
@@ -348,6 +348,8 @@
Blog posts
Show alerts for blog posts
Vibrate
+ Lock Screen
+ Show notifications on the lock screen
Sound
Default ringtone
None
diff --git a/briar-android/src/main/res/xml/settings.xml b/briar-android/src/main/res/xml/settings.xml
index 07d47137b..889161679 100644
--- a/briar-android/src/main/res/xml/settings.xml
+++ b/briar-android/src/main/res/xml/settings.xml
@@ -85,6 +85,14 @@
android:title="@string/notify_blog_posts_setting_title"
android:summary="@string/notify_blog_posts_setting_summary"/>
+
+