Skip to content

Commit

Permalink
适配 Shape 圆角属性布局反方向特性
Browse files Browse the repository at this point in the history
适配 Shape 渐变色属性布局反方面特性
  • Loading branch information
getActivity committed Jul 14, 2024
1 parent 9e6c9d4 commit d640f48
Show file tree
Hide file tree
Showing 23 changed files with 780 additions and 273 deletions.
36 changes: 36 additions & 0 deletions Adaptive.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,42 @@

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

#### 从 9.0 版本升级到 9.2 版本适配方案

* 新增属性

* 新增 `app:shape_radiusInTopStart` 属性

* 新增 `app:shape_radiusInTopEnd` 属性

* 新增 `app:shape_radiusInBottomStart` 属性

* 新增 `app:shape_radiusInBottomEnd` 属性

* 补充属性值

*`app:shape_solidGradientOrientation``app:shape_strokeGradientOrientation` 属性补充了几个布局反方向特性适配的属性值

```
<!-- 从左到右绘制渐变(0 度) -->
<enum name="startToEnd" value="10" />
<!-- 从右到左绘制渐变(180 度) -->
<enum name="endToStart" value="1800" />
<!-- 从左上角到右下角绘制渐变(315 度) -->
<enum name="topStartToBottomEnd" value="3150" />
<!-- 从左下角到右上角绘制渐变(45 度) -->
<enum name="bottomStartToTopEnd" value="450" />
<!-- 从右上角到左下角绘制渐变(225 度) -->
<enum name="topEndToBottomStart" value="2250" />
<!-- 从右下角到左上角绘制渐变(135 度) -->
<enum name="bottomEndToTopStart" value="1350" />
```

#### 从 8.5 版本升级到 9.0 版本适配方案

* 新增
Expand Down
467 changes: 233 additions & 234 deletions README.md

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
minSdkVersion 17
// noinspection ExpiredTargetSdkVersion
targetSdkVersion 28
versionCode 90
versionName "9.0"
versionCode 920
versionName "9.2"
}

// 支持 Java JDK 8
Expand Down Expand Up @@ -42,9 +42,9 @@ android {
}
}

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

// 标题栏框架:https://github.com/getActivity/TitleBar
implementation 'com.github.getActivity:TitleBar:10.0'
implementation 'com.github.getActivity:TitleBar:10.5'

// 内存泄漏检测:https://github.com/square/leakcanary
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.10'
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.12'
}
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<application
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:roundIcon="@mipmap/ic_launcher_round"
android:theme="@style/AppTheme">

Expand Down
1 change: 0 additions & 1 deletion app/src/main/java/com/hjq/shape/demo/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

import com.hjq.bar.OnTitleBarListener;
import com.hjq.bar.TitleBar;
import com.hjq.shape.view.ShapeButton;
Expand Down
21 changes: 18 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,25 @@ allprojects {
jcenter()
}

// 将构建文件统一输出到项目根目录下的 build 文件夹
setBuildDir(new File(rootDir, "build/${path.replaceAll(':', '/')}"))
// 读取 local.properties 文件配置
def properties = new Properties()
def localPropertiesFile = rootProject.file("local.properties")
if (localPropertiesFile.exists()) {
localPropertiesFile.withInputStream { inputStream ->
properties.load(inputStream)
}
}

String buildDirPath = properties.getProperty("build.dir")
if (buildDirPath != null && buildDirPath != "") {
// 将构建文件统一输出到指定的目录下
setBuildDir(new File(buildDirPath, rootProject.name + "/build/${path.replaceAll(':', '/')}"))
} else {
// 将构建文件统一输出到项目根目录下的 build 文件夹
setBuildDir(new File(rootDir, "build/${path.replaceAll(':', '/')}"))
}
}

task clean(type: Delete) {
tasks.register('clean', Delete) {
delete rootProject.buildDir
}
19 changes: 10 additions & 9 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ android {

defaultConfig {
minSdkVersion 17
versionCode 90
versionName "9.0"
versionCode 920
versionName "9.2"
}

// 支持 Java JDK 8
Expand All @@ -15,17 +15,17 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8
}

android.libraryVariants.all { variant ->
android.libraryVariants.configureEach { variant ->
// aar 输出文件名配置
variant.outputs.all { output ->
variant.outputs.configureEach { output ->
outputFileName = "${rootProject.name}-${android.defaultConfig.versionName}.aar"
}
}
}

dependencies {
// ShapeDrawable:https://github.com/getActivity/ShapeDrawable
implementation 'com.github.getActivity:ShapeDrawable:3.0'
implementation 'com.github.getActivity:ShapeDrawable:3.2'
}

afterEvaluate {
Expand All @@ -42,23 +42,24 @@ dependencies {
}

// 防止编码问题
tasks.withType(Javadoc) {
tasks.withType(Javadoc).configureEach {
options.addStringOption('Xdoclint:none', '-quiet')
options.addStringOption('encoding', 'UTF-8')
options.addStringOption('charSet', 'UTF-8')
}

task sourcesJar(type: Jar) {
tasks.register('sourcesJar', Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}

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

task javadocJar(type: Jar, dependsOn: javadoc) {
tasks.register('javadocJar', Jar) {
dependsOn javadoc
classifier = 'javadoc'
from javadoc.destinationDir
}
Expand Down
Loading

0 comments on commit d640f48

Please sign in to comment.