mirror of
https://github.com/fankes/TSBattery.git
synced 2025-09-04 17:55:30 +08:00
Compare commits
17 Commits
Author | SHA1 | Date | |
---|---|---|---|
81331dfe81
|
|||
20f1ceca4d
|
|||
fc8589f1ee
|
|||
|
67378b2ebf | ||
|
bf4ecd8345 | ||
6e8d900dc5
|
|||
3d12d3f4a5
|
|||
4b36437dac
|
|||
93789f163b
|
|||
32d8937ddb
|
|||
38c9d78f1e
|
|||
0ee03340da
|
|||
54ee2358cf
|
|||
55708eb96a
|
|||
c4de8ae448
|
|||
9e092742da
|
|||
fb27c107f4
|
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
[](https://github.com/fankes/TSBattery)
|
[](https://github.com/fankes/TSBattery)
|
||||||
[](https://github.com/fankes/TSBattery/blob/master/LICENSE)
|
[](https://github.com/fankes/TSBattery/blob/master/LICENSE)
|
||||||
[](https://github.com/fankes/TSBattery/releases)
|
[](https://github.com/fankes/TSBattery/releases)
|
||||||
[](https://github.com/fankes/TSBattery/releases)
|
[](https://github.com/fankes/TSBattery/releases)
|
||||||
[](https://github.com/Xposed-Modules-Repo/com.fankes.tsbattery/releases)
|
[](https://github.com/Xposed-Modules-Repo/com.fankes.tsbattery/releases)
|
||||||
[](https://t.me/XiaofangInternet)
|
[](https://t.me/XiaofangInternet)
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'com.android.application'
|
id 'com.android.application'
|
||||||
id 'kotlin-android'
|
id 'kotlin-android'
|
||||||
id 'com.google.devtools.ksp' version '1.6.21-1.0.5'
|
id 'com.google.devtools.ksp' version '1.7.0-1.0.6'
|
||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
@@ -15,8 +15,7 @@ android {
|
|||||||
v2SigningEnabled true
|
v2SigningEnabled true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
compileSdkVersion 31
|
compileSdkVersion 32
|
||||||
buildToolsVersion "31.0.0"
|
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "com.fankes.tsbattery"
|
applicationId "com.fankes.tsbattery"
|
||||||
@@ -61,10 +60,10 @@ dependencies {
|
|||||||
compileOnly 'de.robv.android.xposed:api:82'
|
compileOnly 'de.robv.android.xposed:api:82'
|
||||||
implementation 'com.highcapable.yukihookapi:api:1.0.92'
|
implementation 'com.highcapable.yukihookapi:api:1.0.92'
|
||||||
ksp 'com.highcapable.yukihookapi:ksp-xposed:1.0.92'
|
ksp 'com.highcapable.yukihookapi:ksp-xposed:1.0.92'
|
||||||
implementation 'com.squareup.okhttp3:okhttp:4.9.3'
|
implementation 'com.squareup.okhttp3:okhttp:5.0.0-alpha.7'
|
||||||
implementation 'androidx.core:core-ktx:1.7.0'
|
implementation 'androidx.core:core-ktx:1.8.0'
|
||||||
implementation 'androidx.appcompat:appcompat:1.4.1'
|
implementation 'androidx.appcompat:appcompat:1.4.2'
|
||||||
implementation 'com.google.android.material:material:1.6.0'
|
implementation 'com.google.android.material:material:1.6.1'
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
||||||
testImplementation 'junit:junit:4.13.2'
|
testImplementation 'junit:junit:4.13.2'
|
||||||
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
||||||
|
@@ -84,6 +84,9 @@ class HookEntry : IYukiHookXposedInit {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 是否完全支持当前版本 */
|
||||||
|
private var isHookClientSupport = true
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 这个类 QQ 的 BaseChatPie 是控制聊天界面的
|
* 这个类 QQ 的 BaseChatPie 是控制聊天界面的
|
||||||
*
|
*
|
||||||
@@ -134,7 +137,23 @@ class HookEntry : IYukiHookXposedInit {
|
|||||||
interceptBaseChatPie(methodName = "bl")
|
interceptBaseChatPie(methodName = "bl")
|
||||||
interceptBaseChatPie(methodName = "bm")
|
interceptBaseChatPie(methodName = "bm")
|
||||||
}
|
}
|
||||||
else -> loggerD(msg = "$version not supported!")
|
"8.8.93", "8.8.95" -> {
|
||||||
|
interceptBaseChatPie(methodName = "J3")
|
||||||
|
interceptBaseChatPie(methodName = "S")
|
||||||
|
}
|
||||||
|
"8.8.98" -> {
|
||||||
|
interceptBaseChatPie(methodName = "M3")
|
||||||
|
interceptBaseChatPie(methodName = "S")
|
||||||
|
}
|
||||||
|
/** 8.9.0 贡献者:StarWishsama */
|
||||||
|
"8.9.0", "8.9.1" -> {
|
||||||
|
interceptBaseChatPie(methodName = "N3")
|
||||||
|
interceptBaseChatPie(methodName = "S")
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
isHookClientSupport = false
|
||||||
|
loggerD(msg = "$version not supported!")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,6 +166,7 @@ class HookEntry : IYukiHookXposedInit {
|
|||||||
injectMember {
|
injectMember {
|
||||||
method {
|
method {
|
||||||
name = methodName
|
name = methodName
|
||||||
|
emptyParam()
|
||||||
returnType = UnitType
|
returnType = UnitType
|
||||||
}
|
}
|
||||||
intercept()
|
intercept()
|
||||||
@@ -159,7 +179,7 @@ class HookEntry : IYukiHookXposedInit {
|
|||||||
injectMember {
|
injectMember {
|
||||||
method {
|
method {
|
||||||
name = "acquireLocked"
|
name = "acquireLocked"
|
||||||
returnType = UnitType
|
emptyParam()
|
||||||
}
|
}
|
||||||
intercept()
|
intercept()
|
||||||
}
|
}
|
||||||
@@ -187,11 +207,12 @@ class HookEntry : IYukiHookXposedInit {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 提示模块运行信息 QQ、TIM、微信
|
* 提示模块运行信息 QQ、TIM、微信
|
||||||
* @param isQQTIM 是否为 QQ、TIM
|
* @param isQQ 是否为 QQ
|
||||||
|
* @param isTIM 是否为 TIM
|
||||||
*/
|
*/
|
||||||
private fun PackageParam.hookModuleRunningInfo(isQQTIM: Boolean) =
|
private fun PackageParam.hookModuleRunningInfo(isQQ: Boolean = false, isTIM: Boolean = false) =
|
||||||
when {
|
when {
|
||||||
isQQTIM -> SplashActivityClass.hook {
|
isQQ || isTIM -> SplashActivityClass.hook {
|
||||||
/**
|
/**
|
||||||
* Hook 启动界面的第一个 [Activity]
|
* Hook 启动界面的第一个 [Activity]
|
||||||
* QQ 和 TIM 都是一样的类
|
* QQ 和 TIM 都是一样的类
|
||||||
@@ -208,7 +229,9 @@ class HookEntry : IYukiHookXposedInit {
|
|||||||
showDialog {
|
showDialog {
|
||||||
title = "TSBattery 已激活"
|
title = "TSBattery 已激活"
|
||||||
msg = "[提示模块运行信息功能已打开]\n\n" +
|
msg = "[提示模块运行信息功能已打开]\n\n" +
|
||||||
"模块工作看起来一切正常,请自行测试是否能达到省电效果。\n\n" +
|
(if (isQQ && isHookClientSupport.not())
|
||||||
|
"❎ 当前版本 $versionName($versionCode) 不在兼容列表,请自行测试是否生效~\n\n"
|
||||||
|
else "✅ 模块工作看起来一切正常,请自行测试是否能达到省电效果。\n\n") +
|
||||||
"已生效模块版本:${prefs.get(DataConst.ENABLE_MODULE_VERSION)}\n" +
|
"已生效模块版本:${prefs.get(DataConst.ENABLE_MODULE_VERSION)}\n" +
|
||||||
"当前模式:${if (prefs.get(DataConst.ENABLE_QQTIM_WHITE_MODE)) "保守模式" else "完全模式"}" +
|
"当前模式:${if (prefs.get(DataConst.ENABLE_QQTIM_WHITE_MODE)) "保守模式" else "完全模式"}" +
|
||||||
"\n\n包名:${packageName}\n版本:$versionName($versionCode)" +
|
"\n\n包名:${packageName}\n版本:$versionName($versionCode)" +
|
||||||
@@ -347,7 +370,7 @@ class HookEntry : IYukiHookXposedInit {
|
|||||||
method {
|
method {
|
||||||
name = "setRightText"
|
name = "setRightText"
|
||||||
param(CharSequenceType)
|
param(CharSequenceType)
|
||||||
}.call(prefs.get(DataConst.ENABLE_MODULE_VERSION))
|
}.call("${if (isQQ && isHookClientSupport.not()) "❎" else "✅"} ${prefs.get(DataConst.ENABLE_MODULE_VERSION)}")
|
||||||
method {
|
method {
|
||||||
name = "setBgType"
|
name = "setBgType"
|
||||||
param(IntType)
|
param(IntType)
|
||||||
@@ -357,7 +380,9 @@ class HookEntry : IYukiHookXposedInit {
|
|||||||
instance<Activity>().apply {
|
instance<Activity>().apply {
|
||||||
showDialog {
|
showDialog {
|
||||||
title = "TSBattery 守护中"
|
title = "TSBattery 守护中"
|
||||||
msg = "已生效模块版本:${prefs.get(DataConst.ENABLE_MODULE_VERSION)}\n" +
|
msg = (if (isQQ && isHookClientSupport.not())
|
||||||
|
"❎ 当前版本 $versionName($versionCode) 不在兼容列表,请自行测试是否生效~\n\n" else "") +
|
||||||
|
"已生效模块版本:${prefs.get(DataConst.ENABLE_MODULE_VERSION)}\n" +
|
||||||
"当前模式:${if (prefs.get(DataConst.ENABLE_QQTIM_WHITE_MODE)) "保守模式" else "完全模式"}" +
|
"当前模式:${if (prefs.get(DataConst.ENABLE_QQTIM_WHITE_MODE)) "保守模式" else "完全模式"}" +
|
||||||
"\n\n包名:${packageName}\n版本:$versionName($versionCode)" +
|
"\n\n包名:${packageName}\n版本:$versionName($versionCode)" +
|
||||||
"\n\n模块只对挂后台锁屏情况下有省电效果," +
|
"\n\n模块只对挂后台锁屏情况下有省电效果," +
|
||||||
@@ -408,19 +433,11 @@ class HookEntry : IYukiHookXposedInit {
|
|||||||
hookSystemWakeLock()
|
hookSystemWakeLock()
|
||||||
hookNotification()
|
hookNotification()
|
||||||
hookCoreService(isQQ = true)
|
hookCoreService(isQQ = true)
|
||||||
hookModuleRunningInfo(isQQTIM = true)
|
hookModuleRunningInfo(isQQ = true)
|
||||||
hookQQSettingsSettingActivity(isQQ = true)
|
hookQQSettingsSettingActivity(isQQ = true)
|
||||||
if (prefs.get(DataConst.ENABLE_QQTIM_WHITE_MODE)) return@loadApp
|
if (prefs.get(DataConst.ENABLE_QQTIM_WHITE_MODE)) return@loadApp
|
||||||
/** 通过在 [SplashActivityClass] 里取到应用的版本号 */
|
/** 通过在生命周期里取到应用的版本号 */
|
||||||
SplashActivityClass.hook {
|
onAppLifecycle { onCreate { hookQQBaseChatPie(versionName) } }
|
||||||
injectMember {
|
|
||||||
method {
|
|
||||||
name = "doOnCreate"
|
|
||||||
param(BundleClass)
|
|
||||||
}
|
|
||||||
afterHook { hookQQBaseChatPie(instance<Activity>().versionName) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* 干掉消息收发功能的电源锁
|
* 干掉消息收发功能的电源锁
|
||||||
* 每个版本的差异暂未做排查
|
* 每个版本的差异暂未做排查
|
||||||
@@ -629,13 +646,13 @@ class HookEntry : IYukiHookXposedInit {
|
|||||||
hookSystemWakeLock()
|
hookSystemWakeLock()
|
||||||
hookNotification()
|
hookNotification()
|
||||||
hookCoreService(isQQ = false)
|
hookCoreService(isQQ = false)
|
||||||
hookModuleRunningInfo(isQQTIM = true)
|
hookModuleRunningInfo(isTIM = true)
|
||||||
hookQQSettingsSettingActivity(isQQ = false)
|
hookQQSettingsSettingActivity(isQQ = false)
|
||||||
}
|
}
|
||||||
loadApp(WECHAT_PACKAGE_NAME) {
|
loadApp(WECHAT_PACKAGE_NAME) {
|
||||||
if (prefs.get(DataConst.DISABLE_WECHAT_HOOK)) return@loadApp
|
if (prefs.get(DataConst.DISABLE_WECHAT_HOOK)) return@loadApp
|
||||||
hookSystemWakeLock()
|
hookSystemWakeLock()
|
||||||
hookModuleRunningInfo(isQQTIM = false)
|
hookModuleRunningInfo()
|
||||||
loggerD(msg = "ウイチャット:それが機能するかどうかはわかりませんでした")
|
loggerD(msg = "ウイチャット:それが機能するかどうかはわかりませんでした")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -46,8 +46,20 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
private const val moduleVersion = BuildConfig.VERSION_NAME
|
private const val moduleVersion = BuildConfig.VERSION_NAME
|
||||||
private const val qqSupportVersion =
|
private val qqSupportVersions = arrayOf(
|
||||||
"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.8.85、8.8.88、8.8.90 (8.2.11、8.5.5~8.8.90)"
|
"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.8.85",
|
||||||
|
"8.8.88", "8.8.90", "8.8.93", "8.8.95",
|
||||||
|
"8.8.98", "8.9.0", "8.9.1"
|
||||||
|
)
|
||||||
|
private val qqSupportVersion by lazy {
|
||||||
|
if (qqSupportVersions.isNotEmpty()) {
|
||||||
|
var value = ""
|
||||||
|
qqSupportVersions.forEach { value += "$it、" }
|
||||||
|
"${value.trim().let { it.substring(0, it.lastIndex) }}\n\n其余版本请自行测试是否有效。"
|
||||||
|
} else "empty"
|
||||||
|
}
|
||||||
private const val timSupportVersion = "2+、3+ (并未完全测试每个版本)"
|
private const val timSupportVersion = "2+、3+ (并未完全测试每个版本)"
|
||||||
private const val wechatSupportVersion = "全版本仅支持基础省电,更多功能依然画饼"
|
private const val wechatSupportVersion = "全版本仅支持基础省电,更多功能依然画饼"
|
||||||
|
|
||||||
@@ -96,8 +108,8 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
msg = "若你的设备已 Root,推荐使用 LSPosed 激活模块,太极可能会出现模块设置无法保存的问题。"
|
msg = "若你的设备已 Root,推荐使用 LSPosed 激活模块,太极可能会出现模块设置无法保存的问题。"
|
||||||
confirmButton(text = "我知道了")
|
confirmButton(text = "我知道了")
|
||||||
}
|
}
|
||||||
/** 检测应用转生 */
|
/** 检测应用转生 - 如果模块已激活就不再检测 */
|
||||||
if (("com.bug.xposed").isInstall)
|
if (("com.bug.xposed").isInstall && YukiHookAPI.Status.isModuleActive.not())
|
||||||
showDialog {
|
showDialog {
|
||||||
title = "环境异常"
|
title = "环境异常"
|
||||||
msg = "检测到“应用转生”已被安装,为了保证模块的安全和稳定,请卸载更换其他 Hook 框架后才能继续使用。"
|
msg = "检测到“应用转生”已被安装,为了保证模块的安全和稳定,请卸载更换其他 Hook 框架后才能继续使用。"
|
||||||
|
@@ -27,7 +27,7 @@ import android.os.Build
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.content.res.ResourcesCompat
|
import androidx.core.content.res.ResourcesCompat
|
||||||
import androidx.core.view.ViewCompat
|
import androidx.core.view.WindowCompat
|
||||||
import androidx.viewbinding.ViewBinding
|
import androidx.viewbinding.ViewBinding
|
||||||
import com.fankes.tsbattery.R
|
import com.fankes.tsbattery.R
|
||||||
import com.fankes.tsbattery.utils.factory.isNotSystemInDarkMode
|
import com.fankes.tsbattery.utils.factory.isNotSystemInDarkMode
|
||||||
@@ -54,7 +54,7 @@ abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
|
|||||||
/** 隐藏系统的标题栏 */
|
/** 隐藏系统的标题栏 */
|
||||||
supportActionBar?.hide()
|
supportActionBar?.hide()
|
||||||
/** 初始化沉浸状态栏 */
|
/** 初始化沉浸状态栏 */
|
||||||
ViewCompat.getWindowInsetsController(window.decorView)?.apply {
|
WindowCompat.getInsetsController(window, window.decorView).apply {
|
||||||
isAppearanceLightStatusBars = isNotSystemInDarkMode
|
isAppearanceLightStatusBars = isNotSystemInDarkMode
|
||||||
isAppearanceLightNavigationBars = isNotSystemInDarkMode
|
isAppearanceLightNavigationBars = isNotSystemInDarkMode
|
||||||
}
|
}
|
||||||
|
@@ -19,7 +19,7 @@
|
|||||||
*
|
*
|
||||||
* This file is Created by fankes on 2022/1/8.
|
* This file is Created by fankes on 2022/1/8.
|
||||||
*/
|
*/
|
||||||
@file:Suppress("DEPRECATION", "CanvasSize")
|
@file:Suppress("DEPRECATION", "CanvasSize", "OVERRIDE_DEPRECATION")
|
||||||
|
|
||||||
package com.fankes.tsbattery.utils.drawable.drawabletoolbox
|
package com.fankes.tsbattery.utils.drawable.drawabletoolbox
|
||||||
|
|
||||||
|
@@ -28,18 +28,13 @@ import android.content.Context
|
|||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.graphics.drawable.GradientDrawable
|
import android.graphics.drawable.GradientDrawable
|
||||||
import android.view.Gravity
|
import android.view.Gravity
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import android.widget.ProgressBar
|
import android.widget.ProgressBar
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.viewbinding.ViewBinding
|
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
import com.highcapable.yukihookapi.annotation.CauseProblemsApi
|
|
||||||
import com.highcapable.yukihookapi.hook.factory.method
|
|
||||||
import com.highcapable.yukihookapi.hook.type.android.LayoutInflaterClass
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构造对话框
|
* 构造对话框
|
||||||
@@ -60,9 +55,7 @@ class DialogBuilder(val context: Context, private val isUseBlackTheme: Boolean)
|
|||||||
private var instanceAndroid: android.app.AlertDialog.Builder? = null // 实例对象
|
private var instanceAndroid: android.app.AlertDialog.Builder? = null // 实例对象
|
||||||
|
|
||||||
private var dialogInstance: Dialog? = null // 对话框实例
|
private var dialogInstance: Dialog? = null // 对话框实例
|
||||||
|
private var customLayoutView: View? = null // 自定义布局
|
||||||
@CauseProblemsApi
|
|
||||||
var customLayoutView: View? = null // 自定义布局
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否需要使用 AndroidX 风格对话框
|
* 是否需要使用 AndroidX 风格对话框
|
||||||
@@ -125,18 +118,6 @@ class DialogBuilder(val context: Context, private val isUseBlackTheme: Boolean)
|
|||||||
else customLayoutView?.findViewWithTag<TextView>("progressContent")?.text = value
|
else customLayoutView?.findViewWithTag<TextView>("progressContent")?.text = value
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置对话框自定义布局
|
|
||||||
* @return [ViewBinding]
|
|
||||||
*/
|
|
||||||
inline fun <reified T : ViewBinding> bind() =
|
|
||||||
T::class.java.method {
|
|
||||||
name = "inflate"
|
|
||||||
param(LayoutInflaterClass)
|
|
||||||
}.get().invoke<T>(LayoutInflater.from(context))?.apply {
|
|
||||||
customLayoutView = root
|
|
||||||
} ?: error("binding failed")
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置对话框确定按钮
|
* 设置对话框确定按钮
|
||||||
* @param text 按钮文本内容
|
* @param text 按钮文本内容
|
||||||
|
@@ -19,15 +19,21 @@
|
|||||||
*
|
*
|
||||||
* This file is Created by fankes on 2022/3/20.
|
* This file is Created by fankes on 2022/3/20.
|
||||||
*/
|
*/
|
||||||
|
@file:Suppress("NewApi")
|
||||||
|
|
||||||
package com.fankes.tsbattery.utils.tool
|
package com.fankes.tsbattery.utils.tool
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.icu.text.SimpleDateFormat
|
||||||
|
import android.icu.util.Calendar
|
||||||
|
import android.icu.util.TimeZone
|
||||||
import com.fankes.tsbattery.utils.factory.*
|
import com.fankes.tsbattery.utils.factory.*
|
||||||
import okhttp3.*
|
import okhttp3.*
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.io.Serializable
|
import java.io.Serializable
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取 Github Release 最新版本工具类
|
* 获取 Github Release 最新版本工具类
|
||||||
@@ -56,12 +62,12 @@ object GithubReleaseTool {
|
|||||||
override fun onFailure(call: Call, e: IOException) {}
|
override fun onFailure(call: Call, e: IOException) {}
|
||||||
|
|
||||||
override fun onResponse(call: Call, response: Response) = runInSafe {
|
override fun onResponse(call: Call, response: Response) = runInSafe {
|
||||||
JSONObject(response.body?.string() ?: "").apply {
|
JSONObject(response.body.string()).apply {
|
||||||
GithubReleaseBean(
|
GithubReleaseBean(
|
||||||
name = getString("name"),
|
name = getString("name"),
|
||||||
htmlUrl = getString("html_url"),
|
htmlUrl = getString("html_url"),
|
||||||
content = getString("body"),
|
content = getString("body"),
|
||||||
date = getString("published_at").replace(oldValue = "T", newValue = " ").replace(oldValue = "Z", newValue = "")
|
date = getString("published_at").localTime()
|
||||||
).apply {
|
).apply {
|
||||||
fun showUpdate() = context.showDialog {
|
fun showUpdate() = context.showDialog {
|
||||||
title = "最新版本 $name"
|
title = "最新版本 $name"
|
||||||
@@ -111,6 +117,18 @@ object GithubReleaseTool {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 格式化时间为本地时区
|
||||||
|
* @return [String] 本地时区时间
|
||||||
|
*/
|
||||||
|
private fun String.localTime() = replace(oldValue = "T", newValue = " ").replace(oldValue = "Z", newValue = "").let {
|
||||||
|
runCatching {
|
||||||
|
val local = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.ROOT).apply { timeZone = Calendar.getInstance().timeZone }
|
||||||
|
val current = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.ROOT).apply { timeZone = TimeZone.getTimeZone("GMT") }
|
||||||
|
local.format(current.parse(it))
|
||||||
|
}.getOrNull() ?: it
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Github Release bean
|
* Github Release bean
|
||||||
* @param name 版本名称
|
* @param name 版本名称
|
||||||
|
@@ -22,6 +22,7 @@
|
|||||||
package com.fankes.tsbattery.utils.tool
|
package com.fankes.tsbattery.utils.tool
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import com.fankes.tsbattery.BuildConfig
|
||||||
import com.fankes.tsbattery.utils.factory.openBrowser
|
import com.fankes.tsbattery.utils.factory.openBrowser
|
||||||
import com.fankes.tsbattery.utils.factory.showDialog
|
import com.fankes.tsbattery.utils.factory.showDialog
|
||||||
import com.highcapable.yukihookapi.YukiHookAPI
|
import com.highcapable.yukihookapi.YukiHookAPI
|
||||||
@@ -34,7 +35,7 @@ import com.highcapable.yukihookapi.hook.xposed.prefs.data.PrefsData
|
|||||||
object YukiPromoteTool {
|
object YukiPromoteTool {
|
||||||
|
|
||||||
/** 推广已读存储键值 */
|
/** 推广已读存储键值 */
|
||||||
private val YUKI_PROMOTE_READED = PrefsData("yuki_promote_readed", false)
|
private val YUKI_PROMOTE_READED = PrefsData("yuki_promote_readed_${BuildConfig.VERSION_NAME}", false)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 显示推广对话框
|
* 显示推广对话框
|
||||||
|
@@ -2,13 +2,13 @@
|
|||||||
<!-- Base application theme. -->
|
<!-- Base application theme. -->
|
||||||
<style name="Theme.TSBattery" parent="Theme.Material3.DayNight">
|
<style name="Theme.TSBattery" parent="Theme.Material3.DayNight">
|
||||||
<!-- Primary brand color. -->
|
<!-- Primary brand color. -->
|
||||||
<item name="colorPrimary">@color/purple_200</item>
|
<item name="colorPrimary">@color/colorPrimaryAccent</item>
|
||||||
<item name="colorPrimaryVariant">@color/purple_700</item>
|
<item name="colorPrimaryVariant">@color/colorPrimaryAccent</item>
|
||||||
<item name="colorOnPrimary">@color/black</item>
|
<item name="colorOnPrimary">@color/black</item>
|
||||||
<!-- Secondary brand color. -->
|
<!-- Secondary brand color. -->
|
||||||
<item name="colorSecondary">@color/teal_200</item>
|
<item name="colorSecondary">@color/colorPrimaryAccent</item>
|
||||||
<item name="colorSecondaryVariant">@color/teal_200</item>
|
<item name="colorSecondaryVariant">@color/colorPrimaryAccent</item>
|
||||||
<item name="colorOnSecondary">@color/black</item>
|
<item name="colorOnSecondary">@color/colorPrimaryAccent</item>
|
||||||
<!-- Status bar color. -->
|
<!-- Status bar color. -->
|
||||||
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
|
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
|
||||||
<!-- Customize your theme here. -->
|
<!-- Customize your theme here. -->
|
||||||
|
@@ -1,10 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<color name="purple_200">#656565</color>
|
<color name="colorPrimaryAccent">#656565</color>
|
||||||
<color name="purple_500">#656565</color>
|
|
||||||
<color name="purple_700">#656565</color>
|
|
||||||
<color name="teal_200">#656565</color>
|
|
||||||
<color name="teal_700">#656565</color>
|
|
||||||
<color name="black">#FF000000</color>
|
<color name="black">#FF000000</color>
|
||||||
<color name="white">#FFFFFFFF</color>
|
<color name="white">#FFFFFFFF</color>
|
||||||
</resources>
|
</resources>
|
@@ -2,13 +2,13 @@
|
|||||||
<!-- Base application theme. -->
|
<!-- Base application theme. -->
|
||||||
<style name="Theme.TSBattery" parent="Theme.Material3.DayNight">
|
<style name="Theme.TSBattery" parent="Theme.Material3.DayNight">
|
||||||
<!-- Primary brand color. -->
|
<!-- Primary brand color. -->
|
||||||
<item name="colorPrimary">@color/purple_500</item>
|
<item name="colorPrimary">@color/colorPrimaryAccent</item>
|
||||||
<item name="colorPrimaryVariant">@color/purple_700</item>
|
<item name="colorPrimaryVariant">@color/colorPrimaryAccent</item>
|
||||||
<item name="colorOnPrimary">@color/teal_700</item>
|
<item name="colorOnPrimary">@color/colorPrimaryAccent</item>
|
||||||
<!-- Secondary brand color. -->
|
<!-- Secondary brand color. -->
|
||||||
<item name="colorSecondary">@color/teal_200</item>
|
<item name="colorSecondary">@color/colorPrimaryAccent</item>
|
||||||
<item name="colorSecondaryVariant">@color/teal_700</item>
|
<item name="colorSecondaryVariant">@color/colorPrimaryAccent</item>
|
||||||
<item name="colorOnSecondary">@color/black</item>
|
<item name="colorOnSecondary">@color/colorPrimaryAccent</item>
|
||||||
<!-- Status bar color. -->
|
<!-- Status bar color. -->
|
||||||
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
|
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
|
||||||
<!-- Customize your theme here. -->
|
<!-- Customize your theme here. -->
|
||||||
|
10
build.gradle
10
build.gradle
@@ -1,12 +1,12 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'com.android.application' version '7.2.0' apply false
|
id 'com.android.application' version '7.2.1' apply false
|
||||||
id 'com.android.library' version '7.2.0' apply false
|
id 'com.android.library' version '7.2.1' apply false
|
||||||
id 'org.jetbrains.kotlin.android' version '1.6.21' apply false
|
id 'org.jetbrains.kotlin.android' version '1.7.0' apply false
|
||||||
}
|
}
|
||||||
|
|
||||||
ext {
|
ext {
|
||||||
appVersionName = "3.95"
|
appVersionName = "3.99"
|
||||||
appVersionCode = 18
|
appVersionCode = 22
|
||||||
enableR8 = true
|
enableR8 = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||||
# Specifies the JVM arguments used for the daemon process.
|
# Specifies the JVM arguments used for the daemon process.
|
||||||
# The setting is particularly useful for tweaking memory settings.
|
# The setting is particularly useful for tweaking memory settings.
|
||||||
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
|
org.gradle.jvmargs=-XX:+UseParallelGC
|
||||||
# When configured, Gradle will run in incubating parallel mode.
|
# When configured, Gradle will run in incubating parallel mode.
|
||||||
# This option should only be used with decoupled projects. More details, visit
|
# This option should only be used with decoupled projects. More details, visit
|
||||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||||
@@ -19,3 +19,5 @@ android.useAndroidX=true
|
|||||||
android.enableJetifier=true
|
android.enableJetifier=true
|
||||||
# Kotlin code style for this project: "official" or "obsolete":
|
# Kotlin code style for this project: "official" or "obsolete":
|
||||||
kotlin.code.style=official
|
kotlin.code.style=official
|
||||||
|
# Incremental
|
||||||
|
kotlin.incremental.useClasspathSnapshot=true
|
Reference in New Issue
Block a user