From 3e1f3a6f5ef5fba661f702e7457ee9c833c516f3 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Mon, 2 Nov 2026 20:55:07 +0100 Subject: fix(app): make LegacyScreen a top-level composable Slack's ComposeUnstableReceiver lint rejects an instance composable on the activity. Co-Authored-By: Claude Opus 5.5 --- .../java/app/passwordstore/ui/main/MainActivity.kt | 23 ++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'app/src/main/java') diff --git a/app/src/main/java/app/passwordstore/ui/main/MainActivity.kt b/app/src/main/java/app/passwordstore/ui/main/MainActivity.kt index 018deae3..48546e00 100644 --- a/app/src/main/java/app/passwordstore/ui/main/MainActivity.kt +++ b/app/src/main/java/app/passwordstore/ui/main/MainActivity.kt @@ -5,6 +5,7 @@ package app.passwordstore.ui.main +import android.app.Activity import android.content.Intent import android.os.Bundle import androidx.activity.compose.setContent @@ -46,32 +47,34 @@ class MainActivity : FragmentActivity() { NavHost(rememberNavController(), startDestination = start) { composable { LegacyScreen( - Intent(this@MainActivity, PasswordStore::class.java).setAction(Intent.ACTION_VIEW) + this@MainActivity, + Intent(this@MainActivity, PasswordStore::class.java).setAction(Intent.ACTION_VIEW), ) } composable { entry -> val route = entry.toRoute() LegacyScreen( + this@MainActivity, Intent(this@MainActivity, DecryptActivity::class.java) .putExtra(BasePGPActivity.EXTRA_FILE_PATH, route.filePath) .putExtra( BasePGPActivity.EXTRA_REPO_PATH, PasswordRepository.getRepositoryDirectory().absolutePath, - ) + ), ) } } } } } +} - // ponytail: trampoline to a screen not yet ported; each port replaces one call with the - // real composable, and the last port deletes this function. - @Composable - private fun LegacyScreen(intent: Intent) { - LaunchedEffect(Unit) { - startActivity(intent) - finish() - } +// ponytail: trampoline to a screen not yet ported; each port replaces one call with the +// real composable, and the last port deletes this function. +@Composable +private fun LegacyScreen(activity: Activity, intent: Intent) { + LaunchedEffect(Unit) { + activity.startActivity(intent) + activity.finish() } } -- cgit v1.2.3