Skip to content

Your phone, on your command. Gotcha is world's first fully on-device AI copilot for Android that turns natural language into real device actions — safely.

feat: constrain ScrollView height dynamically and add success/info notification helpers to AssistiveBallOverlay

Rishabh Bajpaid6b876e4118e
diff --git a/app/src/main/java/com/gotcha/service/AssistiveBallService.kt b/app/src/main/java/com/gotcha/service/AssistiveBallService.kt
index 46cecee..c9aa2ce 100644
--- a/app/src/main/java/com/gotcha/service/AssistiveBallService.kt
+++ b/app/src/main/java/com/gotcha/service/AssistiveBallService.kt
@@ -875,7 +875,7 @@ class AssistiveBallService : Service() {
fileName,
bitmap
)
- withContext(Dispatchers.Main) { overlay.showError("Screenshot saved to $location") }
+ withContext(Dispatchers.Main) { overlay.showSuccess("Screenshot saved to $location") }
bitmap.recycle()
} catch (e: Throwable) {
withContext(Dispatchers.Main) {
diff --git a/app/src/main/java/com/gotcha/service/ScreenLensController.kt b/app/src/main/java/com/gotcha/service/ScreenLensController.kt
index 4f0f9ba..86113ef 100644
--- a/app/src/main/java/com/gotcha/service/ScreenLensController.kt
+++ b/app/src/main/java/com/gotcha/service/ScreenLensController.kt
@@ -415,11 +415,20 @@ class ScreenLensController(
setTextIsSelectable(true)
}
- val scroll = android.widget.ScrollView(appContext).apply {
+ val maxLensH = (180 * density).toInt()
+ val scroll = object : android.widget.ScrollView(appContext) {
+ override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
+ val maxHSpec = android.view.View.MeasureSpec.makeMeasureSpec(
+ maxLensH,
+ android.view.View.MeasureSpec.AT_MOST
+ )
+ super.onMeasure(widthMeasureSpec, maxHSpec)
+ }
+ }.apply {
addView(textView)
layoutParams = android.widget.LinearLayout.LayoutParams(
android.widget.LinearLayout.LayoutParams.MATCH_PARENT,
- (180 * density).toInt()
+ android.widget.LinearLayout.LayoutParams.WRAP_CONTENT
)
}
cardLayout.addView(scroll)
diff --git a/app/src/main/java/com/gotcha/ui/AssistiveBallOverlay.kt b/app/src/main/java/com/gotcha/ui/AssistiveBallOverlay.kt
index 27b4a8a..8b79dd0 100644
--- a/app/src/main/java/com/gotcha/ui/AssistiveBallOverlay.kt
+++ b/app/src/main/java/com/gotcha/ui/AssistiveBallOverlay.kt
@@ -328,6 +328,14 @@ class AssistiveBallOverlay(context: Context) {
}
}
+ fun showSuccess(message: String) {
+ showCard("✅ $message", showClose = true)
+ }
+
+ fun showInfo(message: String) {
+ showCard("ℹ️ $message", showClose = true)
+ }
+
fun showError(message: String) {
showCard("⚠️ $message", showClose = true)
}
@@ -342,7 +350,12 @@ class AssistiveBallOverlay(context: Context) {
orientation = LinearLayout.VERTICAL
applyOverlayCard(colors, horizontalDp = 20, verticalDp = 16)
}
- val scroll = ScrollView(appContext).apply {
+ val scroll = object : ScrollView(appContext) {
+ override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
+ val maxHSpec = MeasureSpec.makeMeasureSpec(dp(240), MeasureSpec.AT_MOST)
+ super.onMeasure(widthMeasureSpec, maxHSpec)
+ }
+ }.apply {
addView(
TextView(appContext).apply {
text = message
@@ -353,7 +366,7 @@ class AssistiveBallOverlay(context: Context) {
)
layoutParams = LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
- dp(240)
+ LinearLayout.LayoutParams.WRAP_CONTENT
)
}
container.addView(scroll)
@@ -563,10 +576,15 @@ class AssistiveBallOverlay(context: Context) {
// Then show proactive screen-scan entities if any
if (proactiveSessionItems.isNotEmpty()) {
- val scroll = ScrollView(appContext).apply {
+ val scroll = object : ScrollView(appContext) {
+ override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
+ val maxHSpec = MeasureSpec.makeMeasureSpec(dp(240), MeasureSpec.AT_MOST)
+ super.onMeasure(widthMeasureSpec, maxHSpec)
+ }
+ }.apply {
layoutParams = LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
- dp(240)
+ LinearLayout.LayoutParams.WRAP_CONTENT
)
}
val listContent = LinearLayout(appContext).apply {