Skip to content

Commit

Permalink
Merge pull request #25 from kuassivi/develop
Browse files Browse the repository at this point in the history
Merge issue #23 into master
  • Loading branch information
FranRiadigos committed Apr 14, 2016
2 parents 95d6291 + c2b6515 commit 151a5c3
Show file tree
Hide file tree
Showing 17 changed files with 468 additions and 176 deletions.
67 changes: 38 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,52 +1,57 @@
ProgressProfileView
===================
[![Hex.pm](https://img.shields.io/hexpm/l/plug.svg)](http://www.apache.org/licenses/LICENSE-2.0) [![Platform](https://img.shields.io/badge/platform-android-green.svg)](http://developer.android.com/index.html)
[![Hex.pm](https://img.shields.io/hexpm/l/plug.svg)](http://www.apache.org/licenses/LICENSE-2.0) [![Platform](https://img.shields.io/badge/platform-android-green.svg)](http://developer.android.com/index.html) [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-ProgressProfileView-brightgreen.svg?style=flat)](http://android-arsenal.com/details/1/3333)

Android custom view to load an avatar or profile image with a progress indicator.

It also works on Marshmallow.
![Portrait][1]        ![Ring Samples][2]        ![Gradient Samples][3]

![Portrait][1]
**Preview also on Android Studio!**

You can customize the Component as you wish.

![Ring Samples][2]

**You can also Preview the result on Android Studio!**

![Android Studio Preview][3]
![Android Studio Preview][4]

Background
----------
**ProgressProfileView** extends ImageView, so you can set xml attributes as usual.
<br>It will be square measured both on landscape and portrait.
**ProgressProfileView** inherits from ImageView, so you can set any xml attributes as usual.

***You don't need to transform resources placeholders or loaded images from Picasso or Glide to rounded images!***
Measured both on landscape and portrait.

***No need to crop to rounded images!***

**ProgressProfileView** will clip proportionally all images loaded.
<br>Just remember to set `android:scaleType="centerCrop"` on the component.

How to:
------
Remember to set `android:scaleType="centerCrop"` and `android:adjustViewBounds="true"`


## Dependency

Latest stable version:
[![Latest Version](https://api.bintray.com/packages/kuassivi/maven/progress-profile/images/download.svg) ](https://bintray.com/kuassivi/maven/progress-profile/_latestVersion)
[![Bintray Version](https://img.shields.io/bintray/v/kuassivi/maven/progress-profile.svg)](http://jcenter.bintray.com/com/kuassivi/view/progress-profile/)
[![Maven Central](https://img.shields.io/maven-central/v/com.kuassivi.view/progress-profile.svg)]()

If you are working with gradle, add the dependency to your build.gradle file:
```groovy
dependencies{
compile 'com.kuassivi.view:progressprofile:1.0.5'
compile 'com.kuassivi.view:progressprofile:?.?.?'
}
```
If you are working with maven, do it into your pom.xml
```xml
<dependency>
<groupId>com.kuassivi.view</groupId>
<artifactId>progressprofile</artifactId>
<version>1.0.5</version>
<version>?.?.?</version>
<type>aar</type>
</dependency>
```

Add the **ProgressProfileView** component in some place on the layout.
<br>Set your prefered ImageView attributes on it.

How to:
-------

Add the **ProgressProfileView** component in the layout.
<br>Set your preferred ImageView attributes on it.

```xml
<com.kuassivi.view.ProgressProfileView
Expand All @@ -58,7 +63,7 @@ Add the **ProgressProfileView** component in some place on the layout.
android:src="@drawable/my_avatar"
app:progress="42"
app:progressRingSize="10dp"
app:progressRingCap="ROUND"
app:progressRingCorner="ROUND"
app:progressRingOutline="true"/>
```

Expand Down Expand Up @@ -102,19 +107,22 @@ Glide.with(this)
.into(profile);
```

> Be careful when using `fitCenter()` method of Glide, or any other similar kind of method, because it will scale the bitmap, and the Progress Profile component will loose its original bounds!
> Be careful when using `fitCenter()` method of Glide, Picasso, or any other similar kind of method, because it will re-scale the bitmap, and the Progress Profile component will loose its original bounds!
Features:
---------

* `app:max="100"` - Max value for progress indicator
* `app:progress="50"` - Current progress value
* `app:backgroundRingSize="20dp"` - Set the size of the background ring (not set, means use the same as the <i>progressRingSize</i>)
* `app:progressRingSize="20dp"` - Set the size of the progress ring
* `app:backgroundRingColor="@color/my_color"` - Set the color of the background ring (it can be an hex color as well)
* `app:progressRingColor="@color/my_color"` - Set the color of the progress ring (it can be an hex color as well)
* `app:progressRingCap="BUTT"` - Set the cap style of the progress ring (Possible values: BUTT, ROUND, SQUARE)
* `app:progressRingOutline="true"` - Set the ring as an Outline based on the padding of the ImageView, by default is `false`.
* `app:backgroundRingSize="20dp"` - The size of the background ring (not set, means use the same as the <i>progressRingSize</i>)
* `app:progressRingSize="20dp"` - The size of the progress ring
* `app:backgroundRingColor="@color/my_color"` - The color of the background ring (it can be an hex color as well)
* `app:progressRingColor="@color/my_color"` - The color of the progress ring (it can be an hex color as well)
* `app:progressGradient="@array/colors"` - An array of colors for a gradient ring (you must provide an array resource reference) [#23](https://github.com/kuassivi/ProgressProfileView/issues/23)
* `app:joinGradient="true"` - Enabling this you get a gradient smooth on the ring corners
* `app:gradientFactor="1.0"` - Adjust the gradient factor of the ring
* `app:progressRingOutline="true"` - Sets the ring as an Outline based on the padding of the ImageView, by default is `false`.
* `app:progressRingCorner="ROUND"` - Sets the corner style of the progress ring (by default is RECT)

License
-------
Expand All @@ -135,4 +143,5 @@ limitations under the License.

[1]: ./art/portrait.gif
[2]: ./art/ring-samples.png
[3]: ./art/android-studio-preview.png
[3]: ./art/gradient-samples.png
[4]: ./art/android-studio-preview.png
Binary file modified art/android-studio-preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added art/gradient-samples.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified art/ring-samples.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.android.tools.build:gradle:1.5.0'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.3'
classpath 'com.github.dcendents:android-maven-plugin:1.2'

Expand Down
10 changes: 5 additions & 5 deletions example/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
buildToolsVersion "23.0.3"

defaultConfig {
applicationId "com.kuassivi.progressprofile"
minSdkVersion 16
minSdkVersion 11
targetSdkVersion 23
versionCode 2
versionName "1.1"
versionCode 3
versionName "1.2"
}
buildTypes {
release {
Expand All @@ -21,7 +21,7 @@ android {

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.github.bumptech.glide:glide:3.6.1'
compile project(':progressprofile')
}
22 changes: 10 additions & 12 deletions example/example.iml
Original file line number Diff line number Diff line change
Expand Up @@ -65,33 +65,31 @@
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/coverage-instrumented-classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/libs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/ndk" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/reports" />
<excludeFolder url="file://$MODULE_DIR$/build/test-results" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="support-annotations-23.1.0" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-23.1.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-23.3.0" level="project" />
<orderEntry type="library" exported="" name="glide-3.6.1" level="project" />
<orderEntry type="library" exported="" name="support-v4-23.1.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-23.3.0" level="project" />
<orderEntry type="library" exported="" name="support-vector-drawable-23.3.0" level="project" />
<orderEntry type="library" exported="" name="animated-vector-drawable-23.3.0" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-23.3.0" level="project" />
<orderEntry type="module" module-name="progressprofile" exported="" />
</component>
</module>
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package com.kuassivi.progressprofile;

import com.bumptech.glide.Glide;
import com.kuassivi.view.ProgressProfileView;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.os.Bundle;
import android.os.Handler;
Expand All @@ -9,9 +14,6 @@
import android.view.animation.AccelerateDecelerateInterpolator;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.kuassivi.view.ProgressProfileView;

public class MainActivity extends AppCompatActivity {

@Override
Expand All @@ -33,7 +35,6 @@ public void run() {
Glide.with(MainActivity.this)
.load("http://lorempixel.com/500/500/people/1")
.placeholder(R.drawable.ic_icon_user_default)
.fitCenter() // Fit and center the bitmap
.into(profile);

// Show the current percentage animated
Expand All @@ -46,6 +47,16 @@ public void onAnimationUpdate(ValueAnimator animation) {
});

profile.startAnimation();

profile.getAnimator().addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
Glide.with(MainActivity.this)
.load("http://lorempixel.com/500/500/people/2")
.placeholder(R.drawable.ic_icon_user_default)
.into(profile);
}
});
}
}, 2000);
}
Expand Down
51 changes: 25 additions & 26 deletions example/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,35 +1,34 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".MainActivity">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity">

<TextView
android:id="@+id/percentage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
tools:text="Completed: 42%"/>

<com.kuassivi.view.ProgressProfileView
android:id="@+id/profile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:adjustViewBounds="true"
android:layout_centerInParent="true"
android:layout_margin="50dp"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
android:src="@drawable/ic_icon_user_default"
app:progress="42"
app:progressRingSize="10dp"
app:progressRingCap="ROUND"
app:progressRingOutline="true"/>

<TextView
android:id="@+id/percentage"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@id/profile"
android:layout_centerHorizontal="true"
tools:text="Completed: 42%"/>
app:progressRingCorner="ROUND"
app:progressRingOutline="true"
app:progressRingSize="10dp"/>

</RelativeLayout>
</LinearLayout>
Loading

0 comments on commit 151a5c3

Please sign in to comment.