Skip to content

CircleToSearch with multi search engine support for all android

Kotlin

fix: UI/UX

AKS Labs13a833c6bfc0
diff --git a/app/src/main/java/com/akslabs/circletosearch/CircleToSearchAccessibilityService.kt b/app/src/main/java/com/akslabs/circletosearch/CircleToSearchAccessibilityService.kt
index 703d2fc..037621b 100644
--- a/app/src/main/java/com/akslabs/circletosearch/CircleToSearchAccessibilityService.kt
+++ b/app/src/main/java/com/akslabs/circletosearch/CircleToSearchAccessibilityService.kt
@@ -254,7 +254,11 @@ class CircleToSearchAccessibilityService : AccessibilityService() {
private fun updateOverlay() {
val config = configManager.getConfig()
- if (!config.isEnabled) {
+ // 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) {
overlayViews.forEach {
try { windowManager?.removeView(it) } catch(e: Exception) {}
}
@@ -330,8 +334,8 @@ class CircleToSearchAccessibilityService : AccessibilityService() {
}
}
- // Update Color (Debug)
- if (config.isVisible) {
+ // Update Color (Debug / dropdown preview)
+ if (config.isVisible || previewing) {
val color = themePalette[index % themePalette.size]
val drawable = GradientDrawable().apply {
setColor(color)
@@ -382,7 +386,7 @@ class CircleToSearchAccessibilityService : AccessibilityService() {
params.y = segment.yOffset +
if (segment.yOffset == 0) (3 * resources.displayMetrics.density).toInt() else 0
- if (config.isVisible) {
+ if (config.isVisible || previewing) {
val color = themePalette[index % themePalette.size]
val drawable = GradientDrawable().apply {
setColor(color)
diff --git a/app/src/main/java/com/akslabs/circletosearch/data/OverlayConfig.kt b/app/src/main/java/com/akslabs/circletosearch/data/OverlayConfig.kt
index 6c1246a..ecb1c40 100644
--- a/app/src/main/java/com/akslabs/circletosearch/data/OverlayConfig.kt
+++ b/app/src/main/java/com/akslabs/circletosearch/data/OverlayConfig.kt
@@ -14,6 +14,7 @@ data class OverlayConfig(
@SerializedName("isEnabled") val isEnabled: Boolean = true,
@SerializedName("isEnabledInLandscape") val isEnabledInLandscape: Boolean = false,
@SerializedName("isVisible") val isVisible: Boolean = false, // Debug visibility (colored)
+ @SerializedName("previewVisible") val previewVisible: Boolean = false, // true only while the settings dropdown is open
@SerializedName("activeSegmentIndex") val activeSegmentIndex: Int = -1, // Currently being edited in settings
@SerializedName("segments") val segments: List<OverlaySegment> = listOf(OverlaySegment(width = 1080)) // Default to a common large width
)
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.kt
index 11dcf34..20641e1 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
@@ -109,6 +109,7 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.foundation.Canvas
import androidx.core.app.ActivityOptionsCompat
+import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleEventObserver
import androidx.lifecycle.compose.LocalLifecycleOwner
import com.akslabs.circletosearch.MainActivity
@@ -216,6 +217,8 @@ fun WobbleHomeScreen(
}
var showHwSheet by remember { mutableStateOf(false) }
var bottomEdge by remember { mutableStateOf(configManager.getBottomEdgeConfig()) }
+ var statusBarExpanded by remember { mutableStateOf(false) }
+ var bottomEdgeExpanded by remember { mutableStateOf(false) }
val bottomEdgeActive = bottomEdge.leftEnabled || bottomEdge.rightEnabled || bottomEdge.midEnabled
val hwEnabledCount = hwTriggers.values.count { it }
val running = assistantGranted ||
@@ -233,7 +236,15 @@ fun WobbleHomeScreen(
val lifecycleOwner = LocalLifecycleOwner.current
DisposableEffect(lifecycleOwner) {
- val observer = LifecycleEventObserver { _, _ -> refreshHomeState() }
+ val observer = LifecycleEventObserver { _, event ->
+ refreshHomeState()
+ if (event == Lifecycle.Event.ON_STOP) {
+ // Switching away from the app closes both settings dropdowns, which
+ // also drops their on-screen overlay previews.
+ statusBarExpanded = false
+ bottomEdgeExpanded = false
+ }
+ }
lifecycleOwner.lifecycle.addObserver(observer)
onDispose { lifecycleOwner.lifecycle.removeObserver(observer) }
}
@@ -551,6 +562,8 @@ fun WobbleHomeScreen(
HomeStatusBarSection(
config = overlayConfig,
a11yGranted = a11yGranted,
+ expanded = statusBarExpanded,
+ onExpandedChange = { statusBarExpanded = it },
onChange = saveOverlayConfig,
)
HomeRowDivider()
@@ -566,6 +579,8 @@ fun WobbleHomeScreen(
HomeBottomEdgeSection(
config = bottomEdge,
a11yGranted = a11yGranted,
+ expanded = bottomEdgeExpanded,
+ onExpandedChange = { bottomEdgeExpanded = it },
onChange = saveBottomEdge,
)
HomeRowDivider()
@@ -867,10 +882,11 @@ private fun HomeHwSheet(
private fun HomeStatusBarSection(
config: OverlayConfig,
a11yGranted: Boolean,
+ expanded: Boolean,
+ onExpandedChange: (Boolean) -> Unit,
onChange: (OverlayConfig) -> Unit,
) {
val masterOn = config.isEnabled
- var expanded by remember { mutableStateOf(false) }
val density = LocalDensity.current
val expandProgress by animateFloatAsState(
targetValue = if (expanded) 1f else 0f,
@@ -878,6 +894,14 @@ private fun HomeStatusBarSection(
label = "statusBarExpand",
)
+ // Keep the strip on screen (as a tinted preview) while the dropdown is open so
+ // slider adjustments are visible live; closing the dropdown hides it again.
+ LaunchedEffect(expanded) {
+ if (config.previewVisible != expanded) {
+ onChange(config.copy(previewVisible = expanded))
+ }
+ }
+
val segment = config.segments.firstOrNull() ?: OverlaySegment()
fun saveSegment(newSegment: OverlaySegment) {
val segments = config.segments.toMutableList()
@@ -895,7 +919,7 @@ private fun HomeStatusBarSection(
Row(
modifier = Modifier
.fillMaxWidth()
- .clickable(enabled = a11yGranted) { expanded = !expanded }
+ .clickable(enabled = a11yGranted) { onExpandedChange(!expanded) }
.padding(horizontal = 16.dp, vertical = 12.dp),
verticalAlignment = Alignment.CenterVertically,
) {
@@ -930,7 +954,7 @@ private fun HomeStatusBarSection(
enabled = a11yGranted,
onCheckedChange = { on ->
onChange(config.copy(isEnabled = on))
- if (on) expanded = true
+ if (on) onExpandedChange(true)
},
)
}
@@ -983,7 +1007,7 @@ private fun HomeStatusBarSection(
LabelledSlider(
label = stringResource(R.string.home_statusbar_width),
value = widthDp,
- valueRange = 60f..(screenWidthDp - 40f).coerceAtLeast(120f),
+ valueRange = 60f..maxOf(screenWidthDp, widthDp),
valueText = "${widthDp.toInt()}dp",
onValueChange = {
saveSegment(segment.copy(width = (it * density.density).toInt()))
@@ -1026,10 +1050,11 @@ private fun HomeStatusBarSection(
private fun HomeBottomEdgeSection(
config: BottomEdgeConfig,
a11yGranted: Boolean,
+ expanded: Boolean,
+ onExpandedChange: (Boolean) -> Unit,
onChange: (BottomEdgeConfig) -> Unit,
) {
val masterOn = config.leftEnabled || config.rightEnabled || config.midEnabled
- var expanded by remember { mutableStateOf(false) }
// Keep preview in sync with expansion state.
LaunchedEffect(expanded) {
@@ -1059,7 +1084,7 @@ private fun HomeBottomEdgeSection(
Row(
modifier = Modifier
.fillMaxWidth()
- .clickable(enabled = a11yGranted) { expanded = !expanded }
+ .clickable(enabled = a11yGranted) { onExpandedChange(!expanded) }
.padding(horizontal = 16.dp, vertical = 12.dp),
verticalAlignment = Alignment.CenterVertically,
) {
@@ -1101,7 +1126,7 @@ private fun HomeBottomEdgeSection(
midEnabled = if (on) config.midEnabled else false,
),
)
- if (on) expanded = true
+ if (on) onExpandedChange(true)
},
)
}
diff --git a/app/src/main/java/com/akslabs/circletosearch/ui/wobblepulldown/WobbleSetupWizard.kt b/app/src/main/java/com/akslabs/circletosearch/ui/wobblepulldown/WobbleSetupWizard.kt
index 7afaed0..e63f0cf 100644
--- a/app/src/main/java/com/akslabs/circletosearch/ui/wobblepulldown/WobbleSetupWizard.kt
+++ b/app/src/main/java/com/akslabs/circletosearch/ui/wobblepulldown/WobbleSetupWizard.kt
@@ -5,6 +5,7 @@ import android.os.Build
import android.provider.Settings
import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.result.contract.ActivityResultContracts
+import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
@@ -43,6 +44,7 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
+import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalView
@@ -111,6 +113,12 @@ fun WobbleSetupWizard(modifier: Modifier = Modifier) {
}
Box(modifier = modifier.fillMaxSize()) {
+ // Dim everything outside the wizard card, same weight as the accessibility dialog.
+ Box(
+ modifier = Modifier
+ .fillMaxSize()
+ .background(Color.Black.copy(alpha = 0.10f)),
+ )
Surface(
shape = RoundedCornerShape(bottomStart = 28.dp, bottomEnd = 28.dp),
color = MaterialTheme.colorScheme.surfaceContainer,