diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/SettingsActivity.kt index 71783af7b..0d611bddb 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/SettingsActivity.kt @@ -60,6 +60,9 @@ class SettingsActivity : SimpleActivity() { setupSnoozeTime() setupCaldavSync() setupManageSyncedCalendars() + setupDefaultStartTime() + setupDefaultDuration() + setupDefaultEventType() setupPullToRefresh() setupDefaultReminder() setupDefaultReminder1() @@ -73,8 +76,6 @@ class SettingsActivity : SimpleActivity() { updateTextColors(settings_holder) checkPrimaryColor() setupSectionColors() - setupDefaultStartTime() - setupDefaultDuration() } override fun onPause() { @@ -90,6 +91,14 @@ class SettingsActivity : SimpleActivity() { config.defaultReminder3 = reminders.getOrElse(2) { REMINDER_OFF } } + override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) { + super.onActivityResult(requestCode, resultCode, resultData) + if (requestCode == GET_RINGTONE_URI && resultCode == RESULT_OK && resultData != null) { + val newAlarmSound = storeNewYourAlarmSound(resultData) + updateReminderSound(newAlarmSound) + } + } + private fun checkPrimaryColor() { if (config.primaryColor != mStoredPrimaryColor) { Thread { @@ -546,17 +555,9 @@ class SettingsActivity : SimpleActivity() { } } - override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) { - super.onActivityResult(requestCode, resultCode, resultData) - if (requestCode == GET_RINGTONE_URI && resultCode == RESULT_OK && resultData != null) { - val newAlarmSound = storeNewYourAlarmSound(resultData) - updateReminderSound(newAlarmSound) - } - } - private fun setupDefaultStartTime() { updateDefaultStartTimeText() - settings_set_default_start_time_holder.setOnClickListener { + settings_default_start_time_holder.setOnClickListener { val currentDefaultTime = if (config.defaultStartTime == -1) -1 else 0 val items = ArrayList() items.add(RadioItem(-1, getString(R.string.next_full_hour))) @@ -581,17 +582,17 @@ class SettingsActivity : SimpleActivity() { private fun updateDefaultStartTimeText() { if (config.defaultStartTime == -1) { - settings_set_default_start_time.text = getString(R.string.next_full_hour) + settings_default_start_time.text = getString(R.string.next_full_hour) } else { val hours = config.defaultStartTime / 60 val minutes = config.defaultStartTime % 60 - settings_set_default_start_time.text = String.format("%02d:%02d", hours, minutes) + settings_default_start_time.text = String.format("%02d:%02d", hours, minutes) } } private fun setupDefaultDuration() { updateDefaultDurationText() - settings_set_default_duration_time_holder.setOnClickListener { + settings_default_duration_holder.setOnClickListener { CustomIntervalPickerDialog(this, config.defaultDuration * 60) { val result = it / 60 config.defaultDuration = result @@ -602,10 +603,14 @@ class SettingsActivity : SimpleActivity() { private fun updateDefaultDurationText() { val duration = config.defaultDuration - settings_set_default_duration_time.text = if (duration == 0) { + settings_default_duration.text = if (duration == 0) { "0 ${getString(R.string.minutes_raw)}" } else { getFormattedMinutes(duration, false) } } + + private fun setupDefaultEventType() { + settings_default_event_type.text = getString(R.string.last_used_one) + } } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Config.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Config.kt index 422f0ca74..6187fd866 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Config.kt @@ -181,4 +181,8 @@ class Config(context: Context) : BaseConfig(context) { var defaultDuration: Int get() = prefs.getInt(DEFAULT_DURATION, 0) set(defaultDuration) = prefs.edit().putInt(DEFAULT_DURATION, defaultDuration).apply() + + var defaultEventType: Long + get() = prefs.getLong(DEFAULT_EVENT_TYPE, REGULAR_EVENT_TYPE_ID) + set(defaultEventType) = prefs.edit().putLong(DEFAULT_EVENT_TYPE, defaultEventType).apply() } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Constants.kt index 9c085a3c9..ee5541ef3 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Constants.kt @@ -70,6 +70,7 @@ const val PULL_TO_REFRESH = "pull_to_refresh" const val LAST_VIBRATE_ON_REMINDER = "last_vibrate_on_reminder" const val DEFAULT_START_TIME = "default_start_time" const val DEFAULT_DURATION = "default_duration" +const val DEFAULT_EVENT_TYPE = "default_event_type" // repeat_rule for monthly and yearly repetition const val REPEAT_SAME_DAY = 1 // i.e. 25th every month, or 3rd june (if yearly repetition) diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index eebb7fc4d..5c5ab4993 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -1,6 +1,7 @@ @@ -398,7 +399,7 @@ android:textSize="@dimen/smaller_text_size"/> + android:clickable="false" + tools:text="@string/next_full_hour"/> + android:clickable="false" + tools:text="0 minutes"/> + + + + + + + + @@ -810,9 +845,9 @@ android:layout_height="wrap_content" android:background="?attr/selectableItemBackground" android:paddingStart="@dimen/normal_margin" - android:paddingTop="@dimen/activity_margin" + android:paddingTop="@dimen/bigger_margin" android:paddingEnd="@dimen/normal_margin" - android:paddingBottom="@dimen/activity_margin"> + android:paddingBottom="@dimen/bigger_margin"> + android:paddingBottom="@dimen/bigger_margin"> + android:paddingBottom="@dimen/bigger_margin"> + android:paddingBottom="@dimen/bigger_margin">