Skip to content

CircleToSearch with multi search engine support for all android

Kotlin

chores: UI/UX

AKS Labsc881bde36969
diff --git a/.idea/deploymentTargetSelector.xml b/.idea/deploymentTargetSelector.xml
index d531c7e..dff28b0 100644
--- a/.idea/deploymentTargetSelector.xml
+++ b/.idea/deploymentTargetSelector.xml
@@ -4,10 +4,10 @@
<selectionStates>
<SelectionState runConfigName="app">
<option name="selectionMode" value="DROPDOWN" />
- <DropdownSelection timestamp="2026-10-09T16:15:33.190334200Z">
+ <DropdownSelection timestamp="2026-10-10T05:47:22.124172800Z">
<Target type="DEFAULT_BOOT">
<handle>
- <DeviceId pluginId="Wireless" identifier="serviceName=adb-9c872922-KLor6Z" />
+ <DeviceId pluginId="PhysicalDevice" identifier="serial=9c872922" />
</handle>
</Target>
</DropdownSelection>
diff --git a/app/src/main/java/com/akslabs/circletosearch/CircleToSearchAccessibilityService.kt b/app/src/main/java/com/akslabs/circletosearch/CircleToSearchAccessibilityService.kt
index a38ee85..703d2fc 100644
--- a/app/src/main/java/com/akslabs/circletosearch/CircleToSearchAccessibilityService.kt
+++ b/app/src/main/java/com/akslabs/circletosearch/CircleToSearchAccessibilityService.kt
@@ -99,10 +99,14 @@ private const val KEY_DOUBLE_TAP_MS = 350L
// fire twice (e.g. the second tap of a double-tap counting again later)
private const val KEY_TRIGGER_COOLDOWN_MS = 900L
+// Shape variants for the bottom-edge long-press overlays.
+private enum class BottomEdgeShape { ARC_LEFT, ARC_RIGHT, SEMICIRCLE }
+
class CircleToSearchAccessibilityService : AccessibilityService() {
private var windowManager: WindowManager? = null
private val overlayViews = mutableListOf<View>() // Track all added segment views
+ private val bottomEdgeViews = mutableListOf<BottomEdgeOverlayView>() // Track bottom-edge corner/mid overlays
private val executor: Executor = Executors.newSingleThreadExecutor()
private lateinit var configManager: OverlayConfigurationManager
@@ -125,6 +129,7 @@ class CircleToSearchAccessibilityService : AccessibilityService() {
private val overlayPrefsListener = SharedPreferences.OnSharedPreferenceChangeListener { _, _ ->
// On any overlay config change, rebuild the overlay
updateOverlay()
+ updateBottomEdgeOverlays()
}
override fun onServiceConnected() {
@@ -161,11 +166,13 @@ class CircleToSearchAccessibilityService : AccessibilityService() {
updateBubbleState()
updateOverlay()
+ updateBottomEdgeOverlays()
}
override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig)
updateOverlay()
+ updateBottomEdgeOverlays()
}
private fun updateBubbleState() {
@@ -310,7 +317,10 @@ class CircleToSearchAccessibilityService : AccessibilityService() {
if (params.width != segment.width) { params.width = segment.width; changed = true }
if (params.height != segment.height) { params.height = segment.height; changed = true }
if (params.x != segment.xOffset) { params.x = segment.xOffset; changed = true }
- if (params.y != segment.yOffset) { params.y = segment.yOffset; changed = true }
+ // Keep strips that sit at the very top (status-bar trigger) 3dp below the edge.
+ val targetY = segment.yOffset +
+ if (segment.yOffset == 0) (3 * resources.displayMetrics.density).toInt() else 0
+ if (params.y != targetY) { params.y = targetY; changed = true }
if (changed) {
try {
@@ -368,7 +378,9 @@ class CircleToSearchAccessibilityService : AccessibilityService() {
params.gravity = Gravity.TOP or Gravity.START
params.x = segment.xOffset
- params.y = segment.yOffset
+ // Keep strips that sit at the very top (status-bar trigger) 3dp below the edge.
+ params.y = segment.yOffset +
+ if (segment.yOffset == 0) (3 * resources.displayMetrics.density).toInt() else 0
if (config.isVisible) {
val color = themePalette[index % themePalette.size]
@@ -398,9 +410,93 @@ class CircleToSearchAccessibilityService : AccessibilityService() {
}
}
}
+
+ /**
+ * Bottom-edge long-press triggers (two corner arcs + optional bottom-centre semicircle).
+ * Deliberately kept in their own list and NOT gated by [OverlayConfig.isEnabled], so
+ * toggling the status-bar overlay can never add/remove them (previously they shared the
+ * segment list and got wiped together).
+ */
+ private fun updateBottomEdgeOverlays() {
+ val wm = windowManager ?: return
+ val cfg = configManager.getBottomEdgeConfig()
+
+ // Drop everything and rebuild: simplest correct approach for max 3 views.
+ bottomEdgeViews.forEach { view ->
+ try { wm.removeView(view) } catch (_: Exception) {}
+ }
+ bottomEdgeViews.clear()
+
+ val dm = resources.displayMetrics
+ val density = dm.density
+ // Full display bounds (displayMetrics can exclude bars, which made the overlays
+ // float or sit off-screen, clipping the right corner's border).
+ val bounds = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
+ wm.maximumWindowMetrics.bounds
+ } else {
+ null
+ }
+ val screenW = bounds?.width() ?: dm.widthPixels
+ val screenH = bounds?.height() ?: dm.heightPixels
+
+ val accent = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
+ getColor(android.R.color.system_accent1_400)
+ } else {
+ Color.parseColor("#FF6200EE")
+ }
+
+ fun addView(view: BottomEdgeOverlayView, w: Int, h: Int, x: Int, y: Int) {
+ val params = WindowManager.LayoutParams(
+ w, h,
+ WindowManager.LayoutParams.TYPE_ACCESSIBILITY_OVERLAY,
+ WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE or
+ WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL or
+ WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN or
+ WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
+ PixelFormat.TRANSLUCENT
+ )
+ params.gravity = Gravity.TOP or Gravity.START
+ params.x = x
+ params.y = y
+ try {
+ wm.addView(view, params)
+ bottomEdgeViews.add(view)
+ } catch (e: Exception) {
+ e.printStackTrace()
+ }
+ }
+
+ val cornerSizePx = (cfg.cornerSizeDp * density).toInt().coerceAtLeast(48)
+ val midSizePx = (cfg.midSizeDp * density).toInt().coerceAtLeast(48)
+ // Flush with the very bottom of the screen (no nav-bar inset).
+ val bottomBase = screenH
+
+ if (cfg.leftEnabled) {
+ addView(
+ BottomEdgeOverlayView(this, BottomEdgeShape.ARC_LEFT, cfg.previewVisible, accent),
+ cornerSizePx, cornerSizePx, 0, bottomBase - cornerSizePx,
+ )
+ }
+ if (cfg.rightEnabled) {
+ addView(
+ BottomEdgeOverlayView(this, BottomEdgeShape.ARC_RIGHT, cfg.previewVisible, accent),
+ cornerSizePx, cornerSizePx, screenW - cornerSizePx, bottomBase - cornerSizePx,
+ )
+ }
+ if (cfg.midEnabled) {
+ addView(
+ BottomEdgeOverlayView(this, BottomEdgeShape.SEMICIRCLE, cfg.previewVisible, accent),
+ midSizePx * 2, midSizePx, (screenW - midSizePx * 2) / 2, bottomBase - midSizePx,
+ )
+ }
+ }
@SuppressLint("ClickableViewAccessibility")
private fun attachTouchListener(view: View, segment: OverlaySegment, segmentIndex: Int) {
+ // Slow drags and taps on an overlay must still reach the system UI below
+ // (notification shade / quick settings on the status bar, the app under a strip).
+ var lastScrollForwardAt = 0L
+ var scrollForwardedThisGesture = false
val gestureDetector = GestureDetector(this, object : GestureDetector.SimpleOnGestureListener() {
override fun onDoubleTap(e: MotionEvent): Boolean {
val action = segment.gestures[GestureType.DOUBLE_TAP] ?: ActionType.NONE
@@ -413,6 +509,39 @@ class CircleToSearchAccessibilityService : AccessibilityService() {
if (action != ActionType.NONE) performAction(action, segment)
}
+ override fun onScroll(e1: MotionEvent?, e2: MotionEvent, distanceX: Float, distanceY: Float): Boolean {
+ if (e1 == null) return false
+ val dx = e2.rawX - e1.rawX
+ val dy = e2.rawY - e1.rawY
+ // Only treat this as a real drag once the finger has clearly moved — tiny
+ // jitter during a tap/double-tap must NOT be forwarded (forwarding briefly
+ // makes the window untouchable and swallows the second tap).
+ val minForwardDist = 40 * resources.displayMetrics.density
+ if (Math.abs(dx) < minForwardDist && Math.abs(dy) < minForwardDist) return false
+ val mostlyVertical = Math.abs(dy) > Math.abs(dx)
+ val direction = when {
+ mostlyVertical && dy > 0 -> GestureType.SWIPE_DOWN
+ mostlyVertical && dy < 0 -> GestureType.SWIPE_UP
+ dx > 0 -> GestureType.SWIPE_RIGHT
+ else -> GestureType.SWIPE_LEFT
+ }
+ // A configured custom action wins: don't forward, let the fling handler trigger it.
+ val custom = segment.gestures[direction]
+ if (custom != null && custom != ActionType.NONE) return false
+ // Otherwise forward the drag so the system below still tracks it
+ // (e.g. pulling down the notification shade / quick settings on the status bar).
+ val now = android.os.SystemClock.uptimeMillis()
+ if (now - lastScrollForwardAt < 180L) return true
+ lastScrollForwardAt = now
+ scrollForwardedThisGesture = true
+ val path = android.graphics.Path().apply {
+ moveTo(e1.rawX, e1.rawY)
+ lineTo(e2.rawX, e2.rawY)
+ }
+ forwardPassthroughGesture(view, path, 140)
+ return true
+ }
+
override fun onSingleTapConfirmed(e: MotionEvent): Boolean {
// User wants "buttons behind to be clickable"
// We temporarily disable touch on our window and dispatch the click through.
@@ -422,6 +551,9 @@ class CircleToSearchAccessibilityService : AccessibilityService() {
override fun onFling(e1: MotionEvent?, e2: MotionEvent, velocityX: Float, velocityY: Float): Boolean {
if (e1 == null) return false
+ // This drag was already forwarded to the system below; don't also fire
+ // a global action (would open the shade a second time).
+ if (scrollForwardedThisGesture) return true
val diffY = e2.y - e1.y
val diffX = e2.x - e1.x
@@ -485,7 +617,11 @@ class CircleToSearchAccessibilityService : AccessibilityService() {
}
}).apply {
setOnDoubleTapListener(object : GestureDetector.OnDoubleTapListener {
- override fun onSingleTapConfirmed(e: MotionEvent): Boolean = false
+ override fun onSingleTapConfirmed(e: MotionEvent): Boolean {
+ // Forward single taps so status-bar taps still reach the system UI below.
+ propagateSingleTap(view, e.rawX, e.rawY)
+ return false
+ }
override fun onDoubleTap(e: MotionEvent): Boolean {
val action = segment.gestures[GestureType.DOUBLE_TAP] ?: ActionType.NONE
if (action != ActionType.NONE) { performAction(action, segment); return true }
@@ -500,6 +636,7 @@ class CircleToSearchAccessibilityService : AccessibilityService() {
view.setOnTouchListener { _, event ->
if (event.action == MotionEvent.ACTION_DOWN) {
+ scrollForwardedThisGesture = false
val currentTime = System.currentTimeMillis()
if (currentTime - lastTapTime < 400) {
tapCount++
@@ -668,45 +805,12 @@ class CircleToSearchAccessibilityService : AccessibilityService() {
}
// Pass-through Logic for Single Tap
- // We must temporarily make the window UNTOUCHABLE so the injected gesture falls through to the app below.
- // Otherwise, the injected tap hits our own overlay (loop/blocked).
+ // Temporarily makes the window untouchable, injects the tap, and (via
+ // forwardPassthroughGesture) guarantees the window is restored even if the
+ // dispatch fails — a missing restore would leave the overlay dead.
private fun propagateSingleTap(view: View, x: Float, y: Float) {
- val params = view.layoutParams as WindowManager.LayoutParams
- val originalFlags = params.flags
-
- // Make untouchable
- params.flags = params.flags or WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
- windowManager?.updateViewLayout(view, params)
-
val path = android.graphics.Path().apply { moveTo(x, y) }
- val stroke = android.accessibilityservice.GestureDescription.StrokeDescription(path, 0, 50) // 50ms tap duration (more standard)
- val gesture = android.accessibilityservice.GestureDescription.Builder().addStroke(stroke).build()
-
- // Wait for WindowManager to update input focus before dispatching
- val handler = android.os.Handler(android.os.Looper.getMainLooper())
- handler.postDelayed({
- dispatchGesture(gesture, object : android.accessibilityservice.AccessibilityService.GestureResultCallback() {
- override fun onCompleted(gestureDescription: android.accessibilityservice.GestureDescription?) {
- restoreFlags()
- }
-
- override fun onCancelled(gestureDescription: android.accessibilityservice.GestureDescription?) {
- restoreFlags()
- }
-
- fun restoreFlags() {
- // Restore original flags (Touchable) using main thread to be safe with UI
- handler.post {
- params.flags = originalFlags
- try {
- windowManager?.updateViewLayout(view, params)
- } catch (e: Exception) {
- // View might be removed
- }
- }
- }
- }, null)
- }, 100) // 100ms Delay to ensure 'untouchable' takes effect solidly
+ forwardPassthroughGesture(view, path, 50)
}
private fun toggleFlashlight() {
@@ -1653,7 +1757,282 @@ class CircleToSearchAccessibilityService : AccessibilityService() {
e.printStackTrace()
}
}
+ bottomEdgeViews.forEach { view ->
+ try { windowManager?.removeView(view) } catch (_: Exception) {}
+ }
+ bottomEdgeViews.clear()
hideBubble()
}
+
+ /**
+ * Forwards a synthetic gesture (tap or swipe) to whatever is underneath an overlay window.
+ * The overlay is temporarily made FLAG_NOT_TOUCHABLE so the dispatched stroke reaches the app
+ * below instead of being swallowed by our own window.
+ */
+ private fun forwardPassthroughGesture(
+ view: View,
+ path: android.graphics.Path,
+ durationMs: Long,
+ ) {
+ val params = view.layoutParams as WindowManager.LayoutParams
+ val originalFlags = params.flags
+ params.flags = params.flags or WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
+ try { windowManager?.updateViewLayout(view, params) } catch (_: Exception) {}
+
+ val stroke = android.accessibilityservice.GestureDescription.StrokeDescription(path, 0, durationMs)
+ val gesture = android.accessibilityservice.GestureDescription.Builder().addStroke(stroke).build()
+ val handler = android.os.Handler(android.os.Looper.getMainLooper())
+
+ // The window MUST become touchable again no matter what: if it stayed
+ // FLAG_NOT_TOUCHABLE the overlay would silently stop receiving touches and
+ // long-press would appear dead until the service rebuilt the views.
+ var restored = false
+ fun restore() {
+ if (restored) return
+ restored = true
+ handler.post {
+ params.flags = originalFlags
+ try { windowManager?.updateViewLayout(view, params) } catch (_: Exception) {}
+ }
+ }
+
+ handler.postDelayed({
+ val dispatched = try {
+ dispatchGesture(
+ gesture,
+ object : android.accessibilityservice.AccessibilityService.GestureResultCallback() {
+ override fun onCompleted(g: android.accessibilityservice.GestureDescription?) { restore() }
+ override fun onCancelled(g: android.accessibilityservice.GestureDescription?) { restore() }
+ },
+ null,
+ )
+ } catch (e: Exception) {
+ false
+ }
+ // dispatchGesture returns false when a gesture is already running (or the
+ // service can't dispatch): restore immediately instead of waiting forever.
+ if (!dispatched) restore()
+ // Safety net: never leave the window untouchable for more than a moment.
+ handler.postDelayed({ restore() }, durationMs + 1000L)
+ }, 100)
+ }
+
+ /**
+ * A transparent, click-through overlay that sits at a bottom corner (arc) or bottom-centre
+ * (semicircle). It only reacts to a LONG-PRESS (which triggers Circle to Search); taps and
+ * swipes are forwarded to the app underneath so it never blocks normal interaction.
+ * When [isPreview] is true it draws a translucent filled shape so the user can see/size it.
+ */
+ private inner class BottomEdgeOverlayView(
+ context: android.content.Context,
+ private val shape: BottomEdgeShape,
+ private var isPreview: Boolean,
+ private val accent: Int,
+ ) : android.view.View(context) {
+
+ private val fillPaint = android.graphics.Paint(android.graphics.Paint.ANTI_ALIAS_FLAG).apply {
+ style = android.graphics.Paint.Style.FILL
+ }
+ private val strokePaint = android.graphics.Paint(android.graphics.Paint.ANTI_ALIAS_FLAG).apply {
+ style = android.graphics.Paint.Style.STROKE
+ strokeWidth = 3f * resources.displayMetrics.density
+ }
+
+ private val handler = android.os.Handler(android.os.Looper.getMainLooper())
+ private val touchSlop = android.view.ViewConfiguration.get(context).scaledTouchSlop
+ // Long-press stays alive while the finger drifts a little (more tolerant than
+ // the system tap slop) so slight jitter doesn't kill the gesture.
+ private val longPressSlop = touchSlop * 1.5f
+ private val longPressTimeoutMs = 400L
+ // Minimum gap between forwarded scroll segments (each one briefly makes the
+ // window untouchable and dispatches a synthetic gesture).
+ private val scrollForwardIntervalMs = 180L
+
+ private var downX = 0f
+ private var downY = 0f
+ private var lastScrollRawX = 0f
+ private var lastScrollRawY = 0f
+ private var lastScrollForwardAt = 0L
+ private var longPressConsumed = false
+ private var scrollForwarded = false
+
+ private val longPressRunnable = Runnable {
+ if (longPressConsumed || scrollForwarded) return@Runnable
+ longPressConsumed = true
+ hapticClick()
+ performCapture(null)
+ }
+
+ private fun hapticClick() {
+ val vibrator = getSystemService(Context.VIBRATOR_SERVICE) as android.os.Vibrator
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
+ vibrator.vibrate(android.os.VibrationEffect.createPredefined(android.os.VibrationEffect.EFFECT_CLICK))
+ } else {
+ @Suppress("DEPRECATION") vibrator.vibrate(20)
+ }
+ }
+
+ private fun forwardPath(path: android.graphics.Path, durationMs: Long) {
+ forwardPassthroughGesture(this@BottomEdgeOverlayView, path, durationMs)
+ }
+
+ override fun onDetachedFromWindow() {
+ handler.removeCallbacksAndMessages(null)
+ super.onDetachedFromWindow()
+ }
+
+ /** Hit test: only the shaped region consumes touches; the bounding-box corners pass through. */
+ private fun hitTest(x: Float, y: Float): Boolean {
+ val w = width.toFloat()
+ val h = height.toFloat()
+ return when (shape) {
+ BottomEdgeShape.ARC_LEFT -> {
+ // Quarter disc centred at bottom-left corner (0, h), radius = w.
+ val dx = x; val dy = h - y
+ dx * dx + dy * dy <= w * w
+ }
+ BottomEdgeShape.ARC_RIGHT -> {
+ val dx = w - x; val dy = h - y
+ dx * dx + dy * dy <= w * w
+ }
+ BottomEdgeShape.SEMICIRCLE -> {
+ // Half disc centred at (w/2, h), radius = h, upper half only.
+ val dx = x - w / 2f; val dy = h - y
+ dy >= 0f && dx * dx + dy * dy <= h * h
+ }
+ }
+ }
+
+ override fun onDraw(canvas: android.graphics.Canvas) {
+ super.onDraw(canvas)
+ if (!isPreview) return
+ val w = width.toFloat()
+ val h = height.toFloat()
+
+ fun buildPath(inset: Float): android.graphics.Path {
+ val path = android.graphics.Path()
+ when (shape) {
+ BottomEdgeShape.ARC_LEFT -> {
+ // Quarter disc centred on the bottom-left corner of the view.
+ val r = minOf(w, h) - inset
+ path.moveTo(inset, h - inset)
+ path.lineTo(inset, h - inset - r)
+ path.arcTo(
+ android.graphics.RectF(inset - r, h - inset - r, inset + r, h - inset + r),
+ 270f, 90f,
+ )
+ path.close()
+ }
+ BottomEdgeShape.ARC_RIGHT -> {
+ // Quarter disc centred on the bottom-right corner of the view.
+ val r = minOf(w, h) - inset
+ path.moveTo(w - inset, h - inset)
+ path.lineTo(w - inset, h - inset - r)
+ path.arcTo(
+ android.graphics.RectF(w - inset - r, h - inset - r, w - inset + r, h - inset + r),
+ 270f, -90f,
+ )
+ path.close()
+ }
+ BottomEdgeShape.SEMICIRCLE -> {
+ // Upper half disc centred on the bottom-centre of the view.
+ val r = minOf(w / 2f, h) - inset
+ path.moveTo(w / 2f - r, h - inset)
+ path.arcTo(
+ android.graphics.RectF(w / 2f - r, h - inset - r, w / 2f + r, h - inset + r),
+ 180f, 180f,
+ )
+ path.close()
+ }
+ }
+ return path
+ }
+
+ val a = (0.28f * 255).toInt()
+ fillPaint.color = android.graphics.Color.argb(
+ a, android.graphics.Color.red(accent), android.graphics.Color.green(accent), android.graphics.Color.blue(accent),
+ )
+ strokePaint.color = android.graphics.Color.argb(
+ (0.6f * 255).toInt(), android.graphics.Color.red(accent), android.graphics.Color.green(accent), android.graphics.Color.blue(accent),
+ )
+ // Even border, guaranteed: the fill sits half a stroke width from the view
+ // (screen) edge, and the stroke is placed so its OUTER edge lands exactly on
+ // the fill boundary. The stroke therefore lies entirely on top of the fill
+ // (one uniform tone along the whole border), is never clipped by the view
+ // bounds, and leaves no fill rim outside the border.
+ val sw = strokePaint.strokeWidth
+ canvas.drawPath(buildPath(sw / 2f), fillPaint)
+ canvas.drawPath(buildPath(sw), strokePaint)
+ }
+
+ @SuppressLint("ClickableViewAccessibility")
+ override fun onTouchEvent(event: MotionEvent): Boolean {
+ when (event.actionMasked) {
+ MotionEvent.ACTION_DOWN -> {
+ // Only the shaped region consumes touches; the bounding-box
+ // corners pass straight through to the app underneath.
+ if (!hitTest(event.x, event.y)) return false
+ downX = event.x
+ downY = event.y
+ lastScrollRawX = event.rawX
+ lastScrollRawY = event.rawY
+ lastScrollForwardAt = 0L
+ longPressConsumed = false
+ scrollForwarded = false
+ handler.removeCallbacks(longPressRunnable)
+ handler.postDelayed(longPressRunnable, longPressTimeoutMs)
+ return true
+ }
+ MotionEvent.ACTION_MOVE -> {
+ if (longPressConsumed) return true
+ val dx = event.x - downX
+ val dy = event.y - downY
+ val dist = Math.sqrt((dx * dx + dy * dy).toDouble()).toFloat()
+ if (dist > longPressSlop) {
+ // Moved like a swipe: cancel the pending long-press and keep
+ // forwarding the drag so the app underneath still scrolls.
+ if (!scrollForwarded) {
+ scrollForwarded = true
+ handler.removeCallbacks(longPressRunnable)
+ }
+ val now = android.os.SystemClock.uptimeMillis()
+ if (now - lastScrollForwardAt >= scrollForwardIntervalMs) {
+ lastScrollForwardAt = now
+ val path = android.graphics.Path().apply {
+ moveTo(lastScrollRawX, lastScrollRawY)
+ lineTo(event.rawX, event.rawY)
+ }
+ lastScrollRawX = event.rawX
+ lastScrollRawY = event.rawY
+ forwardPath(path, 120)
+ }
+ }
+ // Small drift keeps the long-press timer running (jitter tolerant).
+ return true
+ }
+ MotionEvent.ACTION_UP -> {
+ handler.removeCallbacks(longPressRunnable)
+ if (!longPressConsumed && !scrollForwarded) {
+ // Stationary release = tap: forward immediately so taps behave
+ // exactly like they do without the overlay.
+ forwardPath(android.graphics.Path().apply { moveTo(event.rawX, event.rawY) }, 50)
+ }
+ return true
+ }
+ MotionEvent.ACTION_CANCEL -> {
+ handler.removeCallbacks(longPressRunnable)
+ return true
+ }
+ else -> return true
+ }
+ }
+
+ fun setPreview(value: Boolean) {
+ if (isPreview != value) {
+ isPreview = value
+ invalidate()
+ }
+ }
+ }
}
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 13b89ad..6c1246a 100644
--- a/app/src/main/java/com/akslabs/circletosearch/data/OverlayConfig.kt
+++ b/app/src/main/java/com/akslabs/circletosearch/data/OverlayConfig.kt
@@ -27,6 +27,20 @@ data class OverlaySegment(
@SerializedName("gestureData") val gestureData: MutableMap<GestureType, String> = mutableMapOf() // Stores extra data like package name for OPEN_APP
)
+/**
+ * Dedicated config for the bottom-edge long-press triggers (two corner arcs + one
+ * bottom-centre semicircle). Stored separately from [OverlayConfig.segments] so that
+ * toggling the status-bar overlay ([OverlayConfig.isEnabled]) can never add/remove them.
+ */
+data class BottomEdgeConfig(
+ @SerializedName("leftEnabled") val leftEnabled: Boolean = true,
+ @SerializedName("rightEnabled") val rightEnabled: Boolean = true,
+ @SerializedName("midEnabled") val midEnabled: Boolean = false,
+ @SerializedName("cornerSizeDp") val cornerSizeDp: Int = 72, // arc radius-ish size
+ @SerializedName("midSizeDp") val midSizeDp: Int = 48, // semicircle size (actual overlay)
+ @SerializedName("previewVisible") val previewVisible: Boolean = false, // true only while settings dropdown open
+)
+
enum class GestureType {
DOUBLE_TAP,
LONG_PRESS,
@@ -100,7 +114,9 @@ class OverlayConfigurationManager(context: Context) {
private val gson = Gson()
companion object {
- private const val KEY_CONFIG = "overlay_config"
+private const val KEY_CONFIG = "overlay_config"
+private const val KEY_BOTTOM_EDGE = "bottom_edge_config"
+private const val KEY_BOTTOM_EDGE_MID_MIGRATED = "bottom_edge_mid_migrated_v1"
}
fun getConfig(): OverlayConfig {
@@ -131,4 +147,28 @@ class OverlayConfigurationManager(context: Context) {
fun resetConfig() {
prefs.edit().remove(KEY_CONFIG).apply()
}
+
+ fun getBottomEdgeConfig(): BottomEdgeConfig {
+ val json = prefs.getString(KEY_BOTTOM_EDGE, null) ?: return BottomEdgeConfig()
+ val cfg = try {
+ gson.fromJson(json, BottomEdgeConfig::class.java) ?: BottomEdgeConfig()
+ } catch (e: Exception) {
+ return BottomEdgeConfig()
+ }
+ // One-time migration: the old mid-overlay defaults (96dp, later 64dp) were too
+ // large for the actual on-screen semicircle — shrink them to the new 48dp default.
+ if (!prefs.getBoolean(KEY_BOTTOM_EDGE_MID_MIGRATED, false) && cfg.midSizeDp >= 64) {
+ val migrated = cfg.copy(midSizeDp = 48)
+ prefs.edit()
+ .putString(KEY_BOTTOM_EDGE, gson.toJson(migrated))
+ .putBoolean(KEY_BOTTOM_EDGE_MID_MIGRATED, true)
+ .apply()
+ return migrated
+ }
+ return cfg
+ }
+
+ fun saveBottomEdgeConfig(config: BottomEdgeConfig) {
+ prefs.edit().putString(KEY_BOTTOM_EDGE, gson.toJson(config)).apply()
+ }
}
diff --git a/app/src/main/java/com/akslabs/circletosearch/ui/components/AccessibilityDisclosureDialog.kt b/app/src/main/java/com/akslabs/circletosearch/ui/components/AccessibilityDisclosureDialog.kt
index 77793d9..d257643 100644
--- a/app/src/main/java/com/akslabs/circletosearch/ui/components/AccessibilityDisclosureDialog.kt
+++ b/app/src/main/java/com/akslabs/circletosearch/ui/components/AccessibilityDisclosureDialog.kt
@@ -1,17 +1,23 @@
package com.akslabs.circletosearch.ui.components
+import android.view.WindowManager
+import androidx.compose.foundation.clickable
+import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.*
+import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.font.FontWeight
-import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
-import androidx.compose.ui.unit.sp
+import androidx.compose.ui.window.Dialog
import androidx.compose.ui.window.DialogProperties
+import androidx.compose.ui.window.DialogWindowProvider
+import androidx.compose.ui.platform.LocalView
import com.akslabs.circletosearch.R
@Composable
@@ -20,59 +26,116 @@ fun AccessibilityDisclosureDialog(
onDismiss: () -> Unit
) {
var hasAgreed by remember { mutableStateOf(false) }
+ // System dim (FLAG_DIM_BEHIND) covers the whole screen edge-to-edge; fall back to a
+ // light internal scrim only if the dialog window can't be reached.
+ var hasWindowDim by remember { mutableStateOf(false) }
+ val view = LocalView.current
+ SideEffect {
+ val dialogWindow = (view.parent as? DialogWindowProvider)?.window
+ if (dialogWindow != null) {
+ dialogWindow.addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND)
+ dialogWindow.attributes = dialogWindow.attributes.apply { dimAmount = 0.10f }
+ if (!hasWindowDim) hasWindowDim = true
+ }
+ }
- AlertDialog(
+ Dialog(
onDismissRequest = onDismiss,
properties = DialogProperties(
dismissOnBackPress = true,
- dismissOnClickOutside = true
- ),
- title = {
- Text(
- text = stringResource(R.string.title_accessibility_permission),
- style = MaterialTheme.typography.titleLarge,
- fontWeight = FontWeight.Bold
- )
- },
- text = {
- Column {
- Text(
- text = stringResource(R.string.body_accessibility_permission),
- style = MaterialTheme.typography.bodyMedium,
- color = MaterialTheme.colorScheme.onSurfaceVariant
+ dismissOnClickOutside = true,
+ usePlatformDefaultWidth = false,
+ decorFitsSystemWindows = false
+ )
+ ) {
+ Box(
+ modifier = Modifier
+ .fillMaxSize()
+ .then(
+ if (hasWindowDim) Modifier
+ else Modifier.clickable(
+ interactionSource = remember { MutableInteractionSource() },
+ indication = null,
+ onClick = onDismiss,
+ )
)
-
- Spacer(modifier = Modifier.height(16.dp))
-
- Row(
- verticalAlignment = Alignment.CenterVertically,
- modifier = Modifier.fillMaxWidth()
+ .padding(24.dp),
+ contentAlignment = Alignment.Center,
+ ) {
+ Surface(
+ shape = RoundedCornerShape(28.dp),
+ color = MaterialTheme.colorScheme.surfaceContainerHigh,
+ tonalElevation = 6.dp,
+ shadowElevation = 16.dp,
+ // Consume clicks so taps on the card body don't reach the scrim.
+ modifier = Modifier
+ .fillMaxWidth()
+ .clickable(
+ interactionSource = remember { MutableInteractionSource() },
+ indication = null,
+ onClick = {},
+ ),
+ ) {
+ Column(
+ modifier = Modifier
+ .fillMaxWidth()
+ .verticalScroll(rememberScrollState())
+ .padding(24.dp),
) {
- Checkbox(
- checked = hasAgreed,
- onCheckedChange = { hasAgreed = it }
+ Text(
+ text = stringResource(R.string.title_accessibility_permission),
+ style = MaterialTheme.typography.titleLarge,
+ fontWeight = FontWeight.Bold
)
+
+ Spacer(modifier = Modifier.height(16.dp))
+
Text(
- text = stringResource(R.string.label_accessibility_agree),
- style = MaterialTheme.typography.labelSmall,
- modifier = Modifier.padding(start = 4.dp),
+ text = stringResource(R.string.body_accessibility_permission),
+ style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
+
+ Spacer(modifier = Modifier.height(16.dp))
+
+ Row(
+ verticalAlignment = Alignment.CenterVertically,
+ modifier = Modifier
+ .fillMaxWidth()
+ .clickable { hasAgreed = !hasAgreed }
+ ) {
+ Checkbox(
+ checked = hasAgreed,
+ onCheckedChange = { hasAgreed = it }
+ )
+ Text(
+ text = stringResource(R.string.label_accessibility_agree),
+ style = MaterialTheme.typography.labelSmall,
+ modifier = Modifier.padding(start = 4.dp),
+ color = MaterialTheme.colorScheme.onSurfaceVariant
+ )
+ }
+
+ Spacer(modifier = Modifier.height(8.dp))
+
+ Row(
+ modifier = Modifier.fillMaxWidth(),
+ horizontalArrangement = Arrangement.End,
+ verticalAlignment = Alignment.CenterVertically,
+ ) {
+ TextButton(onClick = onDismiss) {
+ Text(stringResource(R.string.btn_cancel))
+ }
+ Spacer(modifier = Modifier.width(8.dp))
+ TextButton(
+ onClick = onAccept,
+ enabled = hasAgreed
+ ) {
+ Text(stringResource(R.string.btn_grant), fontWeight = FontWeight.Bold)
+ }
+ }
}
}
- },
- confirmButton = {
- TextButton(
- onClick = onAccept,
- enabled = hasAgreed
- ) {
- Text(stringResource(R.string.btn_grant), fontWeight = FontWeight.Bold)
- }
- },
- dismissButton = {
- TextButton(onClick = onDismiss) {
- Text(stringResource(R.string.btn_cancel))
- }
}
- )
+ }
}
diff --git a/app/src/main/java/com/akslabs/circletosearch/ui/wobblepulldown/WobbleAppInfoScreen.kt b/app/src/main/java/com/akslabs/circletosearch/ui/wobblepulldown/WobbleAppInfoScreen.kt
index 57e23a8..c5f1b2a 100644
--- a/app/src/main/java/com/akslabs/circletosearch/ui/wobblepulldown/WobbleAppInfoScreen.kt
+++ b/app/src/main/java/com/akslabs/circletosearch/ui/wobblepulldown/WobbleAppInfoScreen.kt
@@ -198,6 +198,7 @@ fun WobbleAppInfoScreen(
var assistantGranted by remember { mutableStateOf(isAssistantGranted(context)) }
var launchMethods by remember { mutableStateOf(loadLaunchMethods(context)) }
var showDisclosure by remember { mutableStateOf(false) }
+ var showAssistantSheet by remember { mutableStateOf(false) }
val refreshPermissions = {
a11yGranted = isA11yGranted(context)
@@ -245,6 +246,13 @@ fun WobbleAppInfoScreen(
)
}
+ if (showAssistantSheet) {
+ AssistantSetupSheet(
+ onLaunch = { intent -> settingsLauncher.launch(intent) },
+ onDismiss = { showAssistantSheet = false },
+ )
+ }
+
val grantedCount = (if (a11yGranted) 1 else 0) + (if (assistantGranted) 1 else 0)
val activeTriggerCount = launchMethods.count { it.status == TriggerStatus.ACTIVE }
@@ -420,7 +428,13 @@ fun WobbleAppInfoScreen(
granted = a11yGranted,
onClick = {
WobbleHaptics.performUIHaptic(view)
- showDisclosure = true
+ if (a11yGranted) {
+ runCatching {
+ settingsLauncher.launch(Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS))
+ }
+ } else {
+ showDisclosure = true
+ }
},
)
@@ -431,9 +445,7 @@ fun WobbleAppInfoScreen(
granted = assistantGranted,
onClick = {
WobbleHaptics.performUIHaptic(view)
- runCatching {
- settingsLauncher.launch(Intent(Settings.ACTION_VOICE_INPUT_SETTINGS))
- }
+ showAssistantSheet = true
},
)
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 bee7e1f..11dcf34 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
@@ -3,13 +3,22 @@ package com.akslabs.circletosearch.ui.wobblepulldown
import android.content.Context
import android.content.Intent
import android.provider.Settings
+import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.animateColorAsState
import androidx.compose.animation.core.Spring
import androidx.compose.animation.core.animateDpAsState
+import androidx.compose.animation.core.animateFloat
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.animateIntAsState
+import androidx.compose.animation.core.infiniteRepeatable
+import androidx.compose.animation.core.rememberInfiniteTransition
+import androidx.compose.animation.core.RepeatMode
import androidx.compose.animation.core.spring
import androidx.compose.animation.core.tween
+import androidx.compose.animation.expandVertically
+import androidx.compose.animation.fadeIn
+import androidx.compose.animation.fadeOut
+import androidx.compose.animation.shrinkVertically
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
@@ -25,6 +34,7 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
@@ -40,17 +50,25 @@ import androidx.compose.material.icons.filled.Translate
import androidx.compose.material.icons.filled.Tune
import androidx.compose.material.icons.filled.Widgets
import androidx.compose.material.icons.rounded.KeyboardArrowDown
+import androidx.compose.material3.ButtonGroup
+import androidx.compose.material3.ButtonGroupDefaults
+import androidx.compose.material3.ButtonShapes
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.ExperimentalMaterial3Api
+import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
import androidx.compose.material3.FilledTonalButton
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.ModalBottomSheet
import androidx.compose.material3.OutlinedCard
+import androidx.compose.material3.ShapeDefaults
+import androidx.compose.material3.Slider
import androidx.compose.material3.Surface
import androidx.compose.material3.Switch
import androidx.compose.material3.Text
+import androidx.compose.material3.ToggleButton
+import androidx.compose.material3.ToggleButtonDefaults
import androidx.compose.material3.pulltorefresh.PullToRefreshBox
import androidx.compose.material3.pulltorefresh.rememberPullToRefreshState
import androidx.compose.runtime.Composable
@@ -64,12 +82,19 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
+import androidx.compose.ui.draw.clip
import androidx.compose.ui.geometry.Offset
+import androidx.compose.ui.geometry.Rect
+import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.graphics.Path
+import androidx.compose.ui.graphics.StrokeCap
+import androidx.compose.ui.graphics.drawscope.Stroke
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.layout.positionInRoot
+import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.LocalView
@@ -79,15 +104,19 @@ import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontVariation
import androidx.compose.ui.text.font.FontWeight
+import androidx.compose.ui.text.style.TextAlign
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.LifecycleEventObserver
import androidx.lifecycle.compose.LocalLifecycleOwner
import com.akslabs.circletosearch.MainActivity
import com.akslabs.circletosearch.R
import com.akslabs.circletosearch.data.ActionType
+import com.akslabs.circletosearch.data.BottomEdgeConfig
import com.akslabs.circletosearch.data.GestureType
+import com.akslabs.circletosearch.data.OverlayConfig
import com.akslabs.circletosearch.data.OverlayConfigurationManager
import com.akslabs.circletosearch.data.OverlaySegment
import com.akslabs.circletosearch.ui.SettingsSectionHeader
@@ -180,29 +209,26 @@ fun WobbleHomeScreen(
var a11yGranted by remember { mutableStateOf(isA11yGranted(context)) }
var assistantGranted by remember { mutableStateOf(isAssistantGranted(context)) }
var overlayEnabled by remember { mutableStateOf(configManager.getConfig().isEnabled) }
+ var overlayConfig by remember { mutableStateOf(configManager.getConfig()) }
var bubbleEnabled by remember { mutableStateOf(appPrefs.getBoolean("bubble_enabled", false)) }
var hwTriggers by remember {
mutableStateOf(HW_TRIGGER_KEYS.associateWith { appPrefs.getBoolean(it, false) })
}
var showHwSheet by remember { mutableStateOf(false) }
- var bottomEdgeOn by remember {
- mutableStateOf(
- configManager.getConfig().segments
- .any { it.gestureData[GestureType.LONG_PRESS] == BOTTOM_EDGE_MARKER },
- )
- }
+ var bottomEdge by remember { mutableStateOf(configManager.getBottomEdgeConfig()) }
+ val bottomEdgeActive = bottomEdge.leftEnabled || bottomEdge.rightEnabled || bottomEdge.midEnabled
val hwEnabledCount = hwTriggers.values.count { it }
val running = assistantGranted ||
- (a11yGranted && (overlayEnabled || bubbleEnabled || bottomEdgeOn || hwEnabledCount > 0))
+ (a11yGranted && (overlayEnabled || bubbleEnabled || bottomEdgeActive || hwEnabledCount > 0))
val refreshHomeState = {
a11yGranted = isA11yGranted(context)
assistantGranted = isAssistantGranted(context)
overlayEnabled = configManager.getConfig().isEnabled
+ overlayConfig = configManager.getConfig()
bubbleEnabled = appPrefs.getBoolean("bubble_enabled", false)
hwTriggers = HW_TRIGGER_KEYS.associateWith { appPrefs.getBoolean(it, false) }
- bottomEdgeOn = configManager.getConfig().segments
- .any { it.gestureData[GestureType.LONG_PRESS] == BOTTOM_EDGE_MARKER }
+ bottomEdge = configManager.getBottomEdgeConfig()
}
val lifecycleOwner = LocalLifecycleOwner.current
@@ -230,9 +256,10 @@ fun WobbleHomeScreen(
context.startActivity(intent, options.toBundle())
}
- val setOverlayEnabled: (Boolean) -> Unit = { on ->
- configManager.saveConfig(configManager.getConfig().copy(isEnabled = on))
- overlayEnabled = on
+ val saveOverlayConfig: (OverlayConfig) -> Unit = { cfg ->
+ configManager.saveConfig(cfg)
+ overlayConfig = cfg
+ overlayEnabled = cfg.isEnabled
}
val setBubbleEnabled: (Boolean) -> Unit = { on ->
@@ -245,29 +272,29 @@ fun WobbleHomeScreen(
hwTriggers = hwTriggers + (key to checked)
}
- val setBottomEdge: (Boolean) -> Unit = { on ->
+ val saveBottomEdge: (BottomEdgeConfig) -> Unit = { cfg ->
+ bottomEdge = cfg
+ configManager.saveBottomEdgeConfig(cfg)
+ }
+
+ // Strip any legacy full-width bottom strip that older builds stored as a segment.
+ LaunchedEffect(Unit) {
val cfg = configManager.getConfig()
- val segments = cfg.segments.toMutableList()
- if (on) {
- if (segments.none { it.gestureData[GestureType.LONG_PRESS] == BOTTOM_EDGE_MARKER }) {
- val dm = context.resources.displayMetrics
- val stripPx = with(density) { 48.dp.roundToPx() }
- segments.add(
- OverlaySegment(
- width = dm.widthPixels,
- height = stripPx,
- xOffset = 0,
- yOffset = (dm.heightPixels - stripPx).coerceAtLeast(0),
- gestures = mutableMapOf(GestureType.LONG_PRESS to ActionType.CTS_AUTO),
- gestureData = mutableMapOf(GestureType.LONG_PRESS to BOTTOM_EDGE_MARKER),
- ),
- )
- }
- } else {
- segments.removeAll { it.gestureData[GestureType.LONG_PRESS] == BOTTOM_EDGE_MARKER }
+ if (cfg.segments.any { it.gestureData[GestureType.LONG_PRESS] == BOTTOM_EDGE_MARKER }) {
+ configManager.saveConfig(
+ cfg.copy(segments = cfg.segments.filterNot {
+ it.gestureData[GestureType.LONG_PRESS] == BOTTOM_EDGE_MARKER
+ }),
+ )
+ }
+ }
+
+ // Clear preview when leaving the screen so overlays don't stay visible.
+ DisposableEffect(Unit) {
+ onDispose {
+ val cur = configManager.getBottomEdgeConfig()
+ if (cur.previewVisible) configManager.saveBottomEdgeConfig(cur.copy(previewVisible = false))
}
- configManager.saveConfig(cfg.copy(segments = segments))
- bottomEdgeOn = on
}
LaunchedEffect(wobbleEvent) {
@@ -521,13 +548,10 @@ fun WobbleHomeScreen(
modifier = Modifier.fillMaxWidth(),
) {
Column {
- HomeToggleItem(
- title = stringResource(R.string.trigger_statusbar_title),
- subtitle = stringResource(R.string.trigger_statusbar_subtitle),
- icon = Icons.Default.Layers,
- checked = overlayEnabled,
- enabled = a11yGranted,
- onCheckedChange = { setOverlayEnabled(it) },
+ HomeStatusBarSection(
+ config = overlayConfig,
+ a11yGranted = a11yGranted,
+ onChange = saveOverlayConfig,
)
HomeRowDivider()
HomeToggleItem(
@@ -539,13 +563,10 @@ fun WobbleHomeScreen(
onCheckedChange = { setBubbleEnabled(it) },
)
HomeRowDivider()
- HomeToggleItem(
- title = stringResource(R.string.home_bottom_edge_title),
- subtitle = stringResource(R.string.home_bottom_edge_subtitle),
- icon = Icons.Rounded.KeyboardArrowDown,
- checked = bottomEdgeOn,
- enabled = a11yGranted,
- onCheckedChange = { setBottomEdge(it) },
+ HomeBottomEdgeSection(
+ config = bottomEdge,
+ a11yGranted = a11yGranted,
+ onChange = saveBottomEdge,
)
HomeRowDivider()
HomeAssistantRow(
@@ -837,4 +858,529 @@ private fun HomeHwSheet(
}
}
+/**
+ * Expandable block for the status-bar overlay, mirroring [HomeBottomEdgeSection]:
+ * a header row with a master switch, and a dropdown with an animated strip preview
+ * plus width / height / vertical-position sliders for the top trigger strip.
+ */
+@Composable
+private fun HomeStatusBarSection(
+ config: OverlayConfig,
+ a11yGranted: Boolean,
+ 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,
+ animationSpec = tween(durationMillis = 240),
+ label = "statusBarExpand",
+ )
+
+ val segment = config.segments.firstOrNull() ?: OverlaySegment()
+ fun saveSegment(newSegment: OverlaySegment) {
+ val segments = config.segments.toMutableList()
+ if (segments.isEmpty()) segments.add(newSegment) else segments[0] = newSegment
+ onChange(config.copy(segments = segments))
+ }
+
+ val screenWidthDp = LocalConfiguration.current.screenWidthDp.toFloat()
+ val screenWidthPx = screenWidthDp * density.density
+ val widthDp = segment.width / density.density
+ val heightDp = segment.height / density.density
+ val yDp = segment.yOffset / density.density
+
+ Column(modifier = Modifier.fillMaxWidth()) {
+ Row(
+ modifier = Modifier
+ .fillMaxWidth()
+ .clickable(enabled = a11yGranted) { expanded = !expanded }
+ .padding(horizontal = 16.dp, vertical = 12.dp),
+ verticalAlignment = Alignment.CenterVertically,
+ ) {
+ val rowAlpha = if (a11yGranted) 1f else 0.38f
+ Icon(
+ imageVector = Icons.Rounded.KeyboardArrowDown,
+ contentDescription = null,
+ modifier = Modifier
+ .size(24.dp)
+ .graphicsLayer {
+ alpha = rowAlpha
+ rotationZ = expandProgress * 180f
+ },
+ tint = MaterialTheme.colorScheme.onSurfaceVariant,
+ )
+ Spacer(modifier = Modifier.width(16.dp))
+ Column(modifier = Modifier.weight(1f)) {
+ Text(
+ text = stringResource(R.string.trigger_statusbar_title),
+ style = MaterialTheme.typography.bodyLarge,
+ color = MaterialTheme.colorScheme.onSurface.copy(alpha = rowAlpha),
+ )
+ Text(
+ text = stringResource(R.string.trigger_statusbar_subtitle),
+ style = MaterialTheme.typography.bodyMedium,
+ color = MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = rowAlpha),
+ )
+ }
+ Spacer(modifier = Modifier.width(8.dp))
+ Switch(
+ checked = masterOn,
+ enabled = a11yGranted,
+ onCheckedChange = { on ->
+ onChange(config.copy(isEnabled = on))
+ if (on) expanded = true
+ },
+ )
+ }
+
+ AnimatedVisibility(
+ visible = expanded && a11yGranted,
+ enter = expandVertically(tween(240)) + fadeIn(tween(240)),
+ exit = shrinkVertically(tween(200)) + fadeOut(tween(160)),
+ ) {
+ Column(modifier = Modifier.padding(start = 16.dp, end = 16.dp, bottom = 12.dp)) {
+ Surface(
+ shape = RoundedCornerShape(16.dp),
+ color = MaterialTheme.colorScheme.surfaceContainerLow,
+ border = BorderStroke(1.dp, MaterialTheme.colorScheme.outlineVariant),
+ modifier = Modifier.fillMaxWidth(),
+ ) {
+ Column(modifier = Modifier.padding(12.dp)) {
+ // Animated preview of the trigger strip on a mini phone canvas.
+ Box(
+ modifier = Modifier
+ .fillMaxWidth()
+ .height(72.dp)
+ .graphicsLayer { alpha = expandProgress },
+ contentAlignment = Alignment.TopCenter,
+ ) {
+ Box(
+ modifier = Modifier
+ .fillMaxSize()
+ .padding(horizontal = 48.dp)
+ .clip(RoundedCornerShape(14.dp))
+ .background(MaterialTheme.colorScheme.surfaceContainerHighest),
+ contentAlignment = Alignment.TopCenter,
+ ) {
+ val stripWidthFraction =
+ (segment.width / screenWidthPx).coerceIn(0.08f, 1f)
+ Box(
+ modifier = Modifier
+ .padding(top = yDp.dp)
+ .fillMaxWidth(stripWidthFraction)
+ .height(heightDp.coerceAtMost(56f).dp)
+ .background(
+ MaterialTheme.colorScheme.primary.copy(alpha = 0.25f),
+ ),
+ )
+ }
+ }
+
+ Spacer(modifier = Modifier.height(8.dp))
+
+ LabelledSlider(
+ label = stringResource(R.string.home_statusbar_width),
+ value = widthDp,
+ valueRange = 60f..(screenWidthDp - 40f).coerceAtLeast(120f),
+ valueText = "${widthDp.toInt()}dp",
+ onValueChange = {
+ saveSegment(segment.copy(width = (it * density.density).toInt()))
+ },
+ )
+ LabelledSlider(
+ label = stringResource(R.string.home_statusbar_height),
+ value = heightDp,
+ valueRange = 24f..140f,
+ valueText = "${heightDp.toInt()}dp",
+ onValueChange = {
+ saveSegment(segment.copy(height = (it * density.density).toInt()))
+ },
+ )
+ LabelledSlider(
+ label = stringResource(R.string.home_statusbar_ypos),
+ value = yDp,
+ valueRange = 0f..160f,
+ valueText = "${yDp.toInt()}dp",
+ onValueChange = {
+ saveSegment(segment.copy(yOffset = (it * density.density).toInt()))
+ },
+ )
+ }
+ }
+ }
+ }
+ }
+}
+
+/**
+ * Compact, expandable block for the bottom-edge long-press triggers.
+ * Master switch enables/disables; expanding it reveals an animated illustration plus
+ * per-corner toggles, a corner-size slider, and a separate bottom-mid switch + slider.
+ * While expanded, [BottomEdgeConfig.previewVisible] is forced true so the real overlays
+ * appear on screen for live sizing; collapsing (or leaving) hides them again.
+ */
+@OptIn(ExperimentalMaterial3ExpressiveApi::class)
+@Composable
+private fun HomeBottomEdgeSection(
+ config: BottomEdgeConfig,
+ a11yGranted: Boolean,
+ 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) {
+ if (config.previewVisible != expanded) {
+ onChange(config.copy(previewVisible = expanded))
+ }
+ }
+
+ val cornerSize by animateDpAsState(
+ targetValue = config.cornerSizeDp.dp,
+ animationSpec = spring(stiffness = Spring.StiffnessMediumLow),
+ label = "cornerSize",
+ )
+ val midSize by animateDpAsState(
+ targetValue = config.midSizeDp.dp,
+ animationSpec = spring(stiffness = Spring.StiffnessMediumLow),
+ label = "midSize",
+ )
+ val expandProgress by animateFloatAsState(
+ targetValue = if (expanded) 1f else 0f,
+ animationSpec = tween(durationMillis = 240),
+ label = "expandProgress",
+ )
+
+ Column(modifier = Modifier.fillMaxWidth()) {
+ // Header row: icon + label + master switch + expand chevron.
+ Row(
+ modifier = Modifier
+ .fillMaxWidth()
+ .clickable(enabled = a11yGranted) { expanded = !expanded }
+ .padding(horizontal = 16.dp, vertical = 12.dp),
+ verticalAlignment = Alignment.CenterVertically,
+ ) {
+ val rowAlpha = if (a11yGranted) 1f else 0.38f
+ Icon(
+ imageVector = Icons.Rounded.KeyboardArrowDown,
+ contentDescription = null,
+ modifier = Modifier
+ .size(24.dp)
+ .graphicsLayer {
+ alpha = rowAlpha
+ rotationZ = expandProgress * 180f
+ },
+ tint = MaterialTheme.colorScheme.onSurfaceVariant,
+ )
+ Spacer(modifier = Modifier.width(16.dp))
+ Column(modifier = Modifier.weight(1f)) {
+ Text(
+ text = stringResource(R.string.home_bottom_edge_title),
+ style = MaterialTheme.typography.bodyLarge,
+ color = MaterialTheme.colorScheme.onSurface.copy(alpha = rowAlpha),
+ )
+ Text(
+ text = stringResource(R.string.home_bottom_edge_subtitle),
+ style = MaterialTheme.typography.bodyMedium,
+ color = MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = rowAlpha),
+ )
+ }
+ Spacer(modifier = Modifier.width(8.dp))
+ Switch(
+ checked = masterOn,
+ enabled = a11yGranted,
+ onCheckedChange = { on ->
+ onChange(
+ config.copy(
+ leftEnabled = on,
+ rightEnabled = on,
+ // keep mid as-is unless turning everything on for the first time
+ midEnabled = if (on) config.midEnabled else false,
+ ),
+ )
+ if (on) expanded = true
+ },
+ )
+ }
+
+ AnimatedVisibility(
+ visible = expanded && a11yGranted,
+ enter = expandVertically(tween(240)) + fadeIn(tween(240)),
+ exit = shrinkVertically(tween(200)) + fadeOut(tween(160)),
+ ) {
+ Column(modifier = Modifier.padding(start = 16.dp, end = 16.dp, bottom = 12.dp)) {
+ // Compact container grouping the illustration, toggles and sliders so
+ // they share one consistent width and read as a single control block.
+ Surface(
+ shape = RoundedCornerShape(16.dp),
+ color = MaterialTheme.colorScheme.surfaceContainerLow,
+ border = BorderStroke(1.dp, MaterialTheme.colorScheme.outlineVariant),
+ modifier = Modifier.fillMaxWidth(),
+ ) {
+ Column(modifier = Modifier.padding(12.dp)) {
+ // Animated illustration of the phone bottom edge.
+ Box(
+ modifier = Modifier
+ .fillMaxWidth()
+ .height(96.dp)
+ .graphicsLayer { alpha = expandProgress },
+ contentAlignment = Alignment.Center,
+ ) {
+ BottomEdgeIllustration(
+ leftEnabled = config.leftEnabled,
+ rightEnabled = config.rightEnabled,
+ midEnabled = config.midEnabled,
+ cornerSizeDp = config.cornerSizeDp,
+ midSizeDp = config.midSizeDp,
+ expandProgress = expandProgress,
+ )
+ }
+
+ Spacer(modifier = Modifier.height(8.dp))
+
+ // Per-shape toggles as a small M3 expressive connected button
+ // group: Left / Mid / Right. Unchecked buttons get a chip-like
+ // outline so they stay clearly visible.
+ val groupBorder = BorderStroke(1.dp, MaterialTheme.colorScheme.outline)
+ ButtonGroup(
+ modifier = Modifier.fillMaxWidth(),
+ horizontalArrangement =
+ Arrangement.spacedBy(ButtonGroupDefaults.connectedSpaceBetween),
+ animateFraction = 0f,
+ ) {
+ val startShapes = ButtonShapes(
+ shape = ButtonGroupDefaults.connectedLeadingButtonShape,
+ pressedShape = ButtonGroupDefaults.connectedLeadingButtonPressShape,
+ checkedShape = ToggleButtonDefaults.checkedShape,
+ )
+ val middleShapes = ButtonShapes(
+ shape = ShapeDefaults.Small,
+ pressedShape = ToggleButtonDefaults.pressedShape,
+ checkedShape = ToggleButtonDefaults.checkedShape,
+ )
+ val endShapes = ButtonShapes(
+ shape = ButtonGroupDefaults.connectedTrailingButtonShape,
+ pressedShape = ButtonGroupDefaults.connectedTrailingButtonPressShape,
+ checkedShape = ToggleButtonDefaults.checkedShape,
+ )
+ ToggleButton(
+ checked = config.leftEnabled,
+ onCheckedChange = { on ->
+ onChange(config.copy(leftEnabled = on))
+ },
+ shapes = startShapes,
+ border = groupBorder,
+ modifier = Modifier.weight(1f),
+ ) {
+ Text(
+ text = stringResource(R.string.home_corner_left),
+ maxLines = 1,
+ overflow = TextOverflow.Ellipsis,
+ )
+ }
+ ToggleButton(
+ checked = config.midEnabled,
+ onCheckedChange = { on ->
+ onChange(config.copy(midEnabled = on))
+ },
+ shapes = middleShapes,
+ border = groupBorder,
+ modifier = Modifier.weight(1f),
+ ) {
+ Text(
+ text = stringResource(R.string.home_bottom_mid_title),
+ maxLines = 1,
+ overflow = TextOverflow.Ellipsis,
+ )
+ }
+ ToggleButton(
+ checked = config.rightEnabled,
+ onCheckedChange = { on ->
+ onChange(config.copy(rightEnabled = on))
+ },
+ shapes = endShapes,
+ border = groupBorder,
+ modifier = Modifier.weight(1f),
+ ) {
+ Text(
+ text = stringResource(R.string.home_corner_right),
+ maxLines = 1,
+ overflow = TextOverflow.Ellipsis,
+ )
+ }
+ }
+
+ Spacer(modifier = Modifier.height(10.dp))
+
+ // Corner size slider.
+ LabelledSlider(
+ label = stringResource(R.string.home_corner_size),
+ value = config.cornerSizeDp.toFloat(),
+ valueRange = 48f..140f,
+ valueText = "${config.cornerSizeDp}dp",
+ onValueChange = { onChange(config.copy(cornerSizeDp = it.toInt())) },
+ )
+
+ // Mid size slider (only meaningful when mid enabled).
+ AnimatedVisibility(visible = config.midEnabled) {
+ LabelledSlider(
+ label = stringResource(R.string.home_mid_size),
+ value = config.midSizeDp.toFloat(),
+ valueRange = 48f..200f,
+ valueText = "${config.midSizeDp}dp",
+ onValueChange = { onChange(config.copy(midSizeDp = it.toInt())) },
+ )
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+@Composable
+private fun LabelledSlider(
+ label: String,
+ value: Float,
+ valueRange: ClosedFloatingPointRange<Float>,
+ valueText: String,
+ onValueChange: (Float) -> Unit,
+) {
+ Column(modifier = Modifier.fillMaxWidth()) {
+ Row(
+ modifier = Modifier.fillMaxWidth(),
+ horizontalArrangement = Arrangement.SpaceBetween,
+ ) {
+ Text(
+ text = label,
+ style = MaterialTheme.typography.labelMedium,
+ color = MaterialTheme.colorScheme.onSurfaceVariant,
+ )
+ Text(
+ text = valueText,
+ style = MaterialTheme.typography.labelMedium,
+ color = MaterialTheme.colorScheme.primary,
+ )
+ }
+ Slider(
+ value = value,
+ onValueChange = onValueChange,
+ valueRange = valueRange,
+ )
+ }
+}
+
+/**
+ * A lightweight animated illustration of a phone's bottom edge showing the two corner arcs
+ * and the bottom-mid semicircle, so the user can visualise what they are enabling/sizing.
+ */
+@Composable
+private fun BottomEdgeIllustration(
+ leftEnabled: Boolean,
+ rightEnabled: Boolean,
+ midEnabled: Boolean,
+ cornerSizeDp: Int,
+ midSizeDp: Int,
+ expandProgress: Float,
+) {
+ val primary = MaterialTheme.colorScheme.primary
+ val outline = MaterialTheme.colorScheme.outlineVariant
+
+ // Subtle idle pulse so the enabled shapes feel alive.
+ val infiniteTransition = rememberInfiniteTransition(label = "edgePulse")
+ val pulse by infiniteTransition.animateFloat(
+ initialValue = 0.85f,
+ targetValue = 1f,
+ animationSpec = infiniteRepeatable(tween(1100), RepeatMode.Reverse),
+ label = "pulse",
+ )
+
+ Canvas(
+ modifier = Modifier
+ .fillMaxWidth()
+ .height(96.dp),
+ ) {
+ val w = size.width
+ val h = size.height
+ // Phone outline: rounded rect occupying the lower portion (wide so the
+ // shapes have room and read as small against it).
+ val phoneTop = h * 0.14f
+ val phoneBottom = h * 0.92f
+ val phoneLeft = w * 0.06f
+ val phoneRight = w * 0.94f
+ val cornerRadius = 18.dp.toPx()
+
+ drawRoundRect(
+ color = outline.copy(alpha = 0.35f * expandProgress),
+ topLeft = Offset(phoneLeft, phoneTop),
+ size = Size(phoneRight - phoneLeft, phoneBottom - phoneTop),
+ cornerRadius = androidx.compose.ui.geometry.CornerRadius(cornerRadius, cornerRadius),
+ )
+
+ // Scale dp sizes to fit the illustration box, kept tiny and clamped so a
+ // shape can never grow outside the phone outline. Fractions of the slider
+ // ranges keep the illustration device-independent.
+ val phoneW = phoneRight - phoneLeft
+ val phoneH = phoneBottom - phoneTop
+ val maxCorridor = phoneW / 2f
+ val maxRadius = minOf(maxCorridor * 0.45f, phoneH * 0.85f)
+ val cornerFrac = ((cornerSizeDp - 48f) / 92f).coerceIn(0f, 1f)
+ val midFrac = ((midSizeDp - 48f) / 152f).coerceIn(0f, 1f)
+ val cornerScale = (0.35f + 0.65f * cornerFrac) * maxRadius
+ val midScale = (0.35f + 0.65f * midFrac) * maxRadius
+
+ fun drawArcShape(isLeft: Boolean, radius: Float) {
+ val cx = if (isLeft) phoneLeft else phoneRight
+ val cy = phoneBottom
+ val path = Path().apply {
+ moveTo(cx, cy)
+ if (isLeft) {
+ lineTo(cx, cy - radius)
+ arcTo(
+ Rect(cx - radius, cy - radius, cx + radius, cy + radius),
+ startAngleDegrees = 270f,
+ sweepAngleDegrees = 90f,
+ forceMoveTo = false,
+ )
+ } else {
+ lineTo(cx, cy - radius)
+ arcTo(
+ Rect(cx - radius, cy - radius, cx + radius, cy + radius),
+ startAngleDegrees = 270f,
+ sweepAngleDegrees = -90f,
+ forceMoveTo = false,
+ )
+ }
+ close()
+ }
+ drawPath(path, color = primary.copy(alpha = 0.35f * pulse * expandProgress))
+ drawPath(path, color = primary.copy(alpha = 0.8f * expandProgress), style = Stroke(width = 2.dp.toPx(), cap = StrokeCap.Round))
+ }
+
+ if (leftEnabled) drawArcShape(true, cornerScale)
+ if (rightEnabled) drawArcShape(false, cornerScale)
+
+ if (midEnabled) {
+ val cx = (phoneLeft + phoneRight) / 2f
+ val cy = phoneBottom
+ val r = midScale
+ val path = Path().apply {
+ moveTo(cx - r, cy)
+ arcTo(
+ Rect(cx - r, cy - r, cx + r, cy + r),
+ startAngleDegrees = 180f,
+ sweepAngleDegrees = 180f,
+ forceMoveTo = false,
+ )
+ close()
+ }
+ drawPath(path, color = primary.copy(alpha = 0.35f * pulse * expandProgress))
+ drawPath(path, color = primary.copy(alpha = 0.8f * expandProgress), style = Stroke(width = 2.dp.toPx(), cap = StrokeCap.Round))
+ }
+ }
+}
+
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 5bdd16f..7afaed0 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
@@ -1,12 +1,14 @@
package com.akslabs.circletosearch.ui.wobblepulldown
import android.content.Intent
+import android.os.Build
import android.provider.Settings
import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.result.contract.ActivityResultContracts
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.WindowInsets
@@ -23,11 +25,15 @@ import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.Accessibility
import androidx.compose.material.icons.rounded.Assistant
import androidx.compose.material.icons.rounded.Verified
+import androidx.compose.material3.ExperimentalMaterial3Api
+import androidx.compose.material3.Button
import androidx.compose.material3.FilledTonalButton
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.ModalBottomSheet
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
+import androidx.compose.material3.rememberModalBottomSheetState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.LaunchedEffect
@@ -56,6 +62,7 @@ fun WobbleSetupWizard(modifier: Modifier = Modifier) {
var a11yGranted by remember { mutableStateOf(isA11yGranted(context)) }
var assistantGranted by remember { mutableStateOf(isAssistantGranted(context)) }
var showDisclosure by remember { mutableStateOf(false) }
+ var showAssistantSheet by remember { mutableStateOf(false) }
val refreshPermissions = {
a11yGranted = isA11yGranted(context)
@@ -96,6 +103,13 @@ fun WobbleSetupWizard(modifier: Modifier = Modifier) {
)
}
+ if (showAssistantSheet) {
+ AssistantSetupSheet(
+ onLaunch = { intent -> settingsLauncher.launch(intent) },
+ onDismiss = { showAssistantSheet = false },
+ )
+ }
+
Box(modifier = modifier.fillMaxSize()) {
Surface(
shape = RoundedCornerShape(bottomStart = 28.dp, bottomEnd = 28.dp),
@@ -134,7 +148,13 @@ fun WobbleSetupWizard(modifier: Modifier = Modifier) {
granted = a11yGranted,
onClick = {
WobbleHaptics.performUIHaptic(view)
- showDisclosure = true
+ if (a11yGranted) {
+ runCatching {
+ settingsLauncher.launch(Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS))
+ }
+ } else {
+ showDisclosure = true
+ }
},
)
WizardPermissionRow(
@@ -144,9 +164,7 @@ fun WobbleSetupWizard(modifier: Modifier = Modifier) {
granted = assistantGranted,
onClick = {
WobbleHaptics.performUIHaptic(view)
- runCatching {
- settingsLauncher.launch(Intent(Settings.ACTION_VOICE_INPUT_SETTINGS))
- }
+ showAssistantSheet = true
},
)
}
@@ -154,6 +172,7 @@ fun WobbleSetupWizard(modifier: Modifier = Modifier) {
}
}
+@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun WizardPermissionRow(
icon: ImageVector,
@@ -162,7 +181,11 @@ fun WizardPermissionRow(
granted: Boolean,
onClick: () -> Unit,
) {
+ // The WHOLE row is the click target (ripple over everything), in both states:
+ // un-granted opens the permission flow, granted still opens the system screen so
+ // the user can review or revoke the permission.
Surface(
+ onClick = onClick,
shape = RoundedCornerShape(24.dp),
color = MaterialTheme.colorScheme.surfaceContainerLow,
modifier = Modifier.fillMaxWidth(),
@@ -208,3 +231,95 @@ fun WizardPermissionRow(
}
}
}
+
+/**
+ * Bottom sheet for assistant setup: explains that CircleToSearch can act as the device
+ * assistant (so the normal assistant trigger — long-press Home, gesture handle, etc. —
+ * opens this app) and offers the picker that makes that happen.
+ */
+@OptIn(ExperimentalMaterial3Api::class)
+@Composable
+fun AssistantSetupSheet(
+ onLaunch: (Intent) -> Unit,
+ onDismiss: () -> Unit,
+) {
+ val context = LocalContext.current
+
+ // Try the canonical assistant-role picker first, then generic fallbacks that exist
+ // on different OEM builds.
+ fun launchFirst(vararg intents: Intent?): Boolean {
+ for (intent in intents) {
+ if (intent == null) continue
+ val ok = runCatching { onLaunch(intent); true }.getOrDefault(false)
+ if (ok) return true
+ }
+ return false
+ }
+
+ val roleManager = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
+ runCatching { context.getSystemService(android.app.role.RoleManager::class.java) }.getOrNull()
+ } else {
+ null
+ }
+ // If we already hold the assistant role the request intent is a no-op (launches
+ // nothing visible), so skip it and go straight to the settings screen instead.
+ val alreadyAssistant = roleManager?.isRoleHeld(android.app.role.RoleManager.ROLE_ASSISTANT) == true
+ val roleIntent: Intent? = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && !alreadyAssistant) {
+ runCatching {
+ roleManager?.createRequestRoleIntent(android.app.role.RoleManager.ROLE_ASSISTANT)
+ }.getOrNull()
+ } else {
+ null
+ }
+
+ ModalBottomSheet(
+ onDismissRequest = onDismiss,
+ sheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true),
+ ) {
+ Column(
+ modifier = Modifier
+ .fillMaxWidth()
+ .padding(start = 24.dp, end = 24.dp, bottom = 32.dp),
+ verticalArrangement = Arrangement.spacedBy(12.dp),
+ ) {
+ Text(
+ text = stringResource(R.string.assistant_sheet_title),
+ style = MaterialTheme.typography.titleLarge,
+ fontWeight = FontWeight.Bold,
+ )
+ Text(
+ text = stringResource(R.string.assistant_sheet_body),
+ style = MaterialTheme.typography.bodyMedium,
+ color = MaterialTheme.colorScheme.onSurfaceVariant,
+ )
+
+ Button(
+ onClick = {
+ if (launchFirst(
+ // Same screen the permission row's grant action used to open.
+ Intent(Settings.ACTION_VOICE_INPUT_SETTINGS),
+ roleIntent,
+ Intent(Settings.ACTION_MANAGE_DEFAULT_APPS_SETTINGS),
+ Intent(Settings.ACTION_SETTINGS),
+ )
+ ) {
+ onDismiss()
+ }
+ },
+ modifier = Modifier.fillMaxWidth(),
+ contentPadding = PaddingValues(horizontal = 20.dp, vertical = 14.dp),
+ ) {
+ Icon(
+ imageVector = Icons.Rounded.Assistant,
+ contentDescription = null,
+ modifier = Modifier.size(20.dp),
+ )
+ Spacer(modifier = Modifier.width(10.dp))
+ Text(
+ text = stringResource(R.string.assistant_opt_set_title),
+ fontWeight = FontWeight.Bold,
+ )
+ }
+ }
+ }
+}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index b7eb157..832c8ae 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -60,7 +60,7 @@
<string name="label_optional_assistant">OPTIONAL: For Home Button Trigger</string>
<string name="label_default_assistant_set">Default Assistant Set</string>
<string name="label_set_default_assistant">Set as Default Assistant</string>
- <string name="label_set_default_assistant_subtitle">Hold the Home button or edge-swipe up to summon CircleToSearch.</string>
+ <string name="label_set_default_assistant_subtitle">Tap to set it up and see how your device launches assistants.</string>
<string name="section_customization">CUSTOMIZATION</string>
<string name="info_lens_needs_google">Lens needs Google App Installed. But Degoogled friends can stick with the versatile Multi-Search Engine mode.</string>
<string name="label_from_akslabs">From AKS-Labs With \u2764\uFE0F</string>
@@ -396,11 +396,19 @@
<string name="wizard_assistant_title">Assistant</string>
<string name="wizard_grant">Grant</string>
<string name="wizard_granted">Granted</string>
+ <string name="assistant_sheet_title">Use as your assistant</string>
+ <string name="assistant_sheet_body">Set CircleToSearch as your device\'s assistant. Then the normal way your device opens an assistant — long-press Home, hold the gesture handle, etc. — will open CircleToSearch instead.</string>
+ <string name="assistant_opt_set_title">Set as default assistant</string>
<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_bottom_edge_title">Bottom edge long-press</string>
- <string name="home_bottom_edge_subtitle">Press and hold near the bottom edge of any screen</string>
+ <string name="home_bottom_edge_subtitle">Hold a bottom corner or the centre to search</string>
+ <string name="home_corner_left">Left</string>
+ <string name="home_corner_right">Right</string>
+ <string name="home_bottom_mid_title">Mid</string>
+ <string name="home_corner_size">Corner size</string>
+ <string name="home_mid_size">Mid size</string>
<string name="home_assistant_setup_subtitle">Set as default assistant to use the home button and swipes</string>
<string name="home_assistant_ready_subtitle">Home button and bottom-edge gestures work automatically</string>
<string name="home_ready">Ready</string>
@@ -427,6 +435,9 @@
<string name="trigger_name_assistant">Home button</string>
<string name="trigger_statusbar_title">Status bar double-tap</string>
<string name="trigger_statusbar_subtitle">Double-tap the status bar area to start</string>
+ <string name="home_statusbar_width">Width</string>
+ <string name="home_statusbar_height">Height</string>
+ <string name="home_statusbar_ypos">Vertical position</string>
<string name="trigger_bubble_subtitle">Floating button you can drag anywhere — tap to start</string>
<string name="trigger_double_vol_up_title">Double-tap Volume Up</string>
<string name="trigger_double_vol_down_title">Double-tap Volume Down</string>