mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-01-14 01:34:59 +01:00
avoid exposing file uri at notifications
This commit is contained in:
parent
40e2bcc00a
commit
8e838a295c
@ -248,6 +248,7 @@ class SettingsActivity : SimpleActivity() {
|
||||
} else {
|
||||
settings_reminder_sound.text = RingtoneManager.getRingtone(this, Uri.parse(config.reminderSound))?.getTitle(this) ?: noRingtone
|
||||
}
|
||||
|
||||
settings_reminder_sound_holder.setOnClickListener {
|
||||
Intent(RingtoneManager.ACTION_RINGTONE_PICKER).apply {
|
||||
putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION)
|
||||
|
@ -19,6 +19,7 @@ import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import com.simplemobiletools.calendar.BuildConfig
|
||||
import com.simplemobiletools.calendar.R
|
||||
import com.simplemobiletools.calendar.activities.EventActivity
|
||||
import com.simplemobiletools.calendar.activities.SimpleActivity
|
||||
@ -31,6 +32,7 @@ import com.simplemobiletools.calendar.services.SnoozeService
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import org.joda.time.DateTime
|
||||
import org.joda.time.DateTimeZone
|
||||
import java.io.File
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
||||
@ -95,8 +97,9 @@ fun Context.scheduleNextEventReminder(event: Event?, dbHelper: DBHelper) {
|
||||
}
|
||||
|
||||
fun Context.scheduleEventIn(notifTS: Long, event: Event) {
|
||||
if (notifTS < System.currentTimeMillis())
|
||||
if (notifTS < System.currentTimeMillis()) {
|
||||
return
|
||||
}
|
||||
|
||||
val pendingIntent = getNotificationIntent(applicationContext, event)
|
||||
val alarmManager = getSystemService(Context.ALARM_SERVICE) as AlarmManager
|
||||
@ -194,7 +197,11 @@ private fun getNotification(context: Context, pendingIntent: PendingIntent, even
|
||||
}
|
||||
}
|
||||
|
||||
val soundUri = Uri.parse(context.config.reminderSound)
|
||||
var soundUri = Uri.parse(context.config.reminderSound)
|
||||
if (soundUri.scheme == "file") {
|
||||
soundUri = context.getFilePublicUri(File(soundUri.path), BuildConfig.APPLICATION_ID)
|
||||
}
|
||||
|
||||
val builder = NotificationCompat.Builder(context)
|
||||
.setContentTitle(event.title)
|
||||
.setContentText(content)
|
||||
|
@ -19,12 +19,14 @@ class NotificationReceiver : BroadcastReceiver() {
|
||||
|
||||
context.updateListWidget()
|
||||
val id = intent.getIntExtra(EVENT_ID, -1)
|
||||
if (id == -1)
|
||||
if (id == -1) {
|
||||
return
|
||||
}
|
||||
|
||||
val event = context.dbHelper.getEventWithId(id)
|
||||
if (event == null || event.getReminders().isEmpty())
|
||||
if (event == null || event.getReminders().isEmpty()) {
|
||||
return
|
||||
}
|
||||
|
||||
if (!event.ignoreEventOccurrences.contains(Formatter.getDayCodeFromTS(event.startTS).toInt())) {
|
||||
context.notifyEvent(event)
|
||||
|
Loading…
Reference in New Issue
Block a user