Skip to content

Commit 4ffd451

Browse files
committed
update to 1.5.5 适配android q
1 parent 0f4de68 commit 4ffd451

File tree

12 files changed

+73
-64
lines changed

12 files changed

+73
-64
lines changed

.idea/codeStyles/Project.xml

Lines changed: 0 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 6 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README-EN.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ A framework for directly generating shape through Tags, no need to write shape.x
77
Add this to your app's build.gradle:
88

99
implementation "com.android.support:appcompat-v7:$supportVersion"
10-
implementation 'com.noober.background:core:1.5.4'
10+
implementation 'com.noober.background:core:1.5.5'
1111

1212
if use androidx:
1313

1414
implementation "androidx.appcompat:appcompat:$supportVersion"
15-
implementation 'com.noober.background:core:1.5.4'
15+
implementation 'com.noober.background:core:1.5.5'
1616

1717

1818
## Example effect

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ A framework for directly generating shape through Tags, no need to write shape.x
1010
依赖方式:
1111

1212
implementation "com.android.support:appcompat-v7:$supportVersion"
13-
implementation 'com.noober.background:core:1.5.4'
13+
implementation 'com.noober.background:core:1.5.5'
1414

1515
如果项目使用了androidx:
1616

1717
implementation "androidx.appcompat:appcompat:$supportVersion"
18-
implementation 'com.noober.background:core:1.5.4'
18+
implementation 'com.noober.background:core:1.5.5'
1919

2020

2121
## 使用文档

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ dependencies {
3737
testImplementation 'junit:junit:4.12'
3838
androidTestImplementation 'com.android.support.test:runner:1.0.2'
3939
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
40-
// implementation 'com.noober.background:core:1.5.4'
41-
implementation project(':library')
40+
implementation 'com.noober.background:core:1.5.5'
41+
// implementation project(':library')
4242
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
4343
}

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ ext {
3636
userOrg = 'noober'
3737
groupId = 'com.noober.background'
3838
uploadName = 'LibraryForBackground'
39-
publishVersion = '1.5.4'
39+
publishVersion = '1.5.5'
4040
desc = "A framework for directly generating shape through Tags, no need to write shape.xml again(通过标签直接生成shape,无需再写shape.xml)"
4141
website = 'https://github.com/JavaNoober/BackgroundLibrary'
4242
// gradlew clean build bintrayUpload -PbintrayUser=xiaoqiandroid -PbintrayKey=xxxxxxxxxxxxxxxx -PdryRun=false

library/build.gradle

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ apply plugin: 'com.android.library'
22
apply plugin: 'bintray-release'
33

44
android {
5-
compileSdkVersion 28
5+
compileSdkVersion 29
66

77
defaultConfig {
88
minSdkVersion 14
9-
targetSdkVersion 28
9+
targetSdkVersion 29
1010
versionCode 1
1111
versionName "1.0"
1212
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
@@ -20,6 +20,10 @@ android {
2020
}
2121
}
2222

23+
lintOptions {
24+
abortOnError false
25+
}
26+
2327
}
2428

2529
dependencies {

library/src/main/java/com/noober/background/drawable/DrawableCreator.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -734,17 +734,19 @@ private GradientDrawable getGradientDrawable() {
734734
drawable.setGradientType(gradient.value);
735735
drawable.setUseLevel(useLevel);
736736
if (!padding.isEmpty()) {
737-
738-
try {
739-
Field paddingField = drawable.getClass().getField("mPadding");
740-
paddingField.setAccessible(true);
741-
paddingField.set(drawable, padding);
742-
} catch (NoSuchFieldException e) {
743-
e.printStackTrace();
744-
} catch (IllegalAccessException e) {
745-
e.printStackTrace();
737+
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
738+
drawable.setPadding(padding.left, padding.top, padding.right, padding.bottom);
739+
} else {
740+
try {
741+
Field paddingField = drawable.getClass().getDeclaredField("mPadding");
742+
paddingField.setAccessible(true);
743+
paddingField.set(drawable, padding);
744+
} catch (NoSuchFieldException e) {
745+
e.printStackTrace();
746+
} catch (IllegalAccessException e) {
747+
e.printStackTrace();
748+
}
746749
}
747-
748750
}
749751
if (sizeWidth != null && sizeHeight != null) {
750752
drawable.setSize(sizeWidth.intValue(), sizeHeight.intValue());

library/src/main/java/com/noober/background/drawable/GradientDrawableCreator.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -312,16 +312,19 @@ public Drawable create() throws XmlPullParserException {
312312
typedArray.hasValue(R.styleable.background_bl_padding_top) &&
313313
typedArray.hasValue(R.styleable.background_bl_padding_right) &&
314314
typedArray.hasValue(R.styleable.background_bl_padding_bottom)) {
315-
try {
316-
Field paddingField = drawable.getClass().getDeclaredField("mPadding");
317-
paddingField.setAccessible(true);
318-
paddingField.set(drawable, padding);
319-
} catch (NoSuchFieldException e) {
320-
e.printStackTrace();
321-
} catch (IllegalAccessException e) {
322-
e.printStackTrace();
315+
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
316+
drawable.setPadding(padding.left, padding.top, padding.right, padding.bottom);
317+
} else {
318+
try {
319+
Field paddingField = drawable.getClass().getDeclaredField("mPadding");
320+
paddingField.setAccessible(true);
321+
paddingField.set(drawable, padding);
322+
} catch (NoSuchFieldException e) {
323+
e.printStackTrace();
324+
} catch (IllegalAccessException e) {
325+
e.printStackTrace();
326+
}
323327
}
324-
325328
}
326329
return drawable;
327330
}

libraryx/build.gradle

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ apply plugin: 'com.android.library'
22
apply plugin: 'bintray-release'
33

44
android {
5-
compileSdkVersion 28
5+
compileSdkVersion 29
66

77
defaultConfig {
88
minSdkVersion 14
9-
targetSdkVersion 28
9+
targetSdkVersion 29
1010
versionCode 1
1111
versionName "1.0"
1212
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
@@ -20,12 +20,15 @@ android {
2020
}
2121
}
2222

23+
lintOptions {
24+
abortOnError false
25+
}
26+
2327
}
2428

2529
dependencies {
2630
implementation fileTree(dir: 'libs', include: ['*.jar'])
2731
compileOnly 'androidx.appcompat:appcompat:1.0.0'
28-
// implementation 'com.android.support:support-v4:28.0.0-rc02'
2932
compileOnly 'androidx.legacy:legacy-support-v4:1.0.0'
3033
compileOnly 'androidx.constraintlayout:constraintlayout:1.1.2'
3134
testImplementation 'junit:junit:4.12'

0 commit comments

Comments
 (0)