Commit c5830ea4 authored by Daniel Wolf's avatar Daniel Wolf
Browse files

Use non-hardcoded telegram URL unless no browser is installed

parent a93e0df0
...@@ -430,7 +430,7 @@ val Context.isPrivateDnsActive: Boolean ...@@ -430,7 +430,7 @@ val Context.isPrivateDnsActive: Boolean
} }
} }
fun Context.tryOpenBrowser(withLink:String) { fun Context.tryViewUri(withLink:String, alternativeLink:String? = null) {
try { try {
startActivity( startActivity(
Intent( Intent(
...@@ -439,7 +439,10 @@ fun Context.tryOpenBrowser(withLink:String) { ...@@ -439,7 +439,10 @@ fun Context.tryOpenBrowser(withLink:String) {
) )
) )
} catch (e: ActivityNotFoundException) { } catch (e: ActivityNotFoundException) {
Toast.makeText(this, R.string.error_no_webbrowser_installed, Toast.LENGTH_LONG).show() log("Got ${e.message} when trying to open link: $withLink")
if(alternativeLink != null) {
tryViewUri(alternativeLink)
} else Toast.makeText(this, R.string.error_no_webbrowser_installed, Toast.LENGTH_LONG).show()
} }
} }
...@@ -462,5 +465,5 @@ fun Context.askOpenFAQ(topic: FAQTopic?) { ...@@ -462,5 +465,5 @@ fun Context.askOpenFAQ(topic: FAQTopic?) {
} }
fun Context.openFAQ(topic:FAQTopic?) { fun Context.openFAQ(topic:FAQTopic?) {
tryOpenBrowser("https://nebulo.app/faq#${topic?.id ?: ""}") tryViewUri("https://nebulo.app/faq#${topic?.id ?: ""}")
} }
\ No newline at end of file
...@@ -157,11 +157,7 @@ class MainActivity : NavigationDrawerActivity() { ...@@ -157,11 +157,7 @@ class MainActivity : NavigationDrawerActivity() {
getString(R.string.dialog_join_group_message), getString(R.string.dialog_join_group_message),
getString(R.string.dialog_join_group_positive) to { dialog, _ -> getString(R.string.dialog_join_group_positive) to { dialog, _ ->
dialog.dismiss() dialog.dismiss()
val intent = Intent( tryViewUri("https://nebulo.app/community", "tg://join?invite=I54nRleveRGP8IPmcIdySg")
Intent.ACTION_VIEW,
Uri.parse("tg://join?invite=I54nRleveRGP8IPmcIdySg")
)
startActivity(intent)
}, },
getString(R.string.dialog_crashreporting_negative) to { dialog, _ -> getString(R.string.dialog_crashreporting_negative) to { dialog, _ ->
dialog.dismiss() dialog.dismiss()
......
...@@ -56,8 +56,7 @@ class AboutFragment : Fragment() { ...@@ -56,8 +56,7 @@ class AboutFragment : Fragment() {
} }
if(isPackageInstalled(requireContext(), "org.telegram.messenger")) { if(isPackageInstalled(requireContext(), "org.telegram.messenger")) {
view.group.setOnClickListener { view.group.setOnClickListener {
val intent = Intent(Intent.ACTION_VIEW, Uri.parse("tg://join?invite=I54nRleveRGP8IPmcIdySg")) context?.tryViewUri("https://nebulo.app/community", "tg://join?invite=I54nRleveRGP8IPmcIdySg")
startActivity(intent)
} }
} else { } else {
view.group.visibility = View.GONE view.group.visibility = View.GONE
...@@ -124,7 +123,7 @@ class AboutFragment : Fragment() { ...@@ -124,7 +123,7 @@ class AboutFragment : Fragment() {
true true
} }
view.faq.setOnClickListener { view.faq.setOnClickListener {
requireContext().tryOpenBrowser("https://nebulo.app/faq") requireContext().tryViewUri("https://nebulo.app/faq")
} }
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment