Skip to content

CircleToSearch with multi search engine support for all android

Kotlin

feature: Ui improvements and clear explaination for settings

AKS Labs027089baee35
diff --git a/SearchMethodSelector.kt.snippet b/SearchMethodSelector.kt.snippet
new file mode 100644
index 0000000..8aa9873
--- /dev/null
+++ b/SearchMethodSelector.kt.snippet
@@ -0,0 +1,55 @@
+@OptIn(ExperimentalMaterial3Api::class)
+@Composable
+fun SearchMethodSelector(
+ isLensOnly: Boolean,
+ onMethodChange: (Boolean) -> Unit
+) {
+ Column {
+ Text(
+ text = "SEARCH METHOD",
+ style = MaterialTheme.typography.labelLarge.copy(
+ fontWeight = FontWeight.Bold,
+ letterSpacing = 1.sp
+ ),
+ color = MaterialTheme.colorScheme.primary,
+ modifier = Modifier.padding(bottom = 12.dp)
+ )
+
+ SingleChoiceSegmentedButtonRow(
+ modifier = Modifier.fillMaxWidth()
+ ) {
+ SegmentedButton(
+ shape = SegmentedButtonDefaults.itemShape(index = 0, count = 2),
+ onClick = { onMethodChange(false) },
+ selected = !isLensOnly,
+ icon = { SegmentedButtonDefaults.Icon(!isLensOnly) },
+ colors = SegmentedButtonDefaults.colors(
+ activeContainerColor = MaterialTheme.colorScheme.primaryContainer,
+ activeContentColor = MaterialTheme.colorScheme.onPrimaryContainer
+ )
+ ) {
+ Row(verticalAlignment = Alignment.CenterVertically) {
+ Icon(Icons.Default.ManageSearch, contentDescription = null, modifier = Modifier.size(18.dp))
+ Spacer(modifier = Modifier.width(8.dp))
+ Text("Multi-Search", style = MaterialTheme.typography.labelLarge)
+ }
+ }
+ SegmentedButton(
+ shape = SegmentedButtonDefaults.itemShape(index = 1, count = 2),
+ onClick = { onMethodChange(true) },
+ selected = isLensOnly,
+ icon = { SegmentedButtonDefaults.Icon(isLensOnly) },
+ colors = SegmentedButtonDefaults.colors(
+ activeContainerColor = MaterialTheme.colorScheme.primaryContainer,
+ activeContentColor = MaterialTheme.colorScheme.onPrimaryContainer
+ )
+ ) {
+ Row(verticalAlignment = Alignment.CenterVertically) {
+ Icon(Icons.Default.AutoFixHigh, contentDescription = null, modifier = Modifier.size(18.dp))
+ Spacer(modifier = Modifier.width(8.dp))
+ Text("Google Lens", style = MaterialTheme.typography.labelLarge)
+ }
+ }
+ }
+ }
+}
diff --git a/app/src/main/java/com/akslabs/circletosearch/MainActivity.kt b/app/src/main/java/com/akslabs/circletosearch/MainActivity.kt
index 482b191..c976ad5 100644
--- a/app/src/main/java/com/akslabs/circletosearch/MainActivity.kt
+++ b/app/src/main/java/com/akslabs/circletosearch/MainActivity.kt
@@ -27,6 +27,7 @@ import android.provider.Settings
import android.widget.Toast
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
+import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.material.icons.Icons
@@ -580,25 +581,71 @@ fun BubbleSwitch(context: android.content.Context) {
)
}
+@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun LensOnlySwitch(context: android.content.Context) {
val uiPreferences = remember { com.akslabs.circletosearch.utils.UIPreferences(context) }
var isLensOnlyEnabled by remember { mutableStateOf(uiPreferences.isUseGoogleLensOnly()) }
- ListItem(
- headlineContent = { Text("Search with Google Lens Only") },
- supportingContent = { Text("Bypass multi-engine and launch Lens directly") },
- trailingContent = {
- Switch(
- checked = isLensOnlyEnabled,
- onCheckedChange = { enabled ->
- isLensOnlyEnabled = enabled
- uiPreferences.setUseGoogleLensOnly(enabled)
- }
- )
- },
- colors = ListItemDefaults.colors(
- containerColor = Color.Transparent
+ Column(
+ modifier = Modifier
+ .fillMaxWidth()
+ .clip(androidx.compose.foundation.shape.RoundedCornerShape(20.dp))
+ .background(MaterialTheme.colorScheme.surfaceVariant.copy(alpha = 0.3f))
+ .padding(16.dp)
+ ) {
+ Text(
+ text = "Search Method",
+ style = MaterialTheme.typography.titleMedium.copy(fontWeight = FontWeight.Bold),
+ color = MaterialTheme.colorScheme.onSurface,
+ modifier = Modifier.padding(bottom = 12.dp)
)
- )
+
+ SingleChoiceSegmentedButtonRow(
+ modifier = Modifier.fillMaxWidth()
+ ) {
+ SegmentedButton(
+ shape = SegmentedButtonDefaults.itemShape(index = 0, count = 2),
+ onClick = {
+ isLensOnlyEnabled = false
+ uiPreferences.setUseGoogleLensOnly(false)
+ },
+ selected = !isLensOnlyEnabled,
+ icon = { SegmentedButtonDefaults.Icon(!isLensOnlyEnabled) }
+ ) {
+ Text("Multi-Search Engines", style = MaterialTheme.typography.labelLarge)
+ }
+ SegmentedButton(
+ shape = SegmentedButtonDefaults.itemShape(index = 1, count = 2),
+ onClick = {
+ isLensOnlyEnabled = true
+ uiPreferences.setUseGoogleLensOnly(true)
+ },
+ selected = isLensOnlyEnabled,
+ icon = { SegmentedButtonDefaults.Icon(isLensOnlyEnabled) }
+ ) {
+ Text("Google Lens", style = MaterialTheme.typography.labelLarge)
+ }
+ }
+
+ Spacer(modifier = Modifier.height(8.dp))
+
+ Row(
+ verticalAlignment = Alignment.CenterVertically,
+ modifier = Modifier.padding(top = 8.dp)
+ ) {
+ Icon(
+ imageVector = Icons.Default.Info,
+ contentDescription = null,
+ tint = MaterialTheme.colorScheme.secondary,
+ modifier = Modifier.size(16.dp)
+ )
+ Spacer(modifier = Modifier.width(8.dp))
+ Text(
+ text = "Lens needs Google App Installed. But Degoogled friends can stick with the versatile Multi-Search Engine mode. πŸš€",
+ style = MaterialTheme.typography.bodySmall,
+ color = MaterialTheme.colorScheme.onSurfaceVariant
+ )
+ }
+ }
}
diff --git a/app/src/main/java/com/akslabs/circletosearch/ui/CircleToSearchScreen.kt b/app/src/main/java/com/akslabs/circletosearch/ui/CircleToSearchScreen.kt
index fc51ef4..08056ed 100644
--- a/app/src/main/java/com/akslabs/circletosearch/ui/CircleToSearchScreen.kt
+++ b/app/src/main/java/com/akslabs/circletosearch/ui/CircleToSearchScreen.kt
@@ -484,11 +484,9 @@ fun CircleToSearchScreen(
webViews.clear()
}
- // Main Loading & Search Logic
LaunchedEffect(selectedBitmap, hostedImageUrl) {
if (selectedBitmap != null) {
isLoading = true
- scope.launch { scaffoldState.bottomSheetState.expand() }
// 1. Google Lens Only Mode Check
if (uiPreferences.isUseGoogleLensOnly()) {
@@ -509,7 +507,10 @@ fun CircleToSearchScreen(
}
}
- // 2. Upload to host if needed (Multi-Search Mode)
+ // 2. Multi-Search Mode (Expanded UI)
+ scope.launch { scaffoldState.bottomSheetState.expand() }
+
+ // 3. Upload to host if needed (Multi-Search Mode)
if (hostedImageUrl == null) {
val url = ImageSearchUploader.uploadToImageHost(selectedBitmap!!)
if (url != null) {
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 32ed05c..3d15c4a 100644
--- a/app/src/main/java/com/akslabs/circletosearch/ui/SettingsScreen.kt
+++ b/app/src/main/java/com/akslabs/circletosearch/ui/SettingsScreen.kt
@@ -116,14 +116,43 @@ fun SettingsScreen(
onCheckedChange = { showFriendlyMessages = it }
)
- SettingsToggleItem(
- title = "Use Google Lens only",
- subtitle = "Always bypass multi-search and use Lens directamente",
- icon = Icons.Default.AutoFixHigh,
- checked = useGoogleLensOnly,
- onCheckedChange = { useGoogleLensOnly = it }
+ Spacer(modifier = Modifier.height(16.dp))
+
+ // Search Method Section
+ SearchMethodSelector(
+ isLensOnly = useGoogleLensOnly,
+ onMethodChange = { useGoogleLensOnly = it }
)
+ Spacer(modifier = Modifier.height(12.dp))
+
+ // Explanatory Note
+ Surface(
+ color = MaterialTheme.colorScheme.secondaryContainer.copy(alpha = 0.3f),
+ shape = RoundedCornerShape(16.dp),
+ modifier = Modifier.fillMaxWidth()
+ ) {
+ Row(
+ modifier = Modifier.padding(12.dp),
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ Icon(
+ imageVector = Icons.Default.Info,
+ contentDescription = null,
+ tint = MaterialTheme.colorScheme.secondary,
+ modifier = Modifier.size(20.dp)
+ )
+ Spacer(modifier = Modifier.width(12.dp))
+ Text(
+ text = "Lens mode needs the Google App to work its magic! πŸͺ„ Degoogled? Multi-Search mode has your back! πŸš€",
+ style = MaterialTheme.typography.labelSmall,
+ color = MaterialTheme.colorScheme.onSecondaryContainer,
+ lineHeight = 16.sp,
+ modifier = Modifier.weight(1f)
+ )
+ }
+ }
+
Spacer(modifier = Modifier.height(24.dp))
// Search Engines Section
@@ -288,3 +317,58 @@ fun EngineOrderItem(
}
}
}
+@OptIn(ExperimentalMaterial3Api::class)
+@Composable
+fun SearchMethodSelector(
+ isLensOnly: Boolean,
+ onMethodChange: (Boolean) -> Unit
+) {
+ Column {
+ Text(
+ text = "SEARCH METHOD",
+ style = MaterialTheme.typography.labelLarge.copy(
+ fontWeight = FontWeight.Bold,
+ letterSpacing = 1.sp
+ ),
+ color = MaterialTheme.colorScheme.primary,
+ modifier = Modifier.padding(bottom = 12.dp)
+ )
+
+ SingleChoiceSegmentedButtonRow(
+ modifier = Modifier.fillMaxWidth()
+ ) {
+ SegmentedButton(
+ shape = SegmentedButtonDefaults.itemShape(index = 0, count = 2),
+ onClick = { onMethodChange(false) },
+ selected = !isLensOnly,
+ icon = { SegmentedButtonDefaults.Icon(!isLensOnly) },
+ colors = SegmentedButtonDefaults.colors(
+ activeContainerColor = MaterialTheme.colorScheme.primaryContainer,
+ activeContentColor = MaterialTheme.colorScheme.onPrimaryContainer
+ )
+ ) {
+ Row(verticalAlignment = Alignment.CenterVertically) {
+ Icon(Icons.Default.ManageSearch, contentDescription = null, modifier = Modifier.size(18.dp))
+ Spacer(modifier = Modifier.width(8.dp))
+ Text("Multi-Search", style = MaterialTheme.typography.labelLarge)
+ }
+ }
+ SegmentedButton(
+ shape = SegmentedButtonDefaults.itemShape(index = 1, count = 2),
+ onClick = { onMethodChange(true) },
+ selected = isLensOnly,
+ icon = { SegmentedButtonDefaults.Icon(isLensOnly) },
+ colors = SegmentedButtonDefaults.colors(
+ activeContainerColor = MaterialTheme.colorScheme.primaryContainer,
+ activeContentColor = MaterialTheme.colorScheme.onPrimaryContainer
+ )
+ ) {
+ Row(verticalAlignment = Alignment.CenterVertically) {
+ Icon(Icons.Default.AutoFixHigh, contentDescription = null, modifier = Modifier.size(18.dp))
+ Spacer(modifier = Modifier.width(8.dp))
+ Text("Google Lens", style = MaterialTheme.typography.labelLarge)
+ }
+ }
+ }
+ }
+}