1
1
package uk .openvk .android .legacy ;
2
2
3
- import android .accounts .Account ;
4
- import android .accounts .AccountAuthenticatorResponse ;
5
3
import android .accounts .AccountManager ;
6
4
import android .annotation .SuppressLint ;
7
5
import android .app .Activity ;
8
6
import android .app .AlertDialog ;
9
- import android .content .ContentResolver ;
10
7
import android .content .Context ;
11
8
import android .content .DialogInterface ;
12
9
import android .content .Intent ;
16
13
import android .content .res .TypedArray ;
17
14
import android .net .Uri ;
18
15
import android .os .Build ;
19
- import android .os .Bundle ;
20
- import android .os .Handler ;
21
- import android .os .Message ;
22
- import android .os .Parcel ;
23
16
import android .provider .Settings ;
24
- import android .support .annotation .IdRes ;
25
17
import android .support .annotation .PluralsRes ;
26
18
import android .support .v7 .preference .PreferenceManager ;
27
19
import android .text .Html ;
34
26
import android .view .ViewGroup ;
35
27
import android .view .Window ;
36
28
import android .view .WindowManager ;
37
- import android .webkit .MimeTypeMap ;
38
29
import android .widget .Button ;
39
30
import android .widget .EditText ;
40
- import android .widget .ImageButton ;
41
- import android .widget .ListView ;
42
31
import android .widget .Toast ;
43
32
44
33
import com .jeremyfeinstein .slidingmenu .lib .SlidingMenu ;
45
34
46
35
import java .io .File ;
47
- import java .io .UnsupportedEncodingException ;
48
36
import java .lang .reflect .Field ;
49
37
import java .lang .reflect .Method ;
50
38
import java .security .MessageDigest ;
54
42
import java .util .regex .Pattern ;
55
43
56
44
import uk .openvk .android .legacy .api .OpenVKAPI ;
57
- import uk .openvk .android .legacy .api .entities .Group ;
58
45
import uk .openvk .android .legacy .api .entities .OvkExpandableText ;
59
46
import uk .openvk .android .legacy .api .entities .OvkLink ;
60
47
import uk .openvk .android .legacy .api .entities .WallPost ;
61
- import uk .openvk .android .legacy .api .enumerations .HandlerMessages ;
62
- import uk .openvk .android .legacy .api .wrappers .DownloadManager ;
63
- import uk .openvk .android .legacy .api .wrappers .OvkAPIWrapper ;
64
48
import uk .openvk .android .legacy .ui .OvkAlertDialog ;
65
49
import uk .openvk .android .legacy .ui .core .activities .AppActivity ;
66
50
import uk .openvk .android .legacy .ui .core .activities .AuthActivity ;
67
- import uk .openvk .android .legacy .ui .core .activities .ConversationActivity ;
68
- import uk .openvk .android .legacy .ui .core .activities .DebugMenuActivity ;
69
- import uk .openvk .android .legacy .ui .core .activities .GroupMembersActivity ;
70
- import uk .openvk .android .legacy .ui .core .activities .MainActivity ;
71
51
import uk .openvk .android .legacy .ui .core .activities .NewPostActivity ;
72
- import uk .openvk .android .legacy .ui .core .activities .QuickSearchActivity ;
73
- import uk .openvk .android .legacy .ui .core .activities .WallPostActivity ;
74
- import uk .openvk .android .legacy .ui .core .activities .intents .FriendsIntentActivity ;
75
- import uk .openvk .android .legacy .ui .core .activities .intents .GroupIntentActivity ;
76
- import uk .openvk .android .legacy .ui .core .activities .intents .NotesIntentActivity ;
77
- import uk .openvk .android .legacy .ui .core .activities .intents .PhotoAlbumIntentActivity ;
78
- import uk .openvk .android .legacy .ui .core .activities .intents .ProfileIntentActivity ;
79
- import uk .openvk .android .legacy .ui .core .fragments .app .NewsfeedFragment ;
80
- import uk .openvk .android .legacy .ui .core .fragments .app .ProfileFragment ;
81
- import uk .openvk .android .legacy .ui .list .adapters .SlidingMenuAdapter ;
82
52
import uk .openvk .android .legacy .ui .list .items .InstanceAccount ;
83
53
import uk .openvk .android .legacy .ui .list .items .SlidingMenuItem ;
84
- import uk .openvk .android .legacy .ui .view .layouts .WallLayout ;
85
54
86
55
/** Global.java - global methods for application
87
56
*
@@ -212,7 +181,8 @@ public static Spanned formatLinksAsHtml(String original_text) {
212
181
if (block .startsWith ("[" ) && block .endsWith ("]" )) {
213
182
OvkLink link = new OvkLink ();
214
183
String [] markup = block .replace ("[" , "" ).replace ("]" , "" )
215
- .replace ("<" , "" ).replace ("\" " , "" ).replace (">" , "" )
184
+ .replace ("<" , "" ).replace ("\" " , "" )
185
+ .replace (">" , "" )
216
186
.split ("\\ |" );
217
187
link .screen_name = markup [0 ];
218
188
if (markup .length == 2 ) {
@@ -249,7 +219,8 @@ public static OvkExpandableText formatLinksAsHtml(String original_text, int end_
249
219
"\\ +~#?&//=]{1,256}\\ .[a-z]{2,6}\\ b([-a-zA-Z0-9@:%._\\ +~#?&//=]*)" );
250
220
Matcher matcher = pattern .matcher (original_text );
251
221
boolean regexp_search = matcher .find ();
252
- String text = original_text .replaceAll ("<" , "<" ).replaceAll (">" , ">" )
222
+ String text = original_text .replaceAll ("<" , "<" )
223
+ .replaceAll (">" , ">" )
253
224
.replaceAll ("&" , "&" ).replaceAll (""" , "\" " );
254
225
text = text .replace ("\r \n " , "<br>" ).replace ("\n " , "<br>" );
255
226
int regexp_results = 0 ;
@@ -258,8 +229,10 @@ public static OvkExpandableText formatLinksAsHtml(String original_text, int end_
258
229
String block = matcher .group ();
259
230
if (block .startsWith ("[" ) && block .endsWith ("]" )) {
260
231
OvkLink link = new OvkLink ();
261
- String [] markup = block .replace ("[" , "" ).replace ("]" , "" )
262
- .replace ("<" , "" ).replace (">" , "" ).replace ("\" " , "" )
232
+ String [] markup = block .replace ("[" , "" )
233
+ .replace ("]" , "" )
234
+ .replace ("<" , "" ).replace (">" , "" )
235
+ .replace ("\" " , "" )
263
236
.split ("\\ |" );
264
237
link .screen_name = markup [0 ];
265
238
if (markup .length == 2 ) {
@@ -272,11 +245,13 @@ public static OvkExpandableText formatLinksAsHtml(String original_text, int end_
272
245
}
273
246
link .name = markup [1 ];
274
247
if (markup [0 ].startsWith ("id" ) || markup [0 ].startsWith ("club" )) {
275
- text = text .replace (block , String .format ("<a href=\" %s\" >%s</a>" , link .url , link .name ));
248
+ text = text .replace (block , String .format ("<a href=\" %s\" >%s</a>" ,
249
+ link .url , link .name ));
276
250
}
277
251
}
278
252
} else if (block .startsWith ("https://" ) || block .startsWith ("http://" )) {
279
- text = text .replace (block , String .format ("<a href=\" %s\" >%s</a>" , block , block ));
253
+ text = text .replace (block , String .format ("<a href=\" %s\" >%s</a>" ,
254
+ block , block ));
280
255
}
281
256
}
282
257
regexp_results = regexp_results + 1 ;
@@ -286,7 +261,8 @@ public static OvkExpandableText formatLinksAsHtml(String original_text, int end_
286
261
Spanned html ;
287
262
if (text .length () >= end_number ) {
288
263
if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .N ) {
289
- html = Html .fromHtml (text .substring (0 , end_number - 1 ) + "..." , Html .FROM_HTML_MODE_COMPACT );
264
+ html = Html .fromHtml (text .substring (0 , end_number - 1 ) + "..." ,
265
+ Html .FROM_HTML_MODE_COMPACT );
290
266
} else {
291
267
html = Html .fromHtml (text .substring (0 , end_number - 1 ) + "..." );
292
268
}
@@ -314,7 +290,9 @@ public static void fixWindowPadding(View view, Resources.Theme theme) {
314
290
public static void fixWindowPadding (Window window , Resources .Theme theme ) {
315
291
if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .KITKAT ) {
316
292
View view = window .getDecorView ();
317
- int actionBarId = view .getContext ().getResources ().getIdentifier ("action_bar" , "id" , "android" );
293
+ int actionBarId =
294
+ view .getContext ().getResources ()
295
+ .getIdentifier ("action_bar" , "id" , "android" );
318
296
ViewGroup actionBarView = (ViewGroup ) view .findViewById (actionBarId );
319
297
Resources res = view .getContext ().getResources ();
320
298
try {
@@ -568,9 +546,12 @@ public void onClick(DialogInterface dialog, int which) {
568
546
new DialogInterface .OnClickListener () {
569
547
@ Override
570
548
public void onClick (DialogInterface dialog , int which ) {
571
- SharedPreferences .Editor editor = finalGlobal_prefs .edit ();
572
- editor .putString ("current_instance" , accountArray .get (selectedPosition [0 ]).instance );
573
- editor .putLong ("current_uid" , accountArray .get (selectedPosition [0 ]).id );
549
+ SharedPreferences .Editor editor =
550
+ finalGlobal_prefs .edit ();
551
+ editor .putString ("current_instance" ,
552
+ accountArray .get (selectedPosition [0 ]).instance );
553
+ editor .putLong ("current_uid" ,
554
+ accountArray .get (selectedPosition [0 ]).id );
574
555
editor .commit ();
575
556
dialog .dismiss ();
576
557
if (ctx instanceof Activity ) {
@@ -664,13 +645,16 @@ public void onClick(DialogInterface dialog, int which) {
664
645
OvkAlertDialog dialog = new OvkAlertDialog (ctx );
665
646
dialog .build (builder , ctx .getResources ().getString (R .string .sett_account ), "" , null , "listDlg" );
666
647
final SharedPreferences finalGlobal_prefs = global_prefs ;
667
- dialog .setButton (DialogInterface .BUTTON_POSITIVE , ctx .getResources ().getString (android .R .string .ok ),
648
+ dialog .setButton (DialogInterface .BUTTON_POSITIVE ,
649
+ ctx .getResources ().getString (android .R .string .ok ),
668
650
new DialogInterface .OnClickListener () {
669
651
@ Override
670
652
public void onClick (DialogInterface dialog , int which ) {
671
653
SharedPreferences .Editor editor = finalGlobal_prefs .edit ();
672
- editor .putString ("current_instance" , accountArray .get (selectedPosition [0 ]).instance );
673
- editor .putLong ("current_uid" , accountArray .get (selectedPosition [0 ]).id );
654
+ editor .putString ("current_instance" ,
655
+ accountArray .get (selectedPosition [0 ]).instance );
656
+ editor .putLong ("current_uid" ,
657
+ accountArray .get (selectedPosition [0 ]).id );
674
658
editor .commit ();
675
659
dialog .dismiss ();
676
660
if (ctx instanceof Activity ) {
@@ -793,10 +777,12 @@ public void onClick(DialogInterface dialogInterface, int i) {
793
777
dialog .show ();
794
778
}
795
779
796
- public static void openRepostDialog (Context ctx , final OpenVKAPI ovk_api , String where , final WallPost post ) {
780
+ public static void openRepostDialog (Context ctx ,
781
+ final OpenVKAPI ovk_api , String where , final WallPost post ) {
797
782
if (where .equals ("own_wall" )) {
798
783
AlertDialog .Builder builder = new AlertDialog .Builder (ctx );
799
- final View repost_view = ((Activity )ctx ).getLayoutInflater ().inflate (R .layout .dialog_repost_msg ,
784
+ final View repost_view =
785
+ ((Activity )ctx ).getLayoutInflater ().inflate (R .layout .dialog_repost_msg ,
800
786
null , false );
801
787
final EditText text_edit = ((EditText ) repost_view .findViewById (R .id .text_edit ));
802
788
builder .setView (repost_view );
@@ -817,7 +803,8 @@ public void onClick(View view) {
817
803
String msg_text = ((EditText )
818
804
repost_view .findViewById (R .id .text_edit )).getText ()
819
805
.toString ();
820
- ovk_api .wall .repost (ovk_api .wrapper , post .owner_id , post .post_id , msg_text );
806
+ ovk_api .wall .repost
807
+ (ovk_api .wrapper , post .owner_id , post .post_id , msg_text );
821
808
dialog .close ();
822
809
} catch (Exception ex ) {
823
810
ex .printStackTrace ();
0 commit comments