Skip to content

Commit

Permalink
Merge pull request #42 from FlyJingFish/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
FlyJingFish authored Nov 18, 2024
2 parents 3ad4c76 + bb0090a commit dbef3a0
Show file tree
Hide file tree
Showing 14 changed files with 133 additions and 51 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
plugins {
//必须项 👇 apply 设置为 true 自动为所有module“预”配置debugMode,false则按下边步骤五的方式二
id "io.github.FlyJingFish.AndroidAop.android-aop" version "2.2.7" apply true
id "io.github.FlyJingFish.AndroidAop.android-aop" version "2.2.8" apply true
}
```
<details>
Expand All @@ -134,7 +134,7 @@
buildscript {
dependencies {
//必须项 👇
classpath 'io.github.FlyJingFish.AndroidAop:android-aop-plugin:2.2.7'
classpath 'io.github.FlyJingFish.AndroidAop:android-aop-plugin:2.2.8'
}
}
// 👇加上这句自动为所有module“预”配置debugMode,不加则按下边步骤五的方式二
Expand Down Expand Up @@ -189,7 +189,7 @@
//必须项 👇
plugins {
...
id "io.github.FlyJingFish.AndroidAop.android-aop" version "2.2.7"//最好放在最后一行
id "io.github.FlyJingFish.AndroidAop.android-aop" version "2.2.8"//最好放在最后一行
}
```

Expand All @@ -215,18 +215,18 @@ plugins {
dependencies {
//必须项 👇
implementation 'io.github.FlyJingFish.AndroidAop:android-aop-core:2.2.7'
implementation 'io.github.FlyJingFish.AndroidAop:android-aop-core:2.2.8'
//非必须项 👇这个包提供了一些常见的注解切面
implementation 'io.github.FlyJingFish.AndroidAop:android-aop-extra:2.2.7'
implementation 'io.github.FlyJingFish.AndroidAop:android-aop-extra:2.2.8'
//必须项 👇如果您项目内已经有了这项不用加也可以
implementation 'androidx.appcompat:appcompat:1.3.0' // 至少在1.3.0及以上
//非必须项 👇,如果你想自定义切面需要用到,⚠️支持Java和Kotlin代码写的切面
ksp 'io.github.FlyJingFish.AndroidAop:android-aop-ksp:2.2.7'
ksp 'io.github.FlyJingFish.AndroidAop:android-aop-ksp:2.2.8'
//非必须项 👇,如果你想自定义切面需要用到,⚠️只适用于Java代码写的切面
annotationProcessor 'io.github.FlyJingFish.AndroidAop:android-aop-processor:2.2.7'
annotationProcessor 'io.github.FlyJingFish.AndroidAop:android-aop-processor:2.2.8'
//⚠️上边的 android-aop-ksp 和 android-aop-processor 二选一
}
```
Expand Down
14 changes: 7 additions & 7 deletions README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ Depend on the plug-in in <code>build.gradle</code> in the <strong>project root d
plugins {
//Required item 👇 apply is set to true to automatically apply debugMode to all modules, if false, follow step 5 below.
id "io.github.FlyJingFish.AndroidAop.android-aop" version "2.2.7" apply true
id "io.github.FlyJingFish.AndroidAop.android-aop" version "2.2.8" apply true
}
```
<details>
Expand All @@ -131,7 +131,7 @@ Depend on the plug-in in <code>build.gradle</code> in the <strong>project root d
buildscript {
dependencies {
//Required items 👇
classpath 'io.github.FlyJingFish.AndroidAop:android-aop-plugin:2.2.7'
classpath 'io.github.FlyJingFish.AndroidAop:android-aop-plugin:2.2.8'
}
}
//👇Add this sentence to automatically apply debugMode to all modules. If not, follow step 5 below.
Expand Down Expand Up @@ -179,7 +179,7 @@ Depend on the plug-in in <code>build.gradle</code> in the <strong>project root d
//Required items 👇
plugins {
...
id "io.github.FlyJingFish.AndroidAop.android-aop" version "2.2.7"
id "io.github.FlyJingFish.AndroidAop.android-aop" version "2.2.8"
}
```

Expand Down Expand Up @@ -209,17 +209,17 @@ plugins {
dependencies {
//Required items 👇
implementation 'io.github.FlyJingFish.AndroidAop:android-aop-core:2.2.7'
implementation 'io.github.FlyJingFish.AndroidAop:android-aop-core:2.2.8'
//Optional 👇This package provides some common annotation aspects
implementation 'io.github.FlyJingFish.AndroidAop:android-aop-extra:2.2.7'
implementation 'io.github.FlyJingFish.AndroidAop:android-aop-extra:2.2.8'
//Required item 👇If you already have this item in your project, you don’t need to add it.
implementation 'androidx.appcompat:appcompat:1.3.0' // At least in 1.3.0 and above
//Optional 👇, if you want to customize aspects, you need to use them, ⚠️supports aspects written in Java and Kotlin code
ksp 'io.github.FlyJingFish.AndroidAop:android-aop-ksp:2.2.7'
ksp 'io.github.FlyJingFish.AndroidAop:android-aop-ksp:2.2.8'
//Optional 👇, if you want to customize aspects, you need to use them, ⚠️only applies to aspects written in Java code
annotationProcessor 'io.github.FlyJingFish.AndroidAop:android-aop-processor:2.2.7'
annotationProcessor 'io.github.FlyJingFish.AndroidAop:android-aop-processor:2.2.8'
//⚠️Choose one of the above android-aop-ksp and android-aop-processor
}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ class MethodReplaceInvokeAdapter(private val className:String,private val superN
descriptor: String,
isInterface: Boolean
) {
val isInMethodInner = opcode == Opcodes.INVOKESPECIAL && owner == superName && name == methodName && descriptor == methodDesc

var replaceMethodInfo = getReplaceInfo(owner, name, "")
var isReplaceClass = replaceMethodInfo != null && replaceMethodInfo.replaceType == ReplaceMethodInfo.ReplaceType.NEW && replaceMethodInfo.newClassName.isNotEmpty()
if (!isReplaceClass){
Expand Down Expand Up @@ -91,10 +93,16 @@ class MethodReplaceInvokeAdapter(private val className:String,private val superN
} else {
descriptor.replace("(", "(L${replaceMethodInfo.oldOwner};") == replaceMethodInfo.newMethodDesc || descriptor.replace("(", "(Ljava/lang/Object;") == replaceMethodInfo.newMethodDesc
}
if (shouldReplace) {
if (shouldReplace && !isInMethodInner) {
val isThisInit = owner == className && methodName == "<init>" && methodName == name
val isInitAop = replaceMethodInfo.replaceType == ReplaceMethodInfo.ReplaceType.INIT
if (isInitAop && isThisInit){
super.visitMethodInsn(opcode, owner, name, descriptor, isInterface)
return
}
if (replaceMethodInfo.replaceType == ReplaceMethodInfo.ReplaceType.NEW && replaceMethodInfo.isCallNew()) {
super.visitMethodInsn(opcode, replaceMethodInfo.newClassName, name, descriptor, isInterface)
}else if (replaceMethodInfo.replaceType == ReplaceMethodInfo.ReplaceType.INIT) {
}else if (isInitAop) {
super.visitMethodInsn(opcode, owner, name, descriptor, isInterface)
}
InitConfig.addReplaceMethodInfo(replaceMethodInfo)
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/com/flyjingfish/androidaop/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import com.flyjingfish.androidaop.test2.StaticClass
import com.flyjingfish.androidaop.test.TestBean
import com.flyjingfish.test_lib.mycut.TestParams
import com.flyjingfish.androidaop.test.TestReplace
import com.flyjingfish.androidaop.testReplace.BaseBean
import com.flyjingfish.test_lib.BaseActivity
import com.flyjingfish.test_lib.annotation.MyAnno3
import com.flyjingfish.test_lib.PermissionRejectListener
Expand Down Expand Up @@ -76,6 +77,8 @@ class MainActivity: BaseActivity2(), PermissionRejectListener{
}

})
val bbean = BaseBean(0,0)
bbean.test()
// binding.btnIOThread.setOnClickListener {
// onIOThread()
// }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.flyjingfish.androidaop.testReplace;

public class BaseBean {
int num1;
int num2;

public BaseBean(int num1, int num2) {
this.num1 = num1;
this.num2 = num2;
}

public BaseBean(int num1) {
this(num1,0);
}

public void test(){

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.flyjingfish.androidaop.testReplace;

public class BeanH extends BaseBean{
public BeanH(int num1, int num2) {
super(num1, num2);
}

@Override
public void test() {
super.test();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.flyjingfish.androidaop.testReplace

import com.flyjingfish.android_aop_annotation.anno.AndroidAopReplaceClass
import com.flyjingfish.android_aop_annotation.anno.AndroidAopReplaceMethod

//@AndroidAopReplaceClass("com.flyjingfish.androidaop.testReplace.BaseBean")
object ReplaceBaseBean {
@AndroidAopReplaceMethod("<init>(int,int)")
@JvmStatic
fun getBaseBean(testBean: BaseBean) : BaseBean {
return testBean
}

@AndroidAopReplaceMethod("void test()")
@JvmStatic
fun test(testBean: BaseBean){
testBean.test()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.flyjingfish.androidaop.testReplace;

import android.util.Log;

import com.flyjingfish.android_aop_annotation.anno.AndroidAopReplaceClass;
import com.flyjingfish.android_aop_annotation.anno.AndroidAopReplaceMethod;

@AndroidAopReplaceClass("com.flyjingfish.androidaop.testReplace.BaseBean")
public class ReplaceBaseBean2 {
@AndroidAopReplaceMethod("<init>(int,int)")
public static BaseBean getBaseBean(BaseBean testBean) {
Log.e("ReplaceBaseBean2","getBaseBean");
return testBean;
}

@AndroidAopReplaceMethod("void test()")
public static void test(BaseBean testBean){
Log.e("ReplaceBaseBean2","test");
testBean.test();
}
}
4 changes: 2 additions & 2 deletions docs/android_aop_extra.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
```groovy
dependencies {
//Optional 👇This package provides some common annotation aspects
implementation "io.github.FlyJingFish.AndroidAop:android-aop-extra:2.2.7"
implementation "io.github.FlyJingFish.AndroidAop:android-aop-extra:2.2.8"
}
```

Expand All @@ -15,7 +15,7 @@
```kotlin
dependencies {
//Optional 👇This package provides some common annotation aspects
implementation("io.github.FlyJingFish.AndroidAop:android-aop-extra:2.2.7")
implementation("io.github.FlyJingFish.AndroidAop:android-aop-extra:2.2.8")
}
```

Expand Down
28 changes: 14 additions & 14 deletions docs/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Depend on the plug-in in `build.gradle` in the **project root directory**
plugins {
//👇Required item (1)👈 apply is set to true to automatically apply debugMode to all modules, if false, follow step 5 below.
id "io.github.FlyJingFish.AndroidAop.android-aop" version "2.2.7" apply true
id "io.github.FlyJingFish.AndroidAop.android-aop" version "2.2.8" apply true
}
```

Expand All @@ -40,7 +40,7 @@ Depend on the plug-in in `build.gradle` in the **project root directory**
buildscript {
dependencies {
//👇equired items (1)👈
classpath "io.github.FlyJingFish.AndroidAop:android-aop-plugin:2.2.7"
classpath "io.github.FlyJingFish.AndroidAop:android-aop-plugin:2.2.8"
}
}
//👇Add this sentence to automatically apply debugMode to all modules. If not, follow step 5 below.
Expand All @@ -56,7 +56,7 @@ Depend on the plug-in in `build.gradle` in the **project root directory**
plugins {
//👇Required item (1)👈 apply is set to true to automatically apply debugMode to all modules, if false, follow step 5 below.
id("io.github.FlyJingFish.AndroidAop.android-aop") version "2.2.7" apply true
id("io.github.FlyJingFish.AndroidAop.android-aop") version "2.2.8" apply true
}
```

Expand All @@ -68,7 +68,7 @@ Depend on the plug-in in `build.gradle` in the **project root directory**
buildscript {
dependencies {
//👇Required items (1)👈
classpath("io.github.FlyJingFish.AndroidAop:android-aop-plugin:2.2.7")
classpath("io.github.FlyJingFish.AndroidAop:android-aop-plugin:2.2.8")
}
}
//👇Add this sentence to automatically apply debugMode to all modules. If not, follow step 5 below.
Expand Down Expand Up @@ -136,7 +136,7 @@ Add in `build.gradle` of **app**
//Required items 👇
plugins {
...
id "io.github.FlyJingFish.AndroidAop.android-aop" version "2.2.7"
id "io.github.FlyJingFish.AndroidAop.android-aop" version "2.2.8"
}
```

Expand All @@ -146,7 +146,7 @@ Add in `build.gradle` of **app**
//Required items 👇
plugins {
...
id("io.github.FlyJingFish.AndroidAop.android-aop") version "2.2.7"
id("io.github.FlyJingFish.AndroidAop.android-aop") version "2.2.8"
}
```

Expand Down Expand Up @@ -189,17 +189,17 @@ Add in `build.gradle` of **app**

dependencies {
//👇Required items
implementation "io.github.FlyJingFish.AndroidAop:android-aop-core:2.2.7"
implementation "io.github.FlyJingFish.AndroidAop:android-aop-core:2.2.8"
//👇Optional (1)👈 This package provides some common annotation aspects
implementation "io.github.FlyJingFish.AndroidAop:android-aop-extra:2.2.7"
implementation "io.github.FlyJingFish.AndroidAop:android-aop-extra:2.2.8"
//👇Required item If you already have this item in your project, you don’t need to add it.
implementation "androidx.appcompat:appcompat:1.3.0" // At least in 1.3.0 and above
//👇Optional (2)👈Click + to view detailed description, ⚠️supports aspects written in Java and Kotlin code
ksp "io.github.FlyJingFish.AndroidAop:android-aop-ksp:2.2.7"
ksp "io.github.FlyJingFish.AndroidAop:android-aop-ksp:2.2.8"
//👇Optional (3)👈Click + to view detailed description, ⚠️only applies to aspects written in Java code
annotationProcessor "io.github.FlyJingFish.AndroidAop:android-aop-processor:2.2.7"
annotationProcessor "io.github.FlyJingFish.AndroidAop:android-aop-processor:2.2.8"
//⚠️Choose one of the above android-aop-ksp and android-aop-processor
}
```
Expand All @@ -218,17 +218,17 @@ Add in `build.gradle` of **app**

dependencies {
//👇Required items
implementation("io.github.FlyJingFish.AndroidAop:android-aop-core:2.2.7")
implementation("io.github.FlyJingFish.AndroidAop:android-aop-core:2.2.8")
//👇Optional (1)👈 This package provides some common annotation aspects
implementation("io.github.FlyJingFish.AndroidAop:android-aop-extra:2.2.7")
implementation("io.github.FlyJingFish.AndroidAop:android-aop-extra:2.2.8")

//👇Required item If you already have this item in your project, you don’t need to add it.
implementation("androidx.appcompat:appcompat:1.3.0") // At least in 1.3.0 and above

//👇Optional (2)👈Click + to view detailed description, ⚠️supports aspects written in Java and Kotlin code
ksp("io.github.FlyJingFish.AndroidAop:android-aop-ksp:2.2.7")
ksp("io.github.FlyJingFish.AndroidAop:android-aop-ksp:2.2.8")
//👇Optional (3)👈Click + to view detailed description, ⚠️only applies to aspects written in Java code
annotationProcessor("io.github.FlyJingFish.AndroidAop:android-aop-processor:2.2.7")
annotationProcessor("io.github.FlyJingFish.AndroidAop:android-aop-processor:2.2.8")
//⚠️Choose one of the above android-aop-ksp and android-aop-processor
}
```
Expand Down
4 changes: 2 additions & 2 deletions docs/zh/android_aop_extra.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
```groovy
dependencies {
//非必须项 👇这个包提供了一些常见的注解切面
implementation "io.github.FlyJingFish.AndroidAop:android-aop-extra:2.2.7"
implementation "io.github.FlyJingFish.AndroidAop:android-aop-extra:2.2.8"
}
```

Expand All @@ -15,7 +15,7 @@
```kotlin
dependencies {
//非必须项 👇这个包提供了一些常见的注解切面
implementation("io.github.FlyJingFish.AndroidAop:android-aop-extra:2.2.7")
implementation("io.github.FlyJingFish.AndroidAop:android-aop-extra:2.2.8")
}
```

Expand Down
Loading

0 comments on commit dbef3a0

Please sign in to comment.