mirror of
https://github.com/HighCapable/YukiHookAPI.git
synced 2025-09-04 09:45:19 +08:00
Modify test Kotlin Class to Java Class
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
@@ -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;
|
||||
}
|
||||
}
|
@@ -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() }
|
||||
}
|
||||
|
@@ -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
|
||||
}
|
@@ -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
|
||||
}
|
@@ -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) }
|
||||
|
Reference in New Issue
Block a user