Merge pull request #6386 from Bnyro/master

refactor: add donation button to action menu
This commit is contained in:
Bnyro 2024-08-23 13:46:57 +02:00 committed by GitHub
commit 7c7b109594
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 18 additions and 3 deletions

View File

@ -36,10 +36,10 @@ object IntentHelper {
} }
} }
fun openLinkFromHref(context: Context, fragmentManager: FragmentManager, link: String) { fun openLinkFromHref(context: Context, fragmentManager: FragmentManager, link: String, forceDefaultOpen: Boolean = false) {
val resolveInfoList = getResolveInfo(context, link) val resolveInfoList = getResolveInfo(context, link)
if (resolveInfoList.isEmpty()) { if (resolveInfoList.isEmpty() || forceDefaultOpen) {
try { try {
context.startActivity(getResolveIntent(link)) context.startActivity(getResolveIntent(link))
} catch (e: Exception) { } catch (e: Exception) {

View File

@ -124,7 +124,7 @@ class AboutActivity : BaseActivity() {
} }
companion object { companion object {
private const val DONATE_URL = "https://github.com/libre-tube/LibreTube#donate" const val DONATE_URL = "https://github.com/libre-tube/LibreTube#donate"
private const val WEBSITE_URL = "https://libretube.dev" private const val WEBSITE_URL = "https://libretube.dev"
private const val GITHUB_URL = "https://github.com/libre-tube/LibreTube" private const val GITHUB_URL = "https://github.com/libre-tube/LibreTube"
private const val PIPED_GITHUB_URL = "https://github.com/TeamPiped/Piped" private const val PIPED_GITHUB_URL = "https://github.com/TeamPiped/Piped"

View File

@ -441,6 +441,16 @@ class MainActivity : BaseActivity() {
true true
} }
R.id.action_donate -> {
IntentHelper.openLinkFromHref(
this,
supportFragmentManager,
AboutActivity.DONATE_URL,
forceDefaultOpen = true
)
true
}
else -> super.onOptionsItemSelected(item) else -> super.onOptionsItemSelected(item)
} }
} }

View File

@ -20,6 +20,11 @@
android:title="@string/help" android:title="@string/help"
app:showAsAction="never" /> app:showAsAction="never" />
<item
android:id="@+id/action_donate"
android:title="@string/donate"
app:showAsAction="never" />
<item <item
android:id="@+id/action_about" android:id="@+id/action_about"
android:title="@string/about" android:title="@string/about"