mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-01-06 01:20:29 +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)
|
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) {
|
||||||
|
@ -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"
|
||||||
|
@ -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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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"
|
||||||
|
Loading…
Reference in New Issue
Block a user