docs: update to new usage

This commit is contained in:
2023-10-03 04:17:25 +08:00
parent 375b2f3398
commit 6e658baf17
18 changed files with 649 additions and 681 deletions

View File

@@ -37,12 +37,11 @@ After the Host App is hooked, we can directly inject the `Context` obtained in t
> The following example
```kotlin
injectMember {
method {
name = "onCreate"
param(BundleClass)
}
afterHook {
method {
name = "onCreate"
param(BundleClass)
}.hook {
after {
instance<Activity>().also {
// <Scenario 1> Inject Module App's Resources through Context
it.injectModuleAppResources()
@@ -91,12 +90,11 @@ After the Host App is hooked, we can directly register the `Activity` proxy of t
> The following example
```kotlin
injectMember {
method {
name = "onCreate"
param(BundleClass)
}
afterHook {
method {
name = "onCreate"
param(BundleClass)
}.hook {
after {
instance<Activity>().registerModuleAppActivities()
}
}
@@ -238,12 +236,11 @@ At this time, we want to use `MaterialAlertDialogBuilder` to create a dialog in
> The following example
```kotlin
injectMember {
method {
name = "onCreate"
param(BundleClass)
}
afterHook {
method {
name = "onCreate"
param(BundleClass)
}.hook {
after {
// Use applyModuleTheme to create a theme resource in the current Module App
val appCompatContext = instance<Activity>().applyModuleTheme(R.style.Theme_AppCompat)
// Directly use this Context that wraps the Module App's theme to create a dialog
@@ -263,12 +260,11 @@ Which requires at least Android 10 and above system version support and the curr
> The following example
```kotlin
injectMember {
method {
name = "onCreate"
param(BundleClass)
}
afterHook {
method {
name = "onCreate"
param(BundleClass)
}.hook {
after {
// Define the theme resource in the current Module App
var appCompatContext: ModuleContextThemeWrapper
// <Scenario 1> Get the Configuration object directly to set

View File

@@ -1298,15 +1298,12 @@ Here's how the `getString` method in this `Class` Hooks.
> The following example
```kotlin
Test::class.java.hook {
injectMember {
method {
name = "getString"
emptyParam()
returnType = StringClass
}
replaceTo("Hooked")
}
Test::class.java.method {
name = "getString"
emptyParam()
returnType = StringClass
}.hook {
replaceTo("Hooked")
}
```
@@ -1447,34 +1444,8 @@ Test::class.java.method {
}
```
Take the current `Class` as an example, if [Multiple Find](#multiple-find) is used in conjunction with `RemedyPlan` when creating a Hook, you need to change the usage slightly.
> The following example
```kotlin
injectMember {
method {
name = "doTask"
emptyParam()
}.remedys {
method {
name = "doTask"
paramCount(0..1)
}
method {
name = "doTask"
paramCount(1..2)
}
}.all()
beforeHook {}
afterHook {}
}
```
::: tip
When creating a Hook, please refer to [MethodFinder.Process.all](../public/com/highcapable/yukihookapi/hook/core/finder/members/MethodFinder#all-method), [ConstructorFinder.Process.all]( ../public/com/highcapable/yukihookapi/hook/core/finder/members/ConstructorFinder#all-method) methods.
For more functions, please refer to [MethodFinder.RemedyPlan](../public/com/highcapable/yukihookapi/hook/core/finder/members/MethodFinder#remedyplan-class), [ConstructorFinder.RemedyPlan](../public/com/highcapable/yukihookapi/hook/core/finder/members/ConstructorFinder#remedyplan-class), [FieldFinder.RemedyPlan](../public/com/highcapable/yukihookapi/hook/core/finder/members/FieldFinder#remedyplan-class) .
:::