adding smalltalk to the targetted share menu
This commit is contained in:
parent
2ca96f21d2
commit
33ee1825cf
|
@ -20,6 +20,11 @@
|
|||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
|
||||
<meta-data
|
||||
android:name="android.app.shortcuts"
|
||||
android:resource="@xml/shortcuts" />
|
||||
|
||||
</activity-alias>
|
||||
|
||||
</application>
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<share-target android:targetClass="app.dapk.st.share.ShareEntryActivity">
|
||||
<data android:mimeType="image/*" />
|
||||
<category android:name="android.shortcut.conversation" />
|
||||
</share-target>
|
||||
</shortcuts>
|
|
@ -2,6 +2,7 @@ package app.dapk.st.directory
|
|||
|
||||
import android.content.Context
|
||||
import android.content.pm.ShortcutInfo
|
||||
import androidx.core.app.Person
|
||||
import androidx.core.content.pm.ShortcutInfoCompat
|
||||
import androidx.core.content.pm.ShortcutManagerCompat
|
||||
import app.dapk.st.matrix.common.RoomId
|
||||
|
@ -14,21 +15,26 @@ class ShortcutHandler(private val context: Context) {
|
|||
|
||||
fun onDirectoryUpdate(overviews: List<RoomOverview>) {
|
||||
val update = overviews.map { it.roomId }
|
||||
|
||||
if (cachedRoomIds != update) {
|
||||
cachedRoomIds.clear()
|
||||
cachedRoomIds.addAll(update)
|
||||
|
||||
val currentShortcuts = ShortcutManagerCompat.getShortcuts(context, ShortcutManagerCompat.FLAG_MATCH_DYNAMIC)
|
||||
val maxShortcutCountPerActivity = ShortcutManagerCompat.getMaxShortcutCountPerActivity(context)
|
||||
|
||||
overviews
|
||||
.take(maxShortcutCountPerActivity)
|
||||
.filterNot { roomUpdate -> currentShortcuts.any { it.id == roomUpdate.roomId.value } }
|
||||
.forEachIndexed { index, room ->
|
||||
val build = ShortcutInfoCompat.Builder(context, room.roomId.value)
|
||||
.setShortLabel(room.roomName ?: "N/A")
|
||||
.setLongLabel(room.roomName ?: "N/A")
|
||||
.setRank(index)
|
||||
.run {
|
||||
this.setPerson(
|
||||
Person.Builder()
|
||||
.setName(room.roomName ?: "N/A")
|
||||
.setKey(room.roomId.value)
|
||||
.build()
|
||||
)
|
||||
}
|
||||
.setIntent(MessengerActivity.newShortcutInstance(context, room.roomId))
|
||||
.setLongLived(true)
|
||||
.setCategories(setOf(ShortcutInfo.SHORTCUT_CATEGORY_CONVERSATION))
|
||||
|
|
|
@ -54,4 +54,6 @@ data class MessagerActivityPayload(
|
|||
val roomId: String
|
||||
) : Parcelable
|
||||
|
||||
fun <T : Parcelable> Activity.readPayload(): T = intent.getParcelableExtra("key")!!
|
||||
fun <T : Parcelable> Activity.readPayload(): T = intent.getParcelableExtra("key") ?: intent.getStringExtra("shortcut_key")!!.let {
|
||||
MessagerActivityPayload(it) as T
|
||||
}
|
|
@ -19,6 +19,10 @@
|
|||
<data android:mimeType="image/*" />
|
||||
</intent-filter>
|
||||
|
||||
<meta-data
|
||||
android:name="android.service.chooser.chooser_target_service"
|
||||
android:value="androidx.sharetarget.ChooserTargetServiceCompat" />
|
||||
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
|
|
|
@ -11,22 +11,7 @@ class ShareEntryActivity : DapkActivity() {
|
|||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
val urisToShare = intent.readSendUrisOrNull() ?: throw IllegalArgumentException("")
|
||||
|
||||
// display list of rooms/converations
|
||||
|
||||
// homeViewModel.events.onEach {
|
||||
// when (it) {
|
||||
// HomeEvent.Relaunch -> recreate()
|
||||
// }
|
||||
// }.launchIn(lifecycleScope)
|
||||
//
|
||||
// setContent {
|
||||
// if (homeViewModel.hasVersionChanged()) {
|
||||
// BetaUpgradeDialog()
|
||||
// } else {
|
||||
// HomeScreen(homeViewModel)
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue