|
| 1 | +Android-Rate |
| 2 | +============ |
| 3 | + |
| 4 | +[](https://travis-ci.org/hotchemi/Android-Rate) |
| 5 | +[](http://android-arsenal.com/details/1/846) |
| 6 | + |
| 7 | +Android-Rate is a library to help you promote your android app by prompting users to rate the app after using it for a few days. |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | +## Getting Started |
| 12 | + |
| 13 | + |
| 14 | +You can download from maven central. |
| 15 | + |
| 16 | +```groovy |
| 17 | +dependencies { |
| 18 | + compile 'com.github.hotchemi:android-rate:{$latest.version}' |
| 19 | +} |
| 20 | +``` |
| 21 | + |
| 22 | +## Sample |
| 23 | + |
| 24 | +Please try to move the [sample module](https://github.com/hotchemi/Android-Rate/tree/master/sample). |
| 25 | + |
| 26 | +## How to use |
| 27 | + |
| 28 | +### Configuration |
| 29 | + |
| 30 | +Android-Rate provides methods to configure its behavior. |
| 31 | + |
| 32 | +```java |
| 33 | +@Override |
| 34 | +protected void onCreate(Bundle savedInstanceState) { |
| 35 | + super.onCreate(savedInstanceState); |
| 36 | + setContentView(R.layout.activity_main); |
| 37 | + |
| 38 | + AppRate.with(this) |
| 39 | + .setInstallDays(0) // default 10, 0 means install day. |
| 40 | + .setLaunchTimes(3) // default 10 |
| 41 | + .setRemindInterval(2) // default 1 |
| 42 | + .setShowNeutralButton(true) // default true |
| 43 | + .setDebug(false) // default false |
| 44 | + .setOnClickButtonListener(new OnClickButtonListener() { // callback listener. |
| 45 | + @Override |
| 46 | + public void onClickButton(int which) { |
| 47 | + Log.d(MainActivity.class.getName(), Integer.toString(which)); |
| 48 | + } |
| 49 | + }) |
| 50 | + .monitor(); |
| 51 | + |
| 52 | + // Show a dialog if meets conditions |
| 53 | + AppRate.showRateDialogIfMeetsConditions(this); |
| 54 | +} |
| 55 | +``` |
| 56 | + |
| 57 | +The default conditions to show rate dialog is as below: |
| 58 | + |
| 59 | +1. App is launched more than 10 days later than installation. Change via `AppRate#setInstallDays(int)`. |
| 60 | +2. App is launched more than 10 times. Change via `AppRate#setLaunchTimes(int)`. |
| 61 | +3. App is launched more than 2 days after neutral button clicked. Change via `AppRate#setRemindInterval(int)`. |
| 62 | +4. App shows neutral dialog(Remind me later) by default. Change via `setShowNeutralButton(boolean)`. |
| 63 | +5. To specify the callback when the button is pressed. The same value as the second argument of `DialogInterface.OnClickListener#onClick` will be passed in the argument of `onClickButton`. |
| 64 | +6. Setting `AppRate#setDebug(boolean)` will ensure that the rating request is shown each time the app is launched. **This feature is only development!**. |
| 65 | + |
| 66 | +### Event Tracking |
| 67 | + |
| 68 | +When you want to track significant events, write code as below. |
| 69 | + |
| 70 | +```java |
| 71 | + |
| 72 | +@Override |
| 73 | +protected void onCreate(Bundle savedInstanceState) { |
| 74 | + super.onCreate(savedInstanceState); |
| 75 | + setContentView(R.layout.activity_main); |
| 76 | + AppRate.with(this).setEventTimes(2).monitor(); |
| 77 | +} |
| 78 | + |
| 79 | +@Override |
| 80 | +public void onClick() { |
| 81 | + AppRate.passSignificantEvent(this); // when user pass this line for the third time, dialog appears. |
| 82 | +} |
| 83 | +``` |
| 84 | + |
| 85 | +### Clear show dialog flag |
| 86 | + |
| 87 | +When you want to show the dialog again, call `AppRate#clearAgreeShowDialog()`. |
| 88 | + |
| 89 | +```java |
| 90 | +AppRate.with(this).clearAgreeShowDialog(); |
| 91 | +``` |
| 92 | + |
| 93 | +### When the button presses on |
| 94 | + |
| 95 | +call `AppRate#showDialog(Activity)`. |
| 96 | + |
| 97 | +```java |
| 98 | +AppRate.with(this).showDialog(this); |
| 99 | +``` |
| 100 | + |
| 101 | +### Set custom view |
| 102 | + |
| 103 | +call `AppRate#setView(View)`. |
| 104 | + |
| 105 | +```java |
| 106 | +LayoutInflater inflater = (LayoutInflater)this.getSystemService(LAYOUT_INFLATER_SERVICE); |
| 107 | +View view = inflater.inflate(R.layout.custom_dialog, (ViewGroup)findViewById(R.id.layout_root)); |
| 108 | +AppRate.with(this).setView(view).monitor(); |
| 109 | +``` |
| 110 | + |
| 111 | +### Custom dialog |
| 112 | + |
| 113 | +If you want to use your own dialog labels, override string xml resources on your application. |
| 114 | + |
| 115 | +```xml |
| 116 | +<resources> |
| 117 | + <string name="rate_dialog_title">Rate this app</string> |
| 118 | + <string name="rate_dialog_message">If you enjoy playing this app, would you mind taking a moment to rate it? It won\'t take more than a minute. Thanks for your support!</string> |
| 119 | + <string name="rate_dialog_ok">Rate It Now</string> |
| 120 | + <string name="rate_dialog_cancel">Remind Me Later</string> |
| 121 | + <string name="rate_dialog_no">No, Thanks</string> |
| 122 | +</resources> |
| 123 | +``` |
| 124 | + |
| 125 | +## Localization |
| 126 | + |
| 127 | +Android-Rate currently supports the following languages: |
| 128 | + |
| 129 | +- English |
| 130 | +- Spanish |
| 131 | +- French |
| 132 | +- Chinese |
| 133 | +- Korean |
| 134 | +- Japanese |
| 135 | +- Vietnamese |
| 136 | +- Polish |
| 137 | +- Czech |
| 138 | +- Russian |
| 139 | +- Ukrainian |
| 140 | +- Hebrew |
| 141 | +- Portuguese |
| 142 | + |
| 143 | +## Contribute |
| 144 | + |
| 145 | +1. Fork it |
| 146 | +2. Create your feature branch (`git checkout -b my-new-feature`) |
| 147 | +3. Commit your changes (`git commit -am 'Added some feature'`) |
| 148 | +4. Push to the branch (`git push origin my-new-feature`) |
| 149 | +5. Create new Pull Request |
| 150 | + |
| 151 | +## Contributor |
| 152 | + |
| 153 | +- [androhi](https://github.com/androhi) |
| 154 | +- [hoang8f](https://github.com/hoang8f) |
| 155 | +- [mrmike](https://github.com/mrmike) |
| 156 | +- [maarekj](https://github.com/maarekj) |
| 157 | +- [TomasValenta](https://github.com/TomasValenta) |
| 158 | +- [nein37](https://github.com/nein37) |
| 159 | +- [marta-rodriguez](https://github.com/marta-rodriguez) |
| 160 | +- [Bersh](https://github.com/Bersh) |
| 161 | +- [amitkot](https://github.com/amitkot) |
| 162 | +- [joelbrito](https://github.com/joelbrito) |
| 163 | + |
| 164 | +## Used |
| 165 | + |
| 166 | +- [Zaim](https://play.google.com/store/apps/details?id=net.zaim.android) |
| 167 | +- [就活マネージャー](https://play.google.com/store/apps/details?id=jp.co.recruit.shukatsumgr2016) |
| 168 | +- [candlecake](https://play.google.com/store/apps/details?id=com.eranamit.candlecake&referrer=utm_source%3DAndroid-Rate) |
0 commit comments