Merge pull request #6269 from Bnyro/master

feat: improve about activity and device info dialog
This commit is contained in:
Bnyro 2024-07-23 17:52:12 +02:00 committed by GitHub
commit 5f4fc603fe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 55 additions and 14 deletions

View File

@ -1,10 +1,13 @@
package com.github.libretube.ui.activities package com.github.libretube.ui.activities
import android.annotation.SuppressLint
import android.content.Intent import android.content.Intent
import android.content.res.Resources
import android.os.Build import android.os.Build
import android.os.Bundle import android.os.Bundle
import androidx.core.text.HtmlCompat import androidx.core.text.HtmlCompat
import androidx.core.text.parseAsHtml import androidx.core.text.parseAsHtml
import com.github.libretube.BuildConfig
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.databinding.ActivityAboutBinding import com.github.libretube.databinding.ActivityAboutBinding
import com.github.libretube.helpers.ClipboardHelper import com.github.libretube.helpers.ClipboardHelper
@ -17,6 +20,7 @@ import com.google.android.material.snackbar.Snackbar
class AboutActivity : BaseActivity() { class AboutActivity : BaseActivity() {
private lateinit var binding: ActivityAboutBinding private lateinit var binding: ActivityAboutBinding
@SuppressLint("SetTextI18n")
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
@ -34,6 +38,12 @@ class AboutActivity : BaseActivity() {
startActivity(Intent.createChooser(sendIntent, null)) startActivity(Intent.createChooser(sendIntent, null))
} }
val versionText = "${BuildConfig.VERSION_NAME} (${BuildConfig.VERSION_CODE})"
binding.versionTv.text = versionText
binding.versionCard.setOnClickListener {
ClipboardHelper.save(this, text = versionText)
}
setupCard(binding.donate, DONATE_URL) setupCard(binding.donate, DONATE_URL)
setupCard(binding.website, WEBSITE_URL) setupCard(binding.website, WEBSITE_URL)
setupCard(binding.piped, PIPED_GITHUB_URL) setupCard(binding.piped, PIPED_GITHUB_URL)
@ -93,17 +103,22 @@ class AboutActivity : BaseActivity() {
} }
private fun showDeviceInfo() { private fun showDeviceInfo() {
val metrics = Resources.getSystem().displayMetrics
val text = "Manufacturer: ${Build.MANUFACTURER}\n" + val text = "Manufacturer: ${Build.MANUFACTURER}\n" +
"Model: ${Build.MODEL}\n" + "Board: ${Build.BOARD}\n" +
"SDK: ${Build.VERSION.SDK_INT}\n" + "Arch: ${Build.SUPPORTED_ABIS[0]}\n" +
"Board: ${Build.BOARD}\n" + "Android SDK: ${Build.VERSION.SDK_INT}\n" +
"OS: Android ${Build.VERSION.RELEASE}\n" + "OS: Android ${Build.VERSION.RELEASE}\n" +
"Arch: ${Build.SUPPORTED_ABIS[0]}\n" + "Display: ${metrics.widthPixels}x${metrics.heightPixels}\n" +
"Product: ${Build.PRODUCT}" "Font scale: ${Resources.getSystem().configuration.fontScale}"
MaterialAlertDialogBuilder(this) MaterialAlertDialogBuilder(this)
.setTitle(R.string.device_info) .setTitle(R.string.device_info)
.setMessage(text) .setMessage(text)
.setNegativeButton(R.string.copy_tooltip) { _, _ ->
ClipboardHelper.save(this@AboutActivity, text = text)
}
.setPositiveButton(R.string.okay, null) .setPositiveButton(R.string.okay, null)
.show() .show()
} }

View File

@ -27,17 +27,43 @@
app:tint="?attr/colorSecondary" app:tint="?attr/colorSecondary"
tools:ignore="ContentDescription" /> tools:ignore="ContentDescription" />
<TextView <RelativeLayout
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:layout_marginTop="20dp" android:layout_marginBottom="40dp">
android:layout_marginBottom="40dp"
android:text="@string/app_name"
android:textSize="24sp"
android:textStyle="bold" />
<com.google.android.material.card.MaterialCardView <TextView
android:id="@+id/app_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:text="@string/app_name"
android:textSize="24sp"
android:textStyle="bold" />
<com.google.android.material.card.MaterialCardView
android:id="@+id/version_card"
style="@style/Widget.Material3.CardView.Elevated"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="-40dp"
android:layout_toEndOf="@id/app_name">
<TextView
android:id="@+id/version_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="6dp"
android:layout_marginVertical="3dp"
tools:text="1.0.0 (99)" />
</com.google.android.material.card.MaterialCardView>
</RelativeLayout>
<com.google.android.material.card.MaterialCardView
android:id="@+id/donate" android:id="@+id/donate"
style="@style/AboutCard"> style="@style/AboutCard">