mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-06-05 21:59:17 +02:00
adding a settings item for setting a default event type for new events
This commit is contained in:
@ -60,6 +60,9 @@ class SettingsActivity : SimpleActivity() {
|
|||||||
setupSnoozeTime()
|
setupSnoozeTime()
|
||||||
setupCaldavSync()
|
setupCaldavSync()
|
||||||
setupManageSyncedCalendars()
|
setupManageSyncedCalendars()
|
||||||
|
setupDefaultStartTime()
|
||||||
|
setupDefaultDuration()
|
||||||
|
setupDefaultEventType()
|
||||||
setupPullToRefresh()
|
setupPullToRefresh()
|
||||||
setupDefaultReminder()
|
setupDefaultReminder()
|
||||||
setupDefaultReminder1()
|
setupDefaultReminder1()
|
||||||
@ -73,8 +76,6 @@ class SettingsActivity : SimpleActivity() {
|
|||||||
updateTextColors(settings_holder)
|
updateTextColors(settings_holder)
|
||||||
checkPrimaryColor()
|
checkPrimaryColor()
|
||||||
setupSectionColors()
|
setupSectionColors()
|
||||||
setupDefaultStartTime()
|
|
||||||
setupDefaultDuration()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
@ -90,6 +91,14 @@ class SettingsActivity : SimpleActivity() {
|
|||||||
config.defaultReminder3 = reminders.getOrElse(2) { REMINDER_OFF }
|
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() {
|
private fun checkPrimaryColor() {
|
||||||
if (config.primaryColor != mStoredPrimaryColor) {
|
if (config.primaryColor != mStoredPrimaryColor) {
|
||||||
Thread {
|
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() {
|
private fun setupDefaultStartTime() {
|
||||||
updateDefaultStartTimeText()
|
updateDefaultStartTimeText()
|
||||||
settings_set_default_start_time_holder.setOnClickListener {
|
settings_default_start_time_holder.setOnClickListener {
|
||||||
val currentDefaultTime = if (config.defaultStartTime == -1) -1 else 0
|
val currentDefaultTime = if (config.defaultStartTime == -1) -1 else 0
|
||||||
val items = ArrayList<RadioItem>()
|
val items = ArrayList<RadioItem>()
|
||||||
items.add(RadioItem(-1, getString(R.string.next_full_hour)))
|
items.add(RadioItem(-1, getString(R.string.next_full_hour)))
|
||||||
@ -581,17 +582,17 @@ class SettingsActivity : SimpleActivity() {
|
|||||||
|
|
||||||
private fun updateDefaultStartTimeText() {
|
private fun updateDefaultStartTimeText() {
|
||||||
if (config.defaultStartTime == -1) {
|
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 {
|
} else {
|
||||||
val hours = config.defaultStartTime / 60
|
val hours = config.defaultStartTime / 60
|
||||||
val minutes = 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() {
|
private fun setupDefaultDuration() {
|
||||||
updateDefaultDurationText()
|
updateDefaultDurationText()
|
||||||
settings_set_default_duration_time_holder.setOnClickListener {
|
settings_default_duration_holder.setOnClickListener {
|
||||||
CustomIntervalPickerDialog(this, config.defaultDuration * 60) {
|
CustomIntervalPickerDialog(this, config.defaultDuration * 60) {
|
||||||
val result = it / 60
|
val result = it / 60
|
||||||
config.defaultDuration = result
|
config.defaultDuration = result
|
||||||
@ -602,10 +603,14 @@ class SettingsActivity : SimpleActivity() {
|
|||||||
|
|
||||||
private fun updateDefaultDurationText() {
|
private fun updateDefaultDurationText() {
|
||||||
val duration = config.defaultDuration
|
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)}"
|
"0 ${getString(R.string.minutes_raw)}"
|
||||||
} else {
|
} else {
|
||||||
getFormattedMinutes(duration, false)
|
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
|
var defaultDuration: Int
|
||||||
get() = prefs.getInt(DEFAULT_DURATION, 0)
|
get() = prefs.getInt(DEFAULT_DURATION, 0)
|
||||||
set(defaultDuration) = prefs.edit().putInt(DEFAULT_DURATION, defaultDuration).apply()
|
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 LAST_VIBRATE_ON_REMINDER = "last_vibrate_on_reminder"
|
||||||
const val DEFAULT_START_TIME = "default_start_time"
|
const val DEFAULT_START_TIME = "default_start_time"
|
||||||
const val DEFAULT_DURATION = "default_duration"
|
const val DEFAULT_DURATION = "default_duration"
|
||||||
|
const val DEFAULT_EVENT_TYPE = "default_event_type"
|
||||||
|
|
||||||
// repeat_rule for monthly and yearly repetition
|
// repeat_rule for monthly and yearly repetition
|
||||||
const val REPEAT_SAME_DAY = 1 // i.e. 25th every month, or 3rd june (if 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"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<ScrollView
|
<ScrollView
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:id="@+id/settings_scrollview"
|
android:id="@+id/settings_scrollview"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
@ -398,7 +399,7 @@
|
|||||||
android:textSize="@dimen/smaller_text_size"/>
|
android:textSize="@dimen/smaller_text_size"/>
|
||||||
|
|
||||||
<RelativeLayout
|
<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_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="?attr/selectableItemBackground"
|
android:background="?attr/selectableItemBackground"
|
||||||
@ -408,28 +409,29 @@
|
|||||||
android:paddingBottom="@dimen/bigger_margin">
|
android:paddingBottom="@dimen/bigger_margin">
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyTextView
|
<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_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_centerVertical="true"
|
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:paddingLeft="@dimen/medium_margin"
|
||||||
android:paddingRight="@dimen/medium_margin"
|
android:paddingRight="@dimen/medium_margin"
|
||||||
android:text="@string/default_start_time"/>
|
android:text="@string/default_start_time"/>
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyTextView
|
<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_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentEnd="true"
|
android:layout_alignParentEnd="true"
|
||||||
android:layout_marginEnd="@dimen/small_margin"
|
android:layout_marginEnd="@dimen/small_margin"
|
||||||
android:background="@null"
|
android:background="@null"
|
||||||
android:clickable="false"/>
|
android:clickable="false"
|
||||||
|
tools:text="@string/next_full_hour"/>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<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_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="?attr/selectableItemBackground"
|
android:background="?attr/selectableItemBackground"
|
||||||
@ -439,23 +441,56 @@
|
|||||||
android:paddingBottom="@dimen/bigger_margin">
|
android:paddingBottom="@dimen/bigger_margin">
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyTextView
|
<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_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_centerVertical="true"
|
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:paddingLeft="@dimen/medium_margin"
|
||||||
android:paddingRight="@dimen/medium_margin"
|
android:paddingRight="@dimen/medium_margin"
|
||||||
android:text="@string/default_duration"/>
|
android:text="@string/default_duration"/>
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyTextView
|
<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_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentEnd="true"
|
android:layout_alignParentEnd="true"
|
||||||
android:layout_marginEnd="@dimen/small_margin"
|
android:layout_marginEnd="@dimen/small_margin"
|
||||||
android:background="@null"
|
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>
|
</RelativeLayout>
|
||||||
|
|
||||||
@ -810,9 +845,9 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="?attr/selectableItemBackground"
|
android:background="?attr/selectableItemBackground"
|
||||||
android:paddingStart="@dimen/normal_margin"
|
android:paddingStart="@dimen/normal_margin"
|
||||||
android:paddingTop="@dimen/activity_margin"
|
android:paddingTop="@dimen/bigger_margin"
|
||||||
android:paddingEnd="@dimen/normal_margin"
|
android:paddingEnd="@dimen/normal_margin"
|
||||||
android:paddingBottom="@dimen/activity_margin">
|
android:paddingBottom="@dimen/bigger_margin">
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyTextView
|
<com.simplemobiletools.commons.views.MyTextView
|
||||||
android:id="@+id/settings_font_size_label"
|
android:id="@+id/settings_font_size_label"
|
||||||
@ -841,9 +876,9 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="?attr/selectableItemBackground"
|
android:background="?attr/selectableItemBackground"
|
||||||
android:paddingStart="@dimen/normal_margin"
|
android:paddingStart="@dimen/normal_margin"
|
||||||
android:paddingTop="@dimen/activity_margin"
|
android:paddingTop="@dimen/bigger_margin"
|
||||||
android:paddingEnd="@dimen/normal_margin"
|
android:paddingEnd="@dimen/normal_margin"
|
||||||
android:paddingBottom="@dimen/activity_margin">
|
android:paddingBottom="@dimen/bigger_margin">
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyTextView
|
<com.simplemobiletools.commons.views.MyTextView
|
||||||
android:id="@+id/settings_list_widget_view_to_open_label"
|
android:id="@+id/settings_list_widget_view_to_open_label"
|
||||||
@ -872,9 +907,9 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="?attr/selectableItemBackground"
|
android:background="?attr/selectableItemBackground"
|
||||||
android:paddingStart="@dimen/normal_margin"
|
android:paddingStart="@dimen/normal_margin"
|
||||||
android:paddingTop="@dimen/activity_margin"
|
android:paddingTop="@dimen/bigger_margin"
|
||||||
android:paddingEnd="@dimen/normal_margin"
|
android:paddingEnd="@dimen/normal_margin"
|
||||||
android:paddingBottom="@dimen/activity_margin">
|
android:paddingBottom="@dimen/bigger_margin">
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyTextView
|
<com.simplemobiletools.commons.views.MyTextView
|
||||||
android:id="@+id/settings_customize_widget_colors_label"
|
android:id="@+id/settings_customize_widget_colors_label"
|
||||||
@ -910,9 +945,9 @@
|
|||||||
android:layout_marginTop="@dimen/medium_margin"
|
android:layout_marginTop="@dimen/medium_margin"
|
||||||
android:background="?attr/selectableItemBackground"
|
android:background="?attr/selectableItemBackground"
|
||||||
android:paddingStart="@dimen/normal_margin"
|
android:paddingStart="@dimen/normal_margin"
|
||||||
android:paddingTop="@dimen/activity_margin"
|
android:paddingTop="@dimen/bigger_margin"
|
||||||
android:paddingEnd="@dimen/normal_margin"
|
android:paddingEnd="@dimen/normal_margin"
|
||||||
android:paddingBottom="@dimen/activity_margin">
|
android:paddingBottom="@dimen/bigger_margin">
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MySwitchCompat
|
<com.simplemobiletools.commons.views.MySwitchCompat
|
||||||
android:id="@+id/settings_dim_past_events"
|
android:id="@+id/settings_dim_past_events"
|
||||||
|
Reference in New Issue
Block a user