This file was deleted.

@@ -0,0 +1,130 @@
// SPDX-License-Identifier: GPL-2.0-or-later

package org.dolphinemu.dolphinemu.features.riivolution.ui

import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowCompat
import androidx.core.view.WindowInsetsCompat
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
import com.google.android.material.color.MaterialColors
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.dolphinemu.dolphinemu.R
import org.dolphinemu.dolphinemu.activities.EmulationActivity
import org.dolphinemu.dolphinemu.databinding.ActivityRiivolutionBootBinding
import org.dolphinemu.dolphinemu.features.riivolution.model.RiivolutionPatches
import org.dolphinemu.dolphinemu.features.settings.model.StringSetting
import org.dolphinemu.dolphinemu.utils.DirectoryInitialization
import org.dolphinemu.dolphinemu.utils.InsetsHelper
import org.dolphinemu.dolphinemu.utils.ThemeHelper

class RiivolutionBootActivity : AppCompatActivity() {
private var patches: RiivolutionPatches? = null
private lateinit var binding: ActivityRiivolutionBootBinding

override fun onCreate(savedInstanceState: Bundle?) {
ThemeHelper.setTheme(this)

super.onCreate(savedInstanceState)

binding = ActivityRiivolutionBootBinding.inflate(layoutInflater)
setContentView(binding.root)

WindowCompat.setDecorFitsSystemWindows(window, false)

val path = intent.getStringExtra(ARG_GAME_PATH)
val gameId = intent.getStringExtra(ARG_GAME_ID)
val revision = intent.getIntExtra(ARG_REVISION, -1)
val discNumber = intent.getIntExtra(ARG_DISC_NUMBER, -1)

var loadPath = StringSetting.MAIN_LOAD_PATH.stringGlobal
if (loadPath.isEmpty()) loadPath = DirectoryInitialization.getUserDirectory() + "/Load"

binding.textSdRoot.text = getString(R.string.riivolution_sd_root, "$loadPath/Riivolution")
binding.buttonStart.setOnClickListener {
if (patches != null) patches!!.saveConfig()
EmulationActivity.launch(this, path, true)
}

lifecycleScope.launch {
withContext(Dispatchers.IO) {
val patches = RiivolutionPatches(gameId!!, revision, discNumber)
patches.loadConfig()
withContext(Dispatchers.Main) {
populateList(patches)
}
}
}

binding.toolbarRiivolution.title = getString(R.string.riivolution_riivolution)
setSupportActionBar(binding.toolbarRiivolution)
supportActionBar!!.setDisplayHomeAsUpEnabled(true)

setInsets()
ThemeHelper.enableScrollTint(this, binding.toolbarRiivolution, binding.appbarRiivolution)
}

override fun onStop() {
super.onStop()
if (patches != null) patches!!.saveConfig()
}

override fun onSupportNavigateUp(): Boolean {
onBackPressed()
return true
}

private fun populateList(patches: RiivolutionPatches) {
this.patches = patches
binding.recyclerView.adapter = RiivolutionAdapter(this, patches)
binding.recyclerView.layoutManager = LinearLayoutManager(this)
}

private fun setInsets() {
ViewCompat.setOnApplyWindowInsetsListener(binding.appbarRiivolution) { v: View?, windowInsets: WindowInsetsCompat ->
val insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars())

InsetsHelper.insetAppBar(insets, binding.appbarRiivolution)

binding.scrollViewRiivolution.setPadding(insets.left, 0, insets.right, insets.bottom)

InsetsHelper.applyNavbarWorkaround(insets.bottom, binding.workaroundView)
ThemeHelper.setNavigationBarColor(
this,
MaterialColors.getColor(binding.appbarRiivolution, R.attr.colorSurface)
)

windowInsets
}
}

companion object {
private const val ARG_GAME_PATH = "game_path"
private const val ARG_GAME_ID = "game_id"
private const val ARG_REVISION = "revision"
private const val ARG_DISC_NUMBER = "disc_number"

@JvmStatic
fun launch(
context: Context,
gamePath: String?,
gameId: String?,
revision: Int,
discNumber: Int
) {
val launcher = Intent(context, RiivolutionBootActivity::class.java)
launcher.putExtra(ARG_GAME_PATH, gamePath)
launcher.putExtra(ARG_GAME_ID, gameId)
launcher.putExtra(ARG_REVISION, revision)
launcher.putExtra(ARG_DISC_NUMBER, discNumber)
context.startActivity(launcher)
}
}
}

This file was deleted.

