Skip to content

CircleToSearch with multi search engine support for all android

Kotlin

removed overlay over share button

AKS Labs8ceb091bb1a2
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 41f444e..8441c04 100644
--- a/app/src/main/java/com/akslabs/circletosearch/ui/CircleToSearchScreen.kt
+++ b/app/src/main/java/com/akslabs/circletosearch/ui/CircleToSearchScreen.kt
@@ -1034,84 +1034,6 @@ fun CircleToSearchScreen(
}
}
- // 4. Selection Actions (Share)
- if (selectionRect != null && selectionAnim.value == 1f) {
- val rect = selectionRect!!
- val density = androidx.compose.ui.platform.LocalDensity.current
-
- // Coordinates in pixels from rect
- val leftPx = rect.left.toFloat()
- val topPx = rect.top.toFloat()
- val rightPx = rect.right.toFloat()
- val bottomPx = rect.bottom.toFloat()
-
- // Convert to Dp for offset
- val leftDp = with(density) { leftPx.toDp() }
- val topDp = with(density) { topPx.toDp() }
- val rightDp = with(density) { rightPx.toDp() }
- val bottomDp = with(density) { bottomPx.toDp() }
- val widthDp = rightDp - leftDp
-
- // SHARE BUTTON: Positioned in a separate Box for perfect centering
- Box(
- modifier = Modifier
- .fillMaxSize()
- .zIndex(1000f) // Keep it well above all overlays
- ) {
- Box(
- modifier = Modifier
- .offset(
- x = leftDp,
- y = if (topPx > 200f) topDp - 64.dp else bottomDp + 16.dp
- )
- .width(widthDp),
- contentAlignment = Alignment.Center
- ) {
- androidx.compose.material3.FilledTonalButton(
- onClick = {
- if (selectedBitmap != null) {
- scope.launch {
- try {
- val fileName = "selection_${java.util.UUID.randomUUID()}.png"
- val path = ImageUtils.saveBitmap(context, selectedBitmap!!, fileName)
- val file = java.io.File(path)
- val uri = androidx.core.content.FileProvider.getUriForFile(context, "com.akslabs.circletosearch.fileprovider", file)
- val shareIntent = android.content.Intent(android.content.Intent.ACTION_SEND).apply {
- type = "image/png"
- putExtra(android.content.Intent.EXTRA_STREAM, uri)
- clipData = android.content.ClipData.newRawUri("Selection", uri)
- addFlags(android.content.Intent.FLAG_GRANT_READ_URI_PERMISSION)
- addFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK)
- }
- context.startActivity(android.content.Intent.createChooser(shareIntent, "Share Selection").apply {
- addFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK)
- })
-
- } catch (e: Exception) {
- android.util.Log.e("CircleToSearch", "Failed to share selection", e)
- }
- }
- }
- },
- modifier = Modifier.height(48.dp),
- shape = CircleShape,
- colors = androidx.compose.material3.ButtonDefaults.filledTonalButtonColors(
- containerColor = MaterialTheme.colorScheme.surfaceContainerHigh,
- contentColor = MaterialTheme.colorScheme.onSurface
- ),
- elevation = androidx.compose.material3.ButtonDefaults.buttonElevation(defaultElevation = 6.dp),
- contentPadding = androidx.compose.foundation.layout.PaddingValues(horizontal = 20.dp)
- ) {
- Text(
- "Share",
- style = MaterialTheme.typography.labelLarge.copy(
- fontWeight = androidx.compose.ui.text.font.FontWeight.Normal
- )
- )
- }
- }
- }
- }
}
// 4. Header (Top)
@@ -1447,7 +1369,14 @@ fun CircleToSearchScreen(
@Composable
fun BottomBarButton(label: String, icon: @Composable () -> Unit, onClick: () -> Unit) {
Column(horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.spacedBy(4.dp)) {
- FilledTonalIconButton(onClick = { haptic.performHapticFeedback(androidx.compose.ui.hapticfeedback.HapticFeedbackType.LongPress); onClick() }, modifier = Modifier.size(52.dp)) { icon() }
+ FilledTonalIconButton(
+ onClick = { haptic.performHapticFeedback(androidx.compose.ui.hapticfeedback.HapticFeedbackType.LongPress); onClick() },
+ modifier = Modifier.size(52.dp),
+ colors = IconButtonDefaults.filledTonalIconButtonColors(
+ containerColor = MaterialTheme.colorScheme.surfaceContainer,
+ contentColor = MaterialTheme.colorScheme.onSurface
+ )
+ ) { icon() }
Text(text = label, style = MaterialTheme.typography.labelSmall, color = MaterialTheme.colorScheme.onSurfaceVariant, textAlign = TextAlign.Center, maxLines = 1, softWrap = false)
}
}
@@ -1522,6 +1451,88 @@ fun CircleToSearchScreen(
.zIndex(150f)
)
}
+
+ // 4. Selection Actions (Share) — Positioned at the very end for absolute top-layer rendering
+ if (selectionRect != null && selectionAnim.value == 1f && !isCopyMode) {
+ val rect = selectionRect!!
+ val density = androidx.compose.ui.platform.LocalDensity.current
+ val leftPx = rect.left.toFloat()
+ val topPx = rect.top.toFloat()
+ val rightPx = rect.right.toFloat()
+ val bottomPx = rect.bottom.toFloat()
+
+ val leftDp = with(density) { leftPx.toDp() }
+ val topDp = with(density) { topPx.toDp() }
+ val rightDp = with(density) { rightPx.toDp() }
+ val bottomDp = with(density) { bottomPx.toDp() }
+ val widthDp = rightDp - leftDp
+
+ Box(
+ modifier = Modifier
+ .fillMaxSize()
+ .zIndex(2000f) // Highest Z-index
+ ) {
+ Box(
+ modifier = Modifier
+ .offset(
+ x = leftDp,
+ y = if (topPx > 200f) topDp - 64.dp else bottomDp + 16.dp
+ )
+ .width(widthDp),
+ contentAlignment = Alignment.Center
+ ) {
+ // Wrapped in Surface to match Bottom Bar tonal environment
+ androidx.compose.material3.Surface(
+ color = MaterialTheme.colorScheme.surfaceContainerHigh,
+ shape = CircleShape,
+ tonalElevation = 4.dp,
+ shadowElevation = 8.dp
+ ) {
+ androidx.compose.material3.FilledTonalButton(
+ onClick = {
+ if (selectedBitmap != null) {
+ scope.launch {
+ try {
+ val fileName = "selection_${java.util.UUID.randomUUID()}.png"
+ val path = ImageUtils.saveBitmap(context, selectedBitmap!!, fileName)
+ val file = java.io.File(path)
+ val uri = androidx.core.content.FileProvider.getUriForFile(context, "com.akslabs.circletosearch.fileprovider", file)
+ val shareIntent = android.content.Intent(android.content.Intent.ACTION_SEND).apply {
+ type = "image/png"
+ putExtra(android.content.Intent.EXTRA_STREAM, uri)
+ clipData = android.content.ClipData.newRawUri("Selection", uri)
+ addFlags(android.content.Intent.FLAG_GRANT_READ_URI_PERMISSION)
+ addFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK)
+ }
+ context.startActivity(android.content.Intent.createChooser(shareIntent, "Share Selection").apply {
+ addFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK)
+ })
+ } catch (e: Exception) {
+ android.util.Log.e("CircleToSearch", "Failed to share selection", e)
+ }
+ }
+ }
+ },
+ modifier = Modifier.height(48.dp),
+ shape = CircleShape,
+ colors = androidx.compose.material3.ButtonDefaults.filledTonalButtonColors(
+ containerColor = MaterialTheme.colorScheme.surfaceContainer,
+ contentColor = MaterialTheme.colorScheme.onSurface
+ ),
+ elevation = null, // Surface handles shadow/tonal
+ contentPadding = androidx.compose.foundation.layout.PaddingValues(horizontal = 24.dp)
+ ) {
+ Text(
+ "Share",
+ style = MaterialTheme.typography.labelLarge.copy(
+ fontWeight = androidx.compose.ui.text.font.FontWeight.Normal
+ )
+ )
+ }
+ }
+ }
+ }
+ }
if (showSupportSheet) {
com.akslabs.circletosearch.SupportSheet(
diff --git a/app/src/main/java/com/akslabs/circletosearch/ui/components/CopyTextOverlayManager.kt b/app/src/main/java/com/akslabs/circletosearch/ui/components/CopyTextOverlayManager.kt
index b588790..b830512 100644
--- a/app/src/main/java/com/akslabs/circletosearch/ui/components/CopyTextOverlayManager.kt
+++ b/app/src/main/java/com/akslabs/circletosearch/ui/components/CopyTextOverlayManager.kt
@@ -26,6 +26,7 @@ import androidx.compose.material.icons.filled.Close
import androidx.compose.material.icons.filled.MoreVert
import androidx.compose.foundation.background
import androidx.compose.foundation.shape.CircleShape
+import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.ui.Alignment
import com.akslabs.circletosearch.data.BitmapRepository
import com.akslabs.circletosearch.ocr.TesseractEngine
@@ -77,6 +78,28 @@ class CopyTextOverlayManager(
MaterialTheme {
Box(modifier = Modifier.fillMaxSize()) {
TopBarUI(onClose = { dismiss() })
+
+ if (isScanning.value) {
+ Column(
+ modifier = Modifier.align(Alignment.Center),
+ horizontalAlignment = Alignment.CenterHorizontally
+ ) {
+ CircularProgressIndicator(
+ modifier = Modifier.size(48.dp),
+ color = ComposeColor.White,
+ strokeWidth = 4.dp
+ )
+ Spacer(Modifier.height(16.dp))
+ Text(
+ "Scanning text...",
+ style = MaterialTheme.typography.titleMedium,
+ color = ComposeColor.White,
+ modifier = Modifier
+ .background(ComposeColor.Black.copy(alpha = 0.4f), RoundedCornerShape(8.dp))
+ .padding(horizontal = 12.dp, vertical = 6.dp)
+ )
+ }
+ }
}
}
}
@@ -106,21 +129,6 @@ class CopyTextOverlayManager(
Icon(Icons.Default.Close, contentDescription = "Exit Copy Mode", tint = ComposeColor.White)
}
- if (isScanning.value) {
- Spacer(Modifier.width(16.dp))
- CircularProgressIndicator(
- modifier = Modifier.size(24.dp),
- color = ComposeColor.White,
- strokeWidth = 2.dp
- )
- Spacer(Modifier.width(8.dp))
- Text(
- "Scanning text...",
- style = MaterialTheme.typography.labelMedium,
- color = ComposeColor.White
- )
- }
-
Spacer(modifier = Modifier.weight(1f))
Box {
diff --git a/build_errors_30.txt b/build_errors_30.txt
new file mode 100644
index 0000000..cc2bef2
Binary files /dev/null and b/build_errors_30.txt differ
diff --git a/build_errors_31.txt b/build_errors_31.txt
new file mode 100644
index 0000000..5f4b6b4
Binary files /dev/null and b/build_errors_31.txt differ
diff --git a/builderors.md b/builderors.md
index 36f5b32..e69de29 100644
--- a/builderors.md
+++ b/builderors.md
@@ -1,18 +0,0 @@
-e: file:///C:/Users/ashin/AndroidStudioProjects/CircleToSearch/app/src/main/java/com/akslabs/circletosearch/ui/components/CopyTextOverlayManager.kt:247:42 Unresolved reference 'ToolbarButton'.
-Fix with AI
-
-e: file:///C:/Users/ashin/AndroidStudioProjects/CircleToSearch/app/src/main/java/com/akslabs/circletosearch/ui/components/CopyTextOverlayManager.kt:247:59 Cannot infer type for this parameter. Please specify it explicitly.
-Fix with AI
-
-e: file:///C:/Users/ashin/AndroidStudioProjects/CircleToSearch/app/src/main/java/com/akslabs/circletosearch/ui/components/CopyTextOverlayManager.kt:361:44 Unresolved reference 'ToolbarButton'.
-Fix with AI
-
-e: file:///C:/Users/ashin/AndroidStudioProjects/CircleToSearch/app/src/main/java/com/akslabs/circletosearch/ui/components/CopyTextOverlayManager.kt:373:32 Unresolved reference 'ToolbarButton'.
-Fix with AI
-
-e: file:///C:/Users/ashin/AndroidStudioProjects/CircleToSearch/app/src/main/java/com/akslabs/circletosearch/ui/components/CopyTextOverlayManager.kt:385:38 Unresolved reference 'rect'.
-Fix with AI
-
-e: file:///C:/Users/ashin/AndroidStudioProjects/CircleToSearch/app/src/main/java/com/akslabs/circletosearch/ui/components/CopyTextOverlayManager.kt:386:53 Unresolved reference 'label'.
-Fix with AI
-