update the Settings default reminder to contain only minutes
This commit is contained in:
parent
b1c99387c5
commit
636ab79bea
15 changed files with 19 additions and 123 deletions
|
@ -20,14 +20,11 @@ import com.google.api.client.util.ExponentialBackOff
|
|||
import com.google.api.services.calendar.CalendarScopes
|
||||
import com.simplemobiletools.calendar.R
|
||||
import com.simplemobiletools.calendar.asynctasks.FetchGoogleEventsTask
|
||||
import com.simplemobiletools.calendar.dialogs.EventReminderDialog
|
||||
import com.simplemobiletools.calendar.extensions.config
|
||||
import com.simplemobiletools.calendar.extensions.getDefaultReminderTypeIndex
|
||||
import com.simplemobiletools.calendar.extensions.getDefaultReminderValue
|
||||
import com.simplemobiletools.calendar.extensions.setupReminderPeriod
|
||||
import com.simplemobiletools.calendar.helpers.DAY_MINS
|
||||
import com.simplemobiletools.calendar.helpers.HOUR_MINS
|
||||
import com.simplemobiletools.calendar.helpers.REMINDER_CUSTOM
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.calendar.extensions.getReminderText
|
||||
import com.simplemobiletools.commons.extensions.toast
|
||||
import com.simplemobiletools.commons.extensions.updateTextColors
|
||||
import kotlinx.android.synthetic.main.activity_settings.*
|
||||
|
||||
class SettingsActivity : SimpleActivity() {
|
||||
|
@ -169,45 +166,17 @@ class SettingsActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun setupEventReminder() {
|
||||
val reminderType = config.defaultReminderType
|
||||
settings_default_reminder.setSelection(getDefaultReminderTypeIndex())
|
||||
custom_reminder_save.setTextColor(custom_reminder_other_val.currentTextColor)
|
||||
setupReminderPeriod(custom_reminder_other_period, custom_reminder_value)
|
||||
|
||||
settings_custom_reminder_holder.beVisibleIf(reminderType == REMINDER_CUSTOM)
|
||||
custom_reminder_save.setOnClickListener { saveReminder() }
|
||||
|
||||
settings_default_reminder.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||
override fun onItemSelected(p0: AdapterView<*>?, p1: View?, itemIndex: Int, p3: Long) {
|
||||
settings_custom_reminder_holder.beVisibleIf(itemIndex == 2)
|
||||
if (itemIndex == 2) {
|
||||
showKeyboard(custom_reminder_value)
|
||||
} else {
|
||||
hideKeyboard()
|
||||
}
|
||||
|
||||
config.defaultReminderType = getDefaultReminderValue(itemIndex)
|
||||
}
|
||||
|
||||
override fun onNothingSelected(p0: AdapterView<*>?) {
|
||||
var reminderMinutes = config.defaultReminderMinutes
|
||||
settings_default_reminder.text = getReminderText(reminderMinutes)
|
||||
settings_default_reminder_holder.setOnClickListener {
|
||||
EventReminderDialog(this, reminderMinutes) {
|
||||
config.defaultReminderMinutes = it
|
||||
reminderMinutes = it
|
||||
settings_default_reminder.text = getReminderText(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun saveReminder() {
|
||||
val multiplier = when (custom_reminder_other_period.selectedItemPosition) {
|
||||
1 -> HOUR_MINS
|
||||
2 -> DAY_MINS
|
||||
else -> 1
|
||||
}
|
||||
|
||||
val value = custom_reminder_value.value
|
||||
config.defaultReminderMinutes = Integer.valueOf(if (value.isEmpty()) "0" else value) * multiplier
|
||||
config.defaultReminderType = REMINDER_CUSTOM
|
||||
toast(R.string.reminder_saved)
|
||||
hideKeyboard()
|
||||
}
|
||||
|
||||
private fun getWeeklyAdapter(): ArrayAdapter<String> {
|
||||
val adapter = ArrayAdapter<String>(this, android.R.layout.simple_spinner_item)
|
||||
for (i in 0..24) {
|
||||
|
|
|
@ -109,14 +109,6 @@ fun Context.getDefaultReminderTypeIndex(): Int {
|
|||
}
|
||||
}
|
||||
|
||||
fun Context.getDefaultReminderValue(index: Int): Int {
|
||||
return when (index) {
|
||||
0 -> REMINDER_OFF
|
||||
1 -> REMINDER_AT_START
|
||||
else -> REMINDER_CUSTOM
|
||||
}
|
||||
}
|
||||
|
||||
fun Context.setupReminderPeriod(otherPeriod: AppCompatSpinner, otherValue: EditText) {
|
||||
val mins = config.defaultReminderMinutes
|
||||
var value = mins
|
||||
|
|
|
@ -211,10 +211,10 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/medium_margin"
|
||||
android:paddingBottom="@dimen/activity_margin"
|
||||
android:paddingBottom="@dimen/bigger_margin"
|
||||
android:paddingLeft="@dimen/activity_margin"
|
||||
android:paddingRight="@dimen/medium_margin"
|
||||
android:paddingTop="@dimen/activity_margin">
|
||||
android:paddingRight="@dimen/activity_margin"
|
||||
android:paddingTop="@dimen/bigger_margin">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/settings_default_reminder_label"
|
||||
|
@ -227,70 +227,17 @@
|
|||
android:paddingRight="@dimen/medium_margin"
|
||||
android:text="@string/default_event_reminder"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyAppCompatSpinner
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/settings_default_reminder"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:entries="@array/reminders"/>
|
||||
android:layout_marginEnd="@dimen/small_margin"
|
||||
android:layout_marginRight="@dimen/small_margin"
|
||||
android:background="@null"
|
||||
android:clickable="false"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/settings_custom_reminder_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="@dimen/activity_margin"
|
||||
android:orientation="horizontal"
|
||||
android:visibility="gone">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyEditText
|
||||
android:id="@+id/custom_reminder_value"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/activity_margin"
|
||||
android:layout_marginLeft="@dimen/activity_margin"
|
||||
android:layout_marginRight="@dimen/activity_margin"
|
||||
android:digits="0123456789"
|
||||
android:ems="3"
|
||||
android:inputType="number"
|
||||
android:maxLength="4"
|
||||
android:textCursorDrawable="@null"
|
||||
android:textSize="@dimen/day_text_size"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyAppCompatSpinner
|
||||
android:id="@+id/custom_reminder_other_period"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:entries="@array/custom_reminders"
|
||||
android:gravity="center"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/custom_reminder_other_val"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:text="@string/before"/>
|
||||
|
||||
<android.support.v4.widget.Space
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/custom_reminder_save"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:paddingBottom="@dimen/normal_margin"
|
||||
android:paddingLeft="@dimen/big_margin"
|
||||
android:paddingRight="@dimen/big_margin"
|
||||
android:paddingTop="@dimen/normal_margin"
|
||||
android:text="@string/save"
|
||||
android:textAllCaps="true"
|
||||
android:textSize="@dimen/bigger_text_size"/>
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
|
|
@ -90,7 +90,6 @@
|
|||
<string name="vibrate">Vibration ein bei Errinerung</string>
|
||||
<string name="reminder_sound">Erinnerungs Ton</string>
|
||||
<string name="default_event_reminder">Standard Termin Erinnerung</string>
|
||||
<string name="reminder_saved">Erinnerung gespeichert</string>
|
||||
<string name="notification_sound">Benachrichtigungs Ton</string>
|
||||
<string name="no_ringtone_picker">No app capable of setting ringtone found</string>
|
||||
<string name="no_ringtone_selected">Kein Klingelton gewählt</string>
|
||||
|
|
|
@ -90,7 +90,6 @@
|
|||
<string name="vibrate">Vibrate on reminder notification</string>
|
||||
<string name="reminder_sound">Reminder sound</string>
|
||||
<string name="default_event_reminder">Recordatorio predeterminado de un evento</string>
|
||||
<string name="reminder_saved">Recordatorio guardado</string>
|
||||
<string name="notification_sound">Notification sound</string>
|
||||
<string name="no_ringtone_picker">No app capable of setting ringtone found</string>
|
||||
<string name="no_ringtone_selected">None</string>
|
||||
|
|
|
@ -90,7 +90,6 @@
|
|||
<string name="vibrate">Vibrer à la notification de rappel</string>
|
||||
<string name="reminder_sound">Son de rappel</string>
|
||||
<string name="default_event_reminder">Rappel d\'événement par défaut</string>
|
||||
<string name="reminder_saved">Rappel sauvegardé</string>
|
||||
<string name="notification_sound">Son de notification</string>
|
||||
<string name="no_ringtone_picker">Aucune application capable de configurer la sonnerie trouvée</string>
|
||||
<string name="no_ringtone_selected">None</string>
|
||||
|
|
|
@ -90,7 +90,6 @@
|
|||
<string name="vibrate">Vibrate on reminder notification</string>
|
||||
<string name="reminder_sound">Reminder sound</string>
|
||||
<string name="default_event_reminder">Default event reminder</string>
|
||||
<string name="reminder_saved">Reminder saved</string>
|
||||
<string name="notification_sound">Notification sound</string>
|
||||
<string name="no_ringtone_picker">No app capable of setting ringtone found</string>
|
||||
<string name="no_ringtone_selected">None</string>
|
||||
|
|
|
@ -90,7 +90,6 @@
|
|||
<string name="vibrate">Emlékeztetőnél rezgés</string>
|
||||
<string name="reminder_sound">Reminder sound</string>
|
||||
<string name="default_event_reminder">Alapértelmezett emlékeztetés</string>
|
||||
<string name="reminder_saved">Emlékeztető elmentve</string>
|
||||
<string name="notification_sound">Notification sound</string>
|
||||
<string name="no_ringtone_picker">No app capable of setting ringtone found</string>
|
||||
<string name="no_ringtone_selected">None</string>
|
||||
|
|
|
@ -90,7 +90,6 @@
|
|||
<string name="vibrate">Vibrate on reminder notification</string>
|
||||
<string name="reminder_sound">Reminder sound</string>
|
||||
<string name="default_event_reminder">Default event reminder</string>
|
||||
<string name="reminder_saved">Reminder saved</string>
|
||||
<string name="notification_sound">Notification sound</string>
|
||||
<string name="no_ringtone_picker">No app capable of setting ringtone found</string>
|
||||
<string name="no_ringtone_selected">None</string>
|
||||
|
|
|
@ -90,7 +90,6 @@
|
|||
<string name="vibrate">רטט בהתראת תזכורת</string>
|
||||
<string name="reminder_sound">צליל תזכורת</string>
|
||||
<string name="default_event_reminder">תזכורת קבועה לאירוע</string>
|
||||
<string name="reminder_saved">התזכורת נשמרה</string>
|
||||
<string name="notification_sound">צליל התראה</string>
|
||||
<string name="no_ringtone_picker">לא נמצאה אפליקציה להגדרת רינגטון</string>
|
||||
<string name="no_ringtone_selected">ללא</string>
|
||||
|
|
|
@ -90,7 +90,6 @@
|
|||
<string name="vibrate">リマインダー通知で振動</string>
|
||||
<string name="reminder_sound">Reminder sound</string>
|
||||
<string name="default_event_reminder">デフォルトのイベント リマインダー</string>
|
||||
<string name="reminder_saved">リマインダーを保存しました</string>
|
||||
<string name="notification_sound">Notification sound</string>
|
||||
<string name="no_ringtone_picker">No app capable of setting ringtone found</string>
|
||||
<string name="no_ringtone_selected">None</string>
|
||||
|
|
|
@ -90,7 +90,6 @@
|
|||
<string name="vibrate">Vibrar ao notificar sobre o lembrete</string>
|
||||
<string name="reminder_sound">Som do lembrete</string>
|
||||
<string name="default_event_reminder">Lembrete padrão</string>
|
||||
<string name="reminder_saved">Lembrete guardado</string>
|
||||
<string name="notification_sound">Som da notificação</string>
|
||||
<string name="no_ringtone_picker">Não foi encontrada qualquer aplicação capaz de definir o som</string>
|
||||
<string name="no_ringtone_selected">Nenhum</string>
|
||||
|
|
|
@ -90,7 +90,6 @@
|
|||
<string name="vibrate">Вибрация при напоминании</string>
|
||||
<string name="reminder_sound">Звук напоминания</string>
|
||||
<string name="default_event_reminder">Напоминание для событий по умолчанию</string>
|
||||
<string name="reminder_saved">Напоминание сохранено</string>
|
||||
<string name="notification_sound">Звук уведомления</string>
|
||||
<string name="no_ringtone_picker">Не найдено приложение для выбора рингтона</string>
|
||||
<string name="no_ringtone_selected">Нет</string>
|
||||
|
|
|
@ -90,7 +90,6 @@
|
|||
<string name="vibrate">Vibrera vid påminnelseaviseringen</string>
|
||||
<string name="reminder_sound">Påminnelseljud</string>
|
||||
<string name="default_event_reminder">Standard händelsepåminnare</string>
|
||||
<string name="reminder_saved">Påminnelse sparad</string>
|
||||
<string name="notification_sound">Aviseringsljud</string>
|
||||
<string name="no_ringtone_picker">Hittade ingen app som kan ställa in ljudet</string>
|
||||
<string name="no_ringtone_selected">Ingen</string>
|
||||
|
|
|
@ -90,7 +90,6 @@
|
|||
<string name="vibrate">Vibrate on reminder notification</string>
|
||||
<string name="reminder_sound">Reminder sound</string>
|
||||
<string name="default_event_reminder">Default event reminder</string>
|
||||
<string name="reminder_saved">Reminder saved</string>
|
||||
<string name="notification_sound">Notification sound</string>
|
||||
<string name="no_ringtone_picker">No app capable of setting ringtone found</string>
|
||||
<string name="no_ringtone_selected">None</string>
|
||||
|
|
Loading…
Reference in a new issue