fully implementing question & description in UI and code

This commit is contained in:
Rechee
2020-01-07 20:22:35 -08:00
parent fb40dbdabc
commit 61bcd253f8
4 changed files with 17 additions and 7 deletions

View File

@@ -187,6 +187,7 @@ public class EditHabitDialog extends AppCompatDialogFragment
habit.copyFrom(originalHabit); habit.copyFrom(originalHabit);
habit.setName(namePanel.getName()); habit.setName(namePanel.getName());
habit.setDescription(namePanel.getDescription()); habit.setDescription(namePanel.getDescription());
habit.setQuestion(namePanel.getQuestion());
habit.setColor(namePanel.getColor()); habit.setColor(namePanel.getColor());
habit.setReminder(reminderPanel.getReminder()); habit.setReminder(reminderPanel.getReminder());
habit.setFrequency(frequencyPanel.getFrequency()); habit.setFrequency(frequencyPanel.getFrequency());

View File

@@ -24,6 +24,7 @@ import android.text.*;
import android.util.*; import android.util.*;
import android.view.*; import android.view.*;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatEditText; import androidx.appcompat.widget.AppCompatEditText;
@@ -82,7 +83,7 @@ public class ExampleEditText extends AppCompatEditText
updateText(); updateText();
} }
public void setRealText(String realText) public void setRealText(@NonNull String realText)
{ {
this.realText = realText; this.realText = realText;
updateText(); updateText();

View File

@@ -76,9 +76,14 @@ public class NameDescriptionPanel extends FrameLayout
tvName.setTextColor(PaletteUtils.getColor(getContext(), color)); tvName.setTextColor(PaletteUtils.getColor(getContext(), color));
} }
@NonNull @Nullable
public String getDescription() public String getDescription()
{ {
return tvDescription.getRealText().trim();
}
@NonNull
public String getQuestion() {
return tvQuestion.getRealText().trim(); return tvQuestion.getRealText().trim();
} }
@@ -99,7 +104,11 @@ public class NameDescriptionPanel extends FrameLayout
setColor(habit.getColor()); setColor(habit.getColor());
tvName.setText(habit.getName()); tvName.setText(habit.getName());
tvQuestion.setRealText(habit.getDescription()); tvQuestion.setRealText(habit.getQuestion());
final String description = habit.getDescription();
if(description != null) {
tvDescription.setRealText(description);
}
} }
public boolean validate() public boolean validate()

View File

@@ -70,7 +70,7 @@
<org.isoron.uhabits.activities.habits.edit.views.ExampleEditText <org.isoron.uhabits.activities.habits.edit.views.ExampleEditText
android:id="@+id/tvQuestion" android:id="@+id/tvQuestion"
style="@style/dialogFormInputMultiline" style="@style/dialogFormInput"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:example="@string/example_question_numerical" /> app:example="@string/example_question_numerical" />
@@ -88,11 +88,10 @@
<org.isoron.uhabits.activities.habits.edit.views.ExampleEditText <org.isoron.uhabits.activities.habits.edit.views.ExampleEditText
android:id="@+id/tvDescription" android:id="@+id/tvDescription"
style="@style/dialogFormInput" style="@style/dialogFormInputMultiline"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:gravity="top" android:gravity="top"
android:minHeight="300dp"
app:example="@string/example_notes" /> app:example="@string/example_notes" />
</com.google.android.material.textfield.TextInputLayout> </com.google.android.material.textfield.TextInputLayout>