feat(audio-rooms): View Profile via nostr: deep-link (T2 #2)
The participant context sheet's "View profile" row was previously a
TODO comment — AudioRoomActivity is a separate Android activity
without its own nav stack. Wire it through MainActivity's existing
nostr: URI handler:
* encode the target hex as npub via NPub.create(...)
* fire ACTION_VIEW on `nostr:npub1...` with explicit MainActivity
component (FLAG_ACTIVITY_REORDER_TO_FRONT brings the running
instance forward instead of spawning a duplicate)
* the audio-room foreground service keeps audio alive while the
user is on the profile screen
Reuses the existing audio_room_participant_view_profile string.
This commit is contained in:
+32
-5
@@ -36,12 +36,15 @@ import androidx.compose.runtime.Composable
|
|||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.rememberCoroutineScope
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import com.vitorpamplona.amethyst.R
|
import com.vitorpamplona.amethyst.R
|
||||||
|
import com.vitorpamplona.amethyst.ui.MainActivity
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
||||||
import com.vitorpamplona.amethyst.ui.stringRes
|
import com.vitorpamplona.amethyst.ui.stringRes
|
||||||
import com.vitorpamplona.quartz.experimental.audiorooms.admin.AdminCommandEvent
|
import com.vitorpamplona.quartz.experimental.audiorooms.admin.AdminCommandEvent
|
||||||
import com.vitorpamplona.quartz.nip01Core.tags.aTag.ATag
|
import com.vitorpamplona.quartz.nip01Core.tags.aTag.ATag
|
||||||
|
import com.vitorpamplona.quartz.nip19Bech32.entities.NPub
|
||||||
import com.vitorpamplona.quartz.nip53LiveActivities.meetingSpaces.MeetingSpaceEvent
|
import com.vitorpamplona.quartz.nip53LiveActivities.meetingSpaces.MeetingSpaceEvent
|
||||||
import com.vitorpamplona.quartz.nip53LiveActivities.streaming.tags.ROLE
|
import com.vitorpamplona.quartz.nip53LiveActivities.streaming.tags.ROLE
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
@@ -111,11 +114,35 @@ internal fun ParticipantHostActionsSheet(
|
|||||||
style = MaterialTheme.typography.titleSmall,
|
style = MaterialTheme.typography.titleSmall,
|
||||||
)
|
)
|
||||||
Spacer(Modifier.height(8.dp))
|
Spacer(Modifier.height(8.dp))
|
||||||
// Audience-side rows. View-profile navigation is
|
// View Profile — AudioRoomActivity is a separate Android
|
||||||
// intentionally omitted in v1: AudioRoomActivity is a
|
// Activity without its own nav stack, so the deep-link
|
||||||
// separate Android Activity without an in-room nav
|
// path goes through MainActivity. Launching `nostr:npub1...`
|
||||||
// stack to push a profile screen onto. Adding it later
|
// via ACTION_VIEW lets the existing MainActivity URI
|
||||||
// means launching MainActivity with a deep-link Intent.
|
// handler route to Route.Profile (matches the path that
|
||||||
|
// an external app or a clicked link inside the feed
|
||||||
|
// would take). NEW_TASK + REORDER_TO_FRONT brings the
|
||||||
|
// already-running MainActivity instance forward; the
|
||||||
|
// audio-room foreground service keeps audio alive while
|
||||||
|
// the user is on the profile screen.
|
||||||
|
val context = LocalContext.current
|
||||||
|
ActionRow(stringRes(R.string.audio_room_participant_view_profile)) {
|
||||||
|
val npub = NPub.create(target)
|
||||||
|
runCatching {
|
||||||
|
context.startActivity(
|
||||||
|
android.content
|
||||||
|
.Intent(android.content.Intent.ACTION_VIEW)
|
||||||
|
.apply {
|
||||||
|
data = android.net.Uri.parse("nostr:$npub")
|
||||||
|
setClass(context, MainActivity::class.java)
|
||||||
|
addFlags(
|
||||||
|
android.content.Intent.FLAG_ACTIVITY_NEW_TASK or
|
||||||
|
android.content.Intent.FLAG_ACTIVITY_REORDER_TO_FRONT,
|
||||||
|
)
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
onDismiss()
|
||||||
|
}
|
||||||
ActionRow(
|
ActionRow(
|
||||||
text =
|
text =
|
||||||
stringRes(
|
stringRes(
|
||||||
|
|||||||
Reference in New Issue
Block a user