Skip to content

Commit

Permalink
Merge pull request #3 from googolmo/dev
Browse files Browse the repository at this point in the history
Add Gradle Support
  • Loading branch information
Pkmmte Xeleon committed Jul 20, 2014
2 parents c7a7d79 + 696d13e commit 3411847
Show file tree
Hide file tree
Showing 17 changed files with 423 additions and 36 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ local.properties

# Proguard folder generated by Eclipse
proguard/

.idea/
*.iml
44 changes: 44 additions & 0 deletions CircularImageView-Sample/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion Integer.parseInt(project.COMPILE_SDK_VERSION)
buildToolsVersion project.BUILD_TOOLS_VERSION

defaultConfig {
minSdkVersion Integer.parseInt(project.MIN_SDK_VERSION)
targetSdkVersion Integer.parseInt(project.TARGET_SDK_VERSION)
versionCode Integer.parseInt(project.VERSION_CODE)
versionName project.VERSION_NAME
}

buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
}

}

}




dependencies {
compile project(':CircularImageView')
compile 'com.android.support:support-v4:20.0.0'
compile 'com.squareup.picasso:picasso:2.3.2'
compile 'com.squareup.okhttp:okhttp:2.0.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.0.0'
}

10 changes: 5 additions & 5 deletions CircularImageView-Sample/res/layout/footer.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http:https://schemas.android.com/apk/res/android"
xmlns:app="http:https://schemas.android.com/apk/res/com.pkmmte.circularimageview.sample"
xmlns:app="http:https://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
Expand Down Expand Up @@ -75,10 +75,10 @@
android:layout_height="72dp"
android:layout_margin="16dp"
android:src="@drawable/grumpy_cat"
app:border="true"
app:border_color="@android:color/white"
app:border_width="2dp"
app:shadow="true" />
app:civ_border="true"
app:civ_border_color="@android:color/white"
app:civ_border_width="2dp"
/>
</LinearLayout>

</LinearLayout>
18 changes: 9 additions & 9 deletions CircularImageView-Sample/res/layout/header.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<LinearLayout xmlns:android="http:https://schemas.android.com/apk/res/android"
xmlns:app="http:https://schemas.android.com/apk/res/com.pkmmte.circularimageview.sample"
xmlns:app="http:https://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
Expand All @@ -24,14 +24,14 @@
android:layout_margin="8dp"
android:clickable="true"
android:src="@drawable/doge"
app:border="true"
app:border_color="#FFFFFFFF"
app:border_width="4dp"
app:selector="true"
app:selector_color="#4403a9f4"
app:selector_stroke_color="#aa5677fc"
app:selector_stroke_width="4dp"
app:shadow="true" />
app:civ_border="true"
app:civ_border_color="#FFFFFFFF"
app:civ_border_width="4dp"
app:civ_selector="true"
app:civ_selector_color="#4403a9f4"
app:civ_selector_stroke_color="#aa5677fc"
app:civ_selector_stroke_width="4dp"
app:civ_shadow="true" />

<TextView
android:id="@+id/txtClick"
Expand Down
12 changes: 7 additions & 5 deletions CircularImageView-Sample/res/layout/row.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http:https://schemas.android.com/apk/res/android"
xmlns:app="http:https://schemas.android.com/apk/res/com.pkmmte.circularimageview.sample"
xmlns:app="http:https://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
Expand All @@ -16,10 +16,12 @@
android:layout_marginRight="16dp"
android:layout_marginTop="8dp"
android:clickable="true"
app:selector="true"
app:selector_color="#44FFBB33"
app:selector_stroke_color="#88FF8800"
app:selector_stroke_width="2dp" />
app:civ_selector="true"
app:civ_selector_color="#44FFBB33"
app:civ_selector_stroke_color="#88FF8800"
app:civ_selector_stroke_width="2dp"
app:civ_shadow="false"
/>

<TextView
android:layout_width="match_parent"
Expand Down
7 changes: 7 additions & 0 deletions CircularImageView-Sample/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,18 @@
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
<item name="circularImageViewStyle">@style/CircularImageViewStyle</item>
</style>

<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>

<style name="CircularImageViewStyle">
<item name="civ_border">true</item>
<item name="civ_shadow">true</item>

</style>

</resources>
31 changes: 31 additions & 0 deletions CircularImageView/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
apply plugin: 'com.android.library'

version = project.VERSION_NAME
group = project.GROUP

android {
compileSdkVersion Integer.parseInt(project.COMPILE_SDK_VERSION)
buildToolsVersion project.BUILD_TOOLS_VERSION

defaultConfig {
minSdkVersion Integer.parseInt(project.MIN_SDK_VERSION)
targetSdkVersion Integer.parseInt(project.TARGET_SDK_VERSION)
applicationId project.GROUP
versionName project.VERSION_NAME
versionCode Integer.parseInt(project.VERSION_CODE)
}

sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
}

}

}

3 changes: 3 additions & 0 deletions CircularImageView/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
POM_NAME=CircularImageView
POM_ARTIFACT_ID=circularimageview
POM_PACKAGING=aar
16 changes: 8 additions & 8 deletions CircularImageView/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@
<declare-styleable name="CircularImageView">

