mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-27 15:30:31 +05:30
Merge pull request #2939 from Bnyro/master
[Help & About] UI improvements and cleanup
This commit is contained in:
commit
7bd4d03701
@ -0,0 +1,13 @@
|
||||
package com.github.libretube.helpers
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
|
||||
object IntentHelper {
|
||||
fun openLinkFromHref(context: Context, link: String) {
|
||||
val uri = Uri.parse(link)
|
||||
val launchIntent = Intent(Intent.ACTION_VIEW).setData(uri)
|
||||
context.startActivity(launchIntent)
|
||||
}
|
||||
}
|
@ -4,7 +4,6 @@ import android.content.ClipData
|
||||
import android.content.ClipboardManager
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import androidx.core.text.HtmlCompat
|
||||
@ -16,7 +15,9 @@ import com.github.libretube.constants.PIPED_GITHUB_URL
|
||||
import com.github.libretube.constants.WEBLATE_URL
|
||||
import com.github.libretube.constants.WEBSITE_URL
|
||||
import com.github.libretube.databinding.ActivityAboutBinding
|
||||
import com.github.libretube.helpers.IntentHelper
|
||||
import com.github.libretube.ui.base.BaseActivity
|
||||
import com.google.android.material.card.MaterialCardView
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
|
||||
@ -34,7 +35,7 @@ class AboutActivity : BaseActivity() {
|
||||
}
|
||||
|
||||
binding.appIcon.setOnClickListener {
|
||||
val sendIntent: Intent = Intent().apply {
|
||||
val sendIntent = Intent().apply {
|
||||
action = Intent.ACTION_SEND
|
||||
putExtra(Intent.EXTRA_TEXT, GITHUB_URL)
|
||||
type = "text/plain"
|
||||
@ -44,37 +45,10 @@ class AboutActivity : BaseActivity() {
|
||||
startActivity(shareIntent)
|
||||
}
|
||||
|
||||
binding.website.setOnClickListener {
|
||||
openLinkFromHref(WEBSITE_URL)
|
||||
}
|
||||
binding.website.setOnLongClickListener {
|
||||
onLongClick(WEBSITE_URL)
|
||||
true
|
||||
}
|
||||
|
||||
binding.piped.setOnClickListener {
|
||||
openLinkFromHref(PIPED_GITHUB_URL)
|
||||
}
|
||||
binding.piped.setOnLongClickListener {
|
||||
onLongClick(PIPED_GITHUB_URL)
|
||||
true
|
||||
}
|
||||
|
||||
binding.translate.setOnClickListener {
|
||||
openLinkFromHref(WEBLATE_URL)
|
||||
}
|
||||
binding.translate.setOnLongClickListener {
|
||||
onLongClick(WEBLATE_URL)
|
||||
true
|
||||
}
|
||||
|
||||
binding.github.setOnClickListener {
|
||||
openLinkFromHref(GITHUB_URL)
|
||||
}
|
||||
binding.github.setOnLongClickListener {
|
||||
onLongClick(GITHUB_URL)
|
||||
true
|
||||
}
|
||||
setupCard(binding.website, WEBSITE_URL)
|
||||
setupCard(binding.piped, PIPED_GITHUB_URL)
|
||||
setupCard(binding.translate, WEBLATE_URL)
|
||||
setupCard(binding.github, GITHUB_URL)
|
||||
|
||||
binding.license.setOnClickListener {
|
||||
showLicense()
|
||||
@ -89,10 +63,14 @@ class AboutActivity : BaseActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun openLinkFromHref(link: String) {
|
||||
val uri = Uri.parse(link)
|
||||
val intent = Intent(Intent.ACTION_VIEW).setData(uri)
|
||||
startActivity(intent)
|
||||
private fun setupCard(card: MaterialCardView, link: String) {
|
||||
card.setOnClickListener {
|
||||
IntentHelper.openLinkFromHref(this, link)
|
||||
}
|
||||
card.setOnLongClickListener {
|
||||
onLongClick(link)
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
private fun onLongClick(href: String) {
|
||||
@ -108,7 +86,7 @@ class AboutActivity : BaseActivity() {
|
||||
Snackbar.LENGTH_LONG
|
||||
)
|
||||
.setAction(R.string.open_copied) {
|
||||
openLinkFromHref(href)
|
||||
IntentHelper.openLinkFromHref(this, href)
|
||||
}
|
||||
.setAnimationMode(Snackbar.ANIMATION_MODE_FADE)
|
||||
.show()
|
||||
|
@ -1,7 +1,5 @@
|
||||
package com.github.libretube.ui.activities
|
||||
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import com.github.libretube.constants.DISCORD_URL
|
||||
import com.github.libretube.constants.FAQ_URL
|
||||
@ -10,7 +8,9 @@ import com.github.libretube.constants.MATRIX_URL
|
||||
import com.github.libretube.constants.REDDIT_URL
|
||||
import com.github.libretube.constants.TELEGRAM_URL
|
||||
import com.github.libretube.databinding.ActivityHelpBinding
|
||||
import com.github.libretube.helpers.IntentHelper
|
||||
import com.github.libretube.ui.base.BaseActivity
|
||||
import com.google.android.material.card.MaterialCardView
|
||||
|
||||
class HelpActivity : BaseActivity() {
|
||||
private lateinit var binding: ActivityHelpBinding
|
||||
@ -25,34 +25,17 @@ class HelpActivity : BaseActivity() {
|
||||
onBackPressedDispatcher.onBackPressed()
|
||||
}
|
||||
|
||||
binding.faq.setOnClickListener {
|
||||
openLinkFromHref(FAQ_URL)
|
||||
}
|
||||
|
||||
binding.matrix.setOnClickListener {
|
||||
openLinkFromHref(MATRIX_URL)
|
||||
}
|
||||
|
||||
binding.telegram.setOnClickListener {
|
||||
openLinkFromHref(TELEGRAM_URL)
|
||||
}
|
||||
|
||||
binding.discord.setOnClickListener {
|
||||
openLinkFromHref(DISCORD_URL)
|
||||
}
|
||||
|
||||
binding.reddit.setOnClickListener {
|
||||
openLinkFromHref(REDDIT_URL)
|
||||
}
|
||||
|
||||
binding.mastodon.setOnClickListener {
|
||||
openLinkFromHref(MASTODON_URL)
|
||||
}
|
||||
setupCard(binding.faq, FAQ_URL)
|
||||
setupCard(binding.matrix, MATRIX_URL)
|
||||
setupCard(binding.mastodon, MASTODON_URL)
|
||||
setupCard(binding.telegram, TELEGRAM_URL)
|
||||
setupCard(binding.discord, DISCORD_URL)
|
||||
setupCard(binding.reddit, REDDIT_URL)
|
||||
}
|
||||
|
||||
private fun openLinkFromHref(link: String) {
|
||||
val uri = Uri.parse(link)
|
||||
val intent = Intent(Intent.ACTION_VIEW).setData(uri)
|
||||
startActivity(intent)
|
||||
private fun setupCard(card: MaterialCardView, link: String) {
|
||||
card.setOnClickListener {
|
||||
IntentHelper.openLinkFromHref(this, link)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
@ -16,14 +17,15 @@
|
||||
app:navigationIcon="?homeAsUpIndicator"
|
||||
app:title="@string/about" />
|
||||
|
||||
<com.google.android.material.imageview.ShapeableImageView
|
||||
android:id="@+id/appIcon"
|
||||
android:layout_width="90dp"
|
||||
android:layout_height="90dp"
|
||||
<ImageView
|
||||
android:id="@+id/app_icon"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="120dp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="30dp"
|
||||
android:src="@mipmap/ic_launcher_round"
|
||||
app:shapeAppearance="@style/CircleImageView" />
|
||||
android:src="@drawable/ic_launcher_lockscreen"
|
||||
app:tint="?attr/colorSecondary"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -15,16 +15,17 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:navigationIcon="?homeAsUpIndicator"
|
||||
app:title="@string/community" />
|
||||
app:title="@string/help" />
|
||||
|
||||
<com.google.android.material.imageview.ShapeableImageView
|
||||
android:layout_width="90dp"
|
||||
android:layout_height="90dp"
|
||||
<ImageView
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="120dp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="30dp"
|
||||
android:layout_marginBottom="40dp"
|
||||
android:src="@mipmap/ic_launcher_round"
|
||||
app:shapeAppearance="@style/CircleImageView" />
|
||||
android:src="@drawable/ic_launcher_lockscreen"
|
||||
app:tint="?attr/colorSecondary"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:id="@+id/faq"
|
||||
|
@ -39,8 +39,8 @@
|
||||
<item name="android:drawablePadding">20dp</item>
|
||||
<item name="android:paddingStart">15dp</item>
|
||||
<item name="android:paddingEnd">15dp</item>
|
||||
<item name="android:paddingTop">10dp</item>
|
||||
<item name="android:paddingBottom">10dp</item>
|
||||
<item name="android:paddingTop">15dp</item>
|
||||
<item name="android:paddingBottom">15dp</item>
|
||||
</style>
|
||||
|
||||
<style name="CustomDialogButton" parent="@style/Widget.Material3.Button.TextButton">
|
||||
|
Loading…
x
Reference in New Issue
Block a user