adding a settings item for setting a default event type for new events
This commit is contained in:
parent
9758a69789
commit
b7ef8f7f1b
|
@ -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<RadioItem>()
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/settings_scrollview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
@ -398,7 +399,7 @@
|
|||
android:textSize="@dimen/smaller_text_size"/>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/settings_set_default_start_time_holder"
|
||||
android:id="@+id/settings_default_start_time_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
|
@ -408,28 +409,29 @@
|
|||
android:paddingBottom="@dimen/bigger_margin">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/settings_set_default_start_time_label"
|
||||
android:id="@+id/settings_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_toStartOf="@+id/settings_default_start_time"
|
||||
android:paddingLeft="@dimen/medium_margin"
|
||||
android:paddingRight="@dimen/medium_margin"
|
||||
android:text="@string/default_start_time"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/settings_set_default_start_time"
|
||||
android:id="@+id/settings_default_start_time"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginEnd="@dimen/small_margin"
|
||||
android:background="@null"
|
||||
android:clickable="false"/>
|
||||
android:clickable="false"
|
||||
tools:text="@string/next_full_hour"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/settings_set_default_duration_time_holder"
|
||||
android:id="@+id/settings_default_duration_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
|
@ -439,23 +441,56 @@
|
|||
android:paddingBottom="@dimen/bigger_margin">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/settings_set_default_duration_time_label"
|
||||
android:id="@+id/settings_default_duration_label"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toStartOf="@+id/settings_set_default_duration_time"
|
||||
android:layout_toStartOf="@+id/settings_default_duration"
|
||||
android:paddingLeft="@dimen/medium_margin"
|
||||
android:paddingRight="@dimen/medium_margin"
|
||||
android:text="@string/default_duration"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/settings_set_default_duration_time"
|
||||
android:id="@+id/settings_default_duration"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginEnd="@dimen/small_margin"
|
||||
android:background="@null"
|
||||
android:clickable="false"/>
|
||||
android:clickable="false"
|
||||
tools:text="0 minutes"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/settings_default_event_type_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_default_event_type_label"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toStartOf="@+id/settings_default_event_type"
|
||||
android:paddingLeft="@dimen/medium_margin"
|
||||
android:paddingRight="@dimen/medium_margin"
|
||||
android:text="@string/default_event_type"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/settings_default_event_type"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginEnd="@dimen/small_margin"
|
||||
android:background="@null"
|
||||
android:clickable="false"
|
||||
tools:text="@string/last_used_one"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
@ -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">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/settings_font_size_label"
|
||||
|
@ -841,9 +876,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">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/settings_list_widget_view_to_open_label"
|
||||
|
@ -872,9 +907,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">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/settings_customize_widget_colors_label"
|
||||
|
@ -910,9 +945,9 @@
|
|||
android:layout_marginTop="@dimen/medium_margin"
|
||||
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">
|
||||
|
||||
<com.simplemobiletools.commons.views.MySwitchCompat
|
||||
android:id="@+id/settings_dim_past_events"
|
||||
|
|
Loading…
Reference in New Issue