Skip to content

Commit fb799e3

Browse files
committed
LIBff10424
1 parent 28f4cb3 commit fb799e3

18 files changed

Lines changed: 467 additions & 337 deletions

File tree

.idea/compiler.xml

Lines changed: 0 additions & 7 deletions
This file was deleted.

.idea/inspectionProfiles/Project_Default.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/kotlinc.xml

Lines changed: 0 additions & 6 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
- LIBcc10415
1616
- LIBbb10415 Samsung Galaxy Apps uri update
1717
- LIBff10415 Cafe Bazaar
18-
- LIBff20414 SlideME
18+
- LIBff20414 SlideME Marketplace
1919
- LIBff10414 BlackBerry World
2020
- LIBff10413
2121

README.md

Lines changed: 40 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,26 @@ protected void onCreate(Bundle savedInstanceState) {
3232

3333
AppRate.with(this)
3434
.setStoreType(StoreType.GOOGLEPLAY) // default GOOGLEPLAY (Google Play), other options are AMAZON (Amazon Appstore), BAZAAR (Cafe Bazaar),
35-
// CHINESESTORES (19 chinese app stores), MI (Mi Appstore), SAMSUNG (Samsung Galaxy Apps),
36-
// SLIDEME (SlideME), TENCENT (Tencent App Store), YANDEX (Yandex.Store),
37-
// setStoreType(int) (BlackBerry World, int - your application ID),
38-
// setStoreType(String) (Apple App Store, String - a full URI (only http/https)) and
35+
// CHINESESTORES (19 chinese app stores), MI (Mi Appstore (Xiaomi Market)), SAMSUNG (Samsung Galaxy Apps),
36+
// SLIDEME (SlideME Marketplace), TENCENT (Tencent App Store), YANDEX (Yandex.Store),
37+
// setStoreType(BLACKBERRY, long) (BlackBerry World, long - your application ID),
38+
// setStoreType(APPLE, long) (Apple App Store, long - your application ID) and
3939
// setStoreType(String) (Any other store, String - a full URI to your app)
4040
.setInstallDays((byte) 0) // default 10, 0 means install day
4141
.setLaunchTimes((byte) 3) // default 10
4242
.setRemindInterval((byte) 2) // default 1
4343
.setRemindLaunchTimes((byte) 2) // default 1 (each launch)
4444
.setShowLaterButton(true) // default true
4545
.setDebug(false) // default false
46-
//Java 8+: .setOnClickButtonListener(which -> Log.d(MainActivity.class.getName(), Byte.toString(which)))
47-
.setOnClickButtonListener(new OnClickButtonListener() { // callback listener.
48-
@Override
49-
public void onClickButton(byte which) {
50-
Log.d(MainActivity.class.getName(), Byte.toString(which));
51-
}
52-
})
46+
.setOnClickButtonListener(which -> Log.d(MainActivity.class.getName(), Byte.toString(which)))
47+
/* Java 7- start */
48+
//.setOnClickButtonListener(new OnClickButtonListener() { // callback listener.
49+
// @Override
50+
// public void onClickButton(final byte which) {
51+
// Log.d(MainActivity.class.getName(), Byte.toString(which));
52+
// }
53+
//})
54+
/* Java 7- end */
5355
.monitor();
5456

5557
if (AppRate.with(this).getStoreType() == StoreType.GOOGLEPLAY) {
@@ -135,27 +137,37 @@ If you want to use your own dialog labels, override string xml resources on your
135137

136138
### Appstores
137139

138-
You can use a different Appstores.
140+
You can use different app stores.
139141

140-
#### Google Play, Amazon Appstore, Cafe Bazaar, Mi Appstore, Samsung Galaxy Apps, SlideME, Tencent App Store, Yandex.Store
142+
#### Google Play, Amazon Appstore, Cafe Bazaar, Mi Appstore (Xiaomi Market), Samsung Galaxy Apps, SlideME Marketplace, Tencent App Store, Yandex.Store
141143

142144
```java
143145
AppRate.with(this).setStoreType(StoreType.GOOGLEPLAY); // Google Play
144146
AppRate.with(this).setStoreType(StoreType.AMAZON); // Amazon Appstore
145147
AppRate.with(this).setStoreType(StoreType.BAZAAR); // Cafe Bazaar
146-
AppRate.with(this).setStoreType(StoreType.MI); // Mi Appstore
148+
AppRate.with(this).setStoreType(StoreType.MI); // Mi Appstore (Xiaomi Market)
147149
AppRate.with(this).setStoreType(StoreType.SAMSUNG); // Samsung Galaxy Apps
148-
AppRate.with(this).setStoreType(StoreType.SLIDEME); // SlideME
150+
AppRate.with(this).setStoreType(StoreType.SLIDEME); // SlideME Marketplace
149151
AppRate.with(this).setStoreType(StoreType.TENCENT); // Tencent App Store
150152
AppRate.with(this).setStoreType(StoreType.YANDEX); // Yandex.Store
151153
```
152154

155+
#### Apple App Store
156+
157+
```java
158+
AppRate.with(this).setStoreType(StoreType.APPLE, long); // Apple App Store,
159+
// long - your Apple App Store application ID
160+
// e. g. 284882215 for Facebook
161+
// (https://itunes.apple.com/app/id284882215)
162+
```
163+
153164
#### BlackBerry World
154165

155166
```java
156-
AppRate.with(this).setStoreType(int); // BlackBerry World,
157-
// int - your BlackBerry World application ID
158-
// e. g. 50777 for Facebook
167+
AppRate.with(this).setStoreType(StoreType.BLACKBERRY, long); // BlackBerry World,
168+
// long - your BlackBerry World application ID
169+
// e. g. 50777 for Facebook
170+
// (https://appworld.blackberry.com/webstore/content/50777)
159171
```
160172

161173
#### Chinese app stores
@@ -168,14 +180,6 @@ AppRate.with(this).setStoreType(StoreType.CHINESESTORES); // 19 chinese app stor
168180
// 91手机助手, 应用汇, QQ手机管家, 机锋应用市场, GO市场, 宇龙Coolpad应用商店, 联想应用商店, cool市场
169181
```
170182

171-
#### Apple App Store
172-
173-
```java
174-
AppRate.with(this).setStoreType(String); // Apple App Store,
175-
// String - an RFC 2396-compliant URI (only http/https) to your app
176-
// e. g. "https://itunes.apple.com/app/facebook/id284882215" for Facebook
177-
```
178-
179183
#### Other store
180184

181185
```java
@@ -185,6 +189,16 @@ AppRate.with(this).setStoreType(String); // Any other store,
185189
// or "otherstore://apps/com.yourapp"
186190
```
187191

192+
#### Сustom Intents
193+
194+
You can set custom action to the Rate button. For example, you want to open your custom RateActivity when the Rate button clicked.
195+
196+
```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.
200+
```
201+
188202
### Check the availability of Google Play
189203

190204
```java

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ buildscript {
1010
jcenter()
1111
}
1212
dependencies {
13-
classpath 'com.android.tools.build:gradle:3.2.0-alpha11'
13+
classpath 'com.android.tools.build:gradle:3.2.0-alpha12'
1414
}
1515
}
1616

library/build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,7 @@ android {
4343
}
4444
}
4545
}
46-
46+
dependencies {
47+
api 'com.android.support:support-annotations:27.1.1'
48+
}
4749
apply from: 'https://raw.github.com/chrisbanes/gradle-mvn-push/master/gradle-mvn-push.gradle'

library/src/androidTest/java/com/vorlonsoft/android/rate/UriHelperTest.java

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
import android.net.Uri;
1010
import android.test.AndroidTestCase;
1111

12+
import static com.vorlonsoft.android.rate.StoreType.CHINESESTORES;
13+
import static com.vorlonsoft.android.rate.StoreType.GOOGLEPLAY;
14+
1215
/**
1316
* Unit test for {@link com.vorlonsoft.android.rate.UriHelper}
1417
*/
@@ -23,59 +26,59 @@ public class UriHelperTest extends AndroidTestCase {
2326
@SuppressWarnings("ConstantConditions")
2427
public void testGetStoreUri() {
2528
{
26-
Uri uri = UriHelper.getStoreUri(StoreType.CHINESESTORES,"");
29+
Uri uri = UriHelper.getStoreUri(CHINESESTORES,"");
2730
assertEquals(uri.toString(), CHINESE_STORES);
2831
}
2932
{
30-
Uri uri = UriHelper.getStoreUri(StoreType.GOOGLEPLAY,"");
33+
Uri uri = UriHelper.getStoreUri(GOOGLEPLAY,"");
3134
assertEquals(uri.toString(), GOOGLE_PLAY);
3235
}
3336
{
34-
Uri uri = UriHelper.getStoreUri(StoreType.CHINESESTORES,null);
37+
Uri uri = UriHelper.getStoreUri(CHINESESTORES,null);
3538
assertNull(uri);
3639
}
3740
{
38-
Uri uri = UriHelper.getStoreUri(StoreType.GOOGLEPLAY,null);
41+
Uri uri = UriHelper.getStoreUri(GOOGLEPLAY,null);
3942
assertNull(uri);
4043
}
4144
{
4245
final String paramName = "com.vorlonsoft.android.rate";
43-
Uri uri = UriHelper.getStoreUri(StoreType.CHINESESTORES, paramName);
46+
Uri uri = UriHelper.getStoreUri(CHINESESTORES, paramName);
4447
assertEquals(uri.toString(), CHINESE_STORES + paramName);
4548
}
4649
{
4750
final String paramName = "com.vorlonsoft.android.rate";
48-
Uri uri = UriHelper.getStoreUri(StoreType.GOOGLEPLAY, paramName);
51+
Uri uri = UriHelper.getStoreUri(GOOGLEPLAY, paramName);
4952
assertEquals(uri.toString(), GOOGLE_PLAY + paramName);
5053
}
5154
}
5255

5356
@SuppressWarnings("ConstantConditions")
5457
public void testGetStoreWebUri() {
5558
{
56-
Uri uri = UriHelper.getStoreWebUri(StoreType.CHINESESTORES,"");
59+
Uri uri = UriHelper.getStoreWebUri(CHINESESTORES,"");
5760
assertNull(uri);
5861
}
5962
{
60-
Uri uri = UriHelper.getStoreWebUri(StoreType.GOOGLEPLAY,"");
63+
Uri uri = UriHelper.getStoreWebUri(GOOGLEPLAY,"");
6164
assertEquals(uri.toString(), GOOGLE_PLAY_WEB);
6265
}
6366
{
64-
Uri uri = UriHelper.getStoreWebUri(StoreType.CHINESESTORES,null);
67+
Uri uri = UriHelper.getStoreWebUri(CHINESESTORES,null);
6568
assertNull(uri);
6669
}
6770
{
68-
Uri uri = UriHelper.getStoreWebUri(StoreType.GOOGLEPLAY,null);
71+
Uri uri = UriHelper.getStoreWebUri(GOOGLEPLAY,null);
6972
assertNull(uri);
7073
}
7174
{
7275
final String paramName = "com.vorlonsoft.android.rate";
73-
Uri uri = UriHelper.getStoreWebUri(StoreType.CHINESESTORES, paramName);
76+
Uri uri = UriHelper.getStoreWebUri(CHINESESTORES, paramName);
7477
assertNull(uri);
7578
}
7679
{
7780
final String paramName = "com.vorlonsoft.android.rate";
78-
Uri uri = UriHelper.getStoreWebUri(StoreType.GOOGLEPLAY, paramName);
81+
Uri uri = UriHelper.getStoreWebUri(GOOGLEPLAY, paramName);
7982
assertEquals(uri.toString(), GOOGLE_PLAY_WEB + paramName);
8083
}
8184
}

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

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,24 @@
88

99
import android.annotation.SuppressLint;
1010
import android.app.Activity;
11+
import android.app.Dialog;
1112
import android.content.Context;
13+
import android.content.Intent;
14+
import android.support.annotation.NonNull;
15+
import android.util.Log;
1216
import android.view.View;
1317

1418
import java.util.Date;
1519
import java.util.HashMap;
1620
import java.util.Map;
1721

1822
import static com.vorlonsoft.android.rate.PreferenceHelper.*;
23+
import static com.vorlonsoft.android.rate.StoreType.AMAZON;
24+
import static com.vorlonsoft.android.rate.StoreType.APPLE;
25+
import static com.vorlonsoft.android.rate.StoreType.BLACKBERRY;
26+
import static com.vorlonsoft.android.rate.StoreType.INTENT;
27+
import static com.vorlonsoft.android.rate.StoreType.OTHER;
28+
import static com.vorlonsoft.android.rate.StoreType.YANDEX;
1929

2030
public final class AppRate {
2131

@@ -204,32 +214,46 @@ public AppRate setCancelable(@SuppressWarnings("SameParameterValue") boolean can
204214
return this;
205215
}
206216

207-
public AppRate setStoreType(@SuppressWarnings("SameParameterValue") StoreType appStore) {
208-
return setStoreType(appStore, null);
217+
public AppRate setStoreType(@StoreType.Store final int storeType) {
218+
if ((storeType == APPLE) || (storeType == BLACKBERRY)) {
219+
throw new IllegalArgumentException("For StoreType.APPLE/StoreType.BLACKBERRY you must use setStoreType(StoreType.APPLE/StoreType.BLACKBERRY, long applicationId)");
220+
} else if ((storeType < AMAZON) || (storeType > YANDEX)) {
221+
throw new IllegalArgumentException("StoreType must be one of: AMAZON, APPLE, BAZAAR, BLACKBERRY, CHINESESTORES, GOOGLEPLAY, MI, SAMSUNG, SLIDEME, TENCENT, YANDEX");
222+
}
223+
return setStoreType((byte) storeType, null, null);
209224
}
210225

211226
@SuppressWarnings("unused")
212-
public AppRate setStoreType(int applicationID) {
213-
return setStoreType(StoreType.BLACKBERRY, String.valueOf(applicationID));
227+
public AppRate setStoreType(@StoreType.StoreWithId final int storeType, final long applicationId) {
228+
if ((storeType < AMAZON) || (storeType > YANDEX)) {
229+
throw new IllegalArgumentException("StoreType must be one of: AMAZON, APPLE, BAZAAR, BLACKBERRY, CHINESESTORES, GOOGLEPLAY, MI, SAMSUNG, SLIDEME, TENCENT, YANDEX");
230+
}
231+
return ((storeType != APPLE) && (storeType != BLACKBERRY)) ? setStoreType((byte) storeType, null, null) : setStoreType((byte) storeType, String.valueOf(applicationId), null);
214232
}
215233

216-
@SuppressWarnings("unused")
217-
public AppRate setStoreType(String uri) {
218-
return setStoreType(StoreType.OTHER, uri);
234+
@SuppressWarnings("unused ConstantConditions")
235+
public AppRate setStoreType(@NonNull final String uri) {
236+
if (uri == null) {
237+
throw new IllegalArgumentException("setStoreType(String uri): 'uri' must be != null");
238+
}
239+
return setStoreType(OTHER, uri, null);
219240
}
220241

221-
@SuppressWarnings("WeakerAccess")
222-
public AppRate setStoreType(StoreType appStore, String param) {
223-
if ((appStore == StoreType.BLACKBERRY)&&(param == null)) {
224-
throw new IllegalArgumentException("For StoreType.BLACKBERRY you must use setStoreType(int applicationID)");
225-
} else if ((appStore == StoreType.OTHER)&&(param == null)) {
226-
throw new IllegalArgumentException("For StoreType.OTHER you must use setStoreType(String uri) and 'uri' must be != null");
242+
@SuppressWarnings({"ConstantConditions", "unused"})
243+
public AppRate setStoreType(@NonNull final Intent[] intents) {
244+
if (intents == null) {
245+
throw new IllegalArgumentException("setStoreType(Intent[] intents): 'intents' must be != null");
227246
}
228-
options.setStoreType(appStore, param);
247+
return setStoreType(INTENT, null, intents);
248+
}
249+
250+
private AppRate setStoreType(final byte storeType, final String stringParam, final Intent[] intentParaam) {
251+
options.setStoreType(storeType, stringParam, intentParaam);
229252
return this;
230253
}
231254

232-
public StoreType getStoreType() {
255+
@StoreType.Return
256+
public int getStoreType() {
233257
return options.getStoreType();
234258
}
235259

@@ -266,7 +290,12 @@ public void monitor() {
266290
@SuppressWarnings("WeakerAccess")
267291
public void showRateDialog(Activity activity) {
268292
if (!activity.isFinishing()) {
269-
dialogManagerFactory.createDialogManager(activity, options).createDialog().show();
293+
Dialog dialog = dialogManagerFactory.createDialogManager(activity, options).createDialog();
294+
if (dialog != null) {
295+
dialog.show();
296+
} else {
297+
Log.w(TAG, "Failed to rate app, can't create rate dialog");
298+
}
270299
}
271300
}
272301

0 commit comments

Comments
 (0)