@ -46,21 +46,11 @@ class ListHabitsMenu @Inject constructor(
hideArchivedItem . isChecked = ! preferences . showArchived
hideCompletedItem . isChecked = ! preferences . showCompleted
topBarMenu = menu
//the habit creation menu should be disabled when numeric habits are also disabled
if ( ! preferences . isNumericalHabitsFeatureEnabled ) {
setCreateHabitMenuEnabled ( false , menu )
}
//let the class add itself as listener
preferences . addListener ( this )
}
override fun onNumericalHabitsFeatureChanged ( ) {
if ( topBarMenu == null ) { return }
setCreateHabitMenuEnabled ( preferences . isNumericalHabitsFeatureEnabled , topBarMenu )
}
override fun onItemSelected ( item : MenuItem ) : Boolean {
when ( item . itemId ) {
R . id . actionToggleNightMode -> {
@ -68,11 +58,6 @@ class ListHabitsMenu @Inject constructor(
return true
}
R . id . actionAdd -> {
behavior . onCreateHabit ( )
return true
}
R . id . actionCreateBooleanHabit -> {
behavior . onCreateBooleanHabit ( )
return true
@ -138,6 +123,7 @@ class ListHabitsMenu @Inject constructor(
* @param enabled whether the create habit menu should be enabled or disabled
* @param menu a reference to the menu on which should be enabled or disabled
* /
@Deprecated ( message = " This function was used to enable/disable the habit creation drop down menu, but since the feature is mostly implemented this is no longer necessary. " )
fun setCreateHabitMenuEnabled ( enabled : Boolean , menu : Menu ) {
val habitCreationMenu = menu . findItem ( R . id . actionAdd ) . subMenu
for ( itemIndex : Int in 0 until habitCreationMenu . size ( ) ) {