mirror of
https://github.com/HighCapable/YukiHookAPI.git
synced 2025-09-06 02:35:40 +08:00
Added new "PrefsData" function
This commit is contained in:
@@ -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")
|
||||
}
|
@@ -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
|
||||
|
@@ -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<EditText>(R.id.module_demo_edit_text).also {
|
||||
it.setText(modulePrefs.getString(key = "test_data"))
|
||||
it.setText(modulePrefs.get(DataConst.TEST_KV_DATA))
|
||||
findViewById<Button>(R.id.module_demo_button).setOnClickListener { _ ->
|
||||
if (it.text.toString().isNotEmpty()) {
|
||||
modulePrefs.putString(key = "test_data", value = it.text.toString())
|
||||
modulePrefs.put(DataConst.TEST_KV_DATA, it.text.toString())
|
||||
Toast.makeText(applicationContext, "Saved", Toast.LENGTH_SHORT).show()
|
||||
} else Toast.makeText(applicationContext, "Please enter the text", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
Reference in New Issue
Block a user