mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-29 21:27:40 +00:00
refactor: fix API change of startActivityAndCollapse
See also: https://developer.android.com/reference/android/service/quicksettings/TileService#startActivityAndCollapse(android.content.Intent)
This commit is contained in:
parent
bed6fe2c55
commit
e5eb61fd54
@ -6,10 +6,13 @@
|
|||||||
|
|
||||||
package org.kde.kdeconnect.Plugins.ClibpoardPlugin
|
package org.kde.kdeconnect.Plugins.ClibpoardPlugin
|
||||||
|
|
||||||
|
import android.app.PendingIntent
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.service.quicksettings.TileService
|
import android.service.quicksettings.TileService
|
||||||
import androidx.annotation.RequiresApi
|
import androidx.annotation.RequiresApi
|
||||||
|
import androidx.core.service.quicksettings.PendingIntentActivityWrapper
|
||||||
|
import androidx.core.service.quicksettings.TileServiceCompat
|
||||||
import org.kde.kdeconnect.KdeConnect
|
import org.kde.kdeconnect.KdeConnect
|
||||||
|
|
||||||
@RequiresApi(Build.VERSION_CODES.N)
|
@RequiresApi(Build.VERSION_CODES.N)
|
||||||
@ -17,12 +20,14 @@ class ClipboardTileService : TileService() {
|
|||||||
override fun onClick() {
|
override fun onClick() {
|
||||||
super.onClick()
|
super.onClick()
|
||||||
|
|
||||||
startActivityAndCollapse(Intent(this, ClipboardFloatingActivity::class.java).apply {
|
TileServiceCompat.startActivityAndCollapse(this, PendingIntentActivityWrapper(
|
||||||
flags = Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK
|
this, 0, Intent(this, ClipboardFloatingActivity::class.java).apply {
|
||||||
val ids = KdeConnect.getInstance().devices.values
|
flags = Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK
|
||||||
.filter { it.isReachable && it.isPaired }
|
val ids = KdeConnect.getInstance().devices.values
|
||||||
.map { it.deviceId }
|
.filter { it.isReachable && it.isPaired }
|
||||||
putExtra("connectedDeviceIds", ArrayList(ids))
|
.map { it.deviceId }
|
||||||
})
|
putExtra("connectedDeviceIds", ArrayList(ids))
|
||||||
|
}, PendingIntent.FLAG_ONE_SHOT, true
|
||||||
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user