edit name description panel xml

This commit is contained in:
Rechee
2020-01-07 20:02:55 -08:00
parent 0990192cd6
commit fb40dbdabc
7 changed files with 83 additions and 49 deletions

View File

@@ -42,6 +42,9 @@ public class NameDescriptionPanel extends FrameLayout
@BindView(R.id.tvName)
EditText tvName;
@BindView(R.id.tvQuestion)
ExampleEditText tvQuestion;
@BindView(R.id.tvDescription)
ExampleEditText tvDescription;
@@ -76,7 +79,7 @@ public class NameDescriptionPanel extends FrameLayout
@NonNull
public String getDescription()
{
return tvDescription.getRealText().trim();
return tvQuestion.getRealText().trim();
}
@NonNull
@@ -90,13 +93,13 @@ public class NameDescriptionPanel extends FrameLayout
Resources res = getResources();
if(habit.isNumerical())
tvDescription.setExample(res.getString(R.string.example_question_numerical));
tvQuestion.setExample(res.getString(R.string.example_question_numerical));
else
tvDescription.setExample(res.getString(R.string.example_question_boolean));
tvQuestion.setExample(res.getString(R.string.example_question_boolean));
setColor(habit.getColor());
tvName.setText(habit.getName());
tvDescription.setRealText(habit.getDescription());
tvQuestion.setRealText(habit.getDescription());
}
public boolean validate()

View File

@@ -115,7 +115,7 @@ class AndroidNotificationTray
val builder = NotificationCompat.Builder(context, REMINDERS_CHANNEL_ID)
.setSmallIcon(R.drawable.ic_notification)
.setContentTitle(habit.name)
.setContentText(if(habit.description.isBlank()) defaultText else habit.description)
.setContentText(if(habit.description.isNullOrBlank()) defaultText else habit.description)
.setContentIntent(pendingIntents.showHabit(habit))
.setDeleteIntent(pendingIntents.dismissNotification(habit))
.addAction(addRepetitionAction)

View File

@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright (C) 2016 Álinson Santos Xavier <isoron@gmail.com>
~
~ This file is part of Loop Habit Tracker.
@@ -18,53 +17,83 @@
~ with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://isoron.org/android"
xmlns:app1="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
style="@style/dialogFormRow">
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/tilName"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="6">
<EditText
android:id="@+id/tvName"
style="@style/dialogFormInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/name">
<requestFocus/>
</EditText>
</com.google.android.material.textfield.TextInputLayout>
<ImageButton
android:id="@+id/buttonPickColor"
style="@style/dialogFormInputColor"
android:layout_weight="1"
android:contentDescription="@string/color_picker_default_title"
android:src="?dialogIconChangeColor"/>
</LinearLayout>
android:layout_height="wrap_content"
android:minWidth="300dp">
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:id="@+id/tilName"
android:layout_width="0dp"
android:layout_height="wrap_content"
app1:layout_constraintEnd_toStartOf="@+id/buttonPickColor"
app1:layout_constraintHorizontal_weight="6"
app1:layout_constraintStart_toStartOf="parent"
app1:layout_constraintTop_toTopOf="parent">
<EditText
android:id="@+id/tvName"
style="@style/dialogFormInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="start"
android:gravity="center_vertical"
android:hint="@string/name">
<requestFocus />
</EditText>
</com.google.android.material.textfield.TextInputLayout>
<ImageButton
android:id="@+id/buttonPickColor"
style="@style/dialogFormInputColor"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:contentDescription="@string/color_picker_default_title"
android:src="?dialogIconChangeColor"
app1:layout_constraintBottom_toBottomOf="@id/tilName"
app1:layout_constraintEnd_toEndOf="parent"
app1:layout_constraintHorizontal_weight="1"
app1:layout_constraintStart_toEndOf="@+id/tilName"
app1:layout_constraintTop_toTopOf="@id/tilName" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/tilQuestion"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="@string/question"
app1:layout_constraintEnd_toEndOf="parent"
app1:layout_constraintStart_toStartOf="parent"
app1:layout_constraintTop_toBottomOf="@id/tilName">
<org.isoron.uhabits.activities.habits.edit.views.ExampleEditText
android:id="@+id/tvDescription"
android:id="@+id/tvQuestion"
style="@style/dialogFormInputMultiline"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/question"
app:example="@string/example_question_numerical"/>
app:example="@string/example_question_numerical" />
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:hint="@string/notes"
app1:layout_constraintBottom_toBottomOf="parent"
app1:layout_constraintEnd_toEndOf="parent"
app1:layout_constraintStart_toStartOf="parent"
app1:layout_constraintTop_toBottomOf="@id/tilQuestion">
<org.isoron.uhabits.activities.habits.edit.views.ExampleEditText
android:id="@+id/tvDescription"
style="@style/dialogFormInput"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="top"
android:minHeight="300dp"
app:example="@string/example_notes" />
</com.google.android.material.textfield.TextInputLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -244,5 +244,7 @@
<string name="widget_opacity_description">Makes widgets more transparent or more opaque in your home screen.</string>
<string name="first_day_of_the_week">First day of the week</string>
<string name="default_reminder_question">Have you completed this habit today?</string>
<string name="notes">Notes</string>
<string name="example_notes">You can put whatever you want here!</string>
</resources>