1
1
package fr .free .nrw .commons ;
2
2
3
+ import android .annotation .SuppressLint ;
3
4
import android .content .Intent ;
4
5
import android .net .Uri ;
5
6
import android .os .Bundle ;
7
+ import android .util .Log ;
6
8
import android .support .customtabs .CustomTabsIntent ;
7
9
import android .support .v4 .content .ContextCompat ;
8
10
import android .view .View ;
9
11
import android .widget .TextView ;
12
+ import android .widget .Toast ;
10
13
11
14
import butterknife .BindView ;
12
15
import butterknife .ButterKnife ;
13
16
import butterknife .OnClick ;
14
17
import fr .free .nrw .commons .theme .NavigationBaseActivity ;
15
18
import fr .free .nrw .commons .ui .widget .HtmlTextView ;
16
19
20
+ import static android .widget .Toast .LENGTH_SHORT ;
21
+
17
22
/**
18
23
* Represents about screen of this app
19
24
*/
@@ -27,12 +32,12 @@ public class AboutActivity extends NavigationBaseActivity {
27
32
* @param savedInstanceState Data bundle
28
33
*/
29
34
@ Override
35
+ @ SuppressLint ("StringFormatInvalid" )
30
36
public void onCreate (Bundle savedInstanceState ) {
31
37
super .onCreate (savedInstanceState );
32
38
setContentView (R .layout .activity_about );
33
39
34
40
ButterKnife .bind (this );
35
-
36
41
String aboutText = getString (R .string .about_license );
37
42
aboutLicenseText .setHtmlText (aboutText );
38
43
@@ -42,35 +47,66 @@ public void onCreate(Bundle savedInstanceState) {
42
47
43
48
@ OnClick (R .id .facebook_launch_icon )
44
49
public void launchFacebook (View view ) {
45
-
46
50
Intent intent ;
47
51
try {
48
52
intent = new Intent (Intent .ACTION_VIEW , Uri .parse ("fb://page/" + "1921335171459985" ));
49
53
intent .setPackage ("com.facebook.katana" );
50
54
startActivity (intent );
51
55
} catch (Exception e ) {
52
- Utils .handleWebUrl (this ,Uri .parse ("https://www.facebook.com/" + "1921335171459985" ));
56
+ intent = new Intent (Intent .ACTION_VIEW , Uri .parse ("https://www.facebook.com/" + "1921335171459985\\ " ));
57
+ if (intent .resolveActivity (this .getPackageManager ()) != null ){
58
+ Utils .handleWebUrl (this ,Uri .parse ("https://www.facebook.com/" + "1921335171459985" ));
59
+ } else {
60
+ Toast toast = Toast .makeText (this , getString (R .string .no_web_browser ), LENGTH_SHORT );
61
+ toast .show ();
62
+ }
53
63
}
54
64
}
55
65
56
66
@ OnClick (R .id .github_launch_icon )
57
67
public void launchGithub (View view ) {
58
- Utils .handleWebUrl (this ,Uri .parse ("https://commons-app.github.io/\\ " ));
68
+ Intent browserIntent = new Intent (Intent .ACTION_VIEW , Uri .parse ("https://github.com/commons-app/apps-android-commons\\ " ));
69
+ //check if web browser available
70
+ if (browserIntent .resolveActivity (this .getPackageManager ()) != null ) {
71
+ Utils .handleWebUrl (this ,Uri .parse ("https://github.com/commons-app/apps-android-commons\\ " ));
72
+ } else {
73
+ Toast toast = Toast .makeText (this , getString (R .string .no_web_browser ), LENGTH_SHORT );
74
+ toast .show ();
75
+ }
59
76
}
60
77
61
78
@ OnClick (R .id .website_launch_icon )
62
79
public void launchWebsite (View view ) {
63
- Utils .handleWebUrl (this ,Uri .parse ("https://commons-app.github.io/\\ " ));
80
+ Intent browserIntent = new Intent (Intent .ACTION_VIEW , Uri .parse ("https://commons-app.github.io/\\ " ));
81
+ if (browserIntent .resolveActivity (this .getPackageManager ()) != null ) {
82
+ Utils .handleWebUrl (this ,Uri .parse ("https://commons-app.github.io/\\ " ));
83
+ } else {
84
+ Toast toast = Toast .makeText (this , getString (R .string .no_web_browser ), LENGTH_SHORT );
85
+ toast .show ();
86
+ }
64
87
}
65
88
89
+
66
90
@ OnClick (R .id .about_credits )
67
91
public void launchCredits (View view ) {
68
- Utils .handleWebUrl (this ,Uri .parse ("https://github.com/commons-app/apps-android-commons/blob/master/CREDITS/\\ " ));
92
+ Intent browserIntent = new Intent (Intent .ACTION_VIEW , Uri .parse ("https://github.com/commons-app/apps-android-commons/blob/master/CREDITS/\\ " ));
93
+ if (browserIntent .resolveActivity (this .getPackageManager ()) != null ) {
94
+ Utils .handleWebUrl (this ,Uri .parse ("https://github.com/commons-app/apps-android-commons/blob/master/CREDITS/\\ " ));
95
+ } else {
96
+ Toast toast = Toast .makeText (this , getString (R .string .no_web_browser ), LENGTH_SHORT );
97
+ toast .show ();
98
+ }
69
99
}
70
100
71
101
@ OnClick (R .id .about_privacy_policy )
72
102
public void launchPrivacyPolicy (View view ) {
73
- Utils .handleWebUrl (this ,Uri .parse ("https://github.com/commons-app/apps-android-commons/wiki/Privacy-policy\\ " ));
103
+ Intent browserIntent = new Intent (Intent .ACTION_VIEW , Uri .parse ("https://github.com/commons-app/apps-android-commons/wiki/Privacy-policy\\ " ));
104
+ if (browserIntent .resolveActivity (this .getPackageManager ()) != null ) {
105
+ Utils .handleWebUrl (this ,Uri .parse ("https://github.com/commons-app/apps-android-commons/wiki/Privacy-policy\\ " ));
106
+ } else {
107
+ Toast toast = Toast .makeText (this , getString (R .string .no_web_browser ), LENGTH_SHORT );
108
+ toast .show ();
109
+ }
74
110
}
75
111
76
- }
112
+ }
0 commit comments