@@ -0,0 +1,36 @@
// SPDX-License-Identifier: GPL-2.0-or-later

package org.dolphinemu.dolphinemu.features.riivolution.ui

class RiivolutionItem {
val mDiscIndex: Int
val mSectionIndex: Int
val mOptionIndex: Int

/**
* Constructor for a disc.
*/
constructor(discIndex: Int) {
mDiscIndex = discIndex
mSectionIndex = -1
mOptionIndex = -1
}

/**
* Constructor for a section.
*/
constructor(discIndex: Int, sectionIndex: Int) {
mDiscIndex = discIndex
mSectionIndex = sectionIndex
mOptionIndex = -1
}

/**
* Constructor for an option.
*/
constructor(discIndex: Int, sectionIndex: Int, optionIndex: Int) {
mDiscIndex = discIndex
mSectionIndex = sectionIndex
mOptionIndex = optionIndex
}
}

This file was deleted.

@@ -0,0 +1,87 @@
// SPDX-License-Identifier: GPL-2.0-or-later

package org.dolphinemu.dolphinemu.features.riivolution.ui

import android.content.Context
import android.view.View
import android.widget.AdapterView
import android.widget.AdapterView.OnItemClickListener
import android.widget.ArrayAdapter
import androidx.recyclerview.widget.RecyclerView
import org.dolphinemu.dolphinemu.R
import org.dolphinemu.dolphinemu.databinding.ListItemRiivolutionBinding
import org.dolphinemu.dolphinemu.features.riivolution.model.RiivolutionPatches

class RiivolutionViewHolder(itemView: View, private val binding: ListItemRiivolutionBinding) :
RecyclerView.ViewHolder(itemView), OnItemClickListener {
private lateinit var patches: RiivolutionPatches
private lateinit var item: RiivolutionItem

fun bind(context: Context, patches: RiivolutionPatches, item: RiivolutionItem) {
// TODO: Remove workaround for text filtering issue in material components when fixed
// https://github.com/material-components/material-components-android/issues/1464
binding.dropdownChoice.isSaveEnabled = false

val text: String
if (item.mOptionIndex != -1) {
binding.textName.visibility = View.GONE
text = patches.getOptionName(item.mDiscIndex, item.mSectionIndex, item.mOptionIndex)
binding.layoutChoice.hint = text
} else if (item.mSectionIndex != -1) {
// TODO: Use supported version of setTextAppearance when min requirement is API 23
binding.textName.setTextAppearance(context, R.style.TextAppearance_AppCompat_Medium)
binding.layoutChoice.visibility = View.GONE
text = patches.getSectionName(item.mDiscIndex, item.mSectionIndex)
} else {
binding.layoutChoice.visibility = View.GONE
text = patches.getDiscName(item.mDiscIndex)
}
binding.textName.text = text

if (item.mOptionIndex != -1) {
this.patches = patches
this.item = item
val adapter = ArrayAdapter<String>(
context,
R.layout.support_simple_spinner_dropdown_item
)
val choiceCount = patches.getChoiceCount(
item.mDiscIndex,
item.mSectionIndex,
item.mOptionIndex
)
adapter.add(context.getString(R.string.riivolution_disabled))
for (i in 0 until choiceCount) {
adapter.add(
patches.getChoiceName(
item.mDiscIndex,
item.mSectionIndex,
item.mOptionIndex,
i
)
)
}

binding.dropdownChoice.setAdapter(adapter)
binding.dropdownChoice.setText(
adapter.getItem(
patches.getSelectedChoice(
item.mDiscIndex,
item.mSectionIndex,
item.mOptionIndex
)
), false
)
binding.dropdownChoice.onItemClickListener = this
}
}

override fun onItemClick(parent: AdapterView<*>?, view: View, position: Int, id: Long) {
patches.setSelectedChoice(
item.mDiscIndex,
item.mSectionIndex,
item.mOptionIndex,
position
)
}
}
@@ -539,7 +539,7 @@ JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved)
env->FindClass("org/dolphinemu/dolphinemu/features/riivolution/model/RiivolutionPatches");
s_riivolution_patches_class =
reinterpret_cast<jclass>(env->NewGlobalRef(riivolution_patches_class));
s_riivolution_patches_pointer = env->GetFieldID(riivolution_patches_class, "mPointer", "J");
s_riivolution_patches_pointer = env->GetFieldID(riivolution_patches_class, "pointer", "J");
env->DeleteLocalRef(riivolution_patches_class);

const jclass wii_update_cb_class =