16
16
import android .view .View ;
17
17
18
18
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 ;
27
19
import static com .vorlonsoft .android .rate .IntentHelper .createIntentForAmazonAppstore ;
28
20
import static com .vorlonsoft .android .rate .IntentHelper .createIntentForBlackBerryWorld ;
29
21
import static com .vorlonsoft .android .rate .IntentHelper .createIntentForCafeBazaar ;
34
26
import static com .vorlonsoft .android .rate .IntentHelper .createIntentForSlideME ;
35
27
import static com .vorlonsoft .android .rate .IntentHelper .createIntentForTencentAppStore ;
36
28
import static com .vorlonsoft .android .rate .IntentHelper .createIntentForYandexStore ;
29
+ import static com .vorlonsoft .android .rate .IntentHelper .createIntentsForChineseStores ;
37
30
import static com .vorlonsoft .android .rate .PreferenceHelper .setAgreeShowDialog ;
38
31
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 ;
48
35
import static com .vorlonsoft .android .rate .Utils .getDialogBuilder ;
49
36
50
37
public class DefaultDialogManager implements DialogManager {
@@ -64,123 +51,72 @@ public DialogManager createDialogManager(Context context, DialogOptions options)
64
51
protected final DialogInterface .OnClickListener positiveListener = new DialogInterface .OnClickListener () {
65
52
@ Override
66
53
public void onClick (DialogInterface dialog , int which ) {
67
- final Intent intentToAppStore ;
54
+ final Intent [] intentsToAppStores ;
68
55
final String packageName = context .getPackageName ();
69
56
if ((packageName != null ) && (packageName .hashCode () != "" .hashCode ())) {
70
57
switch (options .getStoreType ()) {
71
58
case AMAZON :
72
- intentToAppStore = createIntentForAmazonAppstore (context , packageName );
59
+ intentsToAppStores = createIntentForAmazonAppstore (context , packageName );
73
60
break ;
74
61
case BAZAAR :
75
- intentToAppStore = createIntentForCafeBazaar (context , packageName );
62
+ intentsToAppStores = createIntentForCafeBazaar (context , packageName );
76
63
break ;
77
64
case BLACKBERRY :
78
- intentToAppStore = createIntentForBlackBerryWorld (context , options .getBlackBerryWorldApplicationId ());
65
+ intentsToAppStores = createIntentForBlackBerryWorld (context , options .getBlackBerryWorldApplicationId ());
66
+ break ;
67
+ case CHINESESTORES :
68
+ intentsToAppStores = createIntentsForChineseStores (context , packageName );
79
69
break ;
80
70
case MI :
81
- intentToAppStore = createIntentForMiAppstore (packageName );
71
+ intentsToAppStores = createIntentForMiAppstore (packageName );
82
72
break ;
83
73
case OTHER :
84
- intentToAppStore = createIntentForOther (options .getOtherStoreUri ());
74
+ intentsToAppStores = createIntentForOther (options .getOtherStoreUri ());
85
75
break ;
86
76
case SAMSUNG :
87
- intentToAppStore = createIntentForSamsungGalaxyApps (context , packageName );
77
+ intentsToAppStores = createIntentForSamsungGalaxyApps (context , packageName );
88
78
break ;
89
79
case SLIDEME :
90
- intentToAppStore = createIntentForSlideME (context , packageName );
80
+ intentsToAppStores = createIntentForSlideME (context , packageName );
91
81
break ;
92
82
case TENCENT :
93
- intentToAppStore = createIntentForTencentAppStore (context , packageName );
83
+ intentsToAppStores = createIntentForTencentAppStore (context , packageName );
94
84
break ;
95
85
case YANDEX :
96
- intentToAppStore = createIntentForYandexStore (context , packageName );
86
+ intentsToAppStores = createIntentForYandexStore (context , packageName );
97
87
break ;
98
88
default :
99
- intentToAppStore = createIntentForGooglePlay (context , packageName );
89
+ intentsToAppStores = createIntentForGooglePlay (context , packageName );
100
90
}
101
91
} else {
102
92
Log .w (TAG , "Failed to rate app, can't get context.getPackageName()" );
103
- intentToAppStore = null ;
93
+ intentsToAppStores = null ;
104
94
}
105
95
try {
106
- if (intentToAppStore != null ) {
107
- context .startActivity (intentToAppStore );
96
+ if (intentsToAppStores != null ) {
97
+ context .startActivity (intentsToAppStores [ 0 ] );
108
98
}
109
99
} 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 ++ ) {
123
113
try {
124
- context .startActivity (new Intent ( Intent . ACTION_VIEW , getCafeBazaarWeb ( context . getPackageName ())) );
114
+ context .startActivity (intentsToAppStores [ i ] );
125
115
} 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 );
127
117
}
128
118
}
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
+ }
184
120
}
185
121
}
186
122
setAgreeShowDialog (context , false );
0 commit comments