Skip to content

Commit d640f48

Browse files
committed
适配 Shape 圆角属性布局反方向特性
适配 Shape 渐变色属性布局反方面特性
1 parent 9e6c9d4 commit d640f48

23 files changed

Lines changed: 780 additions & 273 deletions

Adaptive.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,42 @@
22

33
* 你好,如果你是刚使用这个库的人可以不必理会,如果你之前使用了 `ShapeView` 这个库,也就是 `9.0` 版本以下的,在升级到 `9.0` 版本后需要进行适配,否则 `Android Studio` 会报错`编译不通过`,对于这个问题我表示十分抱歉,低版本的 `xml` 属性命名得并不是很规范,现在在 `9.0` 版本进行优化,尽管这次的代价比较大,但是我会义无反顾去做,如果你使用了 `ShapeView ` 但是不想进行适配,请不要升级依赖库版本。
44

5+
#### 从 9.0 版本升级到 9.2 版本适配方案
6+
7+
* 新增属性
8+
9+
* 新增 `app:shape_radiusInTopStart` 属性
10+
11+
* 新增 `app:shape_radiusInTopEnd` 属性
12+
13+
* 新增 `app:shape_radiusInBottomStart` 属性
14+
15+
* 新增 `app:shape_radiusInBottomEnd` 属性
16+
17+
* 补充属性值
18+
19+
*`app:shape_solidGradientOrientation``app:shape_strokeGradientOrientation` 属性补充了几个布局反方向特性适配的属性值
20+
21+
```
22+
<!-- 从左到右绘制渐变(0 度) -->
23+
<enum name="startToEnd" value="10" />
24+
25+
<!-- 从右到左绘制渐变(180 度) -->
26+
<enum name="endToStart" value="1800" />
27+
28+
<!-- 从左上角到右下角绘制渐变(315 度) -->
29+
<enum name="topStartToBottomEnd" value="3150" />
30+
31+
<!-- 从左下角到右上角绘制渐变(45 度) -->
32+
<enum name="bottomStartToTopEnd" value="450" />
33+
34+
<!-- 从右上角到左下角绘制渐变(225 度) -->
35+
<enum name="topEndToBottomStart" value="2250" />
36+
37+
<!-- 从右下角到左上角绘制渐变(135 度) -->
38+
<enum name="bottomEndToTopStart" value="1350" />
39+
```
40+
541
#### 从 8.5 版本升级到 9.0 版本适配方案
642

743
* 新增

README.md

Lines changed: 233 additions & 234 deletions
Large diffs are not rendered by default.

app/build.gradle

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ android {
88
minSdkVersion 17
99
// noinspection ExpiredTargetSdkVersion
1010
targetSdkVersion 28
11-
versionCode 90
12-
versionName "9.0"
11+
versionCode 920
12+
versionName "9.2"
1313
}
1414

1515
// 支持 Java JDK 8
@@ -42,9 +42,9 @@ android {
4242
}
4343
}
4444

