This is a Android App Rating Dialog to encourage user to rate the app on the Google Play Store.
-
Add it in your root build.gradle at the end of repositories:
allprojects { repositories { ... maven { url 'https://jitpack.io' } } }
-
Add this in your app's build.gradle
dependencies { implementation 'com.github.shurajcodx:android-app-rating-dialog:1.1.0' }
Use the app rating dialog:
final AppRatingDialog appRatingDialog = new AppRatingDialog.Builder(this)
.setTriggerCount(2)
.setRepeatCount(5)
.build();
appRatingDialog.show();
Or customize app rating dialog ui from builder class:
final AppRatingDialog appRatingDialog = new AppRatingDialog.Builder(this)
.setTriggerCount(4)
.setRepeatCount(7)
.setLayoutBackgroundColor(R.color.colorDialogBox)
.setIconDrawable(true, ContextCompat.getDrawable(this, R.drawable.love))
.setTitleText(R.string.rating_dialog_custom_title)
.setTitleTextColor(R.color.white)
.setMessageText(R.string.rating_dialog_custom_message)
.setMessageTextColor(R.color.white)
.setMessageTextSize(R.dimen.text20sp)
.setRateButtonText("Rate App", null)
.setRateButtonBackground(R.color.colorPrimaryDark)
.build();
appRatingDialog.show();
You have the following options to customize dialog ui and dialog show up:
- Change the mimimum number of app launches
.setTriggerCount(int triggerCount) // default is 2
- Change the minmium number of repeat count
.setRepeatCount(int repeatCount) //default is 5
-
Change the icon of the dialog
.setIconDrawable(boolean showIconDrawable, Drawable drawable) // default icon isn't show
-
Change the title text and color
.setTitleText(@StringRes int titleText) //for changing title text .setTitleTextColor(@ColorRes int textColor) //for changing title text color
-
Change the message text, size and color
.setMessageText(@StringRes int messageText) .setMessageTextColor(@ColorRes int textColor) .setMessageTextSize(@DimenRes int textSize)
-
Change the store link
.setStoreLink(String storeLink)
-
Change the rate later button text and add a click listener
.setRateLaterButtonText(String rateLaterButtonText, @Nullable RatingDialog.onRemindMeLater onRateLaterClickListener)
-
Change the rate later button text color and background color
.setRateLaterButtonTextColor(@ColorRes int buttonTextColor) .setRateLaterButtonBackground(@DrawableRes int rateLaterButtonBackground)
-
Change the never rate button text and add listener
.setNeverRateButtonText(@StringRes int neverRateButtonText, @Nullable RatingDialog.onNever onRateLaterClickListener)
-
Change the never rate button text color and background color
.setNeverRateButtonTextColor(@ColorRes int buttonTextColor) .setNeverRateButtonBackground(@DrawableRes int neverRateButtonBackground)
-
Change the rate button text and add listener
.setRateButtonText(String rateButtonText, @Nullable RatingDialog.onRate onRateClickListener) // default listener redirect user to google play store
-
Change the rate button text color and background color
.setRateButtonTextColor(@ColorRes int buttonTextColor) .setRateButtonBackground(@DrawableRes int rateButtonBackground)
Copyright (C) 2019 Shuraj Shampang
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.
Make sure to follow the contribution guidelines when you submit pull request.