CircleToSearch with multi search engine support for all android
Kotlin
fix: custom overlay screen
AKS Labsd343e14ff960
diff --git a/app/src/main/java/com/akslabs/circletosearch/CircleToSearchAccessibilityService.kt b/app/src/main/java/com/akslabs/circletosearch/CircleToSearchAccessibilityService.ktindex cb8bb55..9de5789 100644--- a/app/src/main/java/com/akslabs/circletosearch/CircleToSearchAccessibilityService.kt+++ b/app/src/main/java/com/akslabs/circletosearch/CircleToSearchAccessibilityService.kt@@ -323,14 +323,24 @@ class CircleToSearchAccessibilityService : AccessibilityService() {}}+ /** Force a rebuild/redraw from the latest saved config (called by the settings UI). */+ fun refreshOverlays() {+ if (!::configManager.isInitialized) return+ updateOverlay()+ updateBottomEdgeOverlays()+ }+private fun updateOverlay() {val config = configManager.getConfig()-+// Keep strips alive while their settings dropdown is open (preview), even// when the master switch is off, and tint them so slider adjustments are// visible live (normal running strips are fully transparent).val previewing = config.previewVisible- if (!config.isEnabled && !config.previewVisible) {+ // "Show overlay" or an open segment preview forces the strips to exist and+ // tint — including in landscape, so position can be adjusted on-device.+ val forceShow = config.isVisible || previewing+ if (!config.isEnabled && !forceShow) {overlayViews.forEach {try { windowManager?.removeView(it) } catch(e: Exception) {}}@@ -370,7 +380,7 @@ class CircleToSearchAccessibilityService : AccessibilityService() {// Landscape checkval currentOrientation = resources.configuration.orientation- if (currentOrientation == Configuration.ORIENTATION_LANDSCAPE && !config.isEnabledInLandscape) {+ if (currentOrientation == Configuration.ORIENTATION_LANDSCAPE && !config.isEnabledInLandscape && !forceShow) {overlayViews.forEach {try { windowManager?.removeView(it) } catch(e: Exception) {}}@@ -411,10 +421,12 @@ class CircleToSearchAccessibilityService : AccessibilityService() {val color = themePalette[index % themePalette.size]val drawable = GradientDrawable().apply {setColor(color)- // Only show solid primary border for the expanded/active overlay- if (index == config.activeSegmentIndex) {- setStroke(3, primaryColor)- }+ // Outline every visible strip so its position is obvious while+ // adjusting; the strip being edited gets a thicker border.+ setStroke(+ if (index == config.activeSegmentIndex) 3 else 2,+ primaryColor+ )}view.background = drawableview.elevation = 0f@@ -462,10 +474,12 @@ class CircleToSearchAccessibilityService : AccessibilityService() {val color = themePalette[index % themePalette.size]val drawable = GradientDrawable().apply {setColor(color)- // Only show solid primary border for the expanded/active overlay- if (index == config.activeSegmentIndex) {- setStroke(3, primaryColor)- }+ // Outline every visible strip so its position is obvious while+ // adjusting; the strip being edited gets a thicker border.+ setStroke(+ if (index == config.activeSegmentIndex) 3 else 2,+ primaryColor+ )}view.background = drawableview.elevation = 0fdiff --git a/app/src/main/java/com/akslabs/circletosearch/MainActivity.kt b/app/src/main/java/com/akslabs/circletosearch/MainActivity.ktindex 7254bc6..32eb485 100644--- a/app/src/main/java/com/akslabs/circletosearch/MainActivity.kt+++ b/app/src/main/java/com/akslabs/circletosearch/MainActivity.kt@@ -160,8 +160,8 @@ class MainActivity : ComponentActivity() {)context.startActivity(intent, options.toBundle())},- onOpenSettings = {- pendingSettingsPage = null+ onOpenSettings = { page ->+ pendingSettingsPage = pagecurrentScreen = "settings"},wobbleEvent = wobbleTick,diff --git a/app/src/main/java/com/akslabs/circletosearch/ui/OverlaySettingsScreen.kt b/app/src/main/java/com/akslabs/circletosearch/ui/OverlaySettingsScreen.ktindex 341dbf6..da1adad 100644--- a/app/src/main/java/com/akslabs/circletosearch/ui/OverlaySettingsScreen.kt+++ b/app/src/main/java/com/akslabs/circletosearch/ui/OverlaySettingsScreen.kt@@ -7,6 +7,7 @@ package com.akslabs.circletosearch.uiimport android.content.Contextimport android.content.Intentimport android.net.Uri+import android.provider.Settingsimport androidx.compose.animation.AnimatedContentimport androidx.compose.animation.core.CubicBezierEasingimport androidx.compose.animation.core.tween@@ -39,8 +40,12 @@ import android.os.Buildimport androidx.compose.ui.unit.dpimport androidx.compose.ui.window.Dialogimport androidx.compose.ui.window.DialogProperties+import androidx.lifecycle.Lifecycle+import androidx.lifecycle.LifecycleEventObserver+import androidx.lifecycle.compose.LocalLifecycleOwnerimport androidx.compose.ui.res.stringResourceimport com.akslabs.circletosearch.R+import com.akslabs.circletosearch.CircleToSearchAccessibilityServiceimport com.akslabs.circletosearch.data.*import com.akslabs.circletosearch.isAccessibilityServiceEnabledimport com.akslabs.circletosearch.ui.components.DonateBottomSheet@@ -92,6 +97,9 @@ private class OverlaySettingsState(context: Context) {fun updateConfig(newConfig: OverlayConfig) {_config.value = newConfigconfigManager.saveConfig(newConfig)+ // Direct refresh: don't rely solely on the SharedPreferences listener,+ // some devices delay it — poke the running service so changes apply live.+ CircleToSearchAccessibilityService.instance?.refreshOverlays()}private val _bubbleEnabled = mutableStateOf(appPrefs.getBoolean("bubble_enabled", false))@@ -132,12 +140,16 @@ fun OverlaySettingsScreen(val backStack = remember {val startPage = settingsPageFromName(initialPage)if (startPage != null) {- mutableStateListOf<SettingsPage>(SettingsPage.Root, startPage)+ // Deep link (e.g. "Custom overlay" row): start directly on the target+ // page — back from it returns home, not to the settings root.+ mutableStateListOf<SettingsPage>(startPage)} else {mutableStateListOf<SettingsPage>(SettingsPage.Root)}}- val pop: () -> Unit = { backStack.removeAt(backStack.lastIndex) }+ val pop: () -> Unit = {+ if (backStack.size > 1) backStack.removeAt(backStack.lastIndex) else onBack()+ }androidx.activity.compose.BackHandler {if (backStack.size > 1) pop() else onBack()@@ -237,34 +249,6 @@ private fun SettingsRootScreen() {Spacer(modifier = Modifier.height(8.dp))SettingsGroup {- SettingsCategoryRow(- icon = Icons.Default.RocketLaunch,- title = stringResource(R.string.triggers_card_title),- subtitle = stringResource(R.string.settings_cat_triggers_subtitle),- onClick = { onNavigate(SettingsPage.Triggers) }- )- SettingsGroupDivider()- SettingsCategoryRow(- icon = Icons.Default.Layers,- title = stringResource(R.string.settings_cat_zones),- subtitle = stringResource(R.string.settings_cat_zones_subtitle),- onClick = { onNavigate(SettingsPage.Zones) }- )- SettingsGroupDivider()- SettingsCategoryRow(- icon = Icons.Default.Search,- title = stringResource(R.string.settings_cat_search),- subtitle = stringResource(R.string.settings_cat_search_subtitle),- onClick = { onNavigate(SettingsPage.Search) }- )- SettingsGroupDivider()- SettingsCategoryRow(- icon = Icons.Default.Tune,- title = stringResource(R.string.general),- subtitle = stringResource(R.string.settings_cat_general_subtitle),- onClick = { onNavigate(SettingsPage.General) }- )- SettingsGroupDivider()SettingsCategoryRow(icon = Icons.Default.Info,title = stringResource(R.string.settings_cat_about),@@ -385,6 +369,31 @@ private fun ZonesSettingsScreen(val config = state.configval overlayPalette = rememberOverlayPalette(context)+ // Overlay strips can only render while the accessibility service is running.+ // Re-check on resume so enabling the service elsewhere updates this screen.+ var a11yOn by remember { mutableStateOf(isAccessibilityServiceEnabled(context)) }+ val lifecycleOwner = LocalLifecycleOwner.current+ DisposableEffect(lifecycleOwner) {+ val observer = LifecycleEventObserver { _, event ->+ if (event == Lifecycle.Event.ON_RESUME) {+ a11yOn = isAccessibilityServiceEnabled(context)+ }+ }+ lifecycleOwner.lifecycle.addObserver(observer)+ onDispose { lifecycleOwner.lifecycle.removeObserver(observer) }+ }++ // Clear the editing preview when leaving the screen (deep-link back goes+ // straight home, so no later screen reset can happen).+ DisposableEffect(Unit) {+ onDispose {+ val cfg = state.config+ if (cfg.previewVisible || cfg.activeSegmentIndex != -1) {+ state.updateConfig(cfg.copy(previewVisible = false, activeSegmentIndex = -1))+ }+ }+ }+SettingsDetailScaffold(title = stringResource(R.string.settings_cat_zones),onBack = onBack,@@ -395,6 +404,46 @@ private fun ZonesSettingsScreen(}) {Spacer(modifier = Modifier.height(8.dp))++ if (!a11yOn) {+ Surface(+ shape = RoundedCornerShape(16.dp),+ color = MaterialTheme.colorScheme.errorContainer,+ modifier = Modifier.fillMaxWidth(),+ ) {+ Row(+ modifier = Modifier.padding(16.dp),+ verticalAlignment = Alignment.CenterVertically+ ) {+ Icon(+ Icons.Default.Warning,+ contentDescription = null,+ tint = MaterialTheme.colorScheme.onErrorContainer+ )+ Spacer(modifier = Modifier.width(12.dp))+ Column(modifier = Modifier.weight(1f)) {+ Text(+ text = stringResource(R.string.overlay_a11y_off_title),+ style = MaterialTheme.typography.bodyLarge,+ color = MaterialTheme.colorScheme.onErrorContainer+ )+ Text(+ text = stringResource(R.string.overlay_a11y_off_subtitle),+ style = MaterialTheme.typography.bodyMedium,+ color = MaterialTheme.colorScheme.onErrorContainer+ )+ }+ Spacer(modifier = Modifier.width(12.dp))+ TextButton(onClick = {+ context.startActivity(Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS))+ }) {+ Text(stringResource(R.string.overlay_a11y_off_enable))+ }+ }+ }+ Spacer(modifier = Modifier.height(12.dp))+ }+Row(modifier = Modifier.fillMaxWidth(),horizontalArrangement = Arrangement.SpaceBetween,@@ -428,7 +477,9 @@ private fun ZonesSettingsScreen(isExpanded = config.activeSegmentIndex == index,onExpandToggle = {val nextIndex = if (config.activeSegmentIndex == index) -1 else index- state.updateConfig(config.copy(activeSegmentIndex = nextIndex))+ // While a segment editor is open, force the real overlay strips+ // visible so position/size changes can be seen live.+ state.updateConfig(config.copy(activeSegmentIndex = nextIndex, previewVisible = nextIndex != -1))},onUpdate = { updatedSegment ->val newSegments = config.segments.toMutableList()@@ -441,7 +492,7 @@ private fun ZonesSettingsScreen(val nextActiveIndex = if (config.activeSegmentIndex == index) -1else if (config.activeSegmentIndex > index) config.activeSegmentIndex - 1else config.activeSegmentIndex- state.updateConfig(config.copy(segments = newSegments, activeSegmentIndex = nextActiveIndex))+ state.updateConfig(config.copy(segments = newSegments, activeSegmentIndex = nextActiveIndex, previewVisible = nextActiveIndex != -1))})Spacer(modifier = Modifier.height(16.dp))diff --git a/app/src/main/java/com/akslabs/circletosearch/ui/wobblepulldown/WobbleHomeScreen.kt b/app/src/main/java/com/akslabs/circletosearch/ui/wobblepulldown/WobbleHomeScreen.ktindex c4010e8..4043c30 100644--- a/app/src/main/java/com/akslabs/circletosearch/ui/wobblepulldown/WobbleHomeScreen.kt+++ b/app/src/main/java/com/akslabs/circletosearch/ui/wobblepulldown/WobbleHomeScreen.kt@@ -638,9 +638,18 @@ fun WobbleHomeScreen(modifier = Modifier.fillMaxWidth(),) {Column {+ HomeLinkRow(+ icon = Icons.Default.Layers,+ title = stringResource(R.string.home_custom_overlay),+ subtitle = null,+ onClick = {+ if (onOpenSettings != null) onOpenSettings("zones") else openSettingsPage("zones")+ },+ )+ HomeRowDivider()HomeLinkRow(icon = Icons.Default.Tune,- title = stringResource(R.string.title_settings),+ title = stringResource(R.string.home_additional_settings),subtitle = null,onClick = {if (onOpenSettings != null) onOpenSettings("") else openSettingsPage("")diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xmlindex 5f5d75f..f04a02a 100644--- a/app/src/main/res/values/strings.xml+++ b/app/src/main/res/values/strings.xml@@ -163,6 +163,9 @@<string name="overlay_setting_landscape_subtitle">Keep overlay active in landscape</string><string name="overlay_setting_show_title">Show Overlay</string><string name="overlay_setting_show_subtitle">Show overlay to adjust position</string>+ <string name="overlay_a11y_off_title">Accessibility service is off</string>+ <string name="overlay_a11y_off_subtitle">Overlay strips can\'t appear until the accessibility service is enabled</string>+ <string name="overlay_a11y_off_enable">Enable</string><string name="section_overlays">Overlays</string><string name="btn_add_overlay">Add Overlay</string><string name="label_no_overlays">No overlays added. Click Add Overlay to start.</string>@@ -359,7 +362,7 @@<!-- Settings hierarchy --><string name="settings_cat_triggers_subtitle">Status bar, bubble & hardware buttons</string>- <string name="settings_cat_zones">Overlay zones</string>+ <string name="settings_cat_zones">Custom overlay</string><string name="settings_cat_zones_subtitle">Position, size & gestures</string><string name="settings_cat_search">Search</string><string name="settings_cat_search_subtitle">Lens or Multi-Search launch mode</string>@@ -384,6 +387,8 @@<string name="home_running_title">Circle to search</string><string name="home_running_state">running</string><string name="home_section_more">More</string>+ <string name="home_custom_overlay">Custom overlay</string>+ <string name="home_additional_settings">Additional settings</string><string name="home_bottom_edge_title">Bottom edge long-press</string><string name="home_bottom_edge_subtitle">Hold a bottom corner or the centre to search</string><string name="home_corner_left">Left</string>