summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorCharles Lombardo <clombardo169@gmail.com>2023-08-21 22:25:11 +0200
committerGitHub <noreply@github.com>2023-08-21 22:25:11 +0200
commitdf00da1760dcf336015c6e18233d293fb1fd6cf4 (patch)
tree9a50270b13f8064fcc27940a1561a899c146dac4 /src
parentMerge pull request #11309 from liamwhite/full-xci (diff)
downloadyuzu-df00da1760dcf336015c6e18233d293fb1fd6cf4.tar
yuzu-df00da1760dcf336015c6e18233d293fb1fd6cf4.tar.gz
yuzu-df00da1760dcf336015c6e18233d293fb1fd6cf4.tar.bz2
yuzu-df00da1760dcf336015c6e18233d293fb1fd6cf4.tar.lz
yuzu-df00da1760dcf336015c6e18233d293fb1fd6cf4.tar.xz
yuzu-df00da1760dcf336015c6e18233d293fb1fd6cf4.tar.zst
yuzu-df00da1760dcf336015c6e18233d293fb1fd6cf4.zip
Diffstat (limited to 'src')
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/adapters/HomeSettingAdapter.kt24
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/HomeSettingsFragment.kt12
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/model/HomeSetting.kt6
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/model/HomeViewModel.kt19
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt1
-rw-r--r--src/android/app/src/main/res/layout/card_home_option.xml17
6 files changed, 75 insertions, 4 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/adapters/HomeSettingAdapter.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/adapters/HomeSettingAdapter.kt
index aadc445f9..9f859b442 100644
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/adapters/HomeSettingAdapter.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/adapters/HomeSettingAdapter.kt
@@ -3,19 +3,25 @@
package org.yuzu.yuzu_emu.adapters
+import android.text.TextUtils
import android.view.LayoutInflater
import android.view.View
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 androidx.recyclerview.widget.RecyclerView
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
-class HomeSettingAdapter(private val activity: AppCompatActivity, var options: List<HomeSetting>) :
+class HomeSettingAdapter(
+ private val activity: AppCompatActivity,
+ private val viewLifecycle: LifecycleOwner,
+ var options: List<HomeSetting>
+) :
RecyclerView.Adapter<HomeSettingAdapter.HomeOptionViewHolder>(),
View.OnClickListener {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): HomeOptionViewHolder {
@@ -79,6 +85,22 @@ class HomeSettingAdapter(private val activity: AppCompatActivity, var options: L
binding.optionDescription.alpha = 0.5f
binding.optionIcon.alpha = 0.5f
}
+
+ option.details.observe(viewLifecycle) { updateOptionDetails(it) }
+ binding.optionDetail.postDelayed(
+ {
+ binding.optionDetail.ellipsize = TextUtils.TruncateAt.MARQUEE
+ binding.optionDetail.isSelected = true
+ },
+ 3000
+ )
+ }
+
+ private fun updateOptionDetails(detailString: String) {
+ if (detailString.isNotEmpty()) {
+ binding.optionDetail.text = detailString
+ binding.optionDetail.visibility = View.VISIBLE
+ }
}
}
}
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/HomeSettingsFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/HomeSettingsFragment.kt
index c001af892..d5e793491 100644
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/HomeSettingsFragment.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/HomeSettingsFragment.kt
@@ -129,7 +129,11 @@ class HomeSettingsFragment : Fragment() {
mainActivity.getGamesDirectory.launch(
Intent(Intent.ACTION_OPEN_DOCUMENT_TREE).data
)
- }
+ },
+ { true },
+ 0,
+ 0,
+ homeViewModel.gamesDir
)
)
add(
@@ -201,7 +205,11 @@ class HomeSettingsFragment : Fragment() {
binding.homeSettingsList.apply {
layoutManager = LinearLayoutManager(requireContext())
- adapter = HomeSettingAdapter(requireActivity() as AppCompatActivity, optionsList)
+ adapter = HomeSettingAdapter(
+ requireActivity() as AppCompatActivity,
+ viewLifecycleOwner,
+ optionsList
+ )
}
setInsets()
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/model/HomeSetting.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/model/HomeSetting.kt
index 522d07c37..498c222fa 100644
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/model/HomeSetting.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/model/HomeSetting.kt
@@ -3,6 +3,9 @@
package org.yuzu.yuzu_emu.model
+import androidx.lifecycle.LiveData
+import androidx.lifecycle.MutableLiveData
+
data class HomeSetting(
val titleId: Int,
val descriptionId: Int,
@@ -10,5 +13,6 @@ data class HomeSetting(
val onClick: () -> Unit,
val isEnabled: () -> Boolean = { true },
val disabledTitleId: Int = 0,
- val disabledMessageId: Int = 0
+ val disabledMessageId: Int = 0,
+ val details: LiveData<String> = MutableLiveData("")
)
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/model/HomeViewModel.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/model/HomeViewModel.kt
index e13d84c9c..a48ef7a88 100644
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/model/HomeViewModel.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/model/HomeViewModel.kt
@@ -3,9 +3,15 @@
package org.yuzu.yuzu_emu.model
+import android.net.Uri
+import androidx.fragment.app.FragmentActivity
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
+import androidx.lifecycle.ViewModelProvider
+import androidx.preference.PreferenceManager
+import org.yuzu.yuzu_emu.YuzuApplication
+import org.yuzu.yuzu_emu.utils.GameHelper
class HomeViewModel : ViewModel() {
private val _navigationVisible = MutableLiveData<Pair<Boolean, Boolean>>()
@@ -17,6 +23,14 @@ class HomeViewModel : ViewModel() {
private val _shouldPageForward = MutableLiveData(false)
val shouldPageForward: LiveData<Boolean> get() = _shouldPageForward
+ private val _gamesDir = MutableLiveData(
+ Uri.parse(
+ PreferenceManager.getDefaultSharedPreferences(YuzuApplication.appContext)
+ .getString(GameHelper.KEY_GAME_PATH, "")
+ ).path ?: ""
+ )
+ val gamesDir: LiveData<String> get() = _gamesDir
+
var navigatedToSetup = false
init {
@@ -40,4 +54,9 @@ class HomeViewModel : ViewModel() {
fun setShouldPageForward(pageForward: Boolean) {
_shouldPageForward.value = pageForward
}
+
+ fun setGamesDir(activity: FragmentActivity, dir: String) {
+ ViewModelProvider(activity)[GamesViewModel::class.java].reloadGames(true)
+ _gamesDir.value = dir
+ }
}
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt
index f77d06262..aaf3a0ec1 100644
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt
@@ -290,6 +290,7 @@ class MainActivity : AppCompatActivity(), ThemeProvider {
).show()
gamesViewModel.reloadGames(true)
+ homeViewModel.setGamesDir(this, result.path!!)
}
val getProdKey =
diff --git a/src/android/app/src/main/res/layout/card_home_option.xml b/src/android/app/src/main/res/layout/card_home_option.xml
index dc289db17..f9f1d89fb 100644
--- a/src/android/app/src/main/res/layout/card_home_option.xml
+++ b/src/android/app/src/main/res/layout/card_home_option.xml
@@ -53,6 +53,23 @@
android:layout_marginTop="5dp"
tools:text="@string/install_prod_keys_description" />
+ <com.google.android.material.textview.MaterialTextView
+ style="@style/TextAppearance.Material3.LabelMedium"
+ android:id="@+id/option_detail"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:textAlignment="viewStart"
+ android:textSize="14sp"
+ android:textStyle="bold"
+ android:singleLine="true"
+ android:marqueeRepeatLimit="marquee_forever"
+ android:ellipsize="none"
+ android:requiresFadingEdge="horizontal"
+ android:layout_marginTop="5dp"
+ android:visibility="gone"
+ tools:visibility="visible"
+ tools:text="/tree/primary:Games" />
+
</LinearLayout>
</LinearLayout>