Skip to content

Commit

Permalink
Merge pull request #7 from telly/zero_point_two_point_zero
Browse files Browse the repository at this point in the history
Zero point two point zero
  • Loading branch information
eveliotc committed Dec 30, 2014
2 parents df4c821 + 97a654f commit a5ff0e7
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# Generated files
bin/
gen/
release/

# Gradle files
.gradle/
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
### 0.2.0
- minSdk 7

### 0.1.0
- First Release
- Basic manual inflate
- minSdk 14
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -12,10 +12,10 @@ AKA VectorDrawableCompat: A 14+ backport of [VectorDrawable](https://developer.a

### Usage

See demo, at this point latest version is `0.1.0`
See demo, at this point latest version looks like

```groovy
compile 'com.telly:mrvector:(insert latest version)'
compile 'com.telly:mrvector:0.2.0'
```

### Basic inflate
Expand Down
2 changes: 1 addition & 1 deletion demo/src/main/res/layout/activity_basic_inflate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
/>
</FrameLayout>
Binary file added extras/banner.sketch
Binary file not shown.
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
VERSION_NAME=0.1.0
VERSION_CODE=1
VERSION_NAME=0.2.0
VERSION_CODE=2
GROUP=com.telly

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
Expand All @@ -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
Expand Down
5 changes: 2 additions & 3 deletions library/src/main/java/com/telly/mrvector/PathParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import android.util.Log;

import java.util.ArrayList;
import java.util.Arrays;

import static android.os.Build.VERSION_CODES.LOLLIPOP;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

/**
Expand Down
25 changes: 23 additions & 2 deletions library/src/main/java/com/telly/mrvector/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}

0 comments on commit a5ff0e7

Please sign in to comment.