Offlin33er commited on
Commit
bfa6519
·
verified ·
1 Parent(s): 91a4519

Add GeckoResult import; explicit lambda params

Browse files
app/src/main/java/dev/nova/browser/BrowserActivity.kt CHANGED
@@ -13,6 +13,7 @@ import androidx.compose.runtime.*
13
  import androidx.compose.ui.Modifier
14
  import androidx.compose.ui.unit.dp
15
  import androidx.compose.ui.viewinterop.AndroidView
 
16
  import org.mozilla.geckoview.GeckoRuntime
17
  import org.mozilla.geckoview.GeckoView
18
  import org.mozilla.geckoview.WebExtension
@@ -62,13 +63,12 @@ class BrowserActivity : ComponentActivity() {
62
  .accept(
63
  { ext ->
64
  Log.i("Nova", "Dev-console extension installed: ${ext?.id}")
65
- ext?.let {
66
- // Background script -> app channel.
67
- it.setMessageDelegate(NovaBackgroundMessageDelegate(), "browser")
68
- tabManager.wireExtension(it)
69
  }
70
  },
71
- { e -> Log.e("Nova", "Failed to install dev-console extension", e) }
72
  )
73
  }
74
 
@@ -95,9 +95,9 @@ class BrowserActivity : ComponentActivity() {
95
 
96
  // Switch the engine view whenever the active tab changes.
97
  LaunchedEffect(activeId) {
98
- activeId?.let { id ->
99
- tabManager.tabs.firstOrNull { it.id == id }?.let { geckoView.setSession(it.session) }
100
- }
101
  }
102
 
103
  Column(Modifier.fillMaxSize()) {
@@ -145,7 +145,7 @@ class BrowserActivity : ComponentActivity() {
145
  .heightIn(max = 72.dp),
146
  ) {
147
  Column(Modifier.padding(6.dp)) {
148
- lines.forEach { Text(it, style = MaterialTheme.typography.labelSmall, maxLines = 1) }
149
  }
150
  }
151
  }
 
13
  import androidx.compose.ui.Modifier
14
  import androidx.compose.ui.unit.dp
15
  import androidx.compose.ui.viewinterop.AndroidView
16
+ import org.mozilla.geckoview.GeckoResult
17
  import org.mozilla.geckoview.GeckoRuntime
18
  import org.mozilla.geckoview.GeckoView
19
  import org.mozilla.geckoview.WebExtension
 
63
  .accept(
64
  { ext ->
65
  Log.i("Nova", "Dev-console extension installed: ${ext?.id}")
66
+ ext?.let { installed ->
67
+ installed.setMessageDelegate(NovaBackgroundMessageDelegate(), "browser")
68
+ tabManager.wireExtension(installed)
 
69
  }
70
  },
71
+ { error -> Log.e("Nova", "Failed to install dev-console extension", error) }
72
  )
73
  }
74
 
 
95
 
96
  // Switch the engine view whenever the active tab changes.
97
  LaunchedEffect(activeId) {
98
+ val id = activeId ?: return@LaunchedEffect
99
+ val tab = tabManager.tabs.firstOrNull { t -> t.id == id } ?: return@LaunchedEffect
100
+ geckoView.setSession(tab.session)
101
  }
102
 
103
  Column(Modifier.fillMaxSize()) {
 
145
  .heightIn(max = 72.dp),
146
  ) {
147
  Column(Modifier.padding(6.dp)) {
148
+ lines.forEach { line -> Text(line, style = MaterialTheme.typography.labelSmall, maxLines = 1) }
149
  }
150
  }
151
  }