SnapchatManager.java
8.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
package com.bitstrips.imoji.manager;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.support.annotation.VisibleForTesting;
import android.text.TextUtils;
import android.util.Log;
import com.bitstrips.imoji.api.BitmojiApi;
import com.bitstrips.imoji.experiments.Experiments;
import com.bitstrips.imoji.identity.AvatarManager;
import com.bitstrips.imoji.identity.AvatarManager.UpdateAvatarInfoCallback;
import com.bitstrips.imoji.injection.ForApplication;
import com.bitstrips.imoji.models.SCUser;
import com.bitstrips.imoji.monouser.oauth2.OAuth2Manager;
import com.bitstrips.imoji.ui.BitmojiBaseActivity;
import com.bitstrips.imoji.ui.IntentCreatorService;
import com.bitstrips.imoji.util.PreferenceUtils;
import java.lang.ref.WeakReference;
import java.util.List;
import javax.inject.Inject;
import retrofit.Callback;
import retrofit.RetrofitError;
public class SnapchatManager
{
private Intent a = null;
private String b = "snapchat://";
private final AvatarManager c;
private final BitmojiApi d;
private final PreferenceUtils e;
private final IntentCreatorService f;
private final Context g;
private final OAuth2Manager h;
private final Experiments i;
@Inject
public SnapchatManager(AvatarManager paramAvatarManager, BitmojiApi paramBitmojiApi, PreferenceUtils paramPreferenceUtils, IntentCreatorService paramIntentCreatorService, @ForApplication Context paramContext, OAuth2Manager paramOAuth2Manager, Experiments paramExperiments)
{
this.c = paramAvatarManager;
this.d = paramBitmojiApi;
this.e = paramPreferenceUtils;
this.f = paramIntentCreatorService;
this.g = paramContext;
this.h = paramOAuth2Manager;
this.i = paramExperiments;
}
private Uri a(String paramString)
{
if (("debug".equalsIgnoreCase("release")) && (!this.b.equals("snapchat://")) && (!hasActivityToHandleUri(this.b))) {
this.b = "snapchat://";
}
return Uri.parse(this.b + paramString);
}
private String a(Intent paramIntent)
{
if (paramIntent == null) {
return null;
}
String str;
int j;
if (paramIntent != null)
{
str = paramIntent.getStringExtra("build_type");
if (str != null)
{
j = -1;
switch (str.hashCode())
{
default:
switch (j)
{
default:
label60:
this.b = "snapchat://";
}
break;
}
}
}
for (;;)
{
paramIntent = paramIntent.getStringExtra("snapchat_action");
if (TextUtils.isEmpty(paramIntent)) {
break;
}
return paramIntent;
if (!str.equals("alpha")) {
break label60;
}
j = 0;
break label60;
if (!str.equals("debug")) {
break label60;
}
j = 1;
break label60;
if (!str.equals("master")) {
break label60;
}
j = 2;
break label60;
this.b = "snapchatalpha://";
continue;
this.b = "snapchatdebug://";
continue;
this.b = "snapchatmaster://";
}
}
private static void a(Uri paramUri, Context paramContext)
{
try
{
Intent localIntent = new Intent("android.intent.action.VIEW");
localIntent.addFlags(268435456);
localIntent.setData(paramUri);
paramContext.startActivity(localIntent);
return;
}
catch (Exception paramUri) {}
}
private void a(OnSnapchatResponseListener paramOnSnapchatResponseListener, Intent paramIntent, int paramInt)
{
if (paramIntent == null) {
return;
}
paramIntent = paramIntent.getStringExtra("bitmask_request_token");
if (paramIntent == null)
{
paramOnSnapchatResponseListener.onSnapchatResponseError();
return;
}
handleSnapchatActionLogin(paramOnSnapchatResponseListener, paramIntent, paramInt);
}
public Intent getCurrentLinkingIntent()
{
return this.a;
}
public String getSnapchatRequestTokenForLinkage(Intent paramIntent)
{
if (paramIntent == null) {}
String str;
do
{
return null;
str = paramIntent.getStringExtra("snapchat_action");
} while ((TextUtils.isEmpty(str)) || (!str.equals("auth")));
return paramIntent.getStringExtra("bitmask_request_token");
}
public String getSnapchatRequestTokenForLogin(Intent paramIntent)
{
if (paramIntent == null) {}
String str;
do
{
return null;
str = paramIntent.getStringExtra("snapchat_action");
} while ((TextUtils.isEmpty(str)) || ((!str.equals("create")) && (!str.equals("login"))));
return paramIntent.getStringExtra("bitmask_request_token");
}
public void goBackToSnapchat(Context paramContext)
{
a(a(""), paramContext);
}
public void goBackToSnapchatWithAvatarChange(Context paramContext)
{
a(a("bitmoji/avatar_change"), paramContext);
}
public void goToPlayStoreSnapchat()
{
try
{
Intent localIntent = new Intent("android.intent.action.VIEW");
localIntent.addFlags(268435456);
localIntent.setData(Uri.parse("market://details?id=com.snapchat.android"));
this.g.startActivity(localIntent);
return;
}
catch (Exception localException)
{
localException.printStackTrace();
}
}
public void goToSnapchatOrPlayStore(BitmojiBaseActivity paramBitmojiBaseActivity)
{
if (hasActivityToHandleUri(this.b))
{
sendIntentForRequestToken(paramBitmojiBaseActivity);
return;
}
paramBitmojiBaseActivity.showAlertDialog(this.g.getString(2131230959), this.g.getString(2131230958), new Runnable()new Runnable
{
public final void run()
{
SnapchatManager.this.goToPlayStoreSnapchat();
}
}, new Runnable()
{
public final void run() {}
});
}
public void goToSnapchatWithSuccess(Context paramContext)
{
this.a = null;
a(a("bitmoji/auth_success"), paramContext);
}
public void handleSnapchatActionLogin(OnSnapchatResponseListener paramOnSnapchatResponseListener, String paramString)
{
handleSnapchatActionLogin(paramOnSnapchatResponseListener, paramString, 0);
}
public void handleSnapchatActionLogin(final OnSnapchatResponseListener paramOnSnapchatResponseListener, String paramString, final int paramInt)
{
final WeakReference localWeakReference = new WeakReference(paramOnSnapchatResponseListener);
this.d.loginToSnapchat(paramString, new Callback()
{
public final void failure(RetrofitError paramAnonymousRetrofitError)
{
paramAnonymousRetrofitError = (SnapchatManager.OnSnapchatResponseListener)localWeakReference.get();
if (paramAnonymousRetrofitError != null) {
paramAnonymousRetrofitError.onSnapchatResponseError();
}
}
});
}
@VisibleForTesting
public boolean hasActivityToHandleUri(String paramString)
{
Intent localIntent = new Intent("android.intent.action.VIEW");
localIntent.setData(Uri.parse(paramString));
paramString = this.g.getPackageManager();
if (paramString == null) {}
while (paramString.queryIntentActivities(localIntent, 0).size() <= 0) {
return false;
}
return true;
}
public boolean isSnapchatChangeOutfit(Intent paramIntent)
{
paramIntent = a(paramIntent);
if (paramIntent == null) {
return false;
}
return paramIntent.equals("change_outfit");
}
public boolean isSnapchatCreating(Intent paramIntent)
{
paramIntent = a(paramIntent);
if (paramIntent == null) {
return false;
}
return paramIntent.equals("create");
}
public boolean isSnapchatEditAvatar(Intent paramIntent)
{
paramIntent = a(paramIntent);
if (paramIntent == null) {
return false;
}
return paramIntent.equals("edit");
}
public boolean isSnapchatLinking(Intent paramIntent)
{
paramIntent = a(paramIntent);
if (paramIntent == null) {
return false;
}
return paramIntent.equals("auth");
}
public void logInWithRequestTokenAndOpenAvatarBuilder(OnSnapchatResponseListener paramOnSnapchatResponseListener, Intent paramIntent)
{
a(paramOnSnapchatResponseListener, paramIntent, 1);
}
public void logInWithRequestTokenAndOpenOutfitBuilder(OnSnapchatResponseListener paramOnSnapchatResponseListener, Intent paramIntent)
{
a(paramOnSnapchatResponseListener, paramIntent, 2);
}
public void saveCurrentIntentData(Intent paramIntent)
{
if (isSnapchatLinking(paramIntent)) {
this.a = paramIntent;
}
}
public void sendIntentForRequestToken(Context paramContext)
{
a(a("bitmoji/auth"), paramContext);
((Activity)paramContext).finish();
}
public static abstract interface OnSnapchatResponseListener
{
public abstract void onSnapchatResponseError();
public abstract void onSnapchatResponseSuccess();
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/com/bitstrips/imoji/manager/SnapchatManager.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/