LinkifyCompat.java
11.8 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
package android.support.v4.text.util;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.util.PatternsCompat;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.method.LinkMovementMethod;
import android.text.method.MovementMethod;
import android.text.style.URLSpan;
import android.text.util.Linkify;
import android.text.util.Linkify.MatchFilter;
import android.text.util.Linkify.TransformFilter;
import android.webkit.WebView;
import android.widget.TextView;
import java.io.UnsupportedEncodingException;
import java.lang.annotation.Annotation;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public final class LinkifyCompat
{
private static final String[] a = new String[0];
private static final Comparator<a> b = new Comparator() {};
private static String a(@NonNull String paramString, @NonNull String[] paramArrayOfString, Matcher paramMatcher, @Nullable Linkify.TransformFilter paramTransformFilter)
{
int k = 1;
if (paramTransformFilter != null) {}
for (paramMatcher = paramTransformFilter.transformUrl(paramMatcher, paramString);; paramMatcher = paramString)
{
int i = 0;
int j;
if (i < paramArrayOfString.length) {
if (paramMatcher.regionMatches(true, 0, paramArrayOfString[i], 0, paramArrayOfString[i].length()))
{
paramString = paramMatcher;
j = k;
if (!paramMatcher.regionMatches(false, 0, paramArrayOfString[i], 0, paramArrayOfString[i].length()))
{
paramString = paramArrayOfString[i] + paramMatcher.substring(paramArrayOfString[i].length());
j = k;
}
}
}
for (;;)
{
paramMatcher = paramString;
if (j == 0)
{
paramMatcher = paramString;
if (paramArrayOfString.length > 0) {
paramMatcher = paramArrayOfString[0] + paramString;
}
}
return paramMatcher;
i += 1;
break;
j = 0;
paramString = paramMatcher;
}
}
}
private static void a(@NonNull TextView paramTextView)
{
MovementMethod localMovementMethod = paramTextView.getMovementMethod();
if (((localMovementMethod == null) || (!(localMovementMethod instanceof LinkMovementMethod))) && (paramTextView.getLinksClickable())) {
paramTextView.setMovementMethod(LinkMovementMethod.getInstance());
}
}
private static void a(String paramString, int paramInt1, int paramInt2, Spannable paramSpannable)
{
paramSpannable.setSpan(new URLSpan(paramString), paramInt1, paramInt2, 33);
}
private static final void a(ArrayList<a> paramArrayList, Spannable paramSpannable)
{
paramSpannable = paramSpannable.toString();
int i = 0;
for (;;)
{
try
{
str = WebView.findAddress(paramSpannable);
if (str != null)
{
int j = paramSpannable.indexOf(str);
if (j >= 0)
{
locala = new a();
int k = str.length() + j;
locala.c = (j + i);
locala.d = (i + k);
paramSpannable = paramSpannable.substring(k);
i += k;
}
}
}
catch (UnsupportedOperationException paramArrayList)
{
try
{
a locala;
String str = URLEncoder.encode(str, "UTF-8");
locala.b = ("geo:0,0?q=" + str);
paramArrayList.add(locala);
}
catch (UnsupportedEncodingException localUnsupportedEncodingException) {}
paramArrayList = paramArrayList;
}
return;
}
}
private static void a(ArrayList<a> paramArrayList, Spannable paramSpannable, Pattern paramPattern, String[] paramArrayOfString, Linkify.MatchFilter paramMatchFilter)
{
paramPattern = paramPattern.matcher(paramSpannable);
while (paramPattern.find())
{
int i = paramPattern.start();
int j = paramPattern.end();
if ((paramMatchFilter == null) || (paramMatchFilter.acceptMatch(paramSpannable, i, j)))
{
a locala = new a();
locala.b = a(paramPattern.group(0), paramArrayOfString, paramPattern, null);
locala.c = i;
locala.d = j;
paramArrayList.add(locala);
}
}
}
public static final void addLinks(@NonNull TextView paramTextView, @NonNull Pattern paramPattern, @Nullable String paramString)
{
addLinks(paramTextView, paramPattern, paramString, null, null, null);
}
public static final void addLinks(@NonNull TextView paramTextView, @NonNull Pattern paramPattern, @Nullable String paramString, @Nullable Linkify.MatchFilter paramMatchFilter, @Nullable Linkify.TransformFilter paramTransformFilter)
{
addLinks(paramTextView, paramPattern, paramString, null, paramMatchFilter, paramTransformFilter);
}
public static final void addLinks(@NonNull TextView paramTextView, @NonNull Pattern paramPattern, @Nullable String paramString, @Nullable String[] paramArrayOfString, @Nullable Linkify.MatchFilter paramMatchFilter, @Nullable Linkify.TransformFilter paramTransformFilter)
{
SpannableString localSpannableString = SpannableString.valueOf(paramTextView.getText());
if (addLinks(localSpannableString, paramPattern, paramString, paramArrayOfString, paramMatchFilter, paramTransformFilter))
{
paramTextView.setText(localSpannableString);
a(paramTextView);
}
}
public static final boolean addLinks(@NonNull Spannable paramSpannable, int paramInt)
{
if (paramInt == 0) {
return false;
}
Object localObject1 = (URLSpan[])paramSpannable.getSpans(0, paramSpannable.length(), URLSpan.class);
int i = localObject1.length - 1;
while (i >= 0)
{
paramSpannable.removeSpan(localObject1[i]);
i -= 1;
}
if ((paramInt & 0x4) != 0) {
Linkify.addLinks(paramSpannable, 4);
}
localObject1 = new ArrayList();
Object localObject2;
if ((paramInt & 0x1) != 0)
{
localObject2 = PatternsCompat.AUTOLINK_WEB_URL;
Linkify.MatchFilter localMatchFilter = Linkify.sUrlMatchFilter;
a((ArrayList)localObject1, paramSpannable, (Pattern)localObject2, new String[] { "http://", "https://", "rtsp://" }, localMatchFilter);
}
if ((paramInt & 0x2) != 0) {
a((ArrayList)localObject1, paramSpannable, PatternsCompat.AUTOLINK_EMAIL_ADDRESS, new String[] { "mailto:" }, null);
}
if ((paramInt & 0x8) != 0) {
a((ArrayList)localObject1, paramSpannable);
}
b((ArrayList)localObject1, paramSpannable);
if (((ArrayList)localObject1).size() == 0) {
return false;
}
localObject1 = ((ArrayList)localObject1).iterator();
while (((Iterator)localObject1).hasNext())
{
localObject2 = (a)((Iterator)localObject1).next();
if (((a)localObject2).a == null) {
a(((a)localObject2).b, ((a)localObject2).c, ((a)localObject2).d, paramSpannable);
}
}
return true;
}
public static final boolean addLinks(@NonNull Spannable paramSpannable, @NonNull Pattern paramPattern, @Nullable String paramString)
{
return addLinks(paramSpannable, paramPattern, paramString, null, null, null);
}
public static final boolean addLinks(@NonNull Spannable paramSpannable, @NonNull Pattern paramPattern, @Nullable String paramString, @Nullable Linkify.MatchFilter paramMatchFilter, @Nullable Linkify.TransformFilter paramTransformFilter)
{
return addLinks(paramSpannable, paramPattern, paramString, null, paramMatchFilter, paramTransformFilter);
}
public static final boolean addLinks(@NonNull Spannable paramSpannable, @NonNull Pattern paramPattern, @Nullable String paramString, @Nullable String[] paramArrayOfString, @Nullable Linkify.MatchFilter paramMatchFilter, @Nullable Linkify.TransformFilter paramTransformFilter)
{
String str = paramString;
if (paramString == null) {
str = "";
}
if (paramArrayOfString != null)
{
paramString = paramArrayOfString;
if (paramArrayOfString.length > 0) {}
}
else
{
paramString = a;
}
String[] arrayOfString = new String[paramString.length + 1];
arrayOfString[0] = str.toLowerCase(Locale.ROOT);
int i = 0;
if (i < paramString.length)
{
paramArrayOfString = paramString[i];
if (paramArrayOfString == null) {}
for (paramArrayOfString = "";; paramArrayOfString = paramArrayOfString.toLowerCase(Locale.ROOT))
{
arrayOfString[(i + 1)] = paramArrayOfString;
i += 1;
break;
}
}
paramPattern = paramPattern.matcher(paramSpannable);
boolean bool1 = false;
label181:
label185:
for (;;)
{
int j;
if (paramPattern.find())
{
i = paramPattern.start();
j = paramPattern.end();
if (paramMatchFilter == null) {
break label181;
}
}
for (boolean bool2 = paramMatchFilter.acceptMatch(paramSpannable, i, j);; bool2 = true)
{
if (!bool2) {
break label185;
}
a(a(paramPattern.group(0), arrayOfString, paramPattern, paramTransformFilter), i, j, paramSpannable);
bool1 = true;
break;
return bool1;
}
}
}
public static final boolean addLinks(@NonNull TextView paramTextView, int paramInt)
{
if (paramInt == 0) {
return false;
}
Object localObject = paramTextView.getText();
if ((localObject instanceof Spannable))
{
if (addLinks((Spannable)localObject, paramInt))
{
a(paramTextView);
return true;
}
return false;
}
localObject = SpannableString.valueOf((CharSequence)localObject);
if (addLinks((Spannable)localObject, paramInt))
{
a(paramTextView);
paramTextView.setText((CharSequence)localObject);
return true;
}
return false;
}
private static final void b(ArrayList<a> paramArrayList, Spannable paramSpannable)
{
int j = 0;
Object localObject = (URLSpan[])paramSpannable.getSpans(0, paramSpannable.length(), URLSpan.class);
int i = 0;
a locala;
while (i < localObject.length)
{
locala = new a();
locala.a = localObject[i];
locala.c = paramSpannable.getSpanStart(localObject[i]);
locala.d = paramSpannable.getSpanEnd(localObject[i]);
paramArrayList.add(locala);
i += 1;
}
Collections.sort(paramArrayList, b);
int k = paramArrayList.size();
if (j < k - 1)
{
localObject = (a)paramArrayList.get(j);
locala = (a)paramArrayList.get(j + 1);
if ((((a)localObject).c <= locala.c) && (((a)localObject).d > locala.c)) {
if (locala.d <= ((a)localObject).d) {
i = j + 1;
}
}
}
for (;;)
{
if (i != -1)
{
localObject = ((a)paramArrayList.get(i)).a;
if (localObject != null) {
paramSpannable.removeSpan(localObject);
}
paramArrayList.remove(i);
k -= 1;
break;
if (((a)localObject).d - ((a)localObject).c > locala.d - locala.c)
{
i = j + 1;
continue;
}
if (((a)localObject).d - ((a)localObject).c >= locala.d - locala.c) {
break label295;
}
i = j;
continue;
}
j += 1;
break;
return;
label295:
i = -1;
}
}
@Retention(RetentionPolicy.SOURCE)
public static @interface LinkifyMask {}
static final class a
{
URLSpan a;
String b;
int c;
int d;
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/android/support/v4/text/util/LinkifyCompat.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/