From d06dd59386fd6444e5c4574d1bc5dd52e7fb53e3 Mon Sep 17 00:00:00 2001 From: Alexander Capehart Date: Thu, 31 Oct 2024 15:31:00 -0600 Subject: [PATCH] about: add feedback options --- .../oxycblt/auxio/settings/AboutFragment.kt | 16 ++++++ .../org/oxycblt/auxio/util/FrameworkUtil.kt | 23 ++++----- app/src/main/res/drawable/ic_email_24.xml | 10 ++++ .../res/drawable/ic_feature_request_24.xml | 10 ++++ app/src/main/res/layout/fragment_about.xml | 49 +++++++++++++++++++ app/src/main/res/values/strings.xml | 3 ++ 6 files changed, 100 insertions(+), 11 deletions(-) create mode 100644 app/src/main/res/drawable/ic_email_24.xml create mode 100644 app/src/main/res/drawable/ic_feature_request_24.xml diff --git a/app/src/main/java/org/oxycblt/auxio/settings/AboutFragment.kt b/app/src/main/java/org/oxycblt/auxio/settings/AboutFragment.kt index a80bc446d..11f4b5175 100644 --- a/app/src/main/java/org/oxycblt/auxio/settings/AboutFragment.kt +++ b/app/src/main/java/org/oxycblt/auxio/settings/AboutFragment.kt @@ -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() { 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() { (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" } diff --git a/app/src/main/java/org/oxycblt/auxio/util/FrameworkUtil.kt b/app/src/main/java/org/oxycblt/auxio/util/FrameworkUtil.kt index d9e81f8e3..034299d1d 100644 --- a/app/src/main/java/org/oxycblt/auxio/util/FrameworkUtil.kt +++ b/app/src/main/java/org/oxycblt/auxio/util/FrameworkUtil.kt @@ -332,6 +332,11 @@ fun Context.share(songs: Collection) { * @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 diff --git a/app/src/main/res/drawable/ic_email_24.xml b/app/src/main/res/drawable/ic_email_24.xml new file mode 100644 index 000000000..a50fe012a --- /dev/null +++ b/app/src/main/res/drawable/ic_email_24.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/ic_feature_request_24.xml b/app/src/main/res/drawable/ic_feature_request_24.xml new file mode 100644 index 000000000..1765191ed --- /dev/null +++ b/app/src/main/res/drawable/ic_feature_request_24.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/layout/fragment_about.xml b/app/src/main/res/layout/fragment_about.xml index 787fcb546..bde1c599a 100644 --- a/app/src/main/res/layout/fragment_about.xml +++ b/app/src/main/res/layout/fragment_about.xml @@ -204,6 +204,8 @@ + + + + + + + + + + + + + + + Author Alexander Capehart + Feedback + Make an issue on GitHub + Send an email Donate Supporters