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
|
|
|
|
import androidx.fragment.app.Fragment
|
2022-07-01 20:24:20 +05:30
|
|
|
import com.github.libretube.util.AUTHORS_URL
|
|
|
|
import com.github.libretube.util.CONTRIBUTING_URL
|
|
|
|
import com.github.libretube.util.DONATE_URL
|
|
|
|
import com.github.libretube.util.PIPED_GITHUB_URL
|
2022-06-07 19:22:10 +05:30
|
|
|
import com.github.libretube.R
|
2022-07-01 20:24:20 +05:30
|
|
|
import com.github.libretube.activities.SettingsActivity
|
|
|
|
import com.github.libretube.util.WEBSITE_URL
|
2022-07-01 13:59:00 +05:30
|
|
|
import com.github.libretube.databinding.FragmentAboutBinding
|
2022-06-07 19:22:10 +05:30
|
|
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
|
|
|
|
|
|
|
class AboutFragment : Fragment() {
|
2022-07-01 13:59:00 +05:30
|
|
|
private lateinit var binding: FragmentAboutBinding
|
|
|
|
|
2022-06-07 19:22:10 +05:30
|
|
|
override fun onCreateView(
|
|
|
|
inflater: LayoutInflater,
|
|
|
|
container: ViewGroup?,
|
|
|
|
savedInstanceState: Bundle?
|
2022-07-01 13:59:00 +05:30
|
|
|
): View {
|
|
|
|
binding = FragmentAboutBinding.inflate(layoutInflater)
|
|
|
|
return binding.root
|
2022-06-07 19:22:10 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
|
|
super.onViewCreated(view, savedInstanceState)
|
2022-07-01 14:00:29 +05:30
|
|
|
val settingsActivity = activity as SettingsActivity
|
|
|
|
settingsActivity.binding.topBarTextView.text = getString(R.string.about)
|
2022-06-08 00:52:35 +05:30
|
|
|
|
2022-07-01 14:00:29 +05:30
|
|
|
binding.website.setOnClickListener {
|
2022-06-14 22:38:02 +05:30
|
|
|
openLinkFromHref(WEBSITE_URL)
|
2022-06-07 19:22:10 +05:30
|
|
|
}
|
2022-07-01 14:00:29 +05:30
|
|
|
binding.authors.setOnClickListener {
|
2022-06-14 22:38:02 +05:30
|
|
|
openLinkFromHref(AUTHORS_URL)
|
2022-06-09 13:32:34 +05:30
|
|
|
}
|
2022-07-01 14:00:29 +05:30
|
|
|
binding.piped.setOnClickListener {
|
2022-06-19 01:47:47 +05:30
|
|
|
openLinkFromHref(PIPED_GITHUB_URL)
|
|
|
|
}
|
2022-07-01 14:00:29 +05:30
|
|
|
binding.donate.setOnClickListener {
|
2022-06-14 22:38:02 +05:30
|
|
|
openLinkFromHref(DONATE_URL)
|
2022-06-07 19:22:10 +05:30
|
|
|
}
|
2022-07-01 14:00:29 +05:30
|
|
|
binding.contributing.setOnClickListener {
|
2022-06-14 22:38:02 +05:30
|
|
|
openLinkFromHref(CONTRIBUTING_URL)
|
2022-06-07 19:22:10 +05:30
|
|
|
}
|
2022-07-01 14:00:29 +05:30
|
|
|
binding.license.setOnClickListener {
|
2022-06-14 18:39:47 +05:30
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|