Skip to content

Commit

Permalink
Merge pull request #20 from jooooscha/fix_lock
Browse files Browse the repository at this point in the history
fix: fix double tap2lock
  • Loading branch information
jooooscha committed May 7, 2022
2 parents acb119d + 5e55b3f commit 4f82227
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
18 changes: 12 additions & 6 deletions app/src/main/java/app/olaunchercf/ui/HomeFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import android.os.Build
import android.os.Bundle
import android.os.Vibrator
import android.provider.Settings
import android.util.Log
import android.view.*
import android.widget.TextView
import androidx.core.os.bundleOf
Expand Down Expand Up @@ -410,19 +411,24 @@ class HomeFragment : Fragment(), View.OnClickListener, View.OnLongClickListener

override fun onDoubleClick() {
super.onDoubleClick()
if (prefs.lockModeOn)
if (prefs.lockModeOn) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
requireActivity().runOnUiThread {
if (isAccessServiceEnabled(requireContext()))
if (isAccessServiceEnabled(requireContext())) {
lock.performClick()
else {
prefs.lockModeOn = false
showToastLong(requireContext(), "Please turn on accessibility service for Olauncher")
} else {
// prefs.lockModeOn = false
showToastLong(
requireContext(),
"Please turn on accessibility service for Olauncher"
)
startActivity(Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS))
}
}
} else
} else {
lockPhone()
}
}
}

override fun onTripleClick() {
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/xml/accessibility_service_config.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
android:accessibilityEventTypes="typeViewClicked"
android:accessibilityFeedbackType="feedbackVisual"
android:accessibilityFeedbackType="feedbackGeneric"
android:accessibilityFlags="flagDefault"
android:canRetrieveWindowContent="true"
android:description="@string/accessibility_service_description"
android:notificationTimeout="10"
android:packageNames="app.olauncher.debug, app.olauncher"
android:packageNames="app.olaunchercf.debug, app.olaunchercf"
android:settingsActivity="com.example.android.accessibility.ServiceSettingsActivity" />

0 comments on commit 4f82227

Please sign in to comment.