7 Commits
3.9 ... 3.95

Author SHA1 Message Date
2be9a3d934 Update version to 3.95 2022-05-31 02:06:35 +08:00
d7dbecb65c Update YukiHookAPI 2022-05-31 02:02:26 +08:00
6c2b3f12b3 Merge code 2022-05-30 02:11:30 +08:00
f1c520586a Merge code 2022-05-30 02:03:14 +08:00
e9c99343c3 Merge code 2022-05-30 01:43:47 +08:00
20de713ffd Merge systemBar support with native 2022-05-30 00:47:47 +08:00
3b78e8a515 Repair Licenses 2022-05-30 00:16:53 +08:00
9 changed files with 64 additions and 40 deletions

View File

@@ -2,7 +2,7 @@
[![Blank](https://img.shields.io/badge/build-passing-brightgreen)](https://github.com/fankes/TSBattery) [![Blank](https://img.shields.io/badge/build-passing-brightgreen)](https://github.com/fankes/TSBattery)
[![Blank](https://img.shields.io/badge/license-AGPL3.0-blue)](https://github.com/fankes/TSBattery/blob/master/LICENSE) [![Blank](https://img.shields.io/badge/license-AGPL3.0-blue)](https://github.com/fankes/TSBattery/blob/master/LICENSE)
[![Blank](https://img.shields.io/badge/version-v3.9-green)](https://github.com/fankes/TSBattery/releases) [![Blank](https://img.shields.io/badge/version-v3.95-green)](https://github.com/fankes/TSBattery/releases)
[![Blank](https://img.shields.io/github/downloads/fankes/TSBattery/total?label=Release)](https://github.com/fankes/TSBattery/releases) [![Blank](https://img.shields.io/github/downloads/fankes/TSBattery/total?label=Release)](https://github.com/fankes/TSBattery/releases)
[![Blank](https://img.shields.io/github/downloads/Xposed-Modules-Repo/com.fankes.tsbattery/total?label=LSPosed%20Repo&logo=Android&style=flat&labelColor=F48FB1&logoColor=ffffff)](https://github.com/Xposed-Modules-Repo/com.fankes.tsbattery/releases) [![Blank](https://img.shields.io/github/downloads/Xposed-Modules-Repo/com.fankes.tsbattery/total?label=LSPosed%20Repo&logo=Android&style=flat&labelColor=F48FB1&logoColor=ffffff)](https://github.com/Xposed-Modules-Repo/com.fankes.tsbattery/releases)
[![Telegram](https://img.shields.io/badge/Follow-Telegram-blue.svg?logo=telegram)](https://t.me/XiaofangInternet) [![Telegram](https://img.shields.io/badge/Follow-Telegram-blue.svg?logo=telegram)](https://t.me/XiaofangInternet)

View File

@@ -31,6 +31,8 @@ android {
buildTypes { buildTypes {
release { release {
minifyEnabled rootProject.ext.enableR8 minifyEnabled rootProject.ext.enableR8
shrinkResources rootProject.ext.enableR8
zipAlignEnabled rootProject.ext.enableR8
signingConfig signingConfigs.debug signingConfig signingConfigs.debug
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
} }
@@ -57,11 +59,9 @@ android {
dependencies { dependencies {
compileOnly 'de.robv.android.xposed:api:82' compileOnly 'de.robv.android.xposed:api:82'
implementation 'com.highcapable.yukihookapi:api:1.0.91' implementation 'com.highcapable.yukihookapi:api:1.0.92'
ksp 'com.highcapable.yukihookapi:ksp-xposed:1.0.91' ksp 'com.highcapable.yukihookapi:ksp-xposed:1.0.92'
implementation 'com.squareup.okhttp3:okhttp:4.9.3' implementation 'com.squareup.okhttp3:okhttp:4.9.3'
implementation 'com.geyifeng.immersionbar:immersionbar: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'
implementation 'androidx.appcompat:appcompat:1.4.1' implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.6.0' implementation 'com.google.android.material:material:1.6.0'

View File

@@ -54,7 +54,7 @@ import com.highcapable.yukihookapi.hook.type.android.*
import com.highcapable.yukihookapi.hook.type.java.* import com.highcapable.yukihookapi.hook.type.java.*
import com.highcapable.yukihookapi.hook.xposed.proxy.IYukiHookXposedInit import com.highcapable.yukihookapi.hook.xposed.proxy.IYukiHookXposedInit
@InjectYukiHookWithXposed @InjectYukiHookWithXposed(isUsingResourcesHook = false)
class HookEntry : IYukiHookXposedInit { class HookEntry : IYukiHookXposedInit {
companion object { companion object {

View File

@@ -23,12 +23,14 @@
package com.fankes.tsbattery.ui.activity.base package com.fankes.tsbattery.ui.activity.base
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.view.ViewCompat
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
import com.gyf.immersionbar.ktx.immersionBar
import com.highcapable.yukihookapi.hook.factory.method import com.highcapable.yukihookapi.hook.factory.method
import com.highcapable.yukihookapi.hook.type.android.LayoutInflaterClass import com.highcapable.yukihookapi.hook.type.android.LayoutInflaterClass
import java.lang.reflect.ParameterizedType import java.lang.reflect.ParameterizedType
@@ -52,13 +54,14 @@ abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
/** 隐藏系统的标题栏 */ /** 隐藏系统的标题栏 */
supportActionBar?.hide() supportActionBar?.hide()
/** 初始化沉浸状态栏 */ /** 初始化沉浸状态栏 */
immersionBar { ViewCompat.getWindowInsetsController(window.decorView)?.apply {
statusBarColor(R.color.colorThemeBackground) isAppearanceLightStatusBars = isNotSystemInDarkMode
autoDarkModeEnable(true) isAppearanceLightNavigationBars = isNotSystemInDarkMode
statusBarDarkFont(isNotSystemInDarkMode) }
navigationBarColor(R.color.colorThemeBackground) ResourcesCompat.getColor(resources, R.color.colorThemeBackground, null).also {
navigationBarDarkIcon(isNotSystemInDarkMode) window?.statusBarColor = it
fitsSystemWindows(true) window?.navigationBarColor = it
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) window?.navigationBarDividerColor = it
} }
/** 装载子类 */ /** 装载子类 */
onCreate() onCreate()

View File

@@ -44,10 +44,10 @@ import com.highcapable.yukihookapi.hook.type.android.LayoutInflaterClass
/** /**
* 构造对话框 * 构造对话框
* @param isUseBlackTheme 是否使用深色主题 * @param isUseBlackTheme 是否使用深色主题
* @param it 对话框方法体 * @param initiate 对话框方法体
*/ */
fun Context.showDialog(isUseBlackTheme: Boolean = false, it: DialogBuilder.() -> Unit) = fun Context.showDialog(isUseBlackTheme: Boolean = false, initiate: DialogBuilder.() -> Unit) =
DialogBuilder(this, isUseBlackTheme).apply(it).show() DialogBuilder(context = this, isUseBlackTheme).apply(initiate).show()
/** /**
* 对话框构造器 * 对话框构造器
@@ -140,34 +140,34 @@ class DialogBuilder(val context: Context, private val isUseBlackTheme: Boolean)
/** /**
* 设置对话框确定按钮 * 设置对话框确定按钮
* @param text 按钮文本内容 * @param text 按钮文本内容
* @param it 点击事件 * @param callback 点击事件
*/ */
fun confirmButton(text: String = "确定", it: () -> Unit = {}) { fun confirmButton(text: String = "确定", callback: () -> Unit = {}) {
if (isUsingAndroidX) if (isUsingAndroidX)
runInSafe { instanceAndroidX?.setPositiveButton(text) { _, _ -> it() } } runInSafe { instanceAndroidX?.setPositiveButton(text) { _, _ -> callback() } }
else runInSafe { instanceAndroid?.setPositiveButton(text) { _, _ -> it() } } else runInSafe { instanceAndroid?.setPositiveButton(text) { _, _ -> callback() } }
} }
/** /**
* 设置对话框取消按钮 * 设置对话框取消按钮
* @param text 按钮文本内容 * @param text 按钮文本内容
* @param it 点击事件 * @param callback 点击事件
*/ */
fun cancelButton(text: String = "取消", it: () -> Unit = {}) { fun cancelButton(text: String = "取消", callback: () -> Unit = {}) {
if (isUsingAndroidX) if (isUsingAndroidX)
runInSafe { instanceAndroidX?.setNegativeButton(text) { _, _ -> it() } } runInSafe { instanceAndroidX?.setNegativeButton(text) { _, _ -> callback() } }
else runInSafe { instanceAndroid?.setNegativeButton(text) { _, _ -> it() } } else runInSafe { instanceAndroid?.setNegativeButton(text) { _, _ -> callback() } }
} }
/** /**
* 设置对话框第三个按钮 * 设置对话框第三个按钮
* @param text 按钮文本内容 * @param text 按钮文本内容
* @param it 点击事件 * @param callback 点击事件
*/ */
fun neutralButton(text: String = "更多", it: () -> Unit = {}) { fun neutralButton(text: String = "更多", callback: () -> Unit = {}) {
if (isUsingAndroidX) if (isUsingAndroidX)
runInSafe { instanceAndroidX?.setNeutralButton(text) { _, _ -> it() } } runInSafe { instanceAndroidX?.setNeutralButton(text) { _, _ -> callback() } }
else runInSafe { instanceAndroid?.setNeutralButton(text) { _, _ -> it() } } else runInSafe { instanceAndroid?.setNeutralButton(text) { _, _ -> callback() } }
} }
/** 取消对话框 */ /** 取消对话框 */

View File

@@ -137,13 +137,13 @@ fun toast(msg: String) = Toast.makeText(appContext, msg, Toast.LENGTH_SHORT).sho
* 弹出 [Snackbar] * 弹出 [Snackbar]
* @param msg 提示内容 * @param msg 提示内容
* @param actionText 按钮文本 - 不写默认取消按钮 * @param actionText 按钮文本 - 不写默认取消按钮
* @param it 按钮事件回调 * @param callback 按钮事件回调
*/ */
fun Context.snake(msg: String, actionText: String = "", it: () -> Unit = {}) = fun Context.snake(msg: String, actionText: String = "", callback: () -> Unit = {}) =
Snackbar.make((this as Activity).findViewById(android.R.id.content), msg, Snackbar.LENGTH_LONG).apply { Snackbar.make((this as Activity).findViewById(android.R.id.content), msg, Snackbar.LENGTH_LONG).apply {
if (actionText.isBlank()) return@apply if (actionText.isBlank()) return@apply
setActionTextColor(if (isSystemInDarkMode) Color.BLACK else Color.WHITE) setActionTextColor(if (isSystemInDarkMode) Color.BLACK else Color.WHITE)
setAction(actionText) { it() } setAction(actionText) { callback() }
}.show() }.show()
/** /**

View File

@@ -44,9 +44,9 @@ object GithubReleaseTool {
* 获取最新版本信息 * 获取最新版本信息
* @param context 实例 * @param context 实例
* @param version 当前版本 * @param version 当前版本
* @param it 成功后回调 - ([String] 最新版本,[Function] 更新对话框方法体) * @param result 成功后回调 - ([String] 最新版本,[Function] 更新对话框方法体)
*/ */
fun checkingForUpdate(context: Context, version: String, it: (String, () -> Unit) -> Unit) = checkingInternetConnect(context) { fun checkingForUpdate(context: Context, version: String, result: (String, () -> Unit) -> Unit) = checkingInternetConnect(context) {
OkHttpClient().newBuilder().build().newCall( OkHttpClient().newBuilder().build().newCall(
Request.Builder() Request.Builder()
.url("https://api.github.com/repos/$REPO_AUTHOR/$REPO_NAME/releases/latest") .url("https://api.github.com/repos/$REPO_AUTHOR/$REPO_NAME/releases/latest")
@@ -72,7 +72,7 @@ object GithubReleaseTool {
} }
if (name != version) (context as? Activity?)?.runOnUiThread { if (name != version) (context as? Activity?)?.runOnUiThread {
showUpdate() showUpdate()
it(name) { showUpdate() } result(name) { showUpdate() }
} }
} }
} }
@@ -83,9 +83,9 @@ object GithubReleaseTool {
/** /**
* 检查网络连接情况 * 检查网络连接情况
* @param context 实例 * @param context 实例
* @param it 已连接回调 * @param callback 已连接回调
*/ */
private fun checkingInternetConnect(context: Context, it: () -> Unit) = runInSafe { private fun checkingInternetConnect(context: Context, callback: () -> Unit) = runInSafe {
if (isNetWorkSuccess) if (isNetWorkSuccess)
OkHttpClient().newBuilder().build().newCall( OkHttpClient().newBuilder().build().newCall(
Request.Builder() Request.Builder()
@@ -106,7 +106,7 @@ object GithubReleaseTool {
} }
override fun onResponse(call: Call, response: Response) = runInSafe { override fun onResponse(call: Call, response: Response) = runInSafe {
(context as? Activity?)?.runOnUiThread { runInSafe { it() } } (context as? Activity?)?.runOnUiThread { runInSafe { callback() } }
} }
}) })
} }

View File

@@ -1,3 +1,24 @@
/*
* TSBattery - A new way to save your battery avoid cancer apps hacker it.
* Copyright (C) 2019-2022 Fankes Studio(qzmmcn@163.com)
* https://github.com/fankes/TSBattery
*
* This software is non-free but opensource software: you can redistribute it
* and/or modify it under the terms of the GNU Affero General Public License
* as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* and eula along with this software. If not, see
* <https://www.gnu.org/licenses/>
*
* This file is Created by fankes on 2022/5/30.
*/
package com.fankes.tsbattery.utils.tool package com.fankes.tsbattery.utils.tool
import android.content.Context import android.content.Context

View File

@@ -5,8 +5,8 @@ plugins {
} }
ext { ext {
appVersionName = "3.9" appVersionName = "3.95"
appVersionCode = 17 appVersionCode = 18
enableR8 = true enableR8 = true
} }