Skip to content

Commit a7b9521

Browse files
alperozturk96backportbot[bot]
authored andcommitted
use category and create note intent
Signed-off-by: alperozturk <[email protected]>
1 parent 992ff99 commit a7b9521

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

app/src/main/java/it/niedermann/owncloud/notes/widget/notelist/NoteListWidgetFactory.kt

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,26 @@ class NoteListWidgetFactory internal constructor(private val context: Context, i
127127

128128
val openNoteIntent = getOpenNoteIntent(note)
129129

130+
var createNoteIntent: Intent? = null
131+
data?.let {
132+
val localAccount = repo.getAccountById(it.accountId)
133+
createNoteIntent = getCreateNoteIntent(localAccount)
134+
}
135+
136+
val category = getCategoryTitle(context)
137+
130138
return RemoteViews(context.packageName, R.layout.widget_entry).apply {
131139
setOnClickFillInIntent(R.id.widget_note_list_entry, openNoteIntent)
132-
setTextViewText(R.id.widget_entry_content_tv,
133-
(note.title + getCategoryTitle(context))
134-
)
140+
141+
createNoteIntent?.let {
142+
setOnClickFillInIntent(R.id.widget_entry_fav_icon, createNoteIntent)
143+
}
144+
145+
if (category != null) {
146+
setTextViewText(R.id.widget_entry_content_tv, category)
147+
} else {
148+
setTextViewText(R.id.widget_entry_content_tv, note.title)
149+
}
135150

136151
val starIconId = if (note.favorite) {
137152
R.drawable.ic_star_yellow_24dp
@@ -143,10 +158,6 @@ class NoteListWidgetFactory internal constructor(private val context: Context, i
143158
}
144159

145160
private fun getCategoryTitle(context: Context): String? {
146-
if (data == null) {
147-
return null
148-
}
149-
150161
val widgetData = data ?: return null
151162

152163
return when (widgetData.mode) {

0 commit comments

Comments
 (0)