diff --git a/demo-app/src/main/java/com/highcapable/yukihookapi/demo_app/test/Main.java b/demo-app/src/main/java/com/highcapable/yukihookapi/demo_app/test/Main.java new file mode 100644 index 00000000..1147f867 --- /dev/null +++ b/demo-app/src/main/java/com/highcapable/yukihookapi/demo_app/test/Main.java @@ -0,0 +1,36 @@ +package com.highcapable.yukihookapi.demo_app.test; + +public class Main extends SuperMain { + + private final String content; + + public Main() { + super(""); + content = ""; + } + + public Main(String content) { + super(content); + this.content = content; + } + + public String getTestResultFirst() { + return "The world is beautiful"; + } + + public String getTestResultFirst(String string) { + return string; + } + + public String getTestResultLast() { + return "The world is fantastic"; + } + + public final String getTestResultLast(String string) { + return string; + } + + public String getContent() { + return content; + } +} \ No newline at end of file diff --git a/demo-app/src/main/java/com/highcapable/yukihookapi/demo_app/test/SuperMain.java b/demo-app/src/main/java/com/highcapable/yukihookapi/demo_app/test/SuperMain.java new file mode 100644 index 00000000..32efe923 --- /dev/null +++ b/demo-app/src/main/java/com/highcapable/yukihookapi/demo_app/test/SuperMain.java @@ -0,0 +1,22 @@ +package com.highcapable.yukihookapi.demo_app.test; + +public class SuperMain { + + private final String content; + + public SuperMain(String content) { + this.content = content; + } + + public String getSuperString() { + return "The sea is blue"; + } + + public String getString() { + return getContent(); + } + + public String getContent() { + return content; + } +} \ No newline at end of file diff --git a/demo-app/src/main/java/com/highcapable/yukihookapi/demo_app/ui/MainActivity.kt b/demo-app/src/main/java/com/highcapable/yukihookapi/demo_app/ui/MainActivity.kt index acbf85ad..3abb3499 100644 --- a/demo-app/src/main/java/com/highcapable/yukihookapi/demo_app/ui/MainActivity.kt +++ b/demo-app/src/main/java/com/highcapable/yukihookapi/demo_app/ui/MainActivity.kt @@ -25,7 +25,7 @@ * * This file is Created by fankes on 2022/2/9. */ -@file:Suppress("SameParameterValue") +@file:Suppress("SameParameterValue", "UsePropertyAccessSyntax") package com.highcapable.yukihookapi.demo_app.ui @@ -33,7 +33,7 @@ import android.os.Bundle import android.widget.Toast import androidx.appcompat.app.AppCompatActivity import com.highcapable.yukihookapi.demo_app.databinding.ActivityMainBinding -import com.highcapable.yukihookapi.demo_app.utils.Main +import com.highcapable.yukihookapi.demo_app.test.Main class MainActivity : AppCompatActivity() { @@ -43,14 +43,14 @@ class MainActivity : AppCompatActivity() { setContentView(root) appDemoFirstText.text = getFirstText() appDemoSecondText.text = secondText - appDemoThirdText.text = Main(content = "Feel real").getString() - appDemoFourthText.text = getRegularText(string = "Have fun day") + appDemoThirdText.text = Main("Feel real").getString() + appDemoFourthText.text = getRegularText("Have fun day") appDemoFifthText.text = getDataText() appDemoSixthText.text = getArray(arrayOf("apple", "banana")).let { "${it[0]}, ${it[1]}" } appDemoSeventhText.text = Main().getTestResultFirst() - appDemoEighthText.text = Main().getTestResultFirst(string = "Find something interesting") + appDemoEighthText.text = Main().getTestResultFirst("Find something interesting") appDemoNinthText.text = Main().getTestResultLast() - appDemoTenthText.text = Main().getTestResultLast(string = "This is the last sentence") + appDemoTenthText.text = Main().getTestResultLast("This is the last sentence") appDemoEleventhText.text = Main().getSuperString() appDemoButton.setOnClickListener { toast() } } diff --git a/demo-app/src/main/java/com/highcapable/yukihookapi/demo_app/utils/Main.kt b/demo-app/src/main/java/com/highcapable/yukihookapi/demo_app/utils/Main.kt deleted file mode 100644 index 6ded2555..00000000 --- a/demo-app/src/main/java/com/highcapable/yukihookapi/demo_app/utils/Main.kt +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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/2/9. - */ -package com.highcapable.yukihookapi.demo_app.utils - -class Main(override val content: String = "") : SuperMain(content) { - - fun getTestResultFirst() = "The world is beautiful" - - fun getTestResultFirst(string: String) = string - - fun getTestResultLast() = "The world is fantastic" - - fun getTestResultLast(string: String) = string -} \ No newline at end of file diff --git a/demo-app/src/main/java/com/highcapable/yukihookapi/demo_app/utils/SuperMain.kt b/demo-app/src/main/java/com/highcapable/yukihookapi/demo_app/utils/SuperMain.kt deleted file mode 100644 index 00177374..00000000 --- a/demo-app/src/main/java/com/highcapable/yukihookapi/demo_app/utils/SuperMain.kt +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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/4/29. - */ -package com.highcapable.yukihookapi.demo_app.utils - -open class SuperMain(open val content: String = "") { - - fun getSuperString() = "The sea is blue" - - fun getString() = content -} \ 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 4bec8b72..1497f04a 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 @@ -223,7 +223,7 @@ class HookEntry : IYukiHookXposedInit { } } // 得到需要 Hook 的 Class - findClass(name = "$packageName.utils.Main").hook { + findClass(name = "$packageName.test.Main").hook { // 注入要 Hook 的方法 injectMember { constructor { param(StringType) }