mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-03-03 10:57:41 +01:00
Make weekends highlight color customizable
This commit is contained in:
parent
2683ebf6ed
commit
f8addc7a1e
@ -20,6 +20,7 @@ import com.simplemobiletools.commons.helpers.*
|
||||
import com.simplemobiletools.commons.models.AlarmSound
|
||||
import com.simplemobiletools.commons.models.RadioItem
|
||||
import kotlinx.android.synthetic.main.activity_settings.*
|
||||
import kotlinx.android.synthetic.main.dialog_event_type.view.*
|
||||
import org.joda.time.DateTime
|
||||
import java.io.File
|
||||
import java.io.InputStream
|
||||
@ -51,6 +52,7 @@ class SettingsActivity : SimpleActivity() {
|
||||
setupHourFormat()
|
||||
setupSundayFirst()
|
||||
setupHighlightWeekends()
|
||||
setupHighlightWeekendsColor()
|
||||
setupDeleteAllEvents()
|
||||
setupReplaceDescription()
|
||||
setupWeekNumbers()
|
||||
@ -342,9 +344,22 @@ class SettingsActivity : SimpleActivity() {
|
||||
|
||||
private fun setupHighlightWeekends() {
|
||||
settings_highlight_weekends.isChecked = config.highlightWeekends
|
||||
settings_highlight_weekends_color_holder.beVisibleIf(config.highlightWeekends)
|
||||
settings_highlight_weekends_holder.setOnClickListener {
|
||||
settings_highlight_weekends.toggle()
|
||||
config.highlightWeekends = settings_highlight_weekends.isChecked
|
||||
settings_highlight_weekends_color_holder.beVisibleIf(config.highlightWeekends)
|
||||
}
|
||||
}
|
||||
private fun setupHighlightWeekendsColor() {
|
||||
settings_highlight_weekends_color.setFillWithStroke(config.highlightWeekendsColor, config.backgroundColor)
|
||||
settings_highlight_weekends_color_holder.setOnClickListener {
|
||||
ColorPickerDialog(this, config.highlightWeekendsColor) { wasPositivePressed, color ->
|
||||
if (wasPositivePressed) {
|
||||
config.highlightWeekendsColor = color
|
||||
settings_highlight_weekends_color.setFillWithStroke(color, config.backgroundColor)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -813,6 +828,7 @@ class SettingsActivity : SimpleActivity() {
|
||||
put(USE_24_HOUR_FORMAT, config.use24HourFormat)
|
||||
put(SUNDAY_FIRST, config.isSundayFirst)
|
||||
put(HIGHLIGHT_WEEKENDS, config.highlightWeekends)
|
||||
put(HIGHLIGHT_WEEKENDS_COLOR, config.highlightWeekendsColor)
|
||||
}
|
||||
|
||||
exportSettings(configItems)
|
||||
@ -908,6 +924,7 @@ class SettingsActivity : SimpleActivity() {
|
||||
USE_24_HOUR_FORMAT -> config.use24HourFormat = value.toBoolean()
|
||||
SUNDAY_FIRST -> config.isSundayFirst = value.toBoolean()
|
||||
HIGHLIGHT_WEEKENDS -> config.highlightWeekends = value.toBoolean()
|
||||
HIGHLIGHT_WEEKENDS_COLOR -> config.highlightWeekendsColor = value.toInt()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -230,7 +230,9 @@ class Config(context: Context) : BaseConfig(context) {
|
||||
get() = prefs.getBoolean(HIGHLIGHT_WEEKENDS, false)
|
||||
set(highlightWeekends) = prefs.edit().putBoolean(HIGHLIGHT_WEEKENDS, highlightWeekends).apply()
|
||||
|
||||
val defaultHighlightWeekendsColor = context.resources.getColor(R.color.red_text)
|
||||
|
||||
var highlightWeekendsColor: Int
|
||||
get() = prefs.getInt(HIGHLIGHT_WEEKENDS_COLOR, context.resources.getColor(R.color.red_text))
|
||||
get() = prefs.getInt(HIGHLIGHT_WEEKENDS_COLOR, defaultHighlightWeekendsColor)
|
||||
set(highlightWeekendsColor) = prefs.edit().putInt(HIGHLIGHT_WEEKENDS_COLOR, highlightWeekendsColor).apply()
|
||||
}
|
||||
|
@ -57,6 +57,33 @@
|
||||
android:text="@string/customize_widget_colors" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/settings_highlight_weekends_color_holder"
|
||||
style="@style/SettingsHolderTextViewStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/settings_highlight_weekends_color_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
android:clickable="false"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toStartOf="@+id/settings_highlight_weekends_color"
|
||||
android:text="@string/highlight_weekends_color" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/settings_highlight_weekends_color"
|
||||
android:layout_width="@dimen/color_sample_size"
|
||||
android:layout_height="@dimen/color_sample_size"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginEnd="@dimen/medium_margin"
|
||||
android:clickable="false" />
|
||||
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
|
Loading…
x
Reference in New Issue
Block a user