From d28798135646d4fc37791a1789ec0b925b23dc24 Mon Sep 17 00:00:00 2001 From: Bijoy Singh Kochar Date: Thu, 1 Feb 2018 00:16:07 +0000 Subject: [PATCH] [NoteStateIcon] Note state icon in the home feed --- .../bijoysingh/quicknote/database/Note.java | 2 +- .../NoteRecyclerViewHolderBase.kt | 20 ++++++++++++++++ app/src/main/res/layout/item_note.xml | 23 ++++++++++++------- .../main/res/layout/item_note_staggered.xml | 8 +++++++ 4 files changed, 44 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/bijoysingh/quicknote/database/Note.java b/app/src/main/java/com/bijoysingh/quicknote/database/Note.java index 176309c2..14c53e5b 100644 --- a/app/src/main/java/com/bijoysingh/quicknote/database/Note.java +++ b/app/src/main/java/com/bijoysingh/quicknote/database/Note.java @@ -118,7 +118,7 @@ public CharSequence getLockedText(Context context, boolean isMarkdownEnabled) { public String getDisplayTime() { long time = updateTimestamp != 0 ? updateTimestamp : (timestamp == null ? 0 : timestamp); String format = (Calendar.getInstance().getTimeInMillis() - time < 1000 * 60 * 60 * 2) - ? "hh:mm aa" : "dd MMM"; + ? "hh:mm aa" : "dd MMMM"; return DateFormatter.getDate(format, time); } diff --git a/app/src/main/java/com/bijoysingh/quicknote/recyclerview/NoteRecyclerViewHolderBase.kt b/app/src/main/java/com/bijoysingh/quicknote/recyclerview/NoteRecyclerViewHolderBase.kt index e1e1a156..a39fc10f 100644 --- a/app/src/main/java/com/bijoysingh/quicknote/recyclerview/NoteRecyclerViewHolderBase.kt +++ b/app/src/main/java/com/bijoysingh/quicknote/recyclerview/NoteRecyclerViewHolderBase.kt @@ -15,6 +15,7 @@ import com.bijoysingh.quicknote.activities.sheets.SettingsOptionsBottomSheet.Com import com.bijoysingh.quicknote.database.Note import com.bijoysingh.quicknote.items.NoteRecyclerItem import com.bijoysingh.quicknote.items.RecyclerItem +import com.bijoysingh.quicknote.utils.NoteState import com.bijoysingh.quicknote.utils.trim import com.github.bijoysingh.starter.recyclerview.RecyclerViewHolder import com.github.bijoysingh.starter.util.TextUtils @@ -34,6 +35,7 @@ open class NoteRecyclerViewHolderBase(context: Context, view: View) : RecyclerVi protected val bottomLayout: View protected val pinIndicator: ImageView + protected val stateIndicator: ImageView init { this.view = view as CardView @@ -47,6 +49,7 @@ open class NoteRecyclerViewHolderBase(context: Context, view: View) : RecyclerVi pinIndicator = view.findViewById(R.id.pin_icon) edit = view.findViewById(R.id.edit_button) bottomLayout = view.findViewById(R.id.bottom_toolbar_layout) + stateIndicator = view.findViewById(R.id.state_icon) } override fun populate(itemData: RecyclerItem, extra: Bundle?) { @@ -65,6 +68,23 @@ open class NoteRecyclerViewHolderBase(context: Context, view: View) : RecyclerVi pinIndicator.visibility = if (data.pinned) View.VISIBLE else View.GONE + when (data.noteState) { + NoteState.FAVOURITE -> { + stateIndicator.visibility = View.VISIBLE + stateIndicator.setImageResource(R.drawable.ic_favorite_white_48dp) + } + NoteState.ARCHIVED -> { + stateIndicator.visibility = View.VISIBLE + stateIndicator.setImageResource(R.drawable.ic_archive_white_48dp) + } + NoteState.TRASH -> { + stateIndicator.visibility = View.VISIBLE + stateIndicator.setImageResource(R.drawable.ic_delete_white_48dp) + } + NoteState.DEFAULT -> stateIndicator.visibility = GONE + else -> stateIndicator.visibility = GONE + } + val noteTimestamp = data.displayTime if (!TextUtils.isNullOrEmpty(data.tags)) { tags.setTextColor(ContextCompat.getColor(context, R.color.light_secondary_text)) diff --git a/app/src/main/res/layout/item_note.xml b/app/src/main/res/layout/item_note.xml index 38828191..ae45825c 100644 --- a/app/src/main/res/layout/item_note.xml +++ b/app/src/main/res/layout/item_note.xml @@ -9,22 +9,22 @@ + android:orientation="horizontal" + android:padding="4dp"> + android:layout_weight="1" + android:orientation="vertical"> + + diff --git a/app/src/main/res/layout/item_note_staggered.xml b/app/src/main/res/layout/item_note_staggered.xml index db7ed9c6..f1d1b879 100644 --- a/app/src/main/res/layout/item_note_staggered.xml +++ b/app/src/main/res/layout/item_note_staggered.xml @@ -80,6 +80,14 @@ android:alpha="0.5" android:src="@drawable/ic_pin" android:visibility="gone" /> + +