├── .gitignore
├── CHANGELOG.md
├── README.md
├── _config.yml
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── tech
│ │ └── saymagic
│ │ └── daffodil
│ │ └── demo
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── tech
│ │ │ └── saymagic
│ │ │ └── daffodil
│ │ │ └── demo
│ │ │ └── MainActivity.java
│ └── res
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── tech
│ └── saymagic
│ └── daffodil
│ └── demo
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── lib
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── tech
│ │ └── saymagic
│ │ └── daffodil
│ │ └── lib
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── tech
│ │ │ └── saymagic
│ │ │ └── daffodil
│ │ │ └── lib
│ │ │ ├── Daffodil.java
│ │ │ ├── DaffodilPrinter.java
│ │ │ ├── MethodInfo.java
│ │ │ └── MethodRemember.java
│ └── res
│ │ └── values
│ │ └── strings.xml
│ └── test
│ └── java
│ └── tech
│ └── saymagic
│ └── daffodil
│ └── lib
│ └── ExampleUnitTest.java
├── plugin
├── .gitignore
├── build.gradle
└── src
│ └── main
│ ├── groovy
│ └── tech
│ │ └── saymagic
│ │ └── daffodil
│ │ └── plugin
│ │ ├── ClassGuard.groovy
│ │ ├── ClassUtils.groovy
│ │ ├── Constants.groovy
│ │ ├── DaffodilExtension.groovy
│ │ ├── DaffodilPlugin.groovy
│ │ ├── asm
│ │ ├── DaffodilClassVisiter.groovy
│ │ └── DaffodilMethodVisitor.groovy
│ │ └── transform
│ │ └── DaffodilTransform.groovy
│ └── resources
│ └── META-INF
│ └── gradle-plugins
│ └── tech.saymagic.daffodil.properties
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea
5 | .DS_Store
6 | /build
7 | /captures
8 | .externalNativeBuild
9 | publishToJcenter.sh
10 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## 2017-07-14
2 | Support Library - v1.1.0
3 |
4 | ## 2017-06-17
5 | Init - v1.0.0
6 |
7 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Daffodil
2 | ===
3 |
4 | Daffodil is an Annotation-triggered method call logging library.
5 |
6 | Usage
7 | ---------
8 |
9 |
10 | 1. Add daffodil closure in `build.gradle`
11 |
12 | ```
13 |
14 | daffodil {
15 | enabled true
16 | }
17 |
18 | ```
19 |
20 | 2. Add `@ Daffodil` Annotation on methods, method call's detail info will automatically be recorded.
21 |
22 | ```
23 | @Daffodil
24 | public int max(int a, int b) {
25 | return Math.max(a, b);
26 | }
27 | ```
28 |
29 | As the method max invoked, log is printed like following:
30 |
31 | ```
32 | I/MainActivity: max(1607348716,366634143) = 1607348716 {1ms, main}
33 | ```
34 |
35 | 3. Enable/Disable daffodil in runtime
36 |
37 | ```
38 | DaffodilPrinter.setEnabled(true/false);
39 | ```
40 |
41 | 4. Customized printer
42 |
43 | ```
44 | DaffodilPrinter.setPrintDelegate(new DaffodilPrinter.DaffodilPrinterDelegate() {
45 | @Override
46 | public void printMethod(MethodInfo info) {
47 |
48 | }
49 |
50 | @Override
51 | public void log(String msg) {
52 |
53 | }
54 | });
55 | ```
56 |
57 | Download
58 | ----
59 |
60 | * add the plugin to your top build script:
61 |
62 | ```
63 | buildscript {
64 | repositories {
65 | jcenter()
66 | }
67 | dependencies {
68 | classpath 'tech.saymagic:daffodil:1.1.0'
69 | }
70 | }
71 | ```
72 | * apply plugin in your project:
73 |
74 | ```
75 | apply plugin: 'tech.saymagic.daffodil'
76 | ```
77 |
78 | * add runtime library in your project's dependencies:
79 |
80 | ```
81 | dependencies {
82 | compile 'tech.saymagic:daffodil-lib:1.1.0@aar'
83 | }
84 | ```
85 |
86 | License
87 | --------
88 |
89 | Copyright 2017 Saymagic
90 |
91 | Licensed under the Apache License, Version 2.0 (the "License");
92 | you may not use this file except in compliance with the License.
93 | You may obtain a copy of the License at
94 |
95 | http://www.apache.org/licenses/LICENSE-2.0
96 |
97 | Unless required by applicable law or agreed to in writing, software
98 | distributed under the License is distributed on an "AS IS" BASIS,
99 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
100 | See the License for the specific language governing permissions and
101 | limitations under the License.
102 |
--------------------------------------------------------------------------------
/_config.yml:
--------------------------------------------------------------------------------
1 | theme: jekyll-theme-cayman
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'tech.saymagic.daffodil'
3 |
4 | android {
5 | compileSdkVersion 25
6 | buildToolsVersion "25.0.2"
7 | defaultConfig {
8 | applicationId "tech.saymagic.daffodil.demo"
9 | minSdkVersion 11
10 | targetSdkVersion 25
11 | versionCode 1
12 | versionName "1.0"
13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
14 | }
15 | buildTypes {
16 | release {
17 | minifyEnabled false
18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
19 | }
20 | }
21 | }
22 |
23 | daffodil {
24 | enabled true
25 | }
26 |
27 | dependencies {
28 | compile fileTree(dir: 'libs', include: ['*.jar'])
29 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
30 | exclude group: 'com.android.support', module: 'support-annotations'
31 | })
32 | compile 'com.android.support:appcompat-v7:25.3.0'
33 | compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4'
34 | testCompile 'junit:junit:4.12'
35 | compile 'tech.saymagic:daffodil-lib:1.1.0@aar'
36 |
37 | // compile project(":lib")
38 | }
39 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/saymagic/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/tech/saymagic/daffodil/demo/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package tech.saymagic.daffodil.demo;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("tech.saymagic.daffodil.demo", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/java/tech/saymagic/daffodil/demo/MainActivity.java:
--------------------------------------------------------------------------------
1 | package tech.saymagic.daffodil.demo;
2 |
3 | import android.support.v7.app.AppCompatActivity;
4 | import android.os.Bundle;
5 | import android.util.Log;
6 | import android.view.View;
7 | import android.widget.Toast;
8 |
9 | import java.util.Random;
10 |
11 | import tech.saymagic.daffodil.lib.Daffodil;
12 | import tech.saymagic.daffodil.lib.DaffodilPrinter;
13 | import tech.saymagic.daffodil.lib.MethodInfo;
14 | import tech.saymagic.daffodil.lib.MethodRemember;
15 |
16 | public class MainActivity extends AppCompatActivity implements View.OnClickListener{
17 |
18 | @Override
19 | protected void onCreate(Bundle savedInstanceState) {
20 | super.onCreate(savedInstanceState);
21 | setContentView(R.layout.activity_main);
22 | findViewById(R.id.btn_random_max_test).setOnClickListener(this);
23 | }
24 |
25 | @Daffodil
26 | public int max(int a, int b) {
27 | return Math.max(a, b);
28 | }
29 |
30 | @Override
31 | public void onClick(View v) {
32 | int id = v.getId();
33 | switch (id) {
34 | case R.id.btn_random_max_test:
35 | Random random = new Random();
36 | boolean enabled = random.nextBoolean();
37 | DaffodilPrinter.setEnabled(enabled);
38 | Toast.makeText(this, max(random.nextInt(), random.nextInt()) + " " + enabled, Toast.LENGTH_LONG).show();
39 | break;
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saymagic/Daffodil/719843c53d3dbcd7ddb79d252ca313eee00c2a3b/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saymagic/Daffodil/719843c53d3dbcd7ddb79d252ca313eee00c2a3b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saymagic/Daffodil/719843c53d3dbcd7ddb79d252ca313eee00c2a3b/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saymagic/Daffodil/719843c53d3dbcd7ddb79d252ca313eee00c2a3b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saymagic/Daffodil/719843c53d3dbcd7ddb79d252ca313eee00c2a3b/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saymagic/Daffodil/719843c53d3dbcd7ddb79d252ca313eee00c2a3b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saymagic/Daffodil/719843c53d3dbcd7ddb79d252ca313eee00c2a3b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saymagic/Daffodil/719843c53d3dbcd7ddb79d252ca313eee00c2a3b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saymagic/Daffodil/719843c53d3dbcd7ddb79d252ca313eee00c2a3b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saymagic/Daffodil/719843c53d3dbcd7ddb79d252ca313eee00c2a3b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Daffodil
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/tech/saymagic/daffodil/demo/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package tech.saymagic.daffodil.demo;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | mavenLocal()
6 | jcenter()
7 | }
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:2.3.0'
10 | classpath 'eu.appsatori:gradle-fatjar-plugin:0.3'
11 | classpath 'com.novoda:bintray-release:0.3.4'
12 | classpath 'tech.saymagic:daffodil:1.1.1'
13 | // NOTE: Do not place your application dependencies here; they belong
14 | // in the individual module build.gradle files
15 | }
16 | }
17 |
18 | allprojects {
19 | repositories {
20 | mavenLocal()
21 | jcenter()
22 | }
23 | tasks.withType(Javadoc) {
24 | options {
25 | encoding "UTF-8"
26 | charSet 'UTF-8'
27 | links "http://docs.oracle.com/javase/7/docs/api"
28 | }
29 | }
30 | }
31 |
32 |
33 | ext {
34 | publishVersion = '1.1.0'
35 | groupId = 'tech.saymagic'
36 | userOrg = 'saymagic'
37 | desc = 'Annotation-triggered method call logging for your debug builds.'
38 | website = 'https://github.com/saymagic/daffodil'
39 | licences = ['Apache-2.0']
40 | uploadName = 'Daffodil'
41 | }
42 |
43 | task clean(type: Delete) {
44 | delete rootProject.buildDir
45 | }
46 |
47 | subprojects {
48 | repositories {
49 | jcenter()
50 | }
51 |
52 | group = groupId
53 | version = publishVersion
54 | def name2artifactId = ['plugin': 'daffodil', 'lib': 'daffodil-lib']
55 | if (project.name in name2artifactId.keySet()) {
56 | apply plugin: 'maven'
57 | gradle.taskGraph.whenReady { taskGraph ->
58 | def pomTask = taskGraph.getAllTasks().find {
59 | it.path == ":$project.name:generatePomFileForMavenPublication"
60 | }
61 | if (pomTask == null) return;
62 | pomTask.doLast {
63 | file("build/publications/maven/pom-default.xml").delete()
64 | pom {
65 | //noinspection GroovyAssignabilityCheck
66 | project {
67 | name project.name
68 | artifactId name2artifactId.get(project.name)
69 | packaging 'jar'
70 | description desc
71 | url website
72 | version publishVersion
73 |
74 | scm {
75 | url website
76 | connection website
77 | developerConnection website
78 | }
79 |
80 | licenses {
81 | license {
82 | name 'The Apache Software License, Version 2.0'
83 | }
84 | }
85 |
86 | developers {
87 | developer {
88 | id 'saymagic'
89 | name 'saymagic'
90 | email 'saymagic.dev@gmail.com'
91 | }
92 | }
93 | }
94 | }.writeTo("build/publications/maven/pom-default.xml")
95 | }
96 | }
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saymagic/Daffodil/719843c53d3dbcd7ddb79d252ca313eee00c2a3b/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri May 19 15:53:27 CST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/lib/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/lib/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'com.novoda.bintray-release'
3 |
4 | android {
5 | compileSdkVersion 25
6 | buildToolsVersion "25.0.2"
7 |
8 | defaultConfig {
9 | minSdkVersion 11
10 | targetSdkVersion 25
11 | versionCode 1
12 | versionName "1.0"
13 |
14 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
15 |
16 | }
17 | buildTypes {
18 | release {
19 | minifyEnabled false
20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
21 | }
22 | }
23 | }
24 |
25 | dependencies {
26 | compile fileTree(dir: 'libs', include: ['*.jar'])
27 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
28 | exclude group: 'com.android.support', module: 'support-annotations'
29 | })
30 | compile 'com.android.support:appcompat-v7:25.3.0'
31 | testCompile 'junit:junit:4.12'
32 | }
33 |
34 | task sourcesJar(type: Jar) {
35 | from android.sourceSets.main.java.srcDirs
36 | classifier = 'sources'
37 | }
38 |
39 | task javadoc(type: Javadoc) {
40 | source = android.sourceSets.main.java.srcDirs
41 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
42 | }
43 |
44 | task javadocJar(type: Jar, dependsOn: javadoc) {
45 | classifier = 'javadoc'
46 | from javadoc.destinationDir
47 | }
48 |
49 | publish {
50 | artifactId = 'daffodil-lib'
51 | userOrg = rootProject.userOrg
52 | groupId = rootProject.groupId
53 | publishVersion = rootProject.publishVersion
54 | desc = rootProject.desc
55 | website = rootProject.website
56 | licences = rootProject.licences
57 | }
--------------------------------------------------------------------------------
/lib/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/saymagic/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/lib/src/androidTest/java/tech/saymagic/daffodil/lib/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package tech.saymagic.daffodil.lib;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("tech.saymagic.daffodil.lib.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/lib/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/lib/src/main/java/tech/saymagic/daffodil/lib/Daffodil.java:
--------------------------------------------------------------------------------
1 | package tech.saymagic.daffodil.lib;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | /**
9 | * Created by caoyanming on 2017/5/19.
10 | */
11 |
12 | @Retention(RetentionPolicy.CLASS)
13 | @Target({ElementType.METHOD, ElementType.CONSTRUCTOR})
14 | public @interface Daffodil {
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/lib/src/main/java/tech/saymagic/daffodil/lib/DaffodilPrinter.java:
--------------------------------------------------------------------------------
1 | package tech.saymagic.daffodil.lib;
2 |
3 |
4 | import android.text.TextUtils;
5 | import android.util.Log;
6 |
7 | import java.util.concurrent.atomic.AtomicBoolean;
8 | import java.util.concurrent.atomic.AtomicInteger;
9 | import java.util.logging.Logger;
10 |
11 | /**
12 | * Created by caoyanming on 2017/6/10.
13 | */
14 |
15 | public class DaffodilPrinter {
16 |
17 | private static final String TAG = "DaffodilPrinter";
18 |
19 | private static AtomicBoolean sEnabled = new AtomicBoolean(true);
20 |
21 | private static DaffodilPrinterDelegate mPrintDelegate = new DaffodilPrinterDelegate() {
22 |
23 | @Override
24 | public void printMethod(MethodInfo info) {
25 | StringBuilder builder = new StringBuilder();
26 | builder.append(info.getCallerMethodName());
27 | builder.append("(");
28 | Object[] args = info.getArgs();
29 | if (args != null && args.length > 0) {
30 | for (Object arg : args) {
31 | builder.append(String.valueOf(arg))
32 | .append(",");
33 | }
34 | builder.deleteCharAt(builder.length() - 1);
35 | }
36 | builder.append(")");
37 |
38 | Object ret = info.getReturn();
39 | if (ret != null) {
40 | builder.append(" = ").append(String.valueOf(ret));
41 | }
42 | builder.append(" {")
43 | .append(info.getExitTime() - info.getEnterTime()).append("ms, ")
44 | .append(info.getThreadName()).append("}");
45 | Log.i(removeSuffix(info.getCallerFileName()), builder.toString());
46 | }
47 |
48 | @Override
49 | public void log(String msg) {
50 | Log.i(TAG, msg);
51 | }
52 |
53 | };
54 |
55 | public static void setEnabled(boolean enabled) {
56 | sEnabled.compareAndSet(!enabled, enabled);
57 | }
58 |
59 | public static boolean isEnabled() {
60 | return sEnabled.get();
61 | }
62 |
63 | public static void setPrintDelegate(DaffodilPrinterDelegate mPrintDelegate) {
64 | DaffodilPrinter.mPrintDelegate = mPrintDelegate;
65 | }
66 |
67 | public static void printMethod(MethodInfo info) {
68 | if (mPrintDelegate != null && sEnabled.get()) {
69 | mPrintDelegate.printMethod(info);
70 | }
71 | }
72 |
73 | public static void log(String msg) {
74 | if (mPrintDelegate != null && sEnabled.get()) {
75 | mPrintDelegate.log(msg);
76 | }
77 | }
78 |
79 | public static final String removeSuffix(String source) {
80 | if (TextUtils.isEmpty(source) ) {
81 | return source;
82 | }
83 | int dot = source.lastIndexOf(".");
84 | if (dot >= 0) {
85 | return source.substring(0, dot);
86 | }
87 | return source;
88 | }
89 |
90 | public interface DaffodilPrinterDelegate {
91 |
92 | void printMethod(MethodInfo info);
93 |
94 | void log(String msg);
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/lib/src/main/java/tech/saymagic/daffodil/lib/MethodInfo.java:
--------------------------------------------------------------------------------
1 | package tech.saymagic.daffodil.lib;
2 |
3 | /**
4 | * Created by caoyanming on 2017/6/10.
5 | */
6 |
7 | public class MethodInfo {
8 |
9 | private String mCallerMethodName;
10 |
11 | private String mCallerClass;
12 |
13 | private int mCallerLineNumber;
14 |
15 | private String mCallerFileName;
16 |
17 | private boolean mCallerMethodIsNative;
18 |
19 | private long mEnterTime;
20 |
21 | private Object[] mArgs;
22 |
23 | private Object mReturn;
24 |
25 | private long mExitTime;
26 |
27 | private String mThreadName;
28 |
29 | private long mThreadId;
30 |
31 | public MethodInfo(Object[] args, StackTraceElement stackTraceElement) {
32 | mEnterTime = System.currentTimeMillis();
33 | mArgs = args;
34 | initVarFromElement(stackTraceElement);
35 | }
36 |
37 | private void initVarFromElement(StackTraceElement stackTraceElement) {
38 | if (stackTraceElement != null) {
39 | mCallerClass = stackTraceElement.getClassName();
40 | mCallerFileName = stackTraceElement.getFileName();
41 | mCallerLineNumber = stackTraceElement.getLineNumber();
42 | mCallerMethodIsNative = stackTraceElement.isNativeMethod();
43 | mCallerMethodName = stackTraceElement.getMethodName();
44 | }
45 | }
46 |
47 | public long getEnterTime() {
48 | return mEnterTime;
49 | }
50 |
51 | public void setEnterTime(long enterTime) {
52 | mEnterTime = enterTime;
53 | }
54 |
55 | public Object[] getArgs() {
56 | return mArgs;
57 | }
58 |
59 | public void setArgs(Object[] args) {
60 | mArgs = args;
61 | }
62 |
63 | public Object getReturn() {
64 | return mReturn;
65 | }
66 |
67 | public void setReturn(Object aReturn) {
68 | mReturn = aReturn;
69 | this.mExitTime = System.currentTimeMillis();
70 | }
71 |
72 | public String getCallerMethodName() {
73 | return mCallerMethodName;
74 | }
75 |
76 | public void setCallerMethodName(String callerMethodName) {
77 | mCallerMethodName = callerMethodName;
78 | }
79 |
80 | public String getCallerClass() {
81 | return mCallerClass;
82 | }
83 |
84 | public void setCallerClass(String callerClass) {
85 | mCallerClass = callerClass;
86 | }
87 |
88 | public int getCallerLineNumber() {
89 | return mCallerLineNumber;
90 | }
91 |
92 | public void setCallerLineNumber(int callerLineNumber) {
93 | mCallerLineNumber = callerLineNumber;
94 | }
95 |
96 | public String getCallerFileName() {
97 | return mCallerFileName;
98 | }
99 |
100 | public void setCallerFileName(String callerFileName) {
101 | mCallerFileName = callerFileName;
102 | }
103 |
104 | public boolean isCallerMethodIsNative() {
105 | return mCallerMethodIsNative;
106 | }
107 |
108 | public void setCallerMethodIsNative(boolean callerMethodIsNative) {
109 | mCallerMethodIsNative = callerMethodIsNative;
110 | }
111 |
112 | public long getExitTime() {
113 | return mExitTime;
114 | }
115 |
116 | public void setExitTime(long exitTime) {
117 | mExitTime = exitTime;
118 | }
119 |
120 | public String getThreadName() {
121 | return mThreadName;
122 | }
123 |
124 | public void setThreadName(String threadName) {
125 | mThreadName = threadName;
126 | }
127 |
128 | public long getThreadId() {
129 | return mThreadId;
130 | }
131 |
132 | public void setThreadId(long threadId) {
133 | mThreadId = threadId;
134 | }
135 | }
136 |
--------------------------------------------------------------------------------
/lib/src/main/java/tech/saymagic/daffodil/lib/MethodRemember.java:
--------------------------------------------------------------------------------
1 | package tech.saymagic.daffodil.lib;
2 |
3 | import android.util.Log;
4 |
5 | import java.util.HashMap;
6 | import java.util.Map;
7 | import java.util.concurrent.atomic.AtomicInteger;
8 |
9 | /**
10 | * Created by caoyanming on 2017/6/10.
11 | */
12 |
13 | public class MethodRemember {
14 |
15 |
16 |
17 | private static ThreadLocal