Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add double tap to lock the phone #82

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

rondao
Copy link

@rondao rondao commented Dec 15, 2024

What is it?

  • Feature

Description of the changes in your PR

  • When double tapping at an empty space on the Home Screen, it locks the phone.
  • A new option was added at the Settings menu to enable this feature.
  • This feature requires Device Admin Permission to allow locking the phone.
  • Three new strings were added for this feature.
    • double_tap_to_lock : Text for the settings option.
    • lock_device_admin_hint : Text displayed by Android when agreeing with the Device Admin Permissions.
    • lock_device_admin_warning : Text displayed by Android when disabling Device Admin Permissions for the App at Android Settings.

I see the strings translation for this project are done by Weblate, but I don't know how it's done.
I only added the default strings at strings.xml, if I need to make additional changes, let me know.

Before/After Screenshots/Screen Record

Below screenshots are only related to the new option added at Settings to enable the Double Tap to Lock feature.
The actual feature doesn't change/add any new UI elements.

  • Before:
before - After: after

Fixes the following issue(s)

Acknowledgement

Locking the phone requires admin permission.

Signed-off-by: Rafael Rondão <[email protected]>
app/src/main/res/values/strings.xml Outdated Show resolved Hide resolved
app/src/main/res/values/strings.xml Outdated Show resolved Hide resolved
app/src/main/res/values/strings.xml Outdated Show resolved Hide resolved
app/src/main/res/layout/activity_settings.xml Outdated Show resolved Hide resolved
rondao and others added 2 commits December 16, 2024 10:25
Include "the screen" for better explanation of the feature.

Co-authored-by: Agnieszka C <[email protected]>
@rondao
Copy link
Author

rondao commented Dec 16, 2024

I applied the review suggestions, thanks.

Also, I just realized the unintended side-effect that you can't uninstall the App when the Admin Permission is active, the uninstallation simply fails.
This may be aggravating for the end user when trying to uninstall it, as there is no semantic relationship between enabling Double tap to lock screen with blocking app uninstallation.

To improve this situation, we could check if we are uninstalling ourselves and deactivate the Admin Permission before uninstalling.
The uninstallation process would be transparent this way.

fun Activity.uninstallApp(packageName: String) {
Intent(Intent.ACTION_DELETE).apply {
data = Uri.fromParts("package", packageName, null)
startActivityForResult(this, UNINSTALL_APP_REQUEST_CODE)
}
}

However, if #51 is implemented, then it removes the possibility of uninstalling ourselves, rendering this solution useless.

It is also useless if you're uninstalling from a different Launcher App.
To mitigate this, we could improve lock_device_admin_hint string to mention that Admin Permission must be deactivated before uninstalling.
Although this would probably be the other Launcher App fault for not properly explaining why the uninstallation failed.

Even though this is normal Android behavior, it can really feel to the end user as an App problem, as the only App to fail to be uninstalled would be this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add double tap to sleep phone
2 participants