Skip to content

CircleToSearch with multi search engine support for all android

Kotlin

test

AKS Labs9bb7e897c367
diff --git a/app/src/main/java/com/akslabs/circletosearch/CircleToSearchAccessibilityService.kt b/app/src/main/java/com/akslabs/circletosearch/CircleToSearchAccessibilityService.kt
index eea661c..a38ee85 100644
--- a/app/src/main/java/com/akslabs/circletosearch/CircleToSearchAccessibilityService.kt
+++ b/app/src/main/java/com/akslabs/circletosearch/CircleToSearchAccessibilityService.kt
@@ -85,6 +85,20 @@ import kotlin.coroutines.suspendCoroutine
private fun stickerCornerRadius(width: Int, height: Int, density: Float): Float =
maxOf(16f * density, minOf(width, height) * 0.127f)
+// --- Hardware button trigger prefs (all in app_prefs, default off) ---
+private const val KEY_TRIGGER_DOUBLE_VOL_UP = "trigger_double_vol_up"
+private const val KEY_TRIGGER_DOUBLE_VOL_DOWN = "trigger_double_vol_down"
+private const val KEY_TRIGGER_DOUBLE_POWER = "trigger_double_power"
+private const val KEY_TRIGGER_POWER_VOL_UP = "trigger_power_vol_up"
+private const val KEY_TRIGGER_POWER_VOL_DOWN = "trigger_power_vol_down"
+private const val KEY_TRIGGER_VOL_UP_DOWN = "trigger_vol_up_down"
+
+// Two presses of a single button within this window count as a double-tap
+private const val KEY_DOUBLE_TAP_MS = 350L
+// After a trigger fires, ignore presses for this long so one gesture can't
+// fire twice (e.g. the second tap of a double-tap counting again later)
+private const val KEY_TRIGGER_COOLDOWN_MS = 900L
+
class CircleToSearchAccessibilityService : AccessibilityService() {
private var windowManager: WindowManager? = null
@@ -124,7 +138,9 @@ class CircleToSearchAccessibilityService : AccessibilityService() {
info.flags = info.flags or
android.accessibilityservice.AccessibilityServiceInfo.FLAG_RETRIEVE_INTERACTIVE_WINDOWS or
android.accessibilityservice.AccessibilityServiceInfo.FLAG_REQUEST_ENHANCED_WEB_ACCESSIBILITY or
- android.accessibilityservice.AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS
+ android.accessibilityservice.AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS or
+ // Route volume/power keys through onKeyEvent so hardware triggers work
+ android.accessibilityservice.AccessibilityServiceInfo.FLAG_REQUEST_FILTER_KEY_EVENTS
serviceInfo = info
prefs.registerOnSharedPreferenceChangeListener(prefsListener)
@@ -1483,6 +1499,90 @@ class CircleToSearchAccessibilityService : AccessibilityService() {
override fun onInterrupt() {}
+ // --- Hardware button triggers ---
+ // With FLAG_REQUEST_FILTER_KEY_EVENTS every volume/power press flows through
+ // onKeyEvent. We NEVER consume (always return false), so volume still adjusts
+ // and power still sleeps — presses are only observed to launch the overlay.
+ private var lastVolUpDown = 0L
+ private var lastVolDownDown = 0L
+ private var lastPowerDown = 0L
+ private var lastTriggerFiredAt = 0L
+ private val keysCurrentlyDown = mutableSetOf<Int>()
+
+ override fun onKeyEvent(event: android.view.KeyEvent): Boolean {
+ val code = event.keyCode
+ when (event.action) {
+ android.view.KeyEvent.ACTION_DOWN -> {
+ // Long-press repeats must not count as new presses
+ if (event.repeatCount != 0) return false
+ if (code != android.view.KeyEvent.KEYCODE_VOLUME_UP &&
+ code != android.view.KeyEvent.KEYCODE_VOLUME_DOWN &&
+ code != android.view.KeyEvent.KEYCODE_POWER
+ ) return false
+
+ val now = android.os.SystemClock.uptimeMillis()
+ keysCurrentlyDown.add(code)
+ if (now - lastTriggerFiredAt < KEY_TRIGGER_COOLDOWN_MS) return false
+
+ var fire = false
+ when (code) {
+ android.view.KeyEvent.KEYCODE_VOLUME_UP -> {
+ if (prefs.getBoolean(KEY_TRIGGER_DOUBLE_VOL_UP, false) &&
+ now - lastVolUpDown <= KEY_DOUBLE_TAP_MS
+ ) fire = true
+ lastVolUpDown = now
+ if (!fire && prefs.getBoolean(KEY_TRIGGER_POWER_VOL_UP, false) &&
+ android.view.KeyEvent.KEYCODE_POWER in keysCurrentlyDown
+ ) fire = true
+ if (!fire && prefs.getBoolean(KEY_TRIGGER_VOL_UP_DOWN, false) &&
+ android.view.KeyEvent.KEYCODE_VOLUME_DOWN in keysCurrentlyDown
+ ) fire = true
+ }
+ android.view.KeyEvent.KEYCODE_VOLUME_DOWN -> {
+ if (prefs.getBoolean(KEY_TRIGGER_DOUBLE_VOL_DOWN, false) &&
+ now - lastVolDownDown <= KEY_DOUBLE_TAP_MS
+ ) fire = true
+ lastVolDownDown = now
+ if (!fire && prefs.getBoolean(KEY_TRIGGER_POWER_VOL_DOWN, false) &&
+ android.view.KeyEvent.KEYCODE_POWER in keysCurrentlyDown
+ ) fire = true
+ if (!fire && prefs.getBoolean(KEY_TRIGGER_VOL_UP_DOWN, false) &&
+ android.view.KeyEvent.KEYCODE_VOLUME_UP in keysCurrentlyDown
+ ) fire = true
+ }
+ android.view.KeyEvent.KEYCODE_POWER -> {
+ if (prefs.getBoolean(KEY_TRIGGER_DOUBLE_POWER, false) &&
+ now - lastPowerDown <= KEY_DOUBLE_TAP_MS
+ ) fire = true
+ lastPowerDown = now
+ if (!fire && prefs.getBoolean(KEY_TRIGGER_POWER_VOL_UP, false) &&
+ android.view.KeyEvent.KEYCODE_VOLUME_UP in keysCurrentlyDown
+ ) fire = true
+ if (!fire && prefs.getBoolean(KEY_TRIGGER_POWER_VOL_DOWN, false) &&
+ android.view.KeyEvent.KEYCODE_VOLUME_DOWN in keysCurrentlyDown
+ ) fire = true
+ }
+ }
+ if (fire) fireHardwareTrigger()
+ }
+ android.view.KeyEvent.ACTION_UP -> {
+ keysCurrentlyDown.remove(code)
+ }
+ }
+ // Never consume: system keeps full normal button behavior
+ return false
+ }
+
+ private fun fireHardwareTrigger() {
+ lastTriggerFiredAt = android.os.SystemClock.uptimeMillis()
+ // Reset double-tap state so this gesture can't fire a second time
+ lastVolUpDown = 0L
+ lastVolDownDown = 0L
+ lastPowerDown = 0L
+ android.util.Log.d("CircleToSearch", "Hardware button trigger fired")
+ performCapture(null)
+ }
+
/**
* Translates the screenshot captured when Circle to Search launched using the
* translator module's overlay (same path as its floating bubble). OCR and
diff --git a/app/src/main/java/com/akslabs/circletosearch/MainActivity.kt b/app/src/main/java/com/akslabs/circletosearch/MainActivity.kt
index c65ae9d..68f647d 100644
--- a/app/src/main/java/com/akslabs/circletosearch/MainActivity.kt
+++ b/app/src/main/java/com/akslabs/circletosearch/MainActivity.kt
@@ -43,6 +43,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.graphics.asImageBitmap
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.painterResource
@@ -123,13 +124,40 @@ fun SetupScreen(onSettingsClick: () -> Unit) {
var isAccessibilityEnabled by remember { mutableStateOf(isAccessibilityServiceEnabled(context)) }
var isDefaultAssistant by remember { mutableStateOf(isDefaultAssistant(context)) }
var showAccessibilityDisclosure by remember { mutableStateOf(false) }
-
+
+ // Summary of enabled triggers for the home card (refreshed on resume)
+ var triggerSummary by remember { mutableStateOf("") }
+ fun refreshTriggerSummary() {
+ val names = mutableListOf<String>()
+ val overlayConfig = runCatching {
+ com.akslabs.circletosearch.data.OverlayConfigurationManager(context).getConfig()
+ }.getOrNull()
+ if (overlayConfig?.isEnabled == true) names.add(context.getString(R.string.trigger_name_statusbar))
+ if (prefs.getBoolean("bubble_enabled", false)) names.add(context.getString(R.string.trigger_name_bubble))
+ if (prefs.getBoolean("trigger_double_vol_up", false)) names.add(context.getString(R.string.trigger_double_vol_up_title))
+ if (prefs.getBoolean("trigger_double_vol_down", false)) names.add(context.getString(R.string.trigger_double_vol_down_title))
+ if (prefs.getBoolean("trigger_double_power", false)) names.add(context.getString(R.string.trigger_double_power_title))
+ if (prefs.getBoolean("trigger_power_vol_up", false)) names.add(context.getString(R.string.trigger_power_vol_up_title))
+ if (prefs.getBoolean("trigger_power_vol_down", false)) names.add(context.getString(R.string.trigger_power_vol_down_title))
+ if (prefs.getBoolean("trigger_vol_up_down", false)) names.add(context.getString(R.string.trigger_vol_up_down_title))
+ if (isDefaultAssistant(context)) names.add(context.getString(R.string.trigger_name_assistant))
+ val shown = names.take(3)
+ val hidden = names.size - shown.size
+ triggerSummary = when {
+ names.isEmpty() -> context.getString(R.string.triggers_card_subtitle_none)
+ hidden > 0 -> shown.joinToString(" \u00B7 ") + " \u00B7 " + context.getString(R.string.triggers_more, hidden)
+ else -> shown.joinToString(" \u00B7 ")
+ }
+ }
+ LaunchedEffect(Unit) { refreshTriggerSummary() }
+
// Check permissions on Resume
DisposableEffect(lifecycleOwner) {
val observer = androidx.lifecycle.LifecycleEventObserver { _, event ->
if (event == androidx.lifecycle.Lifecycle.Event.ON_RESUME) {
isAccessibilityEnabled = isAccessibilityServiceEnabled(context)
isDefaultAssistant = isDefaultAssistant(context)
+ refreshTriggerSummary()
}
}
lifecycleOwner.lifecycle.addObserver(observer)
@@ -163,7 +191,56 @@ fun SetupScreen(onSettingsClick: () -> Unit) {
}
Scaffold(
- containerColor = MaterialTheme.colorScheme.background
+ containerColor = MaterialTheme.colorScheme.background,
+ topBar = {
+ // App icon + title on the left, settings gear on the right
+ TopAppBar(
+ title = {
+ Row(verticalAlignment = Alignment.CenterVertically) {
+ val launcherIcon = remember {
+ val drawable = context.getDrawable(R.mipmap.ic_launcher)
+ requireNotNull(drawable) { "ic_launcher drawable missing" }
+ val w = drawable.intrinsicWidth.coerceAtLeast(1)
+ val h = drawable.intrinsicHeight.coerceAtLeast(1)
+ val bitmap = android.graphics.Bitmap.createBitmap(
+ w, h, android.graphics.Bitmap.Config.ARGB_8888
+ )
+ drawable.setBounds(0, 0, w, h)
+ drawable.draw(android.graphics.Canvas(bitmap))
+ bitmap.asImageBitmap()
+ }
+ Icon(
+ bitmap = launcherIcon,
+ contentDescription = stringResource(R.string.cd_app_icon),
+ tint = Color.Unspecified,
+ modifier = Modifier
+ .size(34.dp)
+ .clip(androidx.compose.foundation.shape.RoundedCornerShape(9.dp))
+ )
+ Spacer(modifier = Modifier.width(12.dp))
+ Text(
+ text = stringResource(R.string.header_title),
+ style = MaterialTheme.typography.titleLarge.copy(fontWeight = FontWeight.Bold),
+ color = MaterialTheme.colorScheme.onBackground
+ )
+ }
+ },
+ actions = {
+ IconButton(onClick = onSettingsClick) {
+ Icon(
+ imageVector = Icons.Default.Settings,
+ contentDescription = stringResource(R.string.cd_overlay_settings),
+ tint = MaterialTheme.colorScheme.onSurfaceVariant
+ )
+ }
+ },
+ colors = TopAppBarDefaults.topAppBarColors(
+ containerColor = MaterialTheme.colorScheme.background,
+ titleContentColor = MaterialTheme.colorScheme.onBackground,
+ actionIconContentColor = MaterialTheme.colorScheme.onSurfaceVariant
+ )
+ )
+ }
) { padding ->
Column(
modifier = Modifier
@@ -173,58 +250,9 @@ fun SetupScreen(onSettingsClick: () -> Unit) {
.padding(horizontal = 24.dp),
horizontalAlignment = Alignment.CenterHorizontally
) {
- Spacer(modifier = Modifier.height(32.dp))
+ Spacer(modifier = Modifier.height(8.dp))
- Row(
- modifier = Modifier.fillMaxWidth(),
- verticalAlignment = Alignment.CenterVertically,
- horizontalArrangement = Arrangement.spacedBy(14.dp)
- ) {
- Surface(
- shape = M3ExpressiveShapes.Clover4,
- color = MaterialTheme.colorScheme.primaryContainer,
- modifier = Modifier.size(56.dp)
- ) {
- Box(contentAlignment = Alignment.Center) {
- Icon(
- imageVector = Icons.Default.Search,
- contentDescription = null,
- tint = MaterialTheme.colorScheme.onPrimaryContainer,
- modifier = Modifier.size(28.dp)
- )
- }
- }
- Column(modifier = Modifier.weight(1f)) {
- Text(
- text = stringResource(R.string.header_title),
- style = MaterialTheme.typography.headlineSmall.copy(fontWeight = FontWeight.Bold),
- color = MaterialTheme.colorScheme.onBackground
- )
- Text(
- text = stringResource(R.string.subtitle_main),
- style = MaterialTheme.typography.bodyMedium,
- color = MaterialTheme.colorScheme.onSurfaceVariant
- )
- }
- Surface(
- shape = CircleShape,
- color = MaterialTheme.colorScheme.surfaceVariant.copy(alpha = 0.85f),
- modifier = Modifier
- .size(48.dp)
- .m3ExpressivePress(onClick = onSettingsClick)
- ) {
- Box(contentAlignment = Alignment.Center) {
- Icon(
- Icons.Default.Settings,
- contentDescription = stringResource(R.string.cd_overlay_settings),
- tint = MaterialTheme.colorScheme.onSurfaceVariant,
- modifier = Modifier.size(22.dp)
- )
- }
- }
- }
-
- Spacer(modifier = Modifier.height(28.dp))
+ Spacer(modifier = Modifier.height(16.dp))
Surface(
shape = M3ExpressiveShapes.SlantedPill,
@@ -436,70 +464,24 @@ fun SetupScreen(onSettingsClick: () -> Unit) {
modifier = Modifier.align(Alignment.Start)
) {
Text(
- text = stringResource(R.string.section_customization),
+ text = stringResource(R.string.label_triggers),
style = MaterialTheme.typography.labelMedium.copy(fontWeight = FontWeight.SemiBold),
color = MaterialTheme.colorScheme.secondary,
modifier = Modifier.padding(horizontal = 14.dp, vertical = 7.dp)
)
}
Spacer(modifier = Modifier.height(10.dp))
- BubbleSwitch(context)
-
- val uiPreferences = remember { com.akslabs.circletosearch.utils.UIPreferences(context) }
+ // Quick glance at what's configured — tap to manage all triggers
Card(
+ onClick = onSettingsClick,
shape = M3ExpressiveShapes.AsymmetricCard,
colors = CardDefaults.cardColors(
containerColor = MaterialTheme.colorScheme.surfaceVariant.copy(alpha = 0.55f)
),
- modifier = Modifier
- .fillMaxWidth()
- .padding(top = 16.dp)
- ) {
- Column(modifier = Modifier.padding(16.dp)) {
- UnifiedSearchMethodSelector(
- uiPreferences = uiPreferences
- )
-
- Spacer(modifier = Modifier.height(12.dp))
-
- Row(
- verticalAlignment = Alignment.CenterVertically
- ) {
- Icon(
- imageVector = androidx.compose.material.icons.Icons.Default.Info,
- contentDescription = null,
- tint = MaterialTheme.colorScheme.secondary,
- modifier = Modifier.size(16.dp)
- )
- Spacer(modifier = Modifier.width(8.dp))
- Text(
- text = stringResource(R.string.info_lens_needs_google),
- style = MaterialTheme.typography.bodySmall,
- color = MaterialTheme.colorScheme.onSurfaceVariant
- )
- }
- }
- }
-
- Spacer(modifier = Modifier.height(12.dp))
-
- Card(
- onClick = {
- try {
- context.startActivity(Intent(context, TranslatorMainActivity::class.java))
- } catch (e: Exception) {
- android.widget.Toast.makeText(context, "Could not launch translator: ${e.message}", android.widget.Toast.LENGTH_LONG).show()
- }
- },
- shape = M3ExpressiveShapes.AsymmetricCard,
- colors = CardDefaults.cardColors(
- containerColor = MaterialTheme.colorScheme.tertiaryContainer.copy(alpha = 0.6f)
- ),
modifier = Modifier
.fillMaxWidth()
.m3ExpressivePress()
- .testTag("test_translator_button")
) {
Row(
modifier = Modifier.padding(16.dp),
@@ -507,14 +489,14 @@ fun SetupScreen(onSettingsClick: () -> Unit) {
) {
Surface(
shape = M3ExpressiveShapes.Clover4,
- color = MaterialTheme.colorScheme.tertiary,
+ color = MaterialTheme.colorScheme.tertiaryContainer,
modifier = Modifier.size(48.dp)
) {
Box(contentAlignment = Alignment.Center) {
Icon(
- Icons.Default.Translate,
+ imageVector = Icons.Default.SettingsSuggest,
contentDescription = null,
- tint = MaterialTheme.colorScheme.onTertiary,
+ tint = MaterialTheme.colorScheme.onTertiaryContainer,
modifier = Modifier.size(24.dp)
)
}
@@ -522,16 +504,23 @@ fun SetupScreen(onSettingsClick: () -> Unit) {
Spacer(modifier = Modifier.width(16.dp))
Column(modifier = Modifier.weight(1f)) {
Text(
- text = "Offline Translator (Test)",
+ text = stringResource(R.string.triggers_card_title),
style = MaterialTheme.typography.titleMedium.copy(fontWeight = FontWeight.Bold),
- color = MaterialTheme.colorScheme.onTertiaryContainer
+ color = MaterialTheme.colorScheme.onSurface
)
Text(
- text = "Open the translator home screen",
+ text = triggerSummary,
style = MaterialTheme.typography.bodySmall,
- color = MaterialTheme.colorScheme.onTertiaryContainer.copy(alpha = 0.8f)
+ color = MaterialTheme.colorScheme.onSurfaceVariant,
+ maxLines = 2,
+ overflow = androidx.compose.ui.text.style.TextOverflow.Ellipsis
)
}
+ Icon(
+ Icons.Default.KeyboardArrowRight,
+ contentDescription = null,
+ tint = MaterialTheme.colorScheme.onSurfaceVariant
+ )
}
}
// Spacer(modifier = Modifier.height(25.dp))
diff --git a/app/src/main/java/com/akslabs/circletosearch/ui/OverlaySettingsScreen.kt b/app/src/main/java/com/akslabs/circletosearch/ui/OverlaySettingsScreen.kt
index 7beb9d7..4406d72 100644
--- a/app/src/main/java/com/akslabs/circletosearch/ui/OverlaySettingsScreen.kt
+++ b/app/src/main/java/com/akslabs/circletosearch/ui/OverlaySettingsScreen.kt
@@ -5,6 +5,16 @@
package com.akslabs.circletosearch.ui
import android.content.Context
+import android.content.Intent
+import android.net.Uri
+import androidx.compose.animation.AnimatedContent
+import androidx.compose.animation.core.CubicBezierEasing
+import androidx.compose.animation.core.tween
+import androidx.compose.animation.fadeIn
+import androidx.compose.animation.fadeOut
+import androidx.compose.animation.slideInHorizontally
+import androidx.compose.animation.slideOutHorizontally
+import androidx.compose.animation.togetherWith
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
@@ -32,43 +42,157 @@ import androidx.compose.ui.window.DialogProperties
import androidx.compose.ui.res.stringResource
import com.akslabs.circletosearch.R
import com.akslabs.circletosearch.data.*
+import com.akslabs.circletosearch.isAccessibilityServiceEnabled
+import com.akslabs.circletosearch.ui.components.DonateBottomSheet
+import com.akslabs.circletosearch.ui.components.UnifiedSearchMethodSelector
+import com.akslabs.circletosearch.utils.UIPreferences
+import dev.davidv.translator.MainActivity as TranslatorMainActivity
+
+private const val NAV_TRANSITION_MS = 320
+private val NavEasing = CubicBezierEasing(0.2f, 0f, 0f, 1f)
+
+private sealed class SettingsPage {
+ object Root : SettingsPage()
+ object Triggers : SettingsPage()
+ object Zones : SettingsPage()
+ object Search : SettingsPage()
+ object General : SettingsPage()
+ object About : SettingsPage()
+}
+
+private fun SettingsPage.order(): Int = when (this) {
+ SettingsPage.Root -> 0
+ SettingsPage.Triggers -> 1
+ SettingsPage.Zones -> 2
+ SettingsPage.Search -> 3
+ SettingsPage.General -> 4
+ SettingsPage.About -> 5
+}
+
+@Stable
+private class OverlaySettingsState(context: Context) {
+ private val configManager = OverlayConfigurationManager(context)
+ private val appPrefs = context.getSharedPreferences("app_prefs", Context.MODE_PRIVATE)
+
+ val uiPreferences = UIPreferences(context)
+ val isAccessibilityOn = isAccessibilityServiceEnabled(context)
+
+ private val _config = mutableStateOf(configManager.getConfig())
+ val config: OverlayConfig get() = _config.value
+ fun updateConfig(newConfig: OverlayConfig) {
+ _config.value = newConfig
+ configManager.saveConfig(newConfig)
+ }
+
+ private val _bubbleEnabled = mutableStateOf(appPrefs.getBoolean("bubble_enabled", false))
+ val bubbleEnabled: Boolean get() = _bubbleEnabled.value
+ fun setBubbleEnabled(enabled: Boolean) {
+ _bubbleEnabled.value = enabled
+ appPrefs.edit().putBoolean("bubble_enabled", enabled).apply()
+ }
+
+ private val _hwTriggers = mutableStateOf(
+ HW_TRIGGER_KEYS.associateWith { appPrefs.getBoolean(it, false) }
+ )
+ val hwTriggers: Map<String, Boolean> get() = _hwTriggers.value
+ fun setTrigger(key: String, enabled: Boolean) {
+ _hwTriggers.value = _hwTriggers.value + (key to enabled)
+ appPrefs.edit().putBoolean(key, enabled).apply()
+ }
+
+ companion object {
+ val HW_TRIGGER_KEYS = listOf(
+ "trigger_double_vol_up",
+ "trigger_double_vol_down",
+ "trigger_double_power",
+ "trigger_power_vol_up",
+ "trigger_power_vol_down",
+ "trigger_vol_up_down"
+ )
+ }
+}
-@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun OverlaySettingsScreen(
onBack: () -> Unit
) {
- // Handle system back press
- androidx.activity.compose.BackHandler(onBack = onBack)
-
val context = LocalContext.current
- val configManager = remember { OverlayConfigurationManager(context) }
- var config by remember { mutableStateOf(configManager.getConfig()) }
-
- // Save on changes - Updates in REALTIME
- fun updateConfig(newConfig: OverlayConfig) {
- config = newConfig
- configManager.saveConfig(newConfig)
+ val state = remember { OverlaySettingsState(context) }
+ val backStack = remember { mutableStateListOf<SettingsPage>(SettingsPage.Root) }
+ val pop: () -> Unit = { backStack.removeAt(backStack.lastIndex) }
+
+ androidx.activity.compose.BackHandler {
+ if (backStack.size > 1) pop() else onBack()
}
- val overlayPalette = rememberOverlayPalette(context)
-
+ Surface(
+ modifier = Modifier.fillMaxSize(),
+ color = MaterialTheme.colorScheme.background
+ ) {
+ AnimatedContent(
+ targetState = backStack.last(),
+ modifier = Modifier.fillMaxSize(),
+ transitionSpec = {
+ val forward = targetState.order() > initialState.order()
+ if (forward) {
+ (slideInHorizontally(tween(NAV_TRANSITION_MS, easing = NavEasing)) { it } +
+ fadeIn(tween(240)))
+ .togetherWith(
+ slideOutHorizontally(tween(NAV_TRANSITION_MS, easing = NavEasing)) { -it } +
+ fadeOut(tween(200))
+ )
+ } else {
+ (slideInHorizontally(tween(NAV_TRANSITION_MS, easing = NavEasing)) { -it } +
+ fadeIn(tween(240)))
+ .togetherWith(
+ slideOutHorizontally(tween(NAV_TRANSITION_MS, easing = NavEasing)) { it } +
+ fadeOut(tween(200))
+ )
+ }
+ },
+ label = "settingsNav"
+ ) { page ->
+ when (page) {
+ SettingsPage.Root -> SettingsRootScreen(
+ onBack = onBack,
+ onNavigate = { backStack.add(it) }
+ )
+ SettingsPage.Triggers -> TriggersSettingsScreen(state = state, onBack = pop)
+ SettingsPage.Zones -> ZonesSettingsScreen(state = state, onBack = pop)
+ SettingsPage.Search -> SearchSettingsScreen(state = state, onBack = pop)
+ SettingsPage.General -> GeneralSettingsScreen(onBack = pop)
+ SettingsPage.About -> AboutSettingsScreen(onBack = pop)
+ }
+ }
+ }
+}
+
+@OptIn(ExperimentalMaterial3Api::class)
+@Composable
+private fun SettingsDetailScaffold(
+ title: String,
+ onBack: () -> Unit,
+ actions: @Composable RowScope.() -> Unit = {},
+ content: @Composable ColumnScope.() -> Unit
+) {
Scaffold(
+ containerColor = MaterialTheme.colorScheme.background,
topBar = {
TopAppBar(
- title = { Text(stringResource(R.string.title_overlay_settings), fontWeight = FontWeight.Bold) },
+ title = { Text(title, fontWeight = FontWeight.Bold) },
navigationIcon = {
IconButton(onClick = onBack) {
- Icon(Icons.Default.ArrowBack, contentDescription = stringResource(R.string.cd_back))
+ Icon(
+ Icons.AutoMirrored.Filled.ArrowBack,
+ contentDescription = stringResource(R.string.cd_back)
+ )
}
},
- actions = {
- IconButton(onClick = {
- updateConfig(OverlayConfig()) // Reset
- }) {
- Icon(Icons.Default.Refresh, contentDescription = stringResource(R.string.cd_reset))
- }
- }
+ actions = actions,
+ colors = TopAppBarDefaults.topAppBarColors(
+ containerColor = MaterialTheme.colorScheme.background,
+ titleContentColor = MaterialTheme.colorScheme.onBackground
+ )
)
}
) { padding ->
@@ -77,94 +201,512 @@ fun OverlaySettingsScreen(
.fillMaxSize()
.padding(padding)
.verticalScroll(rememberScrollState())
- .padding(16.dp)
- ) {
- // 1. Main Toggles
- SettingsSectionHeader(title = stringResource(R.string.general))
+ .padding(horizontal = 16.dp),
+ content = content
+ )
+ }
+}
+
+@Composable
+private fun SettingsRootScreen(
+ onBack: () -> Unit,
+ onNavigate: (SettingsPage) -> Unit
+) {
+ SettingsDetailScaffold(
+ title = stringResource(R.string.title_settings),
+ onBack = onBack
+ ) {
+ 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),
+ subtitle = stringResource(R.string.settings_cat_about_subtitle),
+ onClick = { onNavigate(SettingsPage.About) }
+ )
+ }
+ Spacer(modifier = Modifier.height(24.dp))
+ }
+}
+
+@Composable
+private fun TriggersSettingsScreen(
+ state: OverlaySettingsState,
+ onBack: () -> Unit
+) {
+ val config = state.config
+ SettingsDetailScaffold(
+ title = stringResource(R.string.triggers_card_title),
+ onBack = onBack
+ ) {
+ Spacer(modifier = Modifier.height(8.dp))
+ SettingsSectionHeader(title = stringResource(R.string.section_launch_methods))
+ SettingsGroup {
SettingsToggleItem(
- title = stringResource(R.string.overlay_setting_enable_title),
- subtitle = stringResource(R.string.overlay_setting_enable_subtitle),
+ title = stringResource(R.string.trigger_statusbar_title),
+ subtitle = stringResource(R.string.trigger_statusbar_subtitle),
icon = Icons.Default.Layers,
checked = config.isEnabled,
- onCheckedChange = { updateConfig(config.copy(isEnabled = it)) }
+ onCheckedChange = { state.updateConfig(config.copy(isEnabled = it)) }
+ )
+ SettingsGroupDivider()
+ SettingsToggleItem(
+ title = stringResource(R.string.label_floating_bubble),
+ subtitle = stringResource(R.string.trigger_bubble_subtitle),
+ icon = Icons.Default.TouchApp,
+ checked = state.bubbleEnabled,
+ onCheckedChange = { state.setBubbleEnabled(it) }
+ )
+ SettingsGroupDivider()
+ SettingsInfoRow(
+ icon = Icons.Default.Widgets,
+ title = stringResource(R.string.trigger_qs_title),
+ subtitle = stringResource(R.string.trigger_qs_subtitle)
+ )
+ }
+
+ Spacer(modifier = Modifier.height(24.dp))
+ SettingsSectionHeader(title = stringResource(R.string.section_hardware_buttons))
+ if (!state.isAccessibilityOn) {
+ Text(
+ text = stringResource(R.string.trigger_hw_notice),
+ style = MaterialTheme.typography.bodySmall,
+ color = MaterialTheme.colorScheme.error,
+ modifier = Modifier.padding(bottom = 8.dp)
)
- Spacer(modifier = Modifier.height(12.dp))
+ }
+ SettingsGroup {
+ SettingsToggleItem(
+ title = stringResource(R.string.trigger_double_vol_up_title),
+ subtitle = stringResource(R.string.trigger_hw_subtitle),
+ icon = Icons.AutoMirrored.Filled.VolumeUp,
+ checked = state.hwTriggers["trigger_double_vol_up"] ?: false,
+ onCheckedChange = { state.setTrigger("trigger_double_vol_up", it) }
+ )
+ SettingsGroupDivider()
+ SettingsToggleItem(
+ title = stringResource(R.string.trigger_double_vol_down_title),
+ subtitle = stringResource(R.string.trigger_hw_subtitle),
+ icon = Icons.AutoMirrored.Filled.VolumeDown,
+ checked = state.hwTriggers["trigger_double_vol_down"] ?: false,
+ onCheckedChange = { state.setTrigger("trigger_double_vol_down", it) }
+ )
+ SettingsGroupDivider()
+ SettingsToggleItem(
+ title = stringResource(R.string.trigger_double_power_title),
+ subtitle = stringResource(R.string.trigger_hw_subtitle),
+ icon = Icons.Default.PowerSettingsNew,
+ checked = state.hwTriggers["trigger_double_power"] ?: false,
+ onCheckedChange = { state.setTrigger("trigger_double_power", it) }
+ )
+ SettingsGroupDivider()
+ SettingsToggleItem(
+ title = stringResource(R.string.trigger_power_vol_up_title),
+ subtitle = stringResource(R.string.trigger_hw_subtitle),
+ icon = Icons.Default.Add,
+ checked = state.hwTriggers["trigger_power_vol_up"] ?: false,
+ onCheckedChange = { state.setTrigger("trigger_power_vol_up", it) }
+ )
+ SettingsGroupDivider()
+ SettingsToggleItem(
+ title = stringResource(R.string.trigger_power_vol_down_title),
+ subtitle = stringResource(R.string.trigger_hw_subtitle),
+ icon = Icons.Default.Add,
+ checked = state.hwTriggers["trigger_power_vol_down"] ?: false,
+ onCheckedChange = { state.setTrigger("trigger_power_vol_down", it) }
+ )
+ SettingsGroupDivider()
+ SettingsToggleItem(
+ title = stringResource(R.string.trigger_vol_up_down_title),
+ subtitle = stringResource(R.string.trigger_hw_subtitle),
+ icon = Icons.Default.Add,
+ checked = state.hwTriggers["trigger_vol_up_down"] ?: false,
+ onCheckedChange = { state.setTrigger("trigger_vol_up_down", it) }
+ )
+ }
+ Spacer(modifier = Modifier.height(24.dp))
+ }
+}
+
+@Composable
+private fun ZonesSettingsScreen(
+ state: OverlaySettingsState,
+ onBack: () -> Unit
+) {
+ val context = LocalContext.current
+ val config = state.config
+ val overlayPalette = rememberOverlayPalette(context)
+
+ SettingsDetailScaffold(
+ title = stringResource(R.string.settings_cat_zones),
+ onBack = onBack,
+ actions = {
+ IconButton(onClick = { state.updateConfig(OverlayConfig()) }) {
+ Icon(Icons.Default.Refresh, contentDescription = stringResource(R.string.cd_reset))
+ }
+ }
+ ) {
+ Spacer(modifier = Modifier.height(8.dp))
+ Row(
+ modifier = Modifier.fillMaxWidth(),
+ horizontalArrangement = Arrangement.SpaceBetween,
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ SettingsSectionHeader(title = stringResource(R.string.section_overlays))
+ TextButton(onClick = {
+ val currentSegments = config.segments.toMutableList()
+ currentSegments.add(OverlaySegment(xOffset = 300))
+ state.updateConfig(config.copy(segments = currentSegments))
+ }) {
+ Icon(Icons.Default.Add, contentDescription = null, modifier = Modifier.size(18.dp))
+ Spacer(modifier = Modifier.width(4.dp))
+ Text(stringResource(R.string.btn_add_overlay))
+ }
+ }
+
+ if (config.segments.isEmpty()) {
+ Text(
+ text = stringResource(R.string.label_no_overlays),
+ style = MaterialTheme.typography.bodyMedium,
+ color = MaterialTheme.colorScheme.onSurfaceVariant
+ )
+ }
+
+ config.segments.forEachIndexed { index, segment ->
+ SegmentEditorItem(
+ index = index,
+ segment = segment,
+ overlayPalette = overlayPalette,
+ isExpanded = config.activeSegmentIndex == index,
+ onExpandToggle = {
+ val nextIndex = if (config.activeSegmentIndex == index) -1 else index
+ state.updateConfig(config.copy(activeSegmentIndex = nextIndex))
+ },
+ onUpdate = { updatedSegment ->
+ val newSegments = config.segments.toMutableList()
+ newSegments[index] = updatedSegment
+ state.updateConfig(config.copy(segments = newSegments))
+ },
+ onDelete = {
+ val newSegments = config.segments.toMutableList()
+ newSegments.removeAt(index)
+ val nextActiveIndex = if (config.activeSegmentIndex == index) -1
+ else if (config.activeSegmentIndex > index) config.activeSegmentIndex - 1
+ else config.activeSegmentIndex
+ state.updateConfig(config.copy(segments = newSegments, activeSegmentIndex = nextActiveIndex))
+ }
+ )
+ Spacer(modifier = Modifier.height(16.dp))
+ }
+
+ Spacer(modifier = Modifier.height(8.dp))
+ SettingsSectionHeader(title = stringResource(R.string.section_behavior))
+ SettingsGroup {
SettingsToggleItem(
title = stringResource(R.string.overlay_setting_landscape_title),
subtitle = stringResource(R.string.overlay_setting_landscape_subtitle),
icon = Icons.Default.ScreenRotation,
checked = config.isEnabledInLandscape,
- onCheckedChange = { updateConfig(config.copy(isEnabledInLandscape = it)) }
+ onCheckedChange = { state.updateConfig(config.copy(isEnabledInLandscape = it)) }
)
- Spacer(modifier = Modifier.height(12.dp))
+ SettingsGroupDivider()
SettingsToggleItem(
title = stringResource(R.string.overlay_setting_show_title),
subtitle = stringResource(R.string.overlay_setting_show_subtitle),
icon = Icons.Default.Visibility,
checked = config.isVisible,
- onCheckedChange = { updateConfig(config.copy(isVisible = it)) }
+ onCheckedChange = { state.updateConfig(config.copy(isVisible = it)) }
)
+ }
+ Spacer(modifier = Modifier.height(24.dp))
+ }
+}
- Spacer(modifier = Modifier.height(24.dp))
-
- // 2. Overlays List
- Row(
- modifier = Modifier.fillMaxWidth(),
- horizontalArrangement = Arrangement.SpaceBetween,
- verticalAlignment = Alignment.CenterVertically
- ) {
- SettingsSectionHeader(title = stringResource(R.string.section_overlays))
- TextButton(onClick = {
- // Add new overlay segment
- val currentSegments = config.segments.toMutableList()
- currentSegments.add(OverlaySegment(xOffset = 300)) // Add with some offset so it doesn't overlap perfectly if 0
- updateConfig(config.copy(segments = currentSegments))
- }) {
- Icon(Icons.Default.Add, contentDescription = null, modifier = Modifier.size(18.dp))
- Spacer(modifier = Modifier.width(4.dp))
- Text(stringResource(R.string.btn_add_overlay))
+@Composable
+private fun SearchSettingsScreen(
+ state: OverlaySettingsState,
+ onBack: () -> Unit
+) {
+ SettingsDetailScaffold(
+ title = stringResource(R.string.settings_cat_search),
+ onBack = onBack
+ ) {
+ Spacer(modifier = Modifier.height(8.dp))
+ SettingsGroup {
+ Column(modifier = Modifier.padding(16.dp)) {
+ UnifiedSearchMethodSelector(uiPreferences = state.uiPreferences)
+ Spacer(modifier = Modifier.height(12.dp))
+ Row(verticalAlignment = Alignment.CenterVertically) {
+ Icon(
+ imageVector = Icons.Default.Info,
+ contentDescription = null,
+ tint = MaterialTheme.colorScheme.secondary,
+ modifier = Modifier.size(16.dp)
+ )
+ Spacer(modifier = Modifier.width(8.dp))
+ Text(
+ text = stringResource(R.string.info_lens_needs_google),
+ style = MaterialTheme.typography.bodySmall,
+ color = MaterialTheme.colorScheme.onSurfaceVariant
+ )
}
}
-
- if (config.segments.isEmpty()) {
- Text(
- stringResource(R.string.label_no_overlays),
- style = MaterialTheme.typography.bodyMedium,
- color = MaterialTheme.colorScheme.onSurfaceVariant
- )
- }
+ }
+ Spacer(modifier = Modifier.height(24.dp))
+ }
+}
- config.segments.forEachIndexed { index, segment ->
- SegmentEditorItem(
- index = index,
- segment = segment,
- overlayPalette = overlayPalette,
- isExpanded = config.activeSegmentIndex == index,
- onExpandToggle = {
- val nextIndex = if (config.activeSegmentIndex == index) -1 else index
- updateConfig(config.copy(activeSegmentIndex = nextIndex))
- },
- onUpdate = { updatedSegment ->
- val newSegments = config.segments.toMutableList()
- newSegments[index] = updatedSegment
- updateConfig(config.copy(segments = newSegments))
- },
- onDelete = {
- val newSegments = config.segments.toMutableList()
- newSegments.removeAt(index)
- // If we deleted the active one or shifted indices, reset/update active index
- val nextActiveIndex = if (config.activeSegmentIndex == index) -1
- else if (config.activeSegmentIndex > index) config.activeSegmentIndex - 1
- else config.activeSegmentIndex
- updateConfig(config.copy(segments = newSegments, activeSegmentIndex = nextActiveIndex))
+@Composable
+private fun GeneralSettingsScreen(onBack: () -> Unit) {
+ val context = LocalContext.current
+ SettingsDetailScaffold(
+ title = stringResource(R.string.general),
+ onBack = onBack
+ ) {
+ Spacer(modifier = Modifier.height(8.dp))
+ SettingsGroup {
+ SettingsLinkRow(
+ icon = Icons.Default.Translate,
+ title = stringResource(R.string.label_translator_title),
+ subtitle = stringResource(R.string.label_translator_subtitle),
+ onClick = {
+ try {
+ context.startActivity(Intent(context, TranslatorMainActivity::class.java))
+ } catch (e: Exception) {
+ android.widget.Toast.makeText(context, "Could not launch translator: ${e.message}", android.widget.Toast.LENGTH_LONG).show()
}
- )
- Spacer(modifier = Modifier.height(16.dp))
+ }
+ )
+ }
+ Spacer(modifier = Modifier.height(24.dp))
+ }
+}
+
+@Composable
+private fun AboutSettingsScreen(onBack: () -> Unit) {
+ val context = LocalContext.current
+ var showDonateSheet by remember { mutableStateOf(false) }
+ val versionName = remember(context) {
+ runCatching {
+ context.packageManager.getPackageInfo(context.packageName, 0).versionName
+ }.getOrNull().orEmpty()
+ }
+
+ SettingsDetailScaffold(
+ title = stringResource(R.string.settings_cat_about),
+ onBack = onBack
+ ) {
+ Spacer(modifier = Modifier.height(8.dp))
+ SettingsGroup {
+ SettingsValueRow(
+ icon = Icons.Default.Android,
+ title = stringResource(R.string.about_version),
+ value = versionName
+ )
+ SettingsGroupDivider()
+ SettingsLinkRow(
+ icon = Icons.Default.Code,
+ title = stringResource(R.string.about_source_code),
+ subtitle = stringResource(R.string.about_source_subtitle),
+ onClick = {
+ try {
+ context.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/aks-labs")))
+ } catch (e: Exception) {
+ android.widget.Toast.makeText(context, context.getString(R.string.toast_could_not_open_link), android.widget.Toast.LENGTH_SHORT).show()
+ }
+ }
+ )
+ SettingsGroupDivider()
+ SettingsLinkRow(
+ icon = Icons.Default.FavoriteBorder,
+ title = stringResource(R.string.btn_donate),
+ subtitle = stringResource(R.string.about_donate_subtitle),
+ onClick = { showDonateSheet = true }
+ )
+ }
+ Spacer(modifier = Modifier.height(24.dp))
+ }
+
+ if (showDonateSheet) {
+ DonateBottomSheet(
+ onDismiss = { showDonateSheet = false },
+ onDonateOptionSelected = { url ->
+ try {
+ context.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(url)))
+ } catch (e: Exception) {
+ android.widget.Toast.makeText(context, context.getString(R.string.toast_could_not_open_link), android.widget.Toast.LENGTH_SHORT).show()
+ }
+ showDonateSheet = false
}
+ )
+ }
+}
+
+@Composable
+private fun SettingsGroup(
+ modifier: Modifier = Modifier,
+ content: @Composable ColumnScope.() -> Unit
+) {
+ Surface(
+ modifier = modifier.fillMaxWidth(),
+ shape = RoundedCornerShape(16.dp),
+ color = MaterialTheme.colorScheme.surfaceContainerLow
+ ) {
+ Column(content = content)
+ }
+}
+
+@Composable
+private fun SettingsGroupDivider() {
+ HorizontalDivider(modifier = Modifier.padding(start = 56.dp))
+}
+
+@Composable
+private fun SettingsCategoryRow(
+ icon: ImageVector,
+ title: String,
+ subtitle: String,
+ onClick: () -> Unit,
+ iconTint: Color = MaterialTheme.colorScheme.primary
+) {
+ Row(
+ modifier = Modifier
+ .fillMaxWidth()
+ .clickable(onClick = onClick)
+ .padding(horizontal = 16.dp, vertical = 12.dp),
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ Icon(
+ imageVector = icon,
+ contentDescription = null,
+ modifier = Modifier.size(24.dp),
+ tint = iconTint
+ )
+ Spacer(modifier = Modifier.width(16.dp))
+ Column(modifier = Modifier.weight(1f)) {
+ Text(text = title, style = MaterialTheme.typography.bodyLarge)
+ Text(
+ text = subtitle,
+ style = MaterialTheme.typography.bodyMedium,
+ color = MaterialTheme.colorScheme.onSurfaceVariant
+ )
+ }
+ Spacer(modifier = Modifier.width(8.dp))
+ Icon(
+ imageVector = Icons.AutoMirrored.Filled.ArrowForwardIos,
+ contentDescription = null,
+ modifier = Modifier.size(14.dp),
+ tint = MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.5f)
+ )
+ }
+}
+
+@Composable
+private fun SettingsLinkRow(
+ icon: ImageVector,
+ title: String,
+ subtitle: String,
+ onClick: () -> Unit
+) {
+ SettingsCategoryRow(
+ icon = icon,
+ title = title,
+ subtitle = subtitle,
+ onClick = onClick,
+ iconTint = MaterialTheme.colorScheme.onSurfaceVariant
+ )
+}
+
+@Composable
+private fun SettingsInfoRow(
+ icon: ImageVector,
+ title: String,
+ subtitle: String
+) {
+ Row(
+ modifier = Modifier
+ .fillMaxWidth()
+ .padding(horizontal = 16.dp, vertical = 12.dp),
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ Icon(
+ imageVector = icon,
+ contentDescription = null,
+ modifier = Modifier.size(24.dp),
+ tint = MaterialTheme.colorScheme.onSurfaceVariant
+ )
+ Spacer(modifier = Modifier.width(16.dp))
+ Column {
+ Text(text = title, style = MaterialTheme.typography.bodyLarge)
+ Text(
+ text = subtitle,
+ style = MaterialTheme.typography.bodyMedium,
+ color = MaterialTheme.colorScheme.onSurfaceVariant
+ )
}
}
}
+@Composable
+private fun SettingsValueRow(
+ icon: ImageVector,
+ title: String,
+ value: String
+) {
+ Row(
+ modifier = Modifier
+ .fillMaxWidth()
+ .padding(horizontal = 16.dp, vertical = 14.dp),
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ Icon(
+ imageVector = icon,
+ contentDescription = null,
+ modifier = Modifier.size(24.dp),
+ tint = MaterialTheme.colorScheme.onSurfaceVariant
+ )
+ Spacer(modifier = Modifier.width(16.dp))
+ Text(
+ text = title,
+ style = MaterialTheme.typography.bodyLarge,
+ modifier = Modifier.weight(1f)
+ )
+ Text(
+ text = value,
+ style = MaterialTheme.typography.bodyMedium,
+ color = MaterialTheme.colorScheme.onSurfaceVariant
+ )
+ }
+}
+
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun SegmentEditorItem(
diff --git a/app/src/main/java/com/akslabs/circletosearch/ui/SettingsScreen.kt b/app/src/main/java/com/akslabs/circletosearch/ui/SettingsScreen.kt
index 8fbb04f..c2dae5b 100644
--- a/app/src/main/java/com/akslabs/circletosearch/ui/SettingsScreen.kt
+++ b/app/src/main/java/com/akslabs/circletosearch/ui/SettingsScreen.kt
@@ -227,48 +227,31 @@ fun SettingsToggleItem(
Row(
modifier = Modifier
.fillMaxWidth()
- .clip(RoundedCornerShape(20.dp))
.clickable { onCheckedChange(!checked) }
- .padding(vertical = 12.dp),
+ .padding(horizontal = 16.dp, vertical = 12.dp),
verticalAlignment = Alignment.CenterVertically
) {
- Surface(
- modifier = Modifier.size(48.dp),
- shape = RoundedCornerShape(14.dp),
- color = MaterialTheme.colorScheme.primaryContainer.copy(alpha = 0.4f)
- ) {
- Icon(
- imageVector = icon,
- contentDescription = null,
- modifier = Modifier
- .padding(12.dp)
- .size(24.dp),
- tint = MaterialTheme.colorScheme.onPrimaryContainer
- )
- }
-
+ Icon(
+ imageVector = icon,
+ contentDescription = null,
+ modifier = Modifier.size(24.dp),
+ tint = MaterialTheme.colorScheme.onSurfaceVariant
+ )
+
Spacer(modifier = Modifier.width(16.dp))
-
+
Column(modifier = Modifier.weight(1f)) {
- Text(
- text = title,
- style = MaterialTheme.typography.titleMedium.copy(fontWeight = FontWeight.Bold)
- )
+ Text(text = title, style = MaterialTheme.typography.bodyLarge)
Text(
text = subtitle,
- style = MaterialTheme.typography.bodySmall,
+ style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
}
-
- Switch(
- checked = checked,
- onCheckedChange = onCheckedChange,
- colors = SwitchDefaults.colors(
- checkedThumbColor = MaterialTheme.colorScheme.primary,
- checkedTrackColor = MaterialTheme.colorScheme.primaryContainer
- )
- )
+
+ Spacer(modifier = Modifier.width(8.dp))
+
+ Switch(checked = checked, onCheckedChange = onCheckedChange)
}
}
diff --git a/app/src/main/java/com/akslabs/circletosearch/ui/wobblepulldown/LiquidRippleModifier.kt b/app/src/main/java/com/akslabs/circletosearch/ui/wobblepulldown/LiquidRippleModifier.kt
new file mode 100644
index 0000000..b8dfb2a
--- /dev/null
+++ b/app/src/main/java/com/akslabs/circletosearch/ui/wobblepulldown/LiquidRippleModifier.kt
@@ -0,0 +1,112 @@
+package com.sameerasw.essentials.wobblepulldown
+
+import android.graphics.RenderEffect
+import android.graphics.RuntimeShader
+import android.os.Build
+import androidx.compose.animation.core.Animatable
+import androidx.compose.animation.core.LinearEasing
+import androidx.compose.animation.core.tween
+import androidx.compose.runtime.LaunchedEffect
+import androidx.compose.runtime.remember
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.composed
+import androidx.compose.ui.geometry.Offset
+import androidx.compose.ui.geometry.isSpecified
+import androidx.compose.ui.graphics.asComposeRenderEffect
+import androidx.compose.ui.graphics.graphicsLayer
+import androidx.compose.ui.platform.LocalDensity
+import org.intellij.lang.annotations.Language
+
+@Language("AGSL")
+private const val LIQUID_RIPPLE_AGSL = """
+ uniform shader inputShader;
+ uniform float2 uResolution;
+ uniform float2 uOrigin;
+ uniform float uTime;
+ uniform float uAmplitude;
+ uniform float uFrequency;
+ uniform float uDecay;
+ uniform float uSpeed;
+
+ half4 main(float2 fragCoord) {
+ float2 pos = fragCoord;
+ float distance = length(pos - uOrigin);
+ float delay = distance / uSpeed;
+ float time = max(0.0, uTime - delay);
+
+ float wave1 = uAmplitude * sin(uFrequency * time) * exp(-uDecay * time);
+
+ float subTime = max(0.0, time - 0.22);
+ float wave2 = (uAmplitude * 0.55) * sin(uFrequency * 1.15 * subTime) * exp(-(uDecay * 0.8) * subTime);
+
+ float totalWave = wave1 + wave2;
+ float2 n = normalize(pos - uOrigin);
+ float2 newPos = pos + totalWave * n;
+
+ float highlight = 0.16 * (totalWave / max(1.0, uAmplitude));
+
+ return inputShader.eval(newPos) + half4(highlight, highlight, highlight, 0.0);
+ }
+"""
+
+fun Modifier.liquidRipple(
+ trigger: Int,
+ origin: Offset,
+ enabled: Boolean = true,
+ durationMillis: Int = 2800,
+ amplitudeDp: Float = 34f,
+ frequency: Float = 12f,
+ decay: Float = 4.5f,
+ speedDp: Float = 1400f,
+): Modifier = composed {
+ if (!enabled) return@composed Modifier
+
+ val density = LocalDensity.current
+ val animTime = remember { Animatable(0f) }
+
+ LaunchedEffect(trigger) {
+ if (trigger > 0) {
+ animTime.snapTo(0f)
+ animTime.animateTo(
+ targetValue = durationMillis / 1000f,
+ animationSpec = tween(durationMillis = durationMillis, easing = LinearEasing)
+ )
+ animTime.snapTo(0f)
+ }
+ }
+
+ val shader = remember {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
+ RuntimeShader(LIQUID_RIPPLE_AGSL)
+ } else null
+ }
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU && shader != null) {
+ Modifier.graphicsLayer {
+ val currentTime = animTime.value
+ val maxTime = durationMillis / 1000f
+ if (currentTime > 0f && currentTime < maxTime) {
+ val densityVal = density.density
+ val amplitude = amplitudeDp * densityVal
+ val speed = speedDp * densityVal
+
+ val ox = if (origin != Offset.Zero && origin.isSpecified) origin.x else size.width / 2f
+ val oy = if (origin != Offset.Zero && origin.isSpecified) origin.y else size.height / 2f
+
+ shader.setFloatUniform("uResolution", size.width, size.height)
+ shader.setFloatUniform("uOrigin", ox, oy)
+ shader.setFloatUniform("uTime", currentTime)
+ shader.setFloatUniform("uAmplitude", amplitude)
+ shader.setFloatUniform("uFrequency", frequency)
+ shader.setFloatUniform("uDecay", decay)
+ shader.setFloatUniform("uSpeed", speed)
+
+ renderEffect = RenderEffect.createRuntimeShaderEffect(shader, "inputShader").asComposeRenderEffect()
+ } else {
+ renderEffect = null
+ }
+ }
+ } else {
+ Modifier
+ }
+}
diff --git a/app/src/main/java/com/akslabs/circletosearch/ui/wobblepulldown/ProgressiveBlurModifier.kt b/app/src/main/java/com/akslabs/circletosearch/ui/wobblepulldown/ProgressiveBlurModifier.kt
new file mode 100644
index 0000000..d6837b1
--- /dev/null
+++ b/app/src/main/java/com/akslabs/circletosearch/ui/wobblepulldown/ProgressiveBlurModifier.kt
@@ -0,0 +1,141 @@
+package com.sameerasw.essentials.wobblepulldown
+
+import android.graphics.RenderEffect
+import android.graphics.RuntimeShader
+import android.os.Build
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.runtime.remember
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.composed
+import androidx.compose.ui.draw.drawWithContent
+import androidx.compose.ui.graphics.Brush
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.graphics.asComposeRenderEffect
+import androidx.compose.ui.graphics.graphicsLayer
+import org.intellij.lang.annotations.Language
+
+enum class BlurDirection {
+ TOP,
+ BOTTOM,
+}
+
+@Language("AGSL")
+private val PROGRESSIVE_BLUR_SKSL = """
+ uniform shader content;
+ uniform float blurRadius;
+ uniform float height;
+ uniform float contentHeight;
+ uniform int isTop;
+
+ half4 main(float2 fragCoord) {
+ float progress;
+ if (isTop == 1) {
+ progress = 1.0 - clamp(fragCoord.y / height, 0.0, 1.0);
+ } else {
+ progress = 1.0 - clamp((contentHeight - fragCoord.y) / height, 0.0, 1.0);
+ }
+
+ progress = pow(progress, 1.5);
+ float radius = progress * blurRadius;
+
+ if (radius <= 0.0) {
+ return content.eval(fragCoord);
+ }
+
+ half4 accum = half4(0.0);
+ float weightSum = 0.0;
+
+ float dither = fract(sin(dot(fragCoord, float2(12.9898, 78.233))) * 43758.5453);
+ float2 jitter = float2(dither - 0.5, fract(dither * 1.618) - 0.5);
+
+ const int SAMPLES = 4;
+ float offsetScale = radius / float(SAMPLES);
+
+ for (int x = -SAMPLES; x <= SAMPLES; x++) {
+ for (int y = -SAMPLES; y <= SAMPLES; y++) {
+ float2 offset = (float2(float(x), float(y)) + jitter) * offsetScale;
+ float distSq = dot(offset, offset);
+ float radiusSq = radius * radius;
+
+ if (distSq <= radiusSq) {
+ float weight = exp(-3.0 * distSq / radiusSq);
+ accum += content.eval(fragCoord + offset) * weight;
+ weightSum += weight;
+ }
+ }
+ }
+
+ return accum / weightSum;
+ }
+""".trimIndent()
+
+fun Modifier.progressiveBlur(
+ blurRadius: Float,
+ height: Float,
+ direction: BlurDirection = BlurDirection.TOP,
+ showGradientOverlay: Boolean = true,
+): Modifier = composed {
+ val overlayColor = MaterialTheme.colorScheme.surfaceContainer.copy(alpha = 0.65f)
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU && blurRadius > 0f && height > 0f) {
+ val shader = remember { RuntimeShader(PROGRESSIVE_BLUR_SKSL) }
+ this
+ .graphicsLayer {
+ shader.setFloatUniform("blurRadius", blurRadius)
+ shader.setFloatUniform("height", height)
+ shader.setFloatUniform("contentHeight", size.height)
+ shader.setIntUniform("isTop", if (direction == BlurDirection.TOP) 1 else 0)
+
+ renderEffect = RenderEffect
+ .createRuntimeShaderEffect(shader, "content")
+ .asComposeRenderEffect()
+ }
+ .then(
+ if (showGradientOverlay) {
+ Modifier.drawWithContent {
+ drawContent()
+ if (direction == BlurDirection.TOP) {
+ drawRect(
+ brush = Brush.verticalGradient(
+ colors = listOf(overlayColor, Color.Transparent),
+ startY = 0f,
+ endY = height,
+ )
+ )
+ } else {
+ drawRect(
+ brush = Brush.verticalGradient(
+ colors = listOf(Color.Transparent, overlayColor),
+ startY = size.height - height,
+ endY = size.height,
+ )
+ )
+ }
+ }
+ } else Modifier
+ )
+ } else if (showGradientOverlay && height > 0f) {
+ this.drawWithContent {
+ drawContent()
+ if (direction == BlurDirection.TOP) {
+ drawRect(
+ brush = Brush.verticalGradient(
+ colors = listOf(overlayColor, Color.Transparent),
+ startY = 0f,
+ endY = height,
+ )
+ )
+ } else {
+ drawRect(
+ brush = Brush.verticalGradient(
+ colors = listOf(Color.Transparent, overlayColor),
+ startY = size.height - height,
+ endY = size.height,
+ )
+ )
+ }
+ }
+ } else {
+ this
+ }
+}
diff --git a/app/src/main/java/com/akslabs/circletosearch/ui/wobblepulldown/README.md b/app/src/main/java/com/akslabs/circletosearch/ui/wobblepulldown/README.md
new file mode 100644
index 0000000..6365e04
--- /dev/null
+++ b/app/src/main/java/com/akslabs/circletosearch/ui/wobblepulldown/README.md
@@ -0,0 +1,87 @@
+# Wobble Pull-Down & Device Info Animation Package
+
+This package contains all necessary files and composables to implement the full-screen wobble liquid ripple pull-down gesture on a home screen and transition seamlessly into a Device Info screen with elastic overscroll scaling.
+
+## 📦 Package Contents
+
+1. **`LiquidRippleModifier.kt`**: Custom Compose modifier applying an AGSL liquid wave ripple shader (`LIQUID_RIPPLE_AGSL`) on Android 13+ (API 33+).
+2. **`ProgressiveBlurModifier.kt`**: Custom Compose modifier applying a progressive edge blur shader (`PROGRESSIVE_BLUR_SKSL`) to bars and overlays.
+3. **`WobbleHaptics.kt`**: Centralized haptic feedback helper for pull-down steps and overscroll ticks.
+4. **`WobbleDeviceInfo.kt`**: `WobbleDeviceInfo` data model & `WobbleDeviceUtils` helper to fetch hardware (RAM, Storage) and system info (Android Version, SDK, Security Patch, Model, etc.).
+5. **`WobbleDeviceImageMapper.kt`**: Utility mapping Android OS versions/codenames to Android logo drawables.
+6. **`WobbleHomeScreen.kt`**: Home screen UI containing the expandable device hero card, search bar placeholder, settings list, and `PullToRefreshBox` with `liquidRipple` wobble animation.
+7. **`WobbleDeviceInfoScreen.kt`**: Device Info screen UI featuring elastic overscroll logo scaling, hardware spec cards, and progressive blur.
+8. **`WobbleDeviceInfoActivity.kt`**: Activity hosting `WobbleDeviceInfoScreen` with slide-in/slide-out activity transition animations.
+
+---
+
+## 🚀 How to Extract & Use in Another App
+
+### Step 1: Copy Files
+Copy the `wobblepulldown` package folder into your target app module (`com.yourpackage.wobblepulldown`). Update package declarations at the top of each file.
+
+### Step 2: Add Required Dependencies
+Ensure your target app's `build.gradle.kts` includes:
+```kotlin
+dependencies {
+ implementation(platform(libs.androidx.compose.bom))
+ implementation(libs.androidx.compose.ui)
+ implementation(libs.androidx.compose.material3)
+ implementation(libs.androidx.compose.material.icons.extended)
+}
+```
+
+### Step 3: Add Transition Animations
+Copy the following 3 XML animation files into `res/anim/`:
+- `anim_slide_in_top.xml`:
+ ```xml
+ <?xml version="1.0" encoding="utf-8"?>
+ <set xmlns:android="http://schemas.android.com/apk/res/android"
+ android:interpolator="@android:anim/decelerate_interpolator">
+ <translate android:duration="400" android:fromYDelta="-100%" android:toYDelta="0" />
+ </set>
+ ```
+- `anim_slide_out_top.xml`:
+ ```xml
+ <?xml version="1.0" encoding="utf-8"?>
+ <set xmlns:android="http://schemas.android.com/apk/res/android"
+ android:interpolator="@android:anim/accelerate_interpolator">
+ <translate android:duration="400" android:fromYDelta="0" android:toYDelta="-100%" />
+ </set>
+ ```
+- `anim_stay.xml`:
+ ```xml
+ <?xml version="1.0" encoding="utf-8"?>
+ <set xmlns:android="http://schemas.android.com/apk/res/android">
+ <translate android:duration="400" android:fromYDelta="0" android:toYDelta="0" />
+ </set>
+ ```
+
+### Step 4: Register Activity in `AndroidManifest.xml`
+```xml
+<activity
+ android:name=".wobblepulldown.WobbleDeviceInfoActivity"
+ android:exported="false"
+ android:label="Device Info"
+ android:theme="@style/Theme.YourApp" />
+```
+
+### Step 5: Embed `WobbleHomeScreen` in your App
+```kotlin
+@Composable
+fun MainScreen() {
+ val context = LocalContext.current
+
+ WobbleHomeScreen(
+ onOpenDeviceInfo = {
+ val intent = Intent(context, WobbleDeviceInfoActivity::class.java)
+ val options = androidx.core.app.ActivityOptionsCompat.makeCustomAnimation(
+ context,
+ R.anim.anim_slide_in_top,
+ R.anim.anim_stay,
+ )
+ context.startActivity(intent, options.toBundle())
+ }
+ )
+}
+```
diff --git a/app/src/main/java/com/akslabs/circletosearch/ui/wobblepulldown/WobbleDeviceImageMapper.kt b/app/src/main/java/com/akslabs/circletosearch/ui/wobblepulldown/WobbleDeviceImageMapper.kt
new file mode 100644
index 0000000..40017f1
--- /dev/null
+++ b/app/src/main/java/com/akslabs/circletosearch/ui/wobblepulldown/WobbleDeviceImageMapper.kt
@@ -0,0 +1,20 @@
+package com.sameerasw.essentials.wobblepulldown
+
+import com.sameerasw.essentials.R
+
+object WobbleDeviceImageMapper {
+ fun getAndroidLogo(deviceInfo: WobbleDeviceInfo): Int {
+ val osName = deviceInfo.osCodename.lowercase()
+ val sdk = deviceInfo.sdkInt
+
+ return when {
+ osName.contains("android 17") || osName.contains("cinnamonbun") || sdk >= 37 -> R.drawable.android17
+ osName.contains("android 16") || osName.contains("baklava") || sdk >= 36 -> R.drawable.android16
+ osName.contains("android 15") || osName.contains("vanilla") || sdk >= 35 -> R.drawable.android15
+ osName.contains("android 14") || osName.contains("upside") || sdk >= 34 -> R.drawable.android14
+ osName.contains("android 13") || osName.contains("tiramisu") || sdk >= 33 -> R.drawable.android13
+ osName.contains("android 12") || osName.contains("snow cone") || sdk >= 31 -> R.drawable.android12
+ else -> R.drawable.rounded_android_24
+ }
+ }
+}
diff --git a/app/src/main/java/com/akslabs/circletosearch/ui/wobblepulldown/WobbleDeviceInfo.kt b/app/src/main/java/com/akslabs/circletosearch/ui/wobblepulldown/WobbleDeviceInfo.kt
new file mode 100644
index 0000000..6d06236
--- /dev/null
+++ b/app/src/main/java/com/akslabs/circletosearch/ui/wobblepulldown/WobbleDeviceInfo.kt
@@ -0,0 +1,86 @@
+package com.sameerasw.essentials.wobblepulldown
+
+import android.app.ActivityManager
+import android.content.Context
+import android.os.Build
+import android.os.Environment
+import android.os.StatFs
+import android.provider.Settings
+import java.util.Locale
+
+data class WobbleDeviceInfo(
+ val deviceName: String,
+ val brand: String = Build.BRAND,
+ val model: String = Build.MODEL,
+ val device: String = Build.DEVICE,
+ val hardware: String = Build.HARDWARE,
+ val product: String = Build.PRODUCT,
+ val androidVersion: String = Build.VERSION.RELEASE,
+ val sdkInt: Int = Build.VERSION.SDK_INT,
+ val manufacturer: String = Build.MANUFACTURER,
+ val board: String = Build.BOARD,
+ val display: String = Build.DISPLAY,
+ val fingerprint: String = Build.FINGERPRINT,
+ val totalStorage: Long = 0L,
+ val availableStorage: Long = 0L,
+ val totalRam: Long = 0L,
+ val availableRam: Long = 0L,
+ val securityPatch: String = Build.VERSION.SECURITY_PATCH,
+ val osCodename: String = Build.VERSION.CODENAME,
+)
+
+object WobbleDeviceUtils {
+ fun getDeviceInfo(context: Context): WobbleDeviceInfo {
+ val deviceName = try {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
+ Settings.Global.getString(context.contentResolver, Settings.Global.DEVICE_NAME)
+ ?: Settings.Secure.getString(context.contentResolver, "bluetooth_name")
+ ?: Build.MODEL
+ } else {
+ Settings.Secure.getString(context.contentResolver, "bluetooth_name") ?: Build.MODEL
+ }
+ } catch (_: Exception) {
+ Build.MODEL
+ } ?: Build.MODEL
+
+ var totalStorage = 0L
+ var availStorage = 0L
+ try {
+ val stat = StatFs(Environment.getDataDirectory().path)
+ totalStorage = stat.blockCountLong * stat.blockSizeLong
+ availStorage = stat.availableBlocksLong * stat.blockSizeLong
+ } catch (_: Exception) {}
+
+ var totalRam = 0L
+ var availRam = 0L
+ try {
+ val actManager = context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
+ val memInfo = ActivityManager.MemoryInfo()
+ actManager.getMemoryInfo(memInfo)
+ totalRam = memInfo.totalMem
+ availRam = memInfo.availMem
+ } catch (_: Exception) {}
+
+ return WobbleDeviceInfo(
+ deviceName = deviceName,
+ totalStorage = totalStorage,
+ availableStorage = availStorage,
+ totalRam = totalRam,
+ availableRam = availRam,
+ )
+ }
+
+ fun formatHardwareSize(bytes: Long): String {
+ if (bytes <= 0) return "Unknown"
+ val gb = bytes / (1024.0 * 1024.0 * 1024.0)
+ return when {
+ gb > 512 -> "1 TB"
+ gb > 256 -> "512 GB"
+ gb > 128 -> "256 GB"
+ gb > 64 -> "128 GB"
+ gb > 32 -> "64 GB"
+ gb > 16 -> "32 GB"
+ else -> String.format(Locale.US, "%.1f GB", gb)
+ }
+ }
+}
diff --git a/app/src/main/java/com/akslabs/circletosearch/ui/wobblepulldown/WobbleDeviceInfoActivity.kt b/app/src/main/java/com/akslabs/circletosearch/ui/wobblepulldown/WobbleDeviceInfoActivity.kt
new file mode 100644
index 0000000..29a27ac
--- /dev/null
+++ b/app/src/main/java/com/akslabs/circletosearch/ui/wobblepulldown/WobbleDeviceInfoActivity.kt
@@ -0,0 +1,36 @@
+package com.sameerasw.essentials.wobblepulldown
+
+import android.os.Bundle
+import androidx.activity.ComponentActivity
+import androidx.activity.OnBackPressedCallback
+import androidx.activity.compose.setContent
+import androidx.activity.enableEdgeToEdge
+import com.sameerasw.essentials.R
+import com.sameerasw.essentials.ui.theme.EssentialsTheme
+
+class WobbleDeviceInfoActivity : ComponentActivity() {
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ enableEdgeToEdge()
+
+ onBackPressedDispatcher.addCallback(this, object : OnBackPressedCallback(true) {
+ override fun handleOnBackPressed() {
+ finish()
+ @Suppress("DEPRECATION")
+ overridePendingTransition(R.anim.anim_stay, R.anim.anim_slide_out_top)
+ }
+ })
+
+ setContent {
+ EssentialsTheme {
+ WobbleDeviceInfoScreen(
+ onBackClick = {
+ finish()
+ @Suppress("DEPRECATION")
+ overridePendingTransition(R.anim.anim_stay, R.anim.anim_slide_out_top)
+ }
+ )
+ }
+ }
+ }
+}
diff --git a/app/src/main/java/com/akslabs/circletosearch/ui/wobblepulldown/WobbleDeviceInfoScreen.kt b/app/src/main/java/com/akslabs/circletosearch/ui/wobblepulldown/WobbleDeviceInfoScreen.kt
new file mode 100644
index 0000000..4d2bc6d
--- /dev/null
+++ b/app/src/main/java/com/akslabs/circletosearch/ui/wobblepulldown/WobbleDeviceInfoScreen.kt
@@ -0,0 +1,394 @@
+package com.sameerasw.essentials.wobblepulldown
+
+import androidx.compose.animation.core.Animatable
+import androidx.compose.animation.core.EaseOut
+import androidx.compose.animation.core.FastOutSlowInEasing
+import androidx.compose.animation.core.Spring
+import androidx.compose.animation.core.animateDpAsState
+import androidx.compose.animation.core.animateFloatAsState
+import androidx.compose.animation.core.spring
+import androidx.compose.animation.core.tween
+import androidx.compose.foundation.background
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.Spacer
+import androidx.compose.foundation.layout.WindowInsets
+import androidx.compose.foundation.layout.asPaddingValues
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.statusBars
+import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.rememberScrollState
+import androidx.compose.foundation.shape.CircleShape
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.foundation.verticalScroll
+import androidx.compose.material.icons.Icons
+import androidx.compose.material.icons.automirrored.rounded.ArrowBack
+import androidx.compose.material.icons.rounded.Memory
+import androidx.compose.material.icons.rounded.Storage
+import androidx.compose.material3.Card
+import androidx.compose.material3.CardDefaults
+import androidx.compose.material3.Icon
+import androidx.compose.material3.IconButton
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.Surface
+import androidx.compose.material3.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.LaunchedEffect
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.rememberCoroutineScope
+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.graphics.Color
+import androidx.compose.ui.graphics.graphicsLayer
+import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
+import androidx.compose.ui.input.nestedscroll.NestedScrollSource
+import androidx.compose.ui.input.nestedscroll.nestedScroll
+import androidx.compose.ui.input.pointer.PointerEventType
+import androidx.compose.ui.input.pointer.pointerInput
+import androidx.compose.ui.platform.LocalContext
+import androidx.compose.ui.platform.LocalDensity
+import androidx.compose.ui.platform.LocalView
+import androidx.compose.ui.res.painterResource
+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.unit.Dp
+import androidx.compose.ui.unit.dp
+import com.sameerasw.essentials.R
+import kotlinx.coroutines.launch
+
+@Composable
+fun WobbleDeviceInfoScreen(
+ onBackClick: () -> Unit,
+ modifier: Modifier = Modifier,
+) {
+ val context = LocalContext.current
+ val view = LocalView.current
+ val scope = rememberCoroutineScope()
+ val deviceInfo = remember { WobbleDeviceUtils.getDeviceInfo(context) }
+ val scrollState = rememberScrollState()
+ val overscrollOffset = remember { Animatable(0f) }
+
+ val nestedScrollConnection = remember {
+ object : NestedScrollConnection {
+ override fun onPreScroll(available: Offset, source: NestedScrollSource): Offset {
+ if (available.y < 0 && overscrollOffset.value > 0) {
+ val toConsume = if (overscrollOffset.value + available.y >= 0) available.y else -overscrollOffset.value
+ scope.launch { overscrollOffset.snapTo(overscrollOffset.value + toConsume) }
+ return Offset(0f, toConsume)
+ }
+ return Offset.Zero
+ }
+
+ override fun onPostScroll(consumed: Offset, available: Offset, source: NestedScrollSource): Offset {
+ if (available.y > 0 && scrollState.value == 0) {
+ val prevValue = overscrollOffset.value
+ if (prevValue >= 350f) return Offset.Zero
+
+ val newValue = (prevValue + available.y * 0.5f).coerceAtMost(350f)
+ scope.launch { overscrollOffset.snapTo(newValue) }
+
+ if (prevValue < 300f && newValue >= 300f) {
+ WobbleHaptics.performUIHaptic(view)
+ }
+
+ return Offset(0f, available.y)
+ }
+ return super.onPostScroll(consumed, available, source)
+ }
+ }
+ }
+
+ var isStartupAnimDone by remember { mutableStateOf(false) }
+ LaunchedEffect(Unit) {
+ isStartupAnimDone = true
+ }
+
+ val contentAlphaState by animateFloatAsState(
+ targetValue = if (isStartupAnimDone) 1f else 0f,
+ animationSpec = tween(durationMillis = 400, easing = EaseOut),
+ label = "contentAlpha",
+ )
+
+ val contentOffsetState by animateDpAsState(
+ targetValue = if (isStartupAnimDone) 0.dp else 40.dp,
+ animationSpec = tween(durationMillis = 400, easing = FastOutSlowInEasing),
+ label = "contentOffset",
+ )
+
+ val statusBarHeightPx = with(LocalDensity.current) {
+ WindowInsets.statusBars.asPaddingValues().calculateTopPadding().toPx()
+ }
+
+ Box(
+ modifier = modifier
+ .fillMaxSize()
+ .background(MaterialTheme.colorScheme.surfaceContainer)
+ .progressiveBlur(
+ blurRadius = 40f,
+ height = statusBarHeightPx * 1.5f,
+ direction = BlurDirection.TOP,
+ ),
+ ) {
+ Column(
+ modifier = Modifier
+ .fillMaxSize()
+ .progressiveBlur(
+ blurRadius = 40f,
+ height = with(LocalDensity.current) { 120.dp.toPx() },
+ direction = BlurDirection.BOTTOM,
+ )
+ .nestedScroll(nestedScrollConnection)
+ .pointerInput(Unit) {
+ awaitPointerEventScope {
+ while (true) {
+ val event = awaitPointerEvent()
+ if (event.type == PointerEventType.Release && overscrollOffset.value > 0) {
+ scope.launch {
+ overscrollOffset.animateTo(
+ 0f,
+ spring(stiffness = Spring.StiffnessMediumLow),
+ )
+ }
+ }
+ }
+ }
+ }
+ .verticalScroll(scrollState)
+ .padding(
+ top = WindowInsets.statusBars.asPaddingValues().calculateTopPadding() + 16.dp,
+ bottom = 120.dp,
+ start = 16.dp,
+ end = 16.dp,
+ ),
+ verticalArrangement = Arrangement.spacedBy(16.dp),
+ ) {
+ Row(
+ modifier = Modifier.fillMaxWidth(),
+ verticalAlignment = Alignment.CenterVertically,
+ ) {
+ IconButton(
+ onClick = {
+ WobbleHaptics.performUIHaptic(view)
+ onBackClick()
+ },
+ modifier = Modifier
+ .clip(CircleShape)
+ .background(MaterialTheme.colorScheme.surfaceContainerHigh),
+ ) {
+ Icon(
+ imageVector = Icons.AutoMirrored.Rounded.ArrowBack,
+ contentDescription = "Back",
+ tint = MaterialTheme.colorScheme.onSurface,
+ )
+ }
+ Spacer(modifier = Modifier.width(16.dp))
+ Text(
+ text = "Device Info",
+ style = MaterialTheme.typography.titleLarge,
+ fontWeight = FontWeight.Bold,
+ color = MaterialTheme.colorScheme.onSurface,
+ )
+ }
+
+ WobbleDeviceHeroCard(
+ deviceInfo = deviceInfo,
+ contentAlpha = { contentAlphaState },
+ contentOffset = { contentOffsetState },
+ overscrollOffset = overscrollOffset.value,
+ )
+
+ Text(
+ text = "Hardware Details",
+ style = MaterialTheme.typography.titleMedium,
+ color = MaterialTheme.colorScheme.primary,
+ modifier = Modifier.padding(top = 8.dp),
+ )
+
+ Row(
+ modifier = Modifier.fillMaxWidth(),
+ horizontalArrangement = Arrangement.spacedBy(12.dp),
+ ) {
+ Card(
+ modifier = Modifier.weight(1f),
+ colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceContainerLow),
+ shape = RoundedCornerShape(24.dp),
+ ) {
+ Column(modifier = Modifier.padding(16.dp)) {
+ Icon(
+ imageVector = Icons.Rounded.Storage,
+ contentDescription = null,
+ tint = MaterialTheme.colorScheme.primary,
+ )
+ Spacer(modifier = Modifier.height(8.dp))
+ Text(
+ text = WobbleDeviceUtils.formatHardwareSize(deviceInfo.totalStorage),
+ style = MaterialTheme.typography.titleMedium,
+ fontWeight = FontWeight.Bold,
+ )
+ Text(
+ text = "Total Storage",
+ style = MaterialTheme.typography.bodySmall,
+ color = MaterialTheme.colorScheme.onSurfaceVariant,
+ )
+ }
+ }
+
+ Card(
+ modifier = Modifier.weight(1f),
+ colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceContainerLow),
+ shape = RoundedCornerShape(24.dp),
+ ) {
+ Column(modifier = Modifier.padding(16.dp)) {
+ Icon(
+ imageVector = Icons.Rounded.Memory,
+ contentDescription = null,
+ tint = MaterialTheme.colorScheme.primary,
+ )
+ Spacer(modifier = Modifier.height(8.dp))
+ Text(
+ text = WobbleDeviceUtils.formatHardwareSize(deviceInfo.totalRam),
+ style = MaterialTheme.typography.titleMedium,
+ fontWeight = FontWeight.Bold,
+ )
+ Text(
+ text = "Total RAM",
+ style = MaterialTheme.typography.bodySmall,
+ color = MaterialTheme.colorScheme.onSurfaceVariant,
+ )
+ }
+ }
+ }
+
+ Text(
+ text = "System Information",
+ style = MaterialTheme.typography.titleMedium,
+ color = MaterialTheme.colorScheme.primary,
+ modifier = Modifier.padding(top = 8.dp),
+ )
+
+ Surface(
+ shape = RoundedCornerShape(24.dp),
+ color = MaterialTheme.colorScheme.surfaceContainerLow,
+ modifier = Modifier.fillMaxWidth(),
+ ) {
+ Column(modifier = Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(12.dp)) {
+ SpecItem(label = "Android Version", value = "Android ${deviceInfo.androidVersion} (API ${deviceInfo.sdkInt})")
+ SpecItem(label = "Security Patch", value = deviceInfo.securityPatch)
+ SpecItem(label = "Manufacturer", value = deviceInfo.manufacturer.replaceFirstChar { it.uppercase() })
+ SpecItem(label = "Model / Hardware", value = "${deviceInfo.model} (${deviceInfo.hardware})")
+ SpecItem(label = "Display Build", value = deviceInfo.display)
+ }
+ }
+ }
+ }
+}
+
+@Composable
+private fun WobbleDeviceHeroCard(
+ deviceInfo: WobbleDeviceInfo,
+ contentAlpha: () -> Float,
+ contentOffset: () -> Dp,
+ overscrollOffset: Float,
+) {
+ val androidLogoRes = WobbleDeviceImageMapper.getAndroidLogo(deviceInfo)
+ val density = LocalDensity.current
+ val extraSize = with(density) { overscrollOffset.toDp() }
+
+ val fontFamily = remember {
+ try {
+ FontFamily(
+ Font(
+ R.font.google_sans_flex,
+ variationSettings = FontVariation.Settings(
+ FontVariation.width(150f),
+ FontVariation.weight(FontWeight.Normal.weight),
+ FontVariation.Setting("ROND", 100f),
+ ),
+ )
+ )
+ } catch (_: Exception) {
+ FontFamily.Default
+ }
+ }
+
+ Column(
+ modifier = Modifier
+ .fillMaxWidth()
+ .padding(vertical = 12.dp),
+ horizontalAlignment = Alignment.CenterHorizontally,
+ ) {
+ if (androidLogoRes != 0) {
+ Icon(
+ painter = painterResource(id = androidLogoRes),
+ contentDescription = null,
+ tint = Color.Unspecified,
+ modifier = Modifier
+ .graphicsLayer {
+ alpha = contentAlpha()
+ translationY = contentOffset().toPx()
+ scaleX = 1f + (overscrollOffset / 1000f)
+ scaleY = 1f + (overscrollOffset / 1000f)
+ }
+ .size(180.dp + extraSize)
+ .padding(bottom = 24.dp),
+ )
+ }
+
+ Text(
+ text = deviceInfo.deviceName,
+ modifier = Modifier.graphicsLayer {
+ alpha = contentAlpha()
+ translationY = contentOffset().toPx()
+ },
+ style = MaterialTheme.typography.headlineMedium.copy(fontFamily = fontFamily),
+ color = MaterialTheme.colorScheme.onSurface,
+ fontWeight = FontWeight.Bold,
+ )
+
+ Spacer(modifier = Modifier.height(4.dp))
+
+ Text(
+ text = "${deviceInfo.manufacturer.replaceFirstChar { it.uppercase() }} ${deviceInfo.model} (${deviceInfo.hardware})",
+ modifier = Modifier.graphicsLayer {
+ alpha = contentAlpha()
+ translationY = contentOffset().toPx()
+ },
+ style = MaterialTheme.typography.titleMedium,
+ color = MaterialTheme.colorScheme.onSurfaceVariant,
+ )
+ }
+}
+
+@Composable
+private fun SpecItem(label: String, value: String) {
+ Row(
+ modifier = Modifier.fillMaxWidth(),
+ horizontalArrangement = Arrangement.SpaceBetween,
+ verticalAlignment = Alignment.CenterVertically,
+ ) {
+ Text(
+ text = label,
+ style = MaterialTheme.typography.bodyMedium,
+ color = MaterialTheme.colorScheme.onSurfaceVariant,
+ )
+ Text(
+ text = value,
+ style = MaterialTheme.typography.bodyMedium,
+ fontWeight = FontWeight.SemiBold,
+ color = MaterialTheme.colorScheme.onSurface,
+ )
+ }
+}
diff --git a/app/src/main/java/com/akslabs/circletosearch/ui/wobblepulldown/WobbleHaptics.kt b/app/src/main/java/com/akslabs/circletosearch/ui/wobblepulldown/WobbleHaptics.kt
new file mode 100644
index 0000000..9d70576
--- /dev/null
+++ b/app/src/main/java/com/akslabs/circletosearch/ui/wobblepulldown/WobbleHaptics.kt
@@ -0,0 +1,23 @@
+package com.sameerasw.essentials.wobblepulldown
+
+import android.os.Build
+import android.view.HapticFeedbackConstants
+import android.view.View
+
+object WobbleHaptics {
+ fun performUIHaptic(view: View) {
+ view.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP)
+ }
+
+ fun performSliderHaptic(view: View) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
+ view.performHapticFeedback(HapticFeedbackConstants.SEGMENT_FREQUENT_TICK)
+ } else {
+ view.performHapticFeedback(HapticFeedbackConstants.CLOCK_TICK)
+ }
+ }
+
+ fun performHeavyHaptic(view: View) {
+ view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY)
+ }
+}
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
new file mode 100644
index 0000000..d5bb81b
--- /dev/null
+++ b/app/src/main/java/com/akslabs/circletosearch/ui/wobblepulldown/WobbleHomeScreen.kt
@@ -0,0 +1,369 @@
+package com.sameerasw.essentials.wobblepulldown
+
+import androidx.compose.animation.animateColorAsState
+import androidx.compose.animation.core.Spring
+import androidx.compose.animation.core.animateDpAsState
+import androidx.compose.animation.core.animateFloatAsState
+import androidx.compose.animation.core.animateIntAsState
+import androidx.compose.animation.core.spring
+import androidx.compose.animation.core.tween
+import androidx.compose.foundation.BorderStroke
+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.defaultMinSize
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.foundation.layout.fillMaxWidth
+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.lazy.LazyColumn
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.material.icons.Icons
+import androidx.compose.material.icons.rounded.ChevronRight
+import androidx.compose.material.icons.rounded.KeyboardArrowDown
+import androidx.compose.material.icons.rounded.Search
+import androidx.compose.material3.CardDefaults
+import androidx.compose.material3.ExperimentalMaterial3Api
+import androidx.compose.material3.Icon
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.OutlinedCard
+import androidx.compose.material3.OutlinedTextField
+import androidx.compose.material3.OutlinedTextFieldDefaults
+import androidx.compose.material3.Surface
+import androidx.compose.material3.Text
+import androidx.compose.material3.pulltorefresh.PullToRefreshBox
+import androidx.compose.material3.pulltorefresh.rememberPullToRefreshState
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.LaunchedEffect
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableIntStateOf
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.setValue
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.geometry.Offset
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.graphics.graphicsLayer
+import androidx.compose.ui.layout.onGloballyPositioned
+import androidx.compose.ui.layout.positionInRoot
+import androidx.compose.ui.platform.LocalContext
+import androidx.compose.ui.platform.LocalView
+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.unit.dp
+import com.sameerasw.essentials.R
+
+@OptIn(ExperimentalMaterial3Api::class)
+@Composable
+fun WobbleHomeScreen(
+ onOpenDeviceInfo: () -> Unit,
+ modifier: Modifier = Modifier,
+ contentPadding: PaddingValues = PaddingValues(0.dp),
+) {
+ val context = LocalContext.current
+ val view = LocalView.current
+ val pullRefreshState = rememberPullToRefreshState()
+ var isRefreshing by remember { mutableStateOf(false) }
+
+ LaunchedEffect(isRefreshing) {
+ if (isRefreshing) {
+ WobbleHaptics.performUIHaptic(view)
+ onOpenDeviceInfo()
+ isRefreshing = false
+ }
+ }
+
+ var rippleTrigger by remember { mutableIntStateOf(0) }
+ var textCenterOffset by remember { mutableStateOf(Offset.Zero) }
+ var lastHapticBucket by remember { mutableStateOf(0) }
+
+ LaunchedEffect(pullRefreshState.distanceFraction) {
+ val fraction = pullRefreshState.distanceFraction
+ val currentBucket = (fraction * 10).toInt()
+
+ if (fraction >= 1f && lastHapticBucket < 10) {
+ WobbleHaptics.performUIHaptic(view)
+ rippleTrigger++
+ lastHapticBucket = 10
+ } else if (fraction < 1f && currentBucket != lastHapticBucket) {
+ if (currentBucket > lastHapticBucket) {
+ WobbleHaptics.performSliderHaptic(view)
+ }
+ lastHapticBucket = currentBucket
+ }
+
+ if (fraction == 0f) {
+ lastHapticBucket = 0
+ }
+ }
+
+ PullToRefreshBox(
+ isRefreshing = isRefreshing,
+ onRefresh = { isRefreshing = true },
+ state = pullRefreshState,
+ indicator = { },
+ modifier = modifier
+ .fillMaxSize()
+ .liquidRipple(
+ trigger = rippleTrigger,
+ origin = textCenterOffset,
+ enabled = true,
+ durationMillis = 2800,
+ amplitudeDp = 34f,
+ frequency = 12f,
+ decay = 4.5f,
+ speedDp = 1400f,
+ ),
+ ) {
+ val deviceInfo = remember { WobbleDeviceUtils.getDeviceInfo(context) }
+ val displayFraction = if (isRefreshing) 1f else pullRefreshState.distanceFraction
+ val thresholdPassed = displayFraction >= 1f
+ val statusBarPadding = contentPadding.calculateTopPadding()
+
+ val cardExpansion by animateDpAsState(
+ targetValue = 120.dp * displayFraction.coerceIn(0f, 1f),
+ animationSpec = spring(stiffness = Spring.StiffnessMediumLow),
+ label = "cardExpansion",
+ )
+
+ val containerColor by animateColorAsState(
+ targetValue = if (thresholdPassed) MaterialTheme.colorScheme.primary else MaterialTheme.colorScheme.surfaceContainerLow,
+ animationSpec = tween(durationMillis = 300),
+ label = "containerColor",
+ )
+
+ val contentColor by animateColorAsState(
+ targetValue = if (thresholdPassed) MaterialTheme.colorScheme.onPrimary else MaterialTheme.colorScheme.primary,
+ animationSpec = tween(durationMillis = 300),
+ label = "contentColor",
+ )
+
+ val borderColor by animateColorAsState(
+ targetValue = if (thresholdPassed) Color.Transparent else MaterialTheme.colorScheme.outlineVariant,
+ animationSpec = tween(durationMillis = 300),
+ label = "borderColor",
+ )
+
+ val chevronAlpha by animateFloatAsState(
+ targetValue = if (thresholdPassed) 0f else 1f,
+ animationSpec = tween(durationMillis = 300),
+ label = "chevronAlpha",
+ )
+
+ val chevronWidth by animateDpAsState(
+ targetValue = if (thresholdPassed) 0.dp else 24.dp + 8.dp,
+ animationSpec = tween(durationMillis = 300),
+ label = "chevronWidth",
+ )
+
+ val fontWeight by animateIntAsState(
+ targetValue = if (thresholdPassed) 700 else 500,
+ animationSpec = tween(durationMillis = 100),
+ label = "fontWeight",
+ )
+
+ val textScale by animateFloatAsState(
+ targetValue = if (thresholdPassed) 1.5f else 1f,
+ animationSpec = tween(durationMillis = 300),
+ label = "textScale",
+ )
+
+ val fontWidth = remember(displayFraction) {
+ (100f + (displayFraction.coerceIn(0f, 1f) * 50f))
+ }
+
+ val fontFamily = remember(fontWidth, fontWeight) {
+ try {
+ FontFamily(
+ Font(
+ R.font.google_sans_flex,
+ variationSettings = FontVariation.Settings(
+ FontVariation.width(fontWidth),
+ FontVariation.weight(fontWeight),
+ FontVariation.Setting("ROND", 100f),
+ ),
+ )
+ )
+ } catch (_: Exception) {
+ FontFamily.Default
+ }
+ }
+
+ var searchQuery by remember { mutableStateOf("") }
+
+ LazyColumn(
+ modifier = Modifier.fillMaxSize(),
+ contentPadding = PaddingValues(bottom = contentPadding.calculateBottomPadding() + 64.dp),
+ ) {
+ item {
+ OutlinedCard(
+ onClick = {
+ WobbleHaptics.performUIHaptic(view)
+ onOpenDeviceInfo()
+ },
+ modifier = Modifier
+ .fillMaxWidth()
+ .padding(horizontal = 16.dp)
+ .height(64.dp + statusBarPadding + cardExpansion),
+ shape = RoundedCornerShape(
+ topStart = 0.dp,
+ topEnd = 0.dp,
+ bottomStart = 28.dp,
+ bottomEnd = 28.dp,
+ ),
+ colors = CardDefaults.outlinedCardColors(
+ containerColor = containerColor,
+ contentColor = if (thresholdPassed) MaterialTheme.colorScheme.onPrimary else MaterialTheme.colorScheme.onSurface,
+ ),
+ border = BorderStroke(1.dp, borderColor),
+ ) {
+ Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
+ Column(
+ horizontalAlignment = Alignment.CenterHorizontally,
+ verticalArrangement = Arrangement.Center,
+ ) {
+ Spacer(modifier = Modifier.height(statusBarPadding))
+ Row(verticalAlignment = Alignment.CenterVertically) {
+ Box(
+ modifier = Modifier
+ .width(chevronWidth)
+ .graphicsLayer { alpha = chevronAlpha },
+ ) {
+ Row(verticalAlignment = Alignment.CenterVertically) {
+ Icon(
+ imageVector = Icons.Rounded.KeyboardArrowDown,
+ contentDescription = null,
+ modifier = Modifier
+ .size(24.dp)
+ .graphicsLayer {
+ rotationZ = (displayFraction * 180f).coerceIn(0f, 180f)
+ },
+ tint = contentColor,
+ )
+ Spacer(modifier = Modifier.width(8.dp))
+ }
+ }
+ Text(
+ text = deviceInfo.deviceName,
+ style = MaterialTheme.typography.titleMedium.copy(
+ fontFamily = fontFamily,
+ ),
+ modifier = Modifier
+ .onGloballyPositioned { coords ->
+ val pos = coords.positionInRoot()
+ val size = coords.size
+ textCenterOffset = Offset(
+ x = pos.x + (size.width / 2f),
+ y = pos.y + (size.height / 2f),
+ )
+ }
+ .graphicsLayer {
+ scaleX = textScale
+ scaleY = textScale
+ },
+ color = if (thresholdPassed) MaterialTheme.colorScheme.onPrimary else MaterialTheme.colorScheme.onSurface,
+ )
+ }
+ }
+ }
+ }
+ }
+
+ item {
+ OutlinedTextField(
+ value = searchQuery,
+ onValueChange = { searchQuery = it },
+ placeholder = { Text("Search settings & features...") },
+ maxLines = 1,
+ textStyle = MaterialTheme.typography.bodyLarge,
+ modifier = Modifier
+ .fillMaxWidth()
+ .padding(horizontal = 16.dp, vertical = 16.dp)
+ .defaultMinSize(minHeight = 56.dp),
+ leadingIcon = {
+ Icon(
+ imageVector = Icons.Rounded.Search,
+ contentDescription = "Search",
+ modifier = Modifier.padding(start = 12.dp),
+ )
+ },
+ shape = RoundedCornerShape(28.dp),
+ colors = OutlinedTextFieldDefaults.colors(
+ focusedBorderColor = MaterialTheme.colorScheme.primary,
+ unfocusedBorderColor = MaterialTheme.colorScheme.outlineVariant,
+ focusedContainerColor = MaterialTheme.colorScheme.surfaceContainerLow,
+ unfocusedContainerColor = MaterialTheme.colorScheme.surfaceContainerLow,
+ ),
+ )
+ }
+
+ val categories = listOf(
+ "Display & Ambient",
+ "Sound & Vibration",
+ "Notifications & Lighting",
+ "Battery & Power",
+ "System & Security",
+ )
+
+ items(categories.size) { index ->
+ val category = categories[index]
+ Column(
+ modifier = Modifier
+ .fillMaxWidth()
+ .padding(horizontal = 16.dp, vertical = 8.dp),
+ ) {
+ Text(
+ text = category,
+ style = MaterialTheme.typography.titleSmall,
+ color = MaterialTheme.colorScheme.primary,
+ modifier = Modifier.padding(start = 8.dp, bottom = 8.dp),
+ )
+ Surface(
+ shape = RoundedCornerShape(20.dp),
+ color = MaterialTheme.colorScheme.surfaceContainerLow,
+ tonalElevation = 1.dp,
+ modifier = Modifier.fillMaxWidth(),
+ ) {
+ Column {
+ repeat(3) { itemIdx ->
+ Row(
+ modifier = Modifier
+ .fillMaxWidth()
+ .padding(horizontal = 16.dp, vertical = 14.dp),
+ verticalAlignment = Alignment.CenterVertically,
+ horizontalArrangement = Arrangement.SpaceBetween,
+ ) {
+ Column {
+ Text(
+ text = "Sample Setting ${index * 3 + itemIdx + 1}",
+ style = MaterialTheme.typography.bodyLarge,
+ fontWeight = FontWeight.Medium,
+ )
+ Text(
+ text = "Configuration options for $category",
+ style = MaterialTheme.typography.bodySmall,
+ color = MaterialTheme.colorScheme.onSurfaceVariant,
+ )
+ }
+ Icon(
+ imageVector = Icons.Rounded.ChevronRight,
+ contentDescription = null,
+ tint = MaterialTheme.colorScheme.onSurfaceVariant,
+ )
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 80d5cd1..ddbb2e5 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -50,11 +50,11 @@
<!-- Main Screen -->
<string name="header_title">Circle to Search</string>
- <string name="toast_getting_started">Double tap status bar or use floating bubble to start.</string>
+ <string name="toast_getting_started">Set up the permissions, then choose your launch triggers.</string>
<string name="subtitle_main">Search anything on your screen instantly.</string>
<string name="label_required">REQUIRED:</string>
<string name="label_accessibility_active">Accessibility Service Active</string>
- <string name="label_accessibility_active_subtitle">Double tap status bar to launch CircleToSearch</string>
+ <string name="label_accessibility_active_subtitle">Unlocks every trigger: status bar, bubble &amp; hardware buttons</string>
<string name="label_enable_accessibility">Enable Accessibility</string>
<string name="label_enable_accessibility_subtitle">To do its job properly, the app needs this permission.\nTap allow and we\'re good to go! &#x1F44D;</string>
<string name="label_optional_assistant">OPTIONAL: For Home Button Trigger</string>
@@ -359,4 +359,51 @@
<!-- Quick Settings Tile -->
<string name="qs_tile_label">CTS</string>
+
+ <!-- Triggers -->
+ <string name="title_settings">Settings</string>
+ <string name="cd_app_icon">App icon</string>
+ <string name="label_triggers">TRIGGERS</string>
+ <string name="section_triggers">TRIGGERS</string>
+ <string name="section_hardware_buttons">HARDWARE BUTTONS</string>
+ <string name="section_search">SEARCH</string>
+ <string name="section_app">APP</string>
+ <string name="triggers_card_title">Triggers</string>
+ <string name="triggers_card_subtitle_none">No triggers configured yet — tap to choose how to launch</string>
+ <string name="triggers_card_subtitle_list">%1$s</string>
+ <string name="triggers_more">+%1$d more</string>
+
+ <!-- Settings hierarchy -->
+ <string name="settings_cat_triggers_subtitle">Status bar, bubble &amp; hardware buttons</string>
+ <string name="settings_cat_zones">Overlay zones</string>
+ <string name="settings_cat_zones_subtitle">Position, size &amp; gestures</string>
+ <string name="settings_cat_search">Search</string>
+ <string name="settings_cat_search_subtitle">Lens or Multi-Search launch mode</string>
+ <string name="settings_cat_general_subtitle">Offline translator &amp; app options</string>
+ <string name="settings_cat_about">About</string>
+ <string name="settings_cat_about_subtitle">Version, source code &amp; credits</string>
+ <string name="section_launch_methods">LAUNCH METHODS</string>
+ <string name="section_behavior">BEHAVIOR</string>
+ <string name="about_version">Version</string>
+ <string name="about_source_code">Source code</string>
+ <string name="about_source_subtitle">github.com/aks-labs</string>
+ <string name="about_donate_subtitle">Support ongoing development</string>
+ <string name="trigger_name_statusbar">Status bar</string>
+ <string name="trigger_name_bubble">Bubble</string>
+ <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="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>
+ <string name="trigger_double_power_title">Double-tap Power</string>
+ <string name="trigger_power_vol_up_title">Power + Volume Up</string>
+ <string name="trigger_power_vol_down_title">Power + Volume Down</string>
+ <string name="trigger_vol_up_down_title">Volume Up + Volume Down</string>
+ <string name="trigger_hw_subtitle">Starts Circle to Search</string>
+ <string name="trigger_qs_title">Quick Settings tile</string>
+ <string name="trigger_qs_subtitle">Add the CTS tile from the Quick Settings edit screen</string>
+ <string name="trigger_hw_notice">Hardware button triggers need the accessibility service enabled.</string>
+ <string name="label_translator_title">Offline Translator</string>
+ <string name="label_translator_subtitle">Open the translator home screen</string>
</resources>
diff --git a/guide.md b/guide.md
new file mode 100644
index 0000000..5544c5e
--- /dev/null
+++ b/guide.md
@@ -0,0 +1,120 @@
+I have extracted the exact home screen wobble pull-down gesture and Device Info screen animations into a self-contained package called com.sameerasw.essentials.wobblepulldown.
+📂 Package Structure
+All required components are organized in: 📁 app/src/main/java/com/sameerasw/essentials/wobblepulldown/
+File
+Description
+LiquidRippleModifier.kt
+Custom Compose modifier applying the AGSL liquid wave ripple shader (LIQUID_RIPPLE_AGSL) on pull-down.
+ProgressiveBlurModifier.kt
+AGSL progressive edge blur shader (PROGRESSIVE_BLUR_SKSL) for top/bottom translucent overlays.
+WobbleHaptics.kt
+Centralized haptic feedback helper for pull-down steps and overscroll ticks.
+WobbleDeviceInfo.kt
+Hardware & system spec model and utilities (RAM, Storage, Android Version, API level, etc.).
+WobbleDeviceImageMapper.kt
+Maps Android OS versions to Android version logo drawables.
+WobbleHomeScreen.kt
+Home Screen UI Component: Features top expandable hero header card, search bar placeholder, settings categories, and PullToRefreshBox with liquidRipple wobble animation.
+WobbleDeviceInfoScreen.kt
+Device Info Screen UI Component: Features elastic overscroll logo scaling (overscrollOffset), specs cards for RAM & Storage, system specs list, and progressive edge blur.
+WobbleDeviceInfoActivity.kt
+Activity host with top-slide enter/exit activity transition animations.
+README.md
+Package documentation & setup summary.
+📖 Step-by-Step Integration Guide for Other Apps
+Follow these steps to extract and use this exact wobble pull-down animation and Device Info screen in any other Android application:
+Step 1: Copy the wobblepulldown Package
+Copy the entire folder wobblepulldown into your target project's source directory (e.g., com.yourdomain.yourapp.wobblepulldown). Update the package statement at the top of each file to match your target package name.
+Step 2: Ensure Material3 & Compose Dependencies
+Make sure your target app's build.gradle.kts has Jetpack Compose and Material 3 enabled:
+kotlin
+dependencies {
+implementation(platform(libs.androidx.compose.bom))
+implementation(libs.androidx.compose.ui)
+implementation(libs.androidx.compose.material3)
+implementation(libs.androidx.compose.material.icons.extended)
+}
+Step 3: Add the Activity Slide Transition Animations
+Copy the following three XML animation files into res/anim/ in your target app:
+1.
+ res/anim/anim_slide_in_top.xml:
+xml
+<?xml version="1.0" encoding="utf-8"?>
+<set xmlns:android="http://schemas.android.com/apk/res/android"
+android:interpolator="@android:anim/decelerate_interpolator">
+<translate
+android:duration="400"
+android:fromYDelta="-100%"
+android:toYDelta="0" />
+</set>
+2.
+ res/anim/anim_slide_out_top.xml:
+xml
+<?xml version="1.0" encoding="utf-8"?>
+<set xmlns:android="http://schemas.android.com/apk/res/android"
+android:interpolator="@android:anim/accelerate_interpolator">
+<translate
+android:duration="400"
+android:fromYDelta="0"
+android:toYDelta="-100%" />
+</set>
+3.
+ res/anim/anim_stay.xml:
+xml
+<?xml version="1.0" encoding="utf-8"?>
+<set xmlns:android="http://schemas.android.com/apk/res/android">
+ <translate
+ android:duration="400"
+ android:fromYDelta="0"
+ android:toYDelta="0" />
+</set>
+Step 4: Register WobbleDeviceInfoActivity in  AndroidManifest.xml
+Add the activity declaration to your  AndroidManifest.xml:
+xml
+<activity
+ android:name=".wobblepulldown.WobbleDeviceInfoActivity"
+ android:exported="false"
+ android:label="Device Info"
+ android:theme="@style/Theme.YourApp" />
+Step 5: Render WobbleHomeScreen in Your MainActivity or Composable Flow
+kotlin
+import com.yourdomain.yourapp.wobblepulldown.WobbleHomeScreen
+import com.yourdomain.yourapp.wobblepulldown.WobbleDeviceInfoActivity
+
+@Composable
+fun AppHomeScreen() {
+val context = LocalContext.current
+
+ WobbleHomeScreen(
+ onOpenDeviceInfo = {
+ val intent = Intent(context, WobbleDeviceInfoActivity::class.java)
+ val options = androidx.core.app.ActivityOptionsCompat.makeCustomAnimation(
+ context,
+ R.anim.anim_slide_in_top,
+ R.anim.anim_stay,
+ )
+ context.startActivity(intent, options.toBundle())
+ }
+ )
+}
+🎨 How the Animations Work
+1.
+Pull-Down Wobble Shader:
+◦
+PullToRefreshBox tracks distanceFraction.
+◦
+When the user pulls down completely (distanceFraction >= 1f), WobbleHaptics performs haptic feedback, and Modifier.liquidRipple() executes an AGSL runtime shader wave distortion centered at the device header text.
+2.
+Card & Font Morphing:
+◦
+Top hero card expands in height (64.dp + statusBarPadding + cardExpansion).
+◦
+Title text increases weight and width via variable font settings and scales up seamlessly.
+3.
+Transition to Device Info Screen:
+◦
+Upon gesture release when threshold is met, onOpenDeviceInfo() launches WobbleDeviceInfoActivity with custom top slide-in (anim_slide_in_top) activity options.
+4.
+Elastic Overscroll Scaling:
+◦
+WobbleDeviceInfoScreen uses a NestedScrollConnection that captures overscroll drag when scrolled to top, scaling up the Android logo icon smoothly based on drag distance (overscrollOffset). On gesture release, it springs smoothly back to 0.
\ No newline at end of file