mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-09-18 21:50:56 +00:00
#1774 Fix widget on click fill intent
This commit is contained in:
parent
0646d72782
commit
4a528ad9b7
2 changed files with 31 additions and 15 deletions
|
@ -9,21 +9,36 @@ object PendingIntentUtils {
|
|||
|
||||
@JvmStatic
|
||||
fun getImmutableActivity(
|
||||
context: Context, requestCode: Int,
|
||||
intent: Intent, flags: Int): PendingIntent? =
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
PendingIntent.getActivity(context, requestCode, intent, flags or PendingIntent.FLAG_IMMUTABLE, null)
|
||||
} else {
|
||||
PendingIntent.getActivity(context, requestCode, intent, flags, null)
|
||||
}
|
||||
context: Context,
|
||||
requestCode: Int,
|
||||
intent: Intent,
|
||||
flags: Int,
|
||||
): PendingIntent? = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
PendingIntent.getActivity(context, requestCode, intent, flags or PendingIntent.FLAG_IMMUTABLE, null)
|
||||
} else {
|
||||
PendingIntent.getActivity(context, requestCode, intent, flags, null)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getImmutableBroadcast(
|
||||
context: Context, requestCode: Int,
|
||||
intent: Intent, flags: Int): PendingIntent? =
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
PendingIntent.getBroadcast(context, requestCode, intent, flags or PendingIntent.FLAG_IMMUTABLE)
|
||||
} else {
|
||||
PendingIntent.getBroadcast(context, requestCode, intent, flags)
|
||||
}
|
||||
context: Context,
|
||||
requestCode: Int,
|
||||
intent: Intent,
|
||||
flags: Int,
|
||||
): PendingIntent? = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
PendingIntent.getBroadcast(context, requestCode, intent, flags or PendingIntent.FLAG_IMMUTABLE)
|
||||
} else {
|
||||
PendingIntent.getBroadcast(context, requestCode, intent, flags)
|
||||
}
|
||||
|
||||
fun getMutableBroadcast(
|
||||
context: Context,
|
||||
requestCode: Int,
|
||||
intent: Intent,
|
||||
flags: Int,
|
||||
): PendingIntent? = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
PendingIntent.getBroadcast(context, requestCode, intent, flags or PendingIntent.FLAG_MUTABLE)
|
||||
} else {
|
||||
PendingIntent.getBroadcast(context, requestCode, intent, flags)
|
||||
}
|
||||
}
|
|
@ -15,6 +15,7 @@ import com.newsblur.activity.ItemsList
|
|||
import com.newsblur.activity.WidgetConfig
|
||||
import com.newsblur.util.FeedSet
|
||||
import com.newsblur.util.PendingIntentUtils.getImmutableBroadcast
|
||||
import com.newsblur.util.PendingIntentUtils.getMutableBroadcast
|
||||
import com.newsblur.util.PrefsUtils
|
||||
import com.newsblur.util.WidgetBackground
|
||||
import com.newsblur.widget.WidgetUtils.checkWidgetUpdateAlarm
|
||||
|
@ -104,7 +105,7 @@ class WidgetProvider : AppWidgetProvider() {
|
|||
putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId)
|
||||
}
|
||||
|
||||
val touchIntentTemplate = getImmutableBroadcast(context, WidgetUtils.RC_WIDGET_STORY, touchIntent,
|
||||
val touchIntentTemplate = getMutableBroadcast(context, WidgetUtils.RC_WIDGET_STORY, touchIntent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT)
|
||||
rv.setPendingIntentTemplate(R.id.widget_list, touchIntentTemplate)
|
||||
appWidgetManager.updateAppWidget(appWidgetId, rv)
|
||||
|
|
Loading…
Add table
Reference in a new issue