mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-27 07:20:30 +05:30
refactor: re-use app icon header in about, welcome and help activity
This commit is contained in:
parent
8880305147
commit
1da7704ca2
@ -1,13 +1,11 @@
|
||||
package com.github.libretube.ui.activities
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Intent
|
||||
import android.content.res.Resources
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import androidx.core.text.HtmlCompat
|
||||
import androidx.core.text.parseAsHtml
|
||||
import com.github.libretube.BuildConfig
|
||||
import com.github.libretube.R
|
||||
import com.github.libretube.databinding.ActivityAboutBinding
|
||||
import com.github.libretube.helpers.ClipboardHelper
|
||||
@ -31,19 +29,6 @@ class AboutActivity : BaseActivity() {
|
||||
onBackPressedDispatcher.onBackPressed()
|
||||
}
|
||||
|
||||
binding.appIcon.setOnClickListener {
|
||||
val sendIntent = Intent(Intent.ACTION_SEND)
|
||||
.putExtra(Intent.EXTRA_TEXT, GITHUB_URL)
|
||||
.setType("text/plain")
|
||||
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, notify = true)
|
||||
}
|
||||
|
||||
setupCard(binding.donate, DONATE_URL)
|
||||
setupCard(binding.website, WEBSITE_URL)
|
||||
setupCard(binding.piped, PIPED_GITHUB_URL)
|
||||
@ -126,7 +111,7 @@ class AboutActivity : BaseActivity() {
|
||||
companion object {
|
||||
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"
|
||||
const val GITHUB_URL = "https://github.com/libre-tube/LibreTube"
|
||||
private const val PIPED_GITHUB_URL = "https://github.com/TeamPiped/Piped"
|
||||
private const val WEBLATE_URL = "https://hosted.weblate.org/projects/libretube/libretube/"
|
||||
private const val LICENSE_URL = "https://gnu.org/"
|
||||
|
@ -112,7 +112,7 @@ class MainActivity : BaseActivity() {
|
||||
|
||||
val isAppConfigured = PreferenceHelper.getBoolean(PreferenceKeys.LOCAL_FEED_EXTRACTION, false) ||
|
||||
PreferenceHelper.getString(PreferenceKeys.FETCH_INSTANCE, "").isNotEmpty()
|
||||
if (!isAppConfigured) {
|
||||
if (isAppConfigured) {
|
||||
val welcomeIntent = Intent(this, WelcomeActivity::class.java)
|
||||
startActivity(welcomeIntent)
|
||||
finish()
|
||||
|
@ -0,0 +1,32 @@
|
||||
package com.github.libretube.ui.views
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.widget.LinearLayout
|
||||
import com.github.libretube.BuildConfig
|
||||
import com.github.libretube.databinding.AppIconHeaderBinding
|
||||
import com.github.libretube.helpers.ClipboardHelper
|
||||
import com.github.libretube.ui.activities.AboutActivity.Companion.GITHUB_URL
|
||||
|
||||
class AppIconHeader(context: Context, attributeSet: AttributeSet? = null) :
|
||||
LinearLayout(context, attributeSet) {
|
||||
val binding = AppIconHeaderBinding.inflate(LayoutInflater.from(context), this, true)
|
||||
|
||||
init {
|
||||
val versionText = "${BuildConfig.VERSION_NAME} (${BuildConfig.VERSION_CODE})"
|
||||
binding.versionTv.text = versionText
|
||||
binding.versionCard.setOnClickListener {
|
||||
ClipboardHelper.save(context, text = versionText, notify = true)
|
||||
}
|
||||
|
||||
binding.appIcon.setOnClickListener {
|
||||
val sendIntent = Intent(Intent.ACTION_SEND)
|
||||
.putExtra(Intent.EXTRA_TEXT, GITHUB_URL)
|
||||
.setType("text/plain")
|
||||
|
||||
context.startActivity(Intent.createChooser(sendIntent, null))
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
<?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">
|
||||
|
||||
@ -17,51 +16,9 @@
|
||||
app:navigationIcon="?homeAsUpIndicator"
|
||||
app:title="@string/about" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/app_icon"
|
||||
android:layout_width="110dp"
|
||||
android:layout_height="110dp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="30dp"
|
||||
android:src="@drawable/ic_launcher_lockscreen"
|
||||
app:tint="?attr/colorSecondary"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
<RelativeLayout
|
||||
<com.github.libretube.ui.views.AppIconHeader
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginBottom="40dp">
|
||||
|
||||
<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>
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:id="@+id/donate"
|
||||
|
@ -17,15 +17,9 @@
|
||||
app:navigationIcon="?homeAsUpIndicator"
|
||||
app:title="@string/help" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="120dp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="30dp"
|
||||
android:layout_marginBottom="40dp"
|
||||
android:src="@drawable/ic_launcher_lockscreen"
|
||||
app:tint="?attr/colorSecondary"
|
||||
tools:ignore="ContentDescription" />
|
||||
<com.github.libretube.ui.views.AppIconHeader
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:id="@+id/faq"
|
||||
|
@ -19,33 +19,10 @@
|
||||
app:expandedTitleTextColor="@android:color/transparent"
|
||||
app:layout_scrollFlags="scroll|exitUntilCollapsed">
|
||||
|
||||
<LinearLayout
|
||||
<com.github.libretube.ui.views.AppIconHeader
|
||||
android:paddingTop="30dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="50dp"
|
||||
android:paddingBottom="20dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/app_icon"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="120dp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginBottom="15dp"
|
||||
android:src="@drawable/ic_launcher_lockscreen"
|
||||
app:tint="?attr/colorSecondary"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginHorizontal="20dp"
|
||||
android:layout_marginVertical="16dp"
|
||||
android:text="@string/welcome"
|
||||
android:textSize="18sp" />
|
||||
|
||||
</LinearLayout>
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
android:id="@+id/toolbar"
|
||||
|
55
app/src/main/res/layout/app_icon_header.xml
Normal file
55
app/src/main/res/layout/app_icon_header.xml
Normal file
@ -0,0 +1,55 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/app_icon"
|
||||
android:layout_width="110dp"
|
||||
android:layout_height="110dp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="30dp"
|
||||
android:src="@drawable/ic_launcher_lockscreen"
|
||||
app:tint="?attr/colorSecondary"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginBottom="40dp">
|
||||
|
||||
<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>
|
||||
|
||||
</LinearLayout>
|
Loading…
x
Reference in New Issue
Block a user