mirror of
https://github.com/fankes/TSBattery.git
synced 2025-09-07 11:10:10 +08:00
Compare commits
16 Commits
Author | SHA1 | Date | |
---|---|---|---|
48eb942167 | |||
fe11d0e67b | |||
5fffb0b154 | |||
316db6f887 | |||
17b3d8ac9a | |||
6d58f0330b | |||
1c42bc4def | |||
a3772e3673 | |||
af20fad070 | |||
e510e5d043 | |||
2ebc0bc2dc | |||
3e23c67ad2 | |||
6ff9a08366 | |||
8a90303228 | |||
5b411227d9 | |||
88db36a848 |
1
.idea/gradle.xml
generated
1
.idea/gradle.xml
generated
@@ -14,7 +14,6 @@
|
|||||||
<option value="$PROJECT_DIR$/app" />
|
<option value="$PROJECT_DIR$/app" />
|
||||||
</set>
|
</set>
|
||||||
</option>
|
</option>
|
||||||
<option name="resolveModulePerSourceSet" value="false" />
|
|
||||||
</GradleProjectSettings>
|
</GradleProjectSettings>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
|
@@ -2,7 +2,8 @@
|
|||||||
|
|
||||||

|

|
||||||

|

|
||||||

|

|
||||||
|
[](https://t.me/XiaofangInternet)
|
||||||
<br/><br/>
|
<br/><br/>
|
||||||
<br/>
|
<br/>
|
||||||
A new way to save your battery avoid cancer apps hacker it.<br/>
|
A new way to save your battery avoid cancer apps hacker it.<br/>
|
||||||
@@ -11,7 +12,7 @@ TSBattery 是一个旨在使 QQ、TIM、微信 变得更省电的开源 Xposed
|
|||||||
# 开始使用
|
# 开始使用
|
||||||
|
|
||||||
点击下载最新版本
|
点击下载最新版本
|
||||||
<a href='https://github.com/fankes/TSBattery/releases'></a>
|
<a href='https://github.com/fankes/TSBattery/releases'></a>
|
||||||
<br/><br/>
|
<br/><br/>
|
||||||
⚠️ 适配说明<br/>
|
⚠️ 适配说明<br/>
|
||||||
|
|
||||||
|
@@ -46,8 +46,8 @@ android {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly 'de.robv.android.xposed:api:82'
|
compileOnly 'de.robv.android.xposed:api:82'
|
||||||
implementation 'com.highcapable.yukihookapi:api:1.0.2'
|
implementation 'com.highcapable.yukihookapi:api:1.0.5.2'
|
||||||
ksp 'com.highcapable.yukihookapi:ksp-xposed:1.0.2'
|
ksp 'com.highcapable.yukihookapi:ksp-xposed:1.0.5.2'
|
||||||
implementation 'com.geyifeng.immersionbar:immersionbar:3.2.0'
|
implementation 'com.geyifeng.immersionbar:immersionbar:3.2.0'
|
||||||
implementation 'com.geyifeng.immersionbar:immersionbar-ktx:3.2.0'
|
implementation 'com.geyifeng.immersionbar:immersionbar-ktx:3.2.0'
|
||||||
implementation 'androidx.core:core-ktx:1.7.0'
|
implementation 'androidx.core:core-ktx:1.7.0'
|
||||||
|
@@ -38,15 +38,10 @@ class TSApplication : Application() {
|
|||||||
* @return [TSApplication]
|
* @return [TSApplication]
|
||||||
*/
|
*/
|
||||||
val appContext get() = context ?: error("App is death")
|
val appContext get() = context ?: error("App is death")
|
||||||
|
|
||||||
/** 自身 APP 是否已启动 */
|
|
||||||
var isMineStarted = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
super.onCreate()
|
super.onCreate()
|
||||||
/** 设置状态 */
|
|
||||||
isMineStarted = true
|
|
||||||
/** 设置静态实例 */
|
/** 设置静态实例 */
|
||||||
context = this
|
context = this
|
||||||
/** 跟随系统夜间模式 */
|
/** 跟随系统夜间模式 */
|
||||||
|
@@ -25,6 +25,7 @@ object HookConst {
|
|||||||
|
|
||||||
const val ENABLE_HIDE_ICON = "_hide_icon"
|
const val ENABLE_HIDE_ICON = "_hide_icon"
|
||||||
const val ENABLE_RUN_INFO = "_tip_run_info"
|
const val ENABLE_RUN_INFO = "_tip_run_info"
|
||||||
|
const val ENABLE_NOTIFY_TIP = "_tip_in_notify"
|
||||||
const val ENABLE_QQTIM_WHITE_MODE = "_qqtim_white_mode"
|
const val ENABLE_QQTIM_WHITE_MODE = "_qqtim_white_mode"
|
||||||
const val ENABLE_QQTIM_CORESERVICE_BAN = "_qqtim_core_service_ban"
|
const val ENABLE_QQTIM_CORESERVICE_BAN = "_qqtim_core_service_ban"
|
||||||
const val ENABLE_QQTIM_CORESERVICE_CHILD_BAN = "_qqtim_core_service_child_ban"
|
const val ENABLE_QQTIM_CORESERVICE_CHILD_BAN = "_qqtim_core_service_child_ban"
|
||||||
|
@@ -19,6 +19,8 @@
|
|||||||
*
|
*
|
||||||
* This file is Created by fankes on 2022/2/15.
|
* This file is Created by fankes on 2022/2/15.
|
||||||
*/
|
*/
|
||||||
|
@file:Suppress("IMPLICIT_CAST_TO_ANY")
|
||||||
|
|
||||||
package com.fankes.tsbattery.hook
|
package com.fankes.tsbattery.hook
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
@@ -27,6 +29,7 @@ import android.content.Intent
|
|||||||
import android.os.Build
|
import android.os.Build
|
||||||
import com.fankes.tsbattery.hook.HookConst.DISABLE_WECHAT_HOOK
|
import com.fankes.tsbattery.hook.HookConst.DISABLE_WECHAT_HOOK
|
||||||
import com.fankes.tsbattery.hook.HookConst.ENABLE_MODULE_VERSION
|
import com.fankes.tsbattery.hook.HookConst.ENABLE_MODULE_VERSION
|
||||||
|
import com.fankes.tsbattery.hook.HookConst.ENABLE_NOTIFY_TIP
|
||||||
import com.fankes.tsbattery.hook.HookConst.ENABLE_QQTIM_CORESERVICE_BAN
|
import com.fankes.tsbattery.hook.HookConst.ENABLE_QQTIM_CORESERVICE_BAN
|
||||||
import com.fankes.tsbattery.hook.HookConst.ENABLE_QQTIM_CORESERVICE_CHILD_BAN
|
import com.fankes.tsbattery.hook.HookConst.ENABLE_QQTIM_CORESERVICE_CHILD_BAN
|
||||||
import com.fankes.tsbattery.hook.HookConst.ENABLE_QQTIM_WHITE_MODE
|
import com.fankes.tsbattery.hook.HookConst.ENABLE_QQTIM_WHITE_MODE
|
||||||
@@ -34,12 +37,12 @@ import com.fankes.tsbattery.hook.HookConst.ENABLE_RUN_INFO
|
|||||||
import com.fankes.tsbattery.hook.HookConst.QQ_PACKAGE_NAME
|
import com.fankes.tsbattery.hook.HookConst.QQ_PACKAGE_NAME
|
||||||
import com.fankes.tsbattery.hook.HookConst.TIM_PACKAGE_NAME
|
import com.fankes.tsbattery.hook.HookConst.TIM_PACKAGE_NAME
|
||||||
import com.fankes.tsbattery.hook.HookConst.WECHAT_PACKAGE_NAME
|
import com.fankes.tsbattery.hook.HookConst.WECHAT_PACKAGE_NAME
|
||||||
import com.fankes.tsbattery.utils.showDialog
|
import com.fankes.tsbattery.utils.factory.showDialog
|
||||||
import com.fankes.tsbattery.utils.versionCode
|
import com.fankes.tsbattery.utils.factory.versionCode
|
||||||
import com.fankes.tsbattery.utils.versionName
|
import com.fankes.tsbattery.utils.factory.versionName
|
||||||
import com.highcapable.yukihookapi.YukiHookAPI.configs
|
|
||||||
import com.highcapable.yukihookapi.annotation.xposed.InjectYukiHookWithXposed
|
import com.highcapable.yukihookapi.annotation.xposed.InjectYukiHookWithXposed
|
||||||
import com.highcapable.yukihookapi.hook.bean.VariousClass
|
import com.highcapable.yukihookapi.hook.bean.VariousClass
|
||||||
|
import com.highcapable.yukihookapi.hook.factory.configs
|
||||||
import com.highcapable.yukihookapi.hook.factory.encase
|
import com.highcapable.yukihookapi.hook.factory.encase
|
||||||
import com.highcapable.yukihookapi.hook.factory.field
|
import com.highcapable.yukihookapi.hook.factory.field
|
||||||
import com.highcapable.yukihookapi.hook.log.loggerD
|
import com.highcapable.yukihookapi.hook.log.loggerD
|
||||||
@@ -54,9 +57,23 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
/** BaseChatPie 类名 */
|
/** QQ、TIM 存在的类 */
|
||||||
private val BaseChatPieClass =
|
private const val SplashActivityClass = "$QQ_PACKAGE_NAME.activity.SplashActivity"
|
||||||
VariousClass("$QQ_PACKAGE_NAME.activity.aio.core.BaseChatPie", "$QQ_PACKAGE_NAME.activity.BaseChatPie")
|
|
||||||
|
/** QQ、TIM 存在的类 */
|
||||||
|
private const val CoreServiceClass = "$QQ_PACKAGE_NAME.app.CoreService"
|
||||||
|
|
||||||
|
/** QQ、TIM 存在的类 */
|
||||||
|
private const val CoreService_KernelServiceClass = "$QQ_PACKAGE_NAME.app.CoreService\$KernelService"
|
||||||
|
|
||||||
|
/** 微信存在的类 */
|
||||||
|
private const val LauncherUIClass = "$WECHAT_PACKAGE_NAME.ui.LauncherUI"
|
||||||
|
|
||||||
|
/** 根据多个版本存的不同的类 */
|
||||||
|
private val BaseChatPieClass = VariousClass(
|
||||||
|
"$QQ_PACKAGE_NAME.activity.aio.core.BaseChatPie",
|
||||||
|
"$QQ_PACKAGE_NAME.activity.BaseChatPie"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -105,6 +122,10 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
interceptBaseChatPie(methodName = "bk")
|
interceptBaseChatPie(methodName = "bk")
|
||||||
interceptBaseChatPie(methodName = "bl")
|
interceptBaseChatPie(methodName = "bl")
|
||||||
}
|
}
|
||||||
|
"8.8.83" -> {
|
||||||
|
interceptBaseChatPie(methodName = "bl")
|
||||||
|
interceptBaseChatPie(methodName = "bm")
|
||||||
|
}
|
||||||
else -> loggerD(msg = "$version not supported!")
|
else -> loggerD(msg = "$version not supported!")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -145,7 +166,8 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
param(CharSequenceType)
|
param(CharSequenceType)
|
||||||
}
|
}
|
||||||
beforeHook {
|
beforeHook {
|
||||||
when (args[0] as CharSequence) {
|
if (prefs.getBoolean(ENABLE_NOTIFY_TIP, default = true))
|
||||||
|
when (firstArgs as CharSequence) {
|
||||||
"QQ正在后台运行" ->
|
"QQ正在后台运行" ->
|
||||||
args().set("QQ正在后台运行 - TSBattery 守护中")
|
args().set("QQ正在后台运行 - TSBattery 守护中")
|
||||||
"TIM正在后台运行" ->
|
"TIM正在后台运行" ->
|
||||||
@@ -163,7 +185,7 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
when {
|
when {
|
||||||
!prefs.getBoolean(ENABLE_RUN_INFO) -> {}
|
!prefs.getBoolean(ENABLE_RUN_INFO) -> {}
|
||||||
isQQTIM ->
|
isQQTIM ->
|
||||||
findClass(name = "$QQ_PACKAGE_NAME.activity.SplashActivity").hook {
|
SplashActivityClass.hook {
|
||||||
/**
|
/**
|
||||||
* Hook 启动界面的第一个 [Activity]
|
* Hook 启动界面的第一个 [Activity]
|
||||||
* QQ 和 TIM 都是一样的类
|
* QQ 和 TIM 都是一样的类
|
||||||
@@ -197,7 +219,7 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else ->
|
else ->
|
||||||
findClass(name = "$WECHAT_PACKAGE_NAME.ui.LauncherUI").hook {
|
LauncherUIClass.hook {
|
||||||
/**
|
/**
|
||||||
* Hook 启动界面的第一个 [Activity]
|
* Hook 启动界面的第一个 [Activity]
|
||||||
* 在里面加入提示运行信息的对话框测试模块是否激活
|
* 在里面加入提示运行信息的对话框测试模块是否激活
|
||||||
@@ -236,7 +258,7 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
*/
|
*/
|
||||||
private fun PackageParam.hookCoreService(isQQ: Boolean) {
|
private fun PackageParam.hookCoreService(isQQ: Boolean) {
|
||||||
if (prefs.getBoolean(ENABLE_QQTIM_CORESERVICE_BAN))
|
if (prefs.getBoolean(ENABLE_QQTIM_CORESERVICE_BAN))
|
||||||
findClass(name = "$QQ_PACKAGE_NAME.app.CoreService").hook {
|
CoreServiceClass.hook {
|
||||||
if (isQQ) {
|
if (isQQ) {
|
||||||
injectMember {
|
injectMember {
|
||||||
method { name = "startTempService" }
|
method { name = "startTempService" }
|
||||||
@@ -269,7 +291,7 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (prefs.getBoolean(ENABLE_QQTIM_CORESERVICE_CHILD_BAN))
|
if (prefs.getBoolean(ENABLE_QQTIM_CORESERVICE_CHILD_BAN))
|
||||||
findClass(name = "$QQ_PACKAGE_NAME.app.CoreService\$KernelService").hook {
|
CoreService_KernelServiceClass.hook {
|
||||||
injectMember {
|
injectMember {
|
||||||
method { name = "onCreate" }
|
method { name = "onCreate" }
|
||||||
afterHook {
|
afterHook {
|
||||||
@@ -290,11 +312,13 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onHook() = encase {
|
override fun onInit() = configs {
|
||||||
configs {
|
|
||||||
debugTag = "TSBattery"
|
debugTag = "TSBattery"
|
||||||
isDebug = false
|
isDebug = false
|
||||||
|
isEnableModulePrefsCache = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onHook() = encase {
|
||||||
loadApp(QQ_PACKAGE_NAME) {
|
loadApp(QQ_PACKAGE_NAME) {
|
||||||
hookSystemWakeLock()
|
hookSystemWakeLock()
|
||||||
hookNotification()
|
hookNotification()
|
||||||
@@ -302,7 +326,7 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
hookModuleRunningInfo(isQQTIM = true)
|
hookModuleRunningInfo(isQQTIM = true)
|
||||||
if (prefs.getBoolean(ENABLE_QQTIM_WHITE_MODE)) return@loadApp
|
if (prefs.getBoolean(ENABLE_QQTIM_WHITE_MODE)) return@loadApp
|
||||||
/** 通过在 SplashActivity 里取到应用的版本号 */
|
/** 通过在 SplashActivity 里取到应用的版本号 */
|
||||||
findClass(name = "$QQ_PACKAGE_NAME.activity.SplashActivity").hook {
|
SplashActivityClass.hook {
|
||||||
injectMember {
|
injectMember {
|
||||||
method {
|
method {
|
||||||
name = "doOnCreate"
|
name = "doOnCreate"
|
||||||
@@ -409,7 +433,7 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
method { name = "run" }
|
method { name = "run" }
|
||||||
intercept()
|
intercept()
|
||||||
}.ignoredAllFailure()
|
}.ignoredAllFailure()
|
||||||
}
|
}.ignoredHookClassNotFoundFailure()
|
||||||
/**
|
/**
|
||||||
* 这个是毒瘤核心类
|
* 这个是毒瘤核心类
|
||||||
* WakeLockMonitor
|
* WakeLockMonitor
|
||||||
@@ -474,7 +498,7 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
}
|
}
|
||||||
intercept()
|
intercept()
|
||||||
}
|
}
|
||||||
}
|
}.ignoredHookClassNotFoundFailure()
|
||||||
}
|
}
|
||||||
loadApp(TIM_PACKAGE_NAME) {
|
loadApp(TIM_PACKAGE_NAME) {
|
||||||
hookSystemWakeLock()
|
hookSystemWakeLock()
|
||||||
|
@@ -41,6 +41,7 @@ import com.fankes.tsbattery.R
|
|||||||
import com.fankes.tsbattery.hook.HookConst.DISABLE_WECHAT_HOOK
|
import com.fankes.tsbattery.hook.HookConst.DISABLE_WECHAT_HOOK
|
||||||
import com.fankes.tsbattery.hook.HookConst.ENABLE_HIDE_ICON
|
import com.fankes.tsbattery.hook.HookConst.ENABLE_HIDE_ICON
|
||||||
import com.fankes.tsbattery.hook.HookConst.ENABLE_MODULE_VERSION
|
import com.fankes.tsbattery.hook.HookConst.ENABLE_MODULE_VERSION
|
||||||
|
import com.fankes.tsbattery.hook.HookConst.ENABLE_NOTIFY_TIP
|
||||||
import com.fankes.tsbattery.hook.HookConst.ENABLE_QQTIM_CORESERVICE_BAN
|
import com.fankes.tsbattery.hook.HookConst.ENABLE_QQTIM_CORESERVICE_BAN
|
||||||
import com.fankes.tsbattery.hook.HookConst.ENABLE_QQTIM_CORESERVICE_CHILD_BAN
|
import com.fankes.tsbattery.hook.HookConst.ENABLE_QQTIM_CORESERVICE_CHILD_BAN
|
||||||
import com.fankes.tsbattery.hook.HookConst.ENABLE_QQTIM_WHITE_MODE
|
import com.fankes.tsbattery.hook.HookConst.ENABLE_QQTIM_WHITE_MODE
|
||||||
@@ -48,10 +49,10 @@ import com.fankes.tsbattery.hook.HookConst.ENABLE_RUN_INFO
|
|||||||
import com.fankes.tsbattery.hook.HookConst.QQ_PACKAGE_NAME
|
import com.fankes.tsbattery.hook.HookConst.QQ_PACKAGE_NAME
|
||||||
import com.fankes.tsbattery.hook.HookConst.TIM_PACKAGE_NAME
|
import com.fankes.tsbattery.hook.HookConst.TIM_PACKAGE_NAME
|
||||||
import com.fankes.tsbattery.hook.HookConst.WECHAT_PACKAGE_NAME
|
import com.fankes.tsbattery.hook.HookConst.WECHAT_PACKAGE_NAME
|
||||||
import com.fankes.tsbattery.utils.isInstall
|
import com.fankes.tsbattery.utils.factory.isInstall
|
||||||
import com.fankes.tsbattery.utils.isNotSystemInDarkMode
|
import com.fankes.tsbattery.utils.factory.isNotSystemInDarkMode
|
||||||
import com.fankes.tsbattery.utils.openSelfSetting
|
import com.fankes.tsbattery.utils.factory.openSelfSetting
|
||||||
import com.fankes.tsbattery.utils.showDialog
|
import com.fankes.tsbattery.utils.factory.showDialog
|
||||||
import com.gyf.immersionbar.ktx.immersionBar
|
import com.gyf.immersionbar.ktx.immersionBar
|
||||||
import com.highcapable.yukihookapi.hook.factory.isTaiChiModuleActive
|
import com.highcapable.yukihookapi.hook.factory.isTaiChiModuleActive
|
||||||
import com.highcapable.yukihookapi.hook.factory.modulePrefs
|
import com.highcapable.yukihookapi.hook.factory.modulePrefs
|
||||||
@@ -63,7 +64,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
private const val moduleVersion = BuildConfig.VERSION_NAME
|
private const val moduleVersion = BuildConfig.VERSION_NAME
|
||||||
private const val qqSupportVersion =
|
private const val qqSupportVersion =
|
||||||
"8.2.11(Play)、8.8.17、8.8.23、8.8.35、8.8.38、8.8.50、8.8.55、8.8.68、8.8.80 (8.2.11、8.5.5~8.8.80)"
|
"8.2.11(Play)、8.8.17、8.8.23、8.8.35、8.8.38、8.8.50、8.8.55、8.8.68、8.8.80、8.8.83 (8.2.11、8.5.5~8.8.83)"
|
||||||
private const val timSupportVersion = "2+、3+ (并未完全测试每个版本)"
|
private const val timSupportVersion = "2+、3+ (并未完全测试每个版本)"
|
||||||
private const val wechatSupportVersion = "全版本仅支持基础省电,更多功能依然画饼"
|
private const val wechatSupportVersion = "全版本仅支持基础省电,更多功能依然画饼"
|
||||||
}
|
}
|
||||||
@@ -123,7 +124,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
findViewById<View>(R.id.main_text_tim_noinstall).isGone = TIM_PACKAGE_NAME.isInstall
|
findViewById<View>(R.id.main_text_tim_noinstall).isGone = TIM_PACKAGE_NAME.isInstall
|
||||||
findViewById<View>(R.id.main_text_wechat_noinstall).isGone = WECHAT_PACKAGE_NAME.isInstall
|
findViewById<View>(R.id.main_text_wechat_noinstall).isGone = WECHAT_PACKAGE_NAME.isInstall
|
||||||
/** 设置文本 */
|
/** 设置文本 */
|
||||||
findViewById<TextView>(R.id.main_text_version).text = "当前版本:$moduleVersion"
|
findViewById<TextView>(R.id.main_text_version).text = "模块版本:$moduleVersion"
|
||||||
findViewById<TextView>(R.id.main_text_support_qq).apply {
|
findViewById<TextView>(R.id.main_text_support_qq).apply {
|
||||||
text = qqSupportVersion
|
text = qqSupportVersion
|
||||||
setOnClickListener {
|
setOnClickListener {
|
||||||
@@ -161,6 +162,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
val wechatDisableHookSwitch = findViewById<SwitchCompat>(R.id.disable_wechat_sv_switch)
|
val wechatDisableHookSwitch = findViewById<SwitchCompat>(R.id.disable_wechat_sv_switch)
|
||||||
val hideIconInLauncherSwitch = findViewById<SwitchCompat>(R.id.hide_icon_in_launcher_switch)
|
val hideIconInLauncherSwitch = findViewById<SwitchCompat>(R.id.hide_icon_in_launcher_switch)
|
||||||
val notifyModuleInfoSwitch = findViewById<SwitchCompat>(R.id.notify_module_info_switch)
|
val notifyModuleInfoSwitch = findViewById<SwitchCompat>(R.id.notify_module_info_switch)
|
||||||
|
val notifyNotifyTipSwitch = findViewById<SwitchCompat>(R.id.notify_module_notify_tip_switch)
|
||||||
/** 获取 Sp 存储的信息 */
|
/** 获取 Sp 存储的信息 */
|
||||||
qqTimProtectModeSwitch.isChecked = modulePrefs.getBoolean(ENABLE_QQTIM_WHITE_MODE)
|
qqTimProtectModeSwitch.isChecked = modulePrefs.getBoolean(ENABLE_QQTIM_WHITE_MODE)
|
||||||
qqTimCoreServiceSwitch.isChecked = modulePrefs.getBoolean(ENABLE_QQTIM_CORESERVICE_BAN)
|
qqTimCoreServiceSwitch.isChecked = modulePrefs.getBoolean(ENABLE_QQTIM_CORESERVICE_BAN)
|
||||||
@@ -168,6 +170,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
wechatDisableHookSwitch.isChecked = modulePrefs.getBoolean(DISABLE_WECHAT_HOOK)
|
wechatDisableHookSwitch.isChecked = modulePrefs.getBoolean(DISABLE_WECHAT_HOOK)
|
||||||
hideIconInLauncherSwitch.isChecked = modulePrefs.getBoolean(ENABLE_HIDE_ICON)
|
hideIconInLauncherSwitch.isChecked = modulePrefs.getBoolean(ENABLE_HIDE_ICON)
|
||||||
notifyModuleInfoSwitch.isChecked = modulePrefs.getBoolean(ENABLE_RUN_INFO)
|
notifyModuleInfoSwitch.isChecked = modulePrefs.getBoolean(ENABLE_RUN_INFO)
|
||||||
|
notifyNotifyTipSwitch.isChecked = modulePrefs.getBoolean(ENABLE_NOTIFY_TIP, default = true)
|
||||||
qqTimProtectModeSwitch.setOnCheckedChangeListener { btn, b ->
|
qqTimProtectModeSwitch.setOnCheckedChangeListener { btn, b ->
|
||||||
if (!btn.isPressed) return@setOnCheckedChangeListener
|
if (!btn.isPressed) return@setOnCheckedChangeListener
|
||||||
modulePrefs.putBoolean(ENABLE_QQTIM_WHITE_MODE, b)
|
modulePrefs.putBoolean(ENABLE_QQTIM_WHITE_MODE, b)
|
||||||
@@ -197,6 +200,10 @@ class MainActivity : AppCompatActivity() {
|
|||||||
if (!btn.isPressed) return@setOnCheckedChangeListener
|
if (!btn.isPressed) return@setOnCheckedChangeListener
|
||||||
modulePrefs.putBoolean(ENABLE_RUN_INFO, b)
|
modulePrefs.putBoolean(ENABLE_RUN_INFO, b)
|
||||||
}
|
}
|
||||||
|
notifyNotifyTipSwitch.setOnCheckedChangeListener { btn, b ->
|
||||||
|
if (!btn.isPressed) return@setOnCheckedChangeListener
|
||||||
|
modulePrefs.putBoolean(ENABLE_NOTIFY_TIP, b)
|
||||||
|
}
|
||||||
/** 快捷操作 QQ */
|
/** 快捷操作 QQ */
|
||||||
findViewById<View>(R.id.quick_qq_button).setOnClickListener { openSelfSetting(QQ_PACKAGE_NAME) }
|
findViewById<View>(R.id.quick_qq_button).setOnClickListener { openSelfSetting(QQ_PACKAGE_NAME) }
|
||||||
/** 快捷操作 TIM */
|
/** 快捷操作 TIM */
|
||||||
@@ -217,8 +224,8 @@ class MainActivity : AppCompatActivity() {
|
|||||||
Toast.makeText(this, "你可能没有安装酷安", Toast.LENGTH_SHORT).show()
|
Toast.makeText(this, "你可能没有安装酷安", Toast.LENGTH_SHORT).show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/** 项目地址点击事件 */
|
/** 项目地址按钮点击事件 */
|
||||||
findViewById<View>(R.id.link_with_project_address).setOnClickListener {
|
findViewById<View>(R.id.title_github_icon).setOnClickListener {
|
||||||
runCatching {
|
runCatching {
|
||||||
startActivity(Intent().apply {
|
startActivity(Intent().apply {
|
||||||
action = "android.intent.action.VIEW"
|
action = "android.intent.action.VIEW"
|
||||||
|
@@ -21,7 +21,7 @@
|
|||||||
*/
|
*/
|
||||||
@file:Suppress("unused")
|
@file:Suppress("unused")
|
||||||
|
|
||||||
package com.fankes.tsbattery.utils
|
package com.fankes.tsbattery.utils.factory
|
||||||
|
|
||||||
import android.app.AlertDialog
|
import android.app.AlertDialog
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
@@ -102,7 +102,7 @@ class DialogBuilder(private val context: Context, private val isUseBlackTheme: B
|
|||||||
).apply {
|
).apply {
|
||||||
shape = GradientDrawable.RECTANGLE
|
shape = GradientDrawable.RECTANGLE
|
||||||
gradientType = GradientDrawable.LINEAR_GRADIENT
|
gradientType = GradientDrawable.LINEAR_GRADIENT
|
||||||
cornerRadius = 15.dp(this@DialogBuilder.context)
|
cornerRadius = 15.dpFloat(this@DialogBuilder.context)
|
||||||
})
|
})
|
||||||
}?.show()
|
}?.show()
|
||||||
}
|
}
|
@@ -21,7 +21,7 @@
|
|||||||
*/
|
*/
|
||||||
@file:Suppress("DEPRECATION")
|
@file:Suppress("DEPRECATION")
|
||||||
|
|
||||||
package com.fankes.tsbattery.utils
|
package com.fankes.tsbattery.utils.factory
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
@@ -80,24 +80,24 @@ val Context.versionName get() = packageInfo.versionName ?: ""
|
|||||||
val Context.versionCode get() = packageInfo.versionCode
|
val Context.versionCode get() = packageInfo.versionCode
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dp 转换为 px
|
* dp 转换为 pxInt
|
||||||
|
* @param context 使用的实例
|
||||||
* @return [Int]
|
* @return [Int]
|
||||||
*/
|
*/
|
||||||
val Number.dp get() = (toFloat() * appContext.resources.displayMetrics.density).toInt()
|
fun Number.dp(context: Context) = dpFloat(context).toInt()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dp 转换为 px
|
* dp 转换为 pxFloat
|
||||||
* @param context 使用的实例
|
* @param context 使用的实例
|
||||||
* @return [Float]
|
* @return [Float]
|
||||||
*/
|
*/
|
||||||
fun Number.dp(context: Context) = toFloat() * context.resources.displayMetrics.density
|
fun Number.dpFloat(context: Context) = toFloat() * context.resources.displayMetrics.density
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 跳转 APP 自身设置界面
|
* 跳转 APP 自身设置界面
|
||||||
* @param packageName 包名
|
* @param packageName 包名
|
||||||
*/
|
*/
|
||||||
fun Context.openSelfSetting(packageName: String) {
|
fun Context.openSelfSetting(packageName: String) = runCatching {
|
||||||
try {
|
|
||||||
if (packageName.isInstall)
|
if (packageName.isInstall)
|
||||||
startActivity(Intent().apply {
|
startActivity(Intent().apply {
|
||||||
flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||||
@@ -105,8 +105,7 @@ fun Context.openSelfSetting(packageName: String) {
|
|||||||
data = Uri.fromParts("package", packageName, null)
|
data = Uri.fromParts("package", packageName, null)
|
||||||
})
|
})
|
||||||
else Toast.makeText(this, "你没有安装此应用", Toast.LENGTH_SHORT).show()
|
else Toast.makeText(this, "你没有安装此应用", Toast.LENGTH_SHORT).show()
|
||||||
} catch (_: Exception) {
|
}.onFailure {
|
||||||
Toast.makeText(this, "启动 $packageName 应用信息失败", Toast.LENGTH_SHORT).show()
|
Toast.makeText(this, "启动 $packageName 应用信息失败", Toast.LENGTH_SHORT).show()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
@@ -28,8 +28,8 @@ import android.content.res.ColorStateList
|
|||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import androidx.appcompat.widget.SwitchCompat
|
import androidx.appcompat.widget.SwitchCompat
|
||||||
import com.fankes.tsbattery.utils.dp
|
|
||||||
import com.fankes.tsbattery.utils.drawable.drawabletoolbox.DrawableBuilder
|
import com.fankes.tsbattery.utils.drawable.drawabletoolbox.DrawableBuilder
|
||||||
|
import com.fankes.tsbattery.utils.factory.dp
|
||||||
|
|
||||||
class MaterialSwitch(context: Context, attrs: AttributeSet?) : SwitchCompat(context, attrs) {
|
class MaterialSwitch(context: Context, attrs: AttributeSet?) : SwitchCompat(context, attrs) {
|
||||||
|
|
||||||
@@ -47,16 +47,16 @@ class MaterialSwitch(context: Context, attrs: AttributeSet?) : SwitchCompat(cont
|
|||||||
.rectangle()
|
.rectangle()
|
||||||
.rounded()
|
.rounded()
|
||||||
.solidColor(0xFF656565.toInt())
|
.solidColor(0xFF656565.toInt())
|
||||||
.height(20.dp)
|
.height(20.dp(context))
|
||||||
.cornerRadius(15.dp)
|
.cornerRadius(15.dp(context))
|
||||||
.build()
|
.build()
|
||||||
thumbDrawable = DrawableBuilder()
|
thumbDrawable = DrawableBuilder()
|
||||||
.rectangle()
|
.rectangle()
|
||||||
.rounded()
|
.rounded()
|
||||||
.solidColor(Color.WHITE)
|
.solidColor(Color.WHITE)
|
||||||
.size(20.dp, 20.dp)
|
.size(20.dp(context), 20.dp(context))
|
||||||
.cornerRadius(20.dp)
|
.cornerRadius(20.dp(context))
|
||||||
.strokeWidth(2.dp)
|
.strokeWidth(8.dp(context))
|
||||||
.strokeColor(Color.TRANSPARENT)
|
.strokeColor(Color.TRANSPARENT)
|
||||||
.build()
|
.build()
|
||||||
trackTintList = toColors(
|
trackTintList = toColors(
|
||||||
|
@@ -13,19 +13,31 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:elevation="0dp"
|
android:elevation="0dp"
|
||||||
|
android:gravity="center|start"
|
||||||
android:paddingLeft="15dp"
|
android:paddingLeft="15dp"
|
||||||
android:paddingTop="13dp"
|
android:paddingTop="13dp"
|
||||||
android:paddingRight="15dp"
|
android:paddingRight="15dp"
|
||||||
android:paddingBottom="5dp">
|
android:paddingBottom="5dp">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:text="TSBattery"
|
android:text="TSBattery"
|
||||||
android:textColor="@color/colorTextGray"
|
android:textColor="@color/colorTextGray"
|
||||||
android:textSize="25sp"
|
android:textSize="25sp"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<androidx.constraintlayout.utils.widget.ImageFilterView
|
||||||
|
android:id="@+id/title_github_icon"
|
||||||
|
style="?android:attr/selectableItemBackgroundBorderless"
|
||||||
|
android:layout_width="27dp"
|
||||||
|
android:layout_height="27dp"
|
||||||
|
android:layout_marginEnd="5dp"
|
||||||
|
android:alpha="0.85"
|
||||||
|
android:src="@mipmap/ic_github"
|
||||||
|
android:tint="@color/colorTextGray" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
@@ -73,7 +85,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="10dp"
|
android:layout_marginBottom="10dp"
|
||||||
android:alpha="0.8"
|
android:alpha="0.8"
|
||||||
android:text="当前版本:%1"
|
android:text="模块版本:%1"
|
||||||
android:textColor="@color/white"
|
android:textColor="@color/white"
|
||||||
android:textSize="13sp" />
|
android:textSize="13sp" />
|
||||||
|
|
||||||
@@ -333,7 +345,8 @@
|
|||||||
<com.fankes.tsbattery.view.MaterialSwitch
|
<com.fankes.tsbattery.view.MaterialSwitch
|
||||||
android:id="@+id/shut_core_sv_qqtim_switch"
|
android:id="@+id/shut_core_sv_qqtim_switch"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="35dp"
|
||||||
|
android:layout_marginBottom="5dp"
|
||||||
android:text="关闭 CoreService"
|
android:text="关闭 CoreService"
|
||||||
android:textColor="@color/colorTextGray"
|
android:textColor="@color/colorTextGray"
|
||||||
android:textSize="15sp" />
|
android:textSize="15sp" />
|
||||||
@@ -351,7 +364,8 @@
|
|||||||
<com.fankes.tsbattery.view.MaterialSwitch
|
<com.fankes.tsbattery.view.MaterialSwitch
|
||||||
android:id="@+id/shut_core_sv_kn_qqtim_switch"
|
android:id="@+id/shut_core_sv_kn_qqtim_switch"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="35dp"
|
||||||
|
android:layout_marginBottom="5dp"
|
||||||
android:text="关闭 CoreService$KernelService"
|
android:text="关闭 CoreService$KernelService"
|
||||||
android:textColor="@color/colorTextGray"
|
android:textColor="@color/colorTextGray"
|
||||||
android:textSize="15sp" />
|
android:textSize="15sp" />
|
||||||
@@ -513,9 +527,28 @@
|
|||||||
android:paddingRight="15dp">
|
android:paddingRight="15dp">
|
||||||
|
|
||||||
<com.fankes.tsbattery.view.MaterialSwitch
|
<com.fankes.tsbattery.view.MaterialSwitch
|
||||||
android:id="@+id/notify_module_info_switch"
|
android:id="@+id/notify_module_notify_tip_switch"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:text="通知栏显示守护状态"
|
||||||
|
android:textColor="@color/colorTextGray"
|
||||||
|
android:textSize="15sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="10dp"
|
||||||
|
android:alpha="0.6"
|
||||||
|
android:lineSpacingExtra="6dp"
|
||||||
|
android:text="此功能仅支持 QQ、TIM,在开启“系统通知栏显示 QQ、TIM 图标”后系统通知后方将在最后显示“TSBattery 守护中”字样以判断模块已经生效,若不喜欢,你可以随时关闭这个功能。"
|
||||||
|
android:textColor="@color/colorTextDark"
|
||||||
|
android:textSize="12sp" />
|
||||||
|
|
||||||
|
<com.fankes.tsbattery.view.MaterialSwitch
|
||||||
|
android:id="@+id/notify_module_info_switch"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="35dp"
|
||||||
|
android:layout_marginBottom="5dp"
|
||||||
android:text="提示模块运行信息"
|
android:text="提示模块运行信息"
|
||||||
android:textColor="@color/colorTextGray"
|
android:textColor="@color/colorTextGray"
|
||||||
android:textSize="15sp" />
|
android:textSize="15sp" />
|
||||||
@@ -679,53 +712,6 @@
|
|||||||
android:textSize="12sp" />
|
android:textSize="12sp" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/link_with_project_address"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="15dp"
|
|
||||||
android:layout_marginTop="15dp"
|
|
||||||
android:layout_marginRight="15dp"
|
|
||||||
android:background="@drawable/bg_permotion_round"
|
|
||||||
android:elevation="0dp"
|
|
||||||
android:gravity="center"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:padding="15dp">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginBottom="10dp"
|
|
||||||
android:gravity="center|start">
|
|
||||||
|
|
||||||
<androidx.constraintlayout.utils.widget.ImageFilterView
|
|
||||||
android:layout_width="15dp"
|
|
||||||
android:layout_height="15dp"
|
|
||||||
android:layout_marginEnd="5dp"
|
|
||||||
android:alpha="0.85"
|
|
||||||
android:src="@mipmap/ic_about"
|
|
||||||
android:tint="@color/colorTextGray" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:alpha="0.85"
|
|
||||||
android:singleLine="true"
|
|
||||||
android:text="项目地址"
|
|
||||||
android:textColor="@color/colorTextGray"
|
|
||||||
android:textSize="12sp" />
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:alpha="0.8"
|
|
||||||
android:lineSpacingExtra="6dp"
|
|
||||||
android:text="本软件是免费开源项目,遵循 AGPL3.0 协议,你可以点击这里前往 Github 查看源码以及获取模块更新。"
|
|
||||||
android:textColor="@color/colorTextDark"
|
|
||||||
android:textSize="12sp" />
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
BIN
app/src/main/res/mipmap-xxhdpi/ic_github.png
Normal file
BIN
app/src/main/res/mipmap-xxhdpi/ic_github.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.8 KiB |
@@ -5,8 +5,8 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ext {
|
ext {
|
||||||
appVersionName = "3.2"
|
appVersionName = "3.3"
|
||||||
appVersionCode = 11
|
appVersionCode = 12
|
||||||
}
|
}
|
||||||
|
|
||||||
task clean(type: Delete) {
|
task clean(type: Delete) {
|
||||||
|
Reference in New Issue
Block a user