diff --git a/README.md b/README.md index 6896d46..1de51d6 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Mr. Vector ========== ![Mr. Vector](http://i.imgur.com/ucFr5T7.png) -AKA VectorDrawableCompat: A 14+ backport of [VectorDrawable](https://developer.android.com/reference/android/graphics/drawable/VectorDrawable.html). +AKA VectorDrawableCompat: A 7+ backport of [VectorDrawable](https://developer.android.com/reference/android/graphics/drawable/VectorDrawable.html). ### Demo diff --git a/demo/src/main/res/layout/activity_basic_inflate.xml b/demo/src/main/res/layout/activity_basic_inflate.xml index 7a8bbe2..0aafd04 100644 --- a/demo/src/main/res/layout/activity_basic_inflate.xml +++ b/demo/src/main/res/layout/activity_basic_inflate.xml @@ -25,6 +25,6 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" - android:background="?android:selectableItemBackground" + android:background="?selectableItemBackground" /> \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 1101e44..19dcc48 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ POM_NAME=Mr. Vector Library POM_ARTIFACT_ID=mrvector POM_PACKAGING=aar -POM_DESCRIPTION=Mr. Vector (VectorDrawableCompat): A 14+ backport of VectorDrawable +POM_DESCRIPTION=Mr. Vector (VectorDrawableCompat): A 7+ backport of VectorDrawable POM_URL=https://github.com/telly/MrVector POM_SCM_URL=https://github.com/telly/MrVector POM_SCM_CONNECTION=scm:git@github.com:telly/MrVector.git @@ -17,7 +17,7 @@ POM_LICENCE_DIST=repo POM_DEVELOPER_ID=eveliotc POM_DEVELOPER_NAME=Evelio Tarazona Caceres -ANDROID_BUILD_MIN_SDK_VERSION=14 +ANDROID_BUILD_MIN_SDK_VERSION=7 ANDROID_BUILD_TARGET_SDK_VERSION=21 ANDROID_BUILD_SDK_VERSION=21 ANDROID_BUILD_TOOLS_VERSION=21.1.2 diff --git a/library/src/main/java/com/telly/mrvector/PathParser.java b/library/src/main/java/com/telly/mrvector/PathParser.java index e5220e0..71119b0 100644 --- a/library/src/main/java/com/telly/mrvector/PathParser.java +++ b/library/src/main/java/com/telly/mrvector/PathParser.java @@ -18,7 +18,6 @@ import android.util.Log; import java.util.ArrayList; -import java.util.Arrays; import static android.os.Build.VERSION_CODES.LOLLIPOP; @@ -189,7 +188,7 @@ private static float[] getFloats(String s) { startPosition = endPosition + 1; } } - return Arrays.copyOf(results, count); + return Utils.copyOf(results, count); } catch (NumberFormatException e) { Log.e(LOGTAG, "error in parsing \"" + s + "\""); throw e; @@ -247,7 +246,7 @@ private PathDataNode(char type, float[] params) { private PathDataNode(PathDataNode n) { mType = n.mType; - mParams = Arrays.copyOf(n.mParams, n.mParams.length); + mParams = Utils.copyOf(n.mParams, n.mParams.length); } /** diff --git a/library/src/main/java/com/telly/mrvector/Utils.java b/library/src/main/java/com/telly/mrvector/Utils.java index c068e39..ec73644 100644 --- a/library/src/main/java/com/telly/mrvector/Utils.java +++ b/library/src/main/java/com/telly/mrvector/Utils.java @@ -27,8 +27,6 @@ import android.util.Log; import java.lang.reflect.Method; -import java.util.HashMap; -import java.util.Map; import static android.graphics.PorterDuff.Mode; import static android.graphics.PorterDuff.Mode.SRC_IN; @@ -87,6 +85,7 @@ static int getLayoutDirection(Drawable drawable) { * * @hide */ + @TargetApi(Build.VERSION_CODES.HONEYCOMB) static Mode parseTintMode(int value, Mode defaultMode) { switch (value) { case 3: return Mode.SRC_OVER; @@ -133,4 +132,26 @@ static int getChangingConfigurations(TypedArray a) { } return 0; } + + static float[] copyOf(float[] original, int newLength) { + if (newLength < 0) { + throw new NegativeArraySizeException(Integer.toString(newLength)); + } + return copyOfRange(original, 0, newLength); + } + + static float[] copyOfRange(float[] original, int start, int end) { + if (start > end) { + throw new IllegalArgumentException(); + } + int originalLength = original.length; + if (start < 0 || start > originalLength) { + throw new ArrayIndexOutOfBoundsException(); + } + int resultLength = end - start; + int copyLength = Math.min(resultLength, originalLength - start); + float[] result = new float[resultLength]; + System.arraycopy(original, start, result, 0, copyLength); + return result; + } }