Merge pull request #12 from SimpleMobileTools/master

upd
This commit is contained in:
solokot 2018-07-07 09:41:44 +03:00 committed by GitHub
commit 046e2a946e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
34 changed files with 90 additions and 48 deletions

View File

@ -1,6 +1,13 @@
Changelog
==========
Version 4.1.1 *(2018-07-04)*
----------------------------
* Allow customizing the audio stream used by reminders
* Show the time remaining till the reminder appears
* Couple other UX and stability improvements
Version 4.1.0 *(2018-06-13)*
----------------------------

View File

@ -10,8 +10,8 @@ android {
applicationId "com.simplemobiletools.calendar"
minSdkVersion 16
targetSdkVersion 27
versionCode 124
versionName "4.1.0"
versionCode 125
versionName "4.1.1"
multiDexEnabled true
setProperty("archivesBaseName", "calendar")
}
@ -46,7 +46,7 @@ ext {
}
dependencies {
implementation 'com.simplemobiletools:commons:4.3.27'
implementation 'com.simplemobiletools:commons:4.3.28'
implementation 'joda-time:joda-time:2.9.9'
implementation 'com.facebook.stetho:stetho:1.5.0'
implementation 'com.android.support:multidex:1.0.3'

View File

@ -673,13 +673,11 @@ class EventActivity : SimpleActivity() {
private fun storeEvent(wasRepeatable: Boolean) {
if (mEvent.id == 0) {
dbHelper.insert(mEvent, true) {
dbHelper.insert(mEvent, true, this) {
if (DateTime.now().isAfter(mEventStartDateTime.millis)) {
if (mEvent.repeatInterval == 0 && mEvent.getReminders().isNotEmpty()) {
notifyEvent(mEvent)
}
} else {
toast(R.string.event_added)
}
finish()
@ -688,8 +686,8 @@ class EventActivity : SimpleActivity() {
if (mRepeatInterval > 0 && wasRepeatable) {
EditRepeatingEventDialog(this) {
if (it) {
dbHelper.update(mEvent, true) {
eventUpdated()
dbHelper.update(mEvent, true, this) {
finish()
}
} else {
dbHelper.addEventRepeatException(mEvent.id, mEventOccurrenceTS, true)
@ -701,25 +699,19 @@ class EventActivity : SimpleActivity() {
repeatLimit = 0
}
dbHelper.insert(mEvent, true) {
toast(R.string.event_updated)
dbHelper.insert(mEvent, true, this) {
finish()
}
}
}
} else {
dbHelper.update(mEvent, true) {
eventUpdated()
dbHelper.update(mEvent, true, this) {
finish()
}
}
}
}
private fun eventUpdated() {
toast(R.string.event_updated)
finish()
}
private fun updateStartTexts() {
updateStartDateText()
updateStartTimeText()

View File

@ -322,7 +322,8 @@ class SettingsActivity : SimpleActivity() {
val items = arrayListOf(
RadioItem(AudioManager.STREAM_ALARM, res.getString(R.string.alarm_stream)),
RadioItem(AudioManager.STREAM_SYSTEM, res.getString(R.string.system_stream)),
RadioItem(AudioManager.STREAM_NOTIFICATION, res.getString(R.string.notification_stream)))
RadioItem(AudioManager.STREAM_NOTIFICATION, res.getString(R.string.notification_stream)),
RadioItem(AudioManager.STREAM_RING, res.getString(R.string.ring_stream)))
RadioGroupDialog(this@SettingsActivity, items, config.reminderAudioStream) {
config.reminderAudioStream = it as Int
@ -334,7 +335,8 @@ class SettingsActivity : SimpleActivity() {
private fun getAudioStreamText() = getString(when (config.reminderAudioStream) {
AudioManager.STREAM_ALARM -> R.string.alarm_stream
AudioManager.STREAM_SYSTEM -> R.string.system_stream
else -> R.string.notification_stream
AudioManager.STREAM_NOTIFICATION -> R.string.notification_stream
else -> R.string.ring_stream
})
private fun setupVibrate() {

View File

@ -77,8 +77,9 @@ fun Context.scheduleAllEvents() {
}
}
fun Context.scheduleNextEventReminder(event: Event?, dbHelper: DBHelper) {
if (event == null || event.getReminders().isEmpty()) {
fun Context.scheduleNextEventReminder(event: Event, dbHelper: DBHelper, activity: SimpleActivity? = null) {
if (event.getReminders().isEmpty()) {
activity?.toast(R.string.saving)
return
}
@ -89,20 +90,29 @@ fun Context.scheduleNextEventReminder(event: Event?, dbHelper: DBHelper) {
for (curEvent in it) {
for (curReminder in reminderSeconds) {
if (curEvent.getEventStartTS() - curReminder > now) {
scheduleEventIn((curEvent.getEventStartTS() - curReminder) * 1000L, curEvent)
scheduleEventIn((curEvent.getEventStartTS() - curReminder) * 1000L, curEvent, activity)
return@getEvents
}
}
}
}
activity?.toast(R.string.saving)
}
}
fun Context.scheduleEventIn(notifTS: Long, event: Event) {
fun Context.scheduleEventIn(notifTS: Long, event: Event, activity: SimpleActivity? = null) {
if (notifTS < System.currentTimeMillis()) {
activity?.toast(R.string.saving)
return
}
if (activity != null) {
val secondsTillNotification = (notifTS - System.currentTimeMillis()) / 1000
val msg = String.format(getString(R.string.reminder_triggers_in), formatSecondsToTimeString(secondsTillNotification.toInt()))
activity.toast(msg)
}
val pendingIntent = getNotificationIntent(applicationContext, event)
val alarmManager = getSystemService(Context.ALARM_SERVICE) as AlarmManager
AlarmManagerCompat.setExactAndAllowWhileIdle(alarmManager, AlarmManager.RTC_WAKEUP, notifTS, pendingIntent)

View File

@ -10,6 +10,7 @@ import android.database.sqlite.SQLiteQueryBuilder
import android.text.TextUtils
import android.util.SparseIntArray
import com.simplemobiletools.calendar.R
import com.simplemobiletools.calendar.activities.SimpleActivity
import com.simplemobiletools.calendar.extensions.*
import com.simplemobiletools.calendar.models.Event
import com.simplemobiletools.calendar.models.EventType
@ -200,7 +201,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
addEventType(eventType, db)
}
fun insert(event: Event, addToCalDAV: Boolean, callback: (id: Int) -> Unit) {
fun insert(event: Event, addToCalDAV: Boolean, activity: SimpleActivity? = null, callback: (id: Int) -> Unit) {
if (event.startTS > event.endTS) {
callback(0)
return
@ -216,7 +217,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
}
context.updateWidgets()
context.scheduleNextEventReminder(event, this)
context.scheduleNextEventReminder(event, this, activity)
if (addToCalDAV && event.source != SOURCE_SIMPLE_CALENDAR && context.config.caldavSync) {
CalDAVHandler(context).insertCalDAVEvent(event)
@ -254,7 +255,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
}
}
fun update(event: Event, updateAtCalDAV: Boolean, callback: (() -> Unit)? = null) {
fun update(event: Event, updateAtCalDAV: Boolean, activity: SimpleActivity? = null, callback: (() -> Unit)? = null) {
val values = fillEventValues(event)
val selection = "$COL_ID = ?"
val selectionArgs = arrayOf(event.id.toString())
@ -269,7 +270,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
}
context.updateWidgets()
context.scheduleNextEventReminder(event, this)
context.scheduleNextEventReminder(event, this, activity)
if (updateAtCalDAV && event.source != SOURCE_SIMPLE_CALENDAR && context.config.caldavSync) {
CalDAVHandler(context).updateCalDAVEvent(event)
}
@ -548,7 +549,9 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
mDb.insert(EXCEPTIONS_TABLE_NAME, null, it)
val parentEvent = getEventWithId(parentEventId)
context.scheduleNextEventReminder(parentEvent, this)
if (parentEvent != null) {
context.scheduleNextEventReminder(parentEvent, this)
}
}
}

View File

@ -163,6 +163,7 @@
<string name="system_stream">System</string>
<string name="alarm_stream">Alarm</string>
<string name="notification_stream">Notification</string>
<string name="ring_stream">Ring</string>
<!-- CalDAV sync -->
<string name="caldav">CalDAV</string>

View File

@ -163,6 +163,7 @@
<string name="system_stream">System</string>
<string name="alarm_stream">Alarm</string>
<string name="notification_stream">Notification</string>
<string name="ring_stream">Ring</string>
<!-- CalDAV sync -->
<string name="caldav">CalDAV</string>

View File

@ -163,6 +163,7 @@
<string name="system_stream">System</string>
<string name="alarm_stream">Alarm</string>
<string name="notification_stream">Notification</string>
<string name="ring_stream">Ring</string>
<!-- CalDAV sync -->
<string name="caldav">CalDAV</string>

View File

@ -159,10 +159,11 @@
<string name="loop_reminders">Fortsæt påmindelser indtil jeg stopper dem</string>
<string name="dim_past_events">Nedton gamle begivenheder</string>
<string name="events">Begivenheder</string>
<string name="reminder_stream">Audio stream used by reminders</string>
<string name="reminder_stream">Audio stream anvendt af påmindelser</string>
<string name="system_stream">System</string>
<string name="alarm_stream">Alarm</string>
<string name="notification_stream">Notification</string>
<string name="notification_stream">Notifikation</string>
<string name="ring_stream">Ring</string>
<!-- CalDAV sync -->
<string name="caldav">CalDAV</string>

View File

@ -163,6 +163,7 @@
<string name="system_stream">System</string>
<string name="alarm_stream">Alarm</string>
<string name="notification_stream">Notification</string>
<string name="ring_stream">Ring</string>
<!-- CalDAV sync -->
<string name="caldav">CalDAV</string>

View File

@ -163,6 +163,7 @@
<string name="system_stream">System</string>
<string name="alarm_stream">Alarm</string>
<string name="notification_stream">Notification</string>
<string name="ring_stream">Ring</string>
<!-- CalDAV sync -->
<string name="caldav">CalDAV</string>

View File

@ -163,6 +163,7 @@
<string name="system_stream">System</string>
<string name="alarm_stream">Alarm</string>
<string name="notification_stream">Notification</string>
<string name="ring_stream">Ring</string>
<!-- CalDAV sync -->
<string name="caldav">CalDAV</string>

View File

@ -163,6 +163,7 @@
<string name="system_stream">System</string>
<string name="alarm_stream">Alarm</string>
<string name="notification_stream">Notification</string>
<string name="ring_stream">Ring</string>
<!-- CalDAV sync -->
<string name="caldav">CalDAV</string>

View File

@ -164,6 +164,7 @@
<string name="system_stream">System</string>
<string name="alarm_stream">Alarm</string>
<string name="notification_stream">Notification</string>
<string name="ring_stream">Ring</string>
<!-- CalDAV sync -->
<string name="caldav">CalDAV</string>

View File

@ -163,6 +163,7 @@
<string name="system_stream">System</string>
<string name="alarm_stream">Alarm</string>
<string name="notification_stream">Notification</string>
<string name="ring_stream">Ring</string>
<!-- CalDAV sync -->
<string name="caldav">CalDAV</string>

View File

@ -163,6 +163,7 @@
<string name="system_stream">System</string>
<string name="alarm_stream">Alarm</string>
<string name="notification_stream">Notification</string>
<string name="ring_stream">Ring</string>
<!-- CalDAV sync -->
<string name="caldav">CalDAV</string>

View File

@ -163,6 +163,7 @@
<string name="system_stream">System</string>
<string name="alarm_stream">Alarm</string>
<string name="notification_stream">Notification</string>
<string name="ring_stream">Ring</string>
<!-- CalDAV sync -->
<string name="caldav">CalDAV</string>

View File

@ -164,6 +164,7 @@
<string name="system_stream">System</string>
<string name="alarm_stream">Alarm</string>
<string name="notification_stream">Notification</string>
<string name="ring_stream">Ring</string>
<!-- CalDAV sync -->
<string name="caldav">CalDAV</string>

View File

@ -163,6 +163,7 @@
<string name="system_stream">System</string>
<string name="alarm_stream">Alarm</string>
<string name="notification_stream">Notification</string>
<string name="ring_stream">Ring</string>
<!-- CalDAV sync -->
<string name="caldav">CalDAV</string>

View File

@ -163,6 +163,7 @@
<string name="system_stream">System</string>
<string name="alarm_stream">Alarm</string>
<string name="notification_stream">Notification</string>
<string name="ring_stream">Ring</string>
<!-- CalDAV sync -->
<string name="caldav">CalDAV</string>

View File

@ -163,6 +163,7 @@
<string name="system_stream">System</string>
<string name="alarm_stream">Alarm</string>
<string name="notification_stream">Notification</string>
<string name="ring_stream">Ring</string>
<!-- CalDAV sync -->
<string name="caldav">CalDAV</string>

View File

@ -163,6 +163,7 @@
<string name="system_stream">System</string>
<string name="alarm_stream">Alarm</string>
<string name="notification_stream">Notification</string>
<string name="ring_stream">Ring</string>
<!-- CalDAV sync -->
<string name="caldav">CalDAV</string>

View File

@ -159,10 +159,11 @@
<string name="loop_reminders">Herinneringen blijven herhalen totdat ze zijn uitgezet</string>
<string name="dim_past_events">Afgelopen afspraken dimmen</string>
<string name="events">Afspraken</string>
<string name="reminder_stream">Audio stream used by reminders</string>
<string name="system_stream">System</string>
<string name="reminder_stream">Type geluiden voor herinneringen gebruiken</string>
<string name="system_stream">Systeem</string>
<string name="alarm_stream">Alarm</string>
<string name="notification_stream">Notification</string>
<string name="notification_stream">Notificatie</string>
<string name="ring_stream">Beltoon</string>
<!-- CalDAV sync -->
<string name="caldav">CalDAV</string>

View File

@ -163,6 +163,7 @@
<string name="system_stream">System</string>
<string name="alarm_stream">Alarm</string>
<string name="notification_stream">Notification</string>
<string name="ring_stream">Ring</string>
<!-- CalDAV sync -->
<string name="caldav">CalDAV</string>

View File

@ -7,13 +7,13 @@
<string name="weekly_view">Tydzień</string>
<string name="monthly_view">Miesiąc</string>
<string name="yearly_view">Rok</string>
<string name="simple_event_list">Prosta lista zdarzeń</string>
<string name="simple_event_list">Prosta lista wydarzeń</string>
<string name="no_upcoming_events">Wygląda na to, że nie masz żadnych nadchodzących wydarzeń.</string>
<string name="go_to_today">Przejdź do dnia dzisiejszego</string>
<!-- Widget titles -->
<string name="widget_monthly">Prosty Kalendarz - widok miesięczny</string>
<string name="widget_list">Prosty Kalendarz - lista wydarzeń</string>
<string name="widget_monthly">Prosty kalendarz - widok miesięczny</string>
<string name="widget_list">Prosty kalendarz - lista wydarzeń</string>
<!-- Event -->
<string name="event">Wydarzenie</string>
@ -58,9 +58,9 @@
<string name="selected_days">Przez wybrane dni</string>
<string name="the_same_day">Tego samego dnia</string>
<string name="the_last_day">Ostatniego dnia</string>
<string name="repeat_on_the_same_day_monthly">Powtarzaj tego samego dnia każdego miesiąca</string>
<string name="repeat_on_the_same_day_monthly">Powtarzaj w tym samym dniu każdego miesiąca</string>
<string name="repeat_on_the_last_day_monthly">Powtarzaj ostatniego dnia każdego miesiąca</string>
<string name="repeat_on_the_same_day_yearly">Repeat on the same day every year</string>
<string name="repeat_on_the_same_day_yearly">Powtarzaj w tym samym dniu każdego roku</string>
<string name="repeat_every_m">Powtarzaj w każdy(ą)</string>
<string name="every_m">Każdy(ą)</string>
<string name="first_m">pierwszy(ą)</string>
@ -159,10 +159,11 @@
<string name="loop_reminders">Powtarzaj przypomnienia aż do ich wyłączenia</string>
<string name="dim_past_events">Przyciemniaj przeszłe wydarzenia</string>
<string name="events">Wydarzenia</string>
<string name="reminder_stream">Audio stream used by reminders</string>
<string name="reminder_stream">Rodzaj strumienia audio używanego przez przypomnienia</string>
<string name="system_stream">System</string>
<string name="alarm_stream">Alarm</string>
<string name="notification_stream">Notification</string>
<string name="notification_stream">Powiadomienie</string>
<string name="ring_stream">Dzwonek</string>
<!-- CalDAV sync -->
<string name="caldav">CalDAV</string>
@ -212,7 +213,7 @@
      Nie zawiera żadnych żadnych reklam, nie potrzebuje masy uprawnień, jest w pełni otwartoźródłowy, kolory można dowolnie modyfikować.
Uprawniena pamięci są potrzebne tylko do eksportowania lub importowania wydarzeń z plików .isc.
Uprawniena pamięci są potrzebne tylko do eksportowania lub importowania wydarzeń z plików .ics.
Uprawnienia kontaktów są używane tylko do importowania urodzin.

View File

@ -163,6 +163,7 @@
<string name="system_stream">System</string>
<string name="alarm_stream">Alarm</string>
<string name="notification_stream">Notification</string>
<string name="ring_stream">Ring</string>
<!-- CalDAV sync -->
<string name="caldav">CalDAV</string>

View File

@ -163,6 +163,7 @@
<string name="system_stream">System</string>
<string name="alarm_stream">Alarm</string>
<string name="notification_stream">Notification</string>
<string name="ring_stream">Ring</string>
<!-- CalDAV sync -->
<string name="caldav">CalDAV</string>

View File

@ -163,6 +163,7 @@
<string name="system_stream">стема</string>
<string name="alarm_stream">Будильник</string>
<string name="notification_stream">Уведомление</string>
<string name="ring_stream">Ring</string>
<!-- CalDAV sync -->
<string name="caldav">CalDAV</string>

View File

@ -163,6 +163,7 @@
<string name="system_stream">Systémový</string>
<string name="alarm_stream">Výstražný</string>
<string name="notification_stream">Pripomienkový</string>
<string name="ring_stream">Zvoniaci</string>
<!-- CalDAV sync -->
<string name="caldav">CalDAV</string>

View File

@ -163,6 +163,7 @@
<string name="system_stream">System</string>
<string name="alarm_stream">Alarm</string>
<string name="notification_stream">Notification</string>
<string name="ring_stream">Ring</string>
<!-- CalDAV sync -->
<string name="caldav">CalDAV</string>

View File

@ -159,10 +159,11 @@
<string name="loop_reminders">Kapatılana kadar hatırlatıcıları tekrarla</string>
<string name="dim_past_events">Geçmiş etkinlikleri karart</string>
<string name="events">Etkinlikler</string>
<string name="reminder_stream">Audio stream used by reminders</string>
<string name="system_stream">System</string>
<string name="reminder_stream">Hatırlatıcılar tarafından kullanılan ses akışı</string>
<string name="system_stream">Sistem</string>
<string name="alarm_stream">Alarm</string>
<string name="notification_stream">Notification</string>
<string name="notification_stream">Bildirim</string>
<string name="ring_stream">Zil sesi</string>
<!-- CalDAV sync -->
<string name="caldav">CalDAV</string>

View File

@ -159,10 +159,11 @@
<string name="loop_reminders">不斷重複提醒直到解除</string>
<string name="dim_past_events">淡化過去的活動</string>
<string name="events">活動</string>
<string name="reminder_stream">Audio stream used by reminders</string>
<string name="system_stream">System</string>
<string name="alarm_stream">Alarm</string>
<string name="notification_stream">Notification</string>
<string name="reminder_stream">用於提醒的音源串流</string>
<string name="system_stream">系統</string>
<string name="alarm_stream">鬧鐘</string>
<string name="notification_stream">通知</string>
<string name="ring_stream">鈴聲</string>
<!-- CalDAV sync -->
<string name="caldav">CalDAV</string>

View File

@ -163,6 +163,7 @@
<string name="system_stream">System</string>
<string name="alarm_stream">Alarm</string>
<string name="notification_stream">Notification</string>
<string name="ring_stream">Ring</string>
<!-- CalDAV sync -->
<string name="caldav">CalDAV</string>