mirror of
https://github.com/LittleTurtle2333/SimplicityTools.git
synced 2026-07-12 19:31:17 +08:00
Compare commits
5 Commits
788e46cb39
...
92b345af77
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
92b345af77 | ||
|
|
dfd1c660f5 | ||
|
|
d431798808 | ||
|
|
ff95c6d782 | ||
|
|
2f23263333 |
@@ -44,6 +44,7 @@ Xposed仓库下载:[点击此处下载最新发行版](https://github.com/Xpos
|
||||
##### GNU General Public License v3.0
|
||||
[qqlittleice/MiuiHome](https://github.com/qqlittleice/MiuiHome)
|
||||
[yujincheng08/BiliRoaming](https://github.com/yujincheng08/BiliRoaming)
|
||||
[Mikanoshi/CustoMIUIzer](https://code.highspec.ru/Mikanoshi/CustoMIUIzer)
|
||||
##### GNU General Public License v2.0
|
||||
[LSPosed/CorePatch](https://github.com/LSPosed/CorePatch)
|
||||
##### GNU Lesser General Public License v2.1
|
||||
|
||||
@@ -40,11 +40,12 @@ Xposed Repo:[Click here to download the latest release](https://github.com/Xpo
|
||||
## Third party open source references
|
||||
##### GNU General Public License v3.0
|
||||
[qqlittleice/MiuiHome](https://github.com/qqlittleice/MiuiHome)
|
||||
[yujincheng08/BiliRoaming](https://github.com/yujincheng08/BiliRoaming)
|
||||
[yujincheng08/BiliRoaming](https://github.com/yujincheng08/BiliRoaming)
|
||||
[Mikanoshi/CustoMIUIzer](https://code.highspec.ru/Mikanoshi/CustoMIUIzer)
|
||||
##### GNU General Public License v2.0
|
||||
[LSPosed/CorePatch](https://github.com/LSPosed/CorePatch)
|
||||
[LSPosed/CorePatch](https://github.com/LSPosed/CorePatch)
|
||||
##### GNU Lesser General Public License v2.1
|
||||
[577fkj/blockmiui](https://github.com/577fkj/blockmiui)
|
||||
[577fkj/blockmiui](https://github.com/577fkj/blockmiui)
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@ android {
|
||||
applicationId = "com.lt2333.simplicitytools"
|
||||
minSdk = 31
|
||||
targetSdk = 32
|
||||
versionCode = 47
|
||||
versionName = "1.4.6"
|
||||
versionCode = 48
|
||||
versionName = "1.4.7"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
|
||||
@@ -532,7 +532,13 @@ class SettingsActivity : MIUIActivity() {
|
||||
SwitchV("remove_the_maximum_number_of_notification_icons")
|
||||
)
|
||||
)
|
||||
|
||||
add(
|
||||
TextSummaryWithSwitchV(
|
||||
TextSummaryV(
|
||||
textId = R.string.double_tap_to_sleep
|
||||
), SwitchV("status_bar_double_tap_to_sleep")
|
||||
)
|
||||
)
|
||||
add(LineV())
|
||||
add(TitleTextV(resId = R.string.status_bar_layout))
|
||||
add(
|
||||
@@ -803,7 +809,6 @@ class SettingsActivity : MIUIActivity() {
|
||||
|
||||
add(LineV())
|
||||
add(TitleTextV(resId = R.string.lock_screen))
|
||||
|
||||
add(
|
||||
TextSummaryWithSwitchV(
|
||||
TextSummaryV(
|
||||
@@ -839,6 +844,14 @@ class SettingsActivity : MIUIActivity() {
|
||||
SwitchV("lock_screen_charging_current")
|
||||
)
|
||||
)
|
||||
add(
|
||||
TextSummaryWithSwitchV(
|
||||
TextSummaryV(
|
||||
textId = R.string.double_tap_to_sleep,
|
||||
tipsId = R.string.home_double_tap_to_sleep_summary
|
||||
), SwitchV("lock_screen_double_tap_to_sleep")
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -50,6 +50,10 @@ class SystemUI : IXposedHookLoadPackage {
|
||||
WaveCharge().handleLoadPackage(lpparam)
|
||||
//锁屏电流
|
||||
LockScreenCurrent().handleLoadPackage(lpparam)
|
||||
//锁屏下双击锁屏
|
||||
LockScreenDoubleTapToSleep().handleLoadPackage(lpparam)
|
||||
//双击状态栏锁屏
|
||||
StatusBarDoubleTapToSleep().handleLoadPackage(lpparam)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,7 +29,8 @@ class DoubleTapController internal constructor(mContext: Context) {
|
||||
val rawX = motionEvent.rawX
|
||||
val rawY = motionEvent.rawY
|
||||
if (abs(rawX - mActionDownRawX) <= mTouchSlop.toFloat() && abs(rawY - mActionDownRawY) <= mTouchSlop.toFloat()) {
|
||||
if (SystemClock.elapsedRealtime() - mLastClickTime > maxDuration || rawY - mFirstClickRawY > mTouchSlop.toFloat() || rawX - mFirstClickRawX > mTouchSlop.toFloat()) mClickCount = 0
|
||||
if (SystemClock.elapsedRealtime() - mLastClickTime > maxDuration || rawY - mFirstClickRawY > mTouchSlop.toFloat() || rawX - mFirstClickRawX > mTouchSlop.toFloat()) mClickCount =
|
||||
0
|
||||
mClickCount++
|
||||
if (mClickCount == 1) {
|
||||
mFirstClickRawX = rawX
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.KeyguardManager
|
||||
import android.content.Context
|
||||
import android.os.SystemClock
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import android.view.View.OnTouchListener
|
||||
import com.lt2333.simplicitytools.util.findClass
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.hookBeforeMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.XposedHelpers
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class LockScreenDoubleTapToSleep : IXposedHookLoadPackage {
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
hasEnable("lock_screen_double_tap_to_sleep") {
|
||||
"com.android.systemui.statusbar.phone.NotificationsQuickSettingsContainer".findClass(
|
||||
lpparam.classLoader
|
||||
).hookBeforeMethod("onFinishInflate") {
|
||||
val view = it.thisObject as View
|
||||
XposedHelpers.setAdditionalInstanceField(view, "currentTouchTime", 0L)
|
||||
XposedHelpers.setAdditionalInstanceField(view, "currentTouchX", 0f)
|
||||
XposedHelpers.setAdditionalInstanceField(view, "currentTouchY", 0f)
|
||||
view.setOnTouchListener(OnTouchListener { v, event ->
|
||||
if (event.action != MotionEvent.ACTION_DOWN) return@OnTouchListener false
|
||||
var currentTouchTime =
|
||||
XposedHelpers.getAdditionalInstanceField(view, "currentTouchTime") as Long
|
||||
var currentTouchX =
|
||||
XposedHelpers.getAdditionalInstanceField(view, "currentTouchX") as Float
|
||||
var currentTouchY =
|
||||
XposedHelpers.getAdditionalInstanceField(view, "currentTouchY") as Float
|
||||
val lastTouchTime = currentTouchTime
|
||||
val lastTouchX = currentTouchX
|
||||
val lastTouchY = currentTouchY
|
||||
currentTouchTime = System.currentTimeMillis()
|
||||
currentTouchX = event.x
|
||||
currentTouchY = event.y
|
||||
if (currentTouchTime - lastTouchTime < 250L && Math.abs(currentTouchX - lastTouchX) < 100f && Math.abs(
|
||||
currentTouchY - lastTouchY
|
||||
) < 100f
|
||||
) {
|
||||
val keyguardMgr =
|
||||
v.context.getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager
|
||||
if (keyguardMgr.isKeyguardLocked) {
|
||||
XposedHelpers.callMethod(
|
||||
v.context.getSystemService(Context.POWER_SERVICE),
|
||||
"goToSleep",
|
||||
SystemClock.uptimeMillis()
|
||||
)
|
||||
}
|
||||
currentTouchTime = 0L
|
||||
currentTouchX = 0f
|
||||
currentTouchY = 0f
|
||||
}
|
||||
XposedHelpers.setAdditionalInstanceField(
|
||||
view,
|
||||
"currentTouchTime",
|
||||
currentTouchTime
|
||||
)
|
||||
XposedHelpers.setAdditionalInstanceField(view, "currentTouchX", currentTouchX)
|
||||
XposedHelpers.setAdditionalInstanceField(view, "currentTouchY", currentTouchY)
|
||||
false
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.os.SystemClock
|
||||
import android.view.MotionEvent
|
||||
import android.view.View.OnTouchListener
|
||||
import android.view.ViewGroup
|
||||
import com.lt2333.simplicitytools.util.findClass
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.hookBeforeMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.XposedHelpers
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class StatusBarDoubleTapToSleep : IXposedHookLoadPackage {
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
hasEnable("status_bar_double_tap_to_sleep") {
|
||||
"com.android.systemui.statusbar.phone.MiuiPhoneStatusBarView".findClass(
|
||||
lpparam.classLoader
|
||||
).hookBeforeMethod(
|
||||
"onFinishInflate"
|
||||
) {
|
||||
val view = it.thisObject as ViewGroup
|
||||
XposedHelpers.setAdditionalInstanceField(view, "currentTouchTime", 0L)
|
||||
XposedHelpers.setAdditionalInstanceField(view, "currentTouchX", 0f)
|
||||
XposedHelpers.setAdditionalInstanceField(view, "currentTouchY", 0f)
|
||||
view.setOnTouchListener(OnTouchListener { v, event ->
|
||||
if (event.action != MotionEvent.ACTION_DOWN) return@OnTouchListener false
|
||||
var currentTouchTime =
|
||||
XposedHelpers.getAdditionalInstanceField(view, "currentTouchTime") as Long
|
||||
var currentTouchX =
|
||||
XposedHelpers.getAdditionalInstanceField(view, "currentTouchX") as Float
|
||||
var currentTouchY =
|
||||
XposedHelpers.getAdditionalInstanceField(view, "currentTouchY") as Float
|
||||
val lastTouchTime = currentTouchTime
|
||||
val lastTouchX = currentTouchX
|
||||
val lastTouchY = currentTouchY
|
||||
currentTouchTime = System.currentTimeMillis()
|
||||
currentTouchX = event.x
|
||||
currentTouchY = event.y
|
||||
if (currentTouchTime - lastTouchTime < 250L && Math.abs(currentTouchX - lastTouchX) < 100f && Math.abs(
|
||||
currentTouchY - lastTouchY
|
||||
) < 100f
|
||||
) {
|
||||
XposedHelpers.callMethod(
|
||||
v.context.getSystemService(Context.POWER_SERVICE),
|
||||
"goToSleep",
|
||||
SystemClock.uptimeMillis()
|
||||
)
|
||||
currentTouchTime = 0L
|
||||
currentTouchX = 0f
|
||||
currentTouchY = 0f
|
||||
}
|
||||
XposedHelpers.setAdditionalInstanceField(
|
||||
view,
|
||||
"currentTouchTime",
|
||||
currentTouchTime
|
||||
)
|
||||
XposedHelpers.setAdditionalInstanceField(view, "currentTouchX", currentTouchX)
|
||||
XposedHelpers.setAdditionalInstanceField(view, "currentTouchY", currentTouchY)
|
||||
false
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Submodule blockmiui updated: ced7f39efa...8953bd35e2
Reference in New Issue
Block a user