mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
Use 'entered' instead of 'completed' when ? or skips are enabled
This commit is contained in:
@@ -38,7 +38,7 @@ import org.isoron.uhabits.inject.ActivityContextModule
|
||||
import org.isoron.uhabits.inject.DaggerHabitsActivityComponent
|
||||
import org.isoron.uhabits.utils.restartWithFade
|
||||
|
||||
class ListHabitsActivity : AppCompatActivity() {
|
||||
class ListHabitsActivity : AppCompatActivity(), Preferences.Listener {
|
||||
|
||||
var pureBlack: Boolean = false
|
||||
lateinit var taskRunner: TaskRunner
|
||||
@@ -51,6 +51,10 @@ class ListHabitsActivity : AppCompatActivity() {
|
||||
|
||||
private lateinit var menu: ListHabitsMenu
|
||||
|
||||
override fun onQuestionMarksChanged() {
|
||||
invalidateOptionsMenu()
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
@@ -63,6 +67,7 @@ class ListHabitsActivity : AppCompatActivity() {
|
||||
component.themeSwitcher.apply()
|
||||
|
||||
prefs = appComponent.preferences
|
||||
prefs.addListener(this)
|
||||
pureBlack = prefs.isPureBlackEnabled
|
||||
midnightTimer = appComponent.midnightTimer
|
||||
rootView = component.listHabitsRootView
|
||||
|
||||
@@ -52,6 +52,11 @@ class ListHabitsMenu @Inject constructor(
|
||||
nightModeItem.isChecked = themeSwitcher.isNightMode
|
||||
hideArchivedItem.isChecked = !preferences.showArchived
|
||||
hideCompletedItem.isChecked = !preferences.showCompleted
|
||||
if (preferences.areQuestionMarksEnabled || preferences.isSkipEnabled) {
|
||||
hideCompletedItem.title = activity.resources.getString(R.string.hide_entered)
|
||||
} else {
|
||||
hideCompletedItem.title = activity.resources.getString(R.string.hide_completed)
|
||||
}
|
||||
updateArrows(menu)
|
||||
}
|
||||
|
||||
|
||||
@@ -131,7 +131,7 @@ class CheckmarkButtonView(
|
||||
paint.color = when (value) {
|
||||
YES_MANUAL, YES_AUTO, SKIP -> color
|
||||
NO -> {
|
||||
if (preferences.areQuestionMarksEnabled()) mediumContrastColor
|
||||
if (preferences.areQuestionMarksEnabled) mediumContrastColor
|
||||
else lowContrastColor
|
||||
}
|
||||
else -> lowContrastColor
|
||||
@@ -140,7 +140,7 @@ class CheckmarkButtonView(
|
||||
SKIP -> R.string.fa_skipped
|
||||
NO -> R.string.fa_times
|
||||
UNKNOWN -> {
|
||||
if (preferences.areQuestionMarksEnabled()) R.string.fa_question
|
||||
if (preferences.areQuestionMarksEnabled) R.string.fa_question
|
||||
else R.string.fa_times
|
||||
}
|
||||
else -> R.string.fa_check
|
||||
|
||||
@@ -169,7 +169,7 @@ class NumberButtonView(
|
||||
typeface = BOLD_TYPEFACE
|
||||
textSize = dim(R.dimen.smallTextSize)
|
||||
}
|
||||
preferences.areQuestionMarksEnabled() -> {
|
||||
preferences.areQuestionMarksEnabled -> {
|
||||
label = resources.getString(R.string.fa_question)
|
||||
typeface = getFontAwesome()
|
||||
textSize = dim(R.dimen.smallerTextSize)
|
||||
|
||||
@@ -92,6 +92,9 @@ class SharedPreferencesStorage
|
||||
preferences.setNotificationsSticky(getBoolean(key, false))
|
||||
"pref_led_notifications" ->
|
||||
preferences.setNotificationsLed(getBoolean(key, false))
|
||||
"pref_unknown_enabled" -> {
|
||||
preferences.areQuestionMarksEnabled = getBoolean(key, false)
|
||||
}
|
||||
}
|
||||
sharedPreferences.registerOnSharedPreferenceChangeListener(this)
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ class CheckmarkWidgetView : HabitWidgetView {
|
||||
SKIP -> resources.getString(R.string.fa_skipped)
|
||||
UNKNOWN -> {
|
||||
run {
|
||||
if (preferences!!.areQuestionMarksEnabled()) {
|
||||
if (preferences!!.areQuestionMarksEnabled) {
|
||||
return resources.getString(R.string.fa_question)
|
||||
} else {
|
||||
resources.getString(R.string.fa_times)
|
||||
|
||||
@@ -161,6 +161,7 @@
|
||||
<string name="none">None</string>
|
||||
<string name="filter">Filter</string>
|
||||
<string name="hide_completed">Hide completed</string>
|
||||
<string name="hide_entered">Hide entered</string>
|
||||
<string name="hide_archived">Hide archived</string>
|
||||
<string name="sticky_notifications">Make notifications sticky</string>
|
||||
<string name="sticky_notifications_description">Prevents notifications from being swiped away.</string>
|
||||
|
||||
@@ -205,9 +205,12 @@ open class Preferences(private val storage: Storage) {
|
||||
storage.putBoolean("pref_skip_enabled", value)
|
||||
}
|
||||
|
||||
fun areQuestionMarksEnabled(): Boolean {
|
||||
return storage.getBoolean("pref_unknown_enabled", false)
|
||||
}
|
||||
var areQuestionMarksEnabled: Boolean
|
||||
get() = storage.getBoolean("pref_unknown_enabled", false)
|
||||
set(value) {
|
||||
storage.putBoolean("pref_unknown_enabled", value)
|
||||
for (l in listeners) l.onQuestionMarksChanged()
|
||||
}
|
||||
|
||||
/**
|
||||
* @return An integer representing the first day of the week. Sunday
|
||||
@@ -240,6 +243,7 @@ open class Preferences(private val storage: Storage) {
|
||||
interface Listener {
|
||||
fun onCheckmarkSequenceChanged() {}
|
||||
fun onNotificationsChanged() {}
|
||||
fun onQuestionMarksChanged() {}
|
||||
}
|
||||
|
||||
interface Storage {
|
||||
|
||||
Reference in New Issue
Block a user