add a toggle for vibrations on notifications
This commit is contained in:
parent
d77e55582b
commit
d6f8ca66db
|
@ -15,6 +15,7 @@ import com.simplemobiletools.calendar.extensions.*
|
|||
import com.simplemobiletools.calendar.fragments.DayFragment
|
||||
import com.simplemobiletools.calendar.helpers.*
|
||||
import com.simplemobiletools.calendar.models.Event
|
||||
import com.simplemobiletools.filepicker.extensions.toast
|
||||
import kotlinx.android.synthetic.main.activity_event.*
|
||||
import org.joda.time.DateTime
|
||||
import org.joda.time.DateTimeZone
|
||||
|
|
|
@ -5,8 +5,12 @@ import android.support.v4.app.TaskStackBuilder
|
|||
import android.view.View
|
||||
import android.widget.AdapterView
|
||||
import com.simplemobiletools.calendar.R
|
||||
import com.simplemobiletools.calendar.extensions.*
|
||||
import com.simplemobiletools.calendar.extensions.beVisibleIf
|
||||
import com.simplemobiletools.calendar.extensions.hideKeyboard
|
||||
import com.simplemobiletools.calendar.extensions.showKeyboard
|
||||
import com.simplemobiletools.calendar.extensions.value
|
||||
import com.simplemobiletools.calendar.helpers.*
|
||||
import com.simplemobiletools.filepicker.extensions.toast
|
||||
import kotlinx.android.synthetic.main.activity_settings.*
|
||||
|
||||
class SettingsActivity : SimpleActivity() {
|
||||
|
@ -17,6 +21,7 @@ class SettingsActivity : SimpleActivity() {
|
|||
setupDarkTheme()
|
||||
setupSundayFirst()
|
||||
setupWeekNumbers()
|
||||
setupVibrate()
|
||||
setupEventReminder()
|
||||
}
|
||||
|
||||
|
@ -45,6 +50,14 @@ class SettingsActivity : SimpleActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun setupVibrate() {
|
||||
settings_vibrate.isChecked = mConfig.vibrateOnReminder
|
||||
settings_vibrate_holder.setOnClickListener {
|
||||
settings_vibrate.toggle()
|
||||
mConfig.vibrateOnReminder = settings_vibrate.isChecked
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupEventReminder() {
|
||||
val reminderType = mConfig.defaultReminderType
|
||||
val reminderMinutes = mConfig.defaultReminderMinutes
|
||||
|
|
|
@ -7,7 +7,6 @@ import android.content.ComponentName
|
|||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.SystemClock
|
||||
import android.widget.Toast
|
||||
import com.simplemobiletools.calendar.R
|
||||
import com.simplemobiletools.calendar.helpers.*
|
||||
import com.simplemobiletools.calendar.models.Event
|
||||
|
@ -26,8 +25,6 @@ fun Context.updateWidget() {
|
|||
}
|
||||
}
|
||||
|
||||
fun Context.toast(id: Int) = Toast.makeText(this, resources.getString(id), Toast.LENGTH_SHORT).show()
|
||||
|
||||
fun Context.scheduleNextEvent(event: Event) {
|
||||
var startTS = event.startTS - event.reminderMinutes * 60
|
||||
var newTS = startTS
|
||||
|
@ -54,7 +51,6 @@ private fun getNewTS(ts: Int, isMonthly: Boolean): Int {
|
|||
return (dateTime.millis / 1000).toInt()
|
||||
}
|
||||
|
||||
|
||||
fun Context.scheduleNotification(event: Event) {
|
||||
if (event.reminderMinutes == -1)
|
||||
return
|
||||
|
|
|
@ -34,6 +34,10 @@ class Config(context: Context) {
|
|||
get() = mPrefs.getBoolean(WEEK_NUMBERS, false)
|
||||
set(displayWeekNumbers) = mPrefs.edit().putBoolean(WEEK_NUMBERS, displayWeekNumbers).apply()
|
||||
|
||||
var vibrateOnReminder: Boolean
|
||||
get() = mPrefs.getBoolean(VIBRATE, true)
|
||||
set(vibrate) = mPrefs.edit().putBoolean(VIBRATE, vibrate).apply()
|
||||
|
||||
var storedView: Int
|
||||
get() = mPrefs.getInt(VIEW, MONTHLY_VIEW)
|
||||
set(view) = mPrefs.edit().putInt(VIEW, view).apply()
|
||||
|
|
|
@ -33,6 +33,7 @@ val IS_FIRST_RUN = "is_first_run"
|
|||
val IS_DARK_THEME = "is_dark_theme"
|
||||
val SUNDAY_FIRST = "sunday_first"
|
||||
val WEEK_NUMBERS = "week_numbers"
|
||||
val VIBRATE = "vibrate"
|
||||
val VIEW = "view"
|
||||
val REMINDER_TYPE = "reminder_type"
|
||||
val REMINDER_MINUTES = "reminder_minutes"
|
||||
|
|
|
@ -89,6 +89,32 @@
|
|||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/settings_vibrate_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/settings_padding"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:padding="@dimen/activity_margin">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/settings_vibrate_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:paddingLeft="@dimen/settings_padding"
|
||||
android:text="@string/vibrate"/>
|
||||
|
||||
<android.support.v7.widget.SwitchCompat
|
||||
android:id="@+id/settings_vibrate"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:background="@null"
|
||||
android:clickable="false"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/settings_default_reminder_holder"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -64,6 +64,7 @@
|
|||
<string name="dark_theme">Dunkles Design</string>
|
||||
<string name="sunday_first">Sonntag als erster Wochentag</string>
|
||||
<string name="week_numbers">Zeige Kalenderwoche an</string>
|
||||
<string name="vibrate">Vibrate on reminder notification</string>
|
||||
<string name="default_event_reminder">Standard Termin Erinnerung</string>
|
||||
<string name="reminder_saved">Erinnerung gespeichert</string>
|
||||
|
||||
|
|
|
@ -64,6 +64,7 @@
|
|||
<string name="dark_theme">Tema oscuro</string>
|
||||
<string name="sunday_first">Domingo como primer día</string>
|
||||
<string name="week_numbers">Mostrar los números de la semana</string>
|
||||
<string name="vibrate">Vibrate on reminder notification</string>
|
||||
<string name="default_event_reminder">Recordatorio predeterminado de un evento</string>
|
||||
<string name="reminder_saved">Recordatorio guardado</string>
|
||||
|
||||
|
|
|
@ -64,6 +64,7 @@
|
|||
<string name="dark_theme">काली थीम</string>
|
||||
<string name="sunday_first">रविवार पहला दिन हैं</string>
|
||||
<string name="week_numbers">सफ्ताह क्रमांक दिखाए</string>
|
||||
<string name="vibrate">Vibrate on reminder notification</string>
|
||||
<string name="default_event_reminder">Default event reminder</string>
|
||||
<string name="reminder_saved">Reminder saved</string>
|
||||
|
||||
|
|
|
@ -64,6 +64,7 @@
|
|||
<string name="dark_theme">Tema scuro</string>
|
||||
<string name="sunday_first">Sunday as first day</string>
|
||||
<string name="week_numbers">Display week numbers</string>
|
||||
<string name="vibrate">Vibrate on reminder notification</string>
|
||||
<string name="default_event_reminder">Default event reminder</string>
|
||||
<string name="reminder_saved">Reminder saved</string>
|
||||
|
||||
|
|
|
@ -64,6 +64,7 @@
|
|||
<string name="dark_theme">ダークテーマ</string>
|
||||
<string name="sunday_first">Sunday as first day</string>
|
||||
<string name="week_numbers">Display week numbers</string>
|
||||
<string name="vibrate">Vibrate on reminder notification</string>
|
||||
<string name="default_event_reminder">Default event reminder</string>
|
||||
<string name="reminder_saved">Reminder saved</string>
|
||||
|
||||
|
|
|
@ -64,6 +64,7 @@
|
|||
<string name="dark_theme">Tema escuro</string>
|
||||
<string name="sunday_first">Domingo como primeiro dia</string>
|
||||
<string name="week_numbers">Mostrar número das semanas</string>
|
||||
<string name="vibrate">Vibrate on reminder notification</string>
|
||||
<string name="default_event_reminder">Lembrete padrão</string>
|
||||
<string name="reminder_saved">Lembrete guardado</string>
|
||||
|
||||
|
|
|
@ -64,6 +64,7 @@
|
|||
<string name="dark_theme">Mörkt tema</string>
|
||||
<string name="sunday_first">Sunday as first day</string>
|
||||
<string name="week_numbers">Display week numbers</string>
|
||||
<string name="vibrate">Vibrate on reminder notification</string>
|
||||
<string name="default_event_reminder">Default event reminder</string>
|
||||
<string name="reminder_saved">Reminder saved</string>
|
||||
|
||||
|
|
|
@ -65,6 +65,7 @@
|
|||
<string name="dark_theme">Dark theme</string>
|
||||
<string name="sunday_first">Sunday as first day</string>
|
||||
<string name="week_numbers">Display week numbers</string>
|
||||
<string name="vibrate">Vibrate on reminder notification</string>
|
||||
<string name="default_event_reminder">Default event reminder</string>
|
||||
<string name="reminder_saved">Reminder saved</string>
|
||||
|
||||
|
|
Loading…
Reference in New Issue