├── .gitignore
├── LICENSE.md
├── LibraryRateMe
├── .classpath
├── .project
├── AndroidManifest.xml
├── build.gradle
├── gradle.properties
├── libs
│ └── .keep
├── lint.xml
├── proguard-project.txt
├── project.properties
├── res
│ ├── layout
│ │ ├── rateme__dialog_message.xml
│ │ ├── rateme__dialog_title.xml
│ │ ├── rateme__feedback_dialog_message.xml
│ │ └── rateme__feedback_dialog_title.xml
│ ├── values-de
│ │ └── strings.xml
│ ├── values-es
│ │ └── strings.xml
│ ├── values-pt-rBR
│ │ └── strings.xml
│ ├── values-ru
│ │ └── values.xml
│ └── values
│ │ ├── dimen.xml
│ │ └── strings.xml
└── src
│ └── com
│ └── androidsx
│ └── rateme
│ ├── FeedbackDialog.java
│ ├── OnRatingListener.java
│ ├── RateMeDialog.java
│ └── RateMeDialogTimer.java
├── README.md
├── SampleProject
├── .classpath
├── .project
├── AndroidManifest.xml
├── build.gradle
├── ic_launcher-web.png
├── libs
│ └── android-support-v4.jar
├── lint.xml
├── proguard-project.txt
├── project.properties
├── res
│ ├── layout
│ │ └── sample_project.xml
│ ├── menu
│ │ └── rateme.xml
│ ├── mipmap-hdpi
│ │ └── ic_launcher.png
│ ├── mipmap-mdpi
│ │ └── ic_launcher.png
│ ├── mipmap-xhdpi
│ │ └── ic_launcher.png
│ ├── mipmap-xxhdpi
│ │ └── ic_launcher.png
│ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ ├── values-sw600dp
│ │ └── dimens.xml
│ ├── values-sw720dp-land
│ │ └── dimens.xml
│ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
└── src
│ └── com
│ └── androidsx
│ └── rateme
│ └── demo1
│ └── SampleProjectMainActivity.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── maven_push.gradle
├── readme-images
├── rate-me-dialog-in-helium.png
└── rate-me-dialog-in-pixable.png
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | # built application files
2 | *.apk
3 | *.ap_
4 |
5 | # files for the dex VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # generated files
12 | bin/
13 | gen/
14 | .settings/
15 |
16 | # metadata
17 | .metadata
18 |
19 | # rtf
20 | .gitignore.rtf
21 |
22 | # the Google Play keystore
23 | keystore-android
24 |
25 | # some file created by Mac
26 | .DS_Store
27 |
28 | # images-Readme
29 | images-readme/
30 |
31 | # Android studio
32 | .idea
33 | *.iml
34 | local.properties
35 | build/
36 |
37 | # Gradle
38 | .gradle
39 | gradle.properties
40 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Androidsx
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/LibraryRateMe/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/LibraryRateMe/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | LibraryRateMe
4 |
5 |
6 |
7 |
8 |
9 | com.android.ide.eclipse.adt.ResourceManagerBuilder
10 |
11 |
12 |
13 |
14 | com.android.ide.eclipse.adt.PreCompilerBuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.jdt.core.javabuilder
20 |
21 |
22 |
23 |
24 | com.android.ide.eclipse.adt.ApkBuilder
25 |
26 |
27 |
28 |
29 |
30 | com.android.ide.eclipse.adt.AndroidNature
31 | org.eclipse.jdt.core.javanature
32 |
33 |
34 |
--------------------------------------------------------------------------------
/LibraryRateMe/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/LibraryRateMe/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | repositories {
4 | mavenCentral()
5 | }
6 |
7 | android {
8 | compileSdkVersion 22
9 | buildToolsVersion "22.0.1"
10 | resourcePrefix "rateme__"
11 |
12 | defaultConfig {
13 | minSdkVersion 11
14 | targetSdkVersion 22
15 | versionName project.VERSION_NAME
16 | versionCode Integer.parseInt(project.VERSION_CODE)
17 | }
18 |
19 | sourceSets {
20 | main {
21 | manifest.srcFile 'AndroidManifest.xml'
22 | java.srcDirs = ['src']
23 | resources.srcDirs = ['src']
24 | aidl.srcDirs = ['src']
25 | renderscript.srcDirs = ['src']
26 | res.srcDirs = ['res']
27 | assets.srcDirs = ['assets']
28 | }
29 | }
30 |
31 | lintOptions {
32 | abortOnError true
33 | }
34 | }
35 | // Used to push in maven
36 | apply from: '../maven_push.gradle'
37 |
--------------------------------------------------------------------------------
/LibraryRateMe/gradle.properties:
--------------------------------------------------------------------------------
1 | POM_NAME=Rate Me
2 | POM_ARTIFACT_ID=rate-me
3 | POM_PACKAGING=aar
4 |
--------------------------------------------------------------------------------
/LibraryRateMe/libs/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androidsx/rate-me/a779706454ba585a09110745ac3035f28920524a/LibraryRateMe/libs/.keep
--------------------------------------------------------------------------------
/LibraryRateMe/lint.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/LibraryRateMe/proguard-project.txt:
--------------------------------------------------------------------------------
1 | # To enable ProGuard in your project, edit project.properties
2 | # to define the proguard.config property as described in that file.
3 | #
4 | # Add project specific ProGuard rules here.
5 | # By default, the flags in this file are appended to flags specified
6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt
7 | # You can edit the include path and order by changing the ProGuard
8 | # include property in project.properties.
9 | #
10 | # For more details, see
11 | # http://developer.android.com/guide/developing/tools/proguard.html
12 |
13 | # Add any project specific keep options here:
14 |
15 | # If your project uses WebView with JS, uncomment the following
16 | # and specify the fully qualified class name to the JavaScript interface
17 | # class:
18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
19 | # public *;
20 | #}
21 |
--------------------------------------------------------------------------------
/LibraryRateMe/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system edit
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 | #
10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
12 |
13 | # Project target.
14 | target=android-22
15 | android.library=true
16 |
--------------------------------------------------------------------------------
/LibraryRateMe/res/layout/rateme__dialog_message.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
16 |
17 |
28 |
29 |
34 |
35 |
41 |
42 |
58 |
59 |
60 |
61 |
66 |
67 |
74 |
75 |
82 |
83 |
84 |
--------------------------------------------------------------------------------
/LibraryRateMe/res/layout/rateme__dialog_title.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
14 |
15 |
24 |
25 |
32 |
--------------------------------------------------------------------------------
/LibraryRateMe/res/layout/rateme__feedback_dialog_message.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
16 |
17 |
28 |
29 |
35 |
36 |
37 |
43 |
44 |
53 |
54 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/LibraryRateMe/res/layout/rateme__feedback_dialog_title.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
--------------------------------------------------------------------------------
/LibraryRateMe/res/values-de/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Bewertung
4 | Wie würdest du diese Anwendung bewerten?
5 | Bewerte unsere Anwendung im Play Store
6 | Danke für deine Bewertung!
7 | Würdest du uns dein Feedback mitteilen?
8 | Feedback für %1$s
9 | Ikon
10 |
11 |
--------------------------------------------------------------------------------
/LibraryRateMe/res/values-es/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Valora tu experiencia
4 | ¿Qué puntuación nos darías?
5 | Valorar en Google Play
6 | ¡Gracias por la puntuación!
7 | ¿Alguna sugerencia para mejorar nuestra App?
8 | Sugerencias para %1$s
9 | Icono
10 |
11 |
--------------------------------------------------------------------------------
/LibraryRateMe/res/values-pt-rBR/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Avalie sua experiência
4 | Qual pontuação você nos dá?
5 | Deixe uma avaliação na Play Store
6 | Obrigado pela pontuação!
7 | Gostaria de dar seu feedback para melhorarmos o app?
8 | Feedback para %1$s
9 | Icone
10 |
11 |
--------------------------------------------------------------------------------
/LibraryRateMe/res/values-ru/values.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 28dp
6 | 16dp
7 | 12dp
8 | 16dp
9 | 4dp
10 | 88dp
11 | 8dp
12 | 20sp
13 |
14 |
15 | Вы бы хотели написать нам о возникших проблемах? Это поможет улучшить приложение
16 | Поставить оценку в Маркете
17 | Как Вы оцениваете приложение?
18 | Написать разработчикам
19 | Оцените приложение
20 | Отзыв о приложении %1$s
21 | Icon
22 |
--------------------------------------------------------------------------------
/LibraryRateMe/res/values/dimen.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 8dp
5 | 16dp
6 | 4dp
7 | 12dp
8 | 20sp
9 | 88dp
10 | 28dp
11 |
12 |
--------------------------------------------------------------------------------
/LibraryRateMe/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Rate your experience
4 | How would you rate our app?
5 | Rate our app in the Play Store
6 | Thanks for the rating!
7 | Would you mind sharing your feedback?
8 | Feedback for %1$s
9 | Icon
10 |
11 |
--------------------------------------------------------------------------------
/LibraryRateMe/src/com/androidsx/rateme/FeedbackDialog.java:
--------------------------------------------------------------------------------
1 | package com.androidsx.rateme;
2 |
3 | import android.app.AlertDialog;
4 | import android.app.Dialog;
5 | import android.app.DialogFragment;
6 | import android.content.Intent;
7 | import android.content.pm.PackageManager;
8 | import android.net.Uri;
9 | import android.os.Bundle;
10 | import android.util.Log;
11 | import android.view.View;
12 | import android.widget.Button;
13 | import android.widget.ImageView;
14 | import android.widget.TextView;
15 |
16 | import com.androidsx.libraryrateme.R;
17 |
18 | /**
19 | * Dialog to ask the user for feedback after a low rating.
20 | */
21 | public class FeedbackDialog extends DialogFragment {
22 | private static final String TAG = FeedbackDialog.class.getSimpleName();
23 |
24 | private static final String EXTRA_EMAIL = "email";
25 | private static final String EXTRA_APP_NAME = "app-name";
26 | private static final String EXTRA_DIALOG_TITLE_COLOR = "dialog-title-color";
27 | private static final String EXTRA_DIALOG_COLOR = "dialog-color";
28 | private static final String EXTRA_TEXT_COLOR = "text-color";
29 | private static final String EXTRA_HEADER_TEXT_COLOR = "header-text-color";
30 | private static final String EXTRA_LOGO = "icon";
31 | private static final String EXTRA_RATE_BUTTON_TEXT_COLOR = "button-text-color";
32 | private static final String EXTRA_RATE_BUTTON_BG_COLOR = "button-bg-color";
33 | private static final String EXTRA_TITLE_DIVIDER = "color-title-divider";
34 | private static final String EXTRA_RATING_BAR = "get-rating";
35 | private static final String EXTRA_ON_ACTION_LISTENER = "on-action-listener";
36 |
37 | // Views
38 | private View confirmDialogTitleView;
39 | private View confirmDialogView;
40 | private Button cancel;
41 | private Button yes;
42 |
43 | private OnRatingListener onActionListener;
44 |
45 | public static FeedbackDialog newInstance(String email,
46 | String appName,
47 | int titleBackgroundColor,
48 | int dialogColor,
49 | int headerTextColor,
50 | int textColor,
51 | int logoResId,
52 | int lineDividerColor,
53 | int rateButtonTextColor,
54 | int rateButtonBackgroundColor,
55 | float getRatingBar,
56 | OnRatingListener onRatingListener) {
57 | FeedbackDialog feedbackDialog = new FeedbackDialog();
58 | Bundle args = new Bundle();
59 | args.putString(EXTRA_EMAIL, email);
60 | args.putString(EXTRA_APP_NAME, appName);
61 | args.putInt(EXTRA_DIALOG_TITLE_COLOR, titleBackgroundColor);
62 | args.putInt(EXTRA_DIALOG_COLOR, dialogColor);
63 | args.putInt(EXTRA_HEADER_TEXT_COLOR, headerTextColor);
64 | args.putInt(EXTRA_TEXT_COLOR, textColor);
65 | args.putInt(EXTRA_LOGO, logoResId);
66 | args.putInt(EXTRA_RATE_BUTTON_TEXT_COLOR, rateButtonTextColor);
67 | args.putInt(EXTRA_RATE_BUTTON_BG_COLOR, rateButtonBackgroundColor);
68 | args.putInt(EXTRA_TITLE_DIVIDER, lineDividerColor);
69 | args.putFloat(EXTRA_RATING_BAR, getRatingBar);
70 | args.putParcelable(EXTRA_ON_ACTION_LISTENER, onRatingListener);
71 |
72 | feedbackDialog.setArguments(args);
73 | return feedbackDialog;
74 |
75 | }
76 |
77 | public FeedbackDialog() {
78 | // Empty constructor, required for pause/resume
79 | }
80 |
81 | @Override
82 | public Dialog onCreateDialog(Bundle savedInstanceState) {
83 | AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
84 | initializeUiFieldsDialogGoToMail();
85 | Log.d(TAG, "All components were initialized successfully");
86 |
87 | cancel.setOnClickListener(new View.OnClickListener() {
88 | public void onClick(View v) {
89 | dismiss();
90 | onActionListener.onRating(OnRatingListener.RatingAction.LOW_RATING_REFUSED_TO_GIVE_FEEDBACK, getArguments().getFloat(EXTRA_RATING_BAR));
91 | Log.d(TAG, "Canceled the feedback dialog");
92 | }
93 | });
94 |
95 | yes.setOnClickListener(new View.OnClickListener() {
96 | @Override
97 | public void onClick(View v) {
98 | goToMail(getArguments().getString(EXTRA_APP_NAME));
99 | onActionListener.onRating(OnRatingListener.RatingAction.LOW_RATING_GAVE_FEEDBACK, getArguments().getFloat(EXTRA_RATING_BAR));
100 | Log.d(TAG, "Agreed to provide feedback");
101 | dismiss();
102 | }
103 | });
104 |
105 | return builder.setCustomTitle(confirmDialogTitleView).setView(confirmDialogView).create();
106 | }
107 |
108 | private void initializeUiFieldsDialogGoToMail() {
109 | confirmDialogTitleView = View.inflate(getActivity(), R.layout.rateme__feedback_dialog_title, null);
110 | confirmDialogView = View.inflate(getActivity(), R.layout.rateme__feedback_dialog_message, null);
111 | confirmDialogTitleView.setBackgroundColor(getArguments().getInt(EXTRA_DIALOG_TITLE_COLOR));
112 | confirmDialogView.setBackgroundColor(getArguments().getInt(EXTRA_DIALOG_COLOR));
113 | if (getArguments().getInt(EXTRA_LOGO) == 0) {
114 | confirmDialogView.findViewById(R.id.app_icon_dialog_mail).setVisibility(View.GONE);
115 | } else {
116 | ((ImageView) confirmDialogView.findViewById(R.id.app_icon_dialog_mail)).setImageResource(getArguments().getInt(EXTRA_LOGO));
117 | confirmDialogView.findViewById(R.id.app_icon_dialog_mail).setVisibility(View.VISIBLE);
118 | }
119 | ((TextView) confirmDialogTitleView.findViewById(R.id.confirmDialogTitle)).setTextColor(getArguments().getInt(EXTRA_HEADER_TEXT_COLOR));
120 | ((TextView) confirmDialogView.findViewById(R.id.mail_dialog_message)).setTextColor(getArguments().getInt(EXTRA_TEXT_COLOR));
121 | cancel = (Button) confirmDialogView.findViewById(R.id.buttonCancel);
122 | yes = (Button) confirmDialogView.findViewById(R.id.buttonYes);
123 | cancel.setTextColor(getArguments().getInt(EXTRA_RATE_BUTTON_TEXT_COLOR));
124 | yes.setTextColor(getArguments().getInt(EXTRA_RATE_BUTTON_TEXT_COLOR));
125 | cancel.setBackgroundColor(getArguments().getInt(EXTRA_RATE_BUTTON_BG_COLOR));
126 | yes.setBackgroundColor(getArguments().getInt(EXTRA_RATE_BUTTON_BG_COLOR));
127 | onActionListener = getArguments().getParcelable(EXTRA_ON_ACTION_LISTENER);
128 | }
129 |
130 | private void goToMail(String appName) {
131 | final String subject = getResources().getString(R.string.rateme__email_subject, appName);
132 | sendGenericMail(subject);
133 | }
134 |
135 | @Override
136 | public void onStart() {
137 | super.onStart();
138 | final int titleDividerId = getResources().getIdentifier("titleDivider", "id", "android");
139 | final View titleDivider = getDialog().findViewById(titleDividerId);
140 | if (titleDivider != null) {
141 | titleDivider.setBackgroundColor(getArguments().getInt(EXTRA_TITLE_DIVIDER));
142 | }
143 | }
144 |
145 | private boolean isPackageInstalled(String packageName) {
146 | PackageManager pm = getActivity().getPackageManager();
147 | try {
148 | pm.getPackageInfo(packageName, PackageManager.GET_ACTIVITIES);
149 | return true;
150 | } catch (PackageManager.NameNotFoundException e) {
151 | return false;
152 | }
153 | }
154 |
155 | private void sendGenericMail(String subject) {
156 | Log.w(TAG, "Cannot send the email with GMail. Will use the generic chooser");
157 | Intent sendGeneric = new Intent(Intent.ACTION_SENDTO);
158 | sendGeneric.setType("plain/text");
159 | sendGeneric.setData(Uri.parse("mailto:"+getArguments().getString(EXTRA_EMAIL)));
160 | sendGeneric.putExtra(Intent.EXTRA_SUBJECT, subject);
161 | startActivity(Intent.createChooser(sendGeneric, ""));
162 | }
163 | }
164 |
--------------------------------------------------------------------------------
/LibraryRateMe/src/com/androidsx/rateme/OnRatingListener.java:
--------------------------------------------------------------------------------
1 | package com.androidsx.rateme;
2 |
3 | import android.os.Parcel;
4 | import android.os.Parcelable;
5 | import android.util.Log;
6 |
7 | /**
8 | * Listener for the rating (or absence thereof) that the user chooses.
9 | *
10 | * It is an optional parameter for the rate me dialog.
11 | */
12 | public interface OnRatingListener extends Parcelable {
13 |
14 | /**
15 | * Different actions that the user can take.
16 | */
17 | enum RatingAction {
18 |
19 | /** We took them to Google Play. Typically after a good rating. */
20 | HIGH_RATING_WENT_TO_GOOGLE_PLAY,
21 |
22 | /** After a negative rating, he accepted to give us some feedback. */
23 | LOW_RATING_GAVE_FEEDBACK,
24 |
25 | /** After a negative rating, he didn't give us some feedback. */
26 | LOW_RATING_REFUSED_TO_GIVE_FEEDBACK,
27 |
28 | /**
29 | * Gave a negative rating. Providing feedback is not configured, so the user gave the rating
30 | * and left.
31 | */
32 | LOW_RATING,
33 |
34 | /**
35 | * Dismissed the dialog with the cross in the upper-right corner. Note that we do NOT track
36 | * if the user dismisses the dialog through the back button.
37 | */
38 | DISMISSED_WITH_CROSS,
39 |
40 | /** Shared the link to the app through the button in the top-right corner. */
41 | SHARED_APP
42 | }
43 |
44 | /**
45 | * Arbitrary logic to execute after the user performed their action. Typically, keep track
46 | * of it for analytics purposes.
47 | *
48 | * @param action the action the user performed, among all possible ones
49 | * @param rating only meaningful for some of the actions
50 | */
51 | void onRating(RatingAction action, float rating);
52 | }
53 |
54 | class DefaultOnRatingListener implements OnRatingListener {
55 | public static final String TAG = DefaultOnRatingListener.class.getSimpleName();
56 |
57 | @Override
58 | public void onRating(RatingAction action, float rating) {
59 | Log.d(TAG, "Rating " + rating + ", after " + action);
60 | }
61 |
62 | @Override
63 | public int describeContents() {
64 | return 0;
65 | }
66 |
67 | @Override
68 | public void writeToParcel(Parcel dest, int flags) {
69 | // Nothing to write
70 | }
71 |
72 | public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
73 | public DefaultOnRatingListener createFromParcel(Parcel in) {
74 | //return new DefaultOnRatingListener(in);
75 | return new DefaultOnRatingListener();
76 | }
77 |
78 | public DefaultOnRatingListener[] newArray(int size) {
79 | return new DefaultOnRatingListener[size];
80 | }
81 | };
82 | }
83 |
--------------------------------------------------------------------------------
/LibraryRateMe/src/com/androidsx/rateme/RateMeDialog.java:
--------------------------------------------------------------------------------
1 | package com.androidsx.rateme;
2 |
3 | import android.app.AlertDialog;
4 | import android.app.Dialog;
5 | import android.app.DialogFragment;
6 | import android.content.Intent;
7 | import android.graphics.Color;
8 | import android.graphics.LightingColorFilter;
9 | import android.graphics.PorterDuff;
10 | import android.graphics.drawable.LayerDrawable;
11 | import android.net.Uri;
12 | import android.os.Bundle;
13 | import android.util.Log;
14 | import android.view.View;
15 | import android.widget.Button;
16 | import android.widget.ImageView;
17 | import android.widget.RatingBar;
18 | import android.widget.TextView;
19 |
20 | import com.androidsx.libraryrateme.R;
21 |
22 | /**
23 | * Rate Me dialog. Entry point into the library. Use the {@link com.androidsx.rateme.RateMeDialog.Builder} to
24 | * construct your instance.
25 | */
26 | public class RateMeDialog extends DialogFragment {
27 | private static final String TAG = RateMeDialog.class.getSimpleName();
28 |
29 | private static final String MARKET_CONSTANT = "market://details?id=";
30 | private static final String GOOGLE_PLAY_CONSTANT = "http://play.google.com/store/apps/details?id=";
31 |
32 | private final static String RESOURCE_NAME = "titleDivider";
33 | private final static String DEFAULT_TYPE_RESOURCE = "id";
34 | private final static String DEFAULT_PACKAGE = "android";
35 |
36 | // Views
37 | private View mView;
38 | private View tView;
39 | private Button close;
40 | private RatingBar ratingBar;
41 | private LayerDrawable stars;
42 | private Button rateMe;
43 | private Button noThanks;
44 | private Button share;
45 |
46 | // Configuration. It all comes from the builder. On, on resume, from the saved bundle
47 | private String appPackageName;
48 | private String appName;
49 | private int headerBackgroundColor;
50 | private int headerTextColor;
51 | private int bodyBackgroundColor;
52 | private int bodyTextColor;
53 | private boolean feedbackByEmailEnabled;
54 | private String feedbackEmail;
55 | private boolean showShareButton;
56 | private int appIconResId;
57 | private int lineDividerColor;
58 | private int rateButtonBackgroundColor;
59 | private int rateButtonTextColor;
60 | private int rateButtonPressedBackgroundColor;
61 | private int defaultStarsSelected;
62 | private int iconCloseColor;
63 | private int iconShareColor;
64 | private boolean showOKButtonByDefault;
65 | private OnRatingListener onRatingListener;
66 |
67 | public RateMeDialog() {
68 | // Empty constructor, required for pause/resume
69 | }
70 |
71 | public RateMeDialog(String appPackageName,
72 | String appName,
73 | int headerBackgroundColor,
74 | int headerTextColor,
75 | int bodyBackgroundColor,
76 | int bodyTextColor,
77 | boolean feedbackByEmailEnabled,
78 | String feedbackEmail,
79 | boolean showShareButton,
80 | int appIconResId,
81 | int lineDividerColor,
82 | int rateButtonBackgroundColor,
83 | int rateButtonTextColor,
84 | int rateButtonPressedBackgroundColor,
85 | int defaultStarsSelected,
86 | int iconCloseColor,
87 | int iconShareColor,
88 | boolean showOKButtonByDefault,
89 | OnRatingListener onRatingListener) {
90 | this.appPackageName = appPackageName;
91 | this.appName = appName;
92 | this.headerBackgroundColor = headerBackgroundColor;
93 | this.headerTextColor = headerTextColor;
94 | this.bodyBackgroundColor = bodyBackgroundColor;
95 | this.bodyTextColor = bodyTextColor;
96 | this.feedbackByEmailEnabled = feedbackByEmailEnabled;
97 | this.feedbackEmail = feedbackEmail;
98 | this.showShareButton = showShareButton;
99 | this.appIconResId = appIconResId;
100 | this.lineDividerColor = lineDividerColor;
101 | this.rateButtonBackgroundColor = rateButtonBackgroundColor;
102 | this.rateButtonTextColor = rateButtonTextColor;
103 | this.rateButtonPressedBackgroundColor = rateButtonPressedBackgroundColor;
104 | this.defaultStarsSelected = defaultStarsSelected;
105 | this.iconCloseColor = iconCloseColor;
106 | this.iconShareColor = iconShareColor;
107 | this.showOKButtonByDefault = showOKButtonByDefault;
108 | this.onRatingListener = onRatingListener;
109 | }
110 |
111 | @Override
112 | public Dialog onCreateDialog(Bundle savedInstanceState) {
113 | initializeUiFields();
114 | Log.d(TAG, "All components were initialized successfully");
115 |
116 | AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
117 |
118 | setIconsTitleColor(iconCloseColor, iconShareColor);
119 |
120 | stars.getDrawable(2).setColorFilter(Color.YELLOW, PorterDuff.Mode.SRC_ATOP);
121 | ratingBar.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {
122 |
123 | @Override
124 | public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
125 | if (rating >= 4.0) {
126 | rateMe.setVisibility(View.VISIBLE);
127 | noThanks.setVisibility(View.GONE);
128 | } else if (rating > 0.0){
129 | noThanks.setVisibility(View.VISIBLE);
130 | rateMe.setVisibility(View.GONE);
131 | } else {
132 | noThanks.setVisibility(View.GONE);
133 | rateMe.setVisibility(View.GONE);
134 | }
135 | defaultStarsSelected = (int) rating;
136 | }
137 | });
138 | ratingBar.setStepSize(1.0f);
139 | ratingBar.setRating((float) defaultStarsSelected);
140 | configureButtons();
141 |
142 | try {
143 | close.setOnClickListener(new View.OnClickListener() {
144 | @Override
145 | public void onClick(View v) {
146 | dismiss();
147 | RateMeDialogTimer.clearSharedPreferences(getActivity());
148 | Log.d(TAG, "Clear the shared preferences");
149 | RateMeDialogTimer.setOptOut(getActivity(), true);
150 | onRatingListener.onRating(OnRatingListener.RatingAction.DISMISSED_WITH_CROSS, ratingBar.getRating());
151 | }
152 | });
153 | } catch (Exception e) {
154 | Log.w(TAG, "Error while closing the dialog", e);
155 | dismiss();
156 | }
157 |
158 | try {
159 | share.setVisibility(showShareButton ? View.VISIBLE : View.GONE);
160 | share.setOnClickListener(new View.OnClickListener() {
161 | @Override
162 | public void onClick(View v) {
163 | startActivity(shareApp(appPackageName));
164 | Log.d(TAG, "Share the application");
165 | onRatingListener.onRating(OnRatingListener.RatingAction.SHARED_APP, ratingBar.getRating());
166 |
167 | }
168 | });
169 | } catch (Exception e) {
170 | Log.d(TAG,"Error showing share button " + e);
171 | dismiss();
172 | }
173 |
174 | return builder.setView(mView).setCustomTitle(tView).setCancelable(false).create();
175 | }
176 |
177 | @Override
178 | public void onCreate(Bundle savedInstanceState) {
179 | super.onCreate(savedInstanceState);
180 |
181 | if (savedInstanceState != null) {
182 | this.appPackageName = savedInstanceState.getString("appPackageName");
183 | this.appName = savedInstanceState.getString("appName");
184 | this.headerBackgroundColor = savedInstanceState.getInt("headerBackgroundColor");
185 | this.headerTextColor = savedInstanceState.getInt("headerTextColor");
186 | this.bodyBackgroundColor = savedInstanceState.getInt("bodyBackgroundColor");
187 | this.bodyTextColor = savedInstanceState.getInt("bodyTextColor");
188 | this.feedbackByEmailEnabled = savedInstanceState.getBoolean("feedbackByEmailEnabled");
189 | this.feedbackEmail = savedInstanceState.getString("feedbackEmail");
190 | this.showShareButton = savedInstanceState.getBoolean("showShareButton");
191 | this.appIconResId = savedInstanceState.getInt("appIconResId");
192 | this.lineDividerColor = savedInstanceState.getInt("lineDividerColor");
193 | this.rateButtonBackgroundColor = savedInstanceState.getInt("rateButtonBackgroundColor");
194 | this.rateButtonTextColor = savedInstanceState.getInt("rateButtonTextColor");
195 | this.rateButtonPressedBackgroundColor = savedInstanceState.getInt("rateButtonPressedBackgroundColor");
196 | this.defaultStarsSelected = savedInstanceState.getInt("defaultStarsSelected");
197 | this.iconCloseColor = savedInstanceState.getInt("iconCloseColor");
198 | this.iconShareColor = savedInstanceState.getInt("iconShareColor");
199 | this.showOKButtonByDefault = savedInstanceState.getBoolean("showOKButtonByDefault");
200 | this.onRatingListener = savedInstanceState.getParcelable("onRatingListener");
201 | }
202 | }
203 |
204 | @Override
205 | public void onSaveInstanceState(Bundle outState) {
206 | super.onSaveInstanceState(outState);
207 |
208 | outState.putString("appPackageName", appPackageName);
209 | outState.putString("appName", appName);
210 | outState.putInt("headerBackgroundColor", headerBackgroundColor);
211 | outState.putInt("headerTextColor", headerTextColor);
212 | outState.putInt("bodyBackgroundColor", bodyBackgroundColor);
213 | outState.putInt("bodyTextColor", bodyTextColor);
214 | outState.putBoolean("feedbackByEmailEnabled", feedbackByEmailEnabled);
215 | outState.putString("feedbackEmail", feedbackEmail);
216 | outState.putBoolean("showShareButton", showShareButton);
217 | outState.putInt("appIconResId", appIconResId);
218 | outState.putInt("lineDividerColor", lineDividerColor);
219 | outState.putInt("rateButtonBackgroundColor", rateButtonBackgroundColor);
220 | outState.putInt("rateButtonTextColor", rateButtonTextColor);
221 | outState.putInt("rateButtonPressedBackgroundColor", rateButtonPressedBackgroundColor);
222 | outState.putInt("defaultStarsSelected", defaultStarsSelected );
223 | outState.putInt("iconCloseColor", iconCloseColor );
224 | outState.putInt("iconShareColor", iconShareColor);
225 | outState.putBoolean("showOKButtonByDefault", showOKButtonByDefault);
226 | outState.putParcelable("onRatingListener", onRatingListener);
227 | }
228 |
229 | @Override
230 | public void onStart() {
231 | super.onStart();
232 | final int titleDividerId = getResources().getIdentifier(RESOURCE_NAME, DEFAULT_TYPE_RESOURCE, DEFAULT_PACKAGE);
233 | final View titleDivider = getDialog().findViewById(titleDividerId);
234 | if (titleDivider != null) {
235 | titleDivider.setBackgroundColor(lineDividerColor);
236 | }
237 | }
238 |
239 | private void initializeUiFields() {
240 | // Main Dialog
241 | mView = View.inflate(getActivity(), R.layout.rateme__dialog_message, null);
242 | tView = View.inflate(getActivity(), R.layout.rateme__dialog_title, null);
243 | close = (Button) tView.findViewById(R.id.buttonClose);
244 | share = (Button) tView.findViewById(R.id.buttonShare);
245 | rateMe = (Button) mView.findViewById(R.id.buttonRateMe);
246 | noThanks = (Button) mView.findViewById(R.id.buttonThanks);
247 | ratingBar = (RatingBar) mView.findViewById(R.id.ratingBar);
248 | stars = (LayerDrawable) ratingBar.getProgressDrawable();
249 | mView.setBackgroundColor(bodyBackgroundColor);
250 | tView.setBackgroundColor(headerBackgroundColor);
251 | ((TextView) tView.findViewById(R.id.dialog_title)).setTextColor(headerTextColor);
252 | final View iconImage = mView.findViewById(R.id.app_icon_dialog_rating);
253 | if (appIconResId == 0) {
254 | iconImage.setVisibility(View.GONE);
255 | } else {
256 | ((ImageView) iconImage).setImageResource(appIconResId);
257 | iconImage.setVisibility(View.VISIBLE);
258 | }
259 | ((TextView) mView.findViewById(R.id.rating_dialog_message)).setTextColor(bodyTextColor);
260 |
261 | rateMe.setBackgroundColor(rateButtonBackgroundColor);
262 | noThanks.setBackgroundColor(rateButtonBackgroundColor);
263 | rateMe.setTextColor(rateButtonTextColor);
264 | noThanks.setTextColor(rateButtonTextColor);
265 |
266 | }
267 |
268 | private void configureButtons() {
269 | rateMe.setOnClickListener(new View.OnClickListener() {
270 | @Override
271 | public void onClick(View v) {
272 | rateApp();
273 | Log.d(TAG, "Yes: open the Google Play Store");
274 | RateMeDialogTimer.setOptOut(getActivity(), true);
275 | onRatingListener.onRating(OnRatingListener.RatingAction.HIGH_RATING_WENT_TO_GOOGLE_PLAY, ratingBar.getRating());
276 | dismiss();
277 | }
278 | });
279 |
280 | noThanks.setOnClickListener(new View.OnClickListener() {
281 | @Override
282 | public void onClick(View v) {
283 | if (feedbackByEmailEnabled) {
284 | DialogFragment dialogMail = FeedbackDialog.newInstance(feedbackEmail,
285 | appName,
286 | headerBackgroundColor,
287 | bodyBackgroundColor,
288 | headerTextColor,
289 | bodyTextColor,
290 | appIconResId,
291 | lineDividerColor,
292 | rateButtonTextColor,
293 | rateButtonBackgroundColor,
294 | ratingBar.getRating(),
295 | onRatingListener);
296 | dialogMail.show(getFragmentManager(), "feedbackByEmailEnabled");
297 | dismiss();
298 | Log.d(TAG, "No: open the feedback dialog");
299 | } else {
300 | dismiss();
301 | onRatingListener.onRating(OnRatingListener.RatingAction.LOW_RATING, ratingBar.getRating());
302 | }
303 | RateMeDialogTimer.setOptOut(getActivity(), true);
304 | }
305 | });
306 | }
307 |
308 | private void rateApp() {
309 | try {
310 | startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(MARKET_CONSTANT + appPackageName)));
311 | } catch (android.content.ActivityNotFoundException anfe) {
312 | startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(GOOGLE_PLAY_CONSTANT + appPackageName)));
313 | }
314 | }
315 |
316 | private Intent shareApp(String appPackageName) {
317 | Intent shareApp = new Intent();
318 | shareApp.setAction(Intent.ACTION_SEND);
319 | try {
320 | shareApp.putExtra(Intent.EXTRA_TEXT, MARKET_CONSTANT + appPackageName);
321 | } catch (android.content.ActivityNotFoundException anfe) {
322 | shareApp.putExtra(Intent.EXTRA_TEXT, GOOGLE_PLAY_CONSTANT + appPackageName);
323 | }
324 | shareApp.setType("text/plain");
325 | return shareApp;
326 | }
327 |
328 | private void setIconsTitleColor(int colorClose, int colorShare) {
329 | getResources().getDrawable(android.R.drawable.ic_menu_close_clear_cancel)
330 | .setColorFilter(new LightingColorFilter(colorClose, colorClose));
331 | getResources().getDrawable(android.R.drawable.ic_menu_share)
332 | .setColorFilter(new LightingColorFilter(colorShare, colorShare));
333 | }
334 |
335 | public static class Builder {
336 | private static final int LINE_DIVIDER_COLOR_UNSET = -1;
337 | private final String appPackageName;
338 | private final String appName;
339 | private int headerBackgroundColor = Color.BLACK;
340 | private int headerTextColor = Color.WHITE;
341 | private int bodyBackgroundColor = Color.DKGRAY;
342 | private int bodyTextColor = Color.WHITE;
343 | private boolean feedbackByEmailEnabled = false;
344 | private String feedbackEmail = null;
345 | private boolean showShareButton = false;
346 | private int appIconResId = 0;
347 | private int lineDividerColor = LINE_DIVIDER_COLOR_UNSET;
348 | private int rateButtonBackgroundColor = Color.BLACK;
349 | private int rateButtonTextColor = Color.WHITE;
350 | private int rateButtonPressedBackgroundColor = Color.GRAY;
351 | private int defaultStarsSelected = 0;
352 | private int iconCloseColor = Color.WHITE;
353 | private int iconShareColor = Color.WHITE;
354 | private boolean showOKButtonByDefault = true;
355 | private OnRatingListener onRatingListener = new DefaultOnRatingListener();
356 |
357 | /**
358 | * @param appPackageName package name of the application. Available in {@code Context.getPackageName()}.
359 | * @param appName name of the application. Typically {@code getResources().getString(R.string.app_name)}.
360 | */
361 | public Builder(String appPackageName, String appName) {
362 | this.appPackageName = appPackageName;
363 | this.appName = appName;
364 | }
365 |
366 | public Builder setHeaderBackgroundColor(int headerBackgroundColor) {
367 | this.headerBackgroundColor = headerBackgroundColor;
368 | return this;
369 | }
370 |
371 | public Builder setHeaderTextColor(int headerTextColor) {
372 | this.headerTextColor = headerTextColor;
373 | return this;
374 | }
375 |
376 | public Builder setBodyBackgroundColor(int bodyBackgroundColor) {
377 | this.bodyBackgroundColor = bodyBackgroundColor;
378 | return this;
379 | }
380 |
381 | public Builder setBodyTextColor(int bodyTextColor) {
382 | this.bodyTextColor = bodyTextColor;
383 | return this;
384 | }
385 |
386 | /**
387 | * Enables a second dialog that opens if the rating is low, from which the user can send
388 | * an e-mail to the provided e-mail address.
389 | */
390 | public Builder enableFeedbackByEmail(String email) {
391 | this.feedbackByEmailEnabled = true;
392 | this.feedbackEmail = email;
393 | return this;
394 | }
395 |
396 | public Builder setShowShareButton(boolean showShareButton) {
397 | this.showShareButton = showShareButton;
398 | return this;
399 | }
400 |
401 | public Builder setLineDividerColor(int lineDividerColor) {
402 | this.lineDividerColor = lineDividerColor;
403 | return this;
404 | }
405 |
406 | /**
407 | * Sets an icon to be placed on the left-hand side of the dialog. No icon will show up
408 | * otherwise.
409 | *
410 | * Careful: before 3.0.0, there was a default icon.
411 | */
412 | public Builder showAppIcon(int appIconResId) {
413 | this.appIconResId = appIconResId;
414 | return this;
415 | }
416 |
417 | public Builder setRateButtonBackgroundColor(int rateButtonBackgroundColor) {
418 | this.rateButtonBackgroundColor = rateButtonBackgroundColor;
419 | return this;
420 | }
421 |
422 | public Builder setRateButtonTextColor(int rateButtonTextColor) {
423 | this.rateButtonTextColor = rateButtonTextColor;
424 | return this;
425 | }
426 |
427 | public Builder setRateButtonPressedBackgroundColor(int rateButtonPressedBackgroundColor) {
428 | this.rateButtonPressedBackgroundColor = rateButtonPressedBackgroundColor;
429 | return this;
430 | }
431 |
432 | public Builder setDefaultNumberOfStars(int numStars) {
433 | this.defaultStarsSelected = numStars;
434 | return this;
435 | }
436 |
437 | public Builder setIconCloseColorFilter(int iconColor) {
438 | this.iconCloseColor = iconColor;
439 | return this;
440 | }
441 |
442 | public Builder setIconShareColorFilter(int iconColor) {
443 | this.iconShareColor = iconColor;
444 | return this;
445 | }
446 |
447 | public Builder setShowOKButtonByDefault(boolean visible) {
448 | this.showOKButtonByDefault = visible;
449 | return this;
450 | }
451 |
452 | /**
453 | * @see com.androidsx.rateme.OnRatingListener
454 | */
455 | public Builder setOnRatingListener(OnRatingListener onRatingListener) {
456 | this.onRatingListener = onRatingListener;
457 | return this;
458 | }
459 |
460 | public RateMeDialog build() {
461 | if (lineDividerColor == LINE_DIVIDER_COLOR_UNSET) {
462 | lineDividerColor = headerBackgroundColor;
463 | }
464 | return new RateMeDialog(appPackageName,
465 | appName,
466 | headerBackgroundColor,
467 | headerTextColor,
468 | bodyBackgroundColor,
469 | bodyTextColor,
470 | feedbackByEmailEnabled,
471 | feedbackEmail,
472 | showShareButton,
473 | appIconResId,
474 | lineDividerColor,
475 | rateButtonBackgroundColor,
476 | rateButtonTextColor,
477 | rateButtonPressedBackgroundColor,
478 | defaultStarsSelected,
479 | iconCloseColor,
480 | iconShareColor,
481 | showOKButtonByDefault,
482 | onRatingListener);
483 | }
484 | }
485 | }
486 |
--------------------------------------------------------------------------------
/LibraryRateMe/src/com/androidsx/rateme/RateMeDialogTimer.java:
--------------------------------------------------------------------------------
1 | package com.androidsx.rateme;
2 |
3 | import java.util.Date;
4 |
5 | import android.content.Context;
6 | import android.content.SharedPreferences;
7 | import android.content.SharedPreferences.Editor;
8 | import android.os.Bundle;
9 | import android.util.Log;
10 |
11 | /**
12 | * Timer to schedule the rate-me after a number of application launches.
13 | */
14 | public class RateMeDialogTimer {
15 | private static final String TAG = RateMeDialogTimer.class.getSimpleName();
16 |
17 | private static final String PREF_NAME = "RateThisApp";
18 | private static final String KEY_INSTALL_DATE = "rta_install_date";
19 | private static final String KEY_LAUNCH_TIMES = "rta_launch_times";
20 | private static final String KEY_OPT_OUT = "rta_opt_out";
21 |
22 | private static Date mInstallDate = new Date();
23 | private static int mLaunchTimes = 0;
24 | private static boolean mOptOut = false;
25 |
26 | /**
27 | * Note to pre-1.2 users: installDate and launchTimes are now parameters in
28 | * {@link #shouldShowRateDialog}.
29 | */
30 | public RateMeDialogTimer() {
31 | // Intentionally empty. See the javadoc comment
32 | }
33 |
34 | public static void onStart(Context context, Bundle savedInstanceState) {
35 | // Only use FIRST launch of the activity
36 | if (savedInstanceState != null) {
37 | return;
38 | }
39 | saveInPreferences(context);
40 | }
41 |
42 | public static void onStart(Context context) {
43 | saveInPreferences(context);
44 | }
45 |
46 | private static void saveInPreferences(Context context) {
47 | SharedPreferences pref = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
48 | Editor editor = pref.edit();
49 | // If it is the first launch, save the date in shared preference.
50 | if (pref.getLong(KEY_INSTALL_DATE, 0) == 0L) {
51 | Date now = new Date();
52 | editor.putLong(KEY_INSTALL_DATE, now.getTime());
53 | Log.d(TAG, "First install: " + now.toString());
54 | }
55 | // Increment launch times
56 | int launchTimes = pref.getInt(KEY_LAUNCH_TIMES, 0);
57 | launchTimes++;
58 | editor.putInt(KEY_LAUNCH_TIMES, launchTimes);
59 | Log.d(TAG, "Launch times; " + launchTimes);
60 |
61 | editor.apply();
62 |
63 | mInstallDate = new Date(pref.getLong(KEY_INSTALL_DATE, 0));
64 | mLaunchTimes = pref.getInt(KEY_LAUNCH_TIMES, 0);
65 | mOptOut = pref.getBoolean(KEY_OPT_OUT, false);
66 | }
67 |
68 | public static boolean shouldShowRateDialog(final Context context, int installDays, int launchTimes) {
69 | if (mOptOut) {
70 | return false;
71 | } else {
72 | if (mLaunchTimes >= launchTimes) {
73 | clearSharedPreferences(context);
74 | return true;
75 | }
76 | final long thresholdMillis = installDays * 24 * 60 * 60 * 1000L;
77 | if (new Date().getTime() - mInstallDate.getTime() >= thresholdMillis) {
78 | clearSharedPreferences(context);
79 | return true;
80 | } else {
81 | return false;
82 | }
83 | }
84 | }
85 |
86 | public static void clearSharedPreferences(Context context) {
87 | SharedPreferences pref = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
88 | Editor editor = pref.edit();
89 | editor.remove(KEY_INSTALL_DATE);
90 | editor.remove(KEY_LAUNCH_TIMES);
91 | editor.apply();
92 | }
93 |
94 | /**
95 | * Set opt out flag. If it is true, the rate dialog will never shown unless app data is cleared.
96 | */
97 | public static void setOptOut(final Context context, boolean optOut) {
98 | SharedPreferences pref = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
99 | Editor editor = pref.edit();
100 | editor.putBoolean(KEY_OPT_OUT, optOut);
101 | editor.apply();
102 | }
103 |
104 | public static boolean wasRated(Context context) {
105 | SharedPreferences pref = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
106 | return pref.getBoolean(KEY_OPT_OUT, false);
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Rate-Me [](https://android-arsenal.com/details/1/1032)
2 | =======
3 |
4 | Rate Me is an Android library that shows dialog to suggest the user to rate the application in the Google Play Store.
5 |
6 | With a little twist: if the rating is positive, we take the user to the Play Store directly. Otherwise, we ask him for feedback via email. (This is all configurable.)
7 |
8 |
9 |
10 |
11 |
12 |
13 | How to integrate
14 | ================
15 |
16 | Add this dependency in your `build.gradle`:
17 |
18 | ```xml
19 | dependencies {
20 | compile 'com.androidsx:rate-me:4.0.3'
21 | }
22 | ```
23 |
24 | Find the latest version in [Maven Central](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.androidsx%22%20AND%20a%3A%22rate-me%22).
25 |
26 | How to use
27 | ==========
28 |
29 | The simplest integration:
30 |
31 | ```java
32 | new RateMeDialog.Builder(getPackageName())
33 | .enableFeedbackByEmail("email@example.com")
34 | .build()
35 | .show(getFragmentManager(), "plain-dialog");
36 | ```
37 |
38 | Have a look at the sample project for other examples.
39 |
40 | Automatic timer
41 | ---------------
42 |
43 | You can make the dialog appear after a number of times your app has been opened or after a number of days after the install date:
44 |
45 | ```java
46 | RateMeDialogTimer.onStart(this);
47 | if (RateMeDialogTimer.shouldShowRateDialog(this, 7, 3)) {
48 | // show the dialog with the code above
49 | }
50 | ```
51 |
52 | License
53 | =======
54 |
55 | Licensed under the MIT License. See the [LICENSE.md](LICENSE.md) file for more details.
56 |
--------------------------------------------------------------------------------
/SampleProject/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/SampleProject/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | SampleProject
4 |
5 |
6 |
7 |
8 |
9 | com.android.ide.eclipse.adt.ResourceManagerBuilder
10 |
11 |
12 |
13 |
14 | com.android.ide.eclipse.adt.PreCompilerBuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.jdt.core.javabuilder
20 |
21 |
22 |
23 |
24 | com.android.ide.eclipse.adt.ApkBuilder
25 |
26 |
27 |
28 |
29 |
30 | com.android.ide.eclipse.adt.AndroidNature
31 | org.eclipse.jdt.core.javanature
32 |
33 |
34 |
--------------------------------------------------------------------------------
/SampleProject/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
10 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/SampleProject/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | buildscript{
4 | repositories{
5 | mavenCentral()
6 | }
7 | dependencies{
8 | classpath 'com.android.tools.build:gradle:1.1.0'
9 | }
10 | }
11 |
12 | repositories {
13 | mavenCentral()
14 | }
15 |
16 | android {
17 | compileSdkVersion 22
18 | buildToolsVersion "21.1.2"
19 |
20 | defaultConfig {
21 | minSdkVersion 14
22 | targetSdkVersion 22
23 | versionName project.VERSION_NAME
24 | versionCode Integer.parseInt(project.VERSION_CODE)
25 | }
26 |
27 | sourceSets {
28 | main {
29 | manifest.srcFile 'AndroidManifest.xml'
30 | java.srcDirs = ['src']
31 | resources.srcDirs = ['src']
32 | aidl.srcDirs = ['src']
33 | renderscript.srcDirs = ['src']
34 | res.srcDirs = ['res']
35 | assets.srcDirs = ['assets']
36 | }
37 | }
38 |
39 | // It would be better to fix the issues
40 | lintOptions {
41 | abortOnError false
42 | }
43 | }
44 |
45 | dependencies {
46 | compile project(':LibraryRateMe')
47 | compile 'com.android.support:appcompat-v7:22.2.0'
48 | }
49 |
--------------------------------------------------------------------------------
/SampleProject/ic_launcher-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androidsx/rate-me/a779706454ba585a09110745ac3035f28920524a/SampleProject/ic_launcher-web.png
--------------------------------------------------------------------------------
/SampleProject/libs/android-support-v4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androidsx/rate-me/a779706454ba585a09110745ac3035f28920524a/SampleProject/libs/android-support-v4.jar
--------------------------------------------------------------------------------
/SampleProject/lint.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/SampleProject/proguard-project.txt:
--------------------------------------------------------------------------------
1 | # To enable ProGuard in your project, edit project.properties
2 | # to define the proguard.config property as described in that file.
3 | #
4 | # Add project specific ProGuard rules here.
5 | # By default, the flags in this file are appended to flags specified
6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt
7 | # You can edit the include path and order by changing the ProGuard
8 | # include property in project.properties.
9 | #
10 | # For more details, see
11 | # http://developer.android.com/guide/developing/tools/proguard.html
12 |
13 | # Add any project specific keep options here:
14 |
15 | # If your project uses WebView with JS, uncomment the following
16 | # and specify the fully qualified class name to the JavaScript interface
17 | # class:
18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
19 | # public *;
20 | #}
21 |
--------------------------------------------------------------------------------
/SampleProject/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system edit
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 | #
10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
12 |
13 | # Project target.
14 | target=android-19
15 | android.library.reference.1=../LibraryRateMe
16 |
--------------------------------------------------------------------------------
/SampleProject/res/layout/sample_project.xml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
18 |
19 |
25 |
26 |
--------------------------------------------------------------------------------
/SampleProject/res/menu/rateme.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
--------------------------------------------------------------------------------
/SampleProject/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androidsx/rate-me/a779706454ba585a09110745ac3035f28920524a/SampleProject/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/SampleProject/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androidsx/rate-me/a779706454ba585a09110745ac3035f28920524a/SampleProject/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/SampleProject/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androidsx/rate-me/a779706454ba585a09110745ac3035f28920524a/SampleProject/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/SampleProject/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androidsx/rate-me/a779706454ba585a09110745ac3035f28920524a/SampleProject/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/SampleProject/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androidsx/rate-me/a779706454ba585a09110745ac3035f28920524a/SampleProject/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/SampleProject/res/values-sw600dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/SampleProject/res/values-sw720dp-land/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 | 128dp
8 |
9 |
10 |
--------------------------------------------------------------------------------
/SampleProject/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FF5722
4 | #E64A19
5 | #FFCCBC
6 | @android:color/black
7 |
--------------------------------------------------------------------------------
/SampleProject/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 16dp
5 | 16dp
6 |
7 |
8 |
--------------------------------------------------------------------------------
/SampleProject/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Sample Rate Me
4 |
5 | Rate Me (simple)
6 | Rate Me (custom)
7 |
8 |
--------------------------------------------------------------------------------
/SampleProject/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/SampleProject/src/com/androidsx/rateme/demo1/SampleProjectMainActivity.java:
--------------------------------------------------------------------------------
1 | package com.androidsx.rateme.demo1;
2 |
3 | import android.os.Bundle;
4 | import android.os.Parcel;
5 | import android.support.v7.app.ActionBarActivity;
6 | import android.view.Menu;
7 | import android.view.MenuItem;
8 | import android.view.View;
9 | import android.widget.Toast;
10 |
11 | import com.androidsx.rateme.OnRatingListener;
12 | import com.androidsx.rateme.RateMeDialog;
13 | import com.androidsx.rateme.RateMeDialogTimer;
14 | import com.androidsx.rateme.demo.R;
15 |
16 | public class SampleProjectMainActivity extends ActionBarActivity {
17 |
18 | @Override
19 | protected void onCreate(Bundle savedInstanceState) {
20 | super.onCreate(savedInstanceState);
21 | setContentView(R.layout.sample_project);
22 | }
23 |
24 | public void onPlainRateMeButtonClick(View view) {
25 | showPlainRateMeDialog();
26 | }
27 |
28 | public void onCustomRateMeButtonClick(View view) {
29 | showCustomRateMeDialog();
30 | }
31 |
32 | @Override
33 | public boolean onCreateOptionsMenu(Menu menu) {
34 | getMenuInflater().inflate(R.menu.rateme, menu);
35 | return true;
36 | }
37 |
38 | @Override
39 | public boolean onOptionsItemSelected(MenuItem item) {
40 | switch (item.getItemId()) {
41 | case R.id.RateMe: {
42 | showPlainRateMeDialog();
43 | return true;
44 | }
45 | default:
46 | return super.onOptionsItemSelected(item);
47 | }
48 | }
49 |
50 | @Override
51 | protected void onStart() {
52 | super.onStart();
53 |
54 | final int launchTimes = 3;
55 | final int installDate = 7;
56 |
57 | RateMeDialogTimer.onStart(this);
58 | if (RateMeDialogTimer.shouldShowRateDialog(this, installDate, launchTimes)) {
59 | showPlainRateMeDialog();
60 | }
61 |
62 | }
63 |
64 | private void showPlainRateMeDialog() {
65 | new RateMeDialog.Builder(getPackageName(), getString(R.string.app_name))
66 | .build()
67 | .show(getFragmentManager(), "plain-dialog");
68 | }
69 |
70 | private void showCustomRateMeDialog() {
71 | new RateMeDialog.Builder(getPackageName(), getString(R.string.app_name))
72 | .setHeaderBackgroundColor(getResources().getColor(R.color.dialog_primary))
73 | .setBodyBackgroundColor(getResources().getColor(R.color.dialog_primary_light))
74 | .setBodyTextColor(getResources().getColor(R.color.dialog_text_foreground))
75 | .enableFeedbackByEmail("email@example.com")
76 | .showAppIcon(R.mipmap.ic_launcher)
77 | .setShowShareButton(true)
78 | .setRateButtonBackgroundColor(getResources().getColor(R.color.dialog_primary))
79 | .setRateButtonPressedBackgroundColor(getResources().getColor(R.color.dialog_primary_dark))
80 | .setOnRatingListener(new OnRatingListener() {
81 | @Override
82 | public void onRating(RatingAction action, float rating) {
83 | Toast.makeText(SampleProjectMainActivity.this,
84 | "Rate Me action: " + action + " (rating: " + rating + ")", Toast.LENGTH_LONG).show();
85 | }
86 |
87 | @Override
88 | public int describeContents() {
89 | return 0;
90 | }
91 |
92 | @Override
93 | public void writeToParcel(Parcel dest, int flags) {
94 | // Nothing to write
95 | }
96 | })
97 | .build()
98 | .show(getFragmentManager(), "custom-dialog");
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | repositories {
3 | mavenCentral()
4 | }
5 |
6 | dependencies {
7 | classpath 'com.android.tools.build:gradle:1.1.0'
8 | }
9 | }
10 |
11 | def isReleaseBuild() {
12 | return version.contains("SNAPSHOT") == false
13 | }
14 |
15 | allprojects {
16 | version = VERSION_NAME
17 | group = GROUP
18 |
19 | repositories {
20 | mavenCentral()
21 | }
22 | }
23 |
24 | apply plugin: 'android-reporting'
25 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | VERSION_NAME=4.0.3
2 | VERSION_CODE=403
3 | GROUP=com.androidsx
4 |
5 | POM_DESCRIPTION=Android library that shows a dialog to let the user rate this app in the Google Play store
6 | POM_URL=https://github.com/androidsx/rate-me
7 | POM_SCM_URL=https://github.com/androidsx/rate-me
8 | POM_SCM_CONNECTION=scm:git@github.com:androidsx/rate-me.git
9 | POM_SCM_DEV_CONNECTION=scm:git@github.com:androidsx/rate-me.git
10 | POM_LICENCE_NAME=MIT License
11 | POM_LICENCE_URL=https://github.com/androidsx/rate-me/blob/master/LICENSE.md
12 | POM_LICENCE_DIST=repo
13 | POM_DEVELOPER_ID=pocho23
14 | POM_DEVELOPER_NAME=Lucas Ponzoda
15 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androidsx/rate-me/a779706454ba585a09110745ac3035f28920524a/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sun Dec 14 18:29:13 CET 2014
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/maven_push.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'maven'
2 | apply plugin: 'signing'
3 |
4 | def sonatypeRepositoryUrl
5 | if (isReleaseBuild()) {
6 | println 'RELEASE BUILD'
7 | sonatypeRepositoryUrl = hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
8 | : "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
9 | } else {
10 | println 'SNAPSHOT BUILD'
11 | sonatypeRepositoryUrl = hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL
12 | : "https://oss.sonatype.org/content/repositories/snapshots/"
13 |
14 | }
15 |
16 | def getRepositoryUsername() {
17 | return hasProperty('nexusUsername') ? nexusUsername : ""
18 | }
19 |
20 | def getRepositoryPassword() {
21 | return hasProperty('nexusPassword') ? nexusPassword : ""
22 | }
23 |
24 | afterEvaluate { project ->
25 | uploadArchives {
26 | repositories {
27 | mavenDeployer {
28 | beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
29 |
30 | pom.artifactId = POM_ARTIFACT_ID
31 |
32 | repository(url: sonatypeRepositoryUrl) {
33 | authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
34 | }
35 |
36 | pom.project {
37 | name POM_NAME
38 | packaging POM_PACKAGING
39 | description POM_DESCRIPTION
40 | url POM_URL
41 |
42 | scm {
43 | url POM_SCM_URL
44 | connection POM_SCM_CONNECTION
45 | developerConnection POM_SCM_DEV_CONNECTION
46 | }
47 |
48 | licenses {
49 | license {
50 | name POM_LICENCE_NAME
51 | url POM_LICENCE_URL
52 | distribution POM_LICENCE_DIST
53 | }
54 | }
55 |
56 | developers {
57 | developer {
58 | id POM_DEVELOPER_ID
59 | name POM_DEVELOPER_NAME
60 | }
61 | }
62 | }
63 | }
64 | }
65 | }
66 |
67 | signing {
68 | required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") }
69 | sign configurations.archives
70 | }
71 |
72 | task androidJavadocs(type: Javadoc) {
73 | source = android.sourceSets.main.java.sourceFiles
74 | }
75 |
76 | task androidJavadocsJar(type: Jar) {
77 | classifier = 'javadoc'
78 | //basename = artifact_id
79 | from androidJavadocs.destinationDir
80 | }
81 |
82 | task androidSourcesJar(type: Jar) {
83 | classifier = 'sources'
84 | //basename = artifact_id
85 | from android.sourceSets.main.java.sourceFiles
86 | }
87 |
88 | artifacts {
89 | //archives packageReleaseJar
90 | archives androidSourcesJar
91 | archives androidJavadocsJar
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/readme-images/rate-me-dialog-in-helium.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androidsx/rate-me/a779706454ba585a09110745ac3035f28920524a/readme-images/rate-me-dialog-in-helium.png
--------------------------------------------------------------------------------
/readme-images/rate-me-dialog-in-pixable.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androidsx/rate-me/a779706454ba585a09110745ac3035f28920524a/readme-images/rate-me-dialog-in-pixable.png
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':LibraryRateMe'
2 | include ':SampleProject'
3 |
--------------------------------------------------------------------------------