@@ -23,6 +23,8 @@ import androidx.core.content.ContextCompat
23
23
import androidx.core.net.toUri
24
24
import androidx.navigation.NavDeepLinkBuilder
25
25
import com.nononsenseapps.feeder.R
26
+ import com.nononsenseapps.feeder.archmodel.ItemOpener
27
+ import com.nononsenseapps.feeder.archmodel.Repository
26
28
import com.nononsenseapps.feeder.db.COL_LINK
27
29
import com.nononsenseapps.feeder.db.URI_FEEDITEMS
28
30
import com.nononsenseapps.feeder.db.room.FeedDao
@@ -123,7 +125,10 @@ private fun createNotificationChannel(context: Context) {
123
125
notificationManager.createNotificationChannel(channel)
124
126
}
125
127
126
- private fun singleNotification (context : Context , item : FeedItemWithFeed ): Notification {
128
+ private suspend fun singleNotification (context : Context , item : FeedItemWithFeed ): Notification {
129
+ val di by closestDI(context)
130
+ val repository: Repository by di.instance()
131
+
127
132
val style = NotificationCompat .BigTextStyle ()
128
133
val title = item.plainTitle
129
134
val text = item.feedDisplayTitle
@@ -151,42 +156,56 @@ private fun singleNotification(context: Context, item: FeedItemWithFeed): Notifi
151
156
152
157
builder.setContentText(text)
153
158
.setContentTitle(title)
154
- .setContentIntent(pendingIntent)
155
159
.setGroup(articleNotificationGroup)
156
160
.setGroupAlertBehavior(GROUP_ALERT_SUMMARY )
157
161
.setDeleteIntent(getPendingDeleteIntent(context, item))
158
162
.setNumber(1 )
159
163
160
164
// Note that notifications must use PNG resources, because there is no compatibility for vector drawables here
161
165
162
- item.enclosureLink?.let { enclosureLink ->
163
- val intent = Intent (Intent .ACTION_VIEW , Uri .parse(enclosureLink))
164
- intent.putExtra(EXTRA_CREATE_NEW_TAB , true )
165
- builder.addAction(
166
- R .drawable.notification_play_circle_outline,
167
- context.getString(R .string.open_enclosed_media),
166
+ if (repository.getArticleOpener(item.id) == ItemOpener .DEFAULT_BROWSER && item.link != null ) {
167
+ builder.setContentIntent(
168
168
PendingIntent .getActivity(
169
169
context,
170
170
item.id.toInt(),
171
- getOpenInDefaultActivityIntent(context, item.id, enclosureLink ),
171
+ getOpenInDefaultActivityIntent(context, item.id, item.link ),
172
172
PendingIntent .FLAG_UPDATE_CURRENT or FLAG_IMMUTABLE ,
173
173
),
174
174
)
175
+ } else {
176
+ builder.setContentIntent(pendingIntent)
175
177
}
176
178
177
- item.link?.let { link ->
179
+ item.enclosureLink?.let { enclosureLink ->
180
+ val intent = Intent (Intent .ACTION_VIEW , Uri .parse(enclosureLink))
181
+ intent.putExtra(EXTRA_CREATE_NEW_TAB , true )
178
182
builder.addAction(
179
- R .drawable.notification_open_in_browser ,
180
- context.getString(R .string.open_link_in_browser ),
183
+ R .drawable.notification_play_circle_outline ,
184
+ context.getString(R .string.open_enclosed_media ),
181
185
PendingIntent .getActivity(
182
186
context,
183
187
item.id.toInt(),
184
- getOpenInDefaultActivityIntent(context, item.id, link ),
188
+ getOpenInDefaultActivityIntent(context, item.id, enclosureLink ),
185
189
PendingIntent .FLAG_UPDATE_CURRENT or FLAG_IMMUTABLE ,
186
190
),
187
191
)
188
192
}
189
193
194
+ if (repository.getArticleOpener(item.id) != ItemOpener .DEFAULT_BROWSER ) {
195
+ item.link?.let { link ->
196
+ builder.addAction(
197
+ R .drawable.notification_open_in_browser,
198
+ context.getString(R .string.open_link_in_browser),
199
+ PendingIntent .getActivity(
200
+ context,
201
+ item.id.toInt(),
202
+ getOpenInDefaultActivityIntent(context, item.id, link),
203
+ PendingIntent .FLAG_UPDATE_CURRENT or FLAG_IMMUTABLE ,
204
+ ),
205
+ )
206
+ }
207
+ }
208
+
190
209
builder.addAction(
191
210
R .drawable.notification_check,
192
211
context.getString(R .string.mark_as_read),
0 commit comments