about fragment refactor

This commit is contained in:
Bnyro 2022-06-09 10:02:34 +02:00
parent 8712aa4efe
commit 20f4572313
3 changed files with 94 additions and 134 deletions

View File

@ -8,12 +8,12 @@ import android.text.Html
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.LinearLayout
import android.widget.TextView import android.widget.TextView
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import com.github.libretube.BuildConfig import com.github.libretube.BuildConfig
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.util.checkUpdate import com.github.libretube.util.checkUpdate
import com.google.android.material.card.MaterialCardView
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder
class AboutFragment : Fragment() { class AboutFragment : Fragment() {
@ -33,19 +33,23 @@ class AboutFragment : Fragment() {
val appVersion = view?.findViewById<TextView>(R.id.app_version) val appVersion = view?.findViewById<TextView>(R.id.app_version)
appVersion.text = BuildConfig.VERSION_NAME appVersion.text = BuildConfig.VERSION_NAME
val website = view?.findViewById<MaterialCardView>(R.id.website) val website = view?.findViewById<LinearLayout>(R.id.website)
website?.setOnClickListener { website?.setOnClickListener {
openLink("https://libre-tube.github.io/") openLinkFromHref("https://libre-tube.github.io/")
} }
val donate = view?.findViewById<MaterialCardView>(R.id.donate) val authors = view?.findViewById<LinearLayout>(R.id.authors)
authors?.setOnClickListener {
openLinkFromHref("https://github.com/libre-tube/LibreTube/graphs/contributors")
}
val donate = view?.findViewById<LinearLayout>(R.id.donate)
donate?.setOnClickListener { donate?.setOnClickListener {
openLink("https://libre-tube.github.io/#donate") openLinkFromHref("https://libre-tube.github.io/#donate")
} }
val contributing = view?.findViewById<MaterialCardView>(R.id.contributing) val contributing = view?.findViewById<LinearLayout>(R.id.contributing)
contributing?.setOnClickListener { contributing?.setOnClickListener {
openLink("https://github.com/libre-tube/LibreTube") openLinkFromHref("https://github.com/libre-tube/LibreTube")
} }
val license = view.findViewById<MaterialCardView>(R.id.license) val license = view.findViewById<LinearLayout>(R.id.license)
license?.setOnClickListener { license?.setOnClickListener {
val licenseString = view?.context?.assets!! val licenseString = view?.context?.assets!!
.open("gpl3.html").bufferedReader().use { .open("gpl3.html").bufferedReader().use {
@ -61,13 +65,13 @@ class AboutFragment : Fragment() {
.show() .show()
true true
} }
val update = view.findViewById<MaterialCardView>(R.id.update) val update = view.findViewById<LinearLayout>(R.id.update)
update?.setOnClickListener { update?.setOnClickListener {
checkUpdate(childFragmentManager) checkUpdate(childFragmentManager)
} }
} }
private fun openLink(link: String) { private fun openLinkFromHref(link: String) {
val uri = Uri.parse(link) val uri = Uri.parse(link)
val intent = Intent(Intent.ACTION_VIEW).setData(uri) val intent = Intent(Intent.ACTION_VIEW).setData(uri)
startActivity(intent) startActivity(intent)

View File

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
@ -35,170 +34,125 @@
android:layout_marginBottom="30dp" android:layout_marginBottom="30dp"
android:textSize="18sp" /> android:textSize="18sp" />
<com.google.android.material.card.MaterialCardView <LinearLayout
android:id="@+id/website" android:id="@+id/website"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp" android:orientation="vertical"
android:layout_marginBottom="16dp" android:padding="10dp">
android:padding="20dp"
app:cardCornerRadius="16dp">
<LinearLayout <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:orientation="vertical"> android:text="@string/website"
android:textStyle="bold" />
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginHorizontal="20dp" android:text="@string/website_summary" />
android:layout_marginTop="10dp"
android:text="@string/website"
android:textStyle="bold" />
<TextView </LinearLayout>
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginHorizontal="20dp"
android:layout_marginBottom="10dp"
android:text="@string/website_summary" />
</LinearLayout> <LinearLayout
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.card.MaterialCardView
android:id="@+id/contributing" android:id="@+id/contributing"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp" android:orientation="vertical"
android:layout_marginBottom="16dp" android:padding="10dp">
android:padding="20dp"
app:cardCornerRadius="16dp">
<LinearLayout <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:orientation="vertical"> android:text="@string/contributing"
android:textStyle="bold" />
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginHorizontal="20dp" android:text="@string/contributing_summary" />
android:layout_marginTop="10dp"
android:text="@string/contributing"
android:textStyle="bold" />
<TextView </LinearLayout>
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginHorizontal="20dp"
android:layout_marginBottom="10dp"
android:text="@string/contributing_summary" />
</LinearLayout> <LinearLayout
android:id="@+id/authors"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dp">
</com.google.android.material.card.MaterialCardView> <TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/authors"
android:textStyle="bold" />
<com.google.android.material.card.MaterialCardView <TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/authors_summary" />
</LinearLayout>
<LinearLayout
android:id="@+id/donate" android:id="@+id/donate"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp" android:orientation="vertical"
android:layout_marginBottom="16dp" android:padding="10dp">
android:padding="20dp"
app:cardCornerRadius="16dp">
<LinearLayout <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:orientation="vertical"> android:text="@string/donate"
android:textStyle="bold" />
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginHorizontal="20dp" android:text="@string/donate_summary" />
android:layout_marginTop="10dp"
android:text="@string/donate"
android:textStyle="bold" />
<TextView </LinearLayout>
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginHorizontal="20dp"
android:layout_marginBottom="10dp"
android:text="@string/donate_summary" />
</LinearLayout> <LinearLayout
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.card.MaterialCardView
android:id="@+id/license" android:id="@+id/license"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp" android:orientation="vertical"
android:layout_marginBottom="16dp" android:padding="10dp">
android:padding="20dp"
app:cardCornerRadius="16dp">
<LinearLayout <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:orientation="vertical"> android:text="@string/license"
android:textStyle="bold" />
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginHorizontal="20dp" android:text="@string/license_summary" />
android:layout_marginTop="10dp"
android:text="@string/license"
android:textStyle="bold" />
<TextView </LinearLayout>
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginHorizontal="20dp"
android:layout_marginBottom="10dp"
android:text="@string/license_summary" />
</LinearLayout> <LinearLayout
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.card.MaterialCardView
android:id="@+id/update" android:id="@+id/update"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp" android:orientation="vertical"
android:layout_marginBottom="20dp" android:padding="10dp">
android:padding="20dp"
app:cardCornerRadius="16dp">
<LinearLayout <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:orientation="vertical"> android:text="@string/update"
android:textStyle="bold" />
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginHorizontal="20dp" android:text="@string/update_summary" />
android:layout_marginTop="10dp"
android:text="@string/update"
android:textStyle="bold" />
<TextView </LinearLayout>
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginHorizontal="20dp"
android:layout_marginBottom="10dp"
android:text="@string/update_summary" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
</LinearLayout> </LinearLayout>

View File

@ -142,4 +142,6 @@
<string name="advanced_summary">Player, Downloads, History</string> <string name="advanced_summary">Player, Downloads, History</string>
<string name="live">Live</string> <string name="live">Live</string>
<string name="no_replies">This comment has no replies.</string> <string name="no_replies">This comment has no replies.</string>
<string name="authors">Authors</string>
<string name="authors_summary">Find out who\'s behind Team LibreTube and does the magic.</string>
</resources> </resources>