From 388dc0757fa55ee93e53de7e271a01cb7d09398a Mon Sep 17 00:00:00 2001 From: Charles Lombardo Date: Mon, 24 Apr 2023 05:05:24 -0400 Subject: [PATCH] android: Shape/spacing adjustments to game card Ripple effect now reaches into rounded corners, icon size changed, company text removed, title font adjusted, and spacing around the card was adjusted as well. Text also doesn't get cut off anymore and instead scrolls indefinitely on one line. --- .../org/yuzu/yuzu_emu/adapters/GameAdapter.kt | 16 ++- .../app/src/main/res/layout/card_game.xml | 106 +++++++++--------- .../app/src/main/res/values/dimens.xml | 2 +- 3 files changed, 65 insertions(+), 59 deletions(-) diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/adapters/GameAdapter.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/adapters/GameAdapter.kt index 77288b6d8..eca84a694 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/adapters/GameAdapter.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/adapters/GameAdapter.kt @@ -6,6 +6,7 @@ package org.yuzu.yuzu_emu.adapters import android.annotation.SuppressLint import android.graphics.Bitmap import android.graphics.BitmapFactory +import android.text.TextUtils import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -31,7 +32,7 @@ class GameAdapter(private val activity: AppCompatActivity) : override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): GameViewHolder { // Create a new view. val binding = CardGameBinding.inflate(LayoutInflater.from(parent.context), parent, false) - binding.root.setOnClickListener(this) + binding.cardGame.setOnClickListener(this) // Use that view to create a ViewHolder. return GameViewHolder(binding) @@ -58,7 +59,7 @@ class GameAdapter(private val activity: AppCompatActivity) : lateinit var game: Game init { - itemView.tag = this + binding.cardGame.tag = this } fun bind(game: Game) { @@ -73,11 +74,14 @@ class GameAdapter(private val activity: AppCompatActivity) : } binding.textGameTitle.text = game.title.replace("[\\t\\n\\r]+".toRegex(), " ") - binding.textGameCaption.text = game.company - if (game.company.isEmpty()) { - binding.textGameCaption.visibility = View.GONE - } + binding.textGameTitle.postDelayed( + { + binding.textGameTitle.ellipsize = TextUtils.TruncateAt.MARQUEE + binding.textGameTitle.isSelected = true + }, + 3000 + ) } } diff --git a/src/android/app/src/main/res/layout/card_game.xml b/src/android/app/src/main/res/layout/card_game.xml index 4b7d2b3cc..469ad9edf 100644 --- a/src/android/app/src/main/res/layout/card_game.xml +++ b/src/android/app/src/main/res/layout/card_game.xml @@ -1,64 +1,66 @@ - + android:layout_height="wrap_content"> + android:id="@+id/card_game" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:background="?attr/selectableItemBackground" + android:clickable="true" + android:clipToPadding="false" + android:focusable="true" + android:transitionName="card_game" + android:layout_gravity="center" + app:cardElevation="0dp" + app:cardCornerRadius="12dp"> - + + + + + + + + + + + - - - - - + diff --git a/src/android/app/src/main/res/values/dimens.xml b/src/android/app/src/main/res/values/dimens.xml index 23977c9f1..ab2583938 100644 --- a/src/android/app/src/main/res/values/dimens.xml +++ b/src/android/app/src/main/res/values/dimens.xml @@ -11,7 +11,7 @@ 32dp 96dp 256dp - 160dp + 165dp 20dp 3dp