mirror of
https://github.com/mediathekview/zapp.git
synced 2024-09-20 12:22:15 +02:00
Add changelog activity
This commit is contained in:
parent
cb99d2ff86
commit
848af7b47d
@ -58,6 +58,11 @@
|
||||
android:screenOrientation="landscape"
|
||||
android:theme="@style/LeanbackAppTheme" />
|
||||
|
||||
<activity
|
||||
android:name=".tv.changelog.ChangelogActivity"
|
||||
android:screenOrientation="landscape"
|
||||
android:theme="@style/LeanbackAppTheme" />
|
||||
|
||||
<activity
|
||||
android:name=".tv.error.CrashActivity"
|
||||
android:excludeFromRecents="true"
|
||||
|
@ -6,13 +6,11 @@ import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import de.christinecoenen.code.zapp.app.livestream.ui.list.adapter.ListItemListener
|
||||
import de.christinecoenen.code.zapp.databinding.TvFragmentAboutBinding
|
||||
import de.christinecoenen.code.zapp.models.channels.ChannelModel
|
||||
import de.christinecoenen.code.zapp.tv.player.PlayerActivity
|
||||
import de.christinecoenen.code.zapp.tv.changelog.ChangelogActivity
|
||||
|
||||
|
||||
class AboutFragment : Fragment(), ListItemListener {
|
||||
class AboutFragment : Fragment(), AboutItemListener {
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
@ -21,18 +19,14 @@ class AboutFragment : Fragment(), ListItemListener {
|
||||
): View {
|
||||
val binding = TvFragmentAboutBinding.inflate(inflater, container, false)
|
||||
|
||||
binding.grid.adapter = AboutListAdapter()
|
||||
binding.grid.adapter = AboutListAdapter(this)
|
||||
binding.grid.layoutManager = GridLayoutManager(requireContext(), 2)
|
||||
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onItemClick(channel: ChannelModel) {
|
||||
val intent = PlayerActivity.getStartIntent(requireContext(), channel)
|
||||
override fun onclick(item: AboutItem) {
|
||||
val intent = ChangelogActivity.getStartIntent(requireContext())
|
||||
startActivity(intent)
|
||||
}
|
||||
|
||||
override fun onItemLongClick(channel: ChannelModel, view: View) {
|
||||
// no action
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,7 @@
|
||||
package de.christinecoenen.code.zapp.tv.about
|
||||
|
||||
interface AboutItemListener {
|
||||
|
||||
fun onclick(item: AboutItem)
|
||||
|
||||
}
|
@ -6,7 +6,9 @@ import androidx.recyclerview.widget.RecyclerView
|
||||
import de.christinecoenen.code.zapp.R
|
||||
import de.christinecoenen.code.zapp.databinding.TvAboutItemBinding
|
||||
|
||||
class AboutListAdapter : RecyclerView.Adapter<AboutViewViewHolder>() {
|
||||
class AboutListAdapter(
|
||||
private val listener: AboutItemListener
|
||||
) : RecyclerView.Adapter<AboutViewViewHolder>() {
|
||||
|
||||
private val aboutItems = listOf(
|
||||
AboutItem(R.string.activity_changelog_title, R.drawable.ic_sharp_format_list_bulleted_24),
|
||||
@ -16,7 +18,7 @@ class AboutListAdapter : RecyclerView.Adapter<AboutViewViewHolder>() {
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): AboutViewViewHolder {
|
||||
val layoutInflater = LayoutInflater.from(parent.context)
|
||||
val binding = TvAboutItemBinding.inflate(layoutInflater, parent, false)
|
||||
return AboutViewViewHolder(binding)
|
||||
return AboutViewViewHolder(binding, listener)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: AboutViewViewHolder, position: Int) {
|
||||
|
@ -4,10 +4,20 @@ import androidx.recyclerview.widget.RecyclerView
|
||||
import de.christinecoenen.code.zapp.databinding.TvAboutItemBinding
|
||||
|
||||
class AboutViewViewHolder(
|
||||
private val binding: TvAboutItemBinding
|
||||
private val binding: TvAboutItemBinding,
|
||||
val listener: AboutItemListener
|
||||
) : RecyclerView.ViewHolder(binding.root) {
|
||||
|
||||
private var item: AboutItem? = null
|
||||
|
||||
init {
|
||||
binding.root.setOnClickListener {
|
||||
item?.let { listener.onclick(it) }
|
||||
}
|
||||
}
|
||||
|
||||
fun bind(item: AboutItem) {
|
||||
this.item = item
|
||||
binding.title.text = item.getTitle(binding.root.context)
|
||||
binding.icon.setImageResource(item.iconResId)
|
||||
}
|
||||
|
@ -0,0 +1,42 @@
|
||||
package de.christinecoenen.code.zapp.tv.changelog
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import de.christinecoenen.code.zapp.R
|
||||
import de.christinecoenen.code.zapp.databinding.TvActivityChangelogBinding
|
||||
import org.apache.commons.io.IOUtils
|
||||
import ru.noties.markwon.Markwon
|
||||
import timber.log.Timber
|
||||
import java.io.IOException
|
||||
import java.nio.charset.StandardCharsets
|
||||
|
||||
class ChangelogActivity : Activity() {
|
||||
|
||||
companion object {
|
||||
fun getStartIntent(context: Context?): Intent =
|
||||
Intent(context, ChangelogActivity::class.java)
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
val binding = TvActivityChangelogBinding.inflate(layoutInflater)
|
||||
|
||||
setContentView(binding.root)
|
||||
|
||||
try {
|
||||
resources.openRawResource(R.raw.changelog).use { inputStream ->
|
||||
val markdown = IOUtils.toString(inputStream, StandardCharsets.UTF_8)
|
||||
Markwon.setText(
|
||||
binding.txtChangelog,
|
||||
Markwon.markdown(this, markdown),
|
||||
null
|
||||
)
|
||||
}
|
||||
} catch (e: IOException) {
|
||||
Timber.e(e)
|
||||
}
|
||||
}
|
||||
}
|
35
app/src/main/res/layout/tv_activity_changelog.xml
Normal file
35
app/src/main/res/layout/tv_activity_changelog.xml
Normal file
@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout 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="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/headline"
|
||||
style="@style/TextAppearance.Leanback.Title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?colorPrimary"
|
||||
android:padding="16dp"
|
||||
android:text="@string/activity_changelog_title"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/headline"
|
||||
tools:context=".tv.changelog.ChangelogActivity">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txt_changelog"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="64dp"
|
||||
tools:text="Test 123" />
|
||||
|
||||
</ScrollView>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -8,7 +8,7 @@
|
||||
tools:deviceIds="tv">
|
||||
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/pizza_grid_fragment"
|
||||
android:id="@+id/main_fragment"
|
||||
android:name="de.christinecoenen.code.zapp.tv.main.MainFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
Loading…
Reference in New Issue
Block a user