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

This commit is contained in:
Tthecreator
2019-08-12 19:39:44 +02:00
committed by Alinson Xavier
parent ec2fa16fab
commit 3e2cf48223
8 changed files with 44 additions and 54 deletions

View File

@@ -33,12 +33,13 @@ class ListHabitsMenu @Inject constructor(
private val preferences: Preferences,
private val themeSwitcher: ThemeSwitcher,
private val behavior: ListHabitsMenuBehavior
) : BaseMenu(activity) {
) : BaseMenu(activity){
override fun onCreate(menu: Menu) {
val nightModeItem = menu.findItem(R.id.actionToggleNightMode)
val hideArchivedItem = menu.findItem(R.id.actionHideArchived)
val hideCompletedItem = menu.findItem(R.id.actionHideCompleted)
nightModeItem.isChecked = themeSwitcher.isNightMode
hideArchivedItem.isChecked = !preferences.showArchived
hideCompletedItem.isChecked = !preferences.showCompleted
@@ -51,8 +52,13 @@ class ListHabitsMenu @Inject constructor(
return true
}
R.id.actionAdd -> {
behavior.onCreateHabit()
R.id.actionCreateBooleanHabit -> {
behavior.onCreateBooleanHabit()
return true
}
R.id.actionCreateNumeralHabit -> {
behavior.onCreateNumericalHabit()
return true
}

View File

@@ -137,26 +137,14 @@ class ListHabitsScreen
activity.startActivity(intent)
}
fun showCreateBooleanHabitScreen() {
override fun showCreateBooleanHabitScreen() {
val dialog = editHabitDialogFactory.createBoolean()
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 showCreateNumericalHabitScreen() {
val dialog = editHabitDialogFactory.createNumerical()
activity.showDialog(dialog, "editHabit")
}
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) {
taskRunner.execute(importTaskFactory.create(file) { result ->
if (result == ImportDataTask.SUCCESS) {

View File

@@ -18,15 +18,28 @@
-->
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".MainActivity">
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".MainActivity">
<item
android:id="@+id/actionAdd"
android:icon="?iconAdd"
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
android:id="@+id/action_filter"

View File

@@ -184,6 +184,10 @@
<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' -->
<string name="time_every">time in</string>

View File

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