add expert preference to disable all notifications

This preference is meant for whitelabel builds that are meant to be
entirely controlled by the server, without user interaction, e.g.
"appliances".  Some users have asked for such a thing, so it makes sense to
have it available as an expert preference.  In general, we want to ensure
that installs/updates always show a notification so that the user is aware
of what is being installed on their computers.  That is the same policy as
other app stores like Google Play, etc.
This commit is contained in:
Hans-Christoph Steiner 2018-06-25 15:05:50 +02:00
parent 5771908f90
commit d8d043125b
5 changed files with 27 additions and 2 deletions

View File

@ -144,6 +144,12 @@
android:summary="@string/keep_install_history_summary"
android:defaultValue="false"
android:dependency="expert"/>
<CheckBoxPreference
android:key="hideAllNotifications"
android:title="@string/hide_all_notifications"
android:summary="@string/hide_all_notifications_summary"
android:defaultValue="false"
android:dependency="expert"/>
<CheckBoxPreference
android:key="forceOldIndex"
android:title="@string/force_old_index"

View File

@ -162,7 +162,7 @@ class NotificationHelper {
return;
}
if (!notificationManager.areNotificationsEnabled()) {
if (!notificationManager.areNotificationsEnabled() || Preferences.get().hideAllNotifications()) {
return;
}
@ -193,7 +193,7 @@ class NotificationHelper {
}
private void createSummaryNotifications() {
if (!notificationManager.areNotificationsEnabled()) {
if (!notificationManager.areNotificationsEnabled() || Preferences.get().hideAllNotifications()) {
return;
}

View File

@ -105,6 +105,7 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh
public static final String PREF_PANIC_EXIT = "pref_panic_exit";
public static final String PREF_PANIC_HIDE = "pref_panic_hide";
public static final String PREF_HIDE_ON_LONG_PRESS_SEARCH = "hideOnLongPressSearch";
public static final String PREF_HIDE_ALL_NOTIFICATIONS = "hideAllNotifications";
public static final int OVER_NETWORK_NEVER = 0;
public static final int OVER_NETWORK_ON_DEMAND = 1;
@ -489,6 +490,14 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh
return preferences.getBoolean(PREF_HIDE_ON_LONG_PRESS_SEARCH, IGNORED_B);
}
/**
* Preference for whitelabel builds that are meant to be entirely controlled
* by the server, without user interaction, e.g. "appliances".
*/
public boolean hideAllNotifications() {
return preferences.getBoolean(PREF_HIDE_ALL_NOTIFICATIONS, IGNORED_B);
}
/**
* This is cached as it is called several times inside app list adapters.
* Providing it here means the shared preferences file only needs to be

View File

@ -16,6 +16,10 @@
<string name="updates">Updates</string>
<string name="unstable_updates">Unstable updates</string>
<string name="unstable_updates_summary">Suggest updates to unstable versions</string>
<string name="hide_all_notifications">Hide all notifications</string>
<string name="hide_all_notifications_summary">Prevent all actions from showing in the status bar and notification
drawer.
</string>
<string name="keep_install_history">Keep install history</string>
<string name="keep_install_history_summary">Store a log of all installs and uninstalls in a private store</string>
<string name="force_old_index">Force old index format</string>

View File

@ -165,6 +165,12 @@
android:summary="@string/keep_install_history_summary"
android:defaultValue="false"
android:dependency="expert"/>
<CheckBoxPreference
android:key="hideAllNotifications"
android:title="@string/hide_all_notifications"
android:summary="@string/hide_all_notifications_summary"
android:defaultValue="false"
android:dependency="expert"/>
<CheckBoxPreference
android:key="forceOldIndex"
android:title="@string/force_old_index"