Skip to content

Commit

Permalink
Initial commit :octocat:
Browse files Browse the repository at this point in the history
  • Loading branch information
eveliotc committed Dec 22, 2014
0 parents commit bb268b1
Show file tree
Hide file tree
Showing 48 changed files with 4,185 additions and 0 deletions.
129 changes: 129 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# Created by http://www.gitignore.io

### Android ###
# Built application files
*.apk
*.ap_

# Files for the Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin/
gen/

# Gradle files
.gradle/
build/
.gradletasknamecache

# Local configuration file (sdk path, etc)
local.properties

# Proguard folder generated by Eclipse
proguard/

#Log Files
*.log


### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm

## Directory-based project format
.idea/
# if you remove the above rule, at least ignore user-specific stuff:
# .idea/workspace.xml
# .idea/tasks.xml
# and these sensitive or high-churn files:
# .idea/dataSources.ids
# .idea/dataSources.xml
# .idea/sqlDataSources.xml
# .idea/dynamic.xml

## File-based project format
*.ipr
*.iml
*.iws

## Additional for IntelliJ
out/

# generated by mpeltonen/sbt-idea plugin
.idea_modules/

# generated by JIRA plugin
atlassian-ide-plugin.xml

# generated by Crashlytics plugin (for Android Studio and Intellij)
com_crashlytics_export_strings.xml


### Gradle ###
.gradle
build/

# Ignore Gradle GUI config
gradle-app.setting


### Eclipse ###
*.pydevproject
.metadata
.gradle
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath

# External tool builders
.externalToolBuilders/

# Locally stored "Eclipse launch configurations"
*.launch

# CDT-specific
.cproject

# PDT-specific
.buildpath

# sbteclipse plugin
.target

# TeXlipse plugin
.texlipse


### OSX ###
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon



# Thumbnails
._*

# Files that might appear on external disk
.Spotlight-V100
.Trashes

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

20 changes: 20 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Copyright Telly, Inc. and other contributors.

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the
following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
THE USE OR OTHER DEALINGS IN THE SOFTWARE.
114 changes: 114 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
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).

### Demo

![Le demo](http://i.imgur.com/nG4uQiN.gif)

[![Mr. Vector Demo on Google Play Store](http://developer.android.com/images/brand/en_generic_rgb_wo_60.png)](https://play.google.com/store/apps/details?id=com.telly.mrvector.demo)

### Usage

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

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

### Basic inflate
```java
Drawable drawable = MrVector.inflate(getResources(), R.drawable.vector_android);
```

Unfortunately due some inflate weirdness (able to read some correctly but not others) for now (will fix promise) you'll have to duplicate (sucks I know) all your `android:` attributes, in example:


```xml
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:auto="http://schemas.android.com/apk/res-auto"
tools:targetApi="21"

auto:width="@dimen/simple_vector_width"
auto:height="@dimen/simple_vector_height"
auto:viewportWidth="@integer/simple_vector_viewport_width"
auto:viewportHeight="@integer/simple_vector_viewport_height"

android:width="@dimen/simple_vector_width"
android:height="@dimen/simple_vector_height"
android:viewportWidth="@integer/simple_vector_viewport_width"
android:viewportHeight="@integer/simple_vector_viewport_height"
>

<path
auto:strokeColor="@color/simple_vector_stroke_color"
auto:strokeWidth="@integer/simple_vector_stroke_width"
auto:pathData="@string/simple_vector_path_data"

android:strokeColor="@color/simple_vector_stroke_color"
android:strokeWidth="@integer/simple_vector_stroke_width"
android:pathData="@string/simple_vector_path_data"
/>
</vector>
```

### Inflate from Layout (WIP)

Use it as a regular drawable:

```xml
<!-- menu.xml -->
<!-- ... -->
android:icon="@drawable/vector_drawable"
<!-- ... -->
```

```xml
<!-- layout.xml -->
<!-- ... -->
android:src="@drawable/vector_drawable"
<!-- ... -->
```

And then from your `Application` or `Activity`:

```java
\\ ...
{{
MrVector.register(
R.drawable.vector_drawable,
R.drawable.another_vector_drawable,
\\ ...
);
}}
\\ ...
@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(MrVector.wrap(newBase));
}
\\ ...
```

### Roadmap
Right now only basic inflating works, this is the list of features planed:

- [ ] Put this in GH issues.
- [ ] Full inflate from layout support (partially implemented except for `TypedArray` calling directly `loadDrawable`, which sadly is key)
- [ ] Get rid of `auto` namespace, use `android` namespace as much as possible (no duplicated attributes).
- [ ] Tint support.
- [ ] Animation support ([AnimatedVectorDrawable](https://developer.android.com/reference/android/graphics/drawable/AnimatedVectorDrawable.html)).

On the long run, it would be nice to see (but no promises):

- [ ] Per node animation.
- [ ] Additional SVG support (e.g. using [svg-android](https://code.google.com/p/svg-android/) or [svgandroid](https://code.google.com/p/androidsvg/)).
- [ ] SVG animation support.

### License & About

See LICENSE file, logo built from [opoloo/androidicons](https://github.com/opoloo/androidicons).

From [@eveliotc](https://plus.google.com/u/0/+EvelioTarazonaC%C3%A1ceres/posts) @ [Telly](https://telly.com/)
22 changes: 22 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
version = VERSION_NAME
group = GROUP

repositories {
mavenCentral()
}
}
27 changes: 27 additions & 0 deletions demo/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apply plugin: 'com.android.application'

dependencies {
compile project(':library')
compile "com.android.support:appcompat-v7:${project.ANDROID_SUPPORT_VERSION}@aar"
}

android {
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION

defaultConfig {
applicationId "${project.GROUP}.${project.POM_ARTIFACT_ID}.demo"
minSdkVersion Integer.parseInt(project.ANDROID_BUILD_MIN_SDK_VERSION)
targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION)
versionName project.VERSION_NAME
versionCode Integer.parseInt(project.VERSION_CODE)
buildConfigField "String", "ABOUT_URL", "\"${project.POM_URL}\""
}

buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
17 changes: 17 additions & 0 deletions demo/proguard-rules.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /opt/homebrew-cask/Caskroom/android-studio-bundle/0.4.2 build-133.970939/Android Studio.app/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
22 changes: 22 additions & 0 deletions demo/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.telly.mrvector.demo">

<application
android:label="@string/app_name"
android:icon="@drawable/ic_launcher"
android:theme="@style/AppTheme">
<activity
android:name=".BasicInflateActivity"
android:label="@string/title_activities">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:name=".InflateFromLayoutActivity"
android:label="@string/title_activities" />
</application>

</manifest>
Loading

0 comments on commit bb268b1

Please sign in to comment.