A plug and play ;) android library for displaying a "rate this app" dialog

Overview

Easy Rating Dialog Build StatusAndroid Arsenal

This lib provides a simple way to display an alert dialog for rating app.

Default conditions to show:

  1. User opened the app more than 5 times
  2. User opened the app after 7 days of first opening.
  • Please Note: The lastest version uses AppCompat. Your application Theme has to be inherited from Theme.AppCompat

Installation

It's very simple with gradle ;)

Add mavenCentral as repository source:

repositories {
  mavenCentral()
}

And finally add this line inside dependencies { } section:

compile 'com.github.fernandodev.easyratingdialog:easyratingdialog:+'
  • The + symbol indicates to gradle to get the latest version.
  • Current version: 1.1.2

ATTENTION

If you are using afollestad:material-dialogs you must esclude this module from EasyRatingDialog lib to avoid lib conflicting:

  compile('com.github.fernandodev.easyratingdialog:easyratingdialog:1.1.2') {
    exclude module: 'material-dialogs'
  }
  • See the sample if there are any doubts.

Using

The main flow usage is:

Create dialog in your main activity or your start activity:

public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  easyRatingDialog = new EasyRatingDialog(this);
}

after you need to start dialog at:

@Override
protected void onStart() {
  super.onStart();
  easyRatingDialog.onStart();
}

this line inc. counters and initialize first app access date if necessary

And to show when needed just call in onResume:

@Override
protected void onResume() {
  super.onResume();
  easyRatingDialog.showIfNeeded();
}
  • all exceptions are catched when dialog tries to show because I assume the app running is more important than to show the dialog.

Tips

Condition triggers

If you want to change the default lib behavior you can create a custom Condition Trigger:

EasyRatingDialog.ConditionTrigger conditionTrigger = new EasyRatingDialog.ConditionTrigger() {
  @Override
  public boolean shouldShow() {
    //Your custom condition here
    return false;
  }
};

easyRatingDialog.setConditionTrigger(conditionTrigger);

Useful public methods

If you need to create for user an action rate and link it with dialog conditions, don't be afraid, just create the easy rating dialog instance and call rate now as below:

public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  easyRatingDialog = new EasyRatingDialog(this);
}
public void onClickRateNow() {
  super.onResume();
  easyRatingDialog.rateNow();
}

You can do it for neverRemider() and remindMeLater() actions too.

To check stored values just call didNeverReminder(), didRate().

Internationalization

Do you liked the lib but you need to change default strings in en-US, you can do it easily as section below.

Just override default values in your strings.xml:

<resources>
  <string name="erd_title">Rate this app</string>
  <string name="erd_message">Hi, take a minute to rate this app and help support to improve more new features. ;)</string>
  <string name="erd_no_thanks">No, thanks.</string>
  <string name="erd_remind_me_later">Remind me later.</string>
  <string name="erd_rate_now">Rate now.</string>
</resources>

Constants

Do you want to change hit times or days after condition? It's simple!

You need to override default values the lib, for that, just create in res/values folder, or alter, a file named constants.xml.

And override the values:

<?xml version="1.0" encoding="utf-8"?>
<resources>
  <integer name="erd_launch_times">10</integer>
  <integer name="erd_max_days_after">14</integer>
</resources>

Theme

You can customize the alert dialog using style settings:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="AppTheme" parent="Theme.AppCompat">
        <item name="alertDialogTheme">@style/AlertDialogTheme</item>
    </style>

    <!--You can customize dialog theme as below-->

    <style name="AlertDialogTheme" parent="Theme.AppCompat.Light.Dialog.Alert">
        <item name="buttonBarNegativeButtonStyle">@style/NegativeButtonStyle</item>
        <item name="buttonBarPositiveButtonStyle">@style/PositiveButtonStyle</item>
    </style>

    <style name="NegativeButtonStyle" parent="Widget.AppCompat.Button.ButtonBar.AlertDialog">
        <item name="android:textColor">#f00</item>
    </style>

    <style name="PositiveButtonStyle" parent="Widget.AppCompat.Button.ButtonBar.AlertDialog">
        <item name="android:textColor">#00f</item>
    </style>
</resources>

Dagger Issues

If you are using dagger pay attention to some items.

One, you must provide an Activity Context to EasyRatingDialog to show the dialog. So you can do this as below:

@Provides EasyRatingDialog provideRatingDialog(@ForActivity Context context) {
  return new EasyRatingDialog(context);
}

where @ForActivity is an interface that overrides other contexts provided by other modules.

@Qualifier @Retention(RUNTIME)
  public @interface ForActivity {
}

Otherwise if you provide other context and try to show an execption can be occur because dialogs only can be attached to Activity's context.

The code below prevents you to get a BadTokenException exception E/EasyRatingDialog﹕ Unable to add window -- token android.os.BinderProxy@536c3920 is not valid; is your activity running?

@Provides @ForActivity Context provideActivityContext() {
  return activity;
}

If you use `@Singleton annotation to provide the Activity's context a BadTokenException can be occur after restoring from background.

Remember, all exceptions are catched when dialog tries to show because I assume the app running is more important than to show the dialog.

Samples Usage

There are two samples, the first is just a simple acitivity that shows the dialog and the second uses dagger injection.

To run samples you can follow steps below

$ git clone [email protected]:fernandodev/easy-rating-dialog.git
$ cd easyratingdialog
$ ./gradlew installSampleDebug installSampleWithDaggerDebug --daemon

Testing

There are a simple test for the rating dialog. If you want to contribute check the tests too.

$ git clone [email protected]:fernandodev/easy-rating-dialog.git
$ cd easyratingdialog
$ ./gradlew assembleSampleDebugTest connectedAndroidTestSampleDebug --daemon

You must open an emulator before.

Showcase

Have you used my library in your project? Tell me and I'll sponsor your app here ;)

Change Logs

See Change Logs file.

License

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

You might also like...
SL4A brings scripting languages to Android by allowing you to edit and execute scripts and interactive interpreters directly on the Android device.

#Scripting Layer for Android (SL4A) SL4A brings scripting languages to Android by allowing you to edit and execute scripts and interactive interpreter

AboutLibraries is a library to offer some information of libraries.
AboutLibraries is a library to offer some information of libraries.

AboutLibraries .. allows you to easily create an used open source libraries fragment/activity within your app. All the library information is automati

Simple Artificial Neural Network java library

SANN Simple Artificial Neural Network java library WIP Creating neural network Variant 1 //create new net (input, hidden, default len, output) Net net

A library to display pokemon with Shakespearean descriptions

Pokemon Shakespeare SDK A library to display pokemon with Shakespearean descriptions Dependencies Java 11 Retrofit Picasso Material Appcompat Usage Cr

ArduinoJava - A project that uses the JSSC library
ArduinoJava - A project that uses the JSSC library

ArduinoJava este es un proyecto que utiliza la libreria JSSC para connectarse al

Editframe Kotlin Client library

Editframe Kotlin Client library Installing Add the project to your gradle dependencies.

Open-source Desktop library to connect Alsat pardakht peyment API
Open-source Desktop library to connect Alsat pardakht peyment API

Open-source Desktop library to connect Alsat pardakht peyment API

An application for runners and cyclists. Allows you to monitor your physical activity, weight and receive reminders about workouts.

An application for runners and cyclists. Allows you to monitor your physical activity, weight and receive reminders about workouts.

A curated list of standards, tests and benchmarks that can be used for testing and evaluating dev-tools

A curated list of standards, tests and benchmarks that can be used for testing and evaluating dev tools Contribution Add the description of the benchm

Comments
  • Added Flag new task.

    Added Flag new task.

    This is so the application context can be used instead of the activity's. I was using dagger to inject the dialog with the application context, and this was causing issues.

    opened by AndrewReitz 1
Releases(v1.1.2)
Owner
Fernando Martínez
Thinking more than coding.
Fernando Martínez
Makes Google play in app purchase library (BillingClient) into a flowable that can easily be used in compose world

Billy the android Our goal is to make a modern api of BillingClient so that it is easier to use in compose world. This library is still early beta and

Stefan Wärting 16 Dec 14, 2022
Make your IDE play Wilhelm Scream effect when you are using unsafe !! operator in Kotlin

Make your IDE play Wilhelm Scream effect when you are using unsafe !! operator in Kotlin

Mikhail Levchenko 78 Nov 15, 2022
****. Use the native and support library variants instead - https://developer.android.com/guide/topics/ui/look-and-feel/fonts-in-xml.html. An android library that makes it easy to add custom fonts to edittexts and textviews

Add to your project Add this line to your dependencies in build.gradle compile 'in.workarounds.typography:typography:0.0.8' Using the views There are

Workarounds 43 Nov 6, 2021
Starter-Android-Library - Starter Android Library is an Android Project with Modular Architecture.

Starter-Android-Library - Starter Android Library is an Android Project with Modular Architecture.

OpenBytes 1 Feb 18, 2022
Tutorial For openJDK 11 and AGP 7.0.0+ | Tutorial Multi Library Android in 1 Project | Groovy

jitpack-library-guide For openJDK 11 and AGP 7.0.0 + Please read every single note for detail Tutorial Click Here Kotlin DSL Click Here Repository for

Faisal Amir 7 Dec 10, 2022
Using Resilience4J, this is a Demo project which uses a Library as background and manages all its requests.

Using Resilience4J, this is a Demo project which uses a Library as background and manages all its requests. This library can rent books online and the usage rate is extremely high. There is a reactive way to access, which is the one normally used, but sometimes, the system needs a bit of help from an old machine running a non-reactive MVC Spring application using JPA. Let's make this in Kotlin and find the best solution!

João Filipe Sabino Esperancinha 2 Jan 10, 2022
ZXing ("Zebra Crossing") barcode scanning library for Java, Android

Project in Maintenance Mode Only The project is in maintenance mode, meaning, changes are driven by contributed patches. Only bug fixes and minor enha

ZXing Project 30.5k Dec 27, 2022
Android Library to help you with your runtime Permissions.

PermissionHelper Android Library to help you with your runtime Permissions. Demo Android M Watch it in action. Pre M Watch it in action. Nexus 6 (M) N

Kosh Sergani 1.2k Dec 14, 2022
Android validation library which helps developer boil down the tedious work to three easy steps.

AwesomeValidation Introduction Implement validation for Android within only 3 steps. Developers should focus on their awesome code, and let the librar

Jing Li 1.1k Dec 17, 2022
Android library that manages your app's cached data with ease.

Teller Android library that makes your apps faster. Teller facilitates the downloading, saving, and reading of the cached data of your app. Keep your

Levi Bostian 14 Apr 2, 2022