Option to inverse checkmark widget On/Off colours

pull/2092/head
JollyGood1 8 months ago
parent fc9cc423d0
commit a9978b9716

@ -93,6 +93,8 @@ class SharedPreferencesStorage
"pref_unknown_enabled" -> { "pref_unknown_enabled" -> {
preferences.areQuestionMarksEnabled = getBoolean(key, false) preferences.areQuestionMarksEnabled = getBoolean(key, false)
} }
"pref_inverse_checkmark_colors" ->
preferences.isCheckmarkWidgetColorInverted = getBoolean(key, false)
} }
sharedPreferences.registerOnSharedPreferenceChangeListener(this) sharedPreferences.registerOnSharedPreferenceChangeListener(this)
} }

@ -67,20 +67,45 @@ class CheckmarkWidgetView : HabitWidgetView {
val bgColor: Int val bgColor: Int
val fgColor: Int val fgColor: Int
setShadowAlpha(0x4f) setShadowAlpha(0x4f)
when (entryState) { if (preferences!!.isCheckmarkWidgetColorInverted) {
YES_MANUAL, SKIP, YES_AUTO -> { when (entryState) {
bgColor = activeColor YES_MANUAL, SKIP, YES_AUTO -> {
fgColor = res.getColor(R.attr.contrast0) bgColor = res.getColor(R.attr.cardBgColor)
backgroundPaint!!.color = bgColor fgColor = res.getColor(R.attr.contrast60)
frame!!.setBackgroundDrawable(background) }
}
NO, UNKNOWN -> { NO, UNKNOWN -> {
bgColor = res.getColor(R.attr.cardBgColor) bgColor = activeColor
fgColor = res.getColor(R.attr.contrast60) fgColor = res.getColor(R.attr.contrast0)
backgroundPaint!!.color = bgColor
frame!!.setBackgroundDrawable(background)
}
else -> {
bgColor = activeColor
fgColor = res.getColor(R.attr.contrast0)
backgroundPaint!!.color = bgColor
frame!!.setBackgroundDrawable(background)
}
} }
else -> { } else {
bgColor = res.getColor(R.attr.cardBgColor) when (entryState) {
fgColor = res.getColor(R.attr.contrast60) YES_MANUAL, SKIP, YES_AUTO -> {
bgColor = activeColor
fgColor = res.getColor(R.attr.contrast0)
backgroundPaint!!.color = bgColor
frame!!.setBackgroundDrawable(background)
}
NO, UNKNOWN -> {
bgColor = res.getColor(R.attr.cardBgColor)
fgColor = res.getColor(R.attr.contrast60)
}
else -> {
bgColor = res.getColor(R.attr.cardBgColor)
fgColor = res.getColor(R.attr.contrast60)
}
} }
} }
ring.setPercentage(percentage) ring.setPercentage(percentage)

@ -233,4 +233,6 @@
<string name="activity_not_found">No app was found to support this action</string> <string name="activity_not_found">No app was found to support this action</string>
<string name="pref_midnight_delay_title">Extend day a few hours past midnight</string> <string name="pref_midnight_delay_title">Extend day a few hours past midnight</string>
<string name="pref_midnight_delay_description">Wait until 3:00 AM to show a new day. Useful if you typically go to sleep after midnight. Requires app restart.</string> <string name="pref_midnight_delay_description">Wait until 3:00 AM to show a new day. Useful if you typically go to sleep after midnight. Requires app restart.</string>
<string name="pref_inverse_checkmark_colors_title">Inverse checkmark widget colors</string>
<string name="pref_inverse_checkmark_colors_description">Make the checkmark widget looked turn off once the task is done.</string>
</resources> </resources>

@ -81,6 +81,13 @@
android:title="@string/first_day_of_the_week" android:title="@string/first_day_of_the_week"
app:iconSpaceReserved="false" /> app:iconSpaceReserved="false" />
<SwitchPreferenceCompat
android:defaultValue="false"
android:key="pref_inverse_checkmark_colors"
android:summary="@string/pref_inverse_checkmark_colors_description"
android:title="@string/pref_inverse_checkmark_colors_title"
app:iconSpaceReserved="false" />
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory <PreferenceCategory

@ -205,6 +205,13 @@ open class Preferences(private val storage: Storage) {
for (l in listeners) l.onQuestionMarksChanged() for (l in listeners) l.onQuestionMarksChanged()
} }
var isCheckmarkWidgetColorInverted: Boolean
get() = storage.getBoolean("pref_inverse_checkmark_colors", false)
set(value) {
storage.putBoolean("pref_inverse_checkmark_colors", value)
for (l in listeners) l.onCheckmarkColorsChanged()
}
/** /**
* @return An integer representing the first day of the week. Sunday * @return An integer representing the first day of the week. Sunday
* corresponds to 1, Monday to 2, and so on, until Saturday, which is * corresponds to 1, Monday to 2, and so on, until Saturday, which is
@ -237,6 +244,7 @@ open class Preferences(private val storage: Storage) {
fun onCheckmarkSequenceChanged() {} fun onCheckmarkSequenceChanged() {}
fun onNotificationsChanged() {} fun onNotificationsChanged() {}
fun onQuestionMarksChanged() {} fun onQuestionMarksChanged() {}
fun onCheckmarkColorsChanged() {}
} }
interface Storage { interface Storage {

Loading…
Cancel
Save