Removed the "numerical habits enabled" setting

pull/498/head
thomas 6 years ago
parent ef22fd8dce
commit c60b2e0511

@ -46,21 +46,11 @@ class ListHabitsMenu @Inject constructor(
hideArchivedItem.isChecked = !preferences.showArchived hideArchivedItem.isChecked = !preferences.showArchived
hideCompletedItem.isChecked = !preferences.showCompleted hideCompletedItem.isChecked = !preferences.showCompleted
topBarMenu = menu 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 //let the class add itself as listener
preferences.addListener(this) preferences.addListener(this)
} }
override fun onNumericalHabitsFeatureChanged() {
if(topBarMenu==null){return}
setCreateHabitMenuEnabled(preferences.isNumericalHabitsFeatureEnabled, topBarMenu)
}
override fun onItemSelected(item: MenuItem): Boolean { override fun onItemSelected(item: MenuItem): Boolean {
when (item.itemId) { when (item.itemId) {
R.id.actionToggleNightMode -> { R.id.actionToggleNightMode -> {
@ -68,11 +58,6 @@ class ListHabitsMenu @Inject constructor(
return true return true
} }
R.id.actionAdd -> {
behavior.onCreateHabit()
return true
}
R.id.actionCreateBooleanHabit -> { R.id.actionCreateBooleanHabit -> {
behavior.onCreateBooleanHabit() behavior.onCreateBooleanHabit()
return true return true
@ -138,6 +123,7 @@ class ListHabitsMenu @Inject constructor(
* @param enabled whether the create habit menu should be enabled or disabled * @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 * @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) { fun setCreateHabitMenuEnabled(enabled: Boolean, menu: Menu) {
val habitCreationMenu = menu.findItem(R.id.actionAdd).subMenu val habitCreationMenu = menu.findItem(R.id.actionAdd).subMenu
for (itemIndex: Int in 0 until habitCreationMenu.size()) { for (itemIndex: Int in 0 until habitCreationMenu.size()) {

@ -147,23 +147,6 @@ class ListHabitsScreen
activity.showDialog(dialog, "editHabit") activity.showDialog(dialog, "editHabit")
} }
override fun showCreateHabitScreen() {
if (!preferences.isNumericalHabitsFeatureEnabled) {
showCreateBooleanHabitScreen()
return
}
val dialog = AlertDialog.Builder(activity)
.setTitle("Type of habit")
.setItems(R.array.habitTypes) { _, which ->
if (which == 0) showCreateBooleanHabitScreen()
else showCreateNumericalHabitScreen()
}
.create()
dialog.show()
}
override fun showDeleteConfirmationScreen(callback: OnConfirmedCallback) { override fun showDeleteConfirmationScreen(callback: OnConfirmedCallback) {
activity.showDialog(confirmDeleteDialogFactory.create(callback)) activity.showDialog(confirmDeleteDialogFactory.create(callback))
} }

@ -89,8 +89,6 @@ class SharedPreferencesStorage
preferences.setNotificationsLed(getBoolean(key, false)) preferences.setNotificationsLed(getBoolean(key, false))
"pref_feature_sync" -> "pref_feature_sync" ->
preferences.isSyncEnabled = getBoolean(key, false) preferences.isSyncEnabled = getBoolean(key, false)
"pref_feature_numerical_habits" ->
preferences.isNumericalHabitsFeatureEnabled = getBoolean(key, false)
} }
sharedPreferences.registerOnSharedPreferenceChangeListener(this) sharedPreferences.registerOnSharedPreferenceChangeListener(this)
} }

@ -32,12 +32,12 @@
<item <item
android:id="@+id/actionCreateBooleanHabit" android:id="@+id/actionCreateBooleanHabit"
android:enabled="true" android:enabled="true"
android:title="@string/yes_or_no" /> android:title="@string/yes_or_no"/>
<item <item
android:id="@+id/actionCreateNumeralHabit" android:id="@+id/actionCreateNumeralHabit"
android:enabled="true" android:enabled="true"
android:title="@string/number" /> android:title="@string/number"/>
</menu> </menu>
</item> </item>
@ -51,31 +51,31 @@
android:id="@+id/actionHideArchived" android:id="@+id/actionHideArchived"
android:checkable="true" android:checkable="true"
android:enabled="true" android:enabled="true"
android:title="@string/hide_archived" /> android:title="@string/hide_archived"/>
<item <item
android:id="@+id/actionHideCompleted" android:id="@+id/actionHideCompleted"
android:checkable="true" android:checkable="true"
android:enabled="true" android:enabled="true"
android:title="@string/hide_completed" /> android:title="@string/hide_completed"/>
<item android:title="@string/sort"> <item android:title="@string/sort">
<menu> <menu>
<item <item
android:id="@+id/actionSortManual" android:id="@+id/actionSortManual"
android:title="@string/manually" /> android:title="@string/manually"/>
<item <item
android:id="@+id/actionSortName" android:id="@+id/actionSortName"
android:title="@string/by_name" /> android:title="@string/by_name"/>
<item <item
android:id="@+id/actionSortColor" android:id="@+id/actionSortColor"
android:title="@string/by_color" /> android:title="@string/by_color"/>
<item <item
android:id="@+id/actionSortScore" android:id="@+id/actionSortScore"
android:title="@string/by_score" /> android:title="@string/by_score"/>
</menu> </menu>
</item> </item>
</menu> </menu>
@ -87,23 +87,23 @@
android:enabled="true" android:enabled="true"
android:orderInCategory="50" android:orderInCategory="50"
android:title="@string/night_mode" android:title="@string/night_mode"
app:showAsAction="never" /> app:showAsAction="never"/>
<item <item
android:id="@+id/actionSettings" android:id="@+id/actionSettings"
android:orderInCategory="100" android:orderInCategory="100"
android:title="@string/action_settings" android:title="@string/action_settings"
app:showAsAction="never" /> app:showAsAction="never"/>
<item <item
android:id="@+id/actionFAQ" android:id="@+id/actionFAQ"
android:orderInCategory="100" android:orderInCategory="100"
android:title="@string/help" android:title="@string/help"
app:showAsAction="never" /> app:showAsAction="never"/>
<item <item
android:id="@+id/actionAbout" android:id="@+id/actionAbout"
android:orderInCategory="100" android:orderInCategory="100"
android:title="@string/about" android:title="@string/about"
app:showAsAction="never" /> app:showAsAction="never"/>
</menu> </menu>

@ -153,11 +153,6 @@
android:key="pref_developer" android:key="pref_developer"
android:title="Enable developer mode"/> android:title="Enable developer mode"/>
<CheckBoxPreference
android:defaultValue="false"
android:key="pref_feature_numerical_habits"
android:title="Enable numerical habits"/>
<CheckBoxPreference <CheckBoxPreference
android:defaultValue="false" android:defaultValue="false"
android:key="pref_feature_sync" android:key="pref_feature_sync"

@ -224,17 +224,6 @@ public class Preferences
storage.putBoolean("pref_first_run", isFirstRun); storage.putBoolean("pref_first_run", isFirstRun);
} }
public boolean isNumericalHabitsFeatureEnabled()
{
return storage.getBoolean("pref_feature_numerical_habits", false);
}
public void setNumericalHabitsFeatureEnabled(boolean enabled)
{
storage.putBoolean("pref_feature_numerical_habits", enabled);
for (Listener l : listeners) l.onNumericalHabitsFeatureChanged();
}
public boolean isPureBlackEnabled() public boolean isPureBlackEnabled()
{ {
return storage.getBoolean("pref_pure_black", false); return storage.getBoolean("pref_pure_black", false);

@ -61,19 +61,6 @@ public class ListHabitsMenuBehavior
updateAdapterFilter(); updateAdapterFilter();
} }
/**
* This function is called when a new habit should be created. (A dialog will be created)
* When only a single type of habit type exists (e.g. the numeral habits feature is disabled) a menu is spawned directly.
* If this is not the case however, a dropdown menu is shown.
*/
public void onCreateHabit()
{
if(!preferences.isNumericalHabitsFeatureEnabled())
{
screen.showCreateHabitScreen();
}
}
public void onCreateBooleanHabit() public void onCreateBooleanHabit()
{ {
screen.showCreateBooleanHabitScreen(); screen.showCreateBooleanHabitScreen();
@ -163,8 +150,6 @@ public class ListHabitsMenuBehavior
void showAboutScreen(); void showAboutScreen();
void showCreateHabitScreen();
void showCreateBooleanHabitScreen(); void showCreateBooleanHabitScreen();
void showCreateNumericalHabitScreen(); void showCreateNumericalHabitScreen();

@ -196,14 +196,6 @@ public class PreferencesTest extends BaseUnitTest
assertTrue(prefs.isShortToggleEnabled()); assertTrue(prefs.isShortToggleEnabled());
} }
@Test
public void testNumericalHabits() throws Exception
{
assertFalse(prefs.isNumericalHabitsFeatureEnabled());
prefs.setNumericalHabitsFeatureEnabled(true);
assertTrue(prefs.isNumericalHabitsFeatureEnabled());
}
@Test @Test
public void testDeveloper() throws Exception public void testDeveloper() throws Exception
{ {

Loading…
Cancel
Save