adding a settings item for dimming past events

This commit is contained in:
tibbi 2018-05-04 21:04:30 +02:00
parent 0650491ce7
commit 135d2bc8c2
4 changed files with 77 additions and 23 deletions

View File

@ -60,6 +60,7 @@ class SettingsActivity : SimpleActivity() {
setupDisplayPastEvents()
setupFontSize()
setupCustomizeWidgetColors()
setupDimEvents()
updateTextColors(settings_holder)
checkPrimaryColor()
setupSectionColors()
@ -84,7 +85,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, simple_font_size_label).forEach {
arrayListOf(reminders_label, caldav_label, weekly_view_label, monthly_view_label, simple_event_list_label, simple_font_size_label, events_label).forEach {
it.setTextColor(adjustedPrimaryColor)
}
}
@ -409,6 +410,14 @@ class SettingsActivity : SimpleActivity() {
}
}
private fun setupDimEvents() {
settings_dim_past_events.isChecked = config.dimPastEvents
settings_dim_past_events_holder.setOnClickListener {
settings_dim_past_events.toggle()
config.dimPastEvents = settings_dim_past_events.isChecked
}
}
override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) {
super.onActivityResult(requestCode, resultCode, resultData)
if (requestCode == GET_RINGTONE_URI && resultCode == RESULT_OK && resultData != null) {

View File

@ -97,6 +97,10 @@ class Config(context: Context) : BaseConfig(context) {
get() = prefs.getBoolean(LOOP_REMINDERS, false)
set(loopReminders) = prefs.edit().putBoolean(LOOP_REMINDERS, loopReminders).apply()
var dimPastEvents: Boolean
get() = prefs.getBoolean(DIM_PAST_EVENTS, true)
set(dimPastEvents) = prefs.edit().putBoolean(DIM_PAST_EVENTS, dimPastEvents).apply()
fun getSyncedCalendarIdsAsList() = caldavSyncedCalendarIDs.split(",").filter { it.trim().isNotEmpty() } as ArrayList<String>
fun addDisplayEventType(type: String) {

View File

@ -51,6 +51,7 @@ const val REPLACE_DESCRIPTION = "replace_description"
const val SHOW_GRID = "show_grid"
const val IS_CUSTOMIZING_COLORS = "is_customizing_colors"
const val LOOP_REMINDERS = "loop_reminders"
const val DIM_PAST_EVENTS = "dim_past_events"
// repeat_rule for monthly repetition
const val REPEAT_MONTH_SAME_DAY = 1 // ie 25th every month

View File

@ -147,28 +147,6 @@
</RelativeLayout>
<RelativeLayout
android:id="@+id/settings_delete_all_events_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/medium_margin"
android:background="?attr/selectableItemBackground"
android:paddingBottom="@dimen/bigger_margin"
android:paddingLeft="@dimen/normal_margin"
android:paddingRight="@dimen/normal_margin"
android:paddingTop="@dimen/bigger_margin">
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/settings_delete_all_events"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:paddingLeft="@dimen/medium_margin"
android:paddingRight="@dimen/medium_margin"
android:text="@string/delete_all_events"/>
</RelativeLayout>
<View
android:id="@+id/reminders_divider"
android:layout_width="match_parent"
@ -688,5 +666,67 @@
android:text="@string/customize_widget_colors"/>
</RelativeLayout>
<View
android:id="@+id/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/events_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/bigger_margin"
android:layout_marginStart="@dimen/bigger_margin"
android:layout_marginTop="@dimen/activity_margin"
android:text="@string/event_reminders"
android:textAllCaps="true"
android:textSize="@dimen/smaller_text_size"/>
<RelativeLayout
android:id="@+id/settings_dim_past_events_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/medium_margin"
android:background="?attr/selectableItemBackground"
android:paddingBottom="@dimen/activity_margin"
android:paddingLeft="@dimen/normal_margin"
android:paddingRight="@dimen/normal_margin"
android:paddingTop="@dimen/activity_margin">
<com.simplemobiletools.commons.views.MySwitchCompat
android:id="@+id/settings_dim_past_events"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:clickable="false"
android:paddingLeft="@dimen/medium_margin"
android:paddingStart="@dimen/medium_margin"
android:text="@string/dim_past_events"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/settings_delete_all_events_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:paddingBottom="@dimen/bigger_margin"
android:paddingLeft="@dimen/normal_margin"
android:paddingRight="@dimen/normal_margin"
android:paddingTop="@dimen/bigger_margin">
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/settings_delete_all_events"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:paddingLeft="@dimen/medium_margin"
android:paddingRight="@dimen/medium_margin"
android:text="@string/delete_all_events"/>
</RelativeLayout>
</LinearLayout>
</ScrollView>