From e6c3027bbf20306abc0d157857290258b6d73d42 Mon Sep 17 00:00:00 2001 From: vssnake Date: Sun, 6 Mar 2016 16:06:21 +0100 Subject: [PATCH 1/3] update to app compact 23.2.0 --- demo/build.gradle | 8 ++++---- demo/src/main/res/layout/activity_main.xml | 4 ++-- library/build.gradle | 8 ++++---- .../vector/compat/AnimatedVectorDrawable.java | 5 +++-- .../com/wnafee/vector/compat/DrawableCompat.java | 14 ++++++++------ .../com/wnafee/vector/compat/VectorDrawable.java | 2 +- 6 files changed, 22 insertions(+), 19 deletions(-) diff --git a/demo/build.gradle b/demo/build.gradle index 109fe83..169f3bd 100644 --- a/demo/build.gradle +++ b/demo/build.gradle @@ -1,13 +1,13 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 22 - buildToolsVersion "22.0.1" + compileSdkVersion 23 + buildToolsVersion "23.0.2" defaultConfig { applicationId "com.wnafee.vector.compat.demo" minSdkVersion 14 - targetSdkVersion 22 + targetSdkVersion 23 versionCode 1 versionName "1.0" } @@ -21,6 +21,6 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:appcompat-v7:22.1.1' + compile 'com.android.support:appcompat-v7:23.2.0' compile project(':library') } diff --git a/demo/src/main/res/layout/activity_main.xml b/demo/src/main/res/layout/activity_main.xml index 1e53972..ca533d3 100644 --- a/demo/src/main/res/layout/activity_main.xml +++ b/demo/src/main/res/layout/activity_main.xml @@ -54,7 +54,7 @@ android:background="?android:selectableItemBackground" android:scaleType="center" app:vc_backgroundTint="#6A1B9A" - app:vc_startDrawable="@drawable/abc_btn_check_to_on_mtrl_000" - app:vc_endDrawable="@drawable/abc_btn_check_to_on_mtrl_015"/> + app:vc_startDrawable="@drawable/abc_btn_checkbox_checked_mtrl" + app:vc_endDrawable="@drawable/abc_btn_checkbox_unchecked_mtrl"/> diff --git a/library/build.gradle b/library/build.gradle index 0830d96..6062066 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -1,8 +1,8 @@ apply plugin: 'com.android.library' android { - compileSdkVersion 22 - buildToolsVersion "22.0.1" + compileSdkVersion 23 + buildToolsVersion "23.0.2" lintOptions { abortOnError false @@ -10,7 +10,7 @@ android { defaultConfig { minSdkVersion 14 - targetSdkVersion 22 + targetSdkVersion 23 versionCode 1 versionName "1.0" } @@ -24,6 +24,6 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:appcompat-v7:22.1.1' + compile 'com.android.support:appcompat-v7:23.2.0' apply from: 'https://raw.github.com/chrisbanes/gradle-mvn-push/master/gradle-mvn-push.gradle' } diff --git a/library/src/main/java/com/wnafee/vector/compat/AnimatedVectorDrawable.java b/library/src/main/java/com/wnafee/vector/compat/AnimatedVectorDrawable.java index 4539c4f..e0aeebe 100644 --- a/library/src/main/java/com/wnafee/vector/compat/AnimatedVectorDrawable.java +++ b/library/src/main/java/com/wnafee/vector/compat/AnimatedVectorDrawable.java @@ -152,8 +152,9 @@ public boolean setVisible(boolean visible, boolean restart) { return super.setVisible(visible, restart); } - public void setLayoutDirection(int layoutDirection) { - mAnimatedVectorState.mVectorDrawable.setLayoutDirection(layoutDirection); + @Override + public boolean setSupportLayoutDirection(int layoutDirection) { + return mAnimatedVectorState.mVectorDrawable.setSupportLayoutDirection(layoutDirection); } @Override diff --git a/library/src/main/java/com/wnafee/vector/compat/DrawableCompat.java b/library/src/main/java/com/wnafee/vector/compat/DrawableCompat.java index 68eaae0..a5d6908 100644 --- a/library/src/main/java/com/wnafee/vector/compat/DrawableCompat.java +++ b/library/src/main/java/com/wnafee/vector/compat/DrawableCompat.java @@ -27,7 +27,7 @@ public abstract class DrawableCompat extends Drawable { - int mLayoutDirection; + int mSupportLayoutDirecction; public static abstract class ConstantStateCompat extends ConstantState { @@ -77,14 +77,16 @@ public void getHotspotBounds(Rect outRect) { outRect.set(getBounds()); } - public int getLayoutDirection() { - return mLayoutDirection; + public int getSupportLayoutDirecction() { + return mSupportLayoutDirecction; } - public void setLayoutDirection(int layoutDirection) { - if (getLayoutDirection() != layoutDirection) { - mLayoutDirection = layoutDirection; + public boolean setSupportLayoutDirection(int layoutDirection) { + + if (getSupportLayoutDirecction() != layoutDirection) { + mSupportLayoutDirecction = layoutDirection; } + return false; } /** diff --git a/library/src/main/java/com/wnafee/vector/compat/VectorDrawable.java b/library/src/main/java/com/wnafee/vector/compat/VectorDrawable.java index 51d1aaa..b33c480 100644 --- a/library/src/main/java/com/wnafee/vector/compat/VectorDrawable.java +++ b/library/src/main/java/com/wnafee/vector/compat/VectorDrawable.java @@ -503,7 +503,7 @@ void setAllowCaching(boolean allowCaching) { } private boolean needMirroring() { - return isAutoMirrored() && getLayoutDirection() == 1; // 1 is for LayoutDirection.RTL + return isAutoMirrored() && getSupportLayoutDirecction() == 1; // 1 is for LayoutDirection.RTL } @Override From b78b7b6eb35a9df73651cc8338aecf4d40f2005d Mon Sep 17 00:00:00 2001 From: vssnake Date: Sun, 6 Mar 2016 16:36:30 +0100 Subject: [PATCH 2/3] Fix for android 4.4 and below --- build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 4 ++-- library/build.gradle | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index d3ff69d..009b2d0 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:1.1.0' + classpath 'com.android.tools.build:gradle:2.0.0-beta6' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 0c71e76..c3fd65f 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Wed Apr 10 15:27:10 PDT 2013 +#Sun Mar 06 16:32:57 CET 2016 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip diff --git a/library/build.gradle b/library/build.gradle index 6062066..1d97e00 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -13,6 +13,8 @@ android { targetSdkVersion 23 versionCode 1 versionName "1.0" + + vectorDrawables.useSupportLibrary = true } buildTypes { release { From 48a3d82ac428bb418b716cb47cdcf34a6761e1f2 Mon Sep 17 00:00:00 2001 From: vssnake Date: Sun, 27 Mar 2016 16:33:01 +0200 Subject: [PATCH 3/3] update to main grade version --- demo/build.gradle | 2 ++ demo/src/main/res/layout/activity_main.xml | 11 ++++++----- demo/src/main/res/values/strings.xml | 4 ++++ .../com/wnafee/vector/compat/ResourcesCompat.java | 9 ++++----- .../res/{anim => animator}/arrow_to_drawer_path.xml | 0 .../{anim => animator}/arrow_to_drawer_rotation.xml | 0 .../res/{anim => animator}/drawer_to_arrow_path.xml | 0 .../{anim => animator}/drawer_to_arrow_rotation.xml | 0 .../res/{anim => animator}/pause_to_play_path.xml | 0 .../res/{anim => animator}/pause_to_play_rotation.xml | 0 .../res/{anim => animator}/play_to_pause_path.xml | 0 .../res/{anim => animator}/play_to_pause_rotation.xml | 0 .../main/res/{anim => animator}/play_to_stop_path.xml | 0 .../res/{anim => animator}/play_to_stop_rotation.xml | 0 .../main/res/{anim => animator}/stop_to_play_path.xml | 0 .../res/{anim => animator}/stop_to_play_rotation.xml | 0 library/src/main/res/drawable/ic_arrow_to_drawer.xml | 4 ++-- library/src/main/res/drawable/ic_drawer_to_arrow.xml | 4 ++-- library/src/main/res/drawable/ic_pause_to_play.xml | 4 ++-- library/src/main/res/drawable/ic_play_to_pause.xml | 4 ++-- library/src/main/res/drawable/ic_play_to_stop.xml | 4 ++-- library/src/main/res/drawable/ic_stop_to_play.xml | 4 ++-- 22 files changed, 28 insertions(+), 22 deletions(-) rename library/src/main/res/{anim => animator}/arrow_to_drawer_path.xml (100%) rename library/src/main/res/{anim => animator}/arrow_to_drawer_rotation.xml (100%) rename library/src/main/res/{anim => animator}/drawer_to_arrow_path.xml (100%) rename library/src/main/res/{anim => animator}/drawer_to_arrow_rotation.xml (100%) rename library/src/main/res/{anim => animator}/pause_to_play_path.xml (100%) rename library/src/main/res/{anim => animator}/pause_to_play_rotation.xml (100%) rename library/src/main/res/{anim => animator}/play_to_pause_path.xml (100%) rename library/src/main/res/{anim => animator}/play_to_pause_rotation.xml (100%) rename library/src/main/res/{anim => animator}/play_to_stop_path.xml (100%) rename library/src/main/res/{anim => animator}/play_to_stop_rotation.xml (100%) rename library/src/main/res/{anim => animator}/stop_to_play_path.xml (100%) rename library/src/main/res/{anim => animator}/stop_to_play_rotation.xml (100%) diff --git a/demo/build.gradle b/demo/build.gradle index 169f3bd..627c836 100644 --- a/demo/build.gradle +++ b/demo/build.gradle @@ -10,6 +10,8 @@ android { targetSdkVersion 23 versionCode 1 versionName "1.0" + + vectorDrawables.useSupportLibrary = true } buildTypes { release { diff --git a/demo/src/main/res/layout/activity_main.xml b/demo/src/main/res/layout/activity_main.xml index ca533d3..8ab1305 100644 --- a/demo/src/main/res/layout/activity_main.xml +++ b/demo/src/main/res/layout/activity_main.xml @@ -12,7 +12,7 @@ android:paddingTop="@dimen/activity_vertical_margin" tools:context=".MainActivity"> - + app:vc_startDrawable="@drawable/ic_drawer_to_arrow" + app:vc_endDrawable="@drawable/ic_arrow_to_drawer"/> --> - + app:vc_endDrawable="@drawable/abc_btn_checkbox_unchecked_mtrl"/> --> + diff --git a/demo/src/main/res/values/strings.xml b/demo/src/main/res/values/strings.xml index b657428..b7bfd33 100644 --- a/demo/src/main/res/values/strings.xml +++ b/demo/src/main/res/values/strings.xml @@ -3,4 +3,8 @@ Hello world! Settings + + + M10,20v-6h4v6h5v-8h3L12,3 2,12h3v8z + M1,21h4L5,9L1,9v12zM23,10c0,-1.1 -0.9,-2 -2,-2h-6.31l0.95,-4.57 0.03,-0.32c0,-0.41 -0.17,-0.79 -0.44,-1.06L14.17,1 7.59,7.59C7.22,7.95 7,8.45 7,9v10c0,1.1 0.9,2 2,2h9c0.83,0 1.54,-0.5 1.84,-1.22l3.02,-7.05c0.09,-0.23 0.14,-0.47 0.14,-0.73v-1.91l-0.01,-0.01L23,10z diff --git a/library/src/main/java/com/wnafee/vector/compat/ResourcesCompat.java b/library/src/main/java/com/wnafee/vector/compat/ResourcesCompat.java index d02619d..1618b6c 100644 --- a/library/src/main/java/com/wnafee/vector/compat/ResourcesCompat.java +++ b/library/src/main/java/com/wnafee/vector/compat/ResourcesCompat.java @@ -5,6 +5,7 @@ import android.content.res.Resources; import android.graphics.drawable.Drawable; import android.os.Build; +import android.support.v4.content.ContextCompat; /** * Copyright (C) 2015 Wael Nafee @@ -28,11 +29,9 @@ public class ResourcesCompat { public static Drawable getDrawable(Context c, int resId) { Drawable d; try { - if (LOLLIPOP) { - d = c.getResources().getDrawable(resId, c.getTheme()); - } else { - d = c.getResources().getDrawable(resId); - } + + + d = ContextCompat.getDrawable(c,resId); } catch (Resources.NotFoundException e) { try { diff --git a/library/src/main/res/anim/arrow_to_drawer_path.xml b/library/src/main/res/animator/arrow_to_drawer_path.xml similarity index 100% rename from library/src/main/res/anim/arrow_to_drawer_path.xml rename to library/src/main/res/animator/arrow_to_drawer_path.xml diff --git a/library/src/main/res/anim/arrow_to_drawer_rotation.xml b/library/src/main/res/animator/arrow_to_drawer_rotation.xml similarity index 100% rename from library/src/main/res/anim/arrow_to_drawer_rotation.xml rename to library/src/main/res/animator/arrow_to_drawer_rotation.xml diff --git a/library/src/main/res/anim/drawer_to_arrow_path.xml b/library/src/main/res/animator/drawer_to_arrow_path.xml similarity index 100% rename from library/src/main/res/anim/drawer_to_arrow_path.xml rename to library/src/main/res/animator/drawer_to_arrow_path.xml diff --git a/library/src/main/res/anim/drawer_to_arrow_rotation.xml b/library/src/main/res/animator/drawer_to_arrow_rotation.xml similarity index 100% rename from library/src/main/res/anim/drawer_to_arrow_rotation.xml rename to library/src/main/res/animator/drawer_to_arrow_rotation.xml diff --git a/library/src/main/res/anim/pause_to_play_path.xml b/library/src/main/res/animator/pause_to_play_path.xml similarity index 100% rename from library/src/main/res/anim/pause_to_play_path.xml rename to library/src/main/res/animator/pause_to_play_path.xml diff --git a/library/src/main/res/anim/pause_to_play_rotation.xml b/library/src/main/res/animator/pause_to_play_rotation.xml similarity index 100% rename from library/src/main/res/anim/pause_to_play_rotation.xml rename to library/src/main/res/animator/pause_to_play_rotation.xml diff --git a/library/src/main/res/anim/play_to_pause_path.xml b/library/src/main/res/animator/play_to_pause_path.xml similarity index 100% rename from library/src/main/res/anim/play_to_pause_path.xml rename to library/src/main/res/animator/play_to_pause_path.xml diff --git a/library/src/main/res/anim/play_to_pause_rotation.xml b/library/src/main/res/animator/play_to_pause_rotation.xml similarity index 100% rename from library/src/main/res/anim/play_to_pause_rotation.xml rename to library/src/main/res/animator/play_to_pause_rotation.xml diff --git a/library/src/main/res/anim/play_to_stop_path.xml b/library/src/main/res/animator/play_to_stop_path.xml similarity index 100% rename from library/src/main/res/anim/play_to_stop_path.xml rename to library/src/main/res/animator/play_to_stop_path.xml diff --git a/library/src/main/res/anim/play_to_stop_rotation.xml b/library/src/main/res/animator/play_to_stop_rotation.xml similarity index 100% rename from library/src/main/res/anim/play_to_stop_rotation.xml rename to library/src/main/res/animator/play_to_stop_rotation.xml diff --git a/library/src/main/res/anim/stop_to_play_path.xml b/library/src/main/res/animator/stop_to_play_path.xml similarity index 100% rename from library/src/main/res/anim/stop_to_play_path.xml rename to library/src/main/res/animator/stop_to_play_path.xml diff --git a/library/src/main/res/anim/stop_to_play_rotation.xml b/library/src/main/res/animator/stop_to_play_rotation.xml similarity index 100% rename from library/src/main/res/anim/stop_to_play_rotation.xml rename to library/src/main/res/animator/stop_to_play_rotation.xml diff --git a/library/src/main/res/drawable/ic_arrow_to_drawer.xml b/library/src/main/res/drawable/ic_arrow_to_drawer.xml index a98e94b..4698cdb 100644 --- a/library/src/main/res/drawable/ic_arrow_to_drawer.xml +++ b/library/src/main/res/drawable/ic_arrow_to_drawer.xml @@ -4,9 +4,9 @@ + android:animation="@animator/arrow_to_drawer_rotation" /> + android:animation="@animator/arrow_to_drawer_path" /> diff --git a/library/src/main/res/drawable/ic_drawer_to_arrow.xml b/library/src/main/res/drawable/ic_drawer_to_arrow.xml index d09f7b4..5779bbc 100644 --- a/library/src/main/res/drawable/ic_drawer_to_arrow.xml +++ b/library/src/main/res/drawable/ic_drawer_to_arrow.xml @@ -4,9 +4,9 @@ + android:animation="@animator/drawer_to_arrow_rotation" /> + android:animation="@animator/drawer_to_arrow_path" /> diff --git a/library/src/main/res/drawable/ic_pause_to_play.xml b/library/src/main/res/drawable/ic_pause_to_play.xml index 7e5b289..efecfa8 100644 --- a/library/src/main/res/drawable/ic_pause_to_play.xml +++ b/library/src/main/res/drawable/ic_pause_to_play.xml @@ -4,9 +4,9 @@ + android:animation="@animator/pause_to_play_rotation" /> + android:animation="@animator/pause_to_play_path" /> diff --git a/library/src/main/res/drawable/ic_play_to_pause.xml b/library/src/main/res/drawable/ic_play_to_pause.xml index bf30752..0daa9cb 100644 --- a/library/src/main/res/drawable/ic_play_to_pause.xml +++ b/library/src/main/res/drawable/ic_play_to_pause.xml @@ -4,9 +4,9 @@ + android:animation="@animator/play_to_pause_rotation" /> + android:animation="@animator/play_to_pause_path" /> diff --git a/library/src/main/res/drawable/ic_play_to_stop.xml b/library/src/main/res/drawable/ic_play_to_stop.xml index 028ab5c..d971e94 100644 --- a/library/src/main/res/drawable/ic_play_to_stop.xml +++ b/library/src/main/res/drawable/ic_play_to_stop.xml @@ -4,9 +4,9 @@ + android:animation="@animator/play_to_stop_rotation" /> + android:animation="@animator/play_to_stop_path" /> diff --git a/library/src/main/res/drawable/ic_stop_to_play.xml b/library/src/main/res/drawable/ic_stop_to_play.xml index c6153be..d57d0dd 100644 --- a/library/src/main/res/drawable/ic_stop_to_play.xml +++ b/library/src/main/res/drawable/ic_stop_to_play.xml @@ -4,9 +4,9 @@ + android:animation="@animator/stop_to_play_rotation" /> + android:animation="@animator/stop_to_play_path" />