Skip to content

Commit 940c6e4

Browse files
committed
2.2: drawable color changes with text color changing when tinting is on
1 parent 62de19e commit 940c6e4

File tree

4 files changed

+32
-9
lines changed

4 files changed

+32
-9
lines changed

build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
buildscript {
44
repositories {
55
jcenter()
6+
google()
67
}
78
dependencies {
8-
classpath 'com.android.tools.build:gradle:2.3.3'
9+
classpath 'com.android.tools.build:gradle:3.0.0'
910

1011
// NOTE: Do not place your application dependencies here; they belong
1112
// in the individual module build.gradle files
@@ -15,6 +16,7 @@ buildscript {
1516
allprojects {
1617
repositories {
1718
jcenter()
19+
google()
1820
}
1921
}
2022

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Sun Mar 19 16:11:51 CST 2017
1+
#Tue Nov 07 14:08:50 CST 2017
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip

vectorcompattextview/build.gradle

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

33
android {
4-
compileSdkVersion 26
5-
buildToolsVersion "26.0.2"
4+
compileSdkVersion 27
5+
buildToolsVersion "27.0.1"
66

77
defaultConfig {
88
minSdkVersion 9
9-
targetSdkVersion 26
10-
versionCode 9
11-
versionName "2.1"
9+
targetSdkVersion 27
10+
versionCode 10
11+
versionName "2.2"
1212

1313
}
1414
buildTypes {
@@ -20,5 +20,5 @@ android {
2020
}
2121

2222
dependencies {
23-
provided 'com.android.support:appcompat-v7:26.0.0-alpha1'
23+
provided 'com.android.support:appcompat-v7:27.0.0'
2424
}

vectorcompattextview/src/main/java/com/xw/repo/VectorCompatTextView.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,4 +245,25 @@ public void toggle() {
245245
Drawable[] drawables = getCompoundDrawables();
246246
initDrawables(drawables[0], drawables[1], drawables[2], drawables[3]);
247247
}
248+
249+
@Override
250+
protected void drawableStateChanged() {
251+
super.drawableStateChanged();
252+
253+
if (isTintDrawableInTextColor) {
254+
Drawable[] drawables = getCompoundDrawables();
255+
256+
boolean needRefresh = false;
257+
for (Drawable drawable : drawables) {
258+
if (drawable != null) {
259+
needRefresh = true;
260+
break;
261+
}
262+
}
263+
264+
if (needRefresh) {
265+
refreshCompoundDrawables();
266+
}
267+
}
268+
}
248269
}

0 commit comments

Comments
 (0)