mirror of
https://github.com/HighCapable/YukiHookAPI.git
synced 2025-09-04 01:35:17 +08:00
feat: update demo
This commit is contained in:
@@ -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)
|
||||
|
@@ -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,20 +36,34 @@ 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 {
|
||||
LinearLayout(
|
||||
lparams = LayoutParams(widthMatchParent = true),
|
||||
init = {
|
||||
orientation = LinearLayout.VERTICAL
|
||||
}
|
||||
) {
|
||||
MaterialToolbar(
|
||||
lparams = LayoutParams(widthMatchParent = true),
|
||||
init = {
|
||||
title = stringResource(R.string.app_name)
|
||||
}
|
||||
)
|
||||
NestedScrollView(
|
||||
lparams = LayoutParams(matchParent = true),
|
||||
init = {
|
||||
isFillViewport = true
|
||||
isVerticalScrollBarEnabled = false
|
||||
isVerticalFadingEdgeEnabled = true
|
||||
}
|
||||
) {
|
||||
LinearLayout(
|
||||
@@ -101,6 +115,7 @@ class MainActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
hikage.get<TextView>("sample_text_0").text = getFirstText()
|
||||
hikage.get<TextView>("sample_text_1").text = secondText
|
||||
hikage.get<TextView>("sample_text_2").text = Main("Feel real").getString()
|
||||
|
@@ -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>
|
||||
|
@@ -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>
|
@@ -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>
|
||||
|
@@ -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)
|
||||
|
@@ -50,6 +50,7 @@
|
||||
|
||||
<activity
|
||||
android:name=".ui.PreferenceActivity"
|
||||
android:exported="false" />
|
||||
android:exported="false"
|
||||
android:theme="@style/Theme.Default.ActionBar" />
|
||||
</application>
|
||||
</manifest>
|
@@ -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")
|
||||
|
@@ -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,11 +62,24 @@ class MainActivity : ModuleAppCompatActivity() {
|
||||
}
|
||||
}
|
||||
val hikage = setContentView {
|
||||
LinearLayout(
|
||||
lparams = LayoutParams(widthMatchParent = true),
|
||||
init = {
|
||||
orientation = LinearLayout.VERTICAL
|
||||
}
|
||||
) {
|
||||
MaterialToolbar(
|
||||
lparams = LayoutParams(widthMatchParent = true),
|
||||
init = {
|
||||
title = stringResource(R.string.app_name)
|
||||
}
|
||||
)
|
||||
NestedScrollView(
|
||||
lparams = LayoutParams(matchParent = true),
|
||||
init = {
|
||||
isFillViewport = true
|
||||
isVerticalScrollBarEnabled = false
|
||||
isVerticalFadingEdgeEnabled = true
|
||||
}
|
||||
) {
|
||||
LinearLayout(
|
||||
@@ -126,8 +139,11 @@ class MainActivity : ModuleAppCompatActivity() {
|
||||
gravity = Gravity.CENTER or Gravity.START
|
||||
text = "Leave something in there"
|
||||
}
|
||||
editText = EditText(
|
||||
lparams = LayoutParams(width = 250.dp)
|
||||
TextInputLayout(
|
||||
lparams = LayoutParams(widthMatchParent = true)
|
||||
) {
|
||||
editText = TextInputEditText(
|
||||
lparams = LayoutParams(widthMatchParent = true)
|
||||
) {
|
||||
hint = "Please enter the text"
|
||||
isSingleLine = true
|
||||
@@ -136,6 +152,7 @@ class MainActivity : ModuleAppCompatActivity() {
|
||||
setText(prefs().get(DataConst.TEST_KV_DATA))
|
||||
}
|
||||
}
|
||||
}
|
||||
Button(
|
||||
lparams = LayoutParams {
|
||||
bottomMargin = 15.dp
|
||||
@@ -171,6 +188,7 @@ class MainActivity : ModuleAppCompatActivity() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
hikage.get<TextView>("sample_title_text_0").text = "Module is Active: ${YukiHookAPI.Status.isModuleActive}"
|
||||
hikage.get<TextView>("sample_subtitle_text_0").text = "Xposed 模块激活状态"
|
||||
hikage.get<TextView>("sample_title_text_1").text = "Hook Framework: ${YukiHookAPI.Status.Executor.name}"
|
||||
|
@@ -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)
|
||||
|
@@ -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)
|
||||
}
|
||||
}
|
@@ -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>
|
||||
|
@@ -1,3 +1,3 @@
|
||||
<resources>
|
||||
<string name="app_name">YukiHookDemoModule</string>
|
||||
<string name="app_name">YukiHook Module</string>
|
||||
</resources>
|
@@ -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>
|
Reference in New Issue
Block a user