2022-06-07 19:22:10 +05:30
|
|
|
package com.github.libretube.preferences
|
|
|
|
|
|
|
|
import android.content.Intent
|
|
|
|
import android.net.Uri
|
|
|
|
import android.os.Build
|
|
|
|
import android.os.Bundle
|
|
|
|
import android.text.Html
|
|
|
|
import android.view.LayoutInflater
|
|
|
|
import android.view.View
|
|
|
|
import android.view.ViewGroup
|
2022-06-09 13:32:34 +05:30
|
|
|
import android.widget.LinearLayout
|
2022-06-07 19:22:10 +05:30
|
|
|
import android.widget.TextView
|
|
|
|
import androidx.fragment.app.Fragment
|
|
|
|
import com.github.libretube.BuildConfig
|
|
|
|
import com.github.libretube.R
|
|
|
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
|
|
|
|
|
|
|
class AboutFragment : Fragment() {
|
|
|
|
override fun onCreateView(
|
|
|
|
inflater: LayoutInflater,
|
|
|
|
container: ViewGroup?,
|
|
|
|
savedInstanceState: Bundle?
|
|
|
|
): View? {
|
|
|
|
return inflater.inflate(R.layout.fragment_about, container, false)
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
|
|
super.onViewCreated(view, savedInstanceState)
|
2022-06-08 00:52:35 +05:30
|
|
|
val topBarText = activity?.findViewById<TextView>(R.id.topBar_textView)
|
|
|
|
topBarText?.text = getString(R.string.about)
|
|
|
|
|
2022-06-14 18:39:47 +05:30
|
|
|
val appVersion = view.findViewById<TextView>(R.id.app_version)
|
2022-06-07 19:22:10 +05:30
|
|
|
appVersion.text = BuildConfig.VERSION_NAME
|
2022-06-08 14:37:47 +05:30
|
|
|
|
2022-06-14 18:39:47 +05:30
|
|
|
val website = view.findViewById<LinearLayout>(R.id.website)
|
|
|
|
website.setOnClickListener {
|
2022-06-09 13:32:34 +05:30
|
|
|
openLinkFromHref("https://libre-tube.github.io/")
|
2022-06-07 19:22:10 +05:30
|
|
|
}
|
2022-06-14 18:39:47 +05:30
|
|
|
val authors = view.findViewById<LinearLayout>(R.id.authors)
|
|
|
|
authors.setOnClickListener {
|
2022-06-09 13:32:34 +05:30
|
|
|
openLinkFromHref("https://github.com/libre-tube/LibreTube/graphs/contributors")
|
|
|
|
}
|
2022-06-14 18:39:47 +05:30
|
|
|
val donate = view.findViewById<LinearLayout>(R.id.donate)
|
|
|
|
donate.setOnClickListener {
|
2022-06-09 13:32:34 +05:30
|
|
|
openLinkFromHref("https://libre-tube.github.io/#donate")
|
2022-06-07 19:22:10 +05:30
|
|
|
}
|
2022-06-14 18:39:47 +05:30
|
|
|
val contributing = view.findViewById<LinearLayout>(R.id.contributing)
|
|
|
|
contributing.setOnClickListener {
|
2022-06-09 13:32:34 +05:30
|
|
|
openLinkFromHref("https://github.com/libre-tube/LibreTube")
|
2022-06-07 19:22:10 +05:30
|
|
|
}
|
2022-06-09 13:32:34 +05:30
|
|
|
val license = view.findViewById<LinearLayout>(R.id.license)
|
2022-06-14 18:39:47 +05:30
|
|
|
license.setOnClickListener {
|
|
|
|
val licenseString = view.context.assets
|
2022-06-07 19:22:10 +05:30
|
|
|
.open("gpl3.html").bufferedReader().use {
|
|
|
|
it.readText()
|
|
|
|
}
|
2022-06-14 18:39:47 +05:30
|
|
|
val licenseHtml = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
|
|
|
Html.fromHtml(licenseString, 1)
|
|
|
|
} else {
|
|
|
|
Html.fromHtml(licenseString)
|
|
|
|
}
|
2022-06-07 19:22:10 +05:30
|
|
|
|
2022-06-14 18:39:47 +05:30
|
|
|
MaterialAlertDialogBuilder(view.context!!)
|
2022-06-07 19:22:10 +05:30
|
|
|
.setPositiveButton(getString(R.string.okay)) { _, _ -> }
|
|
|
|
.setMessage(licenseHtml)
|
|
|
|
.create()
|
|
|
|
.show()
|
|
|
|
}
|
|
|
|
}
|
2022-06-07 19:29:02 +05:30
|
|
|
|
2022-06-09 13:32:34 +05:30
|
|
|
private fun openLinkFromHref(link: String) {
|
2022-06-07 19:22:10 +05:30
|
|
|
val uri = Uri.parse(link)
|
|
|
|
val intent = Intent(Intent.ACTION_VIEW).setData(uri)
|
|
|
|
startActivity(intent)
|
|
|
|
}
|
|
|
|
}
|