• Stars
    star
    302
  • Rank 138,030 (Top 3 %)
  • Language
    Kotlin
  • License
    Apache License 2.0
  • Created over 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A library for animated rating view in Android apps.

EmotionRatingView

Version API License

About

EmotionRatingApp is a library for Android apps demonstrating emotional response based on selected rating.

Inspiration

EmotionRatingView was inspired by a UI/UX Demo by Adip Nayak

Demo

Description

EmotionRatingView library contains EmotionView, RatingView, and GradientBackgroundView.

EmotionView - Displays an animated face that responds to a rating change.
RatingView - Displays rating bar with animated grades.
GradientBackgroundView - Displays a smoothly changing background with a gradient that responds to the rating change.

Library Usage

Add JitPack repository to your build.gradle file

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

Add the Dependency

dependencies {
    implementation ‘com.github.rubygarage:emotion-rating-view:v1.0.1’
}

Note that starting from 1.0.1, the library is expected to use with AndroidX. Please migrate to AndroidX if you use 1.0.1 or above.

Please use 1.0.0 if you haven't migrated to AndroidX.

Add EmotionRatingView library to your layout. You can also use all views separately.

    <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        
        <com.dm.emotionrating.library.GradientBackgroundView
                android:id="@+id/gradientBackgroundView"
                android:layout_width="0dp"
                android:layout_height="0dp"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent" />
                
        <com.dm.emotionrating.library.EmotionView
                android:id="@+id/emotionView"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginBottom="8dp"
                android:layout_marginEnd="48dp"
                android:layout_marginLeft="48dp"
                android:layout_marginRight="48dp"
                android:layout_marginStart="48dp"
                android:layout_marginTop="8dp"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent" />
                
        <com.dm.emotionrating.library.RatingView
                android:id="@+id/ratingView"
                android:layout_width="wrap_content"
                android:layout_height="40dp"
                android:layout_marginEnd="8dp"
                android:layout_marginLeft="8dp"
                android:layout_marginRight="8dp"
                android:layout_marginStart="8dp"
                android:layout_marginTop="16dp"
                android:padding="5dp"
                app:gap="5dp"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/emotionView" />
                
    </androidx.constraintlayout.widget.ConstraintLayout>

Add to your Activity.

ratingView.setRatingChangeListener { previousRating, newRating ->
            emotionView.setRating(previousRating, newRating)
            gradientBackgroundView.changeBackground(previousRating, newRating)
        }

Set RatingChangeListener to get notified when rating changed.

ratingView.setRatingChangeListener { previousRating, newRating ->
            ...
        }

Set rating for all views from 0 to 5. The default rating is 0.

ratingView.setRating(rating)
 
emotionView.setRating(previousRating, newRating)
 
gradientBackgroundView.changeBackground(previousRating, newRating)

You can also see the example to get better understanding.

Customization

RatingView

Property Description
android:layout_height Changes the height of grades
android:background Changes the background of the RatingView
app:gap Changes the distance between grades

To change the color of the face and grades, you can override the attributes in your theme.

<style name="YourCustomThemeTheme">
    ...
    <item name="faceColor">@color/colorWhite</item>
    <item name="gradeColor">@color/orange</item>
</style>

To change the gradient color set, you can override the attributes in the GradientBackgroundView or in your theme.

<style name="YourCustomThemeTheme">
    ...
    <item name="zeroGradeGradientColors">@array/garageZeroGradeGradientColors</item>
    <item name="oneGradeGradientColors">@array/garageOneGradeGradientColors</item>
    <item name="twoGradeGradientColors">@array/garageTwoGradeGradientColors</item>
    <item name="threeGradeGradientColors">@array/garageThreeGradeGradientColors</item>
    <item name="fourGradeGradientColors">@array/garageFourGradeGradientColors</item>
    <item name="fiveGradeGradientColors">@array/garageFiveGradeGradientColors</item>
</style>

Also, you have to define the arrays of colors that you want to use. There must be at least two colors in one set.

<integer-array name="garageZeroGradeGradientColors">
   <item>@color/thirdGradientColor</item>
   <item>@color/thirdGradientColor</item>
</integer-array>
    
<integer-array name="garageOneGradeGradientColors">
   <item>@color/fifthGradientColor</item>
   <item>@color/fifthGradientColor</item>
</integer-array>
    
<integer-array name="garageTwoGradeGradientColors">
   <item>@color/fifthGradientColor</item>
   <item>@color/fourthGradientColor</item>
   <item>@color/thirdGradientColor</item>
   <item>@color/secondGradientColor</item>
</integer-array>
    
<integer-array name="garageThreeGradeGradientColors">
    <item>@color/fourthGradientColor</item>
    <item>@color/thirdGradientColor</item>
    <item>@color/secondGradientColor</item>
    <item>@color/firstGradientColor</item>
</integer-array>
    
<integer-array name="garageFourGradeGradientColors">
    <item>@color/thirdGradientColor</item>
    <item>@color/firstGradientColor</item>
</integer-array>
    
<integer-array name="garageFiveGradeGradientColors">
    <item>@color/secondGradientColor</item>
    <item>@color/firstGradientColor</item>
    <item>@color/firstGradientColor</item>
</integer-array>

Requirements

  • Android 4.1 (API 16) - a minimum supported version
  • Android Studio for application build
  • Gradle to install all the dependencies

License

EmotionRatingView is licensed under the Apache 2.0 license


RubyGarage Logo

RubyGarage is a leading software development and consulting company in Eastern Europe. Our main expertise includes Ruby and Ruby on Rails, but we successfully employ other technologies to deliver the best results to our clients. Check out our portfolio for even more exciting works!

More Repositories

1

collection-view-layouts

A library that implements custom flow layouts for iOS apps
Swift
662
star
2

media-watermark

GPU/CPU-based iOS Watermark Library for Image and Video Overlay
Swift
203
star
3

shopapp-android

ShopApp is an application that transfers an online store into a mobile app
Kotlin
148
star
4

react-native-firebase-chat

This repository contains the source code for a simple chat application built with React Native (frontend) and Firebase (backend).
JavaScript
148
star
5

shopapp-ios

ShopApp is an application that transfers an online store into a mobile app
Swift
114
star
6

detectify

Detectify is a gem for multi-tenant Rack apps, to help you retrieve domain and subdomain-related data from a database.
Ruby
79
star
7

boilerplate

This repo will help you to build quickly your Rails API with Trailblazer and friends.
Ruby
58
star
8

Design-Patterns-in-Swift

This is a repository for our article about design patterns in the Swift programming language https://rubygarage.org/blog/swift-design-patterns
Swift
53
star
9

shopapp-shopify-ios

A Shopify provider for a ShopApp for iOS application
Swift
52
star
10

shopapp-shopify-android

A Shopify provider for a ShopApp for Android application
Kotlin
51
star
11

authorize-me

Authorization with social networks
Swift
44
star
12

rubygarage.github.com

This repository contains slides for Ruby/Ruby on Rails courses from RubyGarage
CSS
44
star
13

nextjs6-graphql-client-tutorial

Demo app
JavaScript
43
star
14

mvc-components-refactoring-in-rails

Code examples of MVC components refactoring in Rails from RubyGarage to SitePoint
Ruby
16
star
15

arkit-example

This repository is created for the article https://rubygarage.org/blog/create-augmented-reality-app-for-ios-11
Swift
12
star
16

shareconomy

Ruby
7
star
17

holtwinters

JavaScript
4
star
18

graphql_meetup

Ruby
4
star
19

graphql-tutorial

Ruby
3
star
20

monitorbit

Ruby
2
star
21

aws-practice

2
star
22

odbcimporter

Go
1
star
23

terraform-boilerplate

HCL
1
star
24

rubyhub

Ruby implementation for hub soft
Ruby
1
star
25

vertigo-rtm-outdated

Ruby
1
star
26

frontend-internship-template

JavaScript
1
star
27

bootstrap-store-theme

HTML
1
star
28

interview-rails

Ruby
1
star
29

trailblazer-courses

Ruby
1
star
30

action_controller_audit_trail

Action Controller Audit Trail gem
Ruby
1
star
31

ios-application-testing

This repository demonstrates how to set up your iOS project for automated testing. We created this repo as a demo project for the article https://rubygarage.org/blog/testing-ios-app .
Swift
1
star
32

sentryimporter

Go
1
star
33

interview-vuejs

Vue
1
star
34

interview-react-and-scss

JavaScript
1
star