From 99b6f041f092c6bb544e47cdb251678a90f45ff4 Mon Sep 17 00:00:00 2001 From: Fankesyooni Date: Sun, 27 Mar 2022 12:31:10 +0800 Subject: [PATCH] Added new "PrefsData" function --- .../yukihookapi/demo_module/data/DataConst.kt | 35 +++++ .../yukihookapi/demo_module/hook/HookEntry.kt | 3 +- .../demo_module/ui/MainActivity.kt | 5 +- .../hook/xposed/prefs/YukiHookModulePrefs.kt | 126 +++++++++++++----- .../hook/xposed/prefs/data/PrefsData.kt | 41 ++++++ 5 files changed, 177 insertions(+), 33 deletions(-) create mode 100644 demo-module/src/main/java/com/highcapable/yukihookapi/demo_module/data/DataConst.kt create mode 100644 yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/xposed/prefs/data/PrefsData.kt diff --git a/demo-module/src/main/java/com/highcapable/yukihookapi/demo_module/data/DataConst.kt b/demo-module/src/main/java/com/highcapable/yukihookapi/demo_module/data/DataConst.kt new file mode 100644 index 00000000..2dcb85dc --- /dev/null +++ b/demo-module/src/main/java/com/highcapable/yukihookapi/demo_module/data/DataConst.kt @@ -0,0 +1,35 @@ +/* + * YukiHookAPI - An efficient Kotlin version of the Xposed Hook API. + * Copyright (C) 2019-2022 HighCapable + * https://github.com/fankes/YukiHookAPI + * + * MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * This file is Created by fankes on 2022/3/27. + */ +package com.highcapable.yukihookapi.demo_module.data + +import com.highcapable.yukihookapi.hook.xposed.prefs.data.PrefsData + +object DataConst { + + val TEST_KV_DATA = PrefsData("test_data", "Test data is nothing") +} \ No newline at end of file diff --git a/demo-module/src/main/java/com/highcapable/yukihookapi/demo_module/hook/HookEntry.kt b/demo-module/src/main/java/com/highcapable/yukihookapi/demo_module/hook/HookEntry.kt index e93a40f7..3d2e6ef4 100644 --- a/demo-module/src/main/java/com/highcapable/yukihookapi/demo_module/hook/HookEntry.kt +++ b/demo-module/src/main/java/com/highcapable/yukihookapi/demo_module/hook/HookEntry.kt @@ -30,6 +30,7 @@ package com.highcapable.yukihookapi.demo_module.hook import android.app.AlertDialog import com.highcapable.yukihookapi.YukiHookAPI import com.highcapable.yukihookapi.annotation.xposed.InjectYukiHookWithXposed +import com.highcapable.yukihookapi.demo_module.data.DataConst import com.highcapable.yukihookapi.hook.type.android.BundleClass import com.highcapable.yukihookapi.hook.type.java.StringType import com.highcapable.yukihookapi.hook.type.java.UnitType @@ -121,7 +122,7 @@ class HookEntry : YukiHookXposedInitProxy { returnType = StringType } // 执行替换 Hook - replaceTo(prefs.getString(key = "test_data", default = "Test data is nothing")) + replaceTo(prefs.get(DataConst.TEST_KV_DATA)) } } // 得到需要 Hook 的 Class diff --git a/demo-module/src/main/java/com/highcapable/yukihookapi/demo_module/ui/MainActivity.kt b/demo-module/src/main/java/com/highcapable/yukihookapi/demo_module/ui/MainActivity.kt index 6f8e173b..03ae3979 100644 --- a/demo-module/src/main/java/com/highcapable/yukihookapi/demo_module/ui/MainActivity.kt +++ b/demo-module/src/main/java/com/highcapable/yukihookapi/demo_module/ui/MainActivity.kt @@ -36,6 +36,7 @@ import android.widget.TextView import android.widget.Toast import androidx.appcompat.app.AppCompatActivity import com.highcapable.yukihookapi.demo_module.R +import com.highcapable.yukihookapi.demo_module.data.DataConst import com.highcapable.yukihookapi.hook.factory.isModuleActive import com.highcapable.yukihookapi.hook.factory.modulePrefs import com.highcapable.yukihookapi.hook.xposed.YukiHookModuleStatus @@ -49,10 +50,10 @@ class MainActivity : AppCompatActivity() { "Hook Framework -> ${YukiHookModuleStatus.executorName}\n" + "API Version -> ${YukiHookModuleStatus.executorVersion}" findViewById(R.id.module_demo_edit_text).also { - it.setText(modulePrefs.getString(key = "test_data")) + it.setText(modulePrefs.get(DataConst.TEST_KV_DATA)) findViewById