fix #745, properly handle toggling reminder vibrations

This commit is contained in:
tibbi 2019-01-07 14:37:49 +01:00
parent a659d8d3e3
commit 98c1151680
3 changed files with 9 additions and 2 deletions

View File

@ -211,7 +211,7 @@ fun Context.getNotification(pendingIntent: PendingIntent, event: Event, content:
}
// create a new channel for every new sound uri as the new Android Oreo notification system is fundamentally broken
if (soundUri != config.lastSoundUri) {
if (soundUri != config.lastSoundUri || config.lastVibrateOnReminder != config.vibrateOnReminder) {
config.lastReminderChannel = System.currentTimeMillis()
config.lastSoundUri = soundUri
}
@ -231,7 +231,7 @@ fun Context.getNotification(pendingIntent: PendingIntent, event: Event, content:
setBypassDnd(true)
enableLights(true)
lightColor = event.color
enableVibration(false)
enableVibration(config.vibrateOnReminder)
setSound(Uri.parse(soundUri), audioAttributes)
notificationManager.createNotificationChannel(this)
}
@ -266,6 +266,7 @@ fun Context.getNotification(pendingIntent: PendingIntent, event: Event, content:
if (config.loopReminders) {
notification.flags = notification.flags or Notification.FLAG_INSISTENT
}
config.lastVibrateOnReminder = config.vibrateOnReminder
return notification
}

View File

@ -3,6 +3,7 @@ package com.simplemobiletools.calendar.pro.helpers
import android.content.Context
import android.media.AudioManager
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.extensions.config
import com.simplemobiletools.calendar.pro.extensions.scheduleCalDAVSync
import com.simplemobiletools.commons.extensions.getDefaultAlarmTitle
import com.simplemobiletools.commons.extensions.getDefaultAlarmUri
@ -168,4 +169,8 @@ class Config(context: Context) : BaseConfig(context) {
var pullToRefresh: Boolean
get() = prefs.getBoolean(PULL_TO_REFRESH, false)
set(pullToRefresh) = prefs.edit().putBoolean(PULL_TO_REFRESH, pullToRefresh).apply()
var lastVibrateOnReminder: Boolean
get() = prefs.getBoolean(LAST_VIBRATE_ON_REMINDER, context.config.vibrateOnReminder)
set(lastVibrateOnReminder) = prefs.edit().putBoolean(LAST_VIBRATE_ON_REMINDER, lastVibrateOnReminder).apply()
}

View File

@ -67,6 +67,7 @@ const val DEFAULT_REMINDER_1 = "default_reminder_1"
const val DEFAULT_REMINDER_2 = "default_reminder_2"
const val DEFAULT_REMINDER_3 = "default_reminder_3"
const val PULL_TO_REFRESH = "pull_to_refresh"
const val LAST_VIBRATE_ON_REMINDER = "last_vibrate_on_reminder"
// repeat_rule for monthly and yearly repetition
const val REPEAT_SAME_DAY = 1 // i.e. 25th every month, or 3rd june (if yearly repetition)