Offlin33er commited on
Commit
0eb1b34
·
verified ·
1 Parent(s): 5d43081

Wire AI chat/settings into the chrome-less shell; version 0.7.0

Browse files
app/src/main/java/dev/nova/browser/BrowserActivity.kt CHANGED
@@ -7,30 +7,43 @@ import androidx.activity.ComponentActivity
7
  import androidx.activity.OnBackPressedCallback
8
  import androidx.activity.compose.setContent
9
  import androidx.compose.foundation.layout.*
10
- import androidx.compose.foundation.lazy.LazyRow
11
- import androidx.compose.foundation.lazy.items
12
  import androidx.compose.material3.*
13
  import androidx.compose.runtime.*
 
14
  import androidx.compose.ui.Modifier
15
- import androidx.compose.ui.focus.onFocusChanged
16
- import androidx.compose.ui.platform.LocalFocusManager
17
- import androidx.compose.ui.text.style.TextOverflow
18
  import androidx.compose.ui.unit.dp
19
  import androidx.compose.ui.viewinterop.AndroidView
20
- import org.mozilla.geckoview.ContentBlocking
 
 
21
  import org.mozilla.geckoview.GeckoResult
22
  import org.mozilla.geckoview.GeckoRuntime
23
  import org.mozilla.geckoview.GeckoRuntimeSettings
24
- import org.mozilla.geckoview.GeckoSession
25
  import org.mozilla.geckoview.GeckoView
26
  import org.mozilla.geckoview.WebExtension
27
  import org.mozilla.geckoview.WebExtensionController
28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  class BrowserActivity : ComponentActivity() {
30
 
31
  companion object {
32
  // GeckoRuntime must be created exactly once per process (see GeckoView quick-start).
33
  private var runtime: GeckoRuntime? = null
 
 
 
34
  }
35
 
36
  private lateinit var tabManager: TabManager
@@ -39,59 +52,48 @@ class BrowserActivity : ComponentActivity() {
39
  super.onCreate(savedInstanceState)
40
 
41
  if (runtime == null) {
42
- // M6: content blocking (tracking protection) at the runtime level.
43
- // NB: the old GeckoSession.TrackingProtectionPolicy API is gone in
44
- // current GV; the modern API is ContentBlocking settings.
45
- // AntiTracking.DEFAULT = block ad, analytic, social and test trackers.
46
  runtime = GeckoRuntime.create(
47
  this,
48
  GeckoRuntimeSettings.Builder()
49
- .contentBlocking(
50
- ContentBlocking.Settings.Builder()
51
- .antiTracking(ContentBlocking.AntiTracking.DEFAULT)
52
- .cookieBehavior(ContentBlocking.CookieBehavior.ACCEPT_NON_TRACKERS)
53
- .build()
54
- )
55
  .build()
56
  )
57
- // Layer 2 of the dev console: desktop Firefox DevTools can attach
58
- // via about:debugging over USB / Wi-Fi. GV 147 API:
59
- // GeckoRuntimeSettings.setRemoteDebuggingEnabled(boolean).
60
  runtime!!.settings.setRemoteDebuggingEnabled(true)
61
 
62
- // M5: installs REQUIRE a prompt delegate (GV refuses otherwise).
63
- // The user decision is surfaced as a Compose dialog through
64
- // TabManager.pendingInstall.
65
- runtime!!.webExtensionController.setPromptDelegate(
66
- object : WebExtensionController.PromptDelegate {
67
- override fun onInstallPromptRequest(
68
- extension: WebExtension,
69
- permissions: Array<out String>,
70
- origins: Array<out String>,
71
- dataCollectionPermissions: Array<out String>,
72
- ): GeckoResult<WebExtension.PermissionPromptResponse> {
73
- val result = GeckoResult<WebExtension.PermissionPromptResponse>()
74
- val name = extension.metaData?.name ?: extension.id
75
- tabManager.pendingInstall.value = TabManager.InstallPrompt(
76
- name = name,
77
- permissions = permissions.toList(),
78
- origins = origins.toList(),
79
- ) { allow ->
80
- tabManager.pendingInstall.value = null
81
- result.complete(
82
- WebExtension.PermissionPromptResponse(allow, false, false)
83
  )
84
  }
85
- return result
86
  }
87
- }
88
- )
89
  }
90
  tabManager = TabManager(runtime!!, this)
91
 
92
  installDevConsoleExtension()
93
 
94
- // Hardware back button: navigate the page back before leaving the app.
95
  onBackPressedDispatcher.addCallback(this, object : OnBackPressedCallback(true) {
96
  override fun handleOnBackPressed() {
97
  if (tabManager.canGoBack()) {
@@ -124,10 +126,6 @@ class BrowserActivity : ComponentActivity() {
124
  tabManager.persistSession()
125
  }
126
 
127
- /**
128
- * Installs the bundled dev-console extension (idempotent) and wires the
129
- * background-script native messaging channel.
130
- */
131
  private fun installDevConsoleExtension() {
132
  val controller = runtime!!.webExtensionController
133
  controller.ensureBuiltIn("resource://android/assets/devconsole/", "devconsole@nova")
@@ -143,7 +141,6 @@ class BrowserActivity : ComponentActivity() {
143
  )
144
  }
145
 
146
- /** Receives messages from the extension's background script. */
147
  private inner class NovaBackgroundMessageDelegate : WebExtension.MessageDelegate {
148
  override fun onMessage(
149
  nativeApp: String,
@@ -156,75 +153,130 @@ class BrowserActivity : ComponentActivity() {
156
  }
157
 
158
  // ------------------------------------------------------------------
159
- // UI
160
  // ------------------------------------------------------------------
161
  @Composable
162
  private fun NovaUI() {
163
- var urlInput by remember { mutableStateOf("https://example.com") }
164
- var urlFocused by remember { mutableStateOf(false) }
165
  var trayOpen by remember { mutableStateOf(false) }
166
  var addonsOpen by remember { mutableStateOf(false) }
167
  var consoleOpen by remember { mutableStateOf(false) }
 
 
 
168
  val geckoView = remember { GeckoView(this) }
169
- val focusManager = LocalFocusManager.current
170
  val activeId by tabManager.activeTabId
171
 
172
- val canGoBack by remember { derivedStateOf { tabManager.canGoBack() } }
173
- val canGoForward by remember { derivedStateOf { tabManager.canGoForward() } }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
174
 
175
- // M3 add-ons manager state
176
- var extensions by remember { mutableStateOf<List<TabManager.ExtInfo>>(emptyList()) }
177
- var addonsLoading by remember { mutableStateOf(false) }
178
- var installMessage by remember { mutableStateOf("") }
 
 
 
 
 
 
 
 
179
 
180
  val loading = activeId != null && tabManager.loadingStates[activeId!!] == true
181
  val progress = activeId?.let { tabManager.progressStates[it] } ?: 0
182
 
183
- // M5: install permission prompt — visible over every screen.
184
- val pendingInstall by tabManager.pendingInstall
185
- pendingInstall?.let { prompt ->
186
- AlertDialog(
187
- onDismissRequest = { prompt.respond(false) },
188
- title = { Text("Install \"${prompt.name}\"?") },
189
- text = {
190
- Column {
191
- if (prompt.permissions.isEmpty()) {
192
- Text("This add-on requests no special permissions.")
193
- } else {
194
- Text("It requests access to:")
195
- prompt.permissions.forEach { Text("• $it") }
196
- }
197
- if (prompt.origins.isNotEmpty()) {
198
- Text("Site access:")
199
- prompt.origins.forEach { Text("• $it") }
200
- }
201
- }
202
- },
203
- confirmButton = {
204
- TextButton(onClick = { prompt.respond(true) }) { Text("Install") }
205
- },
206
- dismissButton = {
207
- TextButton(onClick = { prompt.respond(false) }) { Text("Cancel") }
208
- },
209
- )
210
- }
211
-
212
  // Re-attach the active session whenever we come back from any overlay.
213
- LaunchedEffect(activeId, trayOpen, addonsOpen, consoleOpen) {
214
  val id = activeId ?: return@LaunchedEffect
215
  val tab = tabManager.tabs.firstOrNull { t -> t.id == id } ?: return@LaunchedEffect
216
  geckoView.setSession(tab.session)
217
  }
218
 
219
- // M2: live URL sync — follow the active tab's navigation while the
220
- // user is not editing the address bar.
221
- val activeUrl = activeId?.let { tabManager.lastUrls[it] }
222
- LaunchedEffect(activeUrl) {
223
- if (!urlFocused && activeUrl != null) urlInput = activeUrl
 
 
 
 
 
 
224
  }
225
 
226
- // M2: autocomplete suggestions from history while typing
227
- val suggestions = if (urlFocused) tabManager.suggestionsFor(urlInput) else emptyList()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
228
 
229
  if (trayOpen) {
230
  TabTray(
@@ -240,6 +292,10 @@ class BrowserActivity : ComponentActivity() {
240
  }
241
 
242
  if (addonsOpen) {
 
 
 
 
243
  LaunchedEffect(Unit) {
244
  addonsLoading = true
245
  tabManager.refreshExtensions { list ->
@@ -254,7 +310,7 @@ class BrowserActivity : ComponentActivity() {
254
  installMessage = installMessage,
255
  onInstall = { input ->
256
  installMessage = "Installing…"
257
- tabManager.installFromAmo(input) { ok, msg -> installMessage = msg }
258
  },
259
  onToggle = { id, enabled -> tabManager.setExtensionEnabled(id, enabled) {} },
260
  onUninstall = { id -> tabManager.uninstallExtension(id) {} },
@@ -272,67 +328,14 @@ class BrowserActivity : ComponentActivity() {
272
  return
273
  }
274
 
275
- Column(Modifier.fillMaxSize()) {
276
- OutlinedTextField(
277
- value = urlInput,
278
- onValueChange = { urlInput = it },
279
- modifier = Modifier
280
- .fillMaxWidth()
281
- .padding(horizontal = 8.dp, vertical = 4.dp)
282
- .onFocusChanged { urlFocused = it.isFocused },
283
- label = { Text("Search or enter address") },
284
- singleLine = true,
285
  )
286
 
287
- // Autocomplete dropdown (history matches, most recent first)
288
- if (urlFocused && suggestions.isNotEmpty()) {
289
- Surface(
290
- tonalElevation = 4.dp,
291
- modifier = Modifier
292
- .fillMaxWidth()
293
- .padding(horizontal = 8.dp),
294
- ) {
295
- Column {
296
- suggestions.forEach { suggestion ->
297
- TextButton(
298
- onClick = {
299
- urlInput = suggestion
300
- urlFocused = false
301
- focusManager.clearFocus()
302
- tabManager.activeSession()?.loadUri(suggestion)
303
- },
304
- modifier = Modifier.fillMaxWidth(),
305
- ) {
306
- Text(suggestion, maxLines = 1, overflow = TextOverflow.Ellipsis)
307
- }
308
- }
309
- }
310
- }
311
- }
312
-
313
- Row(Modifier.padding(horizontal = 8.dp)) {
314
- TextButton(
315
- onClick = { tabManager.activeSession()?.goBack() },
316
- enabled = canGoBack,
317
- ) { Text("◀") }
318
- TextButton(
319
- onClick = { tabManager.activeSession()?.goForward() },
320
- enabled = canGoForward,
321
- ) { Text("▶") }
322
- TextButton(onClick = { tabManager.activeSession()?.reload() }) { Text("⟳") }
323
- TextButton(onClick = {
324
- focusManager.clearFocus()
325
- tabManager.activeSession()?.loadUri(normalize(urlInput))
326
- }) { Text("Go") }
327
- TextButton(onClick = { tabManager.open("about:blank") }) { Text("+") }
328
- TextButton(onClick = { trayOpen = true }) { Text("Tabs ${tabManager.tabs.size}") }
329
- TextButton(onClick = { addonsOpen = true }) { Text("Add-ons") }
330
- TextButton(onClick = { consoleOpen = true }) {
331
- Text("Console ${tabManager.consoleLines.size}")
332
- }
333
- }
334
-
335
- // M2: loading bar for the active tab
336
  if (loading) {
337
  LinearProgressIndicator(
338
  progress = { progress / 100f },
@@ -340,47 +343,20 @@ class BrowserActivity : ComponentActivity() {
340
  )
341
  }
342
 
343
- // Tab strip
344
- LazyRow(Modifier.padding(horizontal = 8.dp)) {
345
- items(tabManager.tabs, key = { it.id }) { tab ->
346
- AssistChip(
347
- onClick = { tabManager.activate(tab.id) },
348
- label = {
349
- Text(
350
- "Tab ${tab.id}" + (if (tab.id == activeId) " ●" else ""),
351
- maxLines = 1,
352
- )
353
- },
354
- trailingIcon = {
355
- TextButton(onClick = { tabManager.close(tab.id) }) { Text("✕") }
356
- },
357
- modifier = Modifier.padding(end = 4.dp),
358
- )
359
- }
360
- }
361
-
362
- // Console preview (full screen lives behind the Console button)
363
- val lines = tabManager.consoleLines.takeLast(3)
364
- if (lines.isNotEmpty()) {
365
- Surface(
366
- tonalElevation = 2.dp,
367
- modifier = Modifier
368
- .fillMaxWidth()
369
- .heightIn(max = 72.dp),
370
- ) {
371
- Column(Modifier.padding(6.dp)) {
372
- lines.forEach { line -> Text(line, style = MaterialTheme.typography.labelSmall, maxLines = 1) }
373
- }
374
- }
375
- }
376
-
377
- AndroidView(
378
- factory = { geckoView },
379
- modifier = Modifier.fillMaxWidth().weight(1f),
380
  )
381
  }
382
  }
383
 
 
 
384
  private fun normalize(input: String): String = when {
385
  input.startsWith("http://") || input.startsWith("https://") -> input
386
  input.startsWith("about:") -> input
 
7
  import androidx.activity.OnBackPressedCallback
8
  import androidx.activity.compose.setContent
9
  import androidx.compose.foundation.layout.*
 
 
10
  import androidx.compose.material3.*
11
  import androidx.compose.runtime.*
12
+ import androidx.compose.ui.Alignment
13
  import androidx.compose.ui.Modifier
 
 
 
14
  import androidx.compose.ui.unit.dp
15
  import androidx.compose.ui.viewinterop.AndroidView
16
+ import kotlinx.coroutines.Dispatchers
17
+ import kotlinx.coroutines.launch
18
+ import kotlinx.coroutines.withContext
19
  import org.mozilla.geckoview.GeckoResult
20
  import org.mozilla.geckoview.GeckoRuntime
21
  import org.mozilla.geckoview.GeckoRuntimeSettings
 
22
  import org.mozilla.geckoview.GeckoView
23
  import org.mozilla.geckoview.WebExtension
24
  import org.mozilla.geckoview.WebExtensionController
25
 
26
+ /**
27
+ * Nova: a chrome-less, unrestricted browser with a built-in AI.
28
+ *
29
+ * Unrestricted defaults:
30
+ * - NO tracking protection / content blocking (conventional browsers ship it on).
31
+ * - Extension install permissions AUTO-GRANTED (no prompts).
32
+ * - about:config enabled (full engine configuration surface).
33
+ * - Remote debugging always on (desktop Firefox DevTools via about:debugging).
34
+ *
35
+ * New UI paradigm: no URL bar, no toolbar, no tab strip. Content is
36
+ * edge-to-edge; a floating ⌘ button summons the command palette which routes
37
+ * everything (navigate, search, tabs, add-ons, console, AI).
38
+ */
39
  class BrowserActivity : ComponentActivity() {
40
 
41
  companion object {
42
  // GeckoRuntime must be created exactly once per process (see GeckoView quick-start).
43
  private var runtime: GeckoRuntime? = null
44
+
45
+ /** Unrestricted mode: install permission requests are auto-granted. */
46
+ private const val AUTO_GRANT_PERMISSIONS = true
47
  }
48
 
49
  private lateinit var tabManager: TabManager
 
52
  super.onCreate(savedInstanceState)
53
 
54
  if (runtime == null) {
55
+ // Unrestricted: no ContentBlocking settings passed — Gecko's default
56
+ // is no anti-tracking policy. about:config gives full engine access.
 
 
57
  runtime = GeckoRuntime.create(
58
  this,
59
  GeckoRuntimeSettings.Builder()
60
+ .aboutConfigEnabled(true)
 
 
 
 
 
61
  .build()
62
  )
63
+ // Desktop Firefox DevTools attach via about:debugging (USB / Wi-Fi).
 
 
64
  runtime!!.settings.setRemoteDebuggingEnabled(true)
65
 
66
+ // Unrestricted: install permission requests are auto-granted, no
67
+ // dialog. (GV refuses installs without a registered PromptDelegate
68
+ // that returns a GeckoResult, so we register one that always
69
+ // allows. Flip AUTO_GRANT_PERMISSIONS to false to restore prompts.)
70
+ if (AUTO_GRANT_PERMISSIONS) {
71
+ runtime!!.webExtensionController.setPromptDelegate(
72
+ object : WebExtensionController.PromptDelegate {
73
+ override fun onInstallPromptRequest(
74
+ extension: WebExtension,
75
+ permissions: Array<out String>,
76
+ origins: Array<out String>,
77
+ dataCollectionPermissions: Array<out String>,
78
+ ): GeckoResult<WebExtension.PermissionPromptResponse> {
79
+ Log.i(
80
+ "Nova",
81
+ "Auto-granting install permissions for ${extension.id}: " +
82
+ "permissions=${permissions.toList()} origins=${origins.toList()}"
83
+ )
84
+ return GeckoResult.fromValue(
85
+ WebExtension.PermissionPromptResponse(true, false, false)
 
86
  )
87
  }
 
88
  }
89
+ )
90
+ }
91
  }
92
  tabManager = TabManager(runtime!!, this)
93
 
94
  installDevConsoleExtension()
95
 
96
+ // Hardware back: navigate the page back before leaving the app.
97
  onBackPressedDispatcher.addCallback(this, object : OnBackPressedCallback(true) {
98
  override fun handleOnBackPressed() {
99
  if (tabManager.canGoBack()) {
 
126
  tabManager.persistSession()
127
  }
128
 
 
 
 
 
129
  private fun installDevConsoleExtension() {
130
  val controller = runtime!!.webExtensionController
131
  controller.ensureBuiltIn("resource://android/assets/devconsole/", "devconsole@nova")
 
141
  )
142
  }
143
 
 
144
  private inner class NovaBackgroundMessageDelegate : WebExtension.MessageDelegate {
145
  override fun onMessage(
146
  nativeApp: String,
 
153
  }
154
 
155
  // ------------------------------------------------------------------
156
+ // UI: edge-to-edge content + floating ⌘ + overlays
157
  // ------------------------------------------------------------------
158
  @Composable
159
  private fun NovaUI() {
160
+ var paletteOpen by remember { mutableStateOf(false) }
 
161
  var trayOpen by remember { mutableStateOf(false) }
162
  var addonsOpen by remember { mutableStateOf(false) }
163
  var consoleOpen by remember { mutableStateOf(false) }
164
+ var aiOpen by remember { mutableStateOf(false) }
165
+ var aiSettingsOpen by remember { mutableStateOf(false) }
166
+ var aiInitialPrompt by remember { mutableStateOf<String?>(null) }
167
  val geckoView = remember { GeckoView(this) }
 
168
  val activeId by tabManager.activeTabId
169
 
170
+ // --- AI state (hoisted so chat survives overlay switches) ---
171
+ var aiConfig by remember { mutableStateOf(AiStore.load(this@BrowserActivity)) }
172
+ val aiMessages = remember { mutableStateListOf<Pair<String, String>>() }
173
+ var aiBusy by remember { mutableStateOf(false) }
174
+ var aiError by remember { mutableStateOf<String?>(null) }
175
+ val aiScope = rememberCoroutineScope()
176
+
177
+ val sendAi: (String) -> Unit = { text ->
178
+ val t = text.trim()
179
+ if (t.isNotBlank() && !aiBusy) {
180
+ aiMessages.add("user" to t)
181
+ aiBusy = true
182
+ aiError = null
183
+ aiScope.launch {
184
+ val reply = try {
185
+ withContext(Dispatchers.IO) { AiClient.chat(aiConfig, aiMessages.toList()) }
186
+ } catch (e: Exception) {
187
+ Log.e("NovaAI", "AI call failed", e)
188
+ aiError = e.message ?: "AI call failed"
189
+ null
190
+ }
191
+ if (reply != null) aiMessages.add("assistant" to reply)
192
+ aiBusy = false
193
+ }
194
+ }
195
+ }
196
 
197
+ // A question launched from the palette ("ask_ai:...") sends immediately.
198
+ var pendingAiPrompt by remember { mutableStateOf<String?>(null) }
199
+ LaunchedEffect(pendingAiPrompt) {
200
+ val p = pendingAiPrompt
201
+ if (p != null) {
202
+ pendingAiPrompt = null
203
+ if (aiMessages.isEmpty()) sendAi(p)
204
+ else sendAi(p)
205
+ }
206
+ }
207
+ // (kept aiInitialPrompt for API compat with the palette flow)
208
+ val aiInitialPrompt = pendingAiPrompt
209
 
210
  val loading = activeId != null && tabManager.loadingStates[activeId!!] == true
211
  val progress = activeId?.let { tabManager.progressStates[it] } ?: 0
212
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
213
  // Re-attach the active session whenever we come back from any overlay.
214
+ LaunchedEffect(activeId, aiOpen, aiSettingsOpen, trayOpen, addonsOpen, consoleOpen) {
215
  val id = activeId ?: return@LaunchedEffect
216
  val tab = tabManager.tabs.firstOrNull { t -> t.id == id } ?: return@LaunchedEffect
217
  geckoView.setSession(tab.session)
218
  }
219
 
220
+ if (aiSettingsOpen) {
221
+ AiSettingsScreen(
222
+ config = aiConfig,
223
+ onSave = { cfg ->
224
+ aiConfig = cfg
225
+ AiStore.save(this, cfg)
226
+ aiSettingsOpen = false
227
+ },
228
+ onDismiss = { aiSettingsOpen = false },
229
+ )
230
+ return
231
  }
232
 
233
+ if (aiOpen) {
234
+ AiChatScreen(
235
+ config = aiConfig,
236
+ messages = aiMessages.toList(),
237
+ busy = aiBusy,
238
+ error = aiError,
239
+ onSend = sendAi,
240
+ onOpenSettings = { aiOpen = false; aiSettingsOpen = true },
241
+ onClear = { aiMessages.clear() },
242
+ onDismiss = { aiOpen = false },
243
+ )
244
+ return
245
+ }
246
+
247
+ if (paletteOpenState) {
248
+ CommandPalette(
249
+ tabCount = tabManager.tabs.size,
250
+ activeTabId = activeId,
251
+ onSubmit = { input ->
252
+ paletteOpenState = false
253
+ tabManager.activeSession()?.loadUri(normalize(input))
254
+ },
255
+ onCommand = { cmd ->
256
+ paletteOpenState = false
257
+ when {
258
+ cmd == "new_tab" -> tabManager.open("about:blank")
259
+ cmd == "close_tab" -> {
260
+ val id = activeId
261
+ if (id != null) tabManager.close(id)
262
+ }
263
+ cmd == "reload" -> tabManager.activeSession()?.reload()
264
+ cmd == "tray" -> trayOpen = true
265
+ cmd == "addons" -> addonsOpen = true
266
+ cmd == "console" -> consoleOpen = true
267
+ cmd == "clear_console" -> tabManager.consoleLines.clear()
268
+ cmd == "ai_chat" -> aiOpen = true
269
+ cmd == "ai_settings" -> aiSettingsOpen = true
270
+ cmd.startsWith("ask_ai:") -> {
271
+ aiOpen = true
272
+ pendingAiPrompt = cmd.removePrefix("ask_ai:")
273
+ }
274
+ }
275
+ },
276
+ onDismiss = { paletteOpenState = false },
277
+ )
278
+ return
279
+ }
280
 
281
  if (trayOpen) {
282
  TabTray(
 
292
  }
293
 
294
  if (addonsOpen) {
295
+ var extensions by remember { mutableStateOf<List<TabManager.ExtInfo>>(emptyList()) }
296
+ var addonsLoading by remember { mutableStateOf(false) }
297
+ var installMessage by remember { mutableStateOf("") }
298
+
299
  LaunchedEffect(Unit) {
300
  addonsLoading = true
301
  tabManager.refreshExtensions { list ->
 
310
  installMessage = installMessage,
311
  onInstall = { input ->
312
  installMessage = "Installing…"
313
+ tabManager.installFromAmo(input) { _, msg -> installMessage = msg }
314
  },
315
  onToggle = { id, enabled -> tabManager.setExtensionEnabled(id, enabled) {} },
316
  onUninstall = { id -> tabManager.uninstallExtension(id) {} },
 
328
  return
329
  }
330
 
331
+ // Chrome-less browsing surface
332
+ Box(Modifier.fillMaxSize()) {
333
+ AndroidView(
334
+ factory = { geckoView },
335
+ modifier = Modifier.fillMaxSize(),
 
 
 
 
 
336
  )
337
 
338
+ // Minimal status: loading bar hugging the top edge
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
339
  if (loading) {
340
  LinearProgressIndicator(
341
  progress = { progress / 100f },
 
343
  )
344
  }
345
 
346
+ // The single piece of chrome: ⌘ summons the palette
347
+ ExtendedFloatingActionButton(
348
+ text = { Text("⌘") },
349
+ icon = {},
350
+ onClick = { paletteOpenState = true },
351
+ modifier = Modifier
352
+ .align(Alignment.BottomEnd)
353
+ .padding(20.dp),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
354
  )
355
  }
356
  }
357
 
358
+ private var paletteOpenState by mutableStateOf(false)
359
+
360
  private fun normalize(input: String): String = when {
361
  input.startsWith("http://") || input.startsWith("https://") -> input
362
  input.startsWith("about:") -> input