Skip to content

Commit 4bfa087

Browse files
committed
LIBff10417 Chinese app stores
1 parent ea90aae commit 4bfa087

File tree

6 files changed

+208
-191
lines changed

6 files changed

+208
-191
lines changed

README.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ protected void onCreate(Bundle savedInstanceState) {
3131
setContentView(R.layout.activity_main);
3232

3333
AppRate.with(this)
34-
.setStoreType(StoreType.GOOGLEPLAY) // default GOOGLEPLAY (Google Play), other options are AMAZON (Amazon Appstore), BAZAAR (Cafe Bazaar), MI (Mi Appstore),
35-
// SAMSUNG (Samsung Galaxy Apps), SLIDEME (SlideME), TENCENT (Tencent App Store), YANDEX (Yandex.Store),
34+
.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),
3637
// setStoreType(int) (BlackBerry World, int - your application ID) and
3738
// setStoreType(String) (Any other store, String - a full URI to your app)
3839
.setInstallDays((byte) 0) // default 10, 0 means install day
@@ -135,7 +136,7 @@ If you want to use your own dialog labels, override string xml resources on your
135136

136137
You can use a different Appstores.
137138

138-
#### Google Play, Amazon Appstore, Mi Appstore, Samsung Galaxy Apps, Tencent App Store
139+
#### Google Play, Amazon Appstore, Cafe Bazaar, Mi Appstore, Samsung Galaxy Apps, SlideME, Tencent App Store, Yandex.Store
139140

140141
```java
141142
AppRate.with(this).setStoreType(StoreType.GOOGLEPLAY); // Google Play
@@ -156,6 +157,16 @@ AppRate.with(this).setStoreType(int); // BlackBerry World,
156157
// e. g. 50777 for Facebook
157158
```
158159

160+
#### Chinese app stores
161+
162+
Your application will use 1st of the Chinese app stores that it can find on the user device, but remember that the Library doesn't check the availability of your application in the app store.
163+
164+
```java
165+
AppRate.with(this).setStoreType(StoreType.CHINESESTORES); // 19 chinese app stores: 腾讯应用宝, 360手机助手,
166+
// 小米应用商店, 华为应用商店, 百度手机助手, OPPO应用商店, 中兴应用商店, VIVO应用商店, 豌豆荚, PP手机助手, 安智应用商店,
167+
// 91手机助手, 应用汇, QQ手机管家, 机锋应用市场, GO市场, 宇龙Coolpad应用商店, 联想应用商店, cool市场
168+
```
169+
159170
#### Other store
160171

161172
```java

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

Lines changed: 37 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,6 @@
1616
import android.view.View;
1717

1818
import static com.vorlonsoft.android.rate.AppRate.TAG;
19-
import static com.vorlonsoft.android.rate.IntentHelper.AMAZON_APPSTORE_PACKAGE_NAME;
20-
import static com.vorlonsoft.android.rate.IntentHelper.BLACKBERRY_WORLD_PACKAGE_NAME;
21-
import static com.vorlonsoft.android.rate.IntentHelper.CAFE_BAZAAR_PACKAGE_NAME;
22-
import static com.vorlonsoft.android.rate.IntentHelper.GOOGLE_PLAY_PACKAGE_NAME;
23-
import static com.vorlonsoft.android.rate.IntentHelper.SAMSUNG_GALAXY_APPS_PACKAGE_NAME;
24-
import static com.vorlonsoft.android.rate.IntentHelper.SLIDEME_PACKAGE_NAME;
25-
import static com.vorlonsoft.android.rate.IntentHelper.TENCENT_PACKAGE_NAME;
26-
import static com.vorlonsoft.android.rate.IntentHelper.YANDEX_STORE_PACKAGE_NAME;
2719
import static com.vorlonsoft.android.rate.IntentHelper.createIntentForAmazonAppstore;
2820
import static com.vorlonsoft.android.rate.IntentHelper.createIntentForBlackBerryWorld;
2921
import static com.vorlonsoft.android.rate.IntentHelper.createIntentForCafeBazaar;
@@ -34,17 +26,12 @@
3426
import static com.vorlonsoft.android.rate.IntentHelper.createIntentForSlideME;
3527
import static com.vorlonsoft.android.rate.IntentHelper.createIntentForTencentAppStore;
3628
import static com.vorlonsoft.android.rate.IntentHelper.createIntentForYandexStore;
29+
import static com.vorlonsoft.android.rate.IntentHelper.createIntentsForChineseStores;
3730
import static com.vorlonsoft.android.rate.PreferenceHelper.setAgreeShowDialog;
3831
import static com.vorlonsoft.android.rate.PreferenceHelper.setRemindInterval;
39-
import static com.vorlonsoft.android.rate.UriHelper.getAmazonAppstoreWeb;
40-
import static com.vorlonsoft.android.rate.UriHelper.getBlackBerryWorldWeb;
41-
import static com.vorlonsoft.android.rate.UriHelper.getCafeBazaarWeb;
42-
import static com.vorlonsoft.android.rate.UriHelper.getGooglePlayWeb;
43-
import static com.vorlonsoft.android.rate.UriHelper.getSamsungGalaxyAppsWeb;
44-
import static com.vorlonsoft.android.rate.UriHelper.getSlideMEWeb;
45-
import static com.vorlonsoft.android.rate.UriHelper.getTencentAppStoreWeb;
46-
import static com.vorlonsoft.android.rate.UriHelper.getYandexStoreWeb;
47-
import static com.vorlonsoft.android.rate.UriHelper.isPackageExists;
32+
import static com.vorlonsoft.android.rate.StoreType.CHINESESTORES;
33+
import static com.vorlonsoft.android.rate.StoreType.MI;
34+
import static com.vorlonsoft.android.rate.StoreType.OTHER;
4835
import static com.vorlonsoft.android.rate.Utils.getDialogBuilder;
4936

5037
public class DefaultDialogManager implements DialogManager {
@@ -64,123 +51,72 @@ public DialogManager createDialogManager(Context context, DialogOptions options)
6451
protected final DialogInterface.OnClickListener positiveListener = new DialogInterface.OnClickListener() {
6552
@Override
6653
public void onClick(DialogInterface dialog, int which) {
67-
final Intent intentToAppStore;
54+
final Intent[] intentsToAppStores;
6855
final String packageName = context.getPackageName();
6956
if ((packageName != null) && (packageName.hashCode() != "".hashCode())) {
7057
switch(options.getStoreType()) {
7158
case AMAZON:
72-
intentToAppStore = createIntentForAmazonAppstore(context, packageName);
59+
intentsToAppStores = createIntentForAmazonAppstore(context, packageName);
7360
break;
7461
case BAZAAR:
75-
intentToAppStore = createIntentForCafeBazaar(context, packageName);
62+
intentsToAppStores = createIntentForCafeBazaar(context, packageName);
7663
break;
7764
case BLACKBERRY:
78-
intentToAppStore = createIntentForBlackBerryWorld(context, options.getBlackBerryWorldApplicationId());
65+
intentsToAppStores = createIntentForBlackBerryWorld(context, options.getBlackBerryWorldApplicationId());
66+
break;
67+
case CHINESESTORES:
68+
intentsToAppStores = createIntentsForChineseStores(context, packageName);
7969
break;
8070
case MI:
81-
intentToAppStore = createIntentForMiAppstore(packageName);
71+
intentsToAppStores = createIntentForMiAppstore(packageName);
8272
break;
8373
case OTHER:
84-
intentToAppStore = createIntentForOther(options.getOtherStoreUri());
74+
intentsToAppStores = createIntentForOther(options.getOtherStoreUri());
8575
break;
8676
case SAMSUNG:
87-
intentToAppStore = createIntentForSamsungGalaxyApps(context, packageName);
77+
intentsToAppStores = createIntentForSamsungGalaxyApps(context, packageName);
8878
break;
8979
case SLIDEME:
90-
intentToAppStore = createIntentForSlideME(context, packageName);
80+
intentsToAppStores = createIntentForSlideME(context, packageName);
9181
break;
9282
case TENCENT:
93-
intentToAppStore = createIntentForTencentAppStore(context, packageName);
83+
intentsToAppStores = createIntentForTencentAppStore(context, packageName);
9484
break;
9585
case YANDEX:
96-
intentToAppStore = createIntentForYandexStore(context, packageName);
86+
intentsToAppStores = createIntentForYandexStore(context, packageName);
9787
break;
9888
default:
99-
intentToAppStore = createIntentForGooglePlay(context, packageName);
89+
intentsToAppStores = createIntentForGooglePlay(context, packageName);
10090
}
10191
} else {
10292
Log.w(TAG, "Failed to rate app, can't get context.getPackageName()");
103-
intentToAppStore = null;
93+
intentsToAppStores = null;
10494
}
10595
try {
106-
if (intentToAppStore != null) {
107-
context.startActivity(intentToAppStore);
96+
if (intentsToAppStores != null) {
97+
context.startActivity(intentsToAppStores[0]);
10898
}
10999
} catch (ActivityNotFoundException e) {
110-
Log.w(TAG, "Failed to rate app, no activity found for " + intentToAppStore, e);
111-
switch(options.getStoreType()) {
112-
case AMAZON:
113-
if (isPackageExists(context, AMAZON_APPSTORE_PACKAGE_NAME)) {
114-
try {
115-
context.startActivity(new Intent(Intent.ACTION_VIEW, getAmazonAppstoreWeb(context.getPackageName())));
116-
} catch (ActivityNotFoundException ex) {
117-
Log.w(TAG, "Failed to rate app, no activity found for " + intentToAppStore, ex);
118-
}
119-
}
120-
break;
121-
case BAZAAR:
122-
if (isPackageExists(context, CAFE_BAZAAR_PACKAGE_NAME)) {
100+
Log.w(TAG, "Failed to rate app, no activity found for " + intentsToAppStores[0], e);
101+
if ((options.getStoreType() != OTHER) &&
102+
(options.getStoreType() != MI) &&
103+
(options.getStoreType() != CHINESESTORES) &&
104+
(intentsToAppStores.length > 1)) {
105+
try {
106+
context.startActivity(intentsToAppStores[1]);
107+
} catch (ActivityNotFoundException ex) {
108+
Log.w(TAG, "Failed to rate app, no activity found for " + intentsToAppStores[1], ex);
109+
}
110+
} else if (options.getStoreType() == CHINESESTORES) {
111+
if (intentsToAppStores.length > 1) {
112+
for (byte i = 1; i < intentsToAppStores.length; i++) {
123113
try {
124-
context.startActivity(new Intent(Intent.ACTION_VIEW, getCafeBazaarWeb(context.getPackageName())));
114+
context.startActivity(intentsToAppStores[i]);
125115
} catch (ActivityNotFoundException ex) {
126-
Log.w(TAG, "Failed to rate app, no activity found for " + intentToAppStore, ex);
116+
Log.w(TAG, "Failed to rate app, no activity found for " + intentsToAppStores[i], ex);
127117
}
128118
}
129-
break;
130-
case BLACKBERRY:
131-
if (isPackageExists(context, BLACKBERRY_WORLD_PACKAGE_NAME)) {
132-
try {
133-
context.startActivity(new Intent(Intent.ACTION_VIEW, getBlackBerryWorldWeb(options.getBlackBerryWorldApplicationId())));
134-
} catch (ActivityNotFoundException ex) {
135-
Log.w(TAG, "Failed to rate app, no activity found for " + intentToAppStore, ex);
136-
}
137-
}
138-
break;
139-
case GOOGLEPLAY:
140-
if (isPackageExists(context, GOOGLE_PLAY_PACKAGE_NAME)) {
141-
try {
142-
context.startActivity(new Intent(Intent.ACTION_VIEW, getGooglePlayWeb(context.getPackageName())));
143-
} catch (ActivityNotFoundException ex) {
144-
Log.w(TAG, "Failed to rate app, no activity found for " + intentToAppStore, ex);
145-
}
146-
}
147-
break;
148-
case SAMSUNG:
149-
if (isPackageExists(context, SAMSUNG_GALAXY_APPS_PACKAGE_NAME)) {
150-
try {
151-
context.startActivity(new Intent(Intent.ACTION_VIEW, getSamsungGalaxyAppsWeb(context.getPackageName())));
152-
} catch (ActivityNotFoundException ex) {
153-
Log.w(TAG, "Failed to rate app, no activity found for " + intentToAppStore, ex);
154-
}
155-
}
156-
break;
157-
case SLIDEME:
158-
if (isPackageExists(context, SLIDEME_PACKAGE_NAME)) {
159-
try {
160-
context.startActivity(new Intent(Intent.ACTION_VIEW, getSlideMEWeb(context.getPackageName())));
161-
} catch (ActivityNotFoundException ex) {
162-
Log.w(TAG, "Failed to rate app, no activity found for " + intentToAppStore, ex);
163-
}
164-
}
165-
break;
166-
case TENCENT:
167-
if (isPackageExists(context, TENCENT_PACKAGE_NAME)) {
168-
try {
169-
context.startActivity(new Intent(Intent.ACTION_VIEW, getTencentAppStoreWeb(context.getPackageName())));
170-
} catch (ActivityNotFoundException ex) {
171-
Log.w(TAG, "Failed to rate app, no activity found for " + intentToAppStore, ex);
172-
}
173-
}
174-
break;
175-
case YANDEX:
176-
if (isPackageExists(context, YANDEX_STORE_PACKAGE_NAME)) {
177-
try {
178-
context.startActivity(new Intent(Intent.ACTION_VIEW, getYandexStoreWeb(context.getPackageName())));
179-
} catch (ActivityNotFoundException ex) {
180-
Log.w(TAG, "Failed to rate app, no activity found for " + intentToAppStore, ex);
181-
}
182-
}
183-
break;
119+
}
184120
}
185121
}
186122
setAgreeShowDialog(context, false);

0 commit comments

Comments
 (0)