mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
introduced notes card to support refresh
This commit is contained in:
@@ -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() {}
|
||||
|
||||
@@ -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.")
|
||||
}
|
||||
@@ -38,15 +38,10 @@
|
||||
android:id="@+id/subtitleCard"
|
||||
style="@style/ShowHabit.Subtitle"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/habitNotes"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
<org.isoron.uhabits.activities.habits.show.views.NotesCard
|
||||
android:id="@+id/notesCard"
|
||||
style="@style/Card"
|
||||
android:gravity="center"
|
||||
android:textColor="?highContrastTextColor"
|
||||
tools:text="This is some example text for the notes"
|
||||
android:visibility="gone"/>
|
||||
android:gravity="center" />
|
||||
|
||||
<View
|
||||
android:id="@+id/headerShadow"
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Copyright (C) 2016 Álinson Santos Xavier <isoron@gmail.com>
|
||||
~
|
||||
~ This file is part of Loop Habit Tracker.
|
||||
~
|
||||
~ Loop Habit Tracker is free software: you can redistribute it and/or modify
|
||||
~ it under the terms of the GNU General Public License as published by the
|
||||
~ Free Software Foundation, either version 3 of the License, or (at your
|
||||
~ option) any later version.
|
||||
~
|
||||
~ Loop Habit Tracker is distributed in the hope that it will be useful, but
|
||||
~ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
~ more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU General Public License along
|
||||
~ with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:layout_height="wrap_content"
|
||||
tools:layout_width="match_parent"
|
||||
tools:orientation="vertical"
|
||||
tools:parentTag="android.widget.LinearLayout">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/habitNotes"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:textColor="?highContrastTextColor"
|
||||
android:visibility="gone"
|
||||
tools:text="This is some example text for the notes" />
|
||||
</merge>
|
||||
Reference in New Issue
Block a user