45-
applicationVariants.all { variant ->
45+
applicationVariants.configureEach { variant ->
4646
// apk 输出文件名配置
47-
variant.outputs.all { output ->
47+
variant.outputs.configureEach { output ->
4848
outputFileName = rootProject.getName() + '.apk'
4949
}
5050
}
@@ -60,8 +60,8 @@ dependencies {
6060
implementation 'com.android.support:design:28.0.0'
6161

6262
// 标题栏框架:https://github.com/getActivity/TitleBar
63-
implementation 'com.github.getActivity:TitleBar:10.0'
63+
implementation 'com.github.getActivity:TitleBar:10.5'
6464

6565
// 内存泄漏检测:https://github.com/square/leakcanary
66-
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.10'
66+
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.12'
6767
}

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<application
66
android:icon="@mipmap/ic_launcher"
77
android:label="@string/app_name"
8+
android:supportsRtl="true"
89
android:roundIcon="@mipmap/ic_launcher_round"
910
android:theme="@style/AppTheme">
1011

app/src/main/java/com/hjq/shape/demo/MainActivity.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import android.os.Bundle;
66
import android.support.v7.app.AppCompatActivity;
77
import android.view.View;
8-
98
import com.hjq.bar.OnTitleBarListener;
109
import com.hjq.bar.TitleBar;
1110
import com.hjq.shape.view.ShapeButton;

build.gradle

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,25 @@ allprojects {
2929
jcenter()
3030
}
3131

32-
// 将构建文件统一输出到项目根目录下的 build 文件夹
33-
setBuildDir(new File(rootDir, "build/${path.replaceAll(':', '/')}"))
32+
// 读取 local.properties 文件配置
33+
def properties = new Properties()
34+
def localPropertiesFile = rootProject.file("local.properties")
35+
if (localPropertiesFile.exists()) {
36+
localPropertiesFile.withInputStream { inputStream ->
37+
properties.load(inputStream)
38+
}
39+
}
40+
41+
String buildDirPath = properties.getProperty("build.dir")
42+
if (buildDirPath != null && buildDirPath != "") {
43+
// 将构建文件统一输出到指定的目录下
44+
setBuildDir(new File(buildDirPath, rootProject.name + "/build/${path.replaceAll(':', '/')}"))
45+
} else {
46+
// 将构建文件统一输出到项目根目录下的 build 文件夹
47+
setBuildDir(new File(rootDir, "build/${path.replaceAll(':', '/')}"))
48+
}
3449
}
3550

36-
task clean(type: Delete) {
51+
tasks.register('clean', Delete) {
3752
delete rootProject.buildDir
3853
}

library/build.gradle

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ android {
55

66
defaultConfig {
77
minSdkVersion 17
8-
versionCode 90
9-
versionName "9.0"
8+
versionCode 920
9+
versionName "9.2"
1010
}
1111

1212
// 支持 Java JDK 8
@@ -15,17 +15,17 @@ android {
1515
sourceCompatibility JavaVersion.VERSION_1_8
1616
}
1717

18-
android.libraryVariants.all { variant ->
18+
android.libraryVariants.configureEach { variant ->
1919
// aar 输出文件名配置
20-
variant.outputs.all { output ->
20+
variant.outputs.configureEach { output ->
2121
outputFileName = "${rootProject.name}-${android.defaultConfig.versionName}.aar"
2222
}
2323
}
2424
}
2525

2626
dependencies {
2727
// ShapeDrawable:https://github.com/getActivity/ShapeDrawable
28-
implementation 'com.github.getActivity:ShapeDrawable:3.0'
28+
implementation 'com.github.getActivity:ShapeDrawable:3.2'
2929
}
3030

3131
afterEvaluate {
@@ -42,23 +42,24 @@ dependencies {
4242
}
4343

4444
// 防止编码问题
45-
tasks.withType(Javadoc) {
45+
tasks.withType(Javadoc).configureEach {
4646
options.addStringOption('Xdoclint:none', '-quiet')
4747
options.addStringOption('encoding', 'UTF-8')
4848
options.addStringOption('charSet', 'UTF-8')
4949
}
5050

51-
task sourcesJar(type: Jar) {
51+
tasks.register('sourcesJar', Jar) {
5252
from android.sourceSets.main.java.srcDirs
5353
classifier = 'sources'
5454
}
5555

56-
task javadoc(type: Javadoc) {
56+
tasks.register('javadoc', Javadoc) {
5757
source = android.sourceSets.main.java.srcDirs
5858
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
5959
}
6060

61-
task javadocJar(type: Jar, dependsOn: javadoc) {
61+
tasks.register('javadocJar', Jar) {
62+
dependsOn javadoc
6263
classifier = 'javadoc'
6364
from javadoc.destinationDir
6465
}

0 commit comments

Comments
 (0)