mirror of
https://github.com/fankes/ColorOSNotifyIcon.git
synced 2025-09-04 09:45:34 +08:00
Modify merge to YukiHookAPI new usage
This commit is contained in:
@@ -27,7 +27,7 @@ package com.fankes.coloros.notify.data
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import com.fankes.coloros.notify.const.IconRuleSourceSyncType
|
import com.fankes.coloros.notify.const.IconRuleSourceSyncType
|
||||||
import com.fankes.coloros.notify.utils.factory.isUpperOfAndroidS
|
import com.fankes.coloros.notify.utils.factory.isUpperOfAndroidS
|
||||||
import com.highcapable.yukihookapi.hook.factory.modulePrefs
|
import com.highcapable.yukihookapi.hook.factory.prefs
|
||||||
import com.highcapable.yukihookapi.hook.log.loggerW
|
import com.highcapable.yukihookapi.hook.log.loggerW
|
||||||
import com.highcapable.yukihookapi.hook.param.PackageParam
|
import com.highcapable.yukihookapi.hook.param.PackageParam
|
||||||
import com.highcapable.yukihookapi.hook.xposed.prefs.data.PrefsData
|
import com.highcapable.yukihookapi.hook.xposed.prefs.data.PrefsData
|
||||||
@@ -118,7 +118,7 @@ object ConfigData {
|
|||||||
* @return [String]
|
* @return [String]
|
||||||
*/
|
*/
|
||||||
private fun getString(data: PrefsData<String>) = when (instance) {
|
private fun getString(data: PrefsData<String>) = when (instance) {
|
||||||
is Context -> (instance as Context).modulePrefs.get(data)
|
is Context -> (instance as Context).prefs().get(data)
|
||||||
is PackageParam -> (instance as PackageParam).prefs.get(data)
|
is PackageParam -> (instance as PackageParam).prefs.get(data)
|
||||||
else -> error("Unknown type for get prefs data")
|
else -> error("Unknown type for get prefs data")
|
||||||
}
|
}
|
||||||
@@ -130,7 +130,7 @@ object ConfigData {
|
|||||||
*/
|
*/
|
||||||
private fun putString(data: PrefsData<String>, value: String) {
|
private fun putString(data: PrefsData<String>, value: String) {
|
||||||
when (instance) {
|
when (instance) {
|
||||||
is Context -> (instance as Context).modulePrefs.put(data, value)
|
is Context -> (instance as Context).prefs().edit { put(data, value) }
|
||||||
is PackageParam -> loggerW(msg = "Not support for this method")
|
is PackageParam -> loggerW(msg = "Not support for this method")
|
||||||
else -> error("Unknown type for put prefs data")
|
else -> error("Unknown type for put prefs data")
|
||||||
}
|
}
|
||||||
@@ -142,7 +142,7 @@ object ConfigData {
|
|||||||
* @return [Int]
|
* @return [Int]
|
||||||
*/
|
*/
|
||||||
internal fun getInt(data: PrefsData<Int>) = when (instance) {
|
internal fun getInt(data: PrefsData<Int>) = when (instance) {
|
||||||
is Context -> (instance as Context).modulePrefs.get(data)
|
is Context -> (instance as Context).prefs().get(data)
|
||||||
is PackageParam -> (instance as PackageParam).prefs.get(data)
|
is PackageParam -> (instance as PackageParam).prefs.get(data)
|
||||||
else -> error("Unknown type for get prefs data")
|
else -> error("Unknown type for get prefs data")
|
||||||
}
|
}
|
||||||
@@ -154,7 +154,7 @@ object ConfigData {
|
|||||||
*/
|
*/
|
||||||
internal fun putInt(data: PrefsData<Int>, value: Int) {
|
internal fun putInt(data: PrefsData<Int>, value: Int) {
|
||||||
when (instance) {
|
when (instance) {
|
||||||
is Context -> (instance as Context).modulePrefs.put(data, value)
|
is Context -> (instance as Context).prefs().edit { put(data, value) }
|
||||||
is PackageParam -> loggerW(msg = "Not support for this method")
|
is PackageParam -> loggerW(msg = "Not support for this method")
|
||||||
else -> error("Unknown type for put prefs data")
|
else -> error("Unknown type for put prefs data")
|
||||||
}
|
}
|
||||||
@@ -166,7 +166,7 @@ object ConfigData {
|
|||||||
* @return [Boolean]
|
* @return [Boolean]
|
||||||
*/
|
*/
|
||||||
internal fun getBoolean(data: PrefsData<Boolean>) = when (instance) {
|
internal fun getBoolean(data: PrefsData<Boolean>) = when (instance) {
|
||||||
is Context -> (instance as Context).modulePrefs.get(data)
|
is Context -> (instance as Context).prefs().get(data)
|
||||||
is PackageParam -> (instance as PackageParam).prefs.get(data)
|
is PackageParam -> (instance as PackageParam).prefs.get(data)
|
||||||
else -> error("Unknown type for get prefs data")
|
else -> error("Unknown type for get prefs data")
|
||||||
}
|
}
|
||||||
@@ -178,7 +178,7 @@ object ConfigData {
|
|||||||
*/
|
*/
|
||||||
internal fun putBoolean(data: PrefsData<Boolean>, value: Boolean) {
|
internal fun putBoolean(data: PrefsData<Boolean>, value: Boolean) {
|
||||||
when (instance) {
|
when (instance) {
|
||||||
is Context -> (instance as Context).modulePrefs.put(data, value)
|
is Context -> (instance as Context).prefs().edit { put(data, value) }
|
||||||
is PackageParam -> loggerW(msg = "Not support for this method")
|
is PackageParam -> loggerW(msg = "Not support for this method")
|
||||||
else -> error("Unknown type for put prefs data")
|
else -> error("Unknown type for put prefs data")
|
||||||
}
|
}
|
||||||
|
@@ -29,7 +29,7 @@ import android.graphics.Color
|
|||||||
import com.fankes.coloros.notify.bean.IconDataBean
|
import com.fankes.coloros.notify.bean.IconDataBean
|
||||||
import com.fankes.coloros.notify.data.ConfigData
|
import com.fankes.coloros.notify.data.ConfigData
|
||||||
import com.fankes.coloros.notify.utils.factory.*
|
import com.fankes.coloros.notify.utils.factory.*
|
||||||
import com.highcapable.yukihookapi.hook.factory.modulePrefs
|
import com.highcapable.yukihookapi.hook.factory.prefs
|
||||||
import com.highcapable.yukihookapi.hook.param.PackageParam
|
import com.highcapable.yukihookapi.hook.param.PackageParam
|
||||||
import org.json.JSONArray
|
import org.json.JSONArray
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
@@ -47,7 +47,7 @@ class IconPackParams(private val context: Context? = null, private val param: Pa
|
|||||||
* 已存储的 JSON 数据
|
* 已存储的 JSON 数据
|
||||||
* @return [String]
|
* @return [String]
|
||||||
*/
|
*/
|
||||||
internal val storageDataJson get() = (context?.modulePrefs ?: param?.prefs)?.direct()?.get(ConfigData.NOTIFY_ICONS_DATA)
|
internal val storageDataJson get() = (context?.prefs() ?: param?.prefs)?.direct()?.get(ConfigData.NOTIFY_ICONS_DATA)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取图标数据
|
* 获取图标数据
|
||||||
@@ -134,5 +134,5 @@ class IconPackParams(private val context: Context? = null, private val param: Pa
|
|||||||
* 保存图标数据
|
* 保存图标数据
|
||||||
* @param dataJson 图标数据 JSON
|
* @param dataJson 图标数据 JSON
|
||||||
*/
|
*/
|
||||||
fun save(dataJson: String) = context?.modulePrefs?.put(ConfigData.NOTIFY_ICONS_DATA, dataJson)
|
fun save(dataJson: String) = context?.prefs()?.edit { put(ConfigData.NOTIFY_ICONS_DATA, dataJson) }
|
||||||
}
|
}
|
||||||
|
@@ -25,7 +25,7 @@ package com.fankes.coloros.notify.param.factory
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import com.fankes.coloros.notify.bean.IconDataBean
|
import com.fankes.coloros.notify.bean.IconDataBean
|
||||||
import com.highcapable.yukihookapi.hook.factory.modulePrefs
|
import com.highcapable.yukihookapi.hook.factory.prefs
|
||||||
import com.highcapable.yukihookapi.hook.param.PackageParam
|
import com.highcapable.yukihookapi.hook.param.PackageParam
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -38,14 +38,14 @@ fun PackageParam.isAppNotifyHookOf(bean: IconDataBean) = prefs.getBoolean(bean.t
|
|||||||
* 获取此 APP 的通知图标是否被 Hook
|
* 获取此 APP 的通知图标是否被 Hook
|
||||||
* @param bean 图标 bean
|
* @param bean 图标 bean
|
||||||
*/
|
*/
|
||||||
fun Context.isAppNotifyHookOf(bean: IconDataBean) = modulePrefs.getBoolean(bean.toEnabledName(), bean.isEnabled)
|
fun Context.isAppNotifyHookOf(bean: IconDataBean) = prefs().getBoolean(bean.toEnabledName(), bean.isEnabled)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置 Hook 此 APP 的通知图标
|
* 设置 Hook 此 APP 的通知图标
|
||||||
* @param bean 图标 bean
|
* @param bean 图标 bean
|
||||||
* @param isHook 是否 Hook
|
* @param isHook 是否 Hook
|
||||||
*/
|
*/
|
||||||
fun Context.putAppNotifyHookOf(bean: IconDataBean, isHook: Boolean) = modulePrefs.putBoolean(bean.toEnabledName(), isHook)
|
fun Context.putAppNotifyHookOf(bean: IconDataBean, isHook: Boolean) = prefs().edit { putBoolean(bean.toEnabledName(), isHook) }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取此 APP 的通知图标是否被全部 Hook
|
* 获取此 APP 的通知图标是否被全部 Hook
|
||||||
@@ -57,11 +57,11 @@ fun PackageParam.isAppNotifyHookAllOf(bean: IconDataBean) = prefs.getBoolean(bea
|
|||||||
* 获取此 APP 的通知图标是否被全部 Hook
|
* 获取此 APP 的通知图标是否被全部 Hook
|
||||||
* @param bean 图标 bean
|
* @param bean 图标 bean
|
||||||
*/
|
*/
|
||||||
fun Context.isAppNotifyHookAllOf(bean: IconDataBean) = modulePrefs.getBoolean(bean.toEnabledAllName(), bean.isEnabledAll)
|
fun Context.isAppNotifyHookAllOf(bean: IconDataBean) = prefs().getBoolean(bean.toEnabledAllName(), bean.isEnabledAll)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置全部 Hook 此 APP 的通知图标
|
* 设置全部 Hook 此 APP 的通知图标
|
||||||
* @param bean 图标 bean
|
* @param bean 图标 bean
|
||||||
* @param isHook 是否 Hook
|
* @param isHook 是否 Hook
|
||||||
*/
|
*/
|
||||||
fun Context.putAppNotifyHookAllOf(bean: IconDataBean, isHook: Boolean) = modulePrefs.putBoolean(bean.toEnabledAllName(), isHook)
|
fun Context.putAppNotifyHookAllOf(bean: IconDataBean, isHook: Boolean) = prefs().edit { putBoolean(bean.toEnabledAllName(), isHook) }
|
@@ -24,7 +24,7 @@ package com.fankes.coloros.notify.utils.tool
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import com.fankes.coloros.notify.utils.factory.showDialog
|
import com.fankes.coloros.notify.utils.factory.showDialog
|
||||||
import com.highcapable.yukihookapi.hook.factory.modulePrefs
|
import com.highcapable.yukihookapi.hook.factory.prefs
|
||||||
import com.highcapable.yukihookapi.hook.xposed.prefs.data.PrefsData
|
import com.highcapable.yukihookapi.hook.xposed.prefs.data.PrefsData
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
@@ -41,8 +41,8 @@ object I18nWarnTool {
|
|||||||
* @param context 实例
|
* @param context 实例
|
||||||
*/
|
*/
|
||||||
fun checkingOrShowing(context: Context) {
|
fun checkingOrShowing(context: Context) {
|
||||||
fun saveReaded() = context.modulePrefs.put(LOCALE_WARN_READED, value = true)
|
fun saveReaded() = context.prefs().edit { put(LOCALE_WARN_READED, value = true) }
|
||||||
if (Locale.getDefault().language.startsWith("zh").not() && context.modulePrefs.get(LOCALE_WARN_READED).not())
|
if (Locale.getDefault().language.startsWith("zh").not() && context.prefs().get(LOCALE_WARN_READED).not())
|
||||||
context.showDialog {
|
context.showDialog {
|
||||||
title = "Notice of I18n Support"
|
title = "Notice of I18n Support"
|
||||||
msg = "This Xposed Module is only for Chinese and the Chinese region.\n\n" +
|
msg = "This Xposed Module is only for Chinese and the Chinese region.\n\n" +
|
||||||
|
@@ -27,7 +27,7 @@ import com.fankes.coloros.notify.BuildConfig
|
|||||||
import com.fankes.coloros.notify.utils.factory.openBrowser
|
import com.fankes.coloros.notify.utils.factory.openBrowser
|
||||||
import com.fankes.coloros.notify.utils.factory.showDialog
|
import com.fankes.coloros.notify.utils.factory.showDialog
|
||||||
import com.highcapable.yukihookapi.YukiHookAPI
|
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
|
import com.highcapable.yukihookapi.hook.xposed.prefs.data.PrefsData
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -43,8 +43,8 @@ object YukiPromoteTool {
|
|||||||
* @param context 实例
|
* @param context 实例
|
||||||
*/
|
*/
|
||||||
fun promote(context: Context) {
|
fun promote(context: Context) {
|
||||||
fun saveReaded() = context.modulePrefs.put(YUKI_PROMOTE_READED, value = true)
|
fun saveReaded() = context.prefs().edit { put(YUKI_PROMOTE_READED, value = true) }
|
||||||
if (context.modulePrefs.get(YUKI_PROMOTE_READED).not())
|
if (context.prefs().get(YUKI_PROMOTE_READED).not())
|
||||||
context.showDialog {
|
context.showDialog {
|
||||||
title = "面向开发者的推广"
|
title = "面向开发者的推广"
|
||||||
msg = "你想快速拥有一个自己的 Xposed 模块吗,你只需要拥有基础的 Android 开发经验以及使用 Kotlin 编程语言即可。\n\n" +
|
msg = "你想快速拥有一个自己的 Xposed 模块吗,你只需要拥有基础的 Android 开发经验以及使用 Kotlin 编程语言即可。\n\n" +
|
||||||
|
Reference in New Issue
Block a user