allow changing the default daily repetition in settings

This commit is contained in:
tibbi 2017-04-15 18:58:01 +02:00
parent cfd40fd486
commit 9dffd1cd74
19 changed files with 72 additions and 1 deletions

View file

@ -153,7 +153,7 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
checkRepeatTexts(interval)
if (mRepeatInterval == DAY) {
setRepeatRule(EVERY_DAY)
setRepeatRule(config.defaultDailyRepetition)
}
}

View file

@ -7,9 +7,11 @@ import android.net.Uri
import android.os.Bundle
import android.os.Parcelable
import com.simplemobiletools.calendar.R
import com.simplemobiletools.calendar.dialogs.RepeatRuleDailyDialog
import com.simplemobiletools.calendar.extensions.config
import com.simplemobiletools.calendar.extensions.dbHelper
import com.simplemobiletools.calendar.extensions.getReminderText
import com.simplemobiletools.calendar.helpers.EVERY_DAY
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
import com.simplemobiletools.commons.extensions.toast
import com.simplemobiletools.commons.extensions.updateTextColors
@ -50,6 +52,7 @@ class SettingsActivity : SimpleActivity() {
setupWeeklyEnd()
setupVibrate()
setupReminderSound()
setupDailyRepetition()
setupEventReminder()
updateTextColors(settings_holder)
checkPrimaryColor()
@ -184,6 +187,20 @@ class SettingsActivity : SimpleActivity() {
}
}
private fun setupDailyRepetition() {
updateDailyRepetitionText()
settings_default_daily_repetition_holder.setOnClickListener {
RepeatRuleDailyDialog(this, config.defaultDailyRepetition) {
config.defaultDailyRepetition = it
updateDailyRepetitionText()
}
}
}
private fun updateDailyRepetitionText() {
settings_default_daily_repetition.text = getString(if (config.defaultDailyRepetition == EVERY_DAY) R.string.every_day else R.string.selected_days)
}
private fun setupEventReminder() {
var reminderMinutes = config.defaultReminderMinutes
settings_default_reminder.text = getReminderText(reminderMinutes)

View file

@ -49,6 +49,10 @@ class Config(context: Context) : BaseConfig(context) {
get() = prefs.getInt(VIEW, MONTHLY_VIEW)
set(view) = prefs.edit().putInt(VIEW, view).apply()
var defaultDailyRepetition: Int
get() = prefs.getInt(DAILY_REPETITION, EVERY_DAY)
set(dailyRepetition) = prefs.edit().putInt(DAILY_REPETITION, dailyRepetition).apply()
var defaultReminderMinutes: Int
get() = prefs.getInt(REMINDER_MINUTES, 10)
set(mins) = prefs.edit().putInt(REMINDER_MINUTES, mins).apply()

View file

@ -39,6 +39,7 @@ val END_WEEKLY_AT = "end_weekly_at"
val VIBRATE = "vibrate"
val REMINDER_SOUND = "reminder_sound"
val VIEW = "view"
val DAILY_REPETITION = "daily_repetition"
val REMINDER_MINUTES = "reminder_minutes"
val DISPLAY_EVENT_TYPES = "display_event_types"
val GOOGLE_SYNC = "google_sync"

View file

@ -255,6 +255,41 @@
</RelativeLayout>
<RelativeLayout
android:id="@+id/settings_default_daily_repetition_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/medium_margin"
android:background="?attr/selectableItemBackground"
android:paddingBottom="@dimen/bigger_margin"
android:paddingLeft="@dimen/activity_margin"
android:paddingRight="@dimen/activity_margin"
android:paddingTop="@dimen/bigger_margin">
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/settings_default_daily_repetition_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="@+id/settings_default_daily_repetition"
android:layout_toStartOf="@+id/settings_default_daily_repetition"
android:paddingLeft="@dimen/medium_margin"
android:paddingRight="@dimen/medium_margin"
android:text="@string/default_daily_repetition"/>
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/settings_default_daily_repetition"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginEnd="@dimen/small_margin"
android:layout_marginRight="@dimen/small_margin"
android:background="@null"
android:clickable="false"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/settings_default_reminder_holder"
android:layout_width="match_parent"

View file

@ -49,6 +49,7 @@
<string name="repeat">Widerholung</string>
<string name="every_day">Täglich</string>
<string name="selected_days">an ausgewählten Tagen</string>
<string name="default_daily_repetition">Default daily repetition</string>
<string name="on_the_same_day">jeden Monat am selben Tag</string>
<string name="on_the_last_day">am letzten Tag des Monat</string>
<string name="every_m">jeden</string>

View file

@ -49,6 +49,7 @@
<string name="repeat">Repeat</string>
<string name="every_day">Every day</string>
<string name="selected_days">On selected days</string>
<string name="default_daily_repetition">Default daily repetition</string>
<string name="on_the_same_day">On the same day every month</string>
<string name="on_the_last_day">On the last day of the month</string>
<string name="every_m">Every</string>

View file

@ -49,6 +49,7 @@
<string name="repeat">Repeat</string>
<string name="every_day">Every day</string>
<string name="selected_days">On selected days</string>
<string name="default_daily_repetition">Default daily repetition</string>
<string name="on_the_same_day">On the same day every month</string>
<string name="on_the_last_day">On the last day of the month</string>
<string name="every_m">Every</string>

View file

@ -49,6 +49,7 @@
<string name="repeat">Repeat</string>
<string name="every_day">Every day</string>
<string name="selected_days">On selected days</string>
<string name="default_daily_repetition">Default daily repetition</string>
<string name="on_the_same_day">On the same day every month</string>
<string name="on_the_last_day">On the last day of the month</string>
<string name="every_m">Every</string>

View file

@ -49,6 +49,7 @@
<string name="repeat">Repeat</string>
<string name="every_day">Every day</string>
<string name="selected_days">On selected days</string>
<string name="default_daily_repetition">Default daily repetition</string>
<string name="on_the_same_day">On the same day every month</string>
<string name="on_the_last_day">On the last day of the month</string>
<string name="every_m">Every</string>

View file

@ -49,6 +49,7 @@
<string name="repeat">Repeat</string>
<string name="every_day">Every day</string>
<string name="selected_days">On selected days</string>
<string name="default_daily_repetition">Default daily repetition</string>
<string name="on_the_same_day">On the same day every month</string>
<string name="on_the_last_day">On the last day of the month</string>
<string name="every_m">Every</string>

View file

@ -49,6 +49,7 @@
<string name="repeat">Repeat</string>
<string name="every_day">Every day</string>
<string name="selected_days">On selected days</string>
<string name="default_daily_repetition">Default daily repetition</string>
<string name="on_the_same_day">On the same day every month</string>
<string name="on_the_last_day">On the last day of the month</string>
<string name="every_m">Every</string>

View file

@ -49,6 +49,7 @@
<string name="repeat">Repeat</string>
<string name="every_day">Every day</string>
<string name="selected_days">On selected days</string>
<string name="default_daily_repetition">Default daily repetition</string>
<string name="on_the_same_day">On the same day every month</string>
<string name="on_the_last_day">On the last day of the month</string>
<string name="every_m">Every</string>

View file

@ -49,6 +49,7 @@
<string name="repeat">Repeat</string>
<string name="every_day">Every day</string>
<string name="selected_days">On selected days</string>
<string name="default_daily_repetition">Default daily repetition</string>
<string name="on_the_same_day">On the same day every month</string>
<string name="on_the_last_day">On the last day of the month</string>
<string name="every_m">Every</string>

View file

@ -49,6 +49,7 @@
<string name="repeat">Repeat</string>
<string name="every_day">Every day</string>
<string name="selected_days">On selected days</string>
<string name="default_daily_repetition">Default daily repetition</string>
<string name="on_the_same_day">On the same day every month</string>
<string name="on_the_last_day">On the last day of the month</string>
<string name="every_m">Every</string>

View file

@ -49,6 +49,7 @@
<string name="repeat">Repeat</string>
<string name="every_day">Every day</string>
<string name="selected_days">On selected days</string>
<string name="default_daily_repetition">Default daily repetition</string>
<string name="on_the_same_day">On the same day every month</string>
<string name="on_the_last_day">On the last day of the month</string>
<string name="every_m">Every</string>

View file

@ -49,6 +49,7 @@
<string name="repeat">Opakovať</string>
<string name="every_day">Každý deň</string>
<string name="selected_days">Vo vybraných dňoch</string>
<string name="default_daily_repetition">Predvolené denné opakovanie</string>
<string name="on_the_same_day">Každý mesiac v rovnaký deň</string>
<string name="on_the_last_day">Posledný deň v mesiaci</string>
<string name="every_m">Každý</string>

View file

@ -49,6 +49,7 @@
<string name="repeat">Repeat</string>
<string name="every_day">Every day</string>
<string name="selected_days">On selected days</string>
<string name="default_daily_repetition">Default daily repetition</string>
<string name="on_the_same_day">On the same day every month</string>
<string name="on_the_last_day">On the last day of the month</string>
<string name="every_m">Every</string>

View file

@ -49,6 +49,7 @@
<string name="repeat">Repeat</string>
<string name="every_day">Every day</string>
<string name="selected_days">On selected days</string>
<string name="default_daily_repetition">Default daily repetition</string>
<string name="on_the_same_day">On the same day every month</string>
<string name="on_the_last_day">On the last day of the month</string>
<string name="every_m">Every</string>