Skip to content

Commit

Permalink
[NoteStateIcon] Note state icon in the home feed
Browse files Browse the repository at this point in the history
  • Loading branch information
BijoySingh committed Feb 1, 2018
1 parent 16c8750 commit d287981
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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?) {
Expand All @@ -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))
Expand Down
23 changes: 15 additions & 8 deletions app/src/main/res/layout/item_note.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@

<LinearLayout
android:id="@+id/note_panel"
style="@style/BorderedBackgroundView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/BorderedBackgroundView"
android:orientation="vertical">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
android:orientation="horizontal"
android:padding="4dp">

<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="4dp">
android:layout_weight="1"
android:orientation="vertical">

<TextView
android:id="@+id/title"
Expand Down Expand Up @@ -59,10 +59,17 @@

<ImageView
android:id="@+id/pin_icon"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_width="@dimen/spacing_normal"
android:layout_height="@dimen/spacing_normal"
android:alpha="0.5"
android:src="@drawable/ic_pin"
android:visibility="gone" />

<ImageView
android:id="@+id/state_icon"
android:layout_width="@dimen/spacing_normal"
android:layout_height="@dimen/spacing_normal"
android:alpha="0.5"
android:padding="@dimen/spacing_xsmall"
android:src="@drawable/ic_pin"
android:visibility="gone" />
</LinearLayout>
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/res/layout/item_note_staggered.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@
android:alpha="0.5"
android:src="@drawable/ic_pin"
android:visibility="gone" />

<ImageView
android:id="@+id/state_icon"
android:layout_width="@dimen/spacing_normal"
android:layout_height="@dimen/spacing_normal"
android:alpha="0.5"
android:src="@drawable/ic_pin"
android:visibility="gone" />
</LinearLayout>

<LinearLayout
Expand Down

0 comments on commit d287981

Please sign in to comment.