Disable custom snoozing for recent Android

sdk_30_31
Quentin Hibon 4 years ago
parent edaed20a98
commit f1ad28820f

@ -19,6 +19,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.isoron.uhabits">
<uses-permission android:name="android.permission.BROADCAST_CLOSE_SYSTEM_DIALOGS" />
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

@ -153,13 +153,15 @@ class AndroidNotificationTray
if (preferences.shouldMakeNotificationsLed())
builder.setLights(Color.RED, 1000, 1000)
val snoozeAction = Action(
R.drawable.ic_action_snooze,
context.getString(R.string.snooze),
pendingIntents.snoozeNotification(habit)
)
wearableExtender.addAction(snoozeAction)
builder.addAction(snoozeAction)
if (SDK_INT < Build.VERSION_CODES.S) {
val snoozeAction = Action(
R.drawable.ic_action_snooze,
context.getString(R.string.snooze),
pendingIntents.snoozeNotification(habit)
)
wearableExtender.addAction(snoozeAction)
builder.addAction(snoozeAction)
}
builder.extend(wearableExtender)
return builder.build()

@ -22,6 +22,8 @@ import android.content.BroadcastReceiver
import android.content.ContentUris
import android.content.Context
import android.content.Intent
import android.os.Build
import android.os.Build.VERSION.SDK_INT
import android.util.Log
import org.isoron.uhabits.HabitsApplication
import org.isoron.uhabits.core.models.Habit
@ -76,8 +78,21 @@ class ReminderReceiver : BroadcastReceiver() {
}
ACTION_SNOOZE_REMINDER -> {
if (habit == null) return
Log.d("ReminderReceiver", String.format("onSnoozePressed habit=%d", habit.id))
reminderController.onSnoozePressed(habit, context)
if (SDK_INT < Build.VERSION_CODES.S) {
Log.d(
"ReminderReceiver",
String.format("onSnoozePressed habit=%d", habit.id)
)
reminderController.onSnoozePressed(habit, context)
} else {
Log.w(
"ReminderReceiver",
String.format(
"onSnoozePressed habit=%d, should be deactivated in recent versions.",
habit.id
)
)
}
}
Intent.ACTION_BOOT_COMPLETED -> {
Log.d("ReminderReceiver", "onBootCompleted")

Loading…
Cancel
Save