Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 38 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ Whatever you need to display some rating or pricing category - just use ProperRa
android:textSize="22sp"
android:textStyle="bold"
app:prb_defaultRating="4"
app:prb_minRating="1"
app:prb_symbolicTick="$"
app:prb_symbolicTickNormalColor="@android:color/darker_gray"
app:prb_symbolicTickSelectedColor="@android:color/holo_green_dark"
app:prb_totalTicks="5"
app:prb_tickAnimation="@anroid:anim/fade_in"
/>
```

Expand Down Expand Up @@ -44,7 +46,7 @@ Library's minSdkVersion is set to 14.

We use jitpack, so you can obtain made-up library right from our github sources in your module's `build.gradle` file:

`compile 'com.github.techery:properratingbar:{version_name}'`
`compile 'com.github.branpark:ProperRatingBar:0.0.6'`

Also you need to add jitpack as repository in the same file:
```groovy
Expand All @@ -59,7 +61,7 @@ So far we only support customising via xml layout.
Here is the list of applicable attributes:
+ ``prb_totalTicks``: total number of ticks to show. Default is '5'
+ ``prb_defaultRating``: use this to set rating from xml. Default is '3'
+ ``prb_clickable``: if set to 'true' - use will be able to change rating by clicking. Default is 'false'
+ ``prb_minRating`` : use this to set minimum rating. Default is '0'

+ ``prb_symbolicTick``: symbol to be used as a tick. Default is '$'
+ ``android:textSize``: text size of symbolic tick. Default is '15sp'
Expand All @@ -70,12 +72,11 @@ Here is the list of applicable attributes:
+ ``prb_tickNormalDrawable``: drawable resource to use as a tick that is not selected (not rated). No default value
+ ``prb_tickSelectedDrawable``: drawable resource to use as a tick that is selected (rated). No default value
+ ``prb_tickSpacing``: margin to be applied to tick drawables. Only applies to drawable-type ticks. Default is '1dp' (gray)
+ ``prb_tickAnimation``: Animation to be applied to the tick view. No default value.

Also there's a number of methods to operate on ProperRatingBar programmatically:
```java

public boolean isClickable();

/**
* Nifty sugar method to just toggle clickable to opposite state.
*/
Expand Down Expand Up @@ -112,6 +113,39 @@ public int getRating();
* @param rating new rating value
*/
public void setRating(int rating);

/**
* Set normal tick drawable
* @param tickDrawable normal tick drawable
*/
public void setTickNormalDrawable(Drawable tickDrawable);

/**
* Set selected tick drawable
* @param tickDrawable selected tick drawable
*/
public void setTickSelectedDrawable(Drawable tickDrawable);

/**
* Get normal tick drawable
* @retrun normal tick drawable
*/
public Drawable getTickNormalDrawable();

/**
* Get selected tick drawable
* @retrun selected tick drawable
*/
public Drawable setTickSelectedDrawable();

/**
* Animation resource id to be applied to the tick view.
* @param animResId animation resource id
*/
public void setTickAnimationResId(int animResId);

public int getTickAnimationResId();

```

## Tests
Expand Down
8 changes: 7 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
apply plugin: 'com.android.application'

allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
buildToolsVersion '25.0.0'

defaultConfig {
applicationId "io.techery.properratingbar.sample"
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/res/anim/animation_scale_updown.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="300">
<scale
android:fromXScale="1.5" android:toXScale="1.0"
android:fromYScale="1.5" android:toYScale="1.0"
android:pivotX="50%" android:pivotY="50%" />
</set>
9 changes: 6 additions & 3 deletions app/src/main/res/layout/content_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
app:prb_symbolicTick="$"
app:prb_symbolicTickNormalColor="@android:color/darker_gray"
app:prb_symbolicTickSelectedColor="@android:color/holo_green_dark"
app:prb_totalTicks="5"
/>
app:prb_totalTicks="5" />

<Button
android:id="@+id/toggleTick"
Expand All @@ -59,12 +58,16 @@
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="@dimen/sample_default_margin"
android:paddingLeft="40dp"
android:paddingRight="40dp"
android:clickable="true"
app:prb_tickAnimation="@anim/animation_scale_updown"
app:prb_defaultRating="4"
app:prb_tickNormalDrawable="@drawable/ic_star_normal"
app:prb_tickSelectedDrawable="@drawable/ic_star_selected"
app:prb_tickSpacing="@dimen/sample_prb_tick_spacing"
app:prb_totalTicks="7"
app:prb_clickable="true"
app:prb_minRating="1"
/>

<LinearLayout
Expand Down
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:2.1.0'
classpath 'com.android.tools.build:gradle:2.3.3'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tue Oct 13 16:58:22 EEST 2015
#Wed Sep 06 11:53:55 KST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
4 changes: 2 additions & 2 deletions library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
apply plugin: 'com.android.library'

group = "io.techery"
group = "com.github.brannpark"

android {

compileSdkVersion 23
buildToolsVersion "23.0.2"
buildToolsVersion '25.0.0'

defaultConfig {
minSdkVersion 14
Expand Down
9 changes: 5 additions & 4 deletions library/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@
<!-- Use this to set rating from xml. Default is '3' -->
<attr name="prb_defaultRating" format="integer" />

<!-- If set to 'true' - use will be able to change rating by clicking. Default is 'false' -->
<attr name="prb_clickable" format="boolean" />

<!-- User this to set minimum rating. Default is '0' -->
<attr name="prb_minRating" format="integer" />

<!-- Symbol to be used as a tick. Default is '$' -->
<attr name="prb_symbolicTick" format="string" />

<!-- Tick animation to use. No default value. -->
<attr name="prb_tickAnimation" format="reference" />

<!-- Text size of symbolic tick. Default is '15sp' -->
<attr name="android:textSize" />

Expand All @@ -52,7 +54,6 @@
<!-- Color of symbolic tick that is selected (rated). Default is '#FF888888' (gray). -->
<attr name="prb_symbolicTickSelectedColor" format="reference|color" />


<!-- Drawable resource to use as a tick that is not selected (not rated). No default value. -->
<attr name="prb_tickNormalDrawable" format="reference" />

Expand Down
Loading