Add 'Bundle notifications' preference

pull/574/head
Alex Baker 7 years ago
parent 15f4dcfd18
commit 2314c28458

@ -36,6 +36,7 @@ import org.tasks.ui.TimePreference;
import javax.inject.Inject;
import static com.todoroo.andlib.utility.AndroidUtilities.atLeastMarshmallow;
import static com.todoroo.andlib.utility.AndroidUtilities.atLeastNougat;
import static com.todoroo.andlib.utility.AndroidUtilities.atLeastOreo;
import static com.todoroo.andlib.utility.AndroidUtilities.preOreo;
import static org.tasks.PermissionUtil.verifyPermissions;
@ -65,7 +66,8 @@ public class ReminderPreferences extends InjectingPreferenceActivity {
R.string.p_rmd_enable_quiet,
R.string.p_rmd_quietStart,
R.string.p_rmd_quietEnd,
R.string.p_rmd_persistent);
R.string.p_rmd_persistent,
R.string.p_bundle_notifications);
resetGeofencesOnChange(
R.string.p_geofence_radius,
R.string.p_geofence_responsiveness);
@ -86,6 +88,7 @@ public class ReminderPreferences extends InjectingPreferenceActivity {
requires(atLeastOreo(), R.string.notification_channel_settings);
requires(atLeastMarshmallow(), R.string.battery_optimization_settings);
requires(preOreo(), R.string.p_rmd_ringtone, R.string.p_rmd_vibrate, R.string.p_led_notification);
requires(atLeastNougat(), R.string.p_bundle_notifications);
}
@TargetApi(Build.VERSION_CODES.O)

@ -44,7 +44,6 @@ import static android.content.Intent.FLAG_ACTIVITY_MULTIPLE_TASK;
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
import static com.google.common.collect.Lists.transform;
import static com.todoroo.andlib.utility.AndroidUtilities.atLeastJellybean;
import static com.todoroo.andlib.utility.AndroidUtilities.atLeastNougat;
import static org.tasks.notifications.NotificationManager.GROUP_KEY;
import static org.tasks.time.DateTimeUtils.currentTimeMillis;
@ -241,7 +240,7 @@ public class Notifier {
}
NotificationCompat.Builder notification = getTaskNotification(entry);
if (notification != null) {
notification.setGroupAlertBehavior(alert && (atLeastNougat() ? entries.size() == 1 : i == entries.size() - 1)
notification.setGroupAlertBehavior(alert && (preferences.bundleNotifications() ? entries.size() == 1 : i == entries.size() - 1)
? NotificationCompat.GROUP_ALERT_CHILDREN
: NotificationCompat.GROUP_ALERT_SUMMARY);
notifications.put(entry, notification.build());

@ -31,7 +31,6 @@ import io.reactivex.schedulers.Schedulers;
import static com.google.common.collect.Iterables.transform;
import static com.google.common.collect.Lists.newArrayList;
import static com.todoroo.andlib.utility.AndroidUtilities.atLeastNougat;
import static com.todoroo.andlib.utility.AndroidUtilities.atLeastOreo;
@ApplicationScope
@ -133,7 +132,7 @@ public class NotificationManager {
}
private void updateSummary(boolean notify, boolean nonStop, boolean fiveTimes) {
if (atLeastNougat()) {
if (preferences.bundleNotifications()) {
if (appDatabase.notificationDao().count() == 0) {
notificationManager.cancel(SUMMARY_NOTIFICATION_ID);
} else {
@ -158,6 +157,8 @@ public class NotificationManager {
notify(NotificationManager.SUMMARY_NOTIFICATION_ID, builder.build(), notify, nonStop, fiveTimes);
}
} else {
notificationManager.cancel(NotificationManager.SUMMARY_NOTIFICATION_ID);
}
}
}

@ -27,6 +27,7 @@ import javax.inject.Inject;
import timber.log.Timber;
import static android.content.SharedPreferences.Editor;
import static com.todoroo.andlib.utility.AndroidUtilities.atLeastNougat;
public class Preferences {
@ -411,4 +412,8 @@ public class Preferences {
editor.remove(context.getString(resId));
editor.apply();
}
public boolean bundleNotifications() {
return atLeastNougat() && getBoolean(R.string.p_bundle_notifications, true);
}
}

@ -280,5 +280,6 @@
<string name="p_start_of_week">start_of_week</string>
<string name="p_use_native_datetime_pickers">use_native_datetime_pickers</string>
<string name="gtask_background_sync">gtask_background_sync</string>
<string name="p_bundle_notifications">bundle_notifications</string>
</resources>

@ -787,4 +787,5 @@ File %1$s contained %2$s.\n\n
<string name="notification_channel_settings">Manage notifications</string>
<string name="battery_optimization_settings">Manage battery optimizations</string>
<string name="notification_disable_battery_optimizations_description">Battery optimizations may delay notifications</string>
<string name="bundle_notifications">Bundle notifications</string>
</resources>

@ -35,6 +35,11 @@
android:key="@string/p_rmd_persistent"
android:summary="@string/persistent_notifications_description"
android:title="@string/persistent_notifications" />
<CheckBoxPreference
android:defaultValue="true"
android:dependency="@string/p_rmd_enabled"
android:key="@string/p_bundle_notifications"
android:title="@string/bundle_notifications" />
<CheckBoxPreference
android:defaultValue="true"
android:dependency="@string/p_rmd_enabled"

Loading…
Cancel
Save