mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 01:08:50 -06:00
Create switch for numerical habits feature
This commit is contained in:
@@ -100,8 +100,8 @@ public class EditHabitDialog extends AppCompatDialogFragment
|
||||
initDependencies();
|
||||
ButterKnife.bind(this, view);
|
||||
|
||||
getDialog().setTitle(getTitle());
|
||||
originalHabit = parseHabitFromArguments();
|
||||
getDialog().setTitle(getTitle());
|
||||
|
||||
populateForm();
|
||||
setupReminderController();
|
||||
@@ -112,7 +112,7 @@ public class EditHabitDialog extends AppCompatDialogFragment
|
||||
|
||||
protected int getTitle()
|
||||
{
|
||||
if (originalHabit == null) return R.string.edit_habit;
|
||||
if (originalHabit != null) return R.string.edit_habit;
|
||||
else return R.string.create_habit;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.isoron.uhabits.commands.*;
|
||||
import org.isoron.uhabits.intents.*;
|
||||
import org.isoron.uhabits.io.*;
|
||||
import org.isoron.uhabits.models.*;
|
||||
import org.isoron.uhabits.preferences.*;
|
||||
import org.isoron.uhabits.utils.*;
|
||||
|
||||
import java.io.*;
|
||||
@@ -94,6 +95,9 @@ public class ListHabitsScreen extends BaseScreen
|
||||
@NonNull
|
||||
private final ThemeSwitcher themeSwitcher;
|
||||
|
||||
@NonNull
|
||||
private Preferences prefs;
|
||||
|
||||
@Inject
|
||||
public ListHabitsScreen(@NonNull BaseActivity activity,
|
||||
@NonNull CommandRunner commandRunner,
|
||||
@@ -104,10 +108,12 @@ public class ListHabitsScreen extends BaseScreen
|
||||
@NonNull ConfirmDeleteDialogFactory confirmDeleteDialogFactory,
|
||||
@NonNull FilePickerDialogFactory filePickerDialogFactory,
|
||||
@NonNull ColorPickerDialogFactory colorPickerFactory,
|
||||
@NonNull EditHabitDialogFactory editHabitDialogFactory)
|
||||
@NonNull EditHabitDialogFactory editHabitDialogFactory,
|
||||
@NonNull Preferences prefs)
|
||||
{
|
||||
super(activity);
|
||||
setRootView(rootView);
|
||||
this.prefs = prefs;
|
||||
this.colorPickerFactory = colorPickerFactory;
|
||||
this.commandRunner = commandRunner;
|
||||
this.confirmDeleteDialogFactory = confirmDeleteDialogFactory;
|
||||
@@ -173,6 +179,12 @@ public class ListHabitsScreen extends BaseScreen
|
||||
|
||||
public void showCreateHabitScreen()
|
||||
{
|
||||
if(!prefs.isNumericalHabitsFeatureEnabled())
|
||||
{
|
||||
showCreateBooleanHabitScreen();
|
||||
return;
|
||||
}
|
||||
|
||||
Dialog dialog = new AlertDialog.Builder(activity)
|
||||
.setTitle("Type of habit")
|
||||
.setItems(R.array.habitTypes, (d, which) -> {
|
||||
|
||||
@@ -77,6 +77,11 @@ public class Preferences
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isNumericalHabitsFeatureEnabled()
|
||||
{
|
||||
return prefs.getBoolean("pref_feature_numerical_habits", false);
|
||||
}
|
||||
|
||||
public void setDefaultOrder(HabitList.Order order)
|
||||
{
|
||||
prefs.edit().putString("pref_default_order", order.name()).apply();
|
||||
|
||||
@@ -142,6 +142,11 @@
|
||||
android:key="pref_developer"
|
||||
android:title="Enable developer mode"/>
|
||||
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="pref_feature_numerical_habits"
|
||||
android:title="Enable numerical habits"/>
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
||||
Reference in New Issue
Block a user