style: format code and remove unnecessary blank lines and imports
This commit is contained in:
parent
0ea1870bbc
commit
6e88a9f1f6
26 changed files with 146 additions and 102 deletions
|
@ -4,7 +4,6 @@
|
|||
// SPDX-FileCopyrightText: 2023 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
|
||||
package org.yuzu.yuzu_emu
|
||||
|
||||
import android.content.DialogInterface
|
||||
|
@ -17,7 +16,6 @@ import android.widget.TextView
|
|||
import androidx.annotation.Keep
|
||||
import androidx.core.net.toUri
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import net.swiftzer.semver.SemVer
|
||||
import java.lang.ref.WeakReference
|
||||
import org.yuzu.yuzu_emu.activities.EmulationActivity
|
||||
import org.yuzu.yuzu_emu.fragments.CoreErrorDialogFragment
|
||||
|
@ -28,7 +26,6 @@ import org.yuzu.yuzu_emu.model.InstallResult
|
|||
import org.yuzu.yuzu_emu.model.Patch
|
||||
import org.yuzu.yuzu_emu.model.GameVerificationResult
|
||||
import org.yuzu.yuzu_emu.network.NetPlayManager
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
* Class which contains methods that interact
|
||||
|
@ -276,8 +273,7 @@ object NativeLibrary {
|
|||
val emulationActivity = sEmulationActivity.get()
|
||||
if (emulationActivity != null) {
|
||||
emulationActivity.addNetPlayMessages(type, message)
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
NetPlayManager.addNetPlayMessage(type, message)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,15 +4,10 @@
|
|||
package org.yuzu.yuzu_emu.adapters
|
||||
|
||||
import android.content.DialogInterface
|
||||
import android.net.Uri
|
||||
import android.text.Html
|
||||
import android.text.method.LinkMovementMethod
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.pm.ShortcutInfoCompat
|
||||
|
@ -37,7 +32,6 @@ import org.yuzu.yuzu_emu.model.GamesViewModel
|
|||
import org.yuzu.yuzu_emu.utils.GameIconUtils
|
||||
import org.yuzu.yuzu_emu.utils.ViewUtils.marquee
|
||||
import org.yuzu.yuzu_emu.viewholder.AbstractViewHolder
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.core.net.toUri
|
||||
import androidx.core.content.edit
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
|
@ -94,7 +88,7 @@ class GameAdapter(private val activity: AppCompatActivity) :
|
|||
}
|
||||
VIEW_TYPE_CAROUSEL -> {
|
||||
val carouselBinding = holder.binding as CardGameCarouselBinding
|
||||
//soothens transient flickering
|
||||
// soothens transient flickering
|
||||
carouselBinding.cardGameCarousel.scaleY = 0f
|
||||
carouselBinding.cardGameCarousel.alpha = 0f
|
||||
}
|
||||
|
@ -103,9 +97,21 @@ class GameAdapter(private val activity: AppCompatActivity) :
|
|||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): GameViewHolder {
|
||||
val binding = when (viewType) {
|
||||
VIEW_TYPE_LIST -> CardGameListBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
VIEW_TYPE_GRID -> CardGameGridBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
VIEW_TYPE_CAROUSEL -> CardGameCarouselBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
VIEW_TYPE_LIST -> CardGameListBinding.inflate(
|
||||
LayoutInflater.from(parent.context),
|
||||
parent,
|
||||
false
|
||||
)
|
||||
VIEW_TYPE_GRID -> CardGameGridBinding.inflate(
|
||||
LayoutInflater.from(parent.context),
|
||||
parent,
|
||||
false
|
||||
)
|
||||
VIEW_TYPE_CAROUSEL -> CardGameCarouselBinding.inflate(
|
||||
LayoutInflater.from(parent.context),
|
||||
parent,
|
||||
false
|
||||
)
|
||||
else -> throw IllegalArgumentException("Invalid view type")
|
||||
}
|
||||
return GameViewHolder(binding, viewType)
|
||||
|
@ -212,7 +218,10 @@ class GameAdapter(private val activity: AppCompatActivity) :
|
|||
.setIcon(GameIconUtils.getShortcutIcon(activity, game))
|
||||
.setIntent(game.launchIntent)
|
||||
.build()
|
||||
ShortcutManagerCompat.pushDynamicShortcut(YuzuApplication.appContext, shortcut)
|
||||
ShortcutManagerCompat.pushDynamicShortcut(
|
||||
YuzuApplication.appContext,
|
||||
shortcut
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -232,7 +241,7 @@ class GameAdapter(private val activity: AppCompatActivity) :
|
|||
.setPositiveButton(android.R.string.ok) { _: DialogInterface?, _: Int ->
|
||||
launch()
|
||||
}
|
||||
.setNegativeButton(android.R.string.cancel) { _,_ -> }
|
||||
.setNegativeButton(android.R.string.cancel) { _, _ -> }
|
||||
.show()
|
||||
} else {
|
||||
launch()
|
||||
|
|
|
@ -6,10 +6,8 @@ package org.yuzu.yuzu_emu.adapters
|
|||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.content.res.ResourcesCompat
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import org.yuzu.yuzu_emu.R
|
||||
import org.yuzu.yuzu_emu.databinding.CardHomeOptionBinding
|
||||
import org.yuzu.yuzu_emu.fragments.MessageDialogFragment
|
||||
import org.yuzu.yuzu_emu.model.HomeSetting
|
||||
|
|
|
@ -220,7 +220,7 @@ class LobbyBrowser(context: Context) : BottomSheetDialog(context) {
|
|||
val baseList = NetPlayManager.getPublicRooms()
|
||||
val filteredList = baseList.filter { room ->
|
||||
(!binding.chipHideFull.isChecked || room.members.size < room.maxPlayers) &&
|
||||
(!binding.chipHideEmpty.isChecked || room.members.isNotEmpty())
|
||||
(!binding.chipHideEmpty.isChecked || room.members.isNotEmpty())
|
||||
}
|
||||
|
||||
if (binding.searchText.text.toString().isEmpty() &&
|
||||
|
@ -245,7 +245,6 @@ class LobbyBrowser(context: Context) : BottomSheetDialog(context) {
|
|||
it.score
|
||||
}.map { it.item }
|
||||
adapter.updateRooms(sortedList)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@ import android.view.View
|
|||
import android.view.ViewGroup
|
||||
import android.widget.ArrayAdapter
|
||||
import android.widget.Button
|
||||
import android.widget.EditText
|
||||
import android.widget.PopupMenu
|
||||
import android.widget.Toast
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
|
@ -38,7 +37,6 @@ import org.yuzu.yuzu_emu.network.NetDataValidators
|
|||
import org.yuzu.yuzu_emu.network.NetPlayManager
|
||||
import org.yuzu.yuzu_emu.utils.CompatUtils
|
||||
import org.yuzu.yuzu_emu.utils.GameHelper
|
||||
import java.net.InetAddress
|
||||
|
||||
class NetPlayDialog(context: Context) : BottomSheetDialog(context) {
|
||||
private lateinit var adapter: NetPlayAdapter
|
||||
|
@ -55,7 +53,9 @@ class NetPlayDialog(context: Context) : BottomSheetDialog(context) {
|
|||
context.resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE
|
||||
|
||||
when {
|
||||
NetPlayManager.netPlayIsJoined() -> DialogMultiplayerLobbyBinding.inflate(layoutInflater)
|
||||
NetPlayManager.netPlayIsJoined() -> DialogMultiplayerLobbyBinding.inflate(
|
||||
layoutInflater
|
||||
)
|
||||
.apply {
|
||||
setContentView(root)
|
||||
adapter = NetPlayAdapter()
|
||||
|
@ -77,7 +77,6 @@ class NetPlayDialog(context: Context) : BottomSheetDialog(context) {
|
|||
btnModeration.setOnClickListener {
|
||||
showModerationDialog()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
else -> {
|
||||
|
@ -140,7 +139,8 @@ class NetPlayDialog(context: Context) : BottomSheetDialog(context) {
|
|||
inner class NetPlayAdapter : RecyclerView.Adapter<NetPlayAdapter.NetPlayViewHolder>() {
|
||||
val netPlayItems = mutableListOf<NetPlayItems>()
|
||||
|
||||
abstract inner class NetPlayViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView),
|
||||
abstract inner class NetPlayViewHolder(itemView: View) :
|
||||
RecyclerView.ViewHolder(itemView),
|
||||
View.OnClickListener {
|
||||
init {
|
||||
itemView.setOnClickListener(this)
|
||||
|
@ -167,7 +167,9 @@ class NetPlayDialog(context: Context) : BottomSheetDialog(context) {
|
|||
visibility = if (iconRes != 0) {
|
||||
setImageResource(iconRes)
|
||||
View.VISIBLE
|
||||
} else View.GONE
|
||||
} else {
|
||||
View.GONE
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -186,14 +188,13 @@ class NetPlayDialog(context: Context) : BottomSheetDialog(context) {
|
|||
|
||||
override fun onClick(clicked: View) {}
|
||||
|
||||
|
||||
private fun showPopupMenu(view: View) {
|
||||
PopupMenu(view.context, view).apply {
|
||||
menuInflater.inflate(R.menu.menu_netplay_member, menu)
|
||||
menu.findItem(R.id.action_kick).isEnabled = isModerator &&
|
||||
netPlayItems.name != StringSetting.WEB_USERNAME.getString()
|
||||
netPlayItems.name != StringSetting.WEB_USERNAME.getString()
|
||||
menu.findItem(R.id.action_ban).isEnabled = isModerator &&
|
||||
netPlayItems.name != StringSetting.WEB_USERNAME.getString()
|
||||
netPlayItems.name != StringSetting.WEB_USERNAME.getString()
|
||||
setOnMenuItemClickListener { item ->
|
||||
if (item.itemId == R.id.action_kick) {
|
||||
NetPlayManager.netPlayKickUser(netPlayItems.name)
|
||||
|
@ -201,7 +202,9 @@ class NetPlayDialog(context: Context) : BottomSheetDialog(context) {
|
|||
} else if (item.itemId == R.id.action_ban) {
|
||||
NetPlayManager.netPlayBanUser(netPlayItems.name)
|
||||
true
|
||||
} else false
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
show()
|
||||
}
|
||||
|
@ -360,12 +363,15 @@ class NetPlayDialog(context: Context) : BottomSheetDialog(context) {
|
|||
|
||||
val visibilityList: List<String> = listOf(
|
||||
context.getString(R.string.multiplayer_public_visibility),
|
||||
context.getString(R.string.multiplayer_unlisted_visibility),
|
||||
context.getString(R.string.multiplayer_unlisted_visibility)
|
||||
)
|
||||
|
||||
binding.textTitle.text = activity.getString(
|
||||
if (isCreateRoom) R.string.multiplayer_create_room
|
||||
else R.string.multiplayer_join_room
|
||||
if (isCreateRoom) {
|
||||
R.string.multiplayer_create_room
|
||||
} else {
|
||||
R.string.multiplayer_join_room
|
||||
}
|
||||
)
|
||||
|
||||
// setup listeners etc
|
||||
|
@ -446,7 +452,9 @@ class NetPlayDialog(context: Context) : BottomSheetDialog(context) {
|
|||
)
|
||||
}
|
||||
|
||||
binding.dropdownLobbyVisibility.setText(context.getString(R.string.multiplayer_unlisted_visibility))
|
||||
binding.dropdownLobbyVisibility.setText(
|
||||
context.getString(R.string.multiplayer_unlisted_visibility)
|
||||
)
|
||||
|
||||
binding.dropdownLobbyVisibility.apply {
|
||||
setAdapter(
|
||||
|
@ -501,8 +509,11 @@ class NetPlayDialog(context: Context) : BottomSheetDialog(context) {
|
|||
binding.btnConfirm.isEnabled = false
|
||||
binding.btnConfirm.text =
|
||||
activity.getString(
|
||||
if (isCreateRoom) R.string.multiplayer_creating
|
||||
else R.string.multiplayer_joining
|
||||
if (isCreateRoom) {
|
||||
R.string.multiplayer_creating
|
||||
} else {
|
||||
R.string.multiplayer_joining
|
||||
}
|
||||
)
|
||||
|
||||
// We don't need to worry about validation because it's already been done.
|
||||
|
@ -546,8 +557,11 @@ class NetPlayDialog(context: Context) : BottomSheetDialog(context) {
|
|||
|
||||
Toast.makeText(
|
||||
YuzuApplication.appContext,
|
||||
if (isCreateRoom) R.string.multiplayer_create_room_success
|
||||
else R.string.multiplayer_join_room_success,
|
||||
if (isCreateRoom) {
|
||||
R.string.multiplayer_create_room_success
|
||||
} else {
|
||||
R.string.multiplayer_join_room_success
|
||||
},
|
||||
Toast.LENGTH_LONG
|
||||
).show()
|
||||
|
||||
|
@ -619,7 +633,9 @@ class NetPlayDialog(context: Context) : BottomSheetDialog(context) {
|
|||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
val binding = ItemBanListBinding.inflate(
|
||||
LayoutInflater.from(parent.context), parent, false
|
||||
LayoutInflater.from(parent.context),
|
||||
parent,
|
||||
false
|
||||
)
|
||||
return ViewHolder(binding)
|
||||
}
|
||||
|
@ -654,6 +670,5 @@ class NetPlayDialog(context: Context) : BottomSheetDialog(context) {
|
|||
notifyItemRemoved(position)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ class ReleaseAdapter(
|
|||
|
||||
// truncates to 150 chars so it does not take up too much space.
|
||||
var bodyPreview = release.body.take(150)
|
||||
bodyPreview = bodyPreview.replace("#", "").removeSurrounding(" ");
|
||||
bodyPreview = bodyPreview.replace("#", "").removeSurrounding(" ")
|
||||
|
||||
val body =
|
||||
bodyPreview.replace("\\r\\n", "\n").replace("\\n", "\n").replace("\n", "<br>")
|
||||
|
@ -122,8 +122,11 @@ class ReleaseAdapter(
|
|||
|
||||
binding.imageDownloadsArrow.rotation = if (isVisible) 0f else 180f
|
||||
binding.buttonToggleDownloads.text =
|
||||
if (isVisible) activity.getString(R.string.show_downloads)
|
||||
else activity.getString(R.string.hide_downloads)
|
||||
if (isVisible) {
|
||||
activity.getString(R.string.show_downloads)
|
||||
} else {
|
||||
activity.getString(R.string.hide_downloads)
|
||||
}
|
||||
}
|
||||
|
||||
binding.buttonToggleDownloads.setOnClickListener {
|
||||
|
@ -139,9 +142,15 @@ class ReleaseAdapter(
|
|||
release.artifacts.forEach { artifact ->
|
||||
val button = MaterialButton(binding.root.context).apply {
|
||||
text = artifact.name
|
||||
setTextAppearance(com.google.android.material.R.style.TextAppearance_Material3_LabelLarge)
|
||||
setTextAppearance(
|
||||
com.google.android.material.R.style.TextAppearance_Material3_LabelLarge
|
||||
)
|
||||
textAlignment = MaterialButton.TEXT_ALIGNMENT_VIEW_START
|
||||
setBackgroundColor(context.getColor(com.google.android.material.R.color.m3_button_background_color_selector))
|
||||
setBackgroundColor(
|
||||
context.getColor(
|
||||
com.google.android.material.R.color.m3_button_background_color_selector
|
||||
)
|
||||
)
|
||||
setIconResource(R.drawable.ic_import)
|
||||
iconTint = ColorStateList.valueOf(
|
||||
MaterialColors.getColor(
|
||||
|
@ -199,7 +208,9 @@ class ReleaseAdapter(
|
|||
input.copyTo(output)
|
||||
}
|
||||
}
|
||||
?: throw IOException(context.getString(R.string.empty_response_body))
|
||||
?: throw IOException(
|
||||
context.getString(R.string.empty_response_body)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -211,7 +222,9 @@ class ReleaseAdapter(
|
|||
|
||||
val driverData = GpuDriverHelper.getMetadataFromZip(file)
|
||||
val driverPath =
|
||||
"${GpuDriverHelper.driverStoragePath}${FileUtil.getFilename(file.toUri())}"
|
||||
"${GpuDriverHelper.driverStoragePath}${FileUtil.getFilename(
|
||||
file.toUri()
|
||||
)}"
|
||||
|
||||
if (GpuDriverHelper.copyDriverToInternalStorage(file.toUri())) {
|
||||
driverViewModel.onDriverAdded(Pair(driverPath, driverData))
|
||||
|
@ -254,7 +267,9 @@ class ReleaseAdapter(
|
|||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ReleaseViewHolder {
|
||||
val binding = ItemReleaseBinding.inflate(
|
||||
LayoutInflater.from(parent.context), parent, false
|
||||
LayoutInflater.from(parent.context),
|
||||
parent,
|
||||
false
|
||||
)
|
||||
return ReleaseViewHolder(binding)
|
||||
}
|
||||
|
@ -264,4 +279,4 @@ class ReleaseAdapter(
|
|||
}
|
||||
|
||||
override fun getItemCount(): Int = releases.size
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,4 +16,4 @@ class SpacingItemDecoration(private val spacing: Int) : RecyclerView.ItemDecorat
|
|||
outRect.top = spacing
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ enum class IntSetting(override val key: String) : AbstractIntSetting {
|
|||
OFFLINE_WEB_APPLET("offline_web_applet_mode"),
|
||||
LOGIN_SHARE_APPLET("login_share_applet_mode"),
|
||||
WIFI_WEB_AUTH_APPLET("wifi_web_auth_applet_mode"),
|
||||
MY_PAGE_APPLET("my_page_applet_mode"),
|
||||
MY_PAGE_APPLET("my_page_applet_mode")
|
||||
;
|
||||
|
||||
override fun getInt(needsGlobal: Boolean): Int = NativeConfig.getInt(key, needsGlobal)
|
||||
|
|
|
@ -13,7 +13,7 @@ enum class StringSetting(override val key: String) : AbstractStringSetting {
|
|||
DEVICE_NAME("device_name"),
|
||||
|
||||
WEB_TOKEN("eden_token"),
|
||||
WEB_USERNAME("eden_username"),
|
||||
WEB_USERNAME("eden_username")
|
||||
;
|
||||
|
||||
override fun getString(needsGlobal: Boolean): String = NativeConfig.getString(key, needsGlobal)
|
||||
|
|
|
@ -21,7 +21,6 @@ import org.yuzu.yuzu_emu.features.settings.model.LongSetting
|
|||
import org.yuzu.yuzu_emu.features.settings.model.ShortSetting
|
||||
import org.yuzu.yuzu_emu.features.settings.model.StringSetting
|
||||
import org.yuzu.yuzu_emu.network.NetDataValidators
|
||||
import org.yuzu.yuzu_emu.utils.GpuDriverHelper
|
||||
import org.yuzu.yuzu_emu.utils.NativeConfig
|
||||
|
||||
/**
|
||||
|
@ -79,7 +78,7 @@ abstract class SettingsItem(
|
|||
|
||||
val needsRuntimeGlobal: Boolean
|
||||
get() = NativeLibrary.isRunning() && !setting.global &&
|
||||
!NativeConfig.isPerGameConfigLoaded()
|
||||
!NativeConfig.isPerGameConfigLoaded()
|
||||
|
||||
val clearable: Boolean
|
||||
get() = !setting.global && NativeConfig.isPerGameConfigLoaded()
|
||||
|
@ -516,7 +515,6 @@ abstract class SettingsItem(
|
|||
)
|
||||
)
|
||||
|
||||
|
||||
put(
|
||||
SingleChoiceSetting(
|
||||
IntSetting.RENDERER_VSYNC,
|
||||
|
@ -724,7 +722,7 @@ abstract class SettingsItem(
|
|||
val fastmem = object : AbstractBooleanSetting {
|
||||
override fun getBoolean(needsGlobal: Boolean): Boolean =
|
||||
BooleanSetting.FASTMEM.getBoolean() &&
|
||||
BooleanSetting.FASTMEM_EXCLUSIVES.getBoolean()
|
||||
BooleanSetting.FASTMEM_EXCLUSIVES.getBoolean()
|
||||
|
||||
override fun setBoolean(value: Boolean) {
|
||||
BooleanSetting.FASTMEM.setBoolean(value)
|
||||
|
@ -739,7 +737,7 @@ abstract class SettingsItem(
|
|||
override var global: Boolean
|
||||
get() {
|
||||
return BooleanSetting.FASTMEM.global &&
|
||||
BooleanSetting.FASTMEM_EXCLUSIVES.global
|
||||
BooleanSetting.FASTMEM_EXCLUSIVES.global
|
||||
}
|
||||
set(value) {
|
||||
BooleanSetting.FASTMEM.global = value
|
||||
|
|
|
@ -18,7 +18,7 @@ class SingleChoiceSetting(
|
|||
@ArrayRes val choicesId: Int,
|
||||
@ArrayRes val valuesId: Int,
|
||||
val warnChoices: List<Int> = ArrayList(),
|
||||
@StringRes val warningMessage: Int = 0,
|
||||
@StringRes val warningMessage: Int = 0
|
||||
) : SettingsItem(setting, titleId, titleString, descriptionId, descriptionString) {
|
||||
override val type = TYPE_SINGLE_CHOICE
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
package org.yuzu.yuzu_emu.features.settings.model.view
|
||||
|
||||
import android.text.Editable
|
||||
import androidx.annotation.StringRes
|
||||
import org.yuzu.yuzu_emu.features.settings.model.AbstractStringSetting
|
||||
|
||||
|
|
|
@ -179,7 +179,13 @@ class SettingsDialogFragment : DialogFragment(), DialogInterface.OnClickListener
|
|||
override fun afterTextChanged(s: Editable?) {
|
||||
val isValid = validator(s.toString())
|
||||
stringInputBinding.editTextLayout.isErrorEnabled = !isValid
|
||||
stringInputBinding.editTextLayout.error = if (isValid) null else requireContext().getString(item.errorId)
|
||||
stringInputBinding.editTextLayout.error = if (isValid) {
|
||||
null
|
||||
} else {
|
||||
requireContext().getString(
|
||||
item.errorId
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ import android.os.Bundle
|
|||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.content.edit
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.core.view.updatePadding
|
||||
|
@ -16,13 +15,11 @@ import androidx.fragment.app.Fragment
|
|||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.navigation.findNavController
|
||||
import androidx.navigation.fragment.navArgs
|
||||
import androidx.preference.PreferenceManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.google.android.material.transition.MaterialSharedAxis
|
||||
import org.yuzu.yuzu_emu.R
|
||||
import org.yuzu.yuzu_emu.databinding.FragmentSettingsBinding
|
||||
import org.yuzu.yuzu_emu.features.input.NativeInput
|
||||
import org.yuzu.yuzu_emu.features.settings.model.BooleanSetting
|
||||
import org.yuzu.yuzu_emu.features.settings.model.Settings
|
||||
import org.yuzu.yuzu_emu.fragments.MessageDialogFragment
|
||||
import org.yuzu.yuzu_emu.utils.ViewUtils.updateMargins
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
package org.yuzu.yuzu_emu.features.settings.ui
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.app.AlertDialog
|
||||
import android.os.Build
|
||||
import android.widget.Toast
|
||||
import androidx.preference.PreferenceManager
|
||||
|
@ -1056,7 +1054,9 @@ class SettingsFragmentPresenter(
|
|||
}
|
||||
|
||||
val staticThemeColor: AbstractIntSetting = object : AbstractIntSetting {
|
||||
val preferences = PreferenceManager.getDefaultSharedPreferences(YuzuApplication.appContext)
|
||||
val preferences = PreferenceManager.getDefaultSharedPreferences(
|
||||
YuzuApplication.appContext
|
||||
)
|
||||
override fun getInt(needsGlobal: Boolean): Int =
|
||||
preferences.getInt(Settings.PREF_STATIC_THEME_COLOR, 0)
|
||||
override fun setInt(value: Int) {
|
||||
|
|
|
@ -27,7 +27,6 @@ import androidx.navigation.findNavController
|
|||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import com.google.android.material.transition.MaterialSharedAxis
|
||||
import org.yuzu.yuzu_emu.BuildConfig
|
||||
import org.yuzu.yuzu_emu.HomeNavigationDirections
|
||||
import org.yuzu.yuzu_emu.NativeLibrary
|
||||
import org.yuzu.yuzu_emu.R
|
||||
|
@ -41,9 +40,7 @@ import org.yuzu.yuzu_emu.model.HomeSetting
|
|||
import org.yuzu.yuzu_emu.model.HomeViewModel
|
||||
import org.yuzu.yuzu_emu.ui.main.MainActivity
|
||||
import org.yuzu.yuzu_emu.utils.FileUtil
|
||||
import org.yuzu.yuzu_emu.utils.GpuDriverHelper
|
||||
import org.yuzu.yuzu_emu.utils.Log
|
||||
import org.yuzu.yuzu_emu.utils.ViewUtils.updateMargins
|
||||
|
||||
class HomeSettingsFragment : Fragment() {
|
||||
private var _binding: FragmentHomeSettingsBinding? = null
|
||||
|
@ -112,7 +109,7 @@ class HomeSettingsFragment : Fragment() {
|
|||
.actionHomeSettingsFragmentToDriverManagerFragment(null)
|
||||
binding.root.findNavController().navigate(action)
|
||||
},
|
||||
{true},
|
||||
{ true },
|
||||
R.string.custom_driver_not_supported,
|
||||
R.string.custom_driver_not_supported_description,
|
||||
driverViewModel.selectedDriverTitle
|
||||
|
@ -125,7 +122,7 @@ class HomeSettingsFragment : Fragment() {
|
|||
R.drawable.ic_two_users,
|
||||
{
|
||||
mainActivity.displayMultiplayerDialog()
|
||||
},
|
||||
}
|
||||
)
|
||||
)
|
||||
add(
|
||||
|
@ -403,7 +400,7 @@ class HomeSettingsFragment : Fragment() {
|
|||
val cutoutInsets = windowInsets.getInsets(WindowInsetsCompat.Type.displayCutout())
|
||||
|
||||
binding.scrollViewSettings.updatePadding(
|
||||
top = barInsets.top,
|
||||
top = barInsets.top
|
||||
)
|
||||
|
||||
binding.homeSettingsList.updatePadding(
|
||||
|
|
|
@ -134,10 +134,10 @@ class InstallableFragment : Fragment() {
|
|||
install = { mainActivity.getFirmware.launch(arrayOf("application/zip")) }
|
||||
),
|
||||
Installable(
|
||||
R.string.uninstall_firmware,
|
||||
R.string.uninstall_firmware_description,
|
||||
install = { mainActivity.uninstallFirmware() }
|
||||
),
|
||||
R.string.uninstall_firmware,
|
||||
R.string.uninstall_firmware_description,
|
||||
install = { mainActivity.uninstallFirmware() }
|
||||
),
|
||||
Installable(
|
||||
R.string.install_prod_keys,
|
||||
R.string.install_prod_keys_description,
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// SPDX-FileCopyrightText: 2025 Eden Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
|
||||
package org.yuzu.yuzu_emu.fragments
|
||||
|
||||
import android.os.Bundle
|
||||
|
|
|
@ -78,7 +78,6 @@ class SetupFragment : Fragment() {
|
|||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
mainActivity = requireActivity() as MainActivity
|
||||
|
||||
|
||||
requireActivity().onBackPressedDispatcher.addCallback(
|
||||
viewLifecycleOwner,
|
||||
object : OnBackPressedCallback(true) {
|
||||
|
@ -129,7 +128,7 @@ class SetupFragment : Fragment() {
|
|||
0,
|
||||
{
|
||||
if (NotificationManagerCompat.from(requireContext())
|
||||
.areNotificationsEnabled()
|
||||
.areNotificationsEnabled()
|
||||
) {
|
||||
StepState.COMPLETE
|
||||
} else {
|
||||
|
|
|
@ -22,7 +22,11 @@ class MidScreenSwipeRefreshLayout @JvmOverloads constructor(
|
|||
MotionEvent.ACTION_DOWN -> {
|
||||
startX = ev.x
|
||||
val width = width
|
||||
val center_fraction = resources.getFraction(R.fraction.carousel_midscreenswipe_width_fraction, 1, 1).coerceIn(0f, 1f)
|
||||
val center_fraction = resources.getFraction(
|
||||
R.fraction.carousel_midscreenswipe_width_fraction,
|
||||
1,
|
||||
1
|
||||
).coerceIn(0f, 1f)
|
||||
val leftBound = ((1 - center_fraction) / 2) * width
|
||||
val rightBound = leftBound + (width * center_fraction)
|
||||
allowRefresh = startX >= leftBound && startX <= rightBound
|
||||
|
@ -30,4 +34,4 @@ class MidScreenSwipeRefreshLayout @JvmOverloads constructor(
|
|||
}
|
||||
return if (allowRefresh) super.onInterceptTouchEvent(ev) else false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -141,7 +141,7 @@ class GamesViewModel : ViewModel() {
|
|||
}
|
||||
}
|
||||
|
||||
fun addFolder(gameDir: GameDir, savedFromGameFragment: Boolean) =
|
||||
fun addFolder(gameDir: GameDir, savedFromGameFragment: Boolean) =
|
||||
viewModelScope.launch {
|
||||
withContext(Dispatchers.IO) {
|
||||
NativeConfig.addGameDir(gameDir)
|
||||
|
|
|
@ -27,7 +27,7 @@ object NetDataValidators {
|
|||
|
||||
fun roomVisibility(s: String, context: Context): Boolean {
|
||||
if (s != context.getString(R.string.multiplayer_public_visibility)) {
|
||||
return true;
|
||||
return true
|
||||
}
|
||||
|
||||
return token()
|
||||
|
@ -53,4 +53,4 @@ object NetDataValidators {
|
|||
fun port(s: String): Boolean {
|
||||
return s.toIntOrNull() in 1..65535
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,7 +70,6 @@ object NetPlayManager {
|
|||
val gameName: String
|
||||
)
|
||||
|
||||
|
||||
private var messageListener: ((Int, String) -> Unit)? = null
|
||||
private var adapterRefreshListener: ((Int, String) -> Unit)? = null
|
||||
|
||||
|
@ -199,7 +198,6 @@ object NetPlayManager {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
Handler(Looper.getMainLooper()).post {
|
||||
if (!isChatOpen) {
|
||||
// TODO(alekpop, crueter): Improve this, potentially a drawer at the top?
|
||||
|
@ -207,7 +205,6 @@ object NetPlayManager {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
messageListener?.invoke(type, msg)
|
||||
adapterRefreshListener?.invoke(type, msg)
|
||||
}
|
||||
|
@ -218,19 +215,29 @@ object NetPlayManager {
|
|||
NetPlayStatus.LOST_CONNECTION -> context.getString(R.string.multiplayer_lost_connection)
|
||||
NetPlayStatus.NAME_COLLISION -> context.getString(R.string.multiplayer_name_collision)
|
||||
NetPlayStatus.MAC_COLLISION -> context.getString(R.string.multiplayer_mac_collision)
|
||||
NetPlayStatus.CONSOLE_ID_COLLISION -> context.getString(R.string.multiplayer_console_id_collision)
|
||||
NetPlayStatus.CONSOLE_ID_COLLISION -> context.getString(
|
||||
R.string.multiplayer_console_id_collision
|
||||
)
|
||||
NetPlayStatus.WRONG_VERSION -> context.getString(R.string.multiplayer_wrong_version)
|
||||
NetPlayStatus.WRONG_PASSWORD -> context.getString(R.string.multiplayer_wrong_password)
|
||||
NetPlayStatus.COULD_NOT_CONNECT -> context.getString(R.string.multiplayer_could_not_connect)
|
||||
NetPlayStatus.COULD_NOT_CONNECT -> context.getString(
|
||||
R.string.multiplayer_could_not_connect
|
||||
)
|
||||
NetPlayStatus.ROOM_IS_FULL -> context.getString(R.string.multiplayer_room_is_full)
|
||||
NetPlayStatus.HOST_BANNED -> context.getString(R.string.multiplayer_host_banned)
|
||||
NetPlayStatus.PERMISSION_DENIED -> context.getString(R.string.multiplayer_permission_denied)
|
||||
NetPlayStatus.PERMISSION_DENIED -> context.getString(
|
||||
R.string.multiplayer_permission_denied
|
||||
)
|
||||
NetPlayStatus.NO_SUCH_USER -> context.getString(R.string.multiplayer_no_such_user)
|
||||
NetPlayStatus.ALREADY_IN_ROOM -> context.getString(R.string.multiplayer_already_in_room)
|
||||
NetPlayStatus.CREATE_ROOM_ERROR -> context.getString(R.string.multiplayer_create_room_error)
|
||||
NetPlayStatus.CREATE_ROOM_ERROR -> context.getString(
|
||||
R.string.multiplayer_create_room_error
|
||||
)
|
||||
NetPlayStatus.HOST_KICKED -> context.getString(R.string.multiplayer_host_kicked)
|
||||
NetPlayStatus.UNKNOWN_ERROR -> context.getString(R.string.multiplayer_unknown_error)
|
||||
NetPlayStatus.ROOM_UNINITIALIZED -> context.getString(R.string.multiplayer_room_uninitialized)
|
||||
NetPlayStatus.ROOM_UNINITIALIZED -> context.getString(
|
||||
R.string.multiplayer_room_uninitialized
|
||||
)
|
||||
NetPlayStatus.ROOM_IDLE -> context.getString(R.string.multiplayer_room_idle)
|
||||
NetPlayStatus.ROOM_JOINING -> context.getString(R.string.multiplayer_room_joining)
|
||||
NetPlayStatus.ROOM_JOINED -> context.getString(R.string.multiplayer_room_joined)
|
||||
|
@ -247,7 +254,9 @@ object NetPlayManager {
|
|||
msg
|
||||
)
|
||||
|
||||
NetPlayStatus.ADDRESS_UNBANNED -> context.getString(R.string.multiplayer_address_unbanned)
|
||||
NetPlayStatus.ADDRESS_UNBANNED -> context.getString(
|
||||
R.string.multiplayer_address_unbanned
|
||||
)
|
||||
NetPlayStatus.CHAT_MESSAGE -> msg
|
||||
else -> ""
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
|
||||
package org.yuzu.yuzu_emu.utils
|
||||
|
||||
import android.os.Handler
|
||||
|
@ -17,7 +16,6 @@ object PowerStateUpdater {
|
|||
private var isStarted = false
|
||||
|
||||
fun start() {
|
||||
|
||||
if (isStarted) {
|
||||
return
|
||||
}
|
||||
|
@ -43,4 +41,4 @@ object PowerStateUpdater {
|
|||
}
|
||||
isStarted = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@ object PowerStateUtils {
|
|||
|
||||
@JvmStatic
|
||||
fun getBatteryInfo(context: Context?): IntArray {
|
||||
|
||||
if (context == null) {
|
||||
return intArrayOf(0, 0, 0) // Percentage, IsCharging, HasBattery
|
||||
}
|
||||
|
@ -42,4 +41,4 @@ object PowerStateUtils {
|
|||
|
||||
return results
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,10 +23,12 @@ import org.yuzu.yuzu_emu.features.settings.model.Settings
|
|||
|
||||
object ThemeHelper {
|
||||
const val SYSTEM_BAR_ALPHA = 0.9f
|
||||
|
||||
// Listener that detects if the theme keys are being changed from the setting menu and recreates the activity
|
||||
private var listener: SharedPreferences.OnSharedPreferenceChangeListener? = null
|
||||
private val preferences = PreferenceManager.getDefaultSharedPreferences(YuzuApplication.appContext)
|
||||
|
||||
private val preferences = PreferenceManager.getDefaultSharedPreferences(
|
||||
YuzuApplication.appContext
|
||||
)
|
||||
|
||||
fun setTheme(activity: AppCompatActivity) {
|
||||
setThemeMode(activity)
|
||||
|
@ -52,6 +54,7 @@ object ThemeHelper {
|
|||
private fun getSelectedStaticThemeColor(): Int {
|
||||
val themeIndex = preferences.getInt(Settings.PREF_STATIC_THEME_COLOR, 0)
|
||||
val themes = arrayOf(
|
||||
R.style.Theme_Eden_Main,
|
||||
R.style.Theme_Yuzu_Main_Violet,
|
||||
R.style.Theme_Yuzu_Main_Blue,
|
||||
R.style.Theme_Yuzu_Main_Cyan,
|
||||
|
@ -120,7 +123,11 @@ object ThemeHelper {
|
|||
|
||||
fun ThemeChangeListener(activity: AppCompatActivity) {
|
||||
listener = SharedPreferences.OnSharedPreferenceChangeListener { _, key ->
|
||||
val relevantKeys = listOf(Settings.PREF_STATIC_THEME_COLOR, Settings.PREF_THEME_MODE, Settings.PREF_BLACK_BACKGROUNDS)
|
||||
val relevantKeys = listOf(
|
||||
Settings.PREF_STATIC_THEME_COLOR,
|
||||
Settings.PREF_THEME_MODE,
|
||||
Settings.PREF_BLACK_BACKGROUNDS
|
||||
)
|
||||
if (key in relevantKeys) {
|
||||
activity.recreate()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue