diff --git a/src/main/java/com/todoroo/andlib/utility/AndroidUtilities.java b/src/main/java/com/todoroo/andlib/utility/AndroidUtilities.java index dfeaf4e95..06432c7de 100644 --- a/src/main/java/com/todoroo/andlib/utility/AndroidUtilities.java +++ b/src/main/java/com/todoroo/andlib/utility/AndroidUtilities.java @@ -363,6 +363,10 @@ public class AndroidUtilities { return !atLeastHoneycomb(); } + public static boolean preJellybean() { + return !atLeastJellybean(); + } + public static boolean preLollipop() { return !atLeastLollipop(); } diff --git a/src/main/java/com/todoroo/astrid/reminders/Notifications.java b/src/main/java/com/todoroo/astrid/reminders/Notifications.java index a2fc6dfaa..2ea8aa7f1 100644 --- a/src/main/java/com/todoroo/astrid/reminders/Notifications.java +++ b/src/main/java/com/todoroo/astrid/reminders/Notifications.java @@ -27,6 +27,7 @@ import org.tasks.R; import org.tasks.injection.ForApplication; import org.tasks.injection.InjectingBroadcastReceiver; import org.tasks.notifications.NotificationManager; +import org.tasks.preferences.Preferences; import javax.inject.Inject; @@ -59,6 +60,7 @@ public class Notifications extends InjectingBroadcastReceiver { @Inject @ForApplication Context context; @Inject NotificationManager notificationManager; @Inject Broadcaster broadcaster; + @Inject Preferences preferences; @Override public void onReceive(Context context, Intent intent) { @@ -128,7 +130,7 @@ public class Notifications extends InjectingBroadcastReceiver { String text = context.getString(R.string.app_name); - Intent intent = atLeastJellybean() + Intent intent = preferences.useNotificationActions() ? createEditIntent(id, task) : createNotificationIntent(id, taskTitle); diff --git a/src/main/java/com/todoroo/astrid/reminders/ReminderPreferences.java b/src/main/java/com/todoroo/astrid/reminders/ReminderPreferences.java index 86921fa20..5328c7653 100644 --- a/src/main/java/com/todoroo/astrid/reminders/ReminderPreferences.java +++ b/src/main/java/com/todoroo/astrid/reminders/ReminderPreferences.java @@ -19,6 +19,8 @@ import org.tasks.ui.TimePreference; import java.text.DateFormat; +import static com.todoroo.andlib.utility.AndroidUtilities.preJellybean; + public class ReminderPreferences extends InjectingPreferenceActivity { @Override @@ -27,6 +29,10 @@ public class ReminderPreferences extends InjectingPreferenceActivity { addPreferencesFromResource(R.xml.preferences_reminders); + if (preJellybean()) { + getPreferenceScreen().removePreference(findPreference(getString(R.string.p_rmd_notif_actions_enabled))); + } + initializeRingtonePreference(); initializeTimePreference(R.string.p_rmd_time, R.string.rmd_EPr_rmd_time_desc); initializeTimePreference(R.string.p_rmd_quietStart, null); diff --git a/src/main/java/com/todoroo/astrid/reminders/ShowNotificationReceiver.java b/src/main/java/com/todoroo/astrid/reminders/ShowNotificationReceiver.java index b05b5167e..aaddb0fef 100644 --- a/src/main/java/com/todoroo/astrid/reminders/ShowNotificationReceiver.java +++ b/src/main/java/com/todoroo/astrid/reminders/ShowNotificationReceiver.java @@ -31,7 +31,6 @@ import java.util.concurrent.Executors; import javax.inject.Inject; -import static com.todoroo.andlib.utility.AndroidUtilities.atLeastJellybean; import static org.tasks.date.DateTimeUtils.currentTimeMillis; /** @@ -124,7 +123,7 @@ public class ShowNotificationReceiver extends InjectingBroadcastReceiver { .setContentTitle(title) .setContentText(text) .setContentIntent(pendingIntent); - if (atLeastJellybean()) { + if (preferences.useNotificationActions()) { final long taskId = intent.getLongExtra(TaskListActivity.OPEN_TASK, 0L); PendingIntent completeIntent = PendingIntent.getBroadcast(context, notificationId, new Intent(context, CompleteTaskReceiver.class) {{ putExtra(CompleteTaskReceiver.TASK_ID, taskId); diff --git a/src/main/java/org/tasks/preferences/Preferences.java b/src/main/java/org/tasks/preferences/Preferences.java index 1be6a4186..d7b7b1760 100644 --- a/src/main/java/org/tasks/preferences/Preferences.java +++ b/src/main/java/org/tasks/preferences/Preferences.java @@ -28,6 +28,7 @@ import ch.qos.logback.core.rolling.RollingFileAppender; import ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy; import static android.content.SharedPreferences.Editor; +import static com.todoroo.andlib.utility.AndroidUtilities.atLeastJellybean; import static com.todoroo.andlib.utility.AndroidUtilities.preLollipop; public class Preferences { @@ -278,4 +279,8 @@ public class Preferences { rfa.start(); rootLogger.addAppender(rfa); } + + public boolean useNotificationActions() { + return atLeastJellybean() && getBoolean(R.string.p_rmd_notif_actions_enabled, true); + } } diff --git a/src/main/res/values/keys.xml b/src/main/res/values/keys.xml index 64fef5c29..ac8b4b80f 100644 --- a/src/main/res/values/keys.xml +++ b/src/main/res/values/keys.xml @@ -245,6 +245,7 @@ TEA_ctrl_share_pref TEA_ctrl_gcal sync_gtasks + p_rmd_notif_actions_enabled @string/TEA_ctrl_when_pref diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index c9e975915..b387f776d 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -91,6 +91,8 @@ Donate Error Select amount + Notification Actions + Show snooze and complete actions in notification diff --git a/src/main/res/xml/preferences_reminders.xml b/src/main/res/xml/preferences_reminders.xml index 3fcbdcb29..04324bba3 100644 --- a/src/main/res/xml/preferences_reminders.xml +++ b/src/main/res/xml/preferences_reminders.xml @@ -9,7 +9,13 @@ + android:title="@string/enabled" /> + + android:title="@string/rmd_EPr_persistent_title" />