Changed habit type selection to dropdown instead of popup message (#498)

pull/504/head
Tthecreator 6 years ago committed by Alinson Xavier
parent ec2fa16fab
commit 3e2cf48223

@ -39,6 +39,7 @@ class ListHabitsMenu @Inject constructor(
val nightModeItem = menu.findItem(R.id.actionToggleNightMode) val nightModeItem = menu.findItem(R.id.actionToggleNightMode)
val hideArchivedItem = menu.findItem(R.id.actionHideArchived) val hideArchivedItem = menu.findItem(R.id.actionHideArchived)
val hideCompletedItem = menu.findItem(R.id.actionHideCompleted) val hideCompletedItem = menu.findItem(R.id.actionHideCompleted)
nightModeItem.isChecked = themeSwitcher.isNightMode nightModeItem.isChecked = themeSwitcher.isNightMode
hideArchivedItem.isChecked = !preferences.showArchived hideArchivedItem.isChecked = !preferences.showArchived
hideCompletedItem.isChecked = !preferences.showCompleted hideCompletedItem.isChecked = !preferences.showCompleted
@ -51,8 +52,13 @@ class ListHabitsMenu @Inject constructor(
return true return true
} }
R.id.actionAdd -> { R.id.actionCreateBooleanHabit -> {
behavior.onCreateHabit() behavior.onCreateBooleanHabit()
return true
}
R.id.actionCreateNumeralHabit -> {
behavior.onCreateNumericalHabit()
return true return true
} }

@ -137,26 +137,14 @@ class ListHabitsScreen
activity.startActivity(intent) activity.startActivity(intent)
} }
fun showCreateBooleanHabitScreen() { override fun showCreateBooleanHabitScreen() {
val dialog = editHabitDialogFactory.createBoolean() val dialog = editHabitDialogFactory.createBoolean()
activity.showDialog(dialog, "editHabit") activity.showDialog(dialog, "editHabit")
} }
override fun showCreateHabitScreen() { override fun showCreateNumericalHabitScreen() {
if (!preferences.isNumericalHabitsFeatureEnabled) { val dialog = editHabitDialogFactory.createNumerical()
showCreateBooleanHabitScreen() activity.showDialog(dialog, "editHabit")
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) {
@ -236,11 +224,6 @@ class ListHabitsScreen
} }
} }
private fun showCreateNumericalHabitScreen() {
val dialog = editHabitDialogFactory.createNumerical()
activity.showDialog(dialog, "editHabit")
}
private fun onImportData(file: File, onFinished: () -> Unit) { private fun onImportData(file: File, onFinished: () -> Unit) {
taskRunner.execute(importTaskFactory.create(file) { result -> taskRunner.execute(importTaskFactory.create(file) { result ->
if (result == ImportDataTask.SUCCESS) { if (result == ImportDataTask.SUCCESS) {

@ -26,7 +26,20 @@
android:id="@+id/actionAdd" android:id="@+id/actionAdd"
android:icon="?iconAdd" android:icon="?iconAdd"
android:title="@string/add_habit" android:title="@string/add_habit"
app:showAsAction="always"/> app:showAsAction="always">
<menu android:id="@+id/createHabitMenu">
<item
android:id="@+id/actionCreateBooleanHabit"
android:enabled="true"
android:title="@string/yes_or_no"/>
<item
android:id="@+id/actionCreateNumeralHabit"
android:enabled="true"
android:title="@string/number"/>
</menu>
</item>
<item <item
android:id="@+id/action_filter" android:id="@+id/action_filter"

@ -184,6 +184,10 @@
<string name="total">Total</string> <string name="total">Total</string>
<!-- Different types of habits -->
<string name="yes_or_no">Yes or No</string>
<string name="number">Number</string>
<!-- Middle part of the sentence '1 time in xx days' --> <!-- Middle part of the sentence '1 time in xx days' -->
<string name="time_every">time in</string> <string name="time_every">time in</string>

@ -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,16 +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);
}
public boolean isPureBlackEnabled() public boolean isPureBlackEnabled()
{ {
return storage.getBoolean("pref_pure_black", false); return storage.getBoolean("pref_pure_black", false);

@ -61,9 +61,14 @@ public class ListHabitsMenuBehavior
updateAdapterFilter(); updateAdapterFilter();
} }
public void onCreateHabit() public void onCreateBooleanHabit()
{ {
screen.showCreateHabitScreen(); screen.showCreateBooleanHabitScreen();
}
public void onCreateNumericalHabit()
{
screen.showCreateNumericalHabitScreen();
} }
public void onViewFAQ() public void onViewFAQ()
@ -145,7 +150,9 @@ public class ListHabitsMenuBehavior
void showAboutScreen(); void showAboutScreen();
void showCreateHabitScreen(); void showCreateBooleanHabitScreen();
void showCreateNumericalHabitScreen();
void showFAQScreen(); void showFAQScreen();

@ -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