feat: update demo

This commit is contained in:
2025-06-18 20:40:28 +08:00
parent 14399538ea
commit 684e3abbdc
14 changed files with 226 additions and 129 deletions

View File

@@ -47,6 +47,9 @@ dependencies {
implementation(com.highcapable.hikage.hikage.extension)
implementation(com.highcapable.hikage.hikage.widget.androidx)
implementation(com.highcapable.hikage.hikage.widget.material)
implementation(com.highcapable.betterandroid.ui.component)
implementation(com.highcapable.betterandroid.ui.extension)
implementation(com.highcapable.betterandroid.system.extension)
implementation(androidx.core.core.ktx)
implementation(androidx.appcompat.appcompat)
implementation(androidx.lifecycle.lifecycle.viewmodel.ktx)

View File

@@ -27,7 +27,7 @@ import android.os.Bundle
import android.view.Gravity
import android.widget.LinearLayout
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import com.highcapable.betterandroid.ui.component.activity.AppViewsActivity
import com.highcapable.betterandroid.ui.extension.view.toast
import com.highcapable.betterandroid.ui.extension.view.updateMargins
import com.highcapable.hikage.extension.setContentView
@@ -36,67 +36,82 @@ import com.highcapable.hikage.widget.android.widget.ImageView
import com.highcapable.hikage.widget.android.widget.LinearLayout
import com.highcapable.hikage.widget.android.widget.TextView
import com.highcapable.hikage.widget.androidx.core.widget.NestedScrollView
import com.highcapable.hikage.widget.com.google.android.material.appbar.MaterialToolbar
import com.highcapable.yukihookapi.demo_app.R
import com.highcapable.yukihookapi.demo_app.test.Main
import android.R as Android_R
class MainActivity : AppCompatActivity() {
class MainActivity : AppViewsActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val hikage = setContentView {
NestedScrollView(
lparams = LayoutParams(matchParent = true),
LinearLayout(
lparams = LayoutParams(widthMatchParent = true),
init = {
isFillViewport = true
isVerticalScrollBarEnabled = false
orientation = LinearLayout.VERTICAL
}
) {
LinearLayout(
lparams = LayoutParams(widthMatchParent = true) {
updateMargins(vertical = 20.dp)
},
MaterialToolbar(
lparams = LayoutParams(widthMatchParent = true),
init = {
orientation = LinearLayout.VERTICAL
gravity = Gravity.CENTER
title = stringResource(R.string.app_name)
}
)
NestedScrollView(
lparams = LayoutParams(matchParent = true),
init = {
isFillViewport = true
isVerticalScrollBarEnabled = false
isVerticalFadingEdgeEnabled = true
}
) {
ImageView(
lparams = LayoutParams(50.dp, 50.dp) {
bottomMargin = 15.dp
LinearLayout(
lparams = LayoutParams(widthMatchParent = true) {
updateMargins(vertical = 20.dp)
},
init = {
orientation = LinearLayout.VERTICAL
gravity = Gravity.CENTER
}
) {
setImageResource(R.mipmap.ic_face_unhappy)
}
TextView(
lparams = LayoutParams {
bottomMargin = 25.dp
}
) {
text = stringResource(R.string.test_string)
textSize = 17.5f
}
repeat(11) {
TextView(
id = "sample_text_$it",
lparams = LayoutParams {
ImageView(
lparams = LayoutParams(50.dp, 50.dp) {
bottomMargin = 15.dp
}
) {
setImageResource(R.mipmap.ic_face_unhappy)
}
TextView(
lparams = LayoutParams {
bottomMargin = 25.dp
}
) {
text = stringResource(R.string.test_string)
textSize = 17.5f
}
}
ImageView(
lparams = LayoutParams(30.dp, 30.dp) {
bottomMargin = 15.dp
repeat(11) {
TextView(
id = "sample_text_$it",
lparams = LayoutParams {
bottomMargin = 15.dp
}
) {
text = stringResource(R.string.test_string)
textSize = 17.5f
}
}
ImageView(
lparams = LayoutParams(30.dp, 30.dp) {
bottomMargin = 15.dp
}
) {
setImageResource(Android_R.mipmap.sym_def_app_icon)
}
Button {
text = "Click Me!"
setOnClickListener { toast() }
}
) {
setImageResource(Android_R.mipmap.sym_def_app_icon)
}
Button {
text = "Click Me!"
setOnClickListener { toast() }
}
}
}

View File

@@ -1,6 +1,6 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.Default" parent="Theme.Material3.DayNight">
<style name="Theme.Default" parent="Theme.Material3.DayNight.NoActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/yuki_theme_color</item>
<item name="colorPrimaryVariant">@color/yuki_theme_color</item>

View File

@@ -1,4 +1,4 @@
<resources>
<string name="app_name">YukiHookDemoApp</string>
<string name="app_name">YukiHook App</string>
<string name="test_string">I am feel not good</string>
</resources>

View File

@@ -1,6 +1,6 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.Default" parent="Theme.Material3.DayNight">
<style name="Theme.Default" parent="Theme.Material3.DayNight.NoActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/yuki_theme_color</item>
<item name="colorPrimaryVariant">@color/yuki_theme_color</item>

View File

@@ -53,6 +53,9 @@ dependencies {
implementation(com.highcapable.hikage.hikage.extension)
implementation(com.highcapable.hikage.hikage.widget.androidx)
implementation(com.highcapable.hikage.hikage.widget.material)
implementation(com.highcapable.betterandroid.ui.component)
implementation(com.highcapable.betterandroid.ui.extension)
implementation(com.highcapable.betterandroid.system.extension)
implementation(androidx.preference.preference.ktx)
implementation(androidx.core.core.ktx)
implementation(androidx.appcompat.appcompat)

View File

@@ -50,6 +50,7 @@
<activity
android:name=".ui.PreferenceActivity"
android:exported="false" />
android:exported="false"
android:theme="@style/Theme.Default.ActionBar" />
</application>
</manifest>

View File

@@ -25,10 +25,10 @@ package com.highcapable.yukihookapi.demo_module.hook
import android.app.Activity
import android.content.Intent
import android.os.Build
import android.os.Bundle
import android.widget.Button
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.highcapable.betterandroid.system.extension.tool.SystemVersion
import com.highcapable.kavaref.KavaRef.Companion.resolve
import com.highcapable.kavaref.extension.ArrayClass
import com.highcapable.yukihookapi.YukiHookAPI
@@ -190,7 +190,7 @@ object HookEntry : IYukiHookXposedInit {
// Register Activity Proxy
// 注册模块 Activity 代理
onAppLifecycle {
onCreate { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) registerModuleAppActivities() }
onCreate { if (SystemVersion.isHighOrEqualsTo(SystemVersion.N)) registerModuleAppActivities() }
}
// Find Class to hook
// 得到需要 Hook 的 Class
@@ -288,7 +288,7 @@ object HookEntry : IYukiHookXposedInit {
.setTitle("Hooked")
.setMessage("I am hook your toast showing!")
.apply {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
if (SystemVersion.isHighOrEqualsTo(SystemVersion.N))
setPositiveButton("START PARASITIC") { _, _ ->
MaterialAlertDialogBuilder(context)
.setTitle("Start Parasitic")

View File

@@ -35,22 +35,22 @@ import com.highcapable.betterandroid.ui.extension.view.toast
import com.highcapable.betterandroid.ui.extension.view.updateMargins
import com.highcapable.hikage.extension.setContentView
import com.highcapable.hikage.widget.android.widget.Button
import com.highcapable.hikage.widget.android.widget.EditText
import com.highcapable.hikage.widget.android.widget.LinearLayout
import com.highcapable.hikage.widget.android.widget.TextView
import com.highcapable.hikage.widget.androidx.core.widget.NestedScrollView
import com.highcapable.hikage.widget.com.google.android.material.appbar.MaterialToolbar
import com.highcapable.hikage.widget.com.google.android.material.textfield.TextInputEditText
import com.highcapable.hikage.widget.com.google.android.material.textfield.TextInputLayout
import com.highcapable.yukihookapi.YukiHookAPI
import com.highcapable.yukihookapi.demo_module.R
import com.highcapable.yukihookapi.demo_module.data.DataConst
import com.highcapable.yukihookapi.demo_module.ui.base.BaseActivity
import com.highcapable.yukihookapi.hook.factory.dataChannel
import com.highcapable.yukihookapi.hook.factory.prefs
import com.highcapable.yukihookapi.hook.xposed.parasitic.activity.base.ModuleAppCompatActivity
import java.text.SimpleDateFormat
import java.util.Date
class MainActivity : ModuleAppCompatActivity() {
override val moduleTheme get() = R.style.Theme_Default
class MainActivity : BaseActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@@ -62,111 +62,129 @@ class MainActivity : ModuleAppCompatActivity() {
}
}
val hikage = setContentView {
NestedScrollView(
lparams = LayoutParams(matchParent = true),
LinearLayout(
lparams = LayoutParams(widthMatchParent = true),
init = {
isFillViewport = true
isVerticalScrollBarEnabled = false
orientation = LinearLayout.VERTICAL
}
) {
LinearLayout(
lparams = LayoutParams(widthMatchParent = true) {
updateMargins(vertical = 20.dp)
},
MaterialToolbar(
lparams = LayoutParams(widthMatchParent = true),
init = {
orientation = LinearLayout.VERTICAL
gravity = Gravity.CENTER
title = stringResource(R.string.app_name)
}
)
NestedScrollView(
lparams = LayoutParams(matchParent = true),
init = {
isFillViewport = true
isVerticalScrollBarEnabled = false
isVerticalFadingEdgeEnabled = true
}
) {
lateinit var editText: TextView
LinearLayout(
lparams = LayoutParams(widthMatchParent = true) {
updateMargins(horizontal = 50.dp)
updateMargins(bottom = 15.dp)
updateMargins(vertical = 20.dp)
},
init = {
orientation = LinearLayout.VERTICAL
gravity = Gravity.CENTER or Gravity.START
gravity = Gravity.CENTER
}
) {
repeat(6) { index ->
TextView(
id = "sample_title_text_$index",
lparams = LayoutParams {
bottomMargin = 5.dp
}
) {
textSize = 18f
isSingleLine = true
ellipsize = TextUtils.TruncateAt.END
lateinit var editText: TextView
LinearLayout(
lparams = LayoutParams(widthMatchParent = true) {
updateMargins(horizontal = 50.dp)
updateMargins(bottom = 15.dp)
},
init = {
orientation = LinearLayout.VERTICAL
gravity = Gravity.CENTER or Gravity.START
}
) {
repeat(6) { index ->
TextView(
id = "sample_title_text_$index",
lparams = LayoutParams {
bottomMargin = 5.dp
}
) {
textSize = 18f
isSingleLine = true
ellipsize = TextUtils.TruncateAt.END
gravity = Gravity.CENTER or Gravity.START
}
TextView(
id = "sample_subtitle_text_$index",
lparams = LayoutParams {
bottomMargin = if (index < 5) 15.dp else 25.dp
}
) {
alpha = 0.85f
textSize = 15f
isSingleLine = true
ellipsize = TextUtils.TruncateAt.END
gravity = Gravity.CENTER or Gravity.START
}
}
TextView(
id = "sample_subtitle_text_$index",
lparams = LayoutParams {
bottomMargin = if (index < 5) 15.dp else 25.dp
leftMargin = 5.dp
bottomMargin = 25.dp
}
) {
alpha = 0.85f
textSize = 15f
isSingleLine = true
ellipsize = TextUtils.TruncateAt.END
gravity = Gravity.CENTER or Gravity.START
text = "Leave something in there"
}
TextInputLayout(
lparams = LayoutParams(widthMatchParent = true)
) {
editText = TextInputEditText(
lparams = LayoutParams(widthMatchParent = true)
) {
hint = "Please enter the text"
isSingleLine = true
textSize = 18f
hostEnvironment { isEnabled = false }
setText(prefs().get(DataConst.TEST_KV_DATA))
}
}
}
Button(
lparams = LayoutParams {
bottomMargin = 15.dp
}
) {
text = "Save Test Data"
hostEnvironment { isEnabled = false }
setOnClickListener { _ ->
moduleEnvironment {
if (editText.textToString().isNotEmpty()) {
prefs().edit { put(DataConst.TEST_KV_DATA, editText.textToString()) }
toast("Saved")
} else toast("Please enter the text")
}
}
}
Button {
text = "Open PreferenceFragment"
setOnClickListener { startActivity<PreferenceActivity>() }
}
TextView(
lparams = LayoutParams {
leftMargin = 5.dp
bottomMargin = 25.dp
topMargin = 25.dp
}
) {
textSize = 15f
alpha = 0.45f
textSize = 13f
isSingleLine = true
ellipsize = TextUtils.TruncateAt.END
gravity = Gravity.CENTER or Gravity.START
text = "Leave something in there"
text = "Compiled Time${SimpleDateFormat.getDateTimeInstance().format(Date(YukiHookAPI.Status.compiledTimestamp))}"
}
editText = EditText(
lparams = LayoutParams(width = 250.dp)
) {
hint = "Please enter the text"
isSingleLine = true
textSize = 18f
hostEnvironment { isEnabled = false }
setText(prefs().get(DataConst.TEST_KV_DATA))
}
}
Button(
lparams = LayoutParams {
bottomMargin = 15.dp
}
) {
text = "Save Test Data"
hostEnvironment { isEnabled = false }
setOnClickListener { _ ->
moduleEnvironment {
if (editText.textToString().isNotEmpty()) {
prefs().edit { put(DataConst.TEST_KV_DATA, editText.textToString()) }
toast("Saved")
} else toast("Please enter the text")
}
}
}
Button {
text = "Open PreferenceFragment"
setOnClickListener { startActivity<PreferenceActivity>() }
}
TextView(
lparams = LayoutParams {
topMargin = 25.dp
}
) {
alpha = 0.45f
textSize = 13f
isSingleLine = true
ellipsize = TextUtils.TruncateAt.END
gravity = Gravity.CENTER or Gravity.START
text = "Compiled Time${SimpleDateFormat.getDateTimeInstance().format(Date(YukiHookAPI.Status.compiledTimestamp))}"
}
}
}

View File

@@ -25,12 +25,12 @@ import android.os.Bundle
import androidx.preference.SwitchPreference
import com.highcapable.yukihookapi.YukiHookAPI
import com.highcapable.yukihookapi.demo_module.R
import com.highcapable.yukihookapi.hook.xposed.parasitic.activity.base.ModuleAppCompatActivity
import com.highcapable.yukihookapi.demo_module.ui.base.BaseActivity
import com.highcapable.yukihookapi.hook.xposed.prefs.ui.ModulePreferenceFragment
class PreferenceActivity : ModuleAppCompatActivity() {
class PreferenceActivity : BaseActivity() {
override val moduleTheme get() = R.style.Theme_Default
override val moduleTheme get() = R.style.Theme_Default_ActionBar
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

View File

@@ -0,0 +1,50 @@
/*
* YukiHookAPI - An efficient Hook API and Xposed Module solution built in Kotlin.
* Copyright (C) 2019 HighCapable
* https://github.com/HighCapable/YukiHookAPI
*
* Apache License Version 2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* This file is created by fankes on 2025/6/18.
*/
package com.highcapable.yukihookapi.demo_module.ui.base
import android.content.res.Configuration
import android.os.Bundle
import com.highcapable.betterandroid.ui.component.activity.AppViewsActivity
import com.highcapable.yukihookapi.demo_module.R
import com.highcapable.yukihookapi.hook.xposed.parasitic.activity.proxy.ModuleActivity
abstract class BaseActivity : AppViewsActivity(), ModuleActivity {
override val moduleTheme get() = R.style.Theme_Default
override fun getClassLoader() = delegate.getClassLoader()
override fun onCreate(savedInstanceState: Bundle?) {
delegate.onCreate(savedInstanceState)
super.onCreate(savedInstanceState)
}
override fun onConfigurationChanged(newConfig: Configuration) {
delegate.onConfigurationChanged(newConfig)
super.onConfigurationChanged(newConfig)
}
override fun onRestoreInstanceState(savedInstanceState: Bundle) {
delegate.onRestoreInstanceState(savedInstanceState)
super.onRestoreInstanceState(savedInstanceState)
}
}

View File

@@ -1,6 +1,6 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.Default" parent="Theme.Material3.DayNight">
<style name="Theme.Default" parent="Theme.Material3.DayNight.NoActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/yuki_theme_color</item>
<item name="colorPrimaryVariant">@color/yuki_theme_color</item>

View File

@@ -1,3 +1,3 @@
<resources>
<string name="app_name">YukiHookDemoModule</string>
<string name="app_name">YukiHook Module</string>
</resources>

View File

@@ -1,6 +1,6 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.Default" parent="Theme.Material3.DayNight">
<style name="Theme.Default" parent="Theme.Material3.DayNight.NoActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/yuki_theme_color</item>
<item name="colorPrimaryVariant">@color/yuki_theme_color</item>
@@ -16,4 +16,11 @@
<!-- Customize your theme here. -->
<item name="android:windowSplashScreenAnimatedIcon" tools:targetApi="s">@mipmap/ic_launcher</item>
</style>
<style name="Theme.Default.ActionBar" parent="Theme.Material3.DayNight">
<!-- Status bar color. -->
<item name="android:statusBarColor">@color/yuki_light_color</item>
<item name="android:navigationBarColor">@android:color/background_light</item>
<item name="android:windowLightStatusBar" tools:targetApi="m">true</item>
</style>
</resources>