We, at Brightec, strongly support the steps and efforts that Google and others have taken in ensuring the Play Store remains a trustworthy experience, protecting end-users from harm and malware. Having reviewed the current Play Store guidelines, we feel that it is no longer appropriate for us to be actively developing or promoting the library. Whilst we don't believe it breaches any current guidelines, we feel it could be perceived as going against the spirit of the guidelines. Existing users of the library are free to take a different viewpoint and continue to use the library should they so choose. For reference the particular guidelines reviewed are https://android-developers.googleblog.com/2016/11/keeping-it-real-improving-reviews-and-ratings-in-google-play.html and https://play.google.com/about/storelisting-promotional/ratings-reviews-installs/
RateTheApp allows users to rate your app prompting them for further action depending on the rating they gave.
<uk.co.brightec.ratetheapp.RateTheApp
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<string name="ratetheapp_feedback_emailaddress">[email protected]</string>
Depending on the user's rating, an AlertDialog prompts the user for further action.
- If a rating of 0, 1 or 2 stars is selected, the user is prompted whether they would like to email the app developer with any issues they might have. RateTheApp will remain visible so the user can re-rate your app once their issues have been resolved.
Using Gradle:
dependencies {
compile 'uk.co.brightec.ratetheapp:ratetheapp:1.0.2'
}
Or Maven:
<dependency>
<groupId>uk.co.brightec.ratetheapp</groupId>
<artifactId>ratetheapp</artifactId>
<version>1.0.2</version>
<type>pom</type>
</dependency>
Note that all the following customisations can be combined together to get the appearance you want.
The title text and appearance can be changed using the rateTheAppTitleText and rateTheAppTitleTextAppearance attributes. The message text and appearance can be changed similarly.
<uk.co.brightec.ratetheapp.RateTheApp
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
app:rateTheAppTitleText="@string/demo_customised_title"
app:rateTheAppTitleTextAppearance="@style/TitleTextAppearance"
app:rateTheAppMessageText="@string/demo_customised_message"
app:rateTheAppMessageTextAppearance="@style/MessageTextAppearance"/>
<string name="demo_customised_title">Would you like to rate this app?</string>
<string name="demo_customised_message">Please rate us so we can see how you are liking the app.</string>
<style name="TitleTextAppearance" parent="TextAppearance.AppCompat.Title">
<item name="android:textColor">@color/colorPrimaryDark</item>
</style>
<style name="MessageTextAppearance" parent="TextAppearance.AppCompat.Body1">
<item name="android:textColor">@color/colorAccent</item>
</style>
<color name="colorPrimaryDark">#0091EA</color>
<color name="colorAccent">#FEDB31</color>
The title can be removed altogether by setting a blank rateTheAppTitleText attribute. Similarly for message.
<uk.co.brightec.ratetheapp.RateTheApp
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
app:rateTheAppTitleText=""
app:rateTheAppMessageText=""/>
The colour of the stars can be changed using the rateTheAppSelectedStarColor and rateTheAppUnselectedStarColor attributes.
<uk.co.brightec.ratetheapp.RateTheApp
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
app:rateTheAppSelectedStarColor="@color/colorPrimaryDark"
app:rateTheAppUnselectedStarColor="@color/colorPrimary"/>
<color name="colorPrimary">#2FBCED</color>
<color name="colorPrimaryDark">#0091EA</color>
The drawables of the stars can be changed using the rateTheAppStarSelectedDrawable and rateTheAppStarUnSelectedDrawable attributes. You can use either normal png drawables or you can use svg's. Notes: You will need to include the desired spacing in the drawable file itself; You can still use the drawables colour attribute as above.
<uk.co.brightec.ratetheapp.RateTheApp
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
app:rateTheAppStarSelectedDrawable="@drawable/ic_android_selected"
app:rateTheAppStarUnSelectedDrawable="@drawable/ic_android_unselected"/>
ic_android_selected.png
ic_android_unselected.png
The class DefaultOnUserSelectedRatingListener provides the default behaviour of showing an AlertDialog. There are a couple of ways of changing the text on the AlertDialog.
- The simpliest way is to override the string definitions used by the DefaultOnUserSelectedRatingListener class
- Alternatively, in code, you can set the strings on the DefaultOnUserSelectedRatingListener class
<string name="ratetheapp_goodrating_title">Thanks!</string>
<string name="ratetheapp_goodrating_text">Thanks so much! Would you mind rating us or leaving a review at the App Store?</string>
<string name="ratetheapp_positive_button">Sure</string>
<string name="ratetheapp_negative_button">No Thanks</string>
<string name="ratetheapp_badrating_title">Hi There!</string>
<string name="ratetheapp_badrating_text">I’m really sorry to hear that you don’t like our app. Would you mind sending me your thoughts on how we can improve it? I’ll respond directly. Thanks for your help.</string>
<string name="ratetheapp_badrating_text">We\'re sorry to hear that you don\'t like our demo. Would you mind sending us your thoughts on how we can improve it?\n\nThanks for your help,\nThe Brightec Team</string>
<string name="ratetheapp_goodrating_title">Thank you!</string>
<string name="ratetheapp_goodrating_text">Thanks, that\'s great to hear! Would you mind rating us or leaving a review on the Google Play Store?\n\nThanks again,\nThe Brightec Team</string>
RateTheApp rta = (RateTheApp) view.findViewById(R.id.noAction);
DefaultOnUserSelectedRatingListener defaultListener = (DefaultOnUserSelectedRatingListener) rta.getOnUserSelectedRatingListener();
if (defaultListener != null) {
defaultListener.setGoodRatingTitle("Man, we're glad you liked our app.");
defaultListener.setGoodRatingMessage("We'd love it if you'd rate us on the Play Store so others may also benefit.");
}
As with the AlertDialog, the class DefaultOnUserSelectedRatingListener provides the default email behaviour. There are a couple of ways of changing the email template.
- The simpliest way is to override the string definitions used by the DefaultOnUserSelectedRatingListener class
- Alternatively, in code, you can set the strings on the DefaultOnUserSelectedRatingListener class
<string name="ratetheapp_feedback_emailaddress"/>
<string name="ratetheapp_feedback_subject">App Feedback: Android</string>
<string name="ratetheapp_feedback_extra_information" formatted="false">\n\n\n\n\n// Please reply above this line\nInformation that helps us:\n%d stars, Android %s, Platform %s, App Version %s</string>
<string name="ratetheapp_feedback_emailaddress">[email protected]</string>
<string name="ratetheapp_feedback_subject">Feedback - Android</string>
An interface OnUserSelectedRatingListener provides the behaviour when a user selects a rating.
public interface OnUserSelectedRatingListener {
void onRatingChanged(RateTheApp rateTheApp, float rating);
}
The class DefaultOnUserSelectedRatingListener provides the default behaviour but custom implementations can also be provided.
The following example, based on the demo app, displays a TextView showing the number of stars awarded to your app.
<TextView
android:id="@+id/textView"
style="@style/Demo.5.TextAppearance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:paddingBottom="16dp"
tools:text="Current Rating: 1.0"/>
<uk.co.brightec.ratetheapp.RateTheApp
android:id="@+id/customAction"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"/>
// Find the RateTheApp widget
RateTheApp rta = (RateTheApp) view.findViewById(R.id.customAction);
// Initialise the text view to the current rating
final TextView textView = (TextView) view.findViewById(R.id.textView);
textView.setText(getString(R.string.current_rating) + " " + rta.getRating());
// Add a custom OnUserSelectedRatingListener to update the text view
rta.setOnUserSelectedRatingListener(new RateTheApp.OnUserSelectedRatingListener() {
@Override
public void onRatingChanged(RateTheApp rateTheApp, float rating) {
textView.setText(getString(R.string.current_rating) + " " + rating);
}
});
<string name="current_rating">Current rating: </string>
It is possible to have no action once a user has rated your app, just set the OnUserSelectedRatingListener to null.
<uk.co.brightec.ratetheapp.RateTheApp
android:id="@+id/noAction"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"/>
RateTheApp rta = (RateTheApp) view.findViewById(R.id.noAction);
rta.setOnUserSelectedRatingListener(null);
To use RateTheApp more than once within an app, a unique rateTheAppName attribute should be set each time.
<uk.co.brightec.ratetheapp.RateTheApp
android:id="@+id/noAction"
app:rateTheAppName="noActionWidget"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"/>
<uk.co.brightec.ratetheapp.RateTheApp
android:id="@+id/customAction"
app:rateTheAppName="customActionWidget"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"/>
The user's rating and whether RateTheApp should be displayed or not are stored as user preferences so that the correct number of stars are remembered the next time the user sees the screen. The rateTheAppName attribute is used as a key when storing user preferences.
The information is stored using the following User Preferences keys
- ratetheapp_XX_rating stores the user's rating as a float value
- ratetheapp_XX_show stores whether RateTheApp should be displayed as a boolean value
where XX is the value of the rateTheAppName attribute (which defaults to rate_the_app if not specified). This means that unless the rateTheAppName attribute is changed from the default, all instances of the RateTheApp will share the same rating and display values.
This project is made up of
- an app folder - containing a demo app with code examples showing how to use and customise RateTheApp
- a ratetheapp folder - an Android Library containing the RateTheApp Android View
Feel free to use and improve this project - contributions are welcome.
If you find a problem, please create an issue https://github.com/brightec/RateTheApp-Android/issues (alternatively, fix the code and create a pull request) ;-)
Copyright 2016 Brightec Ltd
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.