Fix backup sharing from notifications not working when app is in background (#1929)
(cherry picked from commit 3e5d3d099fed5feb6a6807196bea5fed72973fe9) # Conflicts: # CHANGELOG.md
This commit is contained in:
parent
77a4919656
commit
f6b1440bf2
@ -80,7 +80,7 @@ class BackupNotifier(private val context: Context) {
|
|||||||
addAction(
|
addAction(
|
||||||
R.drawable.ic_share_24dp,
|
R.drawable.ic_share_24dp,
|
||||||
context.stringResource(MR.strings.action_share),
|
context.stringResource(MR.strings.action_share),
|
||||||
NotificationReceiver.shareBackupPendingBroadcast(context, file.uri),
|
NotificationReceiver.shareBackupPendingActivity(context, file.uri),
|
||||||
)
|
)
|
||||||
|
|
||||||
show(Notifications.ID_BACKUP_COMPLETE)
|
show(Notifications.ID_BACKUP_COMPLETE)
|
||||||
|
@ -602,18 +602,17 @@ class NotificationReceiver : BroadcastReceiver() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns [PendingIntent] that starts a share activity for a backup file.
|
* Returns [PendingIntent] that directly launches a share activity for a backup file.
|
||||||
*
|
*
|
||||||
* @param context context of application
|
* @param context context of application
|
||||||
* @param uri uri of backup file
|
* @param uri uri of backup file
|
||||||
* @return [PendingIntent]
|
* @return [PendingIntent]
|
||||||
*/
|
*/
|
||||||
internal fun shareBackupPendingBroadcast(context: Context, uri: Uri): PendingIntent {
|
internal fun shareBackupPendingActivity(context: Context, uri: Uri): PendingIntent {
|
||||||
val intent = Intent(context, NotificationReceiver::class.java).apply {
|
val intent = uri.toShareIntent(context, "application/x-protobuf+gzip").apply {
|
||||||
action = ACTION_SHARE_BACKUP
|
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_GRANT_READ_URI_PERMISSION)
|
||||||
putExtra(EXTRA_URI, uri)
|
|
||||||
}
|
}
|
||||||
return PendingIntent.getBroadcast(
|
return PendingIntent.getActivity(
|
||||||
context,
|
context,
|
||||||
0,
|
0,
|
||||||
intent,
|
intent,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user