mirror of
https://github.com/fankes/TSBattery.git
synced 2025-09-04 17:55:30 +08:00
Modify merge to YukiHookAPI new usage
This commit is contained in:
@@ -19,11 +19,14 @@
|
||||
*
|
||||
* This file is Created by fankes on 2022/9/28.
|
||||
*/
|
||||
@file:Suppress("StaticFieldLeak")
|
||||
|
||||
package com.fankes.tsbattery.data
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.widget.CompoundButton
|
||||
import com.highcapable.yukihookapi.hook.factory.prefs
|
||||
import com.highcapable.yukihookapi.hook.xposed.prefs.YukiHookPrefsBridge
|
||||
|
||||
/**
|
||||
* 全局配置存储控制类
|
||||
@@ -42,30 +45,30 @@ object ConfigData {
|
||||
/** 停用全部省电功能 (停用模块) */
|
||||
const val DISABLE_ALL_HOOK = "disable_all_hook"
|
||||
|
||||
/** 当前的 [SharedPreferences] */
|
||||
private var sharePrefs: SharedPreferences? = null
|
||||
/** 当前的 [YukiHookPrefsBridge] */
|
||||
private var prefs: YukiHookPrefsBridge? = null
|
||||
|
||||
/**
|
||||
* 读取 [SharedPreferences]
|
||||
* 读取 [YukiHookPrefsBridge]
|
||||
* @param key 键值名称
|
||||
* @param value 键值内容
|
||||
* @return [Boolean]
|
||||
*/
|
||||
private fun getBoolean(key: String, value: Boolean = false) = sharePrefs?.getBoolean(key, value) ?: value
|
||||
private fun getBoolean(key: String, value: Boolean = false) = prefs?.getBoolean(key, value) ?: value
|
||||
|
||||
/**
|
||||
* 存入 [SharedPreferences]
|
||||
* 存入 [YukiHookPrefsBridge]
|
||||
* @param key 键值名称
|
||||
* @param value 键值内容
|
||||
*/
|
||||
private fun putBoolean(key: String, value: Boolean = false) = sharePrefs?.edit()?.putBoolean(key, value)?.apply()
|
||||
private fun putBoolean(key: String, value: Boolean = false) = prefs?.edit { putBoolean(key, value) }
|
||||
|
||||
/**
|
||||
* 初始化 [SharedPreferences]
|
||||
* 初始化 [YukiHookPrefsBridge]
|
||||
* @param context 实例
|
||||
*/
|
||||
fun init(context: Context) {
|
||||
sharePrefs = context.getSharedPreferences("tsbattery_config", Context.MODE_PRIVATE)
|
||||
prefs = context.prefs(name = "tsbattery_config").native()
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -26,7 +26,7 @@ import com.fankes.tsbattery.BuildConfig
|
||||
import com.fankes.tsbattery.utils.factory.openBrowser
|
||||
import com.fankes.tsbattery.utils.factory.showDialog
|
||||
import com.highcapable.yukihookapi.YukiHookAPI
|
||||
import com.highcapable.yukihookapi.hook.factory.modulePrefs
|
||||
import com.highcapable.yukihookapi.hook.factory.prefs
|
||||
import com.highcapable.yukihookapi.hook.xposed.prefs.data.PrefsData
|
||||
|
||||
/**
|
||||
@@ -42,8 +42,8 @@ object YukiPromoteTool {
|
||||
* @param context 实例
|
||||
*/
|
||||
fun promote(context: Context) {
|
||||
fun saveReaded() = context.modulePrefs.put(YUKI_PROMOTE_READED, value = true)
|
||||
if (context.modulePrefs.get(YUKI_PROMOTE_READED).not())
|
||||
fun saveReaded() = context.prefs().edit { put(YUKI_PROMOTE_READED, value = true) }
|
||||
if (context.prefs().get(YUKI_PROMOTE_READED).not())
|
||||
context.showDialog {
|
||||
title = "面向开发者的推广"
|
||||
msg = "你想快速拥有一个自己的 Xposed 模块吗,你只需要拥有基础的 Android 开发经验以及使用 Kotlin 编程语言即可。\n\n" +
|
||||
|
Reference in New Issue
Block a user