From c6034d94628a05193d2201f8bdad26c7474162e4 Mon Sep 17 00:00:00 2001 From: gherfray Date: Sat, 10 May 2014 21:28:09 +0200 Subject: [PATCH 1/4] Adding build.gradle to allow using it with Android Studio --- build.gradle | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 build.gradle diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..96b15d4 --- /dev/null +++ b/build.gradle @@ -0,0 +1,32 @@ +buildscript { + repositories { + mavenCentral() + } + + dependencies { + classpath 'com.android.tools.build:gradle:0.8.+' + } +} + +apply plugin: 'android' + +android { + + compileSdkVersion 19 + buildToolsVersion "19.0.3" + + defaultConfig { + minSdkVersion 8 + targetSdkVersion 19 + } + + sourceSets { + main { + manifest.srcFile 'AndroidManifest.xml' + java.srcDirs = ['src'] + resources.srcDirs = ['src'] + renderscript.srcDirs = ['src'] + res.srcDirs = ['res'] + } + } +} \ No newline at end of file From f2944da4590e9383b712c9e1a930194b924cfeeb Mon Sep 17 00:00:00 2001 From: gherfray Date: Sat, 10 May 2014 21:32:17 +0200 Subject: [PATCH 2/4] Using attribute with name "background" make error. Changing it into mtv_background (and changing foreground into mtv_foreground for logic). --- README.markdown | 2 +- res/layout/main.xml | 2 +- res/values/attrs.xml | 4 ++-- src/com/qwerjk/better_text/MagicTextView.java | 12 ++++++------ 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/README.markdown b/README.markdown index 6d5d310..d71bf53 100644 --- a/README.markdown +++ b/README.markdown @@ -35,7 +35,7 @@ From Xml: android:drawableLeft="@android:drawable/btn_star" android:textStyle="bold" android:padding="10dp" - qwerjk:foreground="@drawable/fake_luxury_tiled" + qwerjk:mtv_foreground="@drawable/fake_luxury_tiled" qwerjk:innerShadowDy="2" qwerjk:innerShadowColor="#FF000000" qwerjk:innerShadowRadius="1" diff --git a/res/layout/main.xml b/res/layout/main.xml index f7e3300..11c757c 100644 --- a/res/layout/main.xml +++ b/res/layout/main.xml @@ -15,7 +15,7 @@ android:drawableLeft="@android:drawable/btn_star" android:textStyle="bold" android:padding="10dp" - qwerjk:foreground="@drawable/fake_luxury_tiled" + qwerjk:mtv_foreground="@drawable/fake_luxury_tiled" qwerjk:innerShadowDy="2" qwerjk:innerShadowColor="#FF000000" qwerjk:innerShadowRadius="1" diff --git a/res/values/attrs.xml b/res/values/attrs.xml index b830580..ebeb29b 100644 --- a/res/values/attrs.xml +++ b/res/values/attrs.xml @@ -13,8 +13,8 @@ - - + + diff --git a/src/com/qwerjk/better_text/MagicTextView.java b/src/com/qwerjk/better_text/MagicTextView.java index b7bc4f8..025d525 100644 --- a/src/com/qwerjk/better_text/MagicTextView.java +++ b/src/com/qwerjk/better_text/MagicTextView.java @@ -73,21 +73,21 @@ public void init(AttributeSet attrs){ setTypeface(tf); } - if(a.hasValue(R.styleable.MagicTextView_foreground)){ - Drawable foreground = a.getDrawable(R.styleable.MagicTextView_foreground); + if(a.hasValue(R.styleable.MagicTextView_mtv_foreground)){ + Drawable foreground = a.getDrawable(R.styleable.MagicTextView_mtv_foreground); if(foreground != null){ this.setForegroundDrawable(foreground); }else{ - this.setTextColor(a.getColor(R.styleable.MagicTextView_foreground, 0xff000000)); + this.setTextColor(a.getColor(R.styleable.MagicTextView_mtv_foreground, 0xff000000)); } } - if(a.hasValue(R.styleable.MagicTextView_background)){ - Drawable background = a.getDrawable(R.styleable.MagicTextView_background); + if(a.hasValue(R.styleable.MagicTextView_mtv_background)){ + Drawable background = a.getDrawable(R.styleable.MagicTextView_mtv_background); if(background != null){ this.setBackgroundDrawable(background); }else{ - this.setBackgroundColor(a.getColor(R.styleable.MagicTextView_background, 0xff000000)); + this.setBackgroundColor(a.getColor(R.styleable.MagicTextView_mtv_background, 0xff000000)); } } From 854d1136effa4c67d84f203285d2a7788c312f09 Mon Sep 17 00:00:00 2001 From: gherfray Date: Sat, 10 May 2014 21:41:57 +0200 Subject: [PATCH 3/4] Adding documentation for Android Studio --- README.markdown | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/README.markdown b/README.markdown index d71bf53..6dfafc2 100644 --- a/README.markdown +++ b/README.markdown @@ -15,11 +15,35 @@ If anybody figures out how to do text paths, please let me know! Installation === +Eclipse +== + If you like you can import the project into eclipse, and use it as a library project [This is a decent tutorial on using library projects](http://www.vogella.com/blog/2011/03/03/android-library-projects/) Realistically, just copy MagicTextView.java & attrs.xml into your project and use them as your own. +Android Studio +== + +For using it with Android Studio: + + * Add the folder into your project + * Edit build.gradle and change apply plugin: 'android' into apply plugin: 'android-library' + * Remove activity tag in AndroidManifest.xml + * Add ':MagicTextView' in the includes of the settings.xml of your project + * Add compile project(':MagicTextView') in the dependencies section of the module in which you want to use the library + * Use it in this module + +You're done ! + +If you use it as a library into Android Studio, replace in your XML layout: + + xmlns:qwerjk="http://schemas.android.com/apk/res/com.qwerjk.better_text" + +By: + + xmlns:qwerjk="http://schemas.android.com/apk/res-auto" Usage === From abee89fccf76f538897aa058d8509deae840b556 Mon Sep 17 00:00:00 2001 From: gherfray Date: Sat, 10 May 2014 21:44:19 +0200 Subject: [PATCH 4/4] Improving format of documentation --- README.markdown | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.markdown b/README.markdown index 6dfafc2..2a18ef1 100644 --- a/README.markdown +++ b/README.markdown @@ -16,7 +16,7 @@ Installation === Eclipse -== +--- If you like you can import the project into eclipse, and use it as a library project [This is a decent tutorial on using library projects](http://www.vogella.com/blog/2011/03/03/android-library-projects/) @@ -24,15 +24,15 @@ If you like you can import the project into eclipse, and use it as a library pro Realistically, just copy MagicTextView.java & attrs.xml into your project and use them as your own. Android Studio -== +--- For using it with Android Studio: * Add the folder into your project - * Edit build.gradle and change apply plugin: 'android' into apply plugin: 'android-library' + * Edit build.gradle and change `apply plugin: 'android'` into `apply plugin: 'android-library'` * Remove activity tag in AndroidManifest.xml - * Add ':MagicTextView' in the includes of the settings.xml of your project - * Add compile project(':MagicTextView') in the dependencies section of the module in which you want to use the library + * Add `':MagicTextView'` in the includes of the settings.xml of your project + * Add `compile project(':MagicTextView')` in the dependencies section of the module in which you want to use the library * Use it in this module You're done !