diff --git a/app/src/main/java/org/itxtech/daedalus/Daedalus.java b/app/src/main/java/org/itxtech/daedalus/Daedalus.java index 86da3a8..4371dfc 100644 --- a/app/src/main/java/org/itxtech/daedalus/Daedalus.java +++ b/app/src/main/java/org/itxtech/daedalus/Daedalus.java @@ -254,8 +254,16 @@ public class Daedalus extends Application { } public static void donate() { - instance.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://qr.alipay.com/a6x07022gffiehykicipv1a")) - .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); + openUri("https://qr.alipay.com/a6x07022gffiehykicipv1a"); + } + + public static void openUri(String uri) { + try { + instance.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(uri)) + .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); + } catch (Exception e) { + Logger.logException(e); + } } public static Daedalus getInstance() { diff --git a/app/src/main/java/org/itxtech/daedalus/activity/MainActivity.java b/app/src/main/java/org/itxtech/daedalus/activity/MainActivity.java index 9678249..31e10b0 100644 --- a/app/src/main/java/org/itxtech/daedalus/activity/MainActivity.java +++ b/app/src/main/java/org/itxtech/daedalus/activity/MainActivity.java @@ -5,7 +5,6 @@ import android.app.FragmentManager; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; -import android.net.Uri; import android.net.VpnService; import android.os.Bundle; import android.support.annotation.NonNull; @@ -250,7 +249,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On switchFragment(new DNSTestFragment()); break; case R.id.nav_github: - startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/iTXTech/Daedalus"))); + Daedalus.openUri("https://github.com/iTXTech/Daedalus"); break; case R.id.nav_home: switchFragment(new HomeFragment()); diff --git a/app/src/main/java/org/itxtech/daedalus/fragment/GlobalConfigFragment.java b/app/src/main/java/org/itxtech/daedalus/fragment/GlobalConfigFragment.java index 5de8079..c41e7ab 100644 --- a/app/src/main/java/org/itxtech/daedalus/fragment/GlobalConfigFragment.java +++ b/app/src/main/java/org/itxtech/daedalus/fragment/GlobalConfigFragment.java @@ -1,7 +1,5 @@ package org.itxtech.daedalus.fragment; -import android.content.Intent; -import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.preference.*; @@ -104,7 +102,7 @@ public class GlobalConfigFragment extends PreferenceFragment { findPreference("settings_check_update").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { - startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/iTXTech/Daedalus/releases"))); + Daedalus.openUri("https://github.com/iTXTech/Daedalus/releases"); return false; } }); @@ -112,7 +110,7 @@ public class GlobalConfigFragment extends PreferenceFragment { findPreference("settings_issue_tracker").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { - startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/iTXTech/Daedalus/issues"))); + Daedalus.openUri("https://github.com/iTXTech/Daedalus/issues"); return false; } }); @@ -120,7 +118,7 @@ public class GlobalConfigFragment extends PreferenceFragment { findPreference("settings_manual").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { - startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/iTXTech/Daedalus/wiki"))); + Daedalus.openUri("https://github.com/iTXTech/Daedalus/wiki"); return false; } });