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
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()) {

@ -147,23 +147,6 @@ class ListHabitsScreen
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) {
activity.showDialog(confirmDeleteDialogFactory.create(callback))
}

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

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

@ -224,17 +224,6 @@ public class Preferences
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()
{
return storage.getBoolean("pref_pure_black", false);

@ -61,19 +61,6 @@ public class ListHabitsMenuBehavior
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()
{
screen.showCreateBooleanHabitScreen();
@ -163,8 +150,6 @@ public class ListHabitsMenuBehavior
void showAboutScreen();
void showCreateHabitScreen();
void showCreateBooleanHabitScreen();
void showCreateNumericalHabitScreen();

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

Loading…
Cancel
Save