From 25ddc846bbe2207fbef668981372586dbfcdb24b Mon Sep 17 00:00:00 2001 From: lynxnb Date: Wed, 23 Feb 2022 18:09:27 +0100 Subject: [PATCH] Introduce new AppDialog base components --- .../adapter/appdialog/CheatsViewItem.kt | 99 ++++++++++++++ .../skyline/adapter/appdialog/DlcsViewItem.kt | 36 +++++ .../appdialog/DragIndicatorViewItem.kt | 26 ++++ .../adapter/appdialog/GameInfoViewItem.kt | 71 ++++++++++ .../adapter/appdialog/IssuesViewItem.kt | 70 ++++++++++ .../adapter/appdialog/NotesViewItem.kt | 58 ++++++++ .../adapter/appdialog/SavesViewItem.kt | 85 ++++++++++++ .../appdialog/SectionHeaderViewItem.kt | 42 ++++++ .../adapter/appdialog/UpdatesViewItem.kt | 38 ++++++ app/src/main/res/drawable/code_block.xml | 5 + app/src/main/res/drawable/dot_separator.xml | 8 ++ .../main/res/drawable/expand_indicator.xml | 10 ++ app/src/main/res/drawable/ic_download.xml | 10 ++ app/src/main/res/drawable/ic_open.xml | 12 +- app/src/main/res/drawable/ic_stop.xml | 10 ++ .../res/layout/app_dialog_cheats_item.xml | 100 ++++++++++++++ .../main/res/layout/app_dialog_dlcs_item.xml | 12 ++ .../res/layout/app_dialog_drag_indicator.xml | 14 ++ .../main/res/layout/app_dialog_game_info.xml | 127 ++++++++++++++++++ .../res/layout/app_dialog_issues_item.xml | 54 ++++++++ .../main/res/layout/app_dialog_notes_item.xml | 27 ++++ .../main/res/layout/app_dialog_saves_item.xml | 114 ++++++++++++++++ .../res/layout/app_dialog_section_header.xml | 43 ++++++ .../res/layout/app_dialog_updates_item.xml | 12 ++ app/src/main/res/values/dimens.xml | 5 + app/src/main/res/values/strings.xml | 14 ++ app/src/main/res/values/styles.xml | 10 +- 27 files changed, 1105 insertions(+), 7 deletions(-) create mode 100644 app/src/main/java/emu/skyline/adapter/appdialog/CheatsViewItem.kt create mode 100644 app/src/main/java/emu/skyline/adapter/appdialog/DlcsViewItem.kt create mode 100644 app/src/main/java/emu/skyline/adapter/appdialog/DragIndicatorViewItem.kt create mode 100644 app/src/main/java/emu/skyline/adapter/appdialog/GameInfoViewItem.kt create mode 100644 app/src/main/java/emu/skyline/adapter/appdialog/IssuesViewItem.kt create mode 100644 app/src/main/java/emu/skyline/adapter/appdialog/NotesViewItem.kt create mode 100644 app/src/main/java/emu/skyline/adapter/appdialog/SavesViewItem.kt create mode 100644 app/src/main/java/emu/skyline/adapter/appdialog/SectionHeaderViewItem.kt create mode 100644 app/src/main/java/emu/skyline/adapter/appdialog/UpdatesViewItem.kt create mode 100644 app/src/main/res/drawable/code_block.xml create mode 100644 app/src/main/res/drawable/dot_separator.xml create mode 100644 app/src/main/res/drawable/expand_indicator.xml create mode 100644 app/src/main/res/drawable/ic_download.xml create mode 100644 app/src/main/res/drawable/ic_stop.xml create mode 100644 app/src/main/res/layout/app_dialog_cheats_item.xml create mode 100644 app/src/main/res/layout/app_dialog_dlcs_item.xml create mode 100644 app/src/main/res/layout/app_dialog_drag_indicator.xml create mode 100644 app/src/main/res/layout/app_dialog_game_info.xml create mode 100644 app/src/main/res/layout/app_dialog_issues_item.xml create mode 100644 app/src/main/res/layout/app_dialog_notes_item.xml create mode 100644 app/src/main/res/layout/app_dialog_saves_item.xml create mode 100644 app/src/main/res/layout/app_dialog_section_header.xml create mode 100644 app/src/main/res/layout/app_dialog_updates_item.xml diff --git a/app/src/main/java/emu/skyline/adapter/appdialog/CheatsViewItem.kt b/app/src/main/java/emu/skyline/adapter/appdialog/CheatsViewItem.kt new file mode 100644 index 00000000..0c722ec5 --- /dev/null +++ b/app/src/main/java/emu/skyline/adapter/appdialog/CheatsViewItem.kt @@ -0,0 +1,99 @@ +/* + * SPDX-License-Identifier: MPL-2.0 + * Copyright © 2022 Skyline Team and Contributors (https://github.com/skyline-emu/) + */ + +package emu.skyline.adapter.appdialog + +import android.view.View +import android.view.ViewGroup +import android.view.ViewTreeObserver +import emu.skyline.adapter.GenericListItem +import emu.skyline.adapter.ViewBindingFactory +import emu.skyline.adapter.inflater +import emu.skyline.databinding.AppDialogCheatsItemBinding + +object AppDialogCheatsItemBindingFactory : ViewBindingFactory { + override fun createBinding(parent : ViewGroup) = AppDialogCheatsItemBinding.inflate(parent.inflater(), parent, false) +} + +class CheatsViewItem( + private val title : String, + private val author : String?, + private val description : String?, + private val code : String, + var isEnabled : Boolean, + private val onClick : ((item : CheatsViewItem, position : Int) -> Unit)? = null +) : GenericListItem() { + companion object { + const val MAX_LINES = 2 + } + + private var isExpandable : Boolean? = null + private var isExpanded = false + + override fun getViewBindingFactory() = AppDialogCheatsItemBindingFactory + + override fun bind(binding : AppDialogCheatsItemBinding, position : Int) { + binding.title.text = title + author?.let { + binding.author.text = author + binding.author.visibility = View.VISIBLE + } ?: run { binding.author.visibility = View.GONE } + description?.let { + binding.description.text = it + binding.description.visibility = View.VISIBLE + } ?: run { binding.description.visibility = View.GONE } + binding.code.text = code + binding.checkbox.isChecked = isEnabled + + handleExpand(binding, position) + + binding.checkbox.setOnCheckedChangeListener { _, isChecked : Boolean -> + isEnabled = isChecked + onClick?.invoke(this, position) + } + } + + private fun handleExpand(binding : AppDialogCheatsItemBinding, position : Int) { + val setupExpandButton = { + if (isExpandable == true) { + binding.expandButton.visibility = View.VISIBLE + binding.root.setOnClickListener { + isExpanded = !isExpanded + adapter?.notifyItemChanged(position) + } + } else { + binding.expandButton.visibility = View.GONE + } + } + + isExpandable ?: binding.root.viewTreeObserver.addOnPreDrawListener(object : ViewTreeObserver.OnPreDrawListener { + override fun onPreDraw() : Boolean { + isExpandable = binding.title.layout.getEllipsisCount(0) > 0 || + binding.author.layout.getEllipsisCount(0) > 0 || + binding.description.layout.getEllipsisCount(MAX_LINES - 1) > 0 || + code.isNotEmpty() + setupExpandButton.invoke() + binding.root.viewTreeObserver.removeOnPreDrawListener(this) + return true + } + }) + + if (isExpanded) { + binding.expandButton.rotation = 180F + binding.title.isSingleLine = false + binding.author.isSingleLine = false + binding.description.maxLines = Int.MAX_VALUE + binding.code.visibility = View.VISIBLE + } else { + binding.expandButton.rotation = 0F + binding.title.isSingleLine = true + binding.author.isSingleLine = true + binding.description.maxLines = MAX_LINES + binding.code.visibility = View.GONE + } + + setupExpandButton.invoke() + } +} diff --git a/app/src/main/java/emu/skyline/adapter/appdialog/DlcsViewItem.kt b/app/src/main/java/emu/skyline/adapter/appdialog/DlcsViewItem.kt new file mode 100644 index 00000000..546e8035 --- /dev/null +++ b/app/src/main/java/emu/skyline/adapter/appdialog/DlcsViewItem.kt @@ -0,0 +1,36 @@ +/* + * SPDX-License-Identifier: MPL-2.0 + * Copyright © 2022 Skyline Team and Contributors (https://github.com/skyline-emu/) + */ + +package emu.skyline.adapter.appdialog + +import android.view.View +import android.view.ViewGroup +import emu.skyline.adapter.GenericListItem +import emu.skyline.adapter.ViewBindingFactory +import emu.skyline.adapter.inflater +import emu.skyline.databinding.AppDialogDlcsItemBinding + +object AppDialogDlcsItemBindingFactory : ViewBindingFactory { + override fun createBinding(parent : ViewGroup) = AppDialogDlcsItemBinding.inflate(parent.inflater(), parent, false) +} + +class DlcsViewItem( + private val title : String, + var isEnabled : Boolean, + private val onClick : ((item : DlcsViewItem, position : Int) -> Unit)? = null +) : GenericListItem() { + override fun getViewBindingFactory() = AppDialogDlcsItemBindingFactory + + override fun bind(binding : AppDialogDlcsItemBinding, position : Int) { + binding.checkbox.text = title + binding.checkbox.isChecked = isEnabled + binding.checkbox.isSelected = true + + binding.checkbox.setOnCheckedChangeListener { _ : View, isChecked : Boolean -> + isEnabled = isChecked + onClick?.invoke(this, position) + } + } +} diff --git a/app/src/main/java/emu/skyline/adapter/appdialog/DragIndicatorViewItem.kt b/app/src/main/java/emu/skyline/adapter/appdialog/DragIndicatorViewItem.kt new file mode 100644 index 00000000..981ecc04 --- /dev/null +++ b/app/src/main/java/emu/skyline/adapter/appdialog/DragIndicatorViewItem.kt @@ -0,0 +1,26 @@ +/* + * SPDX-License-Identifier: MPL-2.0 + * Copyright © 2022 Skyline Team and Contributors (https://github.com/skyline-emu/) + */ + +package emu.skyline.adapter.appdialog + +import android.view.View +import android.view.ViewGroup +import com.google.android.material.bottomsheet.BottomSheetBehavior +import emu.skyline.adapter.GenericListItem +import emu.skyline.adapter.ViewBindingFactory +import emu.skyline.adapter.inflater +import emu.skyline.databinding.AppDialogDragIndicatorBinding + +object AppDialogDragIndicatorBindingFactory : ViewBindingFactory { + override fun createBinding(parent : ViewGroup) = AppDialogDragIndicatorBinding.inflate(parent.inflater(), parent, false) +} + +class DragIndicatorViewItem(private val behavior : BottomSheetBehavior) : GenericListItem() { + override fun getViewBindingFactory() = AppDialogDragIndicatorBindingFactory + + override fun bind(binding : AppDialogDragIndicatorBinding, position : Int) { + behavior.addBottomSheetCallback(binding.dragIndicator.callback) + } +} diff --git a/app/src/main/java/emu/skyline/adapter/appdialog/GameInfoViewItem.kt b/app/src/main/java/emu/skyline/adapter/appdialog/GameInfoViewItem.kt new file mode 100644 index 00000000..f1c5ad47 --- /dev/null +++ b/app/src/main/java/emu/skyline/adapter/appdialog/GameInfoViewItem.kt @@ -0,0 +1,71 @@ +/* + * SPDX-License-Identifier: MPL-2.0 + * Copyright © 2022 Skyline Team and Contributors (https://github.com/skyline-emu/) + */ + +package emu.skyline.adapter.appdialog + +import android.content.ComponentName +import android.content.Context +import android.content.Intent +import android.content.pm.ShortcutInfo +import android.content.pm.ShortcutManager +import android.graphics.drawable.Icon +import android.view.View +import android.view.ViewGroup +import androidx.core.content.getSystemService +import androidx.core.graphics.drawable.toBitmap +import emu.skyline.EmulationActivity +import emu.skyline.R +import emu.skyline.adapter.GenericListItem +import emu.skyline.adapter.ViewBindingFactory +import emu.skyline.adapter.inflater +import emu.skyline.data.AppItem +import emu.skyline.databinding.AppDialogGameInfoBinding +import emu.skyline.loader.LoaderResult + +object ControllerBindingFactory : ViewBindingFactory { + override fun createBinding(parent : ViewGroup) = AppDialogGameInfoBinding.inflate(parent.inflater(), parent, false) +} + +class GameInfoViewItem(private val context : Context, private val item : AppItem, private val testedVersion : String?, private val rating : Int?) : GenericListItem() { + override fun getViewBindingFactory() = ControllerBindingFactory + + override fun bind(binding : AppDialogGameInfoBinding, position : Int) { + val missingIcon = context.getDrawable(R.drawable.default_icon)!!.toBitmap(256, 256) + + binding.gameIcon.setImageBitmap(item.icon ?: missingIcon) + binding.gameTitle.text = item.title + binding.gameSubtitle.text = item.subTitle ?: item.loaderResultString(context) + // Make the title text view selected for marquee to work + binding.gameTitle.isSelected = true + binding.gameSubtitle.isSelected = true + + binding.flex.visibility = if (rating == null && testedVersion == null) View.INVISIBLE else View.VISIBLE + binding.ratingBar.rating = (rating ?: 0).toFloat() + binding.testedVersion.text = testedVersion?.let { context.getString(R.string.tested_on, it) } ?: context.getString(R.string.not_tested) + + binding.gamePlay.isEnabled = item.loaderResult == LoaderResult.Success + binding.gamePlay.setOnClickListener { + context.startActivity(Intent(context, EmulationActivity::class.java).apply { data = item.uri }) + } + + val shortcutManager = context.getSystemService()!! + binding.gamePin.isEnabled = shortcutManager.isRequestPinShortcutSupported + + binding.gamePin.setOnClickListener { + val info = ShortcutInfo.Builder(context, item.title) + info.setShortLabel(item.title) + info.setActivity(ComponentName(context, EmulationActivity::class.java)) + info.setIcon(Icon.createWithAdaptiveBitmap(item.icon ?: missingIcon)) + + val intent = Intent(context, EmulationActivity::class.java) + intent.data = item.uri + intent.action = Intent.ACTION_VIEW + + info.setIntent(intent) + + shortcutManager.requestPinShortcut(info.build(), null) + } + } +} diff --git a/app/src/main/java/emu/skyline/adapter/appdialog/IssuesViewItem.kt b/app/src/main/java/emu/skyline/adapter/appdialog/IssuesViewItem.kt new file mode 100644 index 00000000..150b93b9 --- /dev/null +++ b/app/src/main/java/emu/skyline/adapter/appdialog/IssuesViewItem.kt @@ -0,0 +1,70 @@ +/* + * SPDX-License-Identifier: MPL-2.0 + * Copyright © 2022 Skyline Team and Contributors (https://github.com/skyline-emu/) + */ + +package emu.skyline.adapter.appdialog + +import android.view.View +import android.view.ViewGroup +import android.view.ViewTreeObserver +import emu.skyline.adapter.GenericListItem +import emu.skyline.adapter.ViewBindingFactory +import emu.skyline.adapter.inflater +import emu.skyline.databinding.AppDialogIssuesItemBinding + +object AppDialogIssuesItemBindingFactory : ViewBindingFactory { + override fun createBinding(parent : ViewGroup) = AppDialogIssuesItemBinding.inflate(parent.inflater(), parent, false) +} + +class IssuesViewItem(private val title : String, private val description : String?) : GenericListItem() { + private var isExpandable : Boolean? = null + private var isExpanded = false + + override fun getViewBindingFactory() = AppDialogIssuesItemBindingFactory + + override fun bind(binding : AppDialogIssuesItemBinding, position : Int) { + binding.title.text = title + description?.let { + binding.description.text = it + binding.description.visibility = View.VISIBLE + } ?: run { binding.description.visibility = View.GONE } + + handleExpand(binding, position) + } + + private fun handleExpand(binding : AppDialogIssuesItemBinding, position : Int) { + val setupExpandButton = { + if (isExpandable == true) { + binding.expandButton.visibility = View.VISIBLE + binding.root.setOnClickListener { + isExpanded = !isExpanded + adapter?.notifyItemChanged(position) + } + } else { + binding.expandButton.visibility = View.GONE + } + } + + isExpandable ?: binding.root.viewTreeObserver.addOnPreDrawListener(object : ViewTreeObserver.OnPreDrawListener { + override fun onPreDraw() : Boolean { + isExpandable = binding.title.layout.getEllipsisCount(0) > 0 || description?.isNotEmpty() == true + setupExpandButton.invoke() + binding.root.viewTreeObserver.removeOnPreDrawListener(this) + return true + } + }) + + if (isExpanded) { + binding.expandButton.rotation = 180F + binding.title.isSingleLine = false + binding.description.visibility = View.VISIBLE + } else { + binding.expandButton.rotation = 0F + binding.title.isSingleLine = true + binding.description.visibility = View.GONE + } + + setupExpandButton.invoke() + } +} diff --git a/app/src/main/java/emu/skyline/adapter/appdialog/NotesViewItem.kt b/app/src/main/java/emu/skyline/adapter/appdialog/NotesViewItem.kt new file mode 100644 index 00000000..2e9c7a12 --- /dev/null +++ b/app/src/main/java/emu/skyline/adapter/appdialog/NotesViewItem.kt @@ -0,0 +1,58 @@ +/* + * SPDX-License-Identifier: MPL-2.0 + * Copyright © 2022 Skyline Team and Contributors (https://github.com/skyline-emu/) + */ + +package emu.skyline.adapter.appdialog + +import android.view.ViewGroup +import android.view.ViewTreeObserver +import emu.skyline.adapter.GenericListItem +import emu.skyline.adapter.ViewBindingFactory +import emu.skyline.adapter.inflater +import emu.skyline.databinding.AppDialogNotesItemBinding + +object AppDialogNotesItemBindingFactory : ViewBindingFactory { + override fun createBinding(parent : ViewGroup) = AppDialogNotesItemBinding.inflate(parent.inflater(), parent, false) +} + +class NotesViewItem(private val title : String) : GenericListItem() { + companion object { + const val MAX_LINES = 3 + } + + private var isExpandable : Boolean? = null + private var isExpanded = false + + override fun getViewBindingFactory() = AppDialogNotesItemBindingFactory + + override fun bind(binding : AppDialogNotesItemBinding, position : Int) { + binding.title.text = title + + handleExpand(binding, position) + } + + private fun handleExpand(binding : AppDialogNotesItemBinding, position : Int) { + val setupExpandButton = { + if (isExpandable == true) { + binding.root.setOnClickListener { + isExpanded = !isExpanded + adapter?.notifyItemChanged(position) + } + } + } + + isExpandable ?: binding.root.viewTreeObserver.addOnPreDrawListener(object : ViewTreeObserver.OnPreDrawListener { + override fun onPreDraw() : Boolean { + isExpandable = binding.title.layout.getEllipsisCount(MAX_LINES - 1) > 0 + setupExpandButton.invoke() + binding.root.viewTreeObserver.removeOnPreDrawListener(this) + return true + } + }) + + binding.title.maxLines = if (isExpanded) Int.MAX_VALUE else MAX_LINES + + setupExpandButton.invoke() + } +} diff --git a/app/src/main/java/emu/skyline/adapter/appdialog/SavesViewItem.kt b/app/src/main/java/emu/skyline/adapter/appdialog/SavesViewItem.kt new file mode 100644 index 00000000..4a0faa51 --- /dev/null +++ b/app/src/main/java/emu/skyline/adapter/appdialog/SavesViewItem.kt @@ -0,0 +1,85 @@ +/* + * SPDX-License-Identifier: MPL-2.0 + * Copyright © 2022 Skyline Team and Contributors (https://github.com/skyline-emu/) + */ + +package emu.skyline.adapter.appdialog + +import android.os.Handler +import android.os.Looper +import android.view.View +import android.view.ViewGroup +import android.view.ViewTreeObserver +import emu.skyline.adapter.GenericListItem +import emu.skyline.adapter.ViewBindingFactory +import emu.skyline.adapter.inflater +import emu.skyline.databinding.AppDialogSavesItemBinding + +object AppDialogSavesItemBindingFactory : ViewBindingFactory { + override fun createBinding(parent : ViewGroup) = AppDialogSavesItemBinding.inflate(parent.inflater(), parent, false) +} + +class SavesViewItem( + private val title : String, + private val author : String, + private val description : String, + private val onClick : ((item : SavesViewItem, position : Int) -> Unit)? = null +) : GenericListItem() { + companion object { + const val MAX_LINES = 2 + } + + private var isExpandable : Boolean? = null + private var isExpanded = false + private var isActive = false + + override fun getViewBindingFactory() = AppDialogSavesItemBindingFactory + + override fun bind(binding : AppDialogSavesItemBinding, position : Int) { + binding.title.text = title + binding.author.text = author + binding.description.text = description + binding.progress.isIndeterminate = true // temp + + handleExpand(binding, position) + } + + private fun handleExpand(binding : AppDialogSavesItemBinding, position : Int) { + val setupExpandButton = { + if (isExpandable == true) { + binding.expandButton.visibility = View.VISIBLE + binding.root.setOnClickListener { + isExpanded = !isExpanded + adapter?.notifyItemChanged(position) + } + } else { + binding.expandButton.visibility = View.GONE + } + } + + isExpandable ?: binding.root.viewTreeObserver.addOnPreDrawListener(object : ViewTreeObserver.OnPreDrawListener { + override fun onPreDraw() : Boolean { + isExpandable = binding.title.layout.getEllipsisCount(0) > 0 || + binding.author.layout.getEllipsisCount(0) > 0 || + binding.description.layout.getEllipsisCount(MAX_LINES - 1) > 0 + setupExpandButton.invoke() + binding.root.viewTreeObserver.removeOnPreDrawListener(this) + return true + } + }) + + if (isExpanded) { + binding.expandButton.rotation = 180F + binding.title.isSingleLine = false + binding.author.isSingleLine = false + binding.description.maxLines = Int.MAX_VALUE + } else { + binding.expandButton.rotation = 0F + binding.title.isSingleLine = true + binding.author.isSingleLine = true + binding.description.maxLines = MAX_LINES + } + + setupExpandButton.invoke() + } +} diff --git a/app/src/main/java/emu/skyline/adapter/appdialog/SectionHeaderViewItem.kt b/app/src/main/java/emu/skyline/adapter/appdialog/SectionHeaderViewItem.kt new file mode 100644 index 00000000..cbc9ab84 --- /dev/null +++ b/app/src/main/java/emu/skyline/adapter/appdialog/SectionHeaderViewItem.kt @@ -0,0 +1,42 @@ +/* + * SPDX-License-Identifier: MPL-2.0 + * Copyright © 2022 Skyline Team and Contributors (https://github.com/skyline-emu/) + */ + +package emu.skyline.adapter.appdialog + +import android.view.View +import android.view.ViewGroup +import emu.skyline.adapter.GenericListItem +import emu.skyline.adapter.ViewBindingFactory +import emu.skyline.adapter.inflater +import emu.skyline.databinding.AppDialogSectionHeaderBinding + +object AppDialogSectionHeaderBindingFactory : ViewBindingFactory { + override fun createBinding(parent : ViewGroup) = AppDialogSectionHeaderBinding.inflate(parent.inflater(), parent, false) +} + +class SectionHeaderViewItem( + private val title : String, + private val attribute : String? = null, + private val onButtonClick : ((item : SectionHeaderViewItem, position : Int) -> Unit)? = null +) : GenericListItem() { + override fun getViewBindingFactory() = AppDialogSectionHeaderBindingFactory + + override fun bind(binding : AppDialogSectionHeaderBinding, position : Int) { + binding.title.text = title + if (attribute != null) { + binding.subtitle.text = attribute + binding.subtitle.visibility = View.VISIBLE + } else { + binding.subtitle.visibility = View.GONE + } + + if (onButtonClick != null) { + binding.button.setOnClickListener { onButtonClick.invoke(this, position) } + binding.button.visibility = View.VISIBLE + } else { + binding.button.visibility = View.GONE + } + } +} diff --git a/app/src/main/java/emu/skyline/adapter/appdialog/UpdatesViewItem.kt b/app/src/main/java/emu/skyline/adapter/appdialog/UpdatesViewItem.kt new file mode 100644 index 00000000..d97aa2db --- /dev/null +++ b/app/src/main/java/emu/skyline/adapter/appdialog/UpdatesViewItem.kt @@ -0,0 +1,38 @@ +/* + * SPDX-License-Identifier: MPL-2.0 + * Copyright © 2022 Skyline Team and Contributors (https://github.com/skyline-emu/) + */ + +package emu.skyline.adapter.appdialog + +import android.view.View +import android.view.ViewGroup +import emu.skyline.adapter.GenericListItem +import emu.skyline.adapter.ViewBindingFactory +import emu.skyline.adapter.inflater +import emu.skyline.databinding.AppDialogUpdatesItemBinding + +object AppDialogUpdatesItemBindingFactory : ViewBindingFactory { + override fun createBinding(parent : ViewGroup) = AppDialogUpdatesItemBinding.inflate(parent.inflater(), parent, false) +} + +class UpdatesViewItem( + private val title : String, + private val onClick : ((item : UpdatesViewItem, position : Int) -> Unit)? = null +) : GenericListItem() { + override fun getViewBindingFactory() = AppDialogUpdatesItemBindingFactory + + override fun bind(binding : AppDialogUpdatesItemBinding, position : Int) { + binding.radioButton.text = title + binding.radioButton.isChecked = adapter?.selectedPosition == position + binding.radioButton.isSelected = true + + binding.radioButton.setOnCheckedChangeListener { _ : View, isChecked : Boolean -> + if (isChecked) { + adapter?.selectedPosition = position + onClick?.invoke(this, position) + adapter?.itemCount?.let { adapter?.notifyItemRangeChanged(0, it) } + } + } + } +} diff --git a/app/src/main/res/drawable/code_block.xml b/app/src/main/res/drawable/code_block.xml new file mode 100644 index 00000000..55958862 --- /dev/null +++ b/app/src/main/res/drawable/code_block.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/drawable/dot_separator.xml b/app/src/main/res/drawable/dot_separator.xml new file mode 100644 index 00000000..57b1453b --- /dev/null +++ b/app/src/main/res/drawable/dot_separator.xml @@ -0,0 +1,8 @@ + + + + + diff --git a/app/src/main/res/drawable/expand_indicator.xml b/app/src/main/res/drawable/expand_indicator.xml new file mode 100644 index 00000000..dc1bcac4 --- /dev/null +++ b/app/src/main/res/drawable/expand_indicator.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/ic_download.xml b/app/src/main/res/drawable/ic_download.xml new file mode 100644 index 00000000..7b584708 --- /dev/null +++ b/app/src/main/res/drawable/ic_download.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/ic_open.xml b/app/src/main/res/drawable/ic_open.xml index 12ac4182..9005391d 100644 --- a/app/src/main/res/drawable/ic_open.xml +++ b/app/src/main/res/drawable/ic_open.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24.0" + android:viewportHeight="24.0"> + android:fillColor="?attr/colorOnSecondary" + android:pathData="M19,19H5V5h7V3H5c-1.11,0 -2,0.9 -2,2v14c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2v-7h-2v7zM14,3v2h3.59l-9.83,9.83 1.41,1.41L19,6.41V10h2V3h-7z" /> diff --git a/app/src/main/res/drawable/ic_stop.xml b/app/src/main/res/drawable/ic_stop.xml new file mode 100644 index 00000000..f39ac461 --- /dev/null +++ b/app/src/main/res/drawable/ic_stop.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/layout/app_dialog_cheats_item.xml b/app/src/main/res/layout/app_dialog_cheats_item.xml new file mode 100644 index 00000000..fa11007d --- /dev/null +++ b/app/src/main/res/layout/app_dialog_cheats_item.xml @@ -0,0 +1,100 @@ + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/app_dialog_dlcs_item.xml b/app/src/main/res/layout/app_dialog_dlcs_item.xml new file mode 100644 index 00000000..5b796e14 --- /dev/null +++ b/app/src/main/res/layout/app_dialog_dlcs_item.xml @@ -0,0 +1,12 @@ + + diff --git a/app/src/main/res/layout/app_dialog_drag_indicator.xml b/app/src/main/res/layout/app_dialog_drag_indicator.xml new file mode 100644 index 00000000..b4199799 --- /dev/null +++ b/app/src/main/res/layout/app_dialog_drag_indicator.xml @@ -0,0 +1,14 @@ + + + + + + diff --git a/app/src/main/res/layout/app_dialog_game_info.xml b/app/src/main/res/layout/app_dialog_game_info.xml new file mode 100644 index 00000000..d82b69d8 --- /dev/null +++ b/app/src/main/res/layout/app_dialog_game_info.xml @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/app_dialog_issues_item.xml b/app/src/main/res/layout/app_dialog_issues_item.xml new file mode 100644 index 00000000..1fc3dc6f --- /dev/null +++ b/app/src/main/res/layout/app_dialog_issues_item.xml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/app_dialog_notes_item.xml b/app/src/main/res/layout/app_dialog_notes_item.xml new file mode 100644 index 00000000..bd5db9c3 --- /dev/null +++ b/app/src/main/res/layout/app_dialog_notes_item.xml @@ -0,0 +1,27 @@ + + + + + + + + + diff --git a/app/src/main/res/layout/app_dialog_saves_item.xml b/app/src/main/res/layout/app_dialog_saves_item.xml new file mode 100644 index 00000000..86fafc9a --- /dev/null +++ b/app/src/main/res/layout/app_dialog_saves_item.xml @@ -0,0 +1,114 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/app_dialog_section_header.xml b/app/src/main/res/layout/app_dialog_section_header.xml new file mode 100644 index 00000000..d9cb7d27 --- /dev/null +++ b/app/src/main/res/layout/app_dialog_section_header.xml @@ -0,0 +1,43 @@ + + + + + + + + + + diff --git a/app/src/main/res/layout/app_dialog_updates_item.xml b/app/src/main/res/layout/app_dialog_updates_item.xml new file mode 100644 index 00000000..0719e146 --- /dev/null +++ b/app/src/main/res/layout/app_dialog_updates_item.xml @@ -0,0 +1,12 @@ + + diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 6929ead2..fcc067ea 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -3,4 +3,9 @@ 8dp 6dp 12dp + + + 10dp + 6dp + 12dp diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 051bab70..c5e881e5 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -21,6 +21,20 @@ Invalid file Missing title key Incomplete production keys + + Updates + DLCs + Issues + Notes + Cheats + Saves + No updates available + No DLCs available + Pin to homescreen + Open external link + Apply + Tested on %1$s + Not tested Emulator Search Location diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index ef554bc2..97bda723 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -1,5 +1,5 @@ - + + +