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
}
}
fun Context.tryOpenBrowser(withLink:String) {
fun Context.tryViewUri(withLink:String, alternativeLink:String? = null) {
try {
startActivity(
Intent(
......@@ -439,7 +439,10 @@ fun Context.tryOpenBrowser(withLink:String) {
)
)
} 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?) {
}
fun Context.openFAQ(topic:FAQTopic?) {
tryOpenBrowser("https://nebulo.app/faq#${topic?.id ?: ""}")
tryViewUri("https://nebulo.app/faq#${topic?.id ?: ""}")
}
......@@ -157,11 +157,7 @@ class MainActivity : NavigationDrawerActivity() {
getString(R.string.dialog_join_group_message),
getString(R.string.dialog_join_group_positive) to { dialog, _ ->
dialog.dismiss()
val intent = Intent(
Intent.ACTION_VIEW,
Uri.parse("tg://join?invite=I54nRleveRGP8IPmcIdySg")
)
startActivity(intent)
tryViewUri("https://nebulo.app/community", "tg://join?invite=I54nRleveRGP8IPmcIdySg")
},
getString(R.string.dialog_crashreporting_negative) to { dialog, _ ->
dialog.dismiss()
......
......@@ -56,8 +56,7 @@ class AboutFragment : Fragment() {
}
if(isPackageInstalled(requireContext(), "org.telegram.messenger")) {
view.group.setOnClickListener {
val intent = Intent(Intent.ACTION_VIEW, Uri.parse("tg://join?invite=I54nRleveRGP8IPmcIdySg"))
startActivity(intent)
context?.tryViewUri("https://nebulo.app/community", "tg://join?invite=I54nRleveRGP8IPmcIdySg")
}
} else {
view.group.visibility = View.GONE
......@@ -124,7 +123,7 @@ class AboutFragment : Fragment() {
true
}
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