mirror of
https://github.com/HighCapable/YukiHookAPI.git
synced 2025-09-07 03:05:36 +08:00
Update Demo support PreferenceFragment
This commit is contained in:
@@ -40,5 +40,9 @@
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".ui.PreferenceActivity"
|
||||
android:exported="false" />
|
||||
</application>
|
||||
</manifest>
|
@@ -93,6 +93,15 @@ class HookEntry : YukiHookXposedInitProxy {
|
||||
type = StringType
|
||||
}.get(instance).set("I am hook result")
|
||||
}
|
||||
// 在执行方法之后拦截
|
||||
afterHook {
|
||||
if (prefs.getBoolean("show_dialog_when_demo_app_opend"))
|
||||
AlertDialog.Builder(instance())
|
||||
.setTitle("Hooked")
|
||||
.setMessage("This App has been hooked!")
|
||||
.setPositiveButton("OK", null)
|
||||
.show()
|
||||
}
|
||||
}
|
||||
// 注入要 Hook 的方法
|
||||
injectMember {
|
||||
@@ -131,7 +140,7 @@ class HookEntry : YukiHookXposedInitProxy {
|
||||
replaceUnit {
|
||||
AlertDialog.Builder(instance())
|
||||
.setTitle("Hooked")
|
||||
.setMessage("I am hook your toast showing")
|
||||
.setMessage("I am hook your toast showing!")
|
||||
.setPositiveButton("OK", null)
|
||||
.show()
|
||||
}
|
||||
|
@@ -29,9 +29,11 @@
|
||||
|
||||
package com.highcapable.yukihookapi.demo_module.ui
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.highcapable.yukihookapi.YukiHookAPI
|
||||
import com.highcapable.yukihookapi.demo_module.data.DataConst
|
||||
import com.highcapable.yukihookapi.demo_module.databinding.ActivityMainBinding
|
||||
import com.highcapable.yukihookapi.hook.factory.isModuleActive
|
||||
@@ -44,9 +46,11 @@ class MainActivity : AppCompatActivity() {
|
||||
super.onCreate(savedInstanceState)
|
||||
ActivityMainBinding.inflate(layoutInflater).apply {
|
||||
setContentView(root)
|
||||
moduleDemoText.text = "Module is Active -> $isModuleActive\n" +
|
||||
"Hook Framework -> ${YukiHookModuleStatus.executorName}\n" +
|
||||
"API Version -> ${YukiHookModuleStatus.executorVersion}"
|
||||
moduleDemoActiveText.text = "Module is Active:$isModuleActive"
|
||||
moduleDemoFrameworkText.text = "Hook Framework:${YukiHookModuleStatus.executorName}"
|
||||
moduleDemoApiVersionText.text = "API Version:${YukiHookModuleStatus.executorVersion}"
|
||||
moduleDemoYukiHookApiVersionText.text = "YukiHookAPI Version:${YukiHookAPI.API_VERSION_NAME}(${YukiHookAPI.API_VERSION_CODE})"
|
||||
moduleDemoNewXshareText.text = "New XShare Mode:${modulePrefs.isRunInNewXShareMode}"
|
||||
moduleDemoEditText.also {
|
||||
it.setText(modulePrefs.get(DataConst.TEST_KV_DATA))
|
||||
moduleDemoButton.setOnClickListener { _ ->
|
||||
@@ -56,6 +60,7 @@ class MainActivity : AppCompatActivity() {
|
||||
} else Toast.makeText(applicationContext, "Please enter the text", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
moduleDemoFrgButton.setOnClickListener { startActivity(Intent(this@MainActivity, PreferenceActivity::class.java)) }
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* 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/18.
|
||||
*/
|
||||
package com.highcapable.yukihookapi.demo_module.ui
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.highcapable.yukihookapi.demo_module.R
|
||||
import com.highcapable.yukihookapi.hook.xposed.prefs.ui.ModulePreferenceFragment
|
||||
|
||||
class PreferenceActivity : AppCompatActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
title = "PreferenceFragment"
|
||||
if (savedInstanceState == null)
|
||||
supportFragmentManager
|
||||
.beginTransaction()
|
||||
.replace(android.R.id.content, SettingsFragment())
|
||||
.commitAllowingStateLoss()
|
||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||
}
|
||||
|
||||
override fun onSupportNavigateUp(): Boolean {
|
||||
onBackPressed()
|
||||
return super.onSupportNavigateUp()
|
||||
}
|
||||
|
||||
class SettingsFragment : ModulePreferenceFragment() {
|
||||
|
||||
override fun onCreatePreferencesInModuleApp(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
setPreferencesFromResource(R.xml.settings_preferences, rootKey)
|
||||
}
|
||||
}
|
||||
}
|
@@ -7,30 +7,103 @@
|
||||
android:orientation="vertical"
|
||||
tools:ignore="HardcodedText">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_demo_text"
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="50dp"
|
||||
android:layout_marginRight="50dp"
|
||||
android:layout_marginBottom="15dp"
|
||||
android:gravity="center"
|
||||
android:lineSpacingExtra="6dp"
|
||||
android:text="sample"
|
||||
android:textSize="20sp" />
|
||||
android:gravity="center|start"
|
||||
android:orientation="vertical">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/module_demo_edit_text"
|
||||
android:layout_width="250dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="15dp"
|
||||
android:hint="Please enter the text"
|
||||
android:singleLine="true"
|
||||
android:textSize="20sp"
|
||||
tools:ignore="Autofill,LabelFor,TextFields" />
|
||||
<TextView
|
||||
android:id="@+id/module_demo_active_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="15dp"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center|start"
|
||||
android:singleLine="true"
|
||||
android:text="sample"
|
||||
android:textSize="18sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_demo_framework_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="15dp"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center|start"
|
||||
android:singleLine="true"
|
||||
android:text="sample"
|
||||
android:textSize="18sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_demo_api_version_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="15dp"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center|start"
|
||||
android:singleLine="true"
|
||||
android:text="sample"
|
||||
android:textSize="18sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_demo_yuki_hook_api_version_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="15dp"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center|start"
|
||||
android:singleLine="true"
|
||||
android:text="sample"
|
||||
android:textSize="18sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_demo_new_xshare_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="25dp"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center|start"
|
||||
android:singleLine="true"
|
||||
android:text="sample"
|
||||
android:textSize="18sp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="5dp"
|
||||
android:layout_marginBottom="15dp"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center|start"
|
||||
android:singleLine="true"
|
||||
android:text="Leave something in there"
|
||||
android:textSize="15sp" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/module_demo_edit_text"
|
||||
android:layout_width="250dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="Please enter the text"
|
||||
android:singleLine="true"
|
||||
android:textSize="18sp"
|
||||
tools:ignore="Autofill,LabelFor,TextFields" />
|
||||
</LinearLayout>
|
||||
|
||||
<Button
|
||||
android:id="@+id/module_demo_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="15dp"
|
||||
android:text="Save Test Data"
|
||||
android:textAllCaps="false" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/module_demo_frg_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Open PreferenceFragment"
|
||||
android:textAllCaps="false" />
|
||||
</LinearLayout>
|
@@ -1,16 +1,16 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<resources>
|
||||
<!-- Base application theme. -->
|
||||
<style name="Theme.Default" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
||||
<style name="Theme.Default" parent="Theme.Material3.DayNight">
|
||||
<!-- Primary brand color. -->
|
||||
<item name="colorPrimary">@color/purple_200</item>
|
||||
<item name="colorPrimaryVariant">@color/purple_700</item>
|
||||
<item name="colorOnPrimary">@color/black</item>
|
||||
<item name="colorPrimary">@color/yuki_theme_color</item>
|
||||
<item name="colorPrimaryVariant">@color/yuki_theme_color</item>
|
||||
<item name="colorOnPrimary">@color/white</item>
|
||||
<!-- Secondary brand color. -->
|
||||
<item name="colorSecondary">@color/teal_200</item>
|
||||
<item name="colorSecondaryVariant">@color/teal_200</item>
|
||||
<item name="colorSecondary">@color/yuki_accent_color</item>
|
||||
<item name="colorSecondaryVariant">@color/yuki_accent_color</item>
|
||||
<item name="colorOnSecondary">@color/black</item>
|
||||
<!-- Status bar color. -->
|
||||
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
|
||||
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
|
||||
<!-- Customize your theme here. -->
|
||||
</style>
|
||||
</resources>
|
@@ -1,10 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="purple_200">#FFBB86FC</color>
|
||||
<color name="purple_500">#FF6200EE</color>
|
||||
<color name="purple_700">#FF3700B3</color>
|
||||
<color name="teal_200">#FF03DAC5</color>
|
||||
<color name="teal_700">#FF018786</color>
|
||||
<color name="yuki_theme_color">#FFEBAD70</color>
|
||||
<color name="yuki_accent_color">#FF777777</color>
|
||||
<color name="black">#FF000000</color>
|
||||
<color name="white">#FFFFFFFF</color>
|
||||
</resources>
|
@@ -1,3 +1,3 @@
|
||||
<resources>
|
||||
<string name="app_name">YukiHookModuleDemo</string>
|
||||
<string name="app_name">YukiHookDemoModule</string>
|
||||
</resources>
|
@@ -1,16 +1,16 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<resources>
|
||||
<!-- Base application theme. -->
|
||||
<style name="Theme.Default" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
||||
<style name="Theme.Default" parent="Theme.Material3.DayNight">
|
||||
<!-- Primary brand color. -->
|
||||
<item name="colorPrimary">@color/purple_500</item>
|
||||
<item name="colorPrimaryVariant">@color/purple_700</item>
|
||||
<item name="colorPrimary">@color/yuki_theme_color</item>
|
||||
<item name="colorPrimaryVariant">@color/yuki_theme_color</item>
|
||||
<item name="colorOnPrimary">@color/white</item>
|
||||
<!-- Secondary brand color. -->
|
||||
<item name="colorSecondary">@color/teal_200</item>
|
||||
<item name="colorSecondaryVariant">@color/teal_700</item>
|
||||
<item name="colorSecondary">@color/yuki_accent_color</item>
|
||||
<item name="colorSecondaryVariant">@color/yuki_accent_color</item>
|
||||
<item name="colorOnSecondary">@color/black</item>
|
||||
<!-- Status bar color. -->
|
||||
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
|
||||
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
|
||||
<!-- Customize your theme here. -->
|
||||
</style>
|
||||
</resources>
|
10
demo-module/src/main/res/xml/settings_preferences.xml
Normal file
10
demo-module/src/main/res/xml/settings_preferences.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<PreferenceCategory app:title="Normal Preference">
|
||||
<SwitchPreference
|
||||
app:defaultValue="false"
|
||||
app:key="show_dialog_when_demo_app_opend"
|
||||
app:summary="Open a dialog on start Demo App"
|
||||
app:title="Show Dialog" />
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
Reference in New Issue
Block a user