Add option to disable notification actions

pull/253/merge
Alex Baker 11 years ago
parent 185ed10ccf
commit 5b4fda9cb6

@ -363,6 +363,10 @@ public class AndroidUtilities {
return !atLeastHoneycomb();
}
public static boolean preJellybean() {
return !atLeastJellybean();
}
public static boolean preLollipop() {
return !atLeastLollipop();
}

@ -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);

@ -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);

@ -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);

@ -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);
}
}

@ -245,6 +245,7 @@
<string name="TEA_ctrl_share_pref">TEA_ctrl_share_pref</string>
<string name="TEA_ctrl_gcal">TEA_ctrl_gcal</string>
<string name="sync_gtasks">sync_gtasks</string>
<string name="p_rmd_notif_actions_enabled">p_rmd_notif_actions_enabled</string>
<string-array name="TEA_control_sets_prefs">
<item>@string/TEA_ctrl_when_pref</item>

@ -91,6 +91,8 @@
<string name="TLA_menu_donate">Donate</string>
<string name="error">Error</string>
<string name="select_amount">Select amount</string>
<string name="notification_actions">Notification Actions</string>
<string name="notification_actions_summary">Show snooze and complete actions in notification</string>
<string-array name="sync_SPr_interval_entries">
<!-- sync_SPr_interval_entries: Synchronization Intervals -->

@ -9,7 +9,13 @@
<CheckBoxPreference
android:defaultValue="true"
android:key="@string/p_rmd_enabled"
android:title="@string/notifications" />
android:title="@string/enabled" />
<CheckBoxPreference
android:defaultValue="true"
android:dependency="@string/p_rmd_enabled"
android:key="@string/p_rmd_notif_actions_enabled"
android:summary="@string/notification_actions_summary"
android:title="@string/notification_actions" />
<RingtonePreference
android:dependency="@string/p_rmd_enabled"
android:key="@string/p_rmd_ringtone"
@ -23,12 +29,12 @@
android:key="@string/p_rmd_vibrate"
android:title="@string/vibrate" />
<com.todoroo.astrid.ui.MultilineCheckboxPreference
android:defaultValue="true"
android:dependency="@string/p_rmd_enabled"
android:key="@string/p_rmd_persistent"
android:summaryOff="@string/rmd_EPr_persistent_desc_false"
android:summaryOn="@string/rmd_EPr_persistent_desc_true"
android:title="@string/rmd_EPr_persistent_title"
android:defaultValue="true"/>
android:title="@string/rmd_EPr_persistent_title" />
<org.tasks.ui.TimePreference
android:defaultValue="@integer/default_remind_time"
android:dependency="@string/p_rmd_enabled"

Loading…
Cancel
Save