modelorona / modelorona/TapLock
[Feature request]Serve the floating lock button through the accessibility service instead of `SYSTEM_ALERT_WINDOW
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 29
- Forks
- 5
- Avg merge
- 12d 13h
- Merged PRs (30d)
- 2
Description
https://github.com/user-attachments/assets/1c73a4c0-bc27-4e89-a84b-86ae9f3c5098
Summary
TapLock already requires the accessibility service for screen locking, and it can host overlays too via WindowManager.LayoutParams.TYPE_ACCESSIBILITY_OVERLAY. Please migrate the Floating Lock Button from FloatingButtonService (which needs Draw-over-other-apps) to an overlay hosted by TapLockAccessibilityService.
Why
- One less permission — users no longer have to grant
SYSTEM_ALERT_WINDOW(Draw over other apps). One fewer permission screen in first-run setup, one fewer sensitive permission on the Play Store listing. - Consistency with the existing codebase —
TapLockAccessibilityServicealready usesTYPE_ACCESSIBILITY_OVERLAYin three places (status bar overlay, edge overlays, corner overlays). The floating button is currently the only overlay that takes theSYSTEM_ALERT_WINDOWpath via a separate service. - Removes a dead foreground-service notification path —
FloatingButtonServicecallsstartForegroundwith aNotificationCompat.Builder, but the app never requests the Android 13+ runtimePOST_NOTIFICATIONSpermission anywhere (only declares it in the manifest). On Android 13+ that means the notification is silently never shown, even though the service is running. The app also doesn't surface any in-app UI hint that notifications are needed — no banner, no setup step, no toggle-time explainer — so unless the user happens to notice this on their own and manually grantsPOST_NOTIFICATIONSfrom Android's system settings, the notification stays hidden forever. Moving to an accessibility overlay drops the entire FGS + notification code path, which is currently non-functional anyway. - Potentially usable above the lock screen — accessibility overlays can render on top of the keyguard on many devices, which
TYPE_APPLICATION_OVERLAYcannot.
Implementation sketch (from a quick read of the source)
- In
TapLockAccessibilityService, add afloatingLockButton: View?field alongside the existingstatusBarOverlay,leftEdgeOverlay, etc. - Add
addFloatingLockButton()/removeFloatingLockButton()/updateFloatingLockButton(sizeDp, opacityPercent)methods mirroring the existingaddStatusBarOverlay()pattern, but with:LayoutParams(size, size, TYPE_ACCESSIBILITY_OVERLAY, FLAG_NOT_FOCUSABLE, PixelFormat.TRANSLUCENT)gravity = Gravity.TOP or Gravity.START, saved x/y from SharedPreferences- The same
OnTouchListenerdrag / edge-snap logic that lives inFloatingButtonService.addFloatingButton()today - The same custom-icon lookup via
File(filesDir, "custom_widget_icon.png"), which works fine from the accessibility service context
- Have the SharedPreferences change listener in the accessibility service react to
floating_button_enabled,floating_button_size_dp,floating_button_opacity_percentand add / remove / update the view accordingly. - Delete
FloatingButtonService, its<service>entry in the manifest,android.permission.SYSTEM_ALERT_WINDOW, and (since the FGS goes away)android.permission.POST_NOTIFICATIONSunless it is needed elsewhere. RemoveSettings.canDrawOverlays()gates and the overlay-permission request UI inMainActivity. - Replace
restartFloatingButtonServiceIfRunning()with a call into the accessibility service via itsinstancesingleton, e.g.TapLockAccessibilityService.instance?.updateFloatingLockButton(...). This also solves the sibling live-preview feature request — in-placeupdateViewLayout/view.alpha = ...becomes trivial once the view is owned by the accessibility service.
Non-goals / caveats
- If the accessibility service is disabled the floating button won't work, but that is already true for locking itself, so it's not a new failure mode.
- Lock-screen layering can vary by OEM. If universal support isn't reliable, gating "show on lock screen" behind a toggle (default off) would be a safe compromise.
- Drag-through-touch behavior needs re-testing under
TYPE_ACCESSIBILITY_OVERLAY; the existing edge / corner overlays already receive touches from the same service, so this should be a small delta.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with TapLockAccessibilityService, FloatingButtonService, MainActivity, and the manifest entries; compare the existing status, edge, and corner overlay methods with the floating button implementation. Verify preference changes, dragging, saved positioning, custom icons, and permission cleanup, then test the button and lock-screen behavior on supported Android versions and OEMs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, kotlin
- Domain
- accessibility, mobile
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 50/100