mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-13 22:00:30 +05:30
Merge pull request #6386 from Bnyro/master
refactor: add donation button to action menu
This commit is contained in:
commit
7c7b109594
@ -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)
|
||||
|
||||
if (resolveInfoList.isEmpty()) {
|
||||
if (resolveInfoList.isEmpty() || forceDefaultOpen) {
|
||||
try {
|
||||
context.startActivity(getResolveIntent(link))
|
||||
} catch (e: Exception) {
|
||||
|
@ -124,7 +124,7 @@ class AboutActivity : BaseActivity() {
|
||||
}
|
||||
|
||||
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 GITHUB_URL = "https://github.com/libre-tube/LibreTube"
|
||||
private const val PIPED_GITHUB_URL = "https://github.com/TeamPiped/Piped"
|
||||
|
@ -441,6 +441,16 @@ class MainActivity : BaseActivity() {
|
||||
true
|
||||
}
|
||||
|
||||
R.id.action_donate -> {
|
||||
IntentHelper.openLinkFromHref(
|
||||
this,
|
||||
supportFragmentManager,
|
||||
AboutActivity.DONATE_URL,
|
||||
forceDefaultOpen = true
|
||||
)
|
||||
true
|
||||
}
|
||||
|
||||
else -> super.onOptionsItemSelected(item)
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,11 @@
|
||||
android:title="@string/help"
|
||||
app:showAsAction="never" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_donate"
|
||||
android:title="@string/donate"
|
||||
app:showAsAction="never" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_about"
|
||||
android:title="@string/about"
|
||||
|
Loading…
Reference in New Issue
Block a user