diff --git a/android/uhabits-android/src/main/java/org/isoron/uhabits/activities/habits/edit/EditHabitActivity.kt b/android/uhabits-android/src/main/java/org/isoron/uhabits/activities/habits/edit/EditHabitActivity.kt
index 0a68e8324..2ffef62e1 100644
--- a/android/uhabits-android/src/main/java/org/isoron/uhabits/activities/habits/edit/EditHabitActivity.kt
+++ b/android/uhabits-android/src/main/java/org/isoron/uhabits/activities/habits/edit/EditHabitActivity.kt
@@ -44,6 +44,7 @@ class EditHabitActivity : AppCompatActivity() {
private lateinit var commandRunner: CommandRunner
var habitId = -1L
+ var habitType = -1
var paletteColor = 11
var androidColor = 0
var freqNum = 1
@@ -66,6 +67,7 @@ class EditHabitActivity : AppCompatActivity() {
binding.toolbar.title = getString(R.string.edit_habit)
habitId = intent.getLongExtra("habitId", -1)
val habit = component.habitList.getById(habitId)!!
+ habitType = habit.type
paletteColor = habit.color
freqNum = habit.frequency.numerator
freqDen = habit.frequency.denominator
@@ -77,10 +79,13 @@ class EditHabitActivity : AppCompatActivity() {
binding.nameInput.setText(habit.name)
binding.questionInput.setText(habit.question)
binding.notesInput.setText(habit.description)
+ } else {
+ habitType = intent.getIntExtra("habitType", Habit.YES_NO_HABIT)
}
if (state != null) {
habitId = state.getLong("habitId")
+ habitType = state.getInt("habitType")
paletteColor = state.getInt("paletteColor")
freqNum = state.getInt("freqNum")
freqDen = state.getInt("freqDen")
@@ -91,6 +96,15 @@ class EditHabitActivity : AppCompatActivity() {
updateColors()
+ if (habitType == Habit.YES_NO_HABIT) {
+ binding.unitOuterBox.visibility = View.GONE
+ binding.targetOuterBox.visibility = View.GONE
+ } else {
+ binding.nameInput.hint = getString(R.string.measurable_short_example)
+ binding.questionInput.hint = getString(R.string.measurable_question_example)
+ binding.frequencyOuterBox.visibility = View.GONE
+ }
+
setSupportActionBar(binding.toolbar)
supportActionBar?.setDisplayHomeAsUpEnabled(true)
supportActionBar?.setDisplayShowHomeEnabled(true)
@@ -238,6 +252,7 @@ class EditHabitActivity : AppCompatActivity() {
super.onSaveInstanceState(state)
with(state) {
putLong("habitId", habitId)
+ putInt("habitType", habitType)
putInt("paletteColor", paletteColor)
putInt("androidColor", androidColor)
putInt("freqNum", freqNum)
diff --git a/android/uhabits-android/src/main/java/org/isoron/uhabits/activities/habits/edit/HabitTypeDialog.kt b/android/uhabits-android/src/main/java/org/isoron/uhabits/activities/habits/edit/HabitTypeDialog.kt
index b32db971e..39e8dfb4c 100644
--- a/android/uhabits-android/src/main/java/org/isoron/uhabits/activities/habits/edit/HabitTypeDialog.kt
+++ b/android/uhabits-android/src/main/java/org/isoron/uhabits/activities/habits/edit/HabitTypeDialog.kt
@@ -23,6 +23,7 @@ import android.os.*
import android.view.*
import androidx.appcompat.app.*
import org.isoron.uhabits.*
+import org.isoron.uhabits.core.models.*
import org.isoron.uhabits.databinding.*
import org.isoron.uhabits.intents.*
@@ -35,16 +36,14 @@ class HabitTypeDialog : AppCompatDialogFragment() {
val binding = SelectHabitTypeBinding.inflate(inflater, container, false)
binding.buttonYesNo.setOnClickListener {
- val intent = IntentFactory().startEditActivity(activity!!)
+ val intent = IntentFactory().startEditActivity(activity!!, Habit.YES_NO_HABIT)
startActivity(intent)
dismiss()
}
binding.buttonMeasurable.setOnClickListener {
- dismiss()
- }
-
- binding.buttonSubjective.setOnClickListener{
+ val intent = IntentFactory().startEditActivity(activity!!, Habit.NUMBER_HABIT)
+ startActivity(intent)
dismiss()
}
diff --git a/android/uhabits-android/src/main/java/org/isoron/uhabits/intents/IntentFactory.kt b/android/uhabits-android/src/main/java/org/isoron/uhabits/intents/IntentFactory.kt
index f2aedd3d9..2287a56d1 100644
--- a/android/uhabits-android/src/main/java/org/isoron/uhabits/intents/IntentFactory.kt
+++ b/android/uhabits-android/src/main/java/org/isoron/uhabits/intents/IntentFactory.kt
@@ -84,13 +84,20 @@ class IntentFactory
fun codeContributors(context: Context) =
buildViewIntent(context.getString(R.string.codeContributorsURL))
- fun startEditActivity(context: Context): Intent {
+ private fun startEditActivity(context: Context): Intent {
return Intent(context, EditHabitActivity::class.java)
}
fun startEditActivity(context: Context, habit: Habit): Intent {
val intent = startEditActivity(context)
intent.putExtra("habitId", habit.id)
+ intent.putExtra("habitType", habit.type)
+ return intent
+ }
+
+ fun startEditActivity(context: Context, habitType: Int): Intent {
+ val intent = startEditActivity(context)
+ intent.putExtra("habitType", habitType)
return intent
}
}
diff --git a/android/uhabits-android/src/main/res/layout/activity_edit_habit.xml b/android/uhabits-android/src/main/res/layout/activity_edit_habit.xml
index fb7e1b143..63302cb4c 100644
--- a/android/uhabits-android/src/main/res/layout/activity_edit_habit.xml
+++ b/android/uhabits-android/src/main/res/layout/activity_edit_habit.xml
@@ -49,55 +49,45 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
- android:paddingTop="8dp">
-
+ android:paddingTop="8dp"
+ android:paddingLeft="4dp"
+ android:paddingRight="4dp">
+ android:orientation="horizontal"
+ android:baselineAligned="false">
-
+ android:layout_weight="1">
-
-
+ android:layout_height="match_parent">
-
+ android:text="@string/color" />
-
-
-
-
-
+
-
-
+ android:id="@+id/frequencyOuterBox"
+ style="@style/FormOuterBox">
-
+ android:text="@string/every_day" />
-
+
+
+
+
+
+
+
+ android:orientation="horizontal"
+ android:baselineAligned="false">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
-
+
+
+
+
+
-
+
+
+
+
+
-
-
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android/uhabits-android/src/main/res/values/strings.xml b/android/uhabits-android/src/main/res/values/strings.xml
index cb6d448e5..cf98025c7 100644
--- a/android/uhabits-android/src/main/res/values/strings.xml
+++ b/android/uhabits-android/src/main/res/values/strings.xml
@@ -254,6 +254,12 @@
e.g. Are you felling happy today? Definitely, somewhat, not at all? How frequently did you snack? Very often, sometimes, never?
%d times per week
%d times per month
- e.g. Exercise
+ e.g. Exercise
+ Color
+ e.g. 15
+ e.g. Run
+ e.g. How many miles did you run today?
+ e.g. miles
+
\ No newline at end of file
diff --git a/android/uhabits-android/src/main/res/values/styles.xml b/android/uhabits-android/src/main/res/values/styles.xml
index c100a528c..7f4f4291c 100644
--- a/android/uhabits-android/src/main/res/values/styles.xml
+++ b/android/uhabits-android/src/main/res/values/styles.xml
@@ -303,7 +303,7 @@
- wrap_content
- wrap_content
- 8dp
- - -17dp
+ - -15dp
- -4dp
- ?attr/highContrastReverseTextColor
- 8dp
@@ -326,8 +326,10 @@
- match_parent
- wrap_content
- @drawable/ic_arrow_drop_down_dark
- - 16dp
- - @string/every_day
+ - 16dp
+ - 14dp
+ - 16dp
+ - 16dp
- @dimen/regularTextSize
@@ -340,6 +342,18 @@
- match_parent
+
+