diff --git a/android/uhabits-android/src/main/java/org/isoron/uhabits/activities/habits/show/ShowHabitRootView.java b/android/uhabits-android/src/main/java/org/isoron/uhabits/activities/habits/show/ShowHabitRootView.java index eafd4207c..9c2963867 100644 --- a/android/uhabits-android/src/main/java/org/isoron/uhabits/activities/habits/show/ShowHabitRootView.java +++ b/android/uhabits-android/src/main/java/org/isoron/uhabits/activities/habits/show/ShowHabitRootView.java @@ -21,7 +21,6 @@ package org.isoron.uhabits.activities.habits.show; import android.content.*; import android.os.*; -import android.view.View; import android.widget.TextView; import androidx.annotation.NonNull; @@ -54,6 +53,9 @@ public class ShowHabitRootView extends BaseRootView @BindView(R.id.subtitleCard) SubtitleCard subtitleCard; + @BindView(R.id.notesCard) + NotesCard notesCard; + @BindView(R.id.habitNotes) TextView habitNotes; @@ -141,7 +143,7 @@ public class ShowHabitRootView extends BaseRootView private void initCards() { subtitleCard.setHabit(habit); - initHabitNotes(); + notesCard.setHabit(habit); overviewCard.setHabit(habit); scoreCard.setHabit(habit); historyCard.setHabit(habit); @@ -150,14 +152,6 @@ public class ShowHabitRootView extends BaseRootView barCard.setHabit(habit); } - private void initHabitNotes() { - final String description = habit.getDescription(); - if(!description.isEmpty()){ - habitNotes.setText(description); - habitNotes.setVisibility(View.VISIBLE); - } - } - public interface Controller extends HistoryCard.Controller { default void onToolbarChanged() {} diff --git a/android/uhabits-android/src/main/java/org/isoron/uhabits/activities/habits/show/views/NotesCard.kt b/android/uhabits-android/src/main/java/org/isoron/uhabits/activities/habits/show/views/NotesCard.kt new file mode 100644 index 000000000..2743f43de --- /dev/null +++ b/android/uhabits-android/src/main/java/org/isoron/uhabits/activities/habits/show/views/NotesCard.kt @@ -0,0 +1,26 @@ +package org.isoron.uhabits.activities.habits.show.views + +import android.content.Context +import android.util.AttributeSet +import android.view.View +import android.widget.TextView +import org.isoron.uhabits.R +import org.isoron.uhabits.core.tasks.Task + +internal class NotesCard(context: Context?, attrs: AttributeSet?) : HabitCard(context, attrs) { + + private val notesTextView: TextView + + init { + View.inflate(getContext(), R.layout.show_habit_notes, this) + notesTextView = findViewById(R.id.habitNotes) + } + + override fun refreshData() { + notesTextView.text = habit.description + visibility = if(habit.description.isEmpty()) View.GONE else View.VISIBLE + notesTextView.visibility = visibility + } + + override fun createRefreshTask(): Task = error("refresh task should never be called.") +} \ No newline at end of file diff --git a/android/uhabits-android/src/main/res/layout/show_habit_inner.xml b/android/uhabits-android/src/main/res/layout/show_habit_inner.xml index af9636d74..3b92b3e26 100644 --- a/android/uhabits-android/src/main/res/layout/show_habit_inner.xml +++ b/android/uhabits-android/src/main/res/layout/show_habit_inner.xml @@ -38,15 +38,10 @@ android:id="@+id/subtitleCard" style="@style/ShowHabit.Subtitle"/> - + android:gravity="center" /> + + + + + \ No newline at end of file