update Commons, allow selecting No Sound at notifications

This commit is contained in:
tibbi 2018-04-11 12:14:29 +02:00
parent 820f4ac256
commit fe16f35c66
3 changed files with 18 additions and 10 deletions

View File

@ -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'

View File

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

View File

@ -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"