about: add feedback options
This commit is contained in:
@@ -18,6 +18,9 @@
|
||||
|
||||
package org.oxycblt.auxio.settings
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import androidx.core.view.updatePadding
|
||||
@@ -33,6 +36,7 @@ import org.oxycblt.auxio.playback.formatDurationMs
|
||||
import org.oxycblt.auxio.ui.ViewBindingFragment
|
||||
import org.oxycblt.auxio.util.collectImmediately
|
||||
import org.oxycblt.auxio.util.openInBrowser
|
||||
import org.oxycblt.auxio.util.startIntent
|
||||
import org.oxycblt.auxio.util.systemBarInsetsCompat
|
||||
|
||||
/**
|
||||
@@ -68,6 +72,12 @@ class AboutFragment : ViewBindingFragment<FragmentAboutBinding>() {
|
||||
binding.aboutLicenses.setOnClickListener { requireContext().openInBrowser(LINK_LICENSES) }
|
||||
binding.aboutProfile.setOnClickListener { requireContext().openInBrowser(LINK_PROFILE) }
|
||||
binding.aboutDonate.setOnClickListener { requireContext().openInBrowser(LINK_DONATE) }
|
||||
binding.aboutFeedbackGithub.setOnClickListener {
|
||||
requireContext().openInBrowser(LINK_NEW_ISSUE)
|
||||
}
|
||||
binding.aboutFeedbackEmail.setOnClickListener {
|
||||
requireContext().sendEmail("feedback@auxio.app")
|
||||
}
|
||||
binding.aboutSupportersPromo.setOnClickListener {
|
||||
requireContext().openInBrowser(LINK_DONATE)
|
||||
}
|
||||
@@ -91,10 +101,16 @@ class AboutFragment : ViewBindingFragment<FragmentAboutBinding>() {
|
||||
(statistics?.durationMs ?: 0).formatDurationMs(false))
|
||||
}
|
||||
|
||||
private fun Context.sendEmail(recipient: String) {
|
||||
val intent = Intent(Intent.ACTION_SENDTO).apply { data = Uri.parse("mailto:$recipient") }
|
||||
startIntent(intent)
|
||||
}
|
||||
|
||||
private companion object {
|
||||
const val LINK_SOURCE = "https://github.com/OxygenCobalt/Auxio"
|
||||
const val LINK_WIKI = "$LINK_SOURCE/wiki"
|
||||
const val LINK_LICENSES = "$LINK_WIKI/Licenses"
|
||||
const val LINK_NEW_ISSUE = "$LINK_SOURCE/issues/new"
|
||||
const val LINK_PROFILE = "https://github.com/OxygenCobalt"
|
||||
const val LINK_DONATE = "https://github.com/sponsors/OxygenCobalt"
|
||||
}
|
||||
|
||||
@@ -332,6 +332,11 @@ fun Context.share(songs: Collection<Song>) {
|
||||
* @param uri The URL to open.
|
||||
*/
|
||||
fun Context.openInBrowser(uri: String) {
|
||||
L.d("Opening $uri")
|
||||
startIntent(Intent(Intent.ACTION_VIEW, uri.toUri()).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK))
|
||||
}
|
||||
|
||||
fun Context.startIntent(intent: Intent) {
|
||||
fun openAppChooser(intent: Intent) {
|
||||
L.d("Opening app chooser for ${intent.action}")
|
||||
val chooserIntent =
|
||||
@@ -341,17 +346,13 @@ fun Context.openInBrowser(uri: String) {
|
||||
startActivity(chooserIntent)
|
||||
}
|
||||
|
||||
L.d("Opening $uri")
|
||||
val browserIntent =
|
||||
Intent(Intent.ACTION_VIEW, uri.toUri()).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
// Android 11 seems to now handle the app chooser situations on its own now
|
||||
// [along with adding a new permission that breaks the old manual code], so
|
||||
// we just do a typical activity launch.
|
||||
L.d("Using API 30+ chooser")
|
||||
try {
|
||||
startActivity(browserIntent)
|
||||
startActivity(intent)
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
// No app installed to open the link
|
||||
showToast(R.string.err_no_app)
|
||||
@@ -363,7 +364,7 @@ fun Context.openInBrowser(uri: String) {
|
||||
// browser.
|
||||
L.d("Resolving browser activity for chooser")
|
||||
val pkgName =
|
||||
packageManager.resolveActivity(browserIntent, PackageManager.MATCH_DEFAULT_ONLY)?.run {
|
||||
packageManager.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY)?.run {
|
||||
activityInfo.packageName
|
||||
}
|
||||
|
||||
@@ -371,15 +372,15 @@ fun Context.openInBrowser(uri: String) {
|
||||
if (pkgName == "android") {
|
||||
// No default browser [Must open app chooser, may not be supported]
|
||||
L.d("No default browser found")
|
||||
openAppChooser(browserIntent)
|
||||
openAppChooser(intent)
|
||||
} else L.d("Opening browser intent")
|
||||
try {
|
||||
browserIntent.setPackage(pkgName)
|
||||
startActivity(browserIntent)
|
||||
intent.setPackage(pkgName)
|
||||
startActivity(intent)
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
// Not a browser but an app chooser
|
||||
browserIntent.setPackage(null)
|
||||
openAppChooser(browserIntent)
|
||||
intent.setPackage(null)
|
||||
openAppChooser(intent)
|
||||
}
|
||||
} else {
|
||||
// No app installed to open the link
|
||||
|
||||
Reference in New Issue
Block a user