├── .DS_Store
├── .gitignore
├── .idea
├── caches
│ ├── build_file_checksums.ser
│ └── gradle_models.ser
├── checkstyle-idea.xml
├── codeStyles
│ ├── Project.xml
│ └── codeStyleConfig.xml
├── encodings.xml
├── inspectionProfiles
│ └── Project_Default.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── README.md
├── app
├── .DS_Store
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── cn
│ │ └── deemons
│ │ └── duck
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── cn
│ │ │ └── deemons
│ │ │ └── duck
│ │ │ ├── App.java
│ │ │ ├── CustomView.java
│ │ │ └── MainActivity.java
│ └── res
│ │ ├── color
│ │ ├── selector_press_color.xml
│ │ └── selector_press_stroke_color.xml
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ ├── ic_launcher_background.xml
│ │ └── test.xml
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.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
│ └── cn
│ └── deemons
│ └── duck
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── image
├── 14-06-02.gif
├── Snipaste_2019-05-29_11-47-18.png
├── duck.gif
├── eberhard-grossgasteiger.jpg
├── screenshot-1551340161787.jpg
├── screenshot-1551340182026.jpg
└── screenshot-1551340314962.jpg
├── library
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── cn
│ │ └── deemons
│ │ └── library
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── cn
│ │ │ └── deemons
│ │ │ └── library
│ │ │ ├── core
│ │ │ ├── AspectPlugin.java
│ │ │ ├── DuckFactor.java
│ │ │ └── Injector.java
│ │ │ ├── shape
│ │ │ ├── ShapeInjector.java
│ │ │ └── ShapeUtils.java
│ │ │ └── view
│ │ │ ├── DuckFrameLayout.java
│ │ │ ├── DuckLinearLayout.java
│ │ │ ├── DuckRelativeLayout.java
│ │ │ ├── DuckScrollView.java
│ │ │ └── DuckTableLayout.java
│ └── res
│ │ └── values
│ │ ├── strings.xml
│ │ └── style.xml
│ └── test
│ └── java
│ └── cn
│ └── deemons
│ └── library
│ └── ExampleUnitTest.java
├── plugin
├── .gitignore
├── build.gradle
└── src
│ └── main
│ ├── groovy
│ └── com
│ │ └── deemons
│ │ └── plugin
│ │ ├── JavassistPlugin.groovy
│ │ ├── JavassistTransform.groovy
│ │ ├── MyInject.groovy
│ │ └── Utils.groovy
│ └── resources
│ └── META-INF
│ └── gradle-plugins
│ └── com.deemons.duck.properties
├── repo
└── com
│ └── deemons
│ └── plugin
│ └── duck
│ ├── 0.0.1
│ ├── duck-0.0.1.jar
│ ├── duck-0.0.1.jar.md5
│ ├── duck-0.0.1.jar.sha1
│ ├── duck-0.0.1.pom
│ ├── duck-0.0.1.pom.md5
│ └── duck-0.0.1.pom.sha1
│ ├── 0.0.2
│ ├── duck-0.0.2.jar
│ ├── duck-0.0.2.jar.md5
│ ├── duck-0.0.2.jar.sha1
│ ├── duck-0.0.2.pom
│ ├── duck-0.0.2.pom.md5
│ └── duck-0.0.2.pom.sha1
│ ├── 0.0.3
│ ├── duck-0.0.3.jar
│ ├── duck-0.0.3.jar.md5
│ ├── duck-0.0.3.jar.sha1
│ ├── duck-0.0.3.pom
│ ├── duck-0.0.3.pom.md5
│ └── duck-0.0.3.pom.sha1
│ ├── maven-metadata.xml
│ ├── maven-metadata.xml.md5
│ └── maven-metadata.xml.sha1
├── settings.gradle
└── settings_duck.jar
/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Deemonser/Duck/a1d190da701627c78b02dc73cea37e404f64c002/.DS_Store
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the ART/Dalvik VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | bin/
13 | gen/
14 | out/
15 |
16 | # Gradle files
17 | .gradle/
18 | build/
19 |
20 | # Local configuration file (sdk path, etc)
21 | local.properties
22 |
23 | # Proguard folder generated by Eclipse
24 | proguard/
25 |
26 | # Log Files
27 | *.log
28 |
29 | # Android Studio Navigation editor temp files
30 | .navigation/
31 |
32 | # Android Studio captures folder
33 | captures/
34 |
35 | # IntelliJ
36 | *.iml
37 | .idea/workspace.xml
38 | .idea/tasks.xml
39 | .idea/gradle.xml
40 | .idea/dictionaries
41 | .idea/libraries
42 |
43 | # Keystore files
44 | # Uncomment the following line if you do not want to check your keystore files in.
45 | #*.jks
46 |
47 | # External native build folder generated in Android Studio 2.2 and later
48 | .externalNativeBuild
49 |
50 | # Google Services (e.g. APIs or Firebase)
51 | google-services.json
52 |
53 | # Freeline
54 | freeline.py
55 | freeline/
56 | freeline_project_description.json
57 |
58 | # fastlane
59 | fastlane/report.xml
60 | fastlane/Preview.html
61 | fastlane/screenshots
62 | fastlane/test_output
63 | fastlane/readme.md
64 | /README.md
65 |
--------------------------------------------------------------------------------
/.idea/caches/build_file_checksums.ser:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Deemonser/Duck/a1d190da701627c78b02dc73cea37e404f64c002/.idea/caches/build_file_checksums.ser
--------------------------------------------------------------------------------
/.idea/caches/gradle_models.ser:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Deemonser/Duck/a1d190da701627c78b02dc73cea37e404f64c002/.idea/caches/gradle_models.ser
--------------------------------------------------------------------------------
/.idea/checkstyle-idea.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
15 |
16 |
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
8 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
40 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 | xmlns:android
80 | ^$
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 | xmlns:.*
90 | ^$
91 |
92 |
93 | BY_NAME
94 |
95 |
96 |
97 |
98 |
99 |
100 | .*:id
101 | http://schemas.android.com/apk/res/android
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 | .*:name
111 | http://schemas.android.com/apk/res/android
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 | name
121 | ^$
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 | style
131 | ^$
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 | .*
141 | ^$
142 |
143 |
144 | BY_NAME
145 |
146 |
147 |
148 |
149 |
150 |
151 | .*:layout_width
152 | http://schemas.android.com/apk/res/android
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 | .*:layout_height
162 | http://schemas.android.com/apk/res/android
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 | .*:layout_.*
172 | http://schemas.android.com/apk/res/android
173 |
174 |
175 | BY_NAME
176 |
177 |
178 |
179 |
180 |
181 |
182 | .*:width
183 | http://schemas.android.com/apk/res/android
184 |
185 |
186 | BY_NAME
187 |
188 |
189 |
190 |
191 |
192 |
193 | .*:height
194 | http://schemas.android.com/apk/res/android
195 |
196 |
197 | BY_NAME
198 |
199 |
200 |
201 |
202 |
203 |
204 | .*
205 | http://schemas.android.com/apk/res/android
206 |
207 |
208 | BY_NAME
209 |
210 |
211 |
212 |
213 |
214 |
215 | .*
216 | .*
217 |
218 |
219 | BY_NAME
220 |
221 |
222 |
223 |
224 |
225 |
226 |
--------------------------------------------------------------------------------
/.idea/codeStyles/codeStyleConfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ### Duck 文档
2 | Duck 能帮助开发者直接在 xml 的任意控件上实现 Shape 效果,无需创建额外的xml文件,并且没有任何侵入性。
3 |
4 | 
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | #### 使用
13 |
14 | 1. 在项目的 build.gradle 文件下添加插件依赖
15 |
16 | ```gr
17 | buildscript {
18 | ...
19 | dependencies {
20 | ...
21 | classpath 'com.hujiang.aspectjx:gradle-android-plugin-aspectjx:2.0.2'
22 | }
23 | }
24 | ```
25 |
26 | 2. 在模块的 build.gradle 文件下添加
27 |
28 | ```groovy
29 | api 'com.deemons.duck:duck:0.0.2'
30 |
31 | // support androidx
32 | api 'com.deemons.duck:duckx:1.0.0'
33 | ```
34 |
35 | 3. 可选
36 |
37 | 在 xml 中使用自定义属性时,是没有提示的,我们可以通过 `Live Template` 来实现。
38 |
39 | 项目根目录下的 `settings_duck.jar` 文件,此文件已经设置了 AS 中的 Live Template,下载此文件并导入到系统设置中 `File` -> `Import setting` 。
40 |
41 | 
42 |
43 | 4. 直接在 xml 中使用
44 |
45 | ~~~xml
46 |
58 |
59 | ~~~
60 |
61 | 或者在代码中使用
62 |
63 | ```java
64 | TextView view = findViewById(R.id.text);
65 |
66 | view.setBackground(new ShapeUtils(GradientDrawable.RECTANGLE)
67 | .corner(10)
68 | .stroke(3, Color.parseColor("#0000ff"))
69 | .gradientLinear(GradientDrawable.Orientation.LEFT_RIGHT)
70 | .gradientColor(Color.RED, Color.GREEN, Color.BLUE, Color.YELLOW)
71 | .create()
72 | );
73 |
74 | ```
75 |
76 |
77 |
78 |
79 |
80 | ### API
81 |
82 | | 代码 | 功能 | 代码 | 功能 |
83 | | :-------------------------- | :------------------------------------------- | ----------------------- | ------------------------------------------ |
84 | | solid | 填充背景色
(API 21支持 SelectorColor) | stroke_color | 边框颜色
(API 21支持 SelectorColor) |
85 | | corner_top_left | 左上倒角 | stroke_width | 边框宽度 |
86 | | corner_top_right | 右上倒角 | stroke_dash_gap | 虚线边框单个长度 |
87 | | corner_bottom_left | 左下倒角 | stroke_dash_width | 虚线边框的间隔 |
88 | | corner_bottom_right | 右下倒角 | padding_left | 左内间距 |
89 | | corner | 所有倒角 | padding_top | 上内间距 |
90 | | gradient_color_start | 渐变初始颜色 | padding_right | 右内间距 |
91 | | gradient_color_center | 渐变中心颜色 | padding_bottom | 下内间距 |
92 | | gradient_color_end | 渐变结尾颜色 | size_width | Shape 的宽 |
93 | | gradient_linear_orientation | 线性 渐变方向 | size_height | Shape 的高 |
94 | | gradient_sweep_centerX | 扫描渐变中心X坐标 | gradient_radial_centerX | 径向渐变中心点X坐标 |
95 | | gradient_sweep_centerY | 扫描渐变中心Y坐标 | gradient_radial_centerY | 径向渐变中心点Y坐标 |
96 | | shape | 图形 | | |
97 |
98 |
99 |
100 |
101 |
102 | #### 原理
103 |
104 | 在考虑用什么技术实现时,考虑这几点:
105 |
106 | 1. 任何控件都能有效,即使是自定义控件。
107 | 2. 不能有侵入性,即使更换或废弃本库,也能保证稳定性。
108 |
109 | 最开始,第一个想到的是 `LayoutInflater.Factory` ,xml 控件解析成 View时,必须经过它,也是换肤的解决方案,但这样得一个个替换成自己的,非常麻烦。
110 |
111 | 有没有更好的解决方案呢?
112 |
113 | **得益于 AspectJ 的 AOP(面向切面编程)能力,我们可以在编译时期,直接在 View 及其子类的构造方法中插入相关代码,解析xml 中自定义的属性,最后设置到控件上。**
114 |
115 | ```java
116 | @Pointcut("execution(android.view.View+.new(..))")
117 | public void callViewConstructor() {
118 | }
119 |
120 | @After("callViewConstructor()")
121 | public void inject(JoinPoint joinPoint) throws Throwable {
122 |
123 | Signature signature = joinPoint.getSignature();
124 | Object target = joinPoint.getTarget();
125 | Object[] args = joinPoint.getArgs();
126 |
127 | int length = args.length;
128 | if (!(target instanceof View) || length < 2 || target.hashCode() == lastHash || !(args[0] instanceof Context) || !(args[1] instanceof AttributeSet)) {
129 | return;
130 | }
131 | lastHash = target.hashCode();
132 |
133 | Context context = (Context) args[0];
134 | AttributeSet attrs = (AttributeSet) args[1];
135 |
136 | int count = attrs.getAttributeCount();
137 |
138 | for (int i = 0; i < count; i++) {
139 | Log.i(TAG, attrs.getAttributeName(i) + " = " + attrs.getAttributeValue(i));
140 | }
141 |
142 | Log.i(TAG, "inject =====> " + signature.toString());
143 | DuckFactor.getFactor().inject((View) target, context, attrs);
144 | }
145 | ```
146 |
147 | AOP 相关内容,可以查看[AOP 系列](https://deemons.cn/categories/AOP/) 包含:
148 |
149 | [1.OOP 与 AOP](https://deemons.cn/2017/09/21/OOP%E4%B8%8EAOP/)
150 |
151 | [2.Java 注解处理器](https://deemons.cn/2017/09/28/Java-%E6%B3%A8%E8%A7%A3%E5%A4%84%E7%90%86%E5%99%A8/)
152 |
153 | [3.Aspect](https://deemons.cn/2017/10/10/AspectJ/)
154 |
155 | [4.Android中使用 Javassist](https://deemons.cn/2017/11/07/Android%E4%B8%AD%E4%BD%BF%E7%94%A8Javassist/)
156 |
157 |
158 |
159 | 由于 AspectJ 能遍历项目中所有依赖包,因此,无论是 support 库,还是第三方库都能得到很好支持。
160 |
161 | 但是 AOP 也存在一定问题,我们的 apk 中是不会存在系统原生 Android SDK 的,例如 `TextView` 这个系统控件,在编译时是不会打包到 apk 中,因此,AOP 技术对这种原生控件无能为力。
162 |
163 | 幸好,我们绝大部分项目为了兼容性,一般都会直接依赖官方的兼容库,即 `support` 相关的库。
164 |
165 | 在 support· 库中,会将一些原生控件,直接替换成 support 相关控件。相关代码如下:
166 |
167 | ```java
168 | android/support/v7/app/AppCompatViewInflater
169 |
170 | switch (name) {
171 | case "TextView":
172 | view = createTextView(context, attrs);
173 | verifyNotNull(view, name);
174 | break;
175 | case "ImageView":
176 | view = createImageView(context, attrs);
177 | verifyNotNull(view, name);
178 | break;
179 | case "Button":
180 | view = createButton(context, attrs);
181 | verifyNotNull(view, name);
182 | break;
183 | case "EditText":
184 | view = createEditText(context, attrs);
185 | verifyNotNull(view, name);
186 | break;
187 | ......
188 | }
189 | ```
190 |
191 | 而对于这些控件,我们的 AOP 都能够生效了。
192 |
193 | 在 support 库中,没有替换掉 ViewGroup 的几个常用子类,如`LinearLayout` 、`RelativeLayout`、`FrameLayout`等,
194 |
195 | 所以,我们我们仿照 support 的替换方式,直接在 `LayoutInflater.Factory.onCreateView` 方法中注入相应的替换代码。
196 |
197 | ```java
198 |
199 | @Pointcut("execution(* *..LayoutInflater.Factory+.onCreateView(..))")
200 | public void callLayoutInflater() {
201 | }
202 |
203 | @Around("callLayoutInflater()")
204 | public Object replaceView(ProceedingJoinPoint joinPoint) throws Throwable {
205 |
206 | ....
207 |
208 | switch (name) {
209 | case "RelativeLayout":
210 | return new DuckRelativeLayout(context, attrs);
211 | case "LinearLayout":
212 | return new DuckLinearLayout(context, attrs);
213 | case "FrameLayout":
214 | return new DuckFrameLayout(context, attrs);
215 | case "TableLayout":
216 | return new DuckTableLayout(context, attrs);
217 | case "ScrollView":
218 | return new DuckScrollView(context, attrs);
219 | default:
220 | break;
221 | }
222 |
223 | return result;
224 | }
225 |
226 | ```
227 |
228 |
229 |
230 | 这个库的代码其实很少,我这里也只是实现了 Shape 这一个功能。
231 |
232 | ```java
233 | private static Injector mInjector;
234 |
235 | public static void setFactor(Injector injector) {
236 | mInjector = injector;
237 | }
238 |
239 | public static Injector getFactor() {
240 | if (mInjector == null) {
241 | mInjector = new ShapeInjector();
242 | }
243 | return mInjector;
244 | }
245 | ```
246 |
247 | 这里保留的 Duck 的扩展性,如果觉得不够,可以自行实现功能更强大的 Injector 来替换默认的。
248 |
249 | AOP 的能力远不止如此,还有很多事情可以做,建议大家可以发挥想象,进行更多的扩展。
250 |
251 |
252 |
253 | ### 初衷
254 | 这个库的由来,是因为公司一个维护了 4 年的项目。
255 |
256 | 经历 4 年的项目,产品设计不知道改了多少版,期间产生并堆砌大量`shape.xml` 文件,这些文件因为索引的问题往往还无法清理。
257 |
258 | 同时,同一个 `shape.xml` 文件,因为设计存在不规范的问题,在不同页面改动了一点颜色、倒角或线宽等,就无法复用,必须据此创建新的文件。
259 |
260 | 最后,大量的文件堆积,开发人员开发时,想复用去画时间找 `shape.xml` ,还不如自己创建新的方便,这样恶性循环, 只能 GG。
261 |
262 | 最后,我想说,Android 设计 `Shape` 的初衷是好的: 一个 APP,统一的设计规范,就应该复用 `Shape` 。
263 |
264 | 但这种情况对于国内的生态来说并不适用。
265 |
266 | 首先,相同屏幕尺寸,中文承载信息的能力远大于英文,这就导致国外大部分 APP 界面设计简洁清爽,国内就显得非常复杂,同时国内互联网更新速度很快,界面是生命周期短,人员流动,很难做到界面统一。
267 |
268 | 所有,Android 的 Shape 并不适合国内生态。
269 |
270 | 开发时,超级羡慕对面 IOS 开发们可以直接在控件上进行花式倒角、加线框等骚操作,想不通为啥 Android 不能在这一点上借鉴IOS。哎,Android 与 IOS 的宿命之争,说多了都是泪。
271 |
272 | 基于上面种种原因,所以出现了想开发这个库。
273 |
274 |
275 |
276 | 这个库只实现了最常用的 Shape 功能,但 selector 及 layout-list 并未实现,因为有两点考虑:
277 |
278 | 1. shape 使用场景更多,并且更频繁,其他两种只在少数特定场景中使用。
279 |
280 | 2. selector 及 layout-list 需要更多精细的代码控制,如全部挤在 xml 中一个控件上,会非常臃肿,难以维护。
281 |
282 |
283 |
284 |
285 |
286 |
287 | ### 不足
288 |
289 | 由于使用 AOP ,所以在编写时,无法实时预览,看看后续能否通过 AS 插件补足吧!
--------------------------------------------------------------------------------
/app/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Deemonser/Duck/a1d190da701627c78b02dc73cea37e404f64c002/app/.DS_Store
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | apply plugin: 'android-aspectjx'
4 |
5 | //apply plugin: 'com.deemons.duck'
6 |
7 | android {
8 | compileSdkVersion 29
9 | defaultConfig {
10 | applicationId "cn.deemons.duck"
11 | minSdkVersion 16
12 | targetSdkVersion 29
13 | versionCode 1
14 | versionName "1.0"
15 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
16 | }
17 | buildTypes {
18 | release {
19 | minifyEnabled false
20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
21 | }
22 | }
23 | }
24 |
25 | dependencies {
26 | implementation fileTree(include: ['*.jar'], dir: 'libs')
27 | implementation 'androidx.appcompat:appcompat:1.0.2'
28 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
29 | testImplementation 'junit:junit:4.12'
30 | androidTestImplementation 'androidx.test:runner:1.2.0'
31 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
32 |
33 | implementation project(':library')
34 | // implementation 'com.deemons.duck:duck:0.0.2'
35 | debugImplementation 'com.facebook.stetho:stetho:1.5.0'
36 | debugImplementation 'com.facebook.stetho:stetho-okhttp3:1.5.0'
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/cn/deemons/duck/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package cn.deemons.duck;
2 |
3 | import android.content.Context;
4 | import androidx.test.InstrumentationRegistry;
5 | import androidx.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 | * Instrumented 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() {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("cn.deemons.duck", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/deemons/duck/App.java:
--------------------------------------------------------------------------------
1 | package cn.deemons.duck;
2 |
3 | import android.app.Application;
4 |
5 | /**
6 | * author: deemons
7 | * date: 2018/9/5
8 | * desc:
9 | */
10 | public class App extends Application {
11 |
12 | @Override
13 | public void onCreate() {
14 | super.onCreate();
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/deemons/duck/CustomView.java:
--------------------------------------------------------------------------------
1 | package cn.deemons.duck;
2 |
3 | import android.content.Context;
4 | import android.graphics.Canvas;
5 | import android.graphics.Color;
6 | import android.graphics.Paint;
7 | import androidx.annotation.Nullable;
8 | import android.util.AttributeSet;
9 | import android.view.View;
10 |
11 | /**
12 | * author: deemons
13 | * date: 2019/2/22
14 | * desc:
15 | */
16 | public class CustomView extends View {
17 | public CustomView(Context context) {
18 | super(context);
19 | }
20 |
21 | public CustomView(Context context, @Nullable AttributeSet attrs) {
22 | super(context, attrs);
23 | }
24 |
25 | public CustomView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
26 | super(context, attrs, defStyleAttr);
27 | }
28 |
29 |
30 | @Override
31 | protected void onDraw(Canvas canvas) {
32 | super.onDraw(canvas);
33 | Paint paint = new Paint();
34 | paint.setTextSize(40);
35 | paint.setColor(Color.BLACK);
36 | canvas.drawText("CustomView", getWidth()/3, getHeight()/2, paint);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/deemons/duck/MainActivity.java:
--------------------------------------------------------------------------------
1 | package cn.deemons.duck;
2 |
3 | import android.os.Bundle;
4 | import androidx.appcompat.app.AppCompatActivity;
5 |
6 | public class MainActivity extends AppCompatActivity {
7 |
8 | private static final String TAG = "MainActivity";
9 |
10 |
11 | @Override
12 | protected void onCreate(Bundle savedInstanceState) {
13 |
14 | // LayoutInflaterCompat.setFactory2(LayoutInflater.from(this), new LayoutInflater.Factory2() {
15 | // @Override
16 | // public View onCreateView(View parent, String name, Context context, AttributeSet attrs) {
17 | //
18 | // Log.e(TAG, "name = " + name);
19 | // int n = attrs.getAttributeCount();
20 | // for (int i = 0; i < n; i++) {
21 | // Log.e(TAG, attrs.getAttributeName(i) + " , " + attrs.getAttributeValue(i));
22 | // }
23 | //
24 | // return null;
25 | // }
26 | //
27 | // @Override
28 | // public View onCreateView(String name, Context context, AttributeSet attrs) {
29 | //
30 | // return null;
31 | // }
32 | // });
33 |
34 |
35 |
36 | super.onCreate(savedInstanceState);
37 | setContentView(R.layout.activity_main);
38 |
39 | // TextView view = findViewById(R.id.text);
40 | // ConstraintLayout root = findViewById(R.id.root_view);
41 |
42 |
43 | // view.setBackground(new ShapeUtils(GradientDrawable.RECTANGLE)
44 | // .corner(10)
45 | // .stroke(3, Color.parseColor("#0000ff"))
46 | // .gradientLinear(GradientDrawable.Orientation.LEFT_RIGHT)
47 | // .gradientColor(Color.RED, Color.GREEN, Color.BLUE, Color.YELLOW)
48 | // .create()
49 | // );
50 |
51 | }
52 |
53 |
54 |
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/app/src/main/res/color/selector_press_color.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/color/selector_press_stroke_color.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/test.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
11 |
12 |
13 |
20 |
21 |
22 |
32 |
33 |
44 |
45 |
46 |
51 |
52 |
62 |
63 |
73 |
74 |
75 |
76 |
77 |
81 |
82 |
94 |
95 |
105 |
106 |
107 |
108 |
109 |
120 |
121 |
133 |
134 |
148 |
149 |
163 |
164 |
165 |
180 |
181 |
182 |
198 |
199 |
200 |
217 |
218 |
219 |
225 |
226 |
227 |
238 |
239 |
248 |
249 |
250 |
259 |
260 |
267 |
268 |
269 |
278 |
279 |
286 |
287 |
288 |
289 |
290 |
291 |
299 |
300 |
307 |
308 |
309 |
310 |
311 |
312 |
320 |
321 |
328 |
329 |
330 |
331 |
332 |
333 |
341 |
342 |
349 |
350 |
351 |
352 |
360 |
361 |
373 |
374 |
375 |
376 |
377 |
388 |
389 |
400 |
401 |
402 |
403 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Deemonser/Duck/a1d190da701627c78b02dc73cea37e404f64c002/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Deemonser/Duck/a1d190da701627c78b02dc73cea37e404f64c002/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Deemonser/Duck/a1d190da701627c78b02dc73cea37e404f64c002/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Deemonser/Duck/a1d190da701627c78b02dc73cea37e404f64c002/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Deemonser/Duck/a1d190da701627c78b02dc73cea37e404f64c002/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Deemonser/Duck/a1d190da701627c78b02dc73cea37e404f64c002/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Deemonser/Duck/a1d190da701627c78b02dc73cea37e404f64c002/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Deemonser/Duck/a1d190da701627c78b02dc73cea37e404f64c002/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Deemonser/Duck/a1d190da701627c78b02dc73cea37e404f64c002/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Deemonser/Duck/a1d190da701627c78b02dc73cea37e404f64c002/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #2c7aff
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Duck
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/cn/deemons/duck/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package cn.deemons.duck;
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() {
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 |
5 | repositories {
6 | google()
7 | jcenter()
8 | maven {
9 | url uri('repo')
10 | }
11 | }
12 | dependencies {
13 | classpath 'com.android.tools.build:gradle:3.4.1'
14 |
15 | classpath 'com.hujiang.aspectjx:gradle-android-plugin-aspectjx:2.0.4'
16 | // NOTE: Do not place your application dependencies here; they belong
17 | // in the individual module build.gradle files
18 |
19 | classpath 'com.novoda:bintray-release:+'
20 | }
21 | }
22 |
23 | allprojects {
24 | repositories {
25 | google()
26 | jcenter()
27 | }
28 | }
29 |
30 | task clean(type: Delete) {
31 | delete rootProject.buildDir
32 | }
33 |
34 |
35 | //开源库中有中文注释,添加下面这些
36 | allprojects {
37 | tasks.withType(Javadoc) {
38 | options {
39 | encoding "UTF-8"
40 | charSet 'UTF-8'
41 | links "http://docs.oracle.com/javase/7/docs/api"
42 | }
43 | }
44 | }
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | android.enableJetifier=true
10 | android.useAndroidX=true
11 | org.gradle.jvmargs=-Xmx1536m
12 | # When configured, Gradle will run in incubating parallel mode.
13 | # This option should only be used with decoupled projects. More details, visit
14 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
15 | # org.gradle.parallel=true
16 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Deemonser/Duck/a1d190da701627c78b02dc73cea37e404f64c002/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed May 29 12:01:44 CST 2019
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-5.1.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/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 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
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 Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/image/14-06-02.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Deemonser/Duck/a1d190da701627c78b02dc73cea37e404f64c002/image/14-06-02.gif
--------------------------------------------------------------------------------
/image/Snipaste_2019-05-29_11-47-18.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Deemonser/Duck/a1d190da701627c78b02dc73cea37e404f64c002/image/Snipaste_2019-05-29_11-47-18.png
--------------------------------------------------------------------------------
/image/duck.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Deemonser/Duck/a1d190da701627c78b02dc73cea37e404f64c002/image/duck.gif
--------------------------------------------------------------------------------
/image/eberhard-grossgasteiger.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Deemonser/Duck/a1d190da701627c78b02dc73cea37e404f64c002/image/eberhard-grossgasteiger.jpg
--------------------------------------------------------------------------------
/image/screenshot-1551340161787.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Deemonser/Duck/a1d190da701627c78b02dc73cea37e404f64c002/image/screenshot-1551340161787.jpg
--------------------------------------------------------------------------------
/image/screenshot-1551340182026.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Deemonser/Duck/a1d190da701627c78b02dc73cea37e404f64c002/image/screenshot-1551340182026.jpg
--------------------------------------------------------------------------------
/image/screenshot-1551340314962.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Deemonser/Duck/a1d190da701627c78b02dc73cea37e404f64c002/image/screenshot-1551340314962.jpg
--------------------------------------------------------------------------------
/library/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/library/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 29
5 |
6 |
7 |
8 | defaultConfig {
9 | minSdkVersion 16
10 | targetSdkVersion 29
11 | versionCode 1
12 | versionName "1.0"
13 |
14 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
15 |
16 | }
17 |
18 | buildTypes {
19 | release {
20 | minifyEnabled false
21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
22 | }
23 | }
24 |
25 | }
26 |
27 | dependencies {
28 | implementation fileTree(include: ['*.jar'], dir: 'libs')
29 | testImplementation 'junit:junit:4.12'
30 | androidTestImplementation 'androidx.test:runner:1.2.0'
31 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
32 | api 'org.aspectj:aspectjrt:1.8.13'
33 | api 'androidx.annotation:annotation:1.1.0'
34 | }
35 |
36 | //for upload
37 | apply plugin: 'com.novoda.bintray-release'
38 | publish {
39 | userOrg = 'deemons' //注册的用户名
40 | groupId = 'com.deemons.duck' //引用时第一部分
41 | artifactId = 'duckx' //引用时的第二部分
42 | publishVersion = '1.0.0' //引用时的第三部分,版本号
43 | desc = 'android shape'//描述
44 | website = 'https://github.com/Deemonser/Duck'//项目地址
45 | }
46 |
47 |
--------------------------------------------------------------------------------
/library/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/library/src/androidTest/java/cn/deemons/library/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package cn.deemons.library;
2 |
3 | import android.content.Context;
4 | import androidx.test.InstrumentationRegistry;
5 | import androidx.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 | * Instrumented 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() {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("cn.deemons.library.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/library/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/library/src/main/java/cn/deemons/library/core/AspectPlugin.java:
--------------------------------------------------------------------------------
1 | package cn.deemons.library.core;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.util.Log;
6 | import android.view.View;
7 | import cn.deemons.library.view.DuckFrameLayout;
8 | import cn.deemons.library.view.DuckLinearLayout;
9 | import cn.deemons.library.view.DuckRelativeLayout;
10 | import cn.deemons.library.view.DuckScrollView;
11 | import cn.deemons.library.view.DuckTableLayout;
12 | import org.aspectj.lang.JoinPoint;
13 | import org.aspectj.lang.ProceedingJoinPoint;
14 | import org.aspectj.lang.Signature;
15 | import org.aspectj.lang.annotation.After;
16 | import org.aspectj.lang.annotation.Around;
17 | import org.aspectj.lang.annotation.Aspect;
18 | import org.aspectj.lang.annotation.Pointcut;
19 |
20 | /**
21 | * author: deemons
22 | * date: 2018/9/4
23 | * desc:
24 | */
25 | @Aspect
26 | public class AspectPlugin {
27 |
28 | private static final String TAG = "Duck";
29 | private static int lastHash = 0;
30 |
31 | //@Pointcut("execution(* *.onCreateView(..))")
32 | @Pointcut("execution(android.view.View+.new(..))")
33 | public void callViewConstructor() {
34 | }
35 |
36 | @Pointcut("execution(* *..LayoutInflater.Factory+.onCreateView(..))")
37 | public void callLayoutInflater() {
38 | }
39 |
40 | //
41 | // @Pointcut("execution(* *..AppCompatViewInflater+.createView(..))")
42 | // public void callCreateView() {
43 | // }
44 | //
45 | //
46 | // //@Pointcut("call(android.view.ViewGroup+.new(..))")
47 | // @Pointcut("execution(android.view.ViewGroup+.new(..))")
48 | // public void callViewGroupConstructor() {
49 | // }
50 |
51 |
52 | @Around("callLayoutInflater()")
53 | public Object replaceView(ProceedingJoinPoint joinPoint) throws Throwable {
54 | Object result = joinPoint.proceed();
55 |
56 | Signature signature = joinPoint.getSignature();
57 | Log.i(TAG, "replaceView =====> " + signature.toString());
58 |
59 |
60 | Object[] args = joinPoint.getArgs();
61 | int length = args.length;
62 | if (length != 4) {
63 | return result;
64 | }
65 |
66 | AttributeSet attrs = (AttributeSet) args[length - 1];
67 | Context context = (Context) args[length - 2];
68 | String name = (String) args[length - 3];
69 |
70 | Log.i(TAG, "AttributeSet:" + attrs.toString() + " ,context:" + context + " ,name=" + name);
71 |
72 | int count = attrs.getAttributeCount();
73 | for (int i = 0; i < count; i++) {
74 | Log.i(TAG, attrs.getAttributeName(i) + " = " + attrs.getAttributeValue(i));
75 | }
76 |
77 | switch (name) {
78 | case "RelativeLayout":
79 | return new DuckRelativeLayout(context, attrs);
80 | case "LinearLayout":
81 | return new DuckLinearLayout(context, attrs);
82 | case "FrameLayout":
83 | return new DuckFrameLayout(context, attrs);
84 | case "TableLayout":
85 | return new DuckTableLayout(context, attrs);
86 | case "ScrollView":
87 | return new DuckScrollView(context, attrs);
88 | default:
89 | break;
90 | }
91 |
92 | return result;
93 | }
94 |
95 |
96 | @After("callViewConstructor()")
97 | public void inject(JoinPoint joinPoint) throws Throwable {
98 |
99 | Signature signature = joinPoint.getSignature();
100 |
101 | Object target = joinPoint.getTarget();
102 |
103 | Object[] args = joinPoint.getArgs();
104 |
105 | int length = args.length;
106 | if (!(target instanceof View) || length < 2 || target.hashCode() == lastHash || !(args[0] instanceof Context) || !(args[1] instanceof AttributeSet)) {
107 | return;
108 | }
109 | lastHash = target.hashCode();
110 |
111 | Context context = (Context) args[0];
112 | AttributeSet attrs = (AttributeSet) args[1];
113 |
114 | int count = attrs.getAttributeCount();
115 |
116 | for (int i = 0; i < count; i++) {
117 | Log.i(TAG, attrs.getAttributeName(i) + " = " + attrs.getAttributeValue(i));
118 | }
119 |
120 | Log.i(TAG, "inject =====> " + signature.toString());
121 | DuckFactor.getFactor().inject((View) target, context, attrs);
122 |
123 | }
124 |
125 | }
126 |
--------------------------------------------------------------------------------
/library/src/main/java/cn/deemons/library/core/DuckFactor.java:
--------------------------------------------------------------------------------
1 | package cn.deemons.library.core;
2 |
3 | import cn.deemons.library.shape.ShapeInjector;
4 |
5 | /**
6 | * author: deemons
7 | * date: 2018/9/28
8 | * desc:
9 | */
10 | public class DuckFactor {
11 |
12 | private static Injector mInjector;
13 |
14 |
15 | public static void setFactor(Injector injector) {
16 | mInjector = injector;
17 | }
18 |
19 | public static Injector getFactor() {
20 | if (mInjector == null) {
21 | mInjector = new ShapeInjector();
22 | }
23 | return mInjector;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/library/src/main/java/cn/deemons/library/core/Injector.java:
--------------------------------------------------------------------------------
1 | package cn.deemons.library.core;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.view.View;
6 |
7 | import java.util.jar.Attributes;
8 |
9 | /**
10 | * author: deemons
11 | * date: 2018/9/28
12 | * desc:
13 | */
14 | public interface Injector {
15 |
16 | /**
17 | * View 构造函数 注入
18 | *
19 | * @param view View
20 | * @param context Context
21 | * @param attrs AttributeSet
22 | */
23 | void inject(View view, Context context, AttributeSet attrs);
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/library/src/main/java/cn/deemons/library/shape/ShapeInjector.java:
--------------------------------------------------------------------------------
1 | package cn.deemons.library.shape;
2 |
3 | import android.content.Context;
4 | import android.content.res.ColorStateList;
5 | import android.content.res.TypedArray;
6 | import android.graphics.drawable.GradientDrawable;
7 | import android.os.Build;
8 | import androidx.annotation.NonNull;
9 | import android.util.AttributeSet;
10 | import android.util.Log;
11 | import android.view.View;
12 |
13 | import java.util.ArrayList;
14 |
15 | import cn.deemons.library.R;
16 | import cn.deemons.library.core.Injector;
17 |
18 | /**
19 | * @author: deemons
20 | * date: 2018/9/28
21 | * desc:
22 | */
23 | public class ShapeInjector implements Injector {
24 |
25 | static final int COLOR_EMPTY_VALUE = -2;
26 | static final int SIZE_EMPTY_VALUE = -3;
27 |
28 | @Override
29 | public void inject(View view, Context context, AttributeSet attrs) {
30 |
31 | TypedArray shapeType = context.obtainStyledAttributes(attrs, R.styleable.Shape);
32 |
33 | int shape = shapeType.getInt(R.styleable.Shape_shape, -1);
34 | int sizeWidth = shapeType.getDimensionPixelOffset(R.styleable.Shape_size_width, SIZE_EMPTY_VALUE);
35 | int sizeHeight = shapeType.getDimensionPixelOffset(R.styleable.Shape_size_height, SIZE_EMPTY_VALUE);
36 |
37 | int solidColor = shapeType.getColor(R.styleable.Shape_solid, COLOR_EMPTY_VALUE);
38 | ColorStateList solidColorStateList = shapeType.getColorStateList(R.styleable.Shape_solid);
39 | float corner = shapeType.getDimension(R.styleable.Shape_corner, -1);
40 |
41 | float topLeft = shapeType.getDimension(R.styleable.Shape_corner_top_left, 0);
42 | float topRight = shapeType.getDimension(R.styleable.Shape_corner_top_right, 0);
43 | float bottomLeft = shapeType.getDimension(R.styleable.Shape_corner_bottom_left, 0);
44 | float bottomRight = shapeType.getDimension(R.styleable.Shape_corner_bottom_right, 0);
45 |
46 |
47 | float paddingLeft = shapeType.getDimension(R.styleable.Shape_padding_left, 0);
48 | float paddingRight = shapeType.getDimension(R.styleable.Shape_padding_right, 0);
49 | float paddingTop = shapeType.getDimension(R.styleable.Shape_padding_top, 0);
50 | float paddingBottom = shapeType.getDimension(R.styleable.Shape_padding_bottom, 0);
51 |
52 |
53 | int strokeWidth = shapeType.getDimensionPixelOffset(R.styleable.Shape_stroke_width, 0);
54 | int strokeColor = shapeType.getColor(R.styleable.Shape_stroke_color, COLOR_EMPTY_VALUE);
55 | ColorStateList strokeColorStateList = shapeType.getColorStateList(R.styleable.Shape_stroke_color);
56 | float strokeDashGap = shapeType.getDimension(R.styleable.Shape_stroke_dash_gap, 0);
57 | float strokeDashWidth = shapeType.getDimension(R.styleable.Shape_stroke_dash_width, 0);
58 |
59 | //线性渐变
60 | int gradientLinearOrientation = shapeType.getInt(R.styleable.Shape_gradient_linear_orientation, 0);
61 |
62 | float gradientSweepCenterX = shapeType.getFloat(R.styleable.Shape_gradient_sweep_centerX, -1);
63 | float gradientSweepCenterY = shapeType.getFloat(R.styleable.Shape_gradient_sweep_centerY, -1);
64 |
65 | float gradientRadialCenterX = shapeType.getFloat(R.styleable.Shape_gradient_radial_centerX, -1);
66 | float gradientRadialCenterY = shapeType.getFloat(R.styleable.Shape_gradient_radial_centerY, -1);
67 | float gradientRadialRadius = shapeType.getDimension(R.styleable.Shape_gradient_radial_radius, 0);
68 |
69 | int gradientColorStart = shapeType.getColor(R.styleable.Shape_gradient_color_start, COLOR_EMPTY_VALUE);
70 | int gradientColorCenter = shapeType.getColor(R.styleable.Shape_gradient_color_center, COLOR_EMPTY_VALUE);
71 | int gradientColorEnd = shapeType.getColor(R.styleable.Shape_gradient_color_end, COLOR_EMPTY_VALUE);
72 |
73 | shapeType.recycle();
74 |
75 |
76 | ShapeUtils utils = null;
77 |
78 | if (shape != -1) {
79 | utils = new ShapeUtils(shape);
80 | }
81 | if (sizeWidth != SIZE_EMPTY_VALUE || sizeHeight != SIZE_EMPTY_VALUE) {
82 | utils = checkAndCreateShapeUtils(utils);
83 | utils.size(sizeWidth != SIZE_EMPTY_VALUE ? sizeWidth : -1, sizeHeight != SIZE_EMPTY_VALUE ? sizeHeight : -1);
84 | }
85 |
86 | if (solidColor != COLOR_EMPTY_VALUE || solidColorStateList != null) {
87 | utils = checkAndCreateShapeUtils(utils);
88 | if (solidColorStateList != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
89 | utils.solid(solidColorStateList);
90 | } else if (solidColor != -1) {
91 | utils.solid(solidColor);
92 | }
93 | }
94 |
95 | if (corner > 0) {
96 | utils = checkAndCreateShapeUtils(utils);
97 | utils.corner(corner);
98 | }
99 |
100 | if (topLeft > 0 || topRight > 0 || bottomLeft > 0 || bottomRight > 0) {
101 | utils = checkAndCreateShapeUtils(utils);
102 | utils.corners(topLeft, topRight, bottomRight, bottomLeft);
103 | }
104 |
105 | if (paddingLeft > 0 || paddingRight > 0 || paddingTop > 0 || paddingBottom > 0) {
106 | utils = checkAndCreateShapeUtils(utils);
107 | utils.padding((int) paddingLeft, (int) paddingTop, (int) paddingRight, (int) paddingBottom);
108 | }
109 |
110 | if (strokeWidth > 0 && (strokeColor != COLOR_EMPTY_VALUE || strokeColorStateList != null)) {
111 | utils = checkAndCreateShapeUtils(utils);
112 | if (strokeDashGap > 0 || strokeDashWidth > 0) {
113 | if (strokeColorStateList != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
114 | utils.stroke(strokeWidth, strokeColorStateList, strokeDashGap > 0 ? strokeDashGap : 0, strokeDashWidth > 0 ? strokeDashWidth : 0);
115 | } else {
116 | utils.stroke(strokeWidth, strokeColor, strokeDashGap > 0 ? strokeDashGap : 0, strokeDashWidth > 0 ? strokeDashWidth : 0);
117 | }
118 | } else if (strokeColorStateList != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
119 | utils.stroke(strokeWidth, strokeColorStateList);
120 | } else {
121 | utils.stroke(strokeWidth, strokeColor);
122 | }
123 | }
124 |
125 | if (gradientLinearOrientation > 0) {
126 | utils = checkAndCreateShapeUtils(utils);
127 | if (gradientLinearOrientation == 1) {
128 | utils.gradientLinear(GradientDrawable.Orientation.TOP_BOTTOM);
129 | } else if (gradientLinearOrientation == 2) {
130 | utils.gradientLinear(GradientDrawable.Orientation.TR_BL);
131 | } else if (gradientLinearOrientation == 3) {
132 | utils.gradientLinear(GradientDrawable.Orientation.RIGHT_LEFT);
133 | } else if (gradientLinearOrientation == 4) {
134 | utils.gradientLinear(GradientDrawable.Orientation.BR_TL);
135 | } else if (gradientLinearOrientation == 5) {
136 | utils.gradientLinear(GradientDrawable.Orientation.BOTTOM_TOP);
137 | } else if (gradientLinearOrientation == 6) {
138 | utils.gradientLinear(GradientDrawable.Orientation.BL_TR);
139 | } else if (gradientLinearOrientation == 7) {
140 | utils.gradientLinear(GradientDrawable.Orientation.LEFT_RIGHT);
141 | } else if (gradientLinearOrientation == 8) {
142 | utils.gradientLinear(GradientDrawable.Orientation.TL_BR);
143 | }
144 | }
145 |
146 | if (gradientSweepCenterX >= 0 || gradientSweepCenterY >= 0) {
147 | utils = checkAndCreateShapeUtils(utils);
148 | utils.gradientSweep(gradientSweepCenterX > 0 ? gradientSweepCenterX : 0.5f, gradientSweepCenterY > 0 ? gradientSweepCenterY : 0.5f);
149 | }
150 |
151 | if (gradientRadialCenterX >= 0 || gradientRadialCenterY >= 0 || gradientRadialRadius > 0) {
152 | utils = checkAndCreateShapeUtils(utils);
153 | utils.gradientRadial(gradientRadialCenterX > 0 ? gradientRadialCenterX : 0.5f, gradientRadialCenterY > 0 ? gradientRadialCenterY : 0.5f, gradientRadialRadius);
154 | }
155 |
156 | if (gradientColorStart != COLOR_EMPTY_VALUE || gradientColorCenter != COLOR_EMPTY_VALUE || gradientColorEnd != COLOR_EMPTY_VALUE) {
157 | utils = checkAndCreateShapeUtils(utils);
158 | ArrayList list = new ArrayList<>();
159 |
160 | if (gradientColorStart != COLOR_EMPTY_VALUE) {
161 | list.add(gradientColorStart);
162 | }
163 | if (gradientColorCenter != COLOR_EMPTY_VALUE) {
164 | list.add(gradientColorCenter);
165 | }
166 | if (gradientColorEnd != COLOR_EMPTY_VALUE) {
167 | list.add(gradientColorEnd);
168 | }
169 |
170 | int[] colors = new int[list.size()];
171 | for (int i = 0; i < list.size(); i++) {
172 | colors[i] = list.get(i);
173 | }
174 | Log.i("Duck", "gradientColor " + colors.length);
175 | utils.gradientColor(colors);
176 | }
177 |
178 |
179 | if (utils != null) {
180 | view.setBackground(utils.create());
181 | Log.i("Duck", "createShape");
182 | }
183 | }
184 |
185 |
186 | @NonNull
187 | private ShapeUtils checkAndCreateShapeUtils(ShapeUtils utils) {
188 | if (utils == null) {
189 | utils = new ShapeUtils();
190 | }
191 | return utils;
192 | }
193 |
194 | }
195 |
--------------------------------------------------------------------------------
/library/src/main/java/cn/deemons/library/shape/ShapeUtils.java:
--------------------------------------------------------------------------------
1 | package cn.deemons.library.shape;
2 |
3 | import android.content.res.ColorStateList;
4 | import android.graphics.Rect;
5 | import android.graphics.drawable.GradientDrawable;
6 | import android.os.Build;
7 | import androidx.annotation.ColorInt;
8 | import androidx.annotation.IntDef;
9 | import androidx.annotation.Nullable;
10 | import androidx.annotation.RequiresApi;
11 |
12 | import java.lang.annotation.Retention;
13 | import java.lang.annotation.RetentionPolicy;
14 |
15 | import static android.graphics.drawable.GradientDrawable.LINE;
16 | import static android.graphics.drawable.GradientDrawable.OVAL;
17 | import static android.graphics.drawable.GradientDrawable.RECTANGLE;
18 | import static android.graphics.drawable.GradientDrawable.RING;
19 |
20 | /**
21 | * author: deemons
22 | * date: 2018/9/3
23 | * desc:
24 | */
25 | public class ShapeUtils {
26 |
27 |
28 | private final GradientDrawable mDrawable;
29 |
30 | @IntDef({RECTANGLE, OVAL, LINE, RING})
31 | @Retention(RetentionPolicy.SOURCE)
32 | public @interface Shape {
33 | }
34 |
35 |
36 | public ShapeUtils() {
37 | mDrawable = new GradientDrawable();
38 | }
39 |
40 | public ShapeUtils(@Shape int shape) {
41 | mDrawable = new GradientDrawable();
42 | mDrawable.setShape(shape);
43 | }
44 |
45 | public ShapeUtils shape(@Shape int shape) {
46 | mDrawable.setShape(shape);
47 | return this;
48 | }
49 |
50 | public ShapeUtils solid(@ColorInt int color) {
51 | mDrawable.setColor(color);
52 | return this;
53 | }
54 |
55 | @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
56 | public ShapeUtils solid(@Nullable ColorStateList colorStateList) {
57 | mDrawable.setColor(colorStateList);
58 | return this;
59 | }
60 |
61 | public ShapeUtils stroke(int width, @ColorInt int color) {
62 | mDrawable.setStroke(width, color);
63 | return this;
64 | }
65 |
66 | @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
67 | public ShapeUtils stroke(int width, @Nullable ColorStateList colorStateList) {
68 | mDrawable.setStroke(width, colorStateList);
69 | return this;
70 | }
71 |
72 | public ShapeUtils stroke(int width, @ColorInt int color, float dashGap, float dashWidth) {
73 | mDrawable.setStroke(width, color, dashGap, dashWidth);
74 | return this;
75 | }
76 |
77 | @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
78 | public ShapeUtils stroke(int width, @Nullable ColorStateList colorStateList, float dashGap, float dashWidth) {
79 | mDrawable.setStroke(width, colorStateList, dashGap, dashWidth);
80 | return this;
81 | }
82 |
83 | public ShapeUtils corner(float radius) {
84 | mDrawable.setCornerRadius(radius);
85 | return this;
86 | }
87 |
88 |
89 | public ShapeUtils corners(float topLeft, float topRight, float bottomRight, float bottomLeft) {
90 | float[] floats = {topLeft, topLeft, topRight, topRight, bottomRight, bottomRight, bottomLeft, bottomLeft};
91 | mDrawable.setCornerRadii(floats);
92 | return this;
93 | }
94 |
95 |
96 | /**
97 | * 线性渐变
98 | */
99 | public ShapeUtils gradientLinear(GradientDrawable.Orientation orientation) {
100 | mDrawable.setGradientType(GradientDrawable.LINEAR_GRADIENT);
101 | mDrawable.setOrientation(orientation);
102 | return this;
103 | }
104 |
105 | /**
106 | * 扫描渐变
107 | */
108 | public ShapeUtils gradientSweep(float centerX, float centerY) {
109 | mDrawable.setGradientType(GradientDrawable.SWEEP_GRADIENT);
110 | mDrawable.setGradientCenter(centerX, centerY);
111 | return this;
112 | }
113 |
114 | /**
115 | * 圆形渐变,以中心为起始,向四周扩散
116 | */
117 | public ShapeUtils gradientRadial(float centerX, float centerY, float radius) {
118 | mDrawable.setGradientType(GradientDrawable.RADIAL_GRADIENT);
119 | mDrawable.setGradientCenter(centerX, centerY);
120 | mDrawable.setGradientRadius(radius);
121 | return this;
122 | }
123 |
124 | public ShapeUtils gradientColor(@ColorInt int... colors) {
125 | mDrawable.setColors(colors);
126 | return this;
127 | }
128 |
129 | public ShapeUtils size(int width, int height) {
130 | mDrawable.setSize(width, height);
131 | return this;
132 | }
133 |
134 | public ShapeUtils padding(int left, int top, int right, int bottom) {
135 | mDrawable.getPadding(new Rect(left, top, right, bottom));
136 | return this;
137 | }
138 |
139 |
140 | public GradientDrawable create() {
141 | return mDrawable;
142 | }
143 |
144 | }
145 |
--------------------------------------------------------------------------------
/library/src/main/java/cn/deemons/library/view/DuckFrameLayout.java:
--------------------------------------------------------------------------------
1 | package cn.deemons.library.view;
2 |
3 | import android.content.Context;
4 | import androidx.annotation.NonNull;
5 | import androidx.annotation.Nullable;
6 | import android.util.AttributeSet;
7 | import android.widget.FrameLayout;
8 |
9 | /**
10 | * author: deemons
11 | * date: 2018/10/9
12 | * desc:
13 | */
14 | public class DuckFrameLayout extends FrameLayout {
15 | public DuckFrameLayout(@NonNull Context context) {
16 | super(context);
17 | }
18 |
19 | public DuckFrameLayout(@NonNull Context context, @Nullable AttributeSet attrs) {
20 | super(context, attrs);
21 | }
22 |
23 | public DuckFrameLayout(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
24 | super(context, attrs, defStyleAttr);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/library/src/main/java/cn/deemons/library/view/DuckLinearLayout.java:
--------------------------------------------------------------------------------
1 | package cn.deemons.library.view;
2 |
3 | import android.content.Context;
4 | import androidx.annotation.Nullable;
5 | import android.util.AttributeSet;
6 | import android.widget.LinearLayout;
7 |
8 | /**
9 | * author: deemons
10 | * date: 2019/2/26
11 | * desc:
12 | */
13 | public class DuckLinearLayout extends LinearLayout {
14 |
15 | public DuckLinearLayout(Context context) {
16 | super(context);
17 | }
18 |
19 | public DuckLinearLayout(Context context,
20 | @Nullable AttributeSet attrs) {
21 | super(context, attrs);
22 | }
23 |
24 | public DuckLinearLayout(Context context,
25 | @Nullable AttributeSet attrs, int defStyleAttr) {
26 | super(context, attrs, defStyleAttr);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/library/src/main/java/cn/deemons/library/view/DuckRelativeLayout.java:
--------------------------------------------------------------------------------
1 | package cn.deemons.library.view;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.widget.RelativeLayout;
6 |
7 | /**
8 | * author: deemons
9 | * date: 2018/10/9
10 | * desc:
11 | */
12 | public class DuckRelativeLayout extends RelativeLayout {
13 |
14 | public DuckRelativeLayout(Context context) {
15 | super(context);
16 | }
17 |
18 | public DuckRelativeLayout(Context context, AttributeSet attrs) {
19 | super(context, attrs);
20 | }
21 |
22 | public DuckRelativeLayout(Context context, AttributeSet attrs, int defStyleAttr) {
23 | super(context, attrs, defStyleAttr);
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/library/src/main/java/cn/deemons/library/view/DuckScrollView.java:
--------------------------------------------------------------------------------
1 | package cn.deemons.library.view;
2 |
3 | import android.content.Context;
4 | import androidx.annotation.NonNull;
5 | import androidx.annotation.Nullable;
6 | import android.util.AttributeSet;
7 | import android.widget.ScrollView;
8 |
9 | /**
10 | * author: deemons
11 | * date: 2018/10/9
12 | * desc:
13 | */
14 | public class DuckScrollView extends ScrollView {
15 | public DuckScrollView(@NonNull Context context) {
16 | super(context);
17 | }
18 |
19 | public DuckScrollView(@NonNull Context context, @Nullable AttributeSet attrs) {
20 | super(context, attrs);
21 | }
22 |
23 | public DuckScrollView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
24 | super(context, attrs, defStyleAttr);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/library/src/main/java/cn/deemons/library/view/DuckTableLayout.java:
--------------------------------------------------------------------------------
1 | package cn.deemons.library.view;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.widget.TableLayout;
6 |
7 | /**
8 | * author: deemons
9 | * date: 2019/2/21
10 | * desc:
11 | */
12 | public class DuckTableLayout extends TableLayout {
13 | public DuckTableLayout(Context context) {
14 | super(context);
15 | }
16 |
17 | public DuckTableLayout(Context context, AttributeSet attrs) {
18 | super(context, attrs);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/library/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Library
3 |
4 |
--------------------------------------------------------------------------------
/library/src/main/res/values/style.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/library/src/test/java/cn/deemons/library/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package cn.deemons.library;
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() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/plugin/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/plugin/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'groovy'
2 | apply plugin: 'maven'
3 | //apply plugin: "com.gradle.plugin-publish"//使用发布到远程的插件
4 |
5 | dependencies {
6 | implementation gradleApi() //gradle sdk
7 | implementation localGroovy() //groovy sdk
8 |
9 | implementation 'com.android.tools.build:gradle:3.4.1'
10 | implementation 'org.javassist:javassist:3.22.0-GA'
11 | }
12 | repositories {
13 | jcenter()
14 | }
15 |
16 | //发布到本地
17 | uploadArchives {
18 | repositories.mavenDeployer {
19 | repository(url: uri('../repo')) //仓库的路径,此处是项目根目录下的 repo 的文件夹
20 | pom.groupId = 'com.deemons.plugin' //groupId ,自行定义,一般是包名
21 | pom.artifactId = 'duck' //artifactId ,自行定义
22 | pom.version = '0.0.4' //version 版本号
23 | }
24 | }
--------------------------------------------------------------------------------
/plugin/src/main/groovy/com/deemons/plugin/JavassistPlugin.groovy:
--------------------------------------------------------------------------------
1 | package com.deemons.plugin
2 |
3 | import org.gradle.api.Plugin
4 | import org.gradle.api.Project
5 |
6 | public class JavassistPlugin implements Plugin {
7 |
8 | void apply(Project project) {
9 | def log = project.logger
10 | log.error "========================";
11 | log.error "Javassist开始修改Class!";
12 | log.error "========================";
13 | project.android.registerTransform(new JavassistTransform(project))
14 | }
15 | }
--------------------------------------------------------------------------------
/plugin/src/main/groovy/com/deemons/plugin/JavassistTransform.groovy:
--------------------------------------------------------------------------------
1 | package com.deemons.plugin
2 |
3 | import com.android.build.api.transform.*
4 | import com.google.common.collect.Sets
5 | import javassist.ClassPool
6 | import org.apache.commons.io.FileUtils
7 | import org.gradle.api.Project
8 |
9 | public class JavassistTransform extends Transform {
10 | Project project
11 |
12 | public JavassistTransform(Project project) {
13 | // 构造函数,我们将Project保存下来备用
14 | this.project = project
15 | }
16 |
17 | @Override
18 | String getName() {
19 | // 设置我们自定义的Transform对应的Task名称
20 | return "DuckTask"
21 | }
22 |
23 | @Override
24 | // 指定输入的类型,通过这里的设定,可以指定我们要处理的文件类型这样确保其他类型的文件不会传入
25 | Set getInputTypes() {
26 | return Sets.immutableEnumSet(QualifiedContent.DefaultContentType.CLASSES)
27 | }
28 |
29 | @Override
30 | // 指定Transform的作用范围
31 | Set getScopes() {
32 | return Sets.immutableEnumSet(QualifiedContent.Scope.PROJECT,
33 | QualifiedContent.Scope.PROJECT_LOCAL_DEPS,
34 | QualifiedContent.Scope.SUB_PROJECTS, QualifiedContent.Scope.SUB_PROJECTS_LOCAL_DEPS,
35 | QualifiedContent.Scope.EXTERNAL_LIBRARIES)
36 | }
37 |
38 | @Override
39 | boolean isIncremental() {
40 | return false
41 | }
42 |
43 | @Override
44 | void transform(Context context, Collection inputs,
45 | Collection referencedInputs,
46 | TransformOutputProvider outputProvider, boolean isIncremental)
47 | throws IOException, TransformException, InterruptedException {
48 | def startTime = System.currentTimeMillis();
49 |
50 | // Transform的inputs有两种类型,一种是目录,一种是jar包,要分开遍历
51 | inputs.each { TransformInput input ->
52 | try {
53 | //对 jar包 类型的inputs 进行遍历
54 | input.jarInputs.each {
55 |
56 | //这里处理自定义的逻辑
57 | MyInject.injectJar(it.file.getAbsolutePath(), "com", project)
58 |
59 | // 重命名输出文件(同目录copyFile会冲突)
60 | String outputFileName = it.name.replace(".jar", "") + '-' +
61 | it.file.path.hashCode()
62 | def output = outputProvider.getContentLocation(outputFileName, it.contentTypes,
63 | it.scopes, Format.JAR)
64 | FileUtils.copyFile(it.file, output)
65 | }
66 | } catch (Exception e) {
67 | project.logger.error(e.getMessage())
68 | }
69 |
70 | //对类型为“文件夹”的input进行遍历
71 | input.directoryInputs.each { DirectoryInput directoryInput ->
72 | //文件夹里面包含的是我们手写的类以及R.class、BuildConfig.class以及R$XXX.class等
73 | MyInject.injectDir(directoryInput.file.absolutePath, "com", project)
74 |
75 | // 获取output目录
76 | def dest = outputProvider.getContentLocation(directoryInput.name,
77 | directoryInput.contentTypes, directoryInput.scopes,
78 | Format.DIRECTORY)
79 |
80 | // 将input的目录复制到output指定目录
81 | FileUtils.copyDirectory(directoryInput.file, dest)
82 | }
83 |
84 | //关闭classPath,否则会一直存在引用
85 | MyInject.removeClassPath(project)
86 | }
87 |
88 |
89 | ClassPool.getDefault().clearImportedPackages();
90 | project.logger.error(
91 | "JavassistTransform cast :" + (System.currentTimeMillis() - startTime) /
92 | 1000 +
93 | " secs");
94 | }
95 | }
--------------------------------------------------------------------------------
/plugin/src/main/groovy/com/deemons/plugin/MyInject.groovy:
--------------------------------------------------------------------------------
1 | package com.deemons.plugin
2 |
3 | import javassist.ClassPool
4 | import javassist.JarClassPath
5 | import org.gradle.api.Project
6 |
7 | public class MyInject {
8 |
9 | static def classPathList = new ArrayList()
10 |
11 | public static void removeClassPath(Project project) {
12 | if (classPathList != null) {
13 | def pool = ClassPool.getDefault()
14 | classPathList.each {
15 | try {
16 | pool.removeClassPath(it)
17 | } catch (Exception e) {
18 | project.logger.error(e.getMessage())
19 | }
20 | }
21 | classPathList.clear()
22 | }
23 | }
24 |
25 |
26 | public static void injectJar(String path, String packageName, Project project) {
27 | project.logger.error("injectJar -> "+ path)
28 | ClassPool pool = ClassPool.getDefault()
29 | def classPath = new JarClassPath(path)
30 | classPathList.add(classPath)
31 | pool.appendClassPath(classPath)
32 |
33 | //project.android.bootClasspath 加入android.jar,否则找不到android相关的所有类
34 | pool.appendClassPath(project.android.bootClasspath[0].toString());
35 | Utils.importBaseClass(pool);
36 | }
37 |
38 |
39 | public static void injectDir(String path, String packageName, Project project) {
40 | project.logger.error("injectDir -> "+ path)
41 | ClassPool pool = ClassPool.getDefault()
42 | pool.appendClassPath(path)
43 |
44 | //project.android.bootClasspath 加入android.jar,否则找不到android相关的所有类
45 | pool.appendClassPath(project.android.bootClasspath[0].toString());
46 | Utils.importBaseClass(pool);
47 | File dir = new File(path)
48 | if (!dir.isDirectory()) {
49 | return;
50 | }
51 | project.logger.error("injectDir -> import")
52 |
53 | dir.eachFileRecurse { File file ->
54 | project.logger.error("injectDir -> file:"+file.absolutePath)
55 | String filePath = file.absolutePath//确保当前文件是class文件,并且不是系统自动生成的class文件
56 | if (filePath.endsWith(".class") && !filePath.contains('R$') && !filePath.contains('$')//代理类
57 | && !filePath.contains('R.class') && !filePath.contains("BuildConfig.class")) {
58 |
59 | // 判断当前目录是否是在我们的应用包里面
60 | int index = filePath.indexOf(packageName);
61 | boolean isMyPackage = index != -1;
62 | project.logger.error("injectDir -> isMyPackage:"+isMyPackage+" ,pass file:"+file.absolutePath)
63 |
64 | if (isMyPackage) {
65 |
66 | String className = Utils.getClassName(index, filePath);
67 | project.logger.error("injectDir -> className:"+className)
68 | // CtClass c = pool.getCtClass(className)
69 | // CtClass superClass =c.getSuperclass();
70 |
71 | // if (superClass!=null) project.logger.error(superClass.name)
72 | if (c.isFrozen()) c.defrost()
73 |
74 |
75 | //
76 | // BusInfo mBusInfo = new BusInfo()
77 | // mBusInfo.setProject(project)
78 | // mBusInfo.setClazz(c)
79 | // if (c.getName().endsWith("Activity") || c.getSuperclass().getName().endsWith("Activity")) mBusInfo.setIsActivity(true)
80 | // boolean isAnnotationByBus = false;
81 | // //getDeclaredMethods获取自己申明的方法,c.getMethods()会把所有父类的方法都加上
82 | // for (CtMethod ctmethod : c.getDeclaredMethods()) {
83 | // String methodName = Utils.getSimpleName(ctmethod);
84 | // if (BusHelper.ON_CREATE.contains(methodName)) mBusInfo.setOnCreateMethod(ctmethod)
85 | // if (BusHelper.ON_DESTROY.contains(methodName)) mBusInfo.setOnDestroyMethod(ctmethod)
86 | // for (Annotation mAnnotation : ctmethod.getAnnotations()) {
87 | // if (mAnnotation.annotationType().canonicalName.equals(BusHelper.OkBusRegisterAnnotation))
88 | // mBusInfo.setBusRegisterMethod(ctmethod)
89 | // if (mAnnotation.annotationType().canonicalName.equals(BusHelper.OkBusUnRegisterAnnotation))
90 | // mBusInfo.setBusUnRegisterMethod(ctmethod)
91 | // if (mAnnotation.annotationType().canonicalName.equals(BusHelper.OkBusAnnotation)) {
92 | // project.logger.error " method:" + c.getName() + " -" + ctmethod.getName()
93 | // mBusInfo.methods.add(ctmethod)
94 | // mBusInfo.annotations.add(mAnnotation)
95 | // if (!isAnnotationByBus) isAnnotationByBus = true
96 | // }
97 | // }
98 | // }
99 | // if (((mBusInfo.BusRegisterMethod != null && mBusInfo.BusUnRegisterMethod == null
100 | // || mBusInfo.BusRegisterMethod == null && mBusInfo.BusUnRegisterMethod != null)))
101 | // assert false: Utils.getBusErr()
102 | // if (mBusInfo != null && isAnnotationByBus) {
103 | // try {
104 | // BusHelper.intBus(mBusInfo, path)
105 | // } catch (DuplicateMemberException e) {
106 | // }
107 | // }
108 | c.detach()//用完一定记得要卸载,否则pool里的永远是旧的代码
109 | }
110 | }
111 | }
112 | }
113 | }
--------------------------------------------------------------------------------
/plugin/src/main/groovy/com/deemons/plugin/Utils.groovy:
--------------------------------------------------------------------------------
1 | package com.deemons.plugin
2 |
3 | import javassist.ClassPool
4 | import javassist.CtMethod
5 |
6 |
7 | public class Utils {
8 | // static String BusErr = "大哥注意哦,非Activity和Fragment中使用@BusRegister必须和@BusUnRegister一起使用,才能自动生成注册和反注册代码"
9 |
10 | static String VIEW_PATH="android.view.View"
11 |
12 | /**
13 | * 事先载入相关类
14 | * @param pool
15 | */
16 | static void importBaseClass(ClassPool pool) {
17 | pool.importPackage("cn.deemons.library")
18 | }
19 |
20 | static String getSimpleName(CtMethod ctmethod) {
21 | def methodName = ctmethod.getName();
22 | return methodName.substring(
23 | methodName.lastIndexOf('.') + 1, methodName.length());
24 | }
25 |
26 | static String getClassName(int index, String filePath) {
27 | int end = filePath.length() - 6 // .class = 6
28 | return filePath.substring(index, end).replace('\\', '.').replace('/', '.')
29 | }
30 | }
--------------------------------------------------------------------------------
/plugin/src/main/resources/META-INF/gradle-plugins/com.deemons.duck.properties:
--------------------------------------------------------------------------------
1 | implementation-class = com.deemons.plugin.JavassistPlugin
--------------------------------------------------------------------------------
/repo/com/deemons/plugin/duck/0.0.1/duck-0.0.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Deemonser/Duck/a1d190da701627c78b02dc73cea37e404f64c002/repo/com/deemons/plugin/duck/0.0.1/duck-0.0.1.jar
--------------------------------------------------------------------------------
/repo/com/deemons/plugin/duck/0.0.1/duck-0.0.1.jar.md5:
--------------------------------------------------------------------------------
1 | 12a71b5c288ec465fb7522244ac51734
--------------------------------------------------------------------------------
/repo/com/deemons/plugin/duck/0.0.1/duck-0.0.1.jar.sha1:
--------------------------------------------------------------------------------
1 | a9dffd255733e089b6833752b4d58ca7ee4fe76d
--------------------------------------------------------------------------------
/repo/com/deemons/plugin/duck/0.0.1/duck-0.0.1.pom:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 | com.deemons.plugin
6 | duck
7 | 0.0.1
8 |
9 |
10 | com.android.tools.build
11 | gradle
12 | 3.1.4
13 | compile
14 |
15 |
16 | org.javassist
17 | javassist
18 | 3.22.0-GA
19 | compile
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/repo/com/deemons/plugin/duck/0.0.1/duck-0.0.1.pom.md5:
--------------------------------------------------------------------------------
1 | 344d2860387b0d9ae4b156f4baaf1e23
--------------------------------------------------------------------------------
/repo/com/deemons/plugin/duck/0.0.1/duck-0.0.1.pom.sha1:
--------------------------------------------------------------------------------
1 | 0bee5dedbab27e36bfc31821d47a716044e67a36
--------------------------------------------------------------------------------
/repo/com/deemons/plugin/duck/0.0.2/duck-0.0.2.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Deemonser/Duck/a1d190da701627c78b02dc73cea37e404f64c002/repo/com/deemons/plugin/duck/0.0.2/duck-0.0.2.jar
--------------------------------------------------------------------------------
/repo/com/deemons/plugin/duck/0.0.2/duck-0.0.2.jar.md5:
--------------------------------------------------------------------------------
1 | f98076db9681faf3a5f6be78935365fb
--------------------------------------------------------------------------------
/repo/com/deemons/plugin/duck/0.0.2/duck-0.0.2.jar.sha1:
--------------------------------------------------------------------------------
1 | 6788259db2cd3696bbea1562771b894063612b6d
--------------------------------------------------------------------------------
/repo/com/deemons/plugin/duck/0.0.2/duck-0.0.2.pom:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 | com.deemons.plugin
6 | duck
7 | 0.0.2
8 |
9 |
10 | com.android.tools.build
11 | gradle
12 | 3.1.4
13 | compile
14 |
15 |
16 | org.javassist
17 | javassist
18 | 3.22.0-GA
19 | compile
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/repo/com/deemons/plugin/duck/0.0.2/duck-0.0.2.pom.md5:
--------------------------------------------------------------------------------
1 | e66ad3a7248cc9e625ffb5e247386015
--------------------------------------------------------------------------------
/repo/com/deemons/plugin/duck/0.0.2/duck-0.0.2.pom.sha1:
--------------------------------------------------------------------------------
1 | d148a62975771e3fd82d0dba54319443778fbe71
--------------------------------------------------------------------------------
/repo/com/deemons/plugin/duck/0.0.3/duck-0.0.3.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Deemonser/Duck/a1d190da701627c78b02dc73cea37e404f64c002/repo/com/deemons/plugin/duck/0.0.3/duck-0.0.3.jar
--------------------------------------------------------------------------------
/repo/com/deemons/plugin/duck/0.0.3/duck-0.0.3.jar.md5:
--------------------------------------------------------------------------------
1 | 1753254b9f719b1917d68c8b76060827
--------------------------------------------------------------------------------
/repo/com/deemons/plugin/duck/0.0.3/duck-0.0.3.jar.sha1:
--------------------------------------------------------------------------------
1 | d1f0bb697dad03bd8c8a5d6e7ed0285932437225
--------------------------------------------------------------------------------
/repo/com/deemons/plugin/duck/0.0.3/duck-0.0.3.pom:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 | com.deemons.plugin
6 | duck
7 | 0.0.3
8 |
9 |
10 | com.android.tools.build
11 | gradle
12 | 3.1.4
13 | compile
14 |
15 |
16 | org.javassist
17 | javassist
18 | 3.22.0-GA
19 | compile
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/repo/com/deemons/plugin/duck/0.0.3/duck-0.0.3.pom.md5:
--------------------------------------------------------------------------------
1 | 74d882c47891cc60124517b3d86ea9b3
--------------------------------------------------------------------------------
/repo/com/deemons/plugin/duck/0.0.3/duck-0.0.3.pom.sha1:
--------------------------------------------------------------------------------
1 | 67c017627ba337e5b3311ed73a4aa6697c28228f
--------------------------------------------------------------------------------
/repo/com/deemons/plugin/duck/maven-metadata.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | com.deemons.plugin
4 | duck
5 |
6 | 0.0.3
7 |
8 | 0.0.1
9 | 0.0.2
10 | 0.0.3
11 |
12 | 20180909142546
13 |
14 |
15 |
--------------------------------------------------------------------------------
/repo/com/deemons/plugin/duck/maven-metadata.xml.md5:
--------------------------------------------------------------------------------
1 | ccc42ee85a9e76903d586c9913eb23e2
--------------------------------------------------------------------------------
/repo/com/deemons/plugin/duck/maven-metadata.xml.sha1:
--------------------------------------------------------------------------------
1 | ff332df89038ab73e99cf84ea3fc89175a6dc30b
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':library', ':plugin'
2 |
--------------------------------------------------------------------------------
/settings_duck.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Deemonser/Duck/a1d190da701627c78b02dc73cea37e404f64c002/settings_duck.jar
--------------------------------------------------------------------------------