Skip to content

Commit

Permalink
feat: 启用日志 24 小时后自动关闭
Browse files Browse the repository at this point in the history
  • Loading branch information
GSWXXN committed Jan 19, 2024
1 parent b90a023 commit aa23d3c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.highcapable.yukihookapi.hook.xposed.prefs.data.PrefsData
object DataConst {
val ENABLE_NEW_SYSTEM_UI_HOOKER = PrefsData("enable_new_system_ui_hooker", true)
val ENABLE_LOG = PrefsData("enable_log", false)
val ENABLE_LOG_TIMESTAMP = PrefsData("enable_log_timestamp", 0L)
val ENABLE_CUSTOM_SCOPE = PrefsData("enable_custom_scope", false)
val IS_CUSTOM_SCOPE_EXCEPTION_MODE = PrefsData("is_custom_scope_exception_mode", true)
val IS_REMOVE_BRANDING_IMAGE_EXCEPTION_MODE = PrefsData("is_remove_branding_image_exception_mode", false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import com.gswxxn.restoresplashscreen.ui.`interface`.ISubSettings
import com.gswxxn.restoresplashscreen.utils.BackupUtils
import com.gswxxn.restoresplashscreen.view.BlockMIUIItemData
import com.gswxxn.restoresplashscreen.view.SwitchView
import com.highcapable.yukihookapi.hook.factory.prefs

/**
* 基础设置 界面
Expand All @@ -27,7 +28,17 @@ object BasicSettings : ISubSettings {

override fun create(context: SubSettings, binding: ActivitySubSettingsBinding): BlockMIUIItemData.() -> Unit = {
// 启用日志
TextSummaryWithSwitch(TextSummaryV(textId = R.string.enable_log), SwitchView(DataConst.ENABLE_LOG))
if (System.currentTimeMillis() - context.prefs().get(DataConst.ENABLE_LOG_TIMESTAMP) > 86400000) {
context.prefs().edit().put(DataConst.ENABLE_LOG, false).commit()
}
TextSummaryWithSwitch(
TextSummaryV(textId = R.string.enable_log, tipsId = R.string.enable_log_tips),
SwitchView(DataConst.ENABLE_LOG) {
if (it) {
context.prefs().edit { put(DataConst.ENABLE_LOG_TIMESTAMP, System.currentTimeMillis()) }
}
}
)

// 隐藏桌面图标
TextSummaryWithSwitch(TextSummaryV(textId = R.string.hide_icon), SwitchView(DataConst.ENABLE_HIDE_ICON) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import com.highcapable.yukihookapi.hook.factory.hasClass
import com.highcapable.yukihookapi.hook.factory.method
import com.highcapable.yukihookapi.hook.log.YLog
import com.highcapable.yukihookapi.hook.type.java.StringClass
import com.highcapable.yukihookapi.hook.xposed.prefs.YukiHookPrefsBridge
import com.highcapable.yukihookapi.hook.xposed.prefs.data.PrefsData

/**
Expand Down Expand Up @@ -84,17 +85,21 @@ object YukiHelper {
/**
* 打印日志
*/
fun YukiBaseHooker.printLog(vararg msg: String) {
if (prefs.get(DataConst.ENABLE_LOG)) msg.forEach { YLog.info(it) }
}
fun YukiBaseHooker.printLog(vararg msg: String) = printLog(prefs, *msg)

/**
* 打印日志
*/
fun BaseHookHandler.printLog(vararg msg: String) {
if (prefs.get(DataConst.ENABLE_LOG)) msg.forEach { YLog.info(it) }
}
fun BaseHookHandler.printLog(vararg msg: String) = printLog(prefs, *msg)

/**
* 打印日志
*/
fun printLog(prefs: YukiHookPrefsBridge, vararg msg: String) {
if (!prefs.get(DataConst.ENABLE_LOG)) return
if (System.currentTimeMillis() - prefs.get(DataConst.ENABLE_LOG_TIMESTAMP) > 86400000) return
msg.forEach { YLog.info(it) }
}
/**
* 当前设备是否是 MIUI 定制 Android 系统
* @return [Boolean] 是否符合条件
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
<!--Sub Settings-->
<string name="make_sure_active">请确保模块已激活再进行配置</string>
<string name="enable_log">启用日志</string>
<string name="enable_log_tips">启用日志 24 小时后自动关闭</string>
<string name="hide_icon">隐藏桌面图标</string>
<string name="min_duration">遮罩最小持续时长</string>
<string name="min_duration_tips">注意:设置此参数会拖慢应用启动时间。如无特殊需求,则不应配置此项。</string>
Expand Down

0 comments on commit aa23d3c

Please sign in to comment.