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 a36ca358e..561945bca 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 @@ -327,9 +327,7 @@ class AndroidNotificationManagerImpl implements AndroidNotificationManager, R.plurals.private_message_notification_text, contactTotal, contactTotal)); b.setNumber(contactTotal); - boolean showOnLockScreen = - settings.getBoolean(PREF_NOTIFY_LOCK_SCREEN, false); - b.setLockscreenVisibility(CATEGORY_MESSAGE, showOnLockScreen); + b.setNotificationCategory(CATEGORY_MESSAGE); if (mayAlertAgain) setAlertProperties(b); setDeleteIntent(b, CONTACT_URI); Set contacts = contactCounts.keySet(); @@ -431,9 +429,7 @@ class AndroidNotificationManagerImpl implements AndroidNotificationManager, R.plurals.group_message_notification_text, groupTotal, groupTotal)); b.setNumber(groupTotal); - boolean showOnLockScreen = - settings.getBoolean(PREF_NOTIFY_LOCK_SCREEN, false); - b.setLockscreenVisibility(CATEGORY_SOCIAL, showOnLockScreen); + b.setNotificationCategory(CATEGORY_SOCIAL); if (mayAlertAgain) setAlertProperties(b); setDeleteIntent(b, GROUP_URI); Set groups = groupCounts.keySet(); @@ -504,9 +500,7 @@ class AndroidNotificationManagerImpl implements AndroidNotificationManager, R.plurals.forum_post_notification_text, forumTotal, forumTotal)); b.setNumber(forumTotal); - boolean showOnLockScreen = - settings.getBoolean(PREF_NOTIFY_LOCK_SCREEN, false); - b.setLockscreenVisibility(CATEGORY_SOCIAL, showOnLockScreen); + b.setNotificationCategory(CATEGORY_SOCIAL); if (mayAlertAgain) setAlertProperties(b); setDeleteIntent(b, FORUM_URI); Set forums = forumCounts.keySet(); @@ -575,9 +569,7 @@ class AndroidNotificationManagerImpl implements AndroidNotificationManager, R.plurals.blog_post_notification_text, blogTotal, blogTotal)); b.setNumber(blogTotal); - boolean showOnLockScreen = - settings.getBoolean(PREF_NOTIFY_LOCK_SCREEN, false); - b.setLockscreenVisibility(CATEGORY_SOCIAL, showOnLockScreen); + b.setNotificationCategory(CATEGORY_SOCIAL); if (mayAlertAgain) setAlertProperties(b); setDeleteIntent(b, BLOG_URI); // Touching the notification shows the combined blog feed @@ -618,9 +610,7 @@ class AndroidNotificationManagerImpl implements AndroidNotificationManager, b.setContentText(appContext.getResources().getQuantityString( R.plurals.introduction_notification_text, introductionTotal, introductionTotal)); - boolean showOnLockScreen = - settings.getBoolean(PREF_NOTIFY_LOCK_SCREEN, false); - b.setLockscreenVisibility(CATEGORY_MESSAGE, showOnLockScreen); + b.setNotificationCategory(CATEGORY_MESSAGE); setAlertProperties(b); setDeleteIntent(b, INTRODUCTION_URI); // Touching the notification shows the contact list 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 9d6075959..51d75e74d 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 @@ -89,7 +89,6 @@ import static org.briarproject.briar.api.android.AndroidNotificationManager.GROU 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; @@ -127,7 +126,6 @@ public class SettingsFragment extends PreferenceFragmentCompat private SwitchPreference notifyForumPosts; private SwitchPreference notifyBlogPosts; private SwitchPreference notifyVibration; - private SwitchPreference notifyLockscreen; private Preference notifySound; @@ -179,8 +177,6 @@ public class SettingsFragment extends PreferenceFragmentCompat "pref_key_notify_blog_posts"); notifyVibration = (SwitchPreference) findPreference( "pref_key_notify_vibration"); - notifyLockscreen = (SwitchPreference) findPreference( - "pref_key_notify_lock_screen"); notifySound = findPreference("pref_key_notify_sound"); language.setOnPreferenceChangeListener(this); @@ -207,10 +203,6 @@ public class SettingsFragment extends PreferenceFragmentCompat torMobile.setOnPreferenceChangeListener(this); screenLock.setOnPreferenceChangeListener(this); screenLockTimeout.setOnPreferenceChangeListener(this); - if (SDK_INT >= 21) { - notifyLockscreen.setVisible(true); - notifyLockscreen.setOnPreferenceChangeListener(this); - } findPreference("pref_key_send_feedback").setOnPreferenceClickListener( preference -> { @@ -380,8 +372,6 @@ public class SettingsFragment extends PreferenceFragmentCompat notifyForumPosts.setOnPreferenceChangeListener(this); notifyBlogPosts.setOnPreferenceChangeListener(this); notifyVibration.setOnPreferenceChangeListener(this); - notifyLockscreen.setChecked(settings.getBoolean( - PREF_NOTIFY_LOCK_SCREEN, false)); notifySound.setOnPreferenceClickListener( pref -> onNotificationSoundClicked()); String text; @@ -409,7 +399,6 @@ public class SettingsFragment extends PreferenceFragmentCompat setupNotificationPreference(notifyBlogPosts, BLOG_CHANNEL_ID, R.string.notify_blog_posts_setting_summary_26); notifyVibration.setVisible(false); - notifyLockscreen.setVisible(false); notifySound.setVisible(false); } setSettingsEnabled(true); @@ -432,7 +421,6 @@ public class SettingsFragment extends PreferenceFragmentCompat notifyForumPosts.setEnabled(enabled); notifyBlogPosts.setEnabled(enabled); notifyVibration.setEnabled(enabled); - notifyLockscreen.setEnabled(enabled); notifySound.setEnabled(enabled); } @@ -553,10 +541,6 @@ public class SettingsFragment extends PreferenceFragmentCompat Settings s = new Settings(); s.putBoolean(PREF_NOTIFY_VIBRATION, (Boolean) newValue); storeSettings(s); - } else if (preference == notifyLockscreen) { - Settings s = new Settings(); - s.putBoolean(PREF_NOTIFY_LOCK_SCREEN, (Boolean) newValue); - storeSettings(s); } return true; } diff --git a/briar-android/src/main/java/org/briarproject/briar/android/util/BriarNotificationBuilder.java b/briar-android/src/main/java/org/briarproject/briar/android/util/BriarNotificationBuilder.java index d51c0dad1..cd6c6e4bd 100644 --- a/briar-android/src/main/java/org/briarproject/briar/android/util/BriarNotificationBuilder.java +++ b/briar-android/src/main/java/org/briarproject/briar/android/util/BriarNotificationBuilder.java @@ -1,15 +1,14 @@ package org.briarproject.briar.android.util; import android.content.Context; -import android.os.Build; import android.support.annotation.ColorRes; import android.support.v4.app.NotificationCompat; import android.support.v4.content.ContextCompat; import org.briarproject.briar.R; +import static android.os.Build.VERSION.SDK_INT; import static android.support.v4.app.NotificationCompat.VISIBILITY_PRIVATE; -import static android.support.v4.app.NotificationCompat.VISIBILITY_SECRET; public class BriarNotificationBuilder extends NotificationCompat.Builder { @@ -22,6 +21,7 @@ public class BriarNotificationBuilder extends NotificationCompat.Builder { setLights(ContextCompat.getColor(context, R.color.briar_green_light), 750, 500); + if (SDK_INT >= 21) setVisibility(VISIBILITY_PRIVATE); } public BriarNotificationBuilder setColorRes(@ColorRes int res) { @@ -29,13 +29,8 @@ public class BriarNotificationBuilder extends NotificationCompat.Builder { return this; } - public BriarNotificationBuilder setLockscreenVisibility(String category, - boolean show) { - if (Build.VERSION.SDK_INT >= 21) { - setCategory(category); - if (show) setVisibility(VISIBILITY_PRIVATE); - else setVisibility(VISIBILITY_SECRET); - } + public BriarNotificationBuilder setNotificationCategory(String category) { + if (SDK_INT >= 21) setCategory(category); return this; } 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 fdca9f595..e02a9832f 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 @@ -21,7 +21,6 @@ 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"; // Notification IDs int ONGOING_NOTIFICATION_ID = 1; diff --git a/briar-android/src/main/res/values/strings.xml b/briar-android/src/main/res/values/strings.xml index 722a2f50d..4ffe21506 100644 --- a/briar-android/src/main/res/values/strings.xml +++ b/briar-android/src/main/res/values/strings.xml @@ -421,8 +421,6 @@ Show alerts for blog posts Configure 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 f325934e9..2865760de 100644 --- a/briar-android/src/main/res/xml/settings.xml +++ b/briar-android/src/main/res/xml/settings.xml @@ -145,15 +145,6 @@ android:title="@string/notify_blog_posts_setting_title" android:widgetLayout="@layout/preference_switch_compat"/> - -