-
-
Notifications
You must be signed in to change notification settings - Fork 592
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1439 from Neamar/double-tap-to-lock
Double tap to lock screen
- Loading branch information
Showing
6 changed files
with
115 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
app/src/main/java/fr/neamar/kiss/utils/LockAccessibilityService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package fr.neamar.kiss.utils; | ||
|
||
import android.accessibilityservice.AccessibilityService; | ||
import android.app.Service; | ||
import android.content.Intent; | ||
import android.os.Build; | ||
import android.view.accessibility.AccessibilityEvent; | ||
|
||
public class LockAccessibilityService extends AccessibilityService { | ||
public static String ACTION_LOCK = "fr.neamar.kiss.LOCK"; | ||
|
||
@Override | ||
public void onAccessibilityEvent(AccessibilityEvent event) { | ||
|
||
} | ||
|
||
@Override | ||
public void onInterrupt() { | ||
|
||
} | ||
|
||
@Override | ||
public int onStartCommand(Intent intent, int flags, int startId) { | ||
if (ACTION_LOCK.equals(intent.getAction())) { | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { | ||
performGlobalAction(AccessibilityService.GLOBAL_ACTION_LOCK_SCREEN); | ||
} | ||
} | ||
return Service.START_STICKY; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:accessibilityFeedbackType="feedbackGeneric" | ||
android:description="@string/lock_service_description" | ||
android:settingsActivity="fr.neamar.kiss.SettingsActivity" /> |