-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
210 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
plugins { | ||
id 'com.android.library' | ||
} | ||
|
||
android { | ||
compileSdkVersion 33 | ||
|
||
defaultConfig { | ||
minSdkVersion 19 | ||
targetSdkVersion 33 | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
consumerProguardFiles "consumer-rules.pro" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
} | ||
|
||
dependencies { | ||
|
||
implementation 'androidx.appcompat:appcompat:1.2.0' | ||
implementation 'com.google.android.material:material:1.2.0' | ||
testImplementation 'junit:junit:4.13.2' | ||
androidTestImplementation 'androidx.test.ext:junit:1.1.5' | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' | ||
api "androidx.startup:startup-runtime:1.1.0" | ||
api 'org.aspectj:aspectjrt:1.9.5' | ||
api 'com.github.hss01248.aop-android:logforaop:1.0.2' | ||
api 'com.blankj:utilcodex:1.30.0' | ||
implementation 'com.github.hss01248.utilcodeEnhance:sentry:1.3.5' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
-keep class com.blankj.utilcode.** { *; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
26 changes: 26 additions & 0 deletions
26
aop-utilcode/src/androidTest/java/com/hss01248/aop/utilcode/ExampleInstrumentedTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.hss01248.aop.utilcode; | ||
|
||
import android.content.Context; | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry; | ||
import androidx.test.ext.junit.runners.AndroidJUnit4; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a> | ||
*/ | ||
@RunWith(AndroidJUnit4.class) | ||
public class ExampleInstrumentedTest { | ||
@Test | ||
public void useAppContext() { | ||
// Context of the app under test. | ||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); | ||
assertEquals("com.hss01248.aop.utilcode.test", appContext.getPackageName()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.hss01248.aop.utilcode"> | ||
|
||
</manifest> |
65 changes: 65 additions & 0 deletions
65
aop-utilcode/src/main/java/com/hss01248/aop/utilcode/AspectLogUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package com.hss01248.aop.utilcode; | ||
|
||
|
||
import com.blankj.utilcode.util.LogUtils; | ||
import com.hss01248.sentry.SentryUtil; | ||
|
||
import org.aspectj.lang.JoinPoint; | ||
import org.aspectj.lang.annotation.Aspect; | ||
import org.aspectj.lang.annotation.Before; | ||
|
||
@Aspect | ||
public class AspectLogUtils { | ||
|
||
/** | ||
* log(final int type, final String tag, final Object... contents) | ||
* @param joinPoint | ||
* @return | ||
* @throws Throwable | ||
*/ | ||
@Before("execution(* com.blankj.utilcode.util.LogUtils.log(..))") | ||
public void weaveJoinPoint(JoinPoint joinPoint) throws Throwable { | ||
int type = (int) joinPoint.getArgs()[0]; | ||
if(type < LogUtils.W){ | ||
return; | ||
} | ||
Object[] objects= (Object[]) joinPoint.getArgs()[2]; | ||
if(objects == null || objects.length ==0){ | ||
return; | ||
} | ||
SentryUtil.Builder builder = SentryUtil.create(); | ||
boolean hasThrowable = false; | ||
int count = 0; | ||
for (Object object : objects) { | ||
if(object instanceof Throwable){ | ||
hasThrowable = true; | ||
Throwable throwable = (Throwable) object; | ||
builder.exception(throwable); | ||
}else { | ||
count++; | ||
builder.addExtra("extra"+count,object+""); | ||
} | ||
} | ||
String typeStr = "warn"; | ||
if(type == LogUtils.E){ | ||
typeStr = "error"; | ||
}else if(type == LogUtils.A){ | ||
typeStr = "assert"; | ||
}else if(type == LogUtils.W){ | ||
typeStr = "warn"; | ||
}else { | ||
typeStr = type+""; | ||
} | ||
builder.addTag("logLevel",typeStr); | ||
if(hasThrowable){ | ||
// builder.addExtra("extraMsg",joinPoint.getArgs()[0]+""); | ||
}else { | ||
builder.msg(objects[0]+""); | ||
} | ||
String tag = joinPoint.getArgs()[1]+""; | ||
if(!tag.equals("") && !"null".equals(tag)){ | ||
builder.addTag("extraTag",joinPoint.getArgs()[1]+""); | ||
} | ||
builder.doReport(); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
aop-utilcode/src/test/java/com/hss01248/aop/utilcode/ExampleUnitTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.hss01248.aop.utilcode; | ||
|
||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Example local unit test, which will execute on the development machine (host). | ||
* | ||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a> | ||
*/ | ||
public class ExampleUnitTest { | ||
@Test | ||
public void addition_isCorrect() { | ||
assertEquals(4, 2 + 2); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters