Use 'entered' instead of 'completed' when ? or skips are enabled

pull/1056/head
Quentin Hibon 4 years ago committed by Alinson S. Xavier
parent 7fe3ce970c
commit f8c7abfff4

@ -38,7 +38,7 @@ import org.isoron.uhabits.inject.ActivityContextModule
import org.isoron.uhabits.inject.DaggerHabitsActivityComponent import org.isoron.uhabits.inject.DaggerHabitsActivityComponent
import org.isoron.uhabits.utils.restartWithFade import org.isoron.uhabits.utils.restartWithFade
class ListHabitsActivity : AppCompatActivity() { class ListHabitsActivity : AppCompatActivity(), Preferences.Listener {
var pureBlack: Boolean = false var pureBlack: Boolean = false
lateinit var taskRunner: TaskRunner lateinit var taskRunner: TaskRunner
@ -51,6 +51,10 @@ class ListHabitsActivity : AppCompatActivity() {
private lateinit var menu: ListHabitsMenu private lateinit var menu: ListHabitsMenu
override fun onQuestionMarksChanged() {
invalidateOptionsMenu()
}
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
@ -63,6 +67,7 @@ class ListHabitsActivity : AppCompatActivity() {
component.themeSwitcher.apply() component.themeSwitcher.apply()
prefs = appComponent.preferences prefs = appComponent.preferences
prefs.addListener(this)
pureBlack = prefs.isPureBlackEnabled pureBlack = prefs.isPureBlackEnabled
midnightTimer = appComponent.midnightTimer midnightTimer = appComponent.midnightTimer
rootView = component.listHabitsRootView rootView = component.listHabitsRootView

@ -52,6 +52,11 @@ class ListHabitsMenu @Inject constructor(
nightModeItem.isChecked = themeSwitcher.isNightMode nightModeItem.isChecked = themeSwitcher.isNightMode
hideArchivedItem.isChecked = !preferences.showArchived hideArchivedItem.isChecked = !preferences.showArchived
hideCompletedItem.isChecked = !preferences.showCompleted 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) updateArrows(menu)
} }

@ -131,7 +131,7 @@ class CheckmarkButtonView(
paint.color = when (value) { paint.color = when (value) {
YES_MANUAL, YES_AUTO, SKIP -> color YES_MANUAL, YES_AUTO, SKIP -> color
NO -> { NO -> {
if (preferences.areQuestionMarksEnabled()) mediumContrastColor if (preferences.areQuestionMarksEnabled) mediumContrastColor
else lowContrastColor else lowContrastColor
} }
else -> lowContrastColor else -> lowContrastColor
@ -140,7 +140,7 @@ class CheckmarkButtonView(
SKIP -> R.string.fa_skipped SKIP -> R.string.fa_skipped
NO -> R.string.fa_times NO -> R.string.fa_times
UNKNOWN -> { UNKNOWN -> {
if (preferences.areQuestionMarksEnabled()) R.string.fa_question if (preferences.areQuestionMarksEnabled) R.string.fa_question
else R.string.fa_times else R.string.fa_times
} }
else -> R.string.fa_check else -> R.string.fa_check

@ -169,7 +169,7 @@ class NumberButtonView(
typeface = BOLD_TYPEFACE typeface = BOLD_TYPEFACE
textSize = dim(R.dimen.smallTextSize) textSize = dim(R.dimen.smallTextSize)
} }
preferences.areQuestionMarksEnabled() -> { preferences.areQuestionMarksEnabled -> {
label = resources.getString(R.string.fa_question) label = resources.getString(R.string.fa_question)
typeface = getFontAwesome() typeface = getFontAwesome()
textSize = dim(R.dimen.smallerTextSize) textSize = dim(R.dimen.smallerTextSize)

@ -92,6 +92,9 @@ class SharedPreferencesStorage
preferences.setNotificationsSticky(getBoolean(key, false)) preferences.setNotificationsSticky(getBoolean(key, false))
"pref_led_notifications" -> "pref_led_notifications" ->
preferences.setNotificationsLed(getBoolean(key, false)) preferences.setNotificationsLed(getBoolean(key, false))
"pref_unknown_enabled" -> {
preferences.areQuestionMarksEnabled = getBoolean(key, false)
}
} }
sharedPreferences.registerOnSharedPreferenceChangeListener(this) sharedPreferences.registerOnSharedPreferenceChangeListener(this)
} }

@ -102,7 +102,7 @@ class CheckmarkWidgetView : HabitWidgetView {
SKIP -> resources.getString(R.string.fa_skipped) SKIP -> resources.getString(R.string.fa_skipped)
UNKNOWN -> { UNKNOWN -> {
run { run {
if (preferences!!.areQuestionMarksEnabled()) { if (preferences!!.areQuestionMarksEnabled) {
return resources.getString(R.string.fa_question) return resources.getString(R.string.fa_question)
} else { } else {
resources.getString(R.string.fa_times) resources.getString(R.string.fa_times)

@ -161,6 +161,7 @@
<string name="none">None</string> <string name="none">None</string>
<string name="filter">Filter</string> <string name="filter">Filter</string>
<string name="hide_completed">Hide completed</string> <string name="hide_completed">Hide completed</string>
<string name="hide_entered">Hide entered</string>
<string name="hide_archived">Hide archived</string> <string name="hide_archived">Hide archived</string>
<string name="sticky_notifications">Make notifications sticky</string> <string name="sticky_notifications">Make notifications sticky</string>
<string name="sticky_notifications_description">Prevents notifications from being swiped away.</string> <string name="sticky_notifications_description">Prevents notifications from being swiped away.</string>

@ -205,8 +205,11 @@ open class Preferences(private val storage: Storage) {
storage.putBoolean("pref_skip_enabled", value) storage.putBoolean("pref_skip_enabled", value)
} }
fun areQuestionMarksEnabled(): Boolean { var areQuestionMarksEnabled: Boolean
return storage.getBoolean("pref_unknown_enabled", false) get() = storage.getBoolean("pref_unknown_enabled", false)
set(value) {
storage.putBoolean("pref_unknown_enabled", value)
for (l in listeners) l.onQuestionMarksChanged()
} }
/** /**
@ -240,6 +243,7 @@ open class Preferences(private val storage: Storage) {
interface Listener { interface Listener {
fun onCheckmarkSequenceChanged() {} fun onCheckmarkSequenceChanged() {}
fun onNotificationsChanged() {} fun onNotificationsChanged() {}
fun onQuestionMarksChanged() {}
} }
interface Storage { interface Storage {

Loading…
Cancel
Save