diff --git a/app/src/main/kotlin/org/fossify/notes/adapters/OpenNoteAdapter.kt b/app/src/main/kotlin/org/fossify/notes/adapters/OpenNoteAdapter.kt index 8e166ba0..20a410fd 100644 --- a/app/src/main/kotlin/org/fossify/notes/adapters/OpenNoteAdapter.kt +++ b/app/src/main/kotlin/org/fossify/notes/adapters/OpenNoteAdapter.kt @@ -11,13 +11,12 @@ import com.google.gson.Gson import com.google.gson.reflect.TypeToken import org.fossify.commons.activities.BaseSimpleActivity import org.fossify.commons.adapters.MyRecyclerViewAdapter -import org.fossify.commons.extensions.beGoneIf -import org.fossify.commons.extensions.beVisibleIf -import org.fossify.commons.extensions.getColoredDrawableWithColor -import org.fossify.commons.extensions.isBlackAndWhiteTheme +import org.fossify.commons.extensions.* import org.fossify.commons.helpers.LOWER_ALPHA_INT import org.fossify.commons.helpers.SORT_BY_CUSTOM +import org.fossify.commons.helpers.isOreoPlus import org.fossify.commons.views.MyRecyclerView +import org.fossify.notes.R import org.fossify.notes.databinding.OpenNoteItemBinding import org.fossify.notes.extensions.config import org.fossify.notes.models.ChecklistItem @@ -25,8 +24,10 @@ import org.fossify.notes.models.Note import org.fossify.notes.models.NoteType class OpenNoteAdapter( - activity: BaseSimpleActivity, var items: List, - recyclerView: MyRecyclerView, itemClick: (Any) -> Unit + activity: BaseSimpleActivity, + var items: List, + recyclerView: MyRecyclerView, + itemClick: (Any) -> Unit, ) : MyRecyclerViewAdapter(activity, recyclerView, itemClick) { override fun getActionMenuId() = 0 @@ -52,9 +53,10 @@ class OpenNoteAdapter( override fun onBindViewHolder(holder: ViewHolder, position: Int) { val item = items[position] - holder.bindView(item, true, false) { itemView, layoutPosition -> + holder.bindView(item, allowSingleClick = true, allowLongClick = false) { itemView, _ -> setupView(itemView, item) } + bindViewHolder(holder) } @@ -67,6 +69,7 @@ class OpenNoteAdapter( text = note.title setTextColor(properPrimaryColor) } + val formattedText = note.getFormattedValue(root.context) openNoteItemText.beGoneIf(formattedText.isNullOrBlank() || note.isLocked()) iconLock.beVisibleIf(note.isLocked()) @@ -75,6 +78,22 @@ class OpenNoteAdapter( text = formattedText setTextColor(textColor) } + + openNoteItemIcon.apply { + beVisibleIf(note.path.isNotEmpty()) + applyColorFilter(textColor) + if (isOreoPlus()) { + tooltipText = context.getString(R.string.this_note_is_linked) + } + + setOnClickListener { + if (isOreoPlus()) { + performLongClick() + } else { + activity.toast(R.string.this_note_is_linked) + } + } + } } } @@ -87,11 +106,13 @@ class OpenNoteAdapter( } else { Color.BLACK } + val cardBackground = if (context.config.isUsingSystemTheme) { org.fossify.commons.R.drawable.dialog_you_background } else { org.fossify.commons.R.drawable.dialog_bg } + background = activity.resources.getColoredDrawableWithColor(cardBackground, cardBackgroundColor, LOWER_ALPHA_INT) } @@ -118,6 +139,7 @@ class OpenNoteAdapter( it } } + val linePrefix = "• " val stringifiedItems = items.joinToString(separator = System.lineSeparator()) { "${linePrefix}${it.title}" @@ -133,6 +155,7 @@ class OpenNoteAdapter( currentPos += item.title.length currentPos += System.lineSeparator().length } + formattedText } } diff --git a/app/src/main/res/layout/open_note_item.xml b/app/src/main/res/layout/open_note_item.xml index e8d18e9b..efdfb24e 100644 --- a/app/src/main/res/layout/open_note_item.xml +++ b/app/src/main/res/layout/open_note_item.xml @@ -25,12 +25,25 @@ android:layout_height="wrap_content" android:layout_alignParentStart="true" android:layout_alignParentTop="true" + android:layout_marginEnd="@dimen/small_margin" + android:layout_toStartOf="@id/open_note_item_icon" android:ellipsize="end" android:lines="1" android:textSize="@dimen/big_text_size" android:textStyle="bold" tools:text="Title" /> + + Note \"%s\" saved successfully Note \"%s\" exported successfully Only export the current file content\n(changing the note will not affect the file) + This note is linked with a local file. Display save success messages