Skip to content

Commit eae4a59

Browse files
committed
LIBcc10508
1 parent d0baee4 commit eae4a59

File tree

4 files changed

+41
-32
lines changed

4 files changed

+41
-32
lines changed

README.md

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
AndroidRate
22
============
33

4-
AndroidRate is a library to help you promote your android app by prompting users to rate the app after using it for a few days. Original project [Android-Rate](https://github.com/hotchemi/Android-Rate) (The MIT License (MIT)) was developed by Shintaro Katafuchi.
4+
AndroidRate is a library to help you promote your android app by prompting users to rate the app after using it for a few days. Project based on [Android-Rate](https://github.com/hotchemi/Android-Rate) by Shintaro Katafuchi.
55

66
![screen shot](http://i.gyazo.com/286342ba215a515f2f443a7ce996cc92.gif)
77

@@ -20,6 +20,23 @@ dependencies {
2020

2121
## Usage
2222

23+
### Simple Configuration
24+
25+
```java
26+
@Override
27+
protected void onCreate(Bundle savedInstanceState) {
28+
super.onCreate(savedInstanceState);
29+
setContentView(R.layout.activity_main);
30+
31+
AppRate.with(this)
32+
.setInstallDays((byte) 0) // default 10, 0 means install day
33+
.setLaunchTimes((byte) 3) // default 10
34+
.monitor();
35+
36+
AppRate.showRateDialogIfMeetsConditions(this);
37+
}
38+
```
39+
2340
### Configuration
2441

2542
AndroidRate provides methods to configure its behavior.
@@ -172,7 +189,7 @@ AppRate.with(this).setStoreType(StoreType.BLACKBERRY, long); // BlackBerry World
172189

173190
#### Chinese app stores
174191

175-
The first Chinese app store found on the user device will be used. The Library doesn't check the availability of your application on the app store.
192+
The first Chinese app store found on the user device will be used, if first fails, second will be used, etc. The Library doesn't check the availability of your application on the app store.
176193

177194
```java
178195
AppRate.with(this).setStoreType(StoreType.CHINESESTORES); // 19 chinese app stores: 腾讯应用宝, 360手机助手,
@@ -183,20 +200,20 @@ AppRate.with(this).setStoreType(StoreType.CHINESESTORES); // 19 chinese app stor
183200
#### Other store
184201

185202
```java
186-
AppRate.with(this).setStoreType(String); // Any other store,
187-
// String - an RFC 2396-compliant URI to your app
188-
// e. g. "https://otherstore.com/app?id=com.yourapp"
189-
// or "otherstore://apps/com.yourapp"
203+
AppRate.with(this).setStoreType(String...); // Any other store/stores,
204+
// String... - an RFC 2396-compliant URI or array of URIs to your app,
205+
// e. g. "https://otherstore.com/app?id=com.yourapp"
206+
// or "otherstore://apps/com.yourapp"
190207
```
191208

192-
#### Сustom Intents
209+
### Сustom Intents
193210

194211
You can set custom action to the Rate button. For example, you want to open your custom RateActivity when the Rate button clicked.
195212

196213
```java
197-
AppRate.with(this).setStoreType(Intent[]); // Any custom intents, Intent[] - array of intents,
198-
// first will be executed (startActivity(intents[0])),
199-
// if first fails, second will be executed (startActivity(intents[1])), etc.
214+
AppRate.with(this).setStoreType(Intent...); // Any custom intents, Intent... - intent or array of intents,
215+
// first will be executed (startActivity(intents[0])),
216+
// if first fails, second will be executed (startActivity(intents[1])), etc.
200217
```
201218

202219
### Check the availability of Google Play
@@ -207,6 +224,12 @@ if (GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(this) != C
207224
}
208225
```
209226

227+
### Maximum number of the display of the dialog within a 365-day period
228+
229+
```java
230+
AppRate.with(this).set365DayPeriodMaxNumberDialogLaunchTimes(short);
231+
```
232+
210233
## Language
211234

212235
AndroidRate currently supports the following languages:

library/src/main/java/com/vorlonsoft/android/rate/AppRate.java

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -275,34 +275,18 @@ public AppRate setStoreType(@StoreType.StoreWithApplicationId final int storeTyp
275275
return ((storeType != APPLE) && (storeType != BLACKBERRY)) ? setStoreType(storeType, null, null) : setStoreType(storeType, new String[]{String.valueOf(applicationId)}, null);
276276
}
277277

278-
@SuppressWarnings({"unused", "ConstantConditions"})
279-
public AppRate setStoreType(@NonNull final String uri) {
280-
if (uri == null) {
281-
throw new IllegalArgumentException("setStoreType(String uri): 'uri' must be != null");
282-
}
283-
return setStoreType(new String[]{uri});
284-
}
285-
286278
@SuppressWarnings({"ConstantConditions", "WeakerAccess"})
287-
public AppRate setStoreType(@NonNull final String[] uris) {
279+
public AppRate setStoreType(@NonNull final String... uris) {
288280
if (uris == null) {
289-
throw new IllegalArgumentException("setStoreType(String[] uris): 'uris' must be != null");
281+
throw new IllegalArgumentException("setStoreType(String... uris): 'uris' must be != null");
290282
}
291283
return setStoreType(OTHER, uris, null);
292284
}
293285

294-
@SuppressWarnings({"ConstantConditions", "unused"})
295-
public AppRate setStoreType(@NonNull final Intent intent) {
296-
if (intent == null) {
297-
throw new IllegalArgumentException("setStoreType(Intent intent): 'intent' must be != null");
298-
}
299-
return setStoreType(new Intent[]{intent});
300-
}
301-
302286
@SuppressWarnings({"ConstantConditions", "WeakerAccess"})
303-
public AppRate setStoreType(@NonNull final Intent[] intents) {
287+
public AppRate setStoreType(@NonNull final Intent... intents) {
304288
if (intents == null) {
305-
throw new IllegalArgumentException("setStoreType(Intent[] intents): 'intents' must be != null");
289+
throw new IllegalArgumentException("setStoreType(Intent... intents): 'intents' must be != null");
306290
}
307291
return setStoreType(INTENT, null, intents);
308292
}

library/src/main/java/com/vorlonsoft/android/rate/PreferenceHelper.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,9 @@ static short get365DayPeriodDialogLaunchTimes(final Context context){
129129
}
130130
}
131131
dialogLaunchTimes = dialogLaunchTimes.replaceAll(":[0-9][0-9]*y[0-9][0-9]*-[0-9][0-9]*:",":");
132-
dialogLaunchTimes = dialogLaunchTimes.substring(1, dialogLaunchTimes.length()-1);
132+
if (dialogLaunchTimes.length() > 2) {
133+
dialogLaunchTimes = dialogLaunchTimes.substring(1, dialogLaunchTimes.length() - 1);
134+
}
133135

134136
short dialogLaunchTimesCount = 0;
135137
final String[] dialogLaunchTimesSplit = dialogLaunchTimes.split(":");

sample/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ android {
6060
}
6161
dependencies {
6262
implementation project(':library')
63-
implementation 'com.google.android.gms:play-services-base:15.0.0'
63+
implementation 'com.google.android.gms:play-services-base:15.0.1'
6464
debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.4'
6565
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4'
6666
}

0 commit comments

Comments
 (0)