ADFA-1383 - debugger toolbar tooltips#854
Conversation
📝 Walkthrough
WalkthroughThis PR adds tooltip metadata for debugger actions, enables long-press tooltip display in the debug overlay/adapters, and makes TooltipManager more robust for non-Activity contexts and overlay dialogs. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Overlay as DebugOverlay (Adapter/View)
participant TooltipMgr as TooltipManager
participant System as WindowManager/Dialog
User->>Overlay: long-press on drag handle / action view
Overlay->>TooltipMgr: request showTooltip(view, tooltipTag)
TooltipMgr->>TooltipMgr: canShowPopup(context, view) checks lifecycle & attachment
alt context is non-Activity and canDrawOverlays == true
TooltipMgr->>System: create dialog with TYPE_APPLICATION_OVERLAY
else
TooltipMgr->>System: create dialog with default window
end
TooltipMgr->>System: dialog.show()
System->>User: tooltip/dialog visible
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
idetooltips/src/main/java/com/itsaky/androidide/idetooltips/ToolTipManager.kt (1)
393-413: Add permission check before setting TYPE_APPLICATION_OVERLAY on the dialog window.The
SYSTEM_ALERT_WINDOWpermission is declared in the manifest and the app has permission-checking utilities (canDrawOverlays(context)in PermissionsHelper.kt), but the code at line 411 setsTYPE_APPLICATION_OVERLAYwithout validating that the permission is granted. This check is necessary because the permission requires explicit runtime grant on Android 6.0+. Without it, the dialog may fail to display or throw an exception. Add a check like:if (context !is Activity && canDrawOverlays(context)) { dialog.window?.setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY) }
🧹 Nitpick comments (1)
app/src/main/java/com/itsaky/androidide/services/debug/DebuggerActionsOverlayAdapter.kt (1)
44-52: CapturedisEnabledmay become stale if action state changes.The
isEnabledvalue is captured at bind time (line 44), but if the action's enabled state changes after binding (e.g., whenprepareis called elsewhere), the click listener will use the stale value. Consider checkingaction.enableddirectly in the click listener.Also, line 45 uses
action.enableddirectly while line 50 uses the capturedisEnabled- this inconsistency may cause confusion.♻️ Suggested fix
- val isEnabled = action.enabled binding.root.alpha = if (action.enabled) 1f else 0.5f TooltipCompat.setTooltipText(binding.root, action.label) binding.root.apply { setOnClickListener { - if (isEnabled) { + if (action.enabled) { actionsRegister.executeAction(action, data) } }
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
idetooltips/src/main/java/com/itsaky/androidide/idetooltips/ToolTipManager.kt (1)
394-413: Guard debug dialog when there's no Activity and no overlay permission.Line 413 can throw
BadTokenExceptionby callingdialog.show()with a non-Activity context that lacks overlay permission. The condition at line 409 should short-circuit and return early if both conditions fail (non-Activity context ANDcanDrawOverlays(context)is false).The proposed fix is mechanically sound. However, note that the Activity-lookup logic already exists in the
canShowPopupfunction (lines 220–226); consider extracting it to a helper rather than duplicating it.🛠️ Proposed fix
+ tailrec fun Context.findActivity(): Activity? = when (this) { + is Activity -> this + is ContextWrapper -> baseContext?.findActivity() + else -> null + } + + val activity = context.findActivity() val dialog = builder.create() - if (context !is Activity && canDrawOverlays(context)) { - dialog.window?.setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY) - } + if (activity == null) { + if (canDrawOverlays(context)) { + dialog.window?.setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY) + } else { + Log.w(TAG, "Cannot show tooltip debug dialog without overlay permission") + return + } + } dialog.show()
Show tooltips for debugger actions