<!-- Specifies whether or not to draw a circular border around the image. -->
<attr name="border" format="boolean"></attr>
<attr name="civ_border" format="boolean"/>
<!-- Specifies the color of the border draw around the image. (if enabled) -->
<attr name="border_color" format="color"></attr>
<attr name="civ_border_color" format="color"/>
<!-- Makes the border this pixels wide. (if enabled) -->
<attr name="border_width" format="dimension"></attr>
<attr name="civ_border_width" format="dimension"/>
<!-- Specifies whether or not to draw a selector on this view upon touch events. -->
<attr name="selector" format="boolean"></attr>
<attr name="civ_selector" format="boolean"/>
<!-- Specifies the color of the selector draw on top of the image upon touch events. (if enabled) -->
<attr name="selector_color" format="color"></attr>
<attr name="civ_selector_color" format="color"/>
<!-- Specifies the color of the selector stroke drawn around the image upon touch events. Be sure to provide some opacity. (if enabled) -->
<attr name="selector_stroke_color" format="color"></attr>
<attr name="civ_selector_stroke_color" format="color"/>
<!-- Makes the selector stroke drawn around the image upon touch events this pixels wide. (if enabled) -->
<attr name="selector_stroke_width" format="dimension"></attr>
<attr name="civ_selector_stroke_width" format="dimension"/>
<!-- Specifies whether or not to draw a shadow around your circular image. -->
<attr name="shadow" format="boolean"></attr>
<attr name="civ_shadow" format="boolean"/>
</declare-styleable>

<declare-styleable name="CustomCircularImageViewTheme">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,26 +73,26 @@ private void init(Context context, AttributeSet attrs, int defStyle)
TypedArray attributes = context.obtainStyledAttributes(attrs, R.styleable.CircularImageView, defStyle, 0);

// Check if border and/or border is enabled
hasBorder = attributes.getBoolean(R.styleable.CircularImageView_border, false);
hasSelector = attributes.getBoolean(R.styleable.CircularImageView_selector, false);
hasBorder = attributes.getBoolean(R.styleable.CircularImageView_civ_border, false);
hasSelector = attributes.getBoolean(R.styleable.CircularImageView_civ_selector, false);

// Set border properties if enabled
if(hasBorder) {
int defaultBorderSize = (int) (2 * context.getResources().getDisplayMetrics().density + 0.5f);
setBorderWidth(attributes.getDimensionPixelOffset(R.styleable.CircularImageView_border_width, defaultBorderSize));
setBorderColor(attributes.getColor(R.styleable.CircularImageView_border_color, Color.WHITE));
setBorderWidth(attributes.getDimensionPixelOffset(R.styleable.CircularImageView_civ_border_width, defaultBorderSize));
setBorderColor(attributes.getColor(R.styleable.CircularImageView_civ_border_color, Color.WHITE));
}

// Set selector properties if enabled
if(hasSelector) {
int defaultSelectorSize = (int) (2 * context.getResources().getDisplayMetrics().density + 0.5f);
setSelectorColor(attributes.getColor(R.styleable.CircularImageView_selector_color, Color.TRANSPARENT));
setSelectorStrokeWidth(attributes.getDimensionPixelOffset(R.styleable.CircularImageView_selector_stroke_width, defaultSelectorSize));
setSelectorStrokeColor(attributes.getColor(R.styleable.CircularImageView_selector_stroke_color, Color.BLUE));
setSelectorColor(attributes.getColor(R.styleable.CircularImageView_civ_selector_color, Color.TRANSPARENT));
setSelectorStrokeWidth(attributes.getDimensionPixelOffset(R.styleable.CircularImageView_civ_selector_stroke_width, defaultSelectorSize));
setSelectorStrokeColor(attributes.getColor(R.styleable.CircularImageView_civ_selector_stroke_color, Color.BLUE));
}

// Add shadow if enabled
if(attributes.getBoolean(R.styleable.CircularImageView_shadow, false))
if(attributes.getBoolean(R.styleable.CircularImageView_civ_shadow, false))
addShadow();

// We no longer need our attributes TypedArray, give it back to cache
Expand Down Expand Up @@ -152,7 +152,7 @@ public void setSelectorStrokeWidth(int selectorStrokeWidth)
* Sets the stroke color to be drawn around the CircularImageView
* during click events when the selector is enabled.
*
* @param borderColor
* @param selectorStrokeColor
*/
public void setSelectorStrokeColor(int selectorStrokeColor)
{
Expand Down
17 changes: 17 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
}
}

allprojects {
repositories {
jcenter()
}
}

19 changes: 19 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
VERSION_NAME=1.0
VERSION_CODE=1
GROUP=com.pkmmte.circularimageview

POM_DESCRIPTION=Custom view for circular images in Android while maintaining the best draw performance
POM_URL=https://github.com/Pkmmte/CircularImageView
POM_SCM_URL=https://github.com/Pkmmte/CircularImageView
POM_SCM_CONNECTION=scm:[email protected]:Pkmmte/CircularImageView.git
POM_SCM_DEV_CONNECTION=scm:[email protected]:Pkmmte/CircularImageView.git
POM_LICENCE_NAME=Creative Commons Attribution 4.0 International License.
POM_LICENCE_URL=http:https://creativecommons.org/licenses/by/4.0/
POM_LICENCE_DIST=repo
POM_DEVELOPER_ID=Pkmmte
POM_DEVELOPER_NAME=Pkmmte

COMPILE_SDK_VERSION=20
BUILD_TOOLS_VERSION=20.0.0
MIN_SDK_VERSION=14
TARGET_SDK_VERSION=20
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
6 changes: 6 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#Sun Jul 20 17:32:19 CST 2014
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\:https://services.gradle.org/distributions/gradle-1.12-bin.zip
Loading

0 comments on commit 3411847

Please sign in to comment.