mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-07-04 23:31:19 +01:00
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.
This commit is contained in:
parent
f984775f12
commit
388dc0757f
3 changed files with 65 additions and 59 deletions
|
@ -6,6 +6,7 @@ package org.yuzu.yuzu_emu.adapters
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.graphics.BitmapFactory
|
import android.graphics.BitmapFactory
|
||||||
|
import android.text.TextUtils
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
@ -31,7 +32,7 @@ class GameAdapter(private val activity: AppCompatActivity) :
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): GameViewHolder {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): GameViewHolder {
|
||||||
// Create a new view.
|
// Create a new view.
|
||||||
val binding = CardGameBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
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.
|
// Use that view to create a ViewHolder.
|
||||||
return GameViewHolder(binding)
|
return GameViewHolder(binding)
|
||||||
|
@ -58,7 +59,7 @@ class GameAdapter(private val activity: AppCompatActivity) :
|
||||||
lateinit var game: Game
|
lateinit var game: Game
|
||||||
|
|
||||||
init {
|
init {
|
||||||
itemView.tag = this
|
binding.cardGame.tag = this
|
||||||
}
|
}
|
||||||
|
|
||||||
fun bind(game: Game) {
|
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.textGameTitle.text = game.title.replace("[\\t\\n\\r]+".toRegex(), " ")
|
||||||
binding.textGameCaption.text = game.company
|
|
||||||
|
|
||||||
if (game.company.isEmpty()) {
|
binding.textGameTitle.postDelayed(
|
||||||
binding.textGameCaption.visibility = View.GONE
|
{
|
||||||
}
|
binding.textGameTitle.ellipsize = TextUtils.TruncateAt.MARQUEE
|
||||||
|
binding.textGameTitle.isSelected = true
|
||||||
|
},
|
||||||
|
3000
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,25 +1,35 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<FrameLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<com.google.android.material.card.MaterialCardView
|
||||||
|
style="?attr/materialCardViewElevatedStyle"
|
||||||
|
android:id="@+id/card_game"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:foreground="?attr/selectableItemBackground"
|
android:background="?attr/selectableItemBackground"
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
android:clipToPadding="false"
|
android:clipToPadding="false"
|
||||||
android:focusable="true"
|
android:focusable="true"
|
||||||
android:paddingStart="4dp"
|
android:transitionName="card_game"
|
||||||
android:paddingTop="8dp"
|
android:layout_gravity="center"
|
||||||
android:paddingEnd="4dp"
|
app:cardElevation="0dp"
|
||||||
android:paddingBottom="8dp"
|
app:cardCornerRadius="12dp">
|
||||||
android:transitionName="card_game">
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="6dp">
|
||||||
|
|
||||||
<com.google.android.material.card.MaterialCardView
|
<com.google.android.material.card.MaterialCardView
|
||||||
style="?attr/materialCardViewElevatedStyle"
|
style="?attr/materialCardViewElevatedStyle"
|
||||||
android:id="@+id/card_game_art"
|
android:id="@+id/card_game_art"
|
||||||
android:layout_width="140dp"
|
android:layout_width="150dp"
|
||||||
android:layout_height="140dp"
|
android:layout_height="150dp"
|
||||||
app:cardCornerRadius="4dp"
|
app:cardCornerRadius="4dp"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
@ -33,32 +43,24 @@
|
||||||
</com.google.android.material.card.MaterialCardView>
|
</com.google.android.material.card.MaterialCardView>
|
||||||
|
|
||||||
<com.google.android.material.textview.MaterialTextView
|
<com.google.android.material.textview.MaterialTextView
|
||||||
style="@style/TextAppearance.Material3.BodyLarge"
|
style="@style/TextAppearance.Material3.TitleMedium"
|
||||||
android:id="@+id/text_game_title"
|
android:id="@+id/text_game_title"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:ellipsize="end"
|
android:layout_marginTop="8dp"
|
||||||
android:maxLines="2"
|
android:textAlignment="center"
|
||||||
android:paddingTop="8dp"
|
android:textSize="14sp"
|
||||||
android:textAlignment="viewStart"
|
android:singleLine="true"
|
||||||
|
android:marqueeRepeatLimit="marquee_forever"
|
||||||
|
android:ellipsize="none"
|
||||||
|
android:requiresFadingEdge="horizontal"
|
||||||
app:layout_constraintEnd_toEndOf="@+id/card_game_art"
|
app:layout_constraintEnd_toEndOf="@+id/card_game_art"
|
||||||
app:layout_constraintStart_toStartOf="@+id/card_game_art"
|
app:layout_constraintStart_toStartOf="@+id/card_game_art"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/card_game_art"
|
app:layout_constraintTop_toBottomOf="@+id/card_game_art"
|
||||||
tools:text="Super Mario Odyssey" />
|
tools:text="The Legend of Zelda: Skyward Sword" />
|
||||||
|
|
||||||
<com.google.android.material.textview.MaterialTextView
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
style="@style/TextAppearance.Material3.BodyMedium"
|
|
||||||
android:id="@+id/text_game_caption"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:ellipsize="end"
|
|
||||||
android:lines="1"
|
|
||||||
android:maxLines="1"
|
|
||||||
android:paddingTop="8dp"
|
|
||||||
android:textAlignment="viewStart"
|
|
||||||
app:layout_constraintEnd_toEndOf="@+id/card_game_art"
|
|
||||||
app:layout_constraintStart_toStartOf="@+id/card_game_art"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/text_game_title"
|
|
||||||
tools:text="Nintendo" />
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</com.google.android.material.card.MaterialCardView>
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
<dimen name="spacing_refresh_start">32dp</dimen>
|
<dimen name="spacing_refresh_start">32dp</dimen>
|
||||||
<dimen name="spacing_refresh_end">96dp</dimen>
|
<dimen name="spacing_refresh_end">96dp</dimen>
|
||||||
<dimen name="menu_width">256dp</dimen>
|
<dimen name="menu_width">256dp</dimen>
|
||||||
<dimen name="card_width">160dp</dimen>
|
<dimen name="card_width">165dp</dimen>
|
||||||
|
|
||||||
<dimen name="dialog_margin">20dp</dimen>
|
<dimen name="dialog_margin">20dp</dimen>
|
||||||
<dimen name="elevated_app_bar">3dp</dimen>
|
<dimen name="elevated_app_bar">3dp</dimen>
|
||||||
|
|
Loading…
Reference in a new issue