diff --git a/app/src/main/java/dev/lucasnlm/antimine/level/view/EndGameDialogFragment.kt b/app/src/main/java/dev/lucasnlm/antimine/level/view/EndGameDialogFragment.kt index 9fb71ad7..c02be206 100644 --- a/app/src/main/java/dev/lucasnlm/antimine/level/view/EndGameDialogFragment.kt +++ b/app/src/main/java/dev/lucasnlm/antimine/level/view/EndGameDialogFragment.kt @@ -53,15 +53,26 @@ class EndGameDialogFragment : DaggerAppCompatDialogFragment() { .from(context) .inflate(R.layout.dialog_end_game, null, false) .apply { - val title = if (isVictory) - endGameViewModel.randomVictoryEmoji() else endGameViewModel.randomGameOverEmoji() + val title = when { + isVictory -> endGameViewModel.randomVictoryEmoji() + else -> endGameViewModel.randomGameOverEmoji() + } + val titleRes = if (isVictory) R.string.you_won else R.string.you_lost val message = endGameViewModel.messageTo(context, rightMines, totalMines, time, isVictory) - findViewById(R.id.title_emoji).text = title findViewById(R.id.title).text = context.getString(titleRes) findViewById(R.id.subtitle).text = message + findViewById(R.id.title_emoji).apply { + text = title + setOnClickListener { + text = when { + isVictory -> endGameViewModel.randomVictoryEmoji(text.toString()) + else -> endGameViewModel.randomGameOverEmoji(text.toString()) + } + } + } } setView(view) diff --git a/app/src/main/java/dev/lucasnlm/antimine/level/viewmodel/EngGameDialogViewModel.kt b/app/src/main/java/dev/lucasnlm/antimine/level/viewmodel/EngGameDialogViewModel.kt index 94e4b795..dd197e39 100644 --- a/app/src/main/java/dev/lucasnlm/antimine/level/viewmodel/EngGameDialogViewModel.kt +++ b/app/src/main/java/dev/lucasnlm/antimine/level/viewmodel/EngGameDialogViewModel.kt @@ -5,14 +5,14 @@ import androidx.lifecycle.ViewModel import dev.lucasnlm.antimine.R class EngGameDialogViewModel : ViewModel() { - fun randomVictoryEmoji() = listOf( + fun randomVictoryEmoji(except: String? = null) = listOf( "\uD83D\uDE00", "\uD83D\uDE0E", "\uD83D\uDE1D", "\uD83E\uDD73", "\uD83D\uDE06" - ).random() + ).filter { it != except }.random() - fun randomGameOverEmoji() = listOf( + fun randomGameOverEmoji(except: String? = null) = listOf( "\uD83D\uDE10", "\uD83D\uDE44", "\uD83D\uDE25", "\uD83D\uDE13", "\uD83D\uDE31", "\uD83E\uDD2C", "\uD83E\uDD15", "\uD83D\uDE16", "\uD83D\uDCA3", "\uD83D\uDE05" - ).random() + ).filter { it != except }.random() fun messageTo(context: Context, rightMines: Int, totalMines: Int, time: Long, isVictory: Boolean) = when { diff --git a/app/src/main/res/layout/dialog_end_game.xml b/app/src/main/res/layout/dialog_end_game.xml index 008b79dd..3b923a4f 100644 --- a/app/src/main/res/layout/dialog_end_game.xml +++ b/app/src/main/res/layout/dialog_end_game.xml @@ -13,6 +13,8 @@ android:layout_height="wrap_content" android:textColor="#FF000000" android:textSize="52sp" + android:background="?selectableItemBackgroundBorderless" + android:clickable="true" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent"