diff --git a/app/src/main/java/dev/lucasnlm/antimine/history/viewmodel/HistoryViewModel.kt b/app/src/main/java/dev/lucasnlm/antimine/history/viewmodel/HistoryViewModel.kt index 7f56e0ce..8f14d0b8 100644 --- a/app/src/main/java/dev/lucasnlm/antimine/history/viewmodel/HistoryViewModel.kt +++ b/app/src/main/java/dev/lucasnlm/antimine/history/viewmodel/HistoryViewModel.kt @@ -31,7 +31,7 @@ class HistoryViewModel @ViewModelInject constructor( } } - override suspend fun mapEventToState(event: HistoryEvent) = flow { + override suspend fun mapEventToState(event: HistoryEvent) = flow { when (event) { is HistoryEvent.LoadAllSaves -> { val newSaveList = savesRepository.getAllSaves().sortedByDescending { it.uid } diff --git a/app/src/main/java/dev/lucasnlm/antimine/level/view/LevelFragment.kt b/app/src/main/java/dev/lucasnlm/antimine/level/view/LevelFragment.kt index 91a0451e..ed51cb3e 100644 --- a/app/src/main/java/dev/lucasnlm/antimine/level/view/LevelFragment.kt +++ b/app/src/main/java/dev/lucasnlm/antimine/level/view/LevelFragment.kt @@ -68,13 +68,6 @@ open class LevelFragment : CommonLevelFragment(R.layout.fragment_level) { } ) - fieldRefresh.observe( - viewLifecycleOwner, - Observer { - areaAdapter.notifyItemChanged(it) - } - ) - eventObserver.observe( viewLifecycleOwner, Observer { diff --git a/app/src/main/java/dev/lucasnlm/antimine/level/viewmodel/EndGameDialogViewModel.kt b/app/src/main/java/dev/lucasnlm/antimine/level/viewmodel/EndGameDialogViewModel.kt index 0642fb6d..5d3f9b5b 100644 --- a/app/src/main/java/dev/lucasnlm/antimine/level/viewmodel/EndGameDialogViewModel.kt +++ b/app/src/main/java/dev/lucasnlm/antimine/level/viewmodel/EndGameDialogViewModel.kt @@ -75,7 +75,7 @@ class EndGameDialogViewModel @ViewModelInject constructor( false ) - override suspend fun mapEventToState(event: EndGameDialogEvent) = flow { + override suspend fun mapEventToState(event: EndGameDialogEvent) = flow { if (event is EndGameDialogEvent.BuildCustomEndGame) { val state = when (event.isVictory) { true -> { diff --git a/app/src/main/java/dev/lucasnlm/antimine/theme/viewmodel/ThemeViewModel.kt b/app/src/main/java/dev/lucasnlm/antimine/theme/viewmodel/ThemeViewModel.kt index 1b740215..2b6474b5 100644 --- a/app/src/main/java/dev/lucasnlm/antimine/theme/viewmodel/ThemeViewModel.kt +++ b/app/src/main/java/dev/lucasnlm/antimine/theme/viewmodel/ThemeViewModel.kt @@ -13,7 +13,7 @@ class ThemeViewModel @ViewModelInject constructor( themeRepository.setTheme(theme) } - override suspend fun mapEventToState(event: ThemeEvent) = flow { + override suspend fun mapEventToState(event: ThemeEvent) = flow { if (event is ThemeEvent.ChangeTheme) { setTheme(event.newTheme) emit(state.copy(current = event.newTheme)) diff --git a/app/src/main/res/layout/activity_game.xml b/app/src/main/res/layout/activity_game.xml index 3bcd5f79..dfc75dc2 100644 --- a/app/src/main/res/layout/activity_game.xml +++ b/app/src/main/res/layout/activity_game.xml @@ -31,7 +31,6 @@ android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_marginEnd="10dp" - android:layout_marginRight="10dp" android:drawablePadding="8dp" android:gravity="center_vertical" android:includeFontPadding="false" diff --git a/app/src/main/res/layout/activity_tv_game.xml b/app/src/main/res/layout/activity_tv_game.xml index 3c2b2a8c..41128208 100644 --- a/app/src/main/res/layout/activity_tv_game.xml +++ b/app/src/main/res/layout/activity_tv_game.xml @@ -1,5 +1,6 @@ @@ -29,9 +30,6 @@ android:layout_height="match_parent" android:layout_gravity="center_vertical" android:layout_marginEnd="10dp" - android:layout_marginRight="10dp" - android:drawableStart="@drawable/timer" - android:drawableLeft="@drawable/timer" android:drawablePadding="8dp" android:gravity="center_vertical" android:includeFontPadding="false" @@ -41,6 +39,8 @@ android:textSize="@dimen/text_size" android:textStyle="bold" android:visibility="gone" + app:drawableLeftCompat="@drawable/timer" + app:drawableStartCompat="@drawable/timer" tools:text="10:00" tools:visibility="visible" /> @@ -49,8 +49,6 @@ android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="center_vertical" - android:drawableStart="@drawable/mine" - android:drawableLeft="@drawable/mine" android:drawablePadding="8dp" android:gravity="center_vertical" android:includeFontPadding="false" @@ -59,6 +57,7 @@ android:textSize="@dimen/text_size" android:textStyle="bold" android:visibility="gone" + app:drawableStartCompat="@drawable/mine" tools:text="99" tools:visibility="visible" /> diff --git a/app/src/main/res/layout/view_control_item.xml b/app/src/main/res/layout/view_control_item.xml index d08c9e76..28480e42 100644 --- a/app/src/main/res/layout/view_control_item.xml +++ b/app/src/main/res/layout/view_control_item.xml @@ -9,8 +9,6 @@ android:background="?android:attr/selectableItemBackground" android:clickable="true" android:focusable="true" - android:paddingLeft="32dp" - android:paddingRight="48dp" android:paddingStart="32dp" android:paddingEnd="48dp" android:paddingVertical="12dp"> diff --git a/app/src/main/res/layout/view_history_item.xml b/app/src/main/res/layout/view_history_item.xml index 8d8a51c8..499461b0 100644 --- a/app/src/main/res/layout/view_history_item.xml +++ b/app/src/main/res/layout/view_history_item.xml @@ -24,7 +24,6 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:textStyle="bold" - android:layout_marginLeft="8dp" android:layout_marginStart="8dp" app:layout_constraintStart_toEndOf="@id/badge" app:layout_constraintTop_toTopOf="parent" @@ -35,7 +34,6 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="4dp" - android:layout_marginLeft="8dp" android:layout_marginStart="8dp" app:layout_constraintStart_toEndOf="@id/badge" app:layout_constraintTop_toBottomOf="@id/difficulty" @@ -46,7 +44,6 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="8dp" - android:layout_marginLeft="8dp" android:layout_marginTop="4dp" android:text="-" app:layout_constraintStart_toEndOf="@id/minefieldSize" @@ -58,7 +55,6 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="8dp" - android:layout_marginLeft="8dp" android:layout_marginTop="4dp" app:layout_constraintStart_toEndOf="@id/dash" app:layout_constraintTop_toBottomOf="@id/difficulty" diff --git a/app/src/main/res/layout/view_play_games_button.xml b/app/src/main/res/layout/view_play_games_button.xml index cd9f0dab..e3aac3f5 100644 --- a/app/src/main/res/layout/view_play_games_button.xml +++ b/app/src/main/res/layout/view_play_games_button.xml @@ -27,7 +27,6 @@ android:layout_weight="1" android:layout_gravity="center_vertical" android:textStyle="bold" - android:layout_marginLeft="8dp" android:layout_marginStart="8dp" tools:text="Text" /> diff --git a/common/src/main/java/dev/lucasnlm/antimine/common/level/GameController.kt b/common/src/main/java/dev/lucasnlm/antimine/common/level/GameController.kt index e4f862db..9c00cc44 100644 --- a/common/src/main/java/dev/lucasnlm/antimine/common/level/GameController.kt +++ b/common/src/main/java/dev/lucasnlm/antimine/common/level/GameController.kt @@ -167,7 +167,7 @@ class GameController { } } - fun findExplodedMine() = mines().filter { it.mistake }.firstOrNull() + fun findExplodedMine() = mines().firstOrNull { it.mistake } fun takeExplosionRadius(target: Area): List = mines().filter { it.isCovered && it.mark.isNone() }.sortedBy { diff --git a/common/src/main/java/dev/lucasnlm/antimine/common/level/repository/DimensionRepository.kt b/common/src/main/java/dev/lucasnlm/antimine/common/level/repository/DimensionRepository.kt index 4096c073..937121ef 100644 --- a/common/src/main/java/dev/lucasnlm/antimine/common/level/repository/DimensionRepository.kt +++ b/common/src/main/java/dev/lucasnlm/antimine/common/level/repository/DimensionRepository.kt @@ -61,7 +61,6 @@ class DimensionRepository( } override fun navigationBarHeight(): Int { - // TODO use official mode if available val resources = context.resources val resourceId: Int = resources.getIdentifier(NAVIGATION_BAR_HEIGHT, DEF_TYPE_DIMEN, DEF_PACKAGE) return if (resourceId > 0) { resources.getDimensionPixelSize(resourceId) } else 0 diff --git a/common/src/main/java/dev/lucasnlm/antimine/common/level/view/AreaAdapter.kt b/common/src/main/java/dev/lucasnlm/antimine/common/level/view/AreaAdapter.kt index 38709908..cdf1b623 100644 --- a/common/src/main/java/dev/lucasnlm/antimine/common/level/view/AreaAdapter.kt +++ b/common/src/main/java/dev/lucasnlm/antimine/common/level/view/AreaAdapter.kt @@ -57,17 +57,19 @@ class AreaAdapter( override fun getItemCount(): Int = field.size private fun AreaView.onClickablePosition(position: Int, action: suspend (Int) -> Unit): Boolean { - return if (position == RecyclerView.NO_POSITION) { - Log.d(TAG, "Item no longer exists.") - false - } else if (clickEnabled) { - requestFocus() - GlobalScope.launch { - action(position) + return when { + position == RecyclerView.NO_POSITION -> { + Log.d(TAG, "Item no longer exists.") + false } - true - } else { - false + clickEnabled -> { + requestFocus() + GlobalScope.launch { + action(position) + } + true + } + else -> false } } diff --git a/common/src/main/java/dev/lucasnlm/antimine/common/level/view/AreaView.kt b/common/src/main/java/dev/lucasnlm/antimine/common/level/view/AreaView.kt index 05943a3c..32f05e64 100755 --- a/common/src/main/java/dev/lucasnlm/antimine/common/level/view/AreaView.kt +++ b/common/src/main/java/dev/lucasnlm/antimine/common/level/view/AreaView.kt @@ -106,12 +106,7 @@ class AreaView : View { area.hasMine -> IMPORTANT_FOR_ACCESSIBILITY_YES area.mistake -> IMPORTANT_FOR_ACCESSIBILITY_YES area.mark.isNotNone() -> IMPORTANT_FOR_ACCESSIBILITY_YES - !area.isCovered -> - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS - } else { - IMPORTANT_FOR_ACCESSIBILITY_NO - } + !area.isCovered -> IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS else -> IMPORTANT_FOR_ACCESSIBILITY_YES } ) diff --git a/common/src/main/java/dev/lucasnlm/antimine/common/level/viewmodel/GameViewModel.kt b/common/src/main/java/dev/lucasnlm/antimine/common/level/viewmodel/GameViewModel.kt index 9befde6d..24a68e9f 100644 --- a/common/src/main/java/dev/lucasnlm/antimine/common/level/viewmodel/GameViewModel.kt +++ b/common/src/main/java/dev/lucasnlm/antimine/common/level/viewmodel/GameViewModel.kt @@ -54,7 +54,6 @@ class GameViewModel @ViewModelInject constructor( private var currentDifficulty: Difficulty = Difficulty.Standard val field = MutableLiveData>() - val fieldRefresh = MutableLiveData() val elapsedTimeSeconds = MutableLiveData() val mineCount = MutableLiveData() val difficulty = MutableLiveData() diff --git a/wear/src/main/java/dev/lucasnlm/antimine/wear/WatchLevelFragment.kt b/wear/src/main/java/dev/lucasnlm/antimine/wear/WatchLevelFragment.kt index 69f507f4..d089235e 100644 --- a/wear/src/main/java/dev/lucasnlm/antimine/wear/WatchLevelFragment.kt +++ b/wear/src/main/java/dev/lucasnlm/antimine/wear/WatchLevelFragment.kt @@ -63,12 +63,7 @@ class WatchLevelFragment : CommonLevelFragment(R.layout.fragment_level) { } } ) - fieldRefresh.observe( - viewLifecycleOwner, - Observer { - areaAdapter.notifyItemChanged(it) - } - ) + eventObserver.observe( viewLifecycleOwner, Observer {