11package fr .free .nrw .commons ;
22
3+ import android .annotation .SuppressLint ;
34import android .content .Intent ;
45import android .net .Uri ;
56import android .os .Bundle ;
7+ import android .util .Log ;
68import android .support .customtabs .CustomTabsIntent ;
79import android .support .v4 .content .ContextCompat ;
810import android .view .View ;
911import android .widget .TextView ;
12+ import android .widget .Toast ;
1013
1114import butterknife .BindView ;
1215import butterknife .ButterKnife ;
1316import butterknife .OnClick ;
1417import fr .free .nrw .commons .theme .NavigationBaseActivity ;
1518import fr .free .nrw .commons .ui .widget .HtmlTextView ;
1619
20+ import static android .widget .Toast .LENGTH_SHORT ;
21+
1722/**
1823 * Represents about screen of this app
1924 */
@@ -27,12 +32,12 @@ public class AboutActivity extends NavigationBaseActivity {
2732 * @param savedInstanceState Data bundle
2833 */
2934 @ Override
35+ @ SuppressLint ("StringFormatInvalid" )
3036 public void onCreate (Bundle savedInstanceState ) {
3137 super .onCreate (savedInstanceState );
3238 setContentView (R .layout .activity_about );
3339
3440 ButterKnife .bind (this );
35-
3641 String aboutText = getString (R .string .about_license );
3742 aboutLicenseText .setHtmlText (aboutText );
3843
@@ -42,35 +47,66 @@ public void onCreate(Bundle savedInstanceState) {
4247
4348 @ OnClick (R .id .facebook_launch_icon )
4449 public void launchFacebook (View view ) {
45-
4650 Intent intent ;
4751 try {
4852 intent = new Intent (Intent .ACTION_VIEW , Uri .parse ("fb://page/" + "1921335171459985" ));
4953 intent .setPackage ("com.facebook.katana" );
5054 startActivity (intent );
5155 } 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+ }
5363 }
5464 }
5565
5666 @ OnClick (R .id .github_launch_icon )
5767 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+ }
5976 }
6077
6178 @ OnClick (R .id .website_launch_icon )
6279 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+ }
6487 }
6588
89+
6690 @ OnClick (R .id .about_credits )
6791 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+ }
6999 }
70100
71101 @ OnClick (R .id .about_privacy_policy )
72102 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+ }
74110 }
75111
76- }
112+ }
0 commit comments