Add setting for default start time of an event
This commit is contained in:
parent
21b112b265
commit
95d403aed9
|
@ -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<RadioItem>()
|
||||
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 = "/"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -922,5 +922,58 @@
|
|||
android:text="@string/delete_all_events"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<View
|
||||
android:id="@+id/new_events_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1px"
|
||||
android:background="@color/divider_grey"
|
||||
android:importantForAccessibility="no"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/new_events_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/bigger_margin"
|
||||
android:layout_marginLeft="@dimen/bigger_margin"
|
||||
android:layout_marginTop="@dimen/activity_margin"
|
||||
android:text="@string/new_event"
|
||||
android:textAllCaps="true"
|
||||
android:textSize="@dimen/smaller_text_size"/>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/settings_set_default_start_time_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:paddingLeft="@dimen/normal_margin"
|
||||
android:paddingTop="@dimen/bigger_margin"
|
||||
android:paddingRight="@dimen/normal_margin"
|
||||
android:paddingBottom="@dimen/bigger_margin">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/settings_set_default_start_time_label"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toStartOf="@+id/settings_set_default_start_time"
|
||||
android:layout_toLeftOf="@+id/settings_set_default_start_time"
|
||||
android:paddingLeft="@dimen/medium_margin"
|
||||
android:paddingRight="@dimen/medium_margin"
|
||||
android:text="@string/new_event_default_start"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/settings_set_default_start_time"
|
||||
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>
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
|
|
@ -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
|
||||
</string>
|
||||
|
||||
<!-- Strings for settings of new event -->
|
||||
<string name="new_event_default_start">Neuer Termin startet standardmäßig um</string>
|
||||
|
||||
<!--
|
||||
Haven't found some strings? There's more at
|
||||
https://github.com/SimpleMobileTools/Simple-Commons/tree/master/commons/src/main/res
|
||||
|
|
|
@ -233,6 +233,9 @@
|
|||
This app is just one piece of a bigger series of apps. You can find the rest of them at https://www.simplemobiletools.com
|
||||
</string>
|
||||
|
||||
<!-- Strings for settings of new event -->
|
||||
<string name="new_event_default_start">Default time for new event</string>
|
||||
|
||||
<!--
|
||||
Haven't found some strings? There's more at
|
||||
https://github.com/SimpleMobileTools/Simple-Commons/tree/master/commons/src/main/res
|
||||
|
|
Loading…
Reference in New Issue