ShareCompat.java
17.3 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
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
package android.support.v4.app;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build.VERSION;
import android.os.Parcelable;
import android.support.annotation.StringRes;
import android.text.Html;
import android.text.Spanned;
import android.util.Log;
import android.view.ActionProvider;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ShareActionProvider;
import java.util.ArrayList;
public final class ShareCompat
{
public static final String EXTRA_CALLING_ACTIVITY = "android.support.v4.app.EXTRA_CALLING_ACTIVITY";
public static final String EXTRA_CALLING_PACKAGE = "android.support.v4.app.EXTRA_CALLING_PACKAGE";
static a a = new b();
static
{
if (Build.VERSION.SDK_INT >= 16)
{
a = new d();
return;
}
if (Build.VERSION.SDK_INT >= 14)
{
a = new c();
return;
}
}
public static void configureMenuItem(Menu paramMenu, int paramInt, IntentBuilder paramIntentBuilder)
{
paramMenu = paramMenu.findItem(paramInt);
if (paramMenu == null) {
throw new IllegalArgumentException("Could not find menu item with id " + paramInt + " in the supplied menu");
}
configureMenuItem(paramMenu, paramIntentBuilder);
}
public static void configureMenuItem(MenuItem paramMenuItem, IntentBuilder paramIntentBuilder)
{
a.a(paramMenuItem, paramIntentBuilder);
}
public static ComponentName getCallingActivity(Activity paramActivity)
{
ComponentName localComponentName2 = paramActivity.getCallingActivity();
ComponentName localComponentName1 = localComponentName2;
if (localComponentName2 == null) {
localComponentName1 = (ComponentName)paramActivity.getIntent().getParcelableExtra("android.support.v4.app.EXTRA_CALLING_ACTIVITY");
}
return localComponentName1;
}
public static String getCallingPackage(Activity paramActivity)
{
String str2 = paramActivity.getCallingPackage();
String str1 = str2;
if (str2 == null) {
str1 = paramActivity.getIntent().getStringExtra("android.support.v4.app.EXTRA_CALLING_PACKAGE");
}
return str1;
}
public static class IntentBuilder
{
Activity a;
private Intent b;
private CharSequence c;
private ArrayList<String> d;
private ArrayList<String> e;
private ArrayList<String> f;
private ArrayList<Uri> g;
private IntentBuilder(Activity paramActivity)
{
this.a = paramActivity;
this.b = new Intent().setAction("android.intent.action.SEND");
this.b.putExtra("android.support.v4.app.EXTRA_CALLING_PACKAGE", paramActivity.getPackageName());
this.b.putExtra("android.support.v4.app.EXTRA_CALLING_ACTIVITY", paramActivity.getComponentName());
this.b.addFlags(524288);
}
private void a(String paramString, ArrayList<String> paramArrayList)
{
String[] arrayOfString1 = this.b.getStringArrayExtra(paramString);
if (arrayOfString1 != null) {}
for (int i = arrayOfString1.length;; i = 0)
{
String[] arrayOfString2 = new String[paramArrayList.size() + i];
paramArrayList.toArray(arrayOfString2);
if (arrayOfString1 != null) {
System.arraycopy(arrayOfString1, 0, arrayOfString2, paramArrayList.size(), i);
}
this.b.putExtra(paramString, arrayOfString2);
return;
}
}
private void a(String paramString, String[] paramArrayOfString)
{
Intent localIntent = getIntent();
String[] arrayOfString1 = localIntent.getStringArrayExtra(paramString);
if (arrayOfString1 != null) {}
for (int i = arrayOfString1.length;; i = 0)
{
String[] arrayOfString2 = new String[paramArrayOfString.length + i];
if (arrayOfString1 != null) {
System.arraycopy(arrayOfString1, 0, arrayOfString2, 0, i);
}
System.arraycopy(paramArrayOfString, 0, arrayOfString2, i, paramArrayOfString.length);
localIntent.putExtra(paramString, arrayOfString2);
return;
}
}
public static IntentBuilder from(Activity paramActivity)
{
return new IntentBuilder(paramActivity);
}
public IntentBuilder addEmailBcc(String paramString)
{
if (this.f == null) {
this.f = new ArrayList();
}
this.f.add(paramString);
return this;
}
public IntentBuilder addEmailBcc(String[] paramArrayOfString)
{
a("android.intent.extra.BCC", paramArrayOfString);
return this;
}
public IntentBuilder addEmailCc(String paramString)
{
if (this.e == null) {
this.e = new ArrayList();
}
this.e.add(paramString);
return this;
}
public IntentBuilder addEmailCc(String[] paramArrayOfString)
{
a("android.intent.extra.CC", paramArrayOfString);
return this;
}
public IntentBuilder addEmailTo(String paramString)
{
if (this.d == null) {
this.d = new ArrayList();
}
this.d.add(paramString);
return this;
}
public IntentBuilder addEmailTo(String[] paramArrayOfString)
{
a("android.intent.extra.EMAIL", paramArrayOfString);
return this;
}
public IntentBuilder addStream(Uri paramUri)
{
Uri localUri = (Uri)this.b.getParcelableExtra("android.intent.extra.STREAM");
if ((this.g == null) && (localUri == null)) {
return setStream(paramUri);
}
if (this.g == null) {
this.g = new ArrayList();
}
if (localUri != null)
{
this.b.removeExtra("android.intent.extra.STREAM");
this.g.add(localUri);
}
this.g.add(paramUri);
return this;
}
public Intent createChooserIntent()
{
return Intent.createChooser(getIntent(), this.c);
}
public Intent getIntent()
{
if (this.d != null)
{
a("android.intent.extra.EMAIL", this.d);
this.d = null;
}
if (this.e != null)
{
a("android.intent.extra.CC", this.e);
this.e = null;
}
if (this.f != null)
{
a("android.intent.extra.BCC", this.f);
this.f = null;
}
int i;
if ((this.g != null) && (this.g.size() > 1))
{
i = 1;
boolean bool = this.b.getAction().equals("android.intent.action.SEND_MULTIPLE");
if ((i == 0) && (bool))
{
this.b.setAction("android.intent.action.SEND");
if ((this.g == null) || (this.g.isEmpty())) {
break label219;
}
this.b.putExtra("android.intent.extra.STREAM", (Parcelable)this.g.get(0));
label155:
this.g = null;
}
if ((i != 0) && (!bool))
{
this.b.setAction("android.intent.action.SEND_MULTIPLE");
if ((this.g == null) || (this.g.isEmpty())) {
break label231;
}
this.b.putParcelableArrayListExtra("android.intent.extra.STREAM", this.g);
}
}
for (;;)
{
return this.b;
i = 0;
break;
label219:
this.b.removeExtra("android.intent.extra.STREAM");
break label155;
label231:
this.b.removeExtra("android.intent.extra.STREAM");
}
}
public IntentBuilder setChooserTitle(@StringRes int paramInt)
{
return setChooserTitle(this.a.getText(paramInt));
}
public IntentBuilder setChooserTitle(CharSequence paramCharSequence)
{
this.c = paramCharSequence;
return this;
}
public IntentBuilder setEmailBcc(String[] paramArrayOfString)
{
this.b.putExtra("android.intent.extra.BCC", paramArrayOfString);
return this;
}
public IntentBuilder setEmailCc(String[] paramArrayOfString)
{
this.b.putExtra("android.intent.extra.CC", paramArrayOfString);
return this;
}
public IntentBuilder setEmailTo(String[] paramArrayOfString)
{
if (this.d != null) {
this.d = null;
}
this.b.putExtra("android.intent.extra.EMAIL", paramArrayOfString);
return this;
}
public IntentBuilder setHtmlText(String paramString)
{
this.b.putExtra("android.intent.extra.HTML_TEXT", paramString);
if (!this.b.hasExtra("android.intent.extra.TEXT")) {
setText(Html.fromHtml(paramString));
}
return this;
}
public IntentBuilder setStream(Uri paramUri)
{
if (!this.b.getAction().equals("android.intent.action.SEND")) {
this.b.setAction("android.intent.action.SEND");
}
this.g = null;
this.b.putExtra("android.intent.extra.STREAM", paramUri);
return this;
}
public IntentBuilder setSubject(String paramString)
{
this.b.putExtra("android.intent.extra.SUBJECT", paramString);
return this;
}
public IntentBuilder setText(CharSequence paramCharSequence)
{
this.b.putExtra("android.intent.extra.TEXT", paramCharSequence);
return this;
}
public IntentBuilder setType(String paramString)
{
this.b.setType(paramString);
return this;
}
public void startChooser()
{
this.a.startActivity(createChooserIntent());
}
}
public static class IntentReader
{
private Activity a;
private Intent b;
private String c;
private ComponentName d;
private ArrayList<Uri> e;
private IntentReader(Activity paramActivity)
{
this.a = paramActivity;
this.b = paramActivity.getIntent();
this.c = ShareCompat.getCallingPackage(paramActivity);
this.d = ShareCompat.getCallingActivity(paramActivity);
}
public static IntentReader from(Activity paramActivity)
{
return new IntentReader(paramActivity);
}
public ComponentName getCallingActivity()
{
return this.d;
}
public Drawable getCallingActivityIcon()
{
if (this.d == null) {
return null;
}
Object localObject = this.a.getPackageManager();
try
{
localObject = ((PackageManager)localObject).getActivityIcon(this.d);
return (Drawable)localObject;
}
catch (PackageManager.NameNotFoundException localNameNotFoundException)
{
Log.e("IntentReader", "Could not retrieve icon for calling activity", localNameNotFoundException);
}
return null;
}
public Drawable getCallingApplicationIcon()
{
if (this.c == null) {
return null;
}
Object localObject = this.a.getPackageManager();
try
{
localObject = ((PackageManager)localObject).getApplicationIcon(this.c);
return (Drawable)localObject;
}
catch (PackageManager.NameNotFoundException localNameNotFoundException)
{
Log.e("IntentReader", "Could not retrieve icon for calling application", localNameNotFoundException);
}
return null;
}
public CharSequence getCallingApplicationLabel()
{
if (this.c == null) {
return null;
}
Object localObject = this.a.getPackageManager();
try
{
localObject = ((PackageManager)localObject).getApplicationLabel(((PackageManager)localObject).getApplicationInfo(this.c, 0));
return (CharSequence)localObject;
}
catch (PackageManager.NameNotFoundException localNameNotFoundException)
{
Log.e("IntentReader", "Could not retrieve label for calling application", localNameNotFoundException);
}
return null;
}
public String getCallingPackage()
{
return this.c;
}
public String[] getEmailBcc()
{
return this.b.getStringArrayExtra("android.intent.extra.BCC");
}
public String[] getEmailCc()
{
return this.b.getStringArrayExtra("android.intent.extra.CC");
}
public String[] getEmailTo()
{
return this.b.getStringArrayExtra("android.intent.extra.EMAIL");
}
public String getHtmlText()
{
String str = this.b.getStringExtra("android.intent.extra.HTML_TEXT");
if (str == null)
{
CharSequence localCharSequence = getText();
if ((localCharSequence instanceof Spanned)) {
return Html.toHtml((Spanned)localCharSequence);
}
if (localCharSequence != null) {
return ShareCompat.a.a(localCharSequence);
}
}
return str;
}
public Uri getStream()
{
return (Uri)this.b.getParcelableExtra("android.intent.extra.STREAM");
}
public Uri getStream(int paramInt)
{
if ((this.e == null) && (isMultipleShare())) {
this.e = this.b.getParcelableArrayListExtra("android.intent.extra.STREAM");
}
if (this.e != null) {
return (Uri)this.e.get(paramInt);
}
if (paramInt == 0) {
return (Uri)this.b.getParcelableExtra("android.intent.extra.STREAM");
}
throw new IndexOutOfBoundsException("Stream items available: " + getStreamCount() + " index requested: " + paramInt);
}
public int getStreamCount()
{
if ((this.e == null) && (isMultipleShare())) {
this.e = this.b.getParcelableArrayListExtra("android.intent.extra.STREAM");
}
if (this.e != null) {
return this.e.size();
}
if (this.b.hasExtra("android.intent.extra.STREAM")) {
return 1;
}
return 0;
}
public String getSubject()
{
return this.b.getStringExtra("android.intent.extra.SUBJECT");
}
public CharSequence getText()
{
return this.b.getCharSequenceExtra("android.intent.extra.TEXT");
}
public String getType()
{
return this.b.getType();
}
public boolean isMultipleShare()
{
return "android.intent.action.SEND_MULTIPLE".equals(this.b.getAction());
}
public boolean isShareIntent()
{
String str = this.b.getAction();
return ("android.intent.action.SEND".equals(str)) || ("android.intent.action.SEND_MULTIPLE".equals(str));
}
public boolean isSingleShare()
{
return "android.intent.action.SEND".equals(this.b.getAction());
}
}
static abstract interface a
{
public abstract String a(CharSequence paramCharSequence);
public abstract void a(MenuItem paramMenuItem, ShareCompat.IntentBuilder paramIntentBuilder);
}
static class b
implements ShareCompat.a
{
private static void a(StringBuilder paramStringBuilder, CharSequence paramCharSequence, int paramInt)
{
int i = 0;
if (i < paramInt)
{
char c = paramCharSequence.charAt(i);
if (c == '<') {
paramStringBuilder.append("<");
}
for (;;)
{
i += 1;
break;
if (c == '>')
{
paramStringBuilder.append(">");
}
else if (c == '&')
{
paramStringBuilder.append("&");
}
else if ((c > '~') || (c < ' '))
{
paramStringBuilder.append("&#" + c + ";");
}
else if (c == ' ')
{
while ((i + 1 < paramInt) && (paramCharSequence.charAt(i + 1) == ' '))
{
paramStringBuilder.append(" ");
i += 1;
}
paramStringBuilder.append(' ');
}
else
{
paramStringBuilder.append(c);
}
}
}
}
public String a(CharSequence paramCharSequence)
{
StringBuilder localStringBuilder = new StringBuilder();
a(localStringBuilder, paramCharSequence, paramCharSequence.length());
return localStringBuilder.toString();
}
public void a(MenuItem paramMenuItem, ShareCompat.IntentBuilder paramIntentBuilder)
{
paramMenuItem.setIntent(paramIntentBuilder.createChooserIntent());
}
}
static class c
extends ShareCompat.b
{
public final void a(MenuItem paramMenuItem, ShareCompat.IntentBuilder paramIntentBuilder)
{
Activity localActivity = paramIntentBuilder.a;
Intent localIntent = paramIntentBuilder.getIntent();
Object localObject = paramMenuItem.getActionProvider();
if (!(localObject instanceof ShareActionProvider)) {}
for (localObject = new ShareActionProvider(localActivity);; localObject = (ShareActionProvider)localObject)
{
((ShareActionProvider)localObject).setShareHistoryFileName(".sharecompat_" + localActivity.getClass().getName());
((ShareActionProvider)localObject).setShareIntent(localIntent);
paramMenuItem.setActionProvider((ActionProvider)localObject);
if (a(paramMenuItem)) {
paramMenuItem.setIntent(paramIntentBuilder.createChooserIntent());
}
return;
}
}
boolean a(MenuItem paramMenuItem)
{
return !paramMenuItem.hasSubMenu();
}
}
static final class d
extends ShareCompat.c
{
public final String a(CharSequence paramCharSequence)
{
return Html.escapeHtml(paramCharSequence);
}
final boolean a(MenuItem paramMenuItem)
{
return false;
}
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/android/support/v4/app/ShareCompat.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/