about: add feedback options
This commit is contained in:
parent
022fe9ae1b
commit
d06dd59386
6 changed files with 100 additions and 11 deletions
|
@ -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
|
||||
|
|
10
app/src/main/res/drawable/ic_email_24.xml
Normal file
10
app/src/main/res/drawable/ic_email_24.xml
Normal file
|
@ -0,0 +1,10 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M160,800Q127,800 103.5,776.5Q80,753 80,720L80,240Q80,207 103.5,183.5Q127,160 160,160L800,160Q833,160 856.5,183.5Q880,207 880,240L880,720Q880,753 856.5,776.5Q833,800 800,800L160,800ZM480,520L160,320L160,720Q160,720 160,720Q160,720 160,720L800,720Q800,720 800,720Q800,720 800,720L800,320L480,520ZM480,440L800,240L160,240L480,440ZM160,320L160,240L160,240L160,320L160,720Q160,720 160,720Q160,720 160,720L160,720Q160,720 160,720Q160,720 160,720L160,320Z"/>
|
||||
</vector>
|
10
app/src/main/res/drawable/ic_feature_request_24.xml
Normal file
10
app/src/main/res/drawable/ic_feature_request_24.xml
Normal file
|
@ -0,0 +1,10 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M480,600Q497,600 508.5,588.5Q520,577 520,560Q520,543 508.5,531.5Q497,520 480,520Q463,520 451.5,531.5Q440,543 440,560Q440,577 451.5,588.5Q463,600 480,600ZM440,440L520,440L520,200L440,200L440,440ZM80,880L80,160Q80,127 103.5,103.5Q127,80 160,80L800,80Q833,80 856.5,103.5Q880,127 880,160L880,640Q880,673 856.5,696.5Q833,720 800,720L240,720L80,880ZM206,640L800,640Q800,640 800,640Q800,640 800,640L800,160Q800,160 800,160Q800,160 800,160L160,160Q160,160 160,160Q160,160 160,160L160,685L206,640ZM160,640L160,640L160,160Q160,160 160,160Q160,160 160,160L160,160Q160,160 160,160Q160,160 160,160L160,640Q160,640 160,640Q160,640 160,640Z"/>
|
||||
</vector>
|
|
@ -204,6 +204,8 @@
|
|||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -240,6 +242,53 @@
|
|||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/spacing_medium">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="@dimen/spacing_tiny">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/about_feedback"
|
||||
style="@style/Widget.Auxio.TextView.Header"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/lbl_feedback"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/about_feedback_github"
|
||||
style="@style/Widget.Auxio.TextView.Icon.Clickable"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/lbl_github"
|
||||
app:drawableStartCompat="@drawable/ic_feature_request_24"
|
||||
app:drawableTint="?attr/colorControlNormal"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/about_licenses" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/about_feedback_email"
|
||||
style="@style/Widget.Auxio.TextView.Icon.Clickable"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/lbl_email"
|
||||
app:drawableStartCompat="@drawable/ic_email_24"
|
||||
app:drawableTint="?attr/colorControlNormal"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/about_licenses" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
@ -188,6 +188,9 @@
|
|||
|
||||
<string name="lbl_author">Author</string>
|
||||
<string name="lbl_author_name">Alexander Capehart</string>
|
||||
<string name="lbl_feedback">Feedback</string>
|
||||
<string name="lbl_github">Make an issue on GitHub</string>
|
||||
<string name="lbl_email">Send an email</string>
|
||||
<string name="lbl_donate">Donate</string>
|
||||
<string name="lbl_supporters">Supporters</string>
|
||||
|
||||
|
|
Loading…
Reference in a new issue