Merge branch 'notification-preferences' into 'master'
notification preferences See merge request fdroid/fdroidclient!698
This commit is contained in:
commit
407e545a24
@ -144,6 +144,12 @@
|
|||||||
android:summary="@string/keep_install_history_summary"
|
android:summary="@string/keep_install_history_summary"
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:dependency="expert"/>
|
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
|
<CheckBoxPreference
|
||||||
android:key="forceOldIndex"
|
android:key="forceOldIndex"
|
||||||
android:title="@string/force_old_index"
|
android:title="@string/force_old_index"
|
||||||
|
@ -162,7 +162,7 @@ class NotificationHelper {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!notificationManager.areNotificationsEnabled()) {
|
if (!notificationManager.areNotificationsEnabled() || Preferences.get().hideAllNotifications()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,7 +193,7 @@ class NotificationHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void createSummaryNotifications() {
|
private void createSummaryNotifications() {
|
||||||
if (!notificationManager.areNotificationsEnabled()) {
|
if (!notificationManager.areNotificationsEnabled() || Preferences.get().hideAllNotifications()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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_EXIT = "pref_panic_exit";
|
||||||
public static final String PREF_PANIC_HIDE = "pref_panic_hide";
|
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_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_NEVER = 0;
|
||||||
public static final int OVER_NETWORK_ON_DEMAND = 1;
|
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);
|
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.
|
* 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
|
* Providing it here means the shared preferences file only needs to be
|
||||||
|
@ -319,14 +319,14 @@ public class UpdateService extends JobIntentService {
|
|||||||
} else {
|
} else {
|
||||||
notificationBuilder.setProgress(100, 0, true);
|
notificationBuilder.setProgress(100, 0, true);
|
||||||
}
|
}
|
||||||
notificationManager.notify(NOTIFY_ID_UPDATING, notificationBuilder.build());
|
setNotification();
|
||||||
break;
|
break;
|
||||||
case STATUS_ERROR_GLOBAL:
|
case STATUS_ERROR_GLOBAL:
|
||||||
text = context.getString(R.string.global_error_updating_repos, message);
|
text = context.getString(R.string.global_error_updating_repos, message);
|
||||||
notificationBuilder.setContentText(text)
|
notificationBuilder.setContentText(text)
|
||||||
.setCategory(NotificationCompat.CATEGORY_ERROR)
|
.setCategory(NotificationCompat.CATEGORY_ERROR)
|
||||||
.setSmallIcon(android.R.drawable.ic_dialog_alert);
|
.setSmallIcon(android.R.drawable.ic_dialog_alert);
|
||||||
notificationManager.notify(NOTIFY_ID_UPDATING, notificationBuilder.build());
|
setNotification();
|
||||||
Toast.makeText(context, text, Toast.LENGTH_LONG).show();
|
Toast.makeText(context, text, Toast.LENGTH_LONG).show();
|
||||||
break;
|
break;
|
||||||
case STATUS_ERROR_LOCAL:
|
case STATUS_ERROR_LOCAL:
|
||||||
@ -344,7 +344,7 @@ public class UpdateService extends JobIntentService {
|
|||||||
notificationBuilder.setContentText(text)
|
notificationBuilder.setContentText(text)
|
||||||
.setCategory(NotificationCompat.CATEGORY_ERROR)
|
.setCategory(NotificationCompat.CATEGORY_ERROR)
|
||||||
.setSmallIcon(android.R.drawable.ic_dialog_info);
|
.setSmallIcon(android.R.drawable.ic_dialog_info);
|
||||||
notificationManager.notify(NOTIFY_ID_UPDATING, notificationBuilder.build());
|
setNotification();
|
||||||
Toast.makeText(context, text, Toast.LENGTH_LONG).show();
|
Toast.makeText(context, text, Toast.LENGTH_LONG).show();
|
||||||
break;
|
break;
|
||||||
case STATUS_COMPLETE_WITH_CHANGES:
|
case STATUS_COMPLETE_WITH_CHANGES:
|
||||||
@ -353,12 +353,18 @@ public class UpdateService extends JobIntentService {
|
|||||||
text = context.getString(R.string.repos_unchanged);
|
text = context.getString(R.string.repos_unchanged);
|
||||||
notificationBuilder.setContentText(text)
|
notificationBuilder.setContentText(text)
|
||||||
.setCategory(NotificationCompat.CATEGORY_SERVICE);
|
.setCategory(NotificationCompat.CATEGORY_SERVICE);
|
||||||
notificationManager.notify(NOTIFY_ID_UPDATING, notificationBuilder.build());
|
setNotification();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private void setNotification() {
|
||||||
|
if (Preferences.get().isUpdateNotificationEnabled()) {
|
||||||
|
notificationManager.notify(NOTIFY_ID_UPDATING, notificationBuilder.build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In order to send a {@link Toast} from a {@link IntentService}, we have to do these tricks.
|
* In order to send a {@link Toast} from a {@link IntentService}, we have to do these tricks.
|
||||||
*/
|
*/
|
||||||
@ -404,7 +410,7 @@ public class UpdateService extends JobIntentService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updating = true;
|
updating = true;
|
||||||
notificationManager.notify(NOTIFY_ID_UPDATING, notificationBuilder.build());
|
setNotification();
|
||||||
LocalBroadcastManager.getInstance(this).registerReceiver(updateStatusReceiver,
|
LocalBroadcastManager.getInstance(this).registerReceiver(updateStatusReceiver,
|
||||||
new IntentFilter(LOCAL_ACTION_STATUS));
|
new IntentFilter(LOCAL_ACTION_STATUS));
|
||||||
|
|
||||||
|
@ -37,7 +37,9 @@ import android.support.v7.preference.EditTextPreference;
|
|||||||
import android.support.v7.preference.ListPreference;
|
import android.support.v7.preference.ListPreference;
|
||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
import android.support.v7.preference.PreferenceCategory;
|
import android.support.v7.preference.PreferenceCategory;
|
||||||
|
import android.support.v7.preference.PreferenceGroup;
|
||||||
import android.support.v7.preference.SeekBarPreference;
|
import android.support.v7.preference.SeekBarPreference;
|
||||||
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import info.guardianproject.netcipher.NetCipher;
|
import info.guardianproject.netcipher.NetCipher;
|
||||||
@ -91,6 +93,7 @@ public class PreferencesFragment extends PreferenceFragment
|
|||||||
|
|
||||||
private static final int REQUEST_INSTALL_ORBOT = 0x1234;
|
private static final int REQUEST_INSTALL_ORBOT = 0x1234;
|
||||||
|
|
||||||
|
private PreferenceGroup otherPrefGroup;
|
||||||
private LiveSeekBarPreference overWifiSeekBar;
|
private LiveSeekBarPreference overWifiSeekBar;
|
||||||
private LiveSeekBarPreference overDataSeekBar;
|
private LiveSeekBarPreference overDataSeekBar;
|
||||||
private LiveSeekBarPreference updateIntervalSeekBar;
|
private LiveSeekBarPreference updateIntervalSeekBar;
|
||||||
@ -109,6 +112,8 @@ public class PreferencesFragment extends PreferenceFragment
|
|||||||
Preferences.get().migrateOldPreferences();
|
Preferences.get().migrateOldPreferences();
|
||||||
|
|
||||||
addPreferencesFromResource(R.xml.preferences);
|
addPreferencesFromResource(R.xml.preferences);
|
||||||
|
otherPrefGroup = (PreferenceGroup) findPreference("pref_category_other");
|
||||||
|
|
||||||
useTorCheckPref = (SwitchPreference) findPreference(Preferences.PREF_USE_TOR);
|
useTorCheckPref = (SwitchPreference) findPreference(Preferences.PREF_USE_TOR);
|
||||||
enableProxyCheckPref = (SwitchPreference) findPreference(Preferences.PREF_ENABLE_PROXY);
|
enableProxyCheckPref = (SwitchPreference) findPreference(Preferences.PREF_ENABLE_PROXY);
|
||||||
updateAutoDownloadPref = findPreference(Preferences.PREF_AUTO_DOWNLOAD_INSTALL_UPDATES);
|
updateAutoDownloadPref = findPreference(Preferences.PREF_AUTO_DOWNLOAD_INSTALL_UPDATES);
|
||||||
@ -284,6 +289,15 @@ public class PreferencesFragment extends PreferenceFragment
|
|||||||
|
|
||||||
case Preferences.PREF_EXPERT:
|
case Preferences.PREF_EXPERT:
|
||||||
checkSummary(key, R.string.expert_on);
|
checkSummary(key, R.string.expert_on);
|
||||||
|
boolean isExpertMode = Preferences.get().expertMode();
|
||||||
|
for (int i = 0; i < otherPrefGroup.getPreferenceCount(); i++) {
|
||||||
|
Preference pref = otherPrefGroup.getPreference(i);
|
||||||
|
if (TextUtils.equals(Preferences.PREF_EXPERT, pref.getDependency())) {
|
||||||
|
pref.setVisible(isExpertMode);
|
||||||
|
}
|
||||||
|
RecyclerView recyclerView = getListView();
|
||||||
|
recyclerView.smoothScrollToPosition(recyclerView.getAdapter().getItemCount() - 1);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Preferences.PREF_PRIVILEGED_INSTALLER:
|
case Preferences.PREF_PRIVILEGED_INSTALLER:
|
||||||
@ -355,9 +369,8 @@ public class PreferencesFragment extends PreferenceFragment
|
|||||||
// is no benefit showing it to them (it will only be disabled and we can't offer any
|
// is no benefit showing it to them (it will only be disabled and we can't offer any
|
||||||
// way to easily install from here.
|
// way to easily install from here.
|
||||||
if (Build.VERSION.SDK_INT > 19 && !installed) {
|
if (Build.VERSION.SDK_INT > 19 && !installed) {
|
||||||
PreferenceCategory other = (PreferenceCategory) findPreference("pref_category_other");
|
|
||||||
if (pref != null) {
|
if (pref != null) {
|
||||||
other.removePreference(pref);
|
otherPrefGroup.removePreference(pref);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
pref.setEnabled(installed);
|
pref.setEnabled(installed);
|
||||||
@ -383,8 +396,7 @@ public class PreferencesFragment extends PreferenceFragment
|
|||||||
private void initUpdatePrivilegedExtensionPreference() {
|
private void initUpdatePrivilegedExtensionPreference() {
|
||||||
if (Build.VERSION.SDK_INT > 19) {
|
if (Build.VERSION.SDK_INT > 19) {
|
||||||
// this will never work on newer Android versions, so hide it
|
// this will never work on newer Android versions, so hide it
|
||||||
PreferenceCategory other = (PreferenceCategory) findPreference("pref_category_other");
|
otherPrefGroup.removePreference(updatePrivilegedExtensionPref);
|
||||||
other.removePreference(updatePrivilegedExtensionPref);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
updatePrivilegedExtensionPref.setPersistent(false);
|
updatePrivilegedExtensionPref.setPersistent(false);
|
||||||
|
@ -16,6 +16,10 @@
|
|||||||
<string name="updates">Updates</string>
|
<string name="updates">Updates</string>
|
||||||
<string name="unstable_updates">Unstable updates</string>
|
<string name="unstable_updates">Unstable updates</string>
|
||||||
<string name="unstable_updates_summary">Suggest updates to unstable versions</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">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="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>
|
<string name="force_old_index">Force old index format</string>
|
||||||
|
@ -165,6 +165,12 @@
|
|||||||
android:summary="@string/keep_install_history_summary"
|
android:summary="@string/keep_install_history_summary"
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:dependency="expert"/>
|
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
|
<CheckBoxPreference
|
||||||
android:key="forceOldIndex"
|
android:key="forceOldIndex"
|
||||||
android:title="@string/force_old_index"
|
android:title="@string/force_old_index"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user