diff --git a/app/build.gradle b/app/build.gradle index 60789fd5..18f8c4f4 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -41,7 +41,7 @@ android { } dependencies { - implementation 'com.simplemobiletools:commons:3.18.17' + implementation 'com.simplemobiletools:commons:3.18.18' implementation 'com.facebook.stetho:stetho:1.5.0' implementation 'com.android.support.constraint:constraint-layout:1.0.2' implementation 'com.shawnlin:number-picker:2.4.6' diff --git a/app/src/main/kotlin/com/simplemobiletools/clock/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/clock/extensions/Context.kt index 2577f621..bc83cec5 100644 --- a/app/src/main/kotlin/com/simplemobiletools/clock/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/clock/extensions/Context.kt @@ -28,10 +28,7 @@ import com.simplemobiletools.clock.receivers.HideAlarmReceiver import com.simplemobiletools.clock.receivers.HideTimerReceiver import com.simplemobiletools.clock.services.SnoozeService import com.simplemobiletools.commons.extensions.* -import com.simplemobiletools.commons.helpers.ALARM_SOUND_TYPE_ALARM -import com.simplemobiletools.commons.helpers.isKitkatPlus -import com.simplemobiletools.commons.helpers.isLollipopPlus -import com.simplemobiletools.commons.helpers.isOreoPlus +import com.simplemobiletools.commons.helpers.* import java.util.* import kotlin.math.pow @@ -235,7 +232,13 @@ fun Context.getTimerNotification(pendingIntent: PendingIntent, addDeleteIntent: } } - grantReadUriPermission(config.timerSoundUri) + var uri = config.timerSoundUri + if (uri == SILENT) { + uri = "" + } else { + grantReadUriPermission(uri) + } + val reminderActivityIntent = getReminderActivityIntent() val builder = NotificationCompat.Builder(this) .setContentTitle(getString(R.string.timer)) @@ -245,7 +248,7 @@ fun Context.getTimerNotification(pendingIntent: PendingIntent, addDeleteIntent: .setPriority(Notification.PRIORITY_HIGH) .setDefaults(Notification.DEFAULT_LIGHTS) .setAutoCancel(true) - .setSound(Uri.parse(config.timerSoundUri), AudioManager.STREAM_SYSTEM) + .setSound(Uri.parse(uri), AudioManager.STREAM_SYSTEM) .setChannelId(channelId) .addAction(R.drawable.ic_cross, getString(R.string.dismiss), if (addDeleteIntent) reminderActivityIntent else getHideTimerPendingIntent()) @@ -294,7 +297,13 @@ fun Context.getAlarmNotification(pendingIntent: PendingIntent, alarm: Alarm, add } } - grantReadUriPermission(alarm.soundUri) + var uri = alarm.soundUri + if (uri == SILENT) { + uri = "" + } else { + grantReadUriPermission(uri) + } + val reminderActivityIntent = getReminderActivityIntent() val builder = NotificationCompat.Builder(this) .setContentTitle(label) @@ -304,7 +313,7 @@ fun Context.getAlarmNotification(pendingIntent: PendingIntent, alarm: Alarm, add .setPriority(Notification.PRIORITY_HIGH) .setDefaults(Notification.DEFAULT_LIGHTS) .setAutoCancel(true) - .setSound(Uri.parse(alarm.soundUri), AudioManager.STREAM_ALARM) + .setSound(Uri.parse(uri), AudioManager.STREAM_ALARM) .setChannelId(channelId) .addAction(R.drawable.ic_cross, getString(R.string.dismiss), if (addDeleteIntent) reminderActivityIntent else getHideAlarmPendingIntent(alarm)) .addAction(R.drawable.ic_snooze, getString(R.string.snooze), getSnoozePendingIntent(alarm, addDeleteIntent)) diff --git a/app/src/main/kotlin/com/simplemobiletools/clock/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/clock/helpers/Constants.kt index 13f9205a..31b4bf51 100644 --- a/app/src/main/kotlin/com/simplemobiletools/clock/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/clock/helpers/Constants.kt @@ -19,7 +19,6 @@ const val TABS_COUNT = 4 const val EDITED_TIME_ZONE_SEPARATOR = ":" const val ALARM_ID = "alarm_id" const val DEFAULT_ALARM_MINUTES = 480 -const val DAY_MINUTES = 1440 const val DEFAULT_MAX_ALARM_REMINDER_SECS = 300 const val DEFAULT_MAX_TIMER_REMINDER_SECS = 60 const val HIDE_REMINDER_ACTIVITY = "hide_reminder_activity"