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 5a61add1d..fe7c6064e 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 @@ -71,6 +71,7 @@ class SettingsActivity : SimpleActivity() { updateTextColors(settings_holder) checkPrimaryColor() setupSectionColors() + setupDefaultStartTime() } override fun onPause() { @@ -101,7 +102,7 @@ class SettingsActivity : SimpleActivity() { private fun setupSectionColors() { val adjustedPrimaryColor = getAdjustedPrimaryColor() - arrayListOf(reminders_label, caldav_label, weekly_view_label, monthly_view_label, simple_event_list_label, widgets_label, events_label).forEach { + arrayListOf(reminders_label, caldav_label, weekly_view_label, monthly_view_label, simple_event_list_label, widgets_label, events_label, new_events_label).forEach { it.setTextColor(adjustedPrimaryColor) } } @@ -298,6 +299,7 @@ class SettingsActivity : SimpleActivity() { } } + private fun setupWeekNumbers() { settings_week_numbers.isChecked = config.showWeekNumbers settings_week_numbers_holder.setOnClickListener { @@ -548,4 +550,24 @@ class SettingsActivity : SimpleActivity() { updateReminderSound(newAlarmSound) } } + + private fun setupDefaultStartTime() { + settings_set_default_start_time.text = getHoursString(config.defaultStartTime) + if (config.defaultStartTime == -1) { + settings_set_default_start_time.text = "/" + } + settings_set_default_start_time_holder.setOnClickListener { + val items = ArrayList() + items.add(RadioItem(-1, "/")) + (0..24).mapTo(items) { RadioItem(it, getHoursString(it)) } + + RadioGroupDialog(this@SettingsActivity, items, config.defaultStartTime) { + config.defaultStartTime = it as Int + settings_set_default_start_time.text = getHoursString(it) + if (it == -1) { + settings_set_default_start_time.text = "/" + } + } + } + } } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/extensions/Context.kt index 2b58fe3db..73003ffed 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/extensions/Context.kt @@ -313,9 +313,17 @@ fun Context.launchNewEventIntent(dayCode: String = Formatter.getTodayCode()) { } fun Context.getNewEventTimestampFromCode(dayCode: String): Long { - val currHour = DateTime(System.currentTimeMillis(), DateTimeZone.getDefault()).hourOfDay - val dateTime = Formatter.getLocalDateTimeFromCode(dayCode).withHourOfDay(currHour) - val newDateTime = dateTime.plusHours(1).withMinuteOfHour(0).withSecondOfMinute(0).withMillisOfSecond(0) + val defaultStartTime = config.defaultStartTime + var currHour = DateTime(System.currentTimeMillis(), DateTimeZone.getDefault()).hourOfDay + var dateTime = Formatter.getLocalDateTimeFromCode(dayCode).withHourOfDay(currHour) + var newDateTime = dateTime.plusHours(1).withMinuteOfHour(0).withSecondOfMinute(0).withMillisOfSecond(0) + + if (defaultStartTime != -1) { + currHour = defaultStartTime + dateTime = Formatter.getLocalDateTimeFromCode(dayCode).withHourOfDay(currHour) + newDateTime = dateTime + } + // make sure the date doesn't change return newDateTime.withDate(dateTime.year, dateTime.monthOfYear, dateTime.dayOfMonth).seconds() } 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 f4b3c994c..110b16107 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 @@ -173,4 +173,8 @@ class Config(context: Context) : BaseConfig(context) { var lastVibrateOnReminder: Boolean get() = prefs.getBoolean(LAST_VIBRATE_ON_REMINDER, context.config.vibrateOnReminder) set(lastVibrateOnReminder) = prefs.edit().putBoolean(LAST_VIBRATE_ON_REMINDER, lastVibrateOnReminder).apply() + + var defaultStartTime: Int + get() = prefs.getInt(DEFAULT_START_TIME, -1) + set(defaultStartTime) = prefs.edit().putInt(DEFAULT_START_TIME, defaultStartTime).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 07f1ce543..cafb16d62 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 @@ -40,6 +40,7 @@ const val YEAR = 31536000 const val WEEK_NUMBERS = "week_numbers" const val START_WEEKLY_AT = "start_weekly_at" const val END_WEEKLY_AT = "end_weekly_at" +const val DEFAULT_START_TIME = "default_start_time" const val VIBRATE = "vibrate" const val REMINDER_SOUND_URI = "reminder_sound_uri" const val REMINDER_SOUND_TITLE = "reminder_sound_title" diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index 4fc431e1e..ae67c9c78 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -922,5 +922,58 @@ android:text="@string/delete_all_events"/> + + + + + + + + + + + + + diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index f0a3655a4..793fa8df0 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -234,6 +234,9 @@ Diese App ist nur eine aus einer größeren Serie von schlichten Apps. Der Rest davon findet sich auf https://www.simplemobiletools.com + + Neuer Termin startet standardmäßig um + + Default time for new event +