From 768961d5decef03a4e46a96f4ba368bf1f673a6f Mon Sep 17 00:00:00 2001 From: Lucas Lima Date: Fri, 21 Apr 2023 16:42:13 -0300 Subject: [PATCH 1/5] Bump depedencies --- about/build.gradle | 4 ++-- app/build.gradle | 6 +++--- common/build.gradle | 4 ++-- control/build.gradle | 4 ++-- donation/build.gradle | 4 ++-- gdx/build.gradle | 4 ++-- themes/build.gradle | 4 ++-- tutorial/build.gradle | 4 ++-- ui/build.gradle | 4 ++-- wear/build.gradle | 6 +++--- 10 files changed, 22 insertions(+), 22 deletions(-) diff --git a/about/build.gradle b/about/build.gradle index 2fc4dc6f3..1983604fd 100644 --- a/about/build.gradle +++ b/about/build.gradle @@ -50,8 +50,8 @@ dependencies { // AndroidX implementation 'androidx.appcompat:appcompat:1.6.1' - implementation 'androidx.activity:activity-ktx:1.7.0' - implementation 'androidx.fragment:fragment-ktx:1.5.6' + implementation 'androidx.activity:activity-ktx:1.7.1' + implementation 'androidx.fragment:fragment-ktx:1.5.7' // RecyclerView implementation 'androidx.recyclerview:recyclerview:1.3.0' diff --git a/app/build.gradle b/app/build.gradle index 43b86e6b5..058ec878c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -127,8 +127,8 @@ dependencies { implementation 'androidx.preference:preference-ktx:1.2.0' implementation 'androidx.recyclerview:recyclerview:1.3.0' implementation 'androidx.multidex:multidex:2.0.1' - implementation 'androidx.activity:activity-ktx:1.7.0' - implementation 'androidx.fragment:fragment-ktx:1.5.6' + implementation 'androidx.activity:activity-ktx:1.7.1' + implementation 'androidx.fragment:fragment-ktx:1.5.7' // Lifecycle implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1' @@ -164,7 +164,7 @@ dependencies { testImplementation 'androidx.test:rules:1.5.0' testImplementation 'androidx.test:runner:1.5.2' testImplementation 'androidx.test.espresso:espresso-core:3.5.1' - testImplementation 'androidx.fragment:fragment-testing:1.5.6' + testImplementation 'androidx.fragment:fragment-testing:1.5.7' testImplementation 'org.robolectric:robolectric:4.5.1' testImplementation 'androidx.test.ext:junit:1.1.5' testImplementation 'io.mockk:mockk:1.11.0' diff --git a/common/build.gradle b/common/build.gradle index ceceb77ca..10354132b 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -46,8 +46,8 @@ dependencies { implementation 'androidx.appcompat:appcompat:1.6.1' implementation 'androidx.preference:preference-ktx:1.2.0' implementation 'androidx.recyclerview:recyclerview:1.3.0' - implementation 'androidx.activity:activity-ktx:1.7.0' - implementation 'androidx.fragment:fragment-ktx:1.5.6' + implementation 'androidx.activity:activity-ktx:1.7.1' + implementation 'androidx.fragment:fragment-ktx:1.5.7' // Google implementation 'com.google.android.material:material:1.9.0-beta01' diff --git a/control/build.gradle b/control/build.gradle index 06fb84630..73d7b6e17 100644 --- a/control/build.gradle +++ b/control/build.gradle @@ -49,8 +49,8 @@ dependencies { // AndroidX implementation 'androidx.appcompat:appcompat:1.6.1' - implementation 'androidx.activity:activity-ktx:1.7.0' - implementation 'androidx.fragment:fragment-ktx:1.5.6' + implementation 'androidx.activity:activity-ktx:1.7.1' + implementation 'androidx.fragment:fragment-ktx:1.5.7' // RecyclerView implementation 'androidx.recyclerview:recyclerview:1.3.0' diff --git a/donation/build.gradle b/donation/build.gradle index 7007c9367..8ae31a55e 100644 --- a/donation/build.gradle +++ b/donation/build.gradle @@ -47,8 +47,8 @@ dependencies { // AndroidX implementation 'androidx.appcompat:appcompat:1.6.1' - implementation 'androidx.activity:activity-ktx:1.7.0' - implementation 'androidx.fragment:fragment-ktx:1.5.6' + implementation 'androidx.activity:activity-ktx:1.7.1' + implementation 'androidx.fragment:fragment-ktx:1.5.7' // Google implementation 'com.google.android.material:material:1.9.0-beta01' diff --git a/gdx/build.gradle b/gdx/build.gradle index 89688e5a7..4e3b14bcc 100644 --- a/gdx/build.gradle +++ b/gdx/build.gradle @@ -50,8 +50,8 @@ dependencies { // AndroidX implementation 'androidx.appcompat:appcompat:1.6.1' - implementation 'androidx.activity:activity-ktx:1.7.0' - implementation 'androidx.fragment:fragment-ktx:1.5.6' + implementation 'androidx.activity:activity-ktx:1.7.1' + implementation 'androidx.fragment:fragment-ktx:1.5.7' // Koin implementation 'io.insert-koin:koin-android:3.1.2' diff --git a/themes/build.gradle b/themes/build.gradle index 1164a2f23..b44cab3b5 100644 --- a/themes/build.gradle +++ b/themes/build.gradle @@ -47,8 +47,8 @@ dependencies { // AndroidX implementation 'androidx.appcompat:appcompat:1.6.1' - implementation 'androidx.activity:activity-ktx:1.7.0' - implementation 'androidx.fragment:fragment-ktx:1.5.6' + implementation 'androidx.activity:activity-ktx:1.7.1' + implementation 'androidx.fragment:fragment-ktx:1.5.7' // Google implementation 'com.google.android.material:material:1.9.0-beta01' diff --git a/tutorial/build.gradle b/tutorial/build.gradle index 46e0f6fd9..dab67e906 100644 --- a/tutorial/build.gradle +++ b/tutorial/build.gradle @@ -47,8 +47,8 @@ dependencies { // AndroidX implementation 'androidx.appcompat:appcompat:1.6.1' - implementation 'androidx.activity:activity-ktx:1.7.0' - implementation 'androidx.fragment:fragment-ktx:1.5.6' + implementation 'androidx.activity:activity-ktx:1.7.1' + implementation 'androidx.fragment:fragment-ktx:1.5.7' // Google implementation 'com.google.android.material:material:1.9.0-beta01' diff --git a/ui/build.gradle b/ui/build.gradle index 5e145b9d5..543446abd 100644 --- a/ui/build.gradle +++ b/ui/build.gradle @@ -44,8 +44,8 @@ dependencies { // AndroidX implementation 'androidx.appcompat:appcompat:1.6.1' - implementation 'androidx.activity:activity-ktx:1.7.0' - implementation 'androidx.fragment:fragment-ktx:1.5.6' + implementation 'androidx.activity:activity-ktx:1.7.1' + implementation 'androidx.fragment:fragment-ktx:1.5.7' // RecyclerView implementation 'androidx.recyclerview:recyclerview:1.3.0' diff --git a/wear/build.gradle b/wear/build.gradle index 26d5f209d..0de2fed1c 100644 --- a/wear/build.gradle +++ b/wear/build.gradle @@ -93,8 +93,8 @@ dependencies { implementation 'androidx.preference:preference-ktx:1.2.0' implementation 'androidx.recyclerview:recyclerview:1.3.0' implementation 'androidx.multidex:multidex:2.0.1' - implementation 'androidx.activity:activity-ktx:1.7.0' - implementation 'androidx.fragment:fragment-ktx:1.5.6' + implementation 'androidx.activity:activity-ktx:1.7.1' + implementation 'androidx.fragment:fragment-ktx:1.5.7' // Lifecycle implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1' @@ -127,7 +127,7 @@ dependencies { testImplementation 'androidx.test:rules:1.5.0' testImplementation 'androidx.test:runner:1.5.2' testImplementation 'androidx.test.espresso:espresso-core:3.5.1' - testImplementation 'androidx.fragment:fragment-testing:1.5.6' + testImplementation 'androidx.fragment:fragment-testing:1.5.7' testImplementation 'org.robolectric:robolectric:4.5.1' testImplementation 'androidx.test.ext:junit:1.1.5' testImplementation 'io.mockk:mockk:1.11.0' From 475247f4a84f6bb68bae9825b3cd6dc04f7840ad Mon Sep 17 00:00:00 2001 From: Lucas Lima Date: Fri, 21 Apr 2023 18:06:05 -0300 Subject: [PATCH 2/5] Fix switch action bug --- app/build.gradle | 4 +- .../common/level/view/GameRenderFragment.kt | 29 ++++++------ .../common/level/view/SwitchButtonView.kt | 45 ++++++++++--------- .../antimine/core/audio/GameAudioManager.kt | 1 + .../core/audio/GameAudioManagerImpl.kt | 5 +++ 5 files changed, 48 insertions(+), 36 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 058ec878c..4441e963c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -15,8 +15,8 @@ android { defaultConfig { // versionCode and versionName must be hardcoded to support F-droid - versionCode 1702011 - versionName '17.2.1' + versionCode 1702021 + versionName '17.2.2' minSdkVersion 21 targetSdkVersion 33 multiDexEnabled true diff --git a/common/src/main/java/dev/lucasnlm/antimine/common/level/view/GameRenderFragment.kt b/common/src/main/java/dev/lucasnlm/antimine/common/level/view/GameRenderFragment.kt index b7af3e9f7..a5372c4d0 100644 --- a/common/src/main/java/dev/lucasnlm/antimine/common/level/view/GameRenderFragment.kt +++ b/common/src/main/java/dev/lucasnlm/antimine/common/level/view/GameRenderFragment.kt @@ -14,6 +14,7 @@ import com.badlogic.gdx.backends.android.AndroidFragmentApplication import dev.lucasnlm.antimine.common.level.viewmodel.GameEvent import dev.lucasnlm.antimine.common.level.viewmodel.GameViewModel import dev.lucasnlm.antimine.core.AppVersionManager +import dev.lucasnlm.antimine.core.audio.GameAudioManager import dev.lucasnlm.antimine.core.dpToPx import dev.lucasnlm.antimine.core.repository.DimensionRepository import dev.lucasnlm.antimine.gdx.GameApplicationListener @@ -21,10 +22,8 @@ import dev.lucasnlm.antimine.preferences.PreferencesRepository import dev.lucasnlm.antimine.preferences.models.Action import dev.lucasnlm.antimine.preferences.models.ControlStyle import dev.lucasnlm.antimine.ui.repository.ThemeRepository -import dev.lucasnlm.external.CrashReporter import kotlinx.coroutines.delay -import kotlinx.coroutines.flow.distinctUntilChanged -import kotlinx.coroutines.flow.map +import kotlinx.coroutines.flow.* import kotlinx.coroutines.launch import org.koin.android.ext.android.inject import org.koin.androidx.viewmodel.ext.android.sharedViewModel @@ -35,8 +34,8 @@ open class GameRenderFragment : AndroidFragmentApplication() { private val themeRepository: ThemeRepository by inject() private val dimensionRepository: DimensionRepository by inject() private val preferencesRepository: PreferencesRepository by inject() - private val crashReporter: CrashReporter by inject() private val appVersionManager: AppVersionManager by inject() + private val gameAudioManager: GameAudioManager by inject() private var controlSwitcher: SwitchButtonView? = null private val isWatch = appVersionManager.isWatch() @@ -193,25 +192,29 @@ open class GameRenderFragment : AndroidFragmentApplication() { setOnFlagClickListener { gameViewModel.changeSwitchControlAction(Action.SwitchMark) + gameAudioManager.playSwitchAction() } setOnOpenClickListener { gameViewModel.changeSwitchControlAction(Action.OpenTile) + gameAudioManager.playSwitchAction() } setOnQuestionClickListener { gameViewModel.changeSwitchControlAction(Action.QuestionMark) + gameAudioManager.playSwitchAction() } + }.also { + it.selectDefault() + } - val selectedAction = preferencesRepository.getSwitchControlAction() - val openAsDefault = - selectedAction == Action.OpenTile || selectedAction == Action.QuestionMark - selectOpenAsDefault(openAsDefault) - if (openAsDefault) { - gameViewModel.changeSwitchControlAction(Action.OpenTile) - } else { - gameViewModel.changeSwitchControlAction(Action.SwitchMark) - } + lifecycleScope.launch { + gameViewModel + .observeState() + .filter { it.isGameCompleted || it.turn == 0 } + .collect { + this@GameRenderFragment.controlSwitcher?.selectDefault() + } } addView(this@GameRenderFragment.controlSwitcher, getSwitchControlLayoutParams()) diff --git a/common/src/main/java/dev/lucasnlm/antimine/common/level/view/SwitchButtonView.kt b/common/src/main/java/dev/lucasnlm/antimine/common/level/view/SwitchButtonView.kt index 952c5eab5..91ef42878 100644 --- a/common/src/main/java/dev/lucasnlm/antimine/common/level/view/SwitchButtonView.kt +++ b/common/src/main/java/dev/lucasnlm/antimine/common/level/view/SwitchButtonView.kt @@ -60,43 +60,46 @@ class SwitchButtonView : FrameLayout { } fun setOnFlagClickListener(listener: OnClickListener?) { + flagButton.isSoundEffectsEnabled = false flagButton.setOnClickListener { listener?.onClick(it) - updateMaterialButtonState(flagButton, true) - updateMaterialButtonState(questionButton, false) - updateMaterialButtonState(openButton, false) + selectFlag() } } fun setOnOpenClickListener(listener: OnClickListener?) { + openButton.isSoundEffectsEnabled = false openButton.setOnClickListener { listener?.onClick(it) - updateMaterialButtonState(flagButton, false) - updateMaterialButtonState(questionButton, false) - updateMaterialButtonState(openButton, true) + selectOpen() } } fun setOnQuestionClickListener(listener: OnClickListener?) { + questionButton.isSoundEffectsEnabled = false questionButton.setOnClickListener { listener?.onClick(it) - updateMaterialButtonState(flagButton, false) - updateMaterialButtonState(questionButton, true) - updateMaterialButtonState(openButton, false) + selectQuestionMark() } } - fun selectOpenAsDefault(enabled: Boolean) { - if (currentSelected == null) { - if (enabled) { - updateMaterialButtonState(flagButton, false) - updateMaterialButtonState(questionButton, false) - updateMaterialButtonState(openButton, true) - } else { - updateMaterialButtonState(flagButton, true) - updateMaterialButtonState(questionButton, false) - updateMaterialButtonState(openButton, false) - } - } + private fun selectQuestionMark() { + updateMaterialButtonState(flagButton, false) + updateMaterialButtonState(questionButton, true) + updateMaterialButtonState(openButton, false) + } + + private fun selectOpen() { + updateMaterialButtonState(flagButton, false) + updateMaterialButtonState(questionButton, false) + updateMaterialButtonState(openButton, true) + } + + private fun selectFlag() { + updateMaterialButtonState(flagButton, true) + updateMaterialButtonState(questionButton, false) + updateMaterialButtonState(openButton, false) } + + fun selectDefault() = selectFlag() } diff --git a/core/src/main/java/dev/lucasnlm/antimine/core/audio/GameAudioManager.kt b/core/src/main/java/dev/lucasnlm/antimine/core/audio/GameAudioManager.kt index d8fe195d3..d1b6ad8ec 100644 --- a/core/src/main/java/dev/lucasnlm/antimine/core/audio/GameAudioManager.kt +++ b/core/src/main/java/dev/lucasnlm/antimine/core/audio/GameAudioManager.kt @@ -15,6 +15,7 @@ interface GameAudioManager { fun playRevealBomb() fun playMonetization() fun playRevealBombReloaded() + fun playSwitchAction() fun free() fun getComposerData(): List } diff --git a/core/src/main/java/dev/lucasnlm/antimine/core/audio/GameAudioManagerImpl.kt b/core/src/main/java/dev/lucasnlm/antimine/core/audio/GameAudioManagerImpl.kt index e0f990115..dd6b1037f 100644 --- a/core/src/main/java/dev/lucasnlm/antimine/core/audio/GameAudioManagerImpl.kt +++ b/core/src/main/java/dev/lucasnlm/antimine/core/audio/GameAudioManagerImpl.kt @@ -118,6 +118,11 @@ class GameAudioManagerImpl( playSoundFromAssets(fileName) } + override fun playSwitchAction() { + val fileName = revealBombReloadFile() + playSoundFromAssets(fileName) + } + override fun free() { stopMusic() } From d82d13b004e2a1b922ec02ca192863ce19c9cd66 Mon Sep 17 00:00:00 2001 From: Lucas Lima Date: Fri, 21 Apr 2023 18:39:11 -0300 Subject: [PATCH 3/5] Add gdx check to github workflows --- .github/workflows/android.yml | 14 +++++++++++++- gdx/check_import.sh | 22 ++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100755 gdx/check_import.sh diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 407f5f168..69427d5e1 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -6,6 +6,18 @@ on: - main jobs: + libgdx: + name: Check LibGDX import + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Run script + run: | + chmod +x ./gdx/check_import.sh + bash ./gdx/check_import.sh ./gdx/build.gradle + shell: bash + ktlint: name: Check Code Quality runs-on: ubuntu-latest @@ -15,7 +27,7 @@ jobs: uses: actions/checkout@v2 with: fetch-depth: 1 - - name: Run Ktlint + - name: Run ktlint uses: lucasnlm/ktlint-action@master test: diff --git a/gdx/check_import.sh b/gdx/check_import.sh new file mode 100755 index 000000000..f4475aef8 --- /dev/null +++ b/gdx/check_import.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# Check if a file was provided as argument +if [ $# -eq 0 ]; then + echo "Error: Please provide a filename as argument." + exit 1 +fi + +# Check if the file exists +if [ ! -f "$1" ]; then + echo "Error: File '$1' not found." + exit 1 +fi + +# Check if the file contains the string in an unique line +if grep -xq "preBuild.dependsOn copyAndroidNatives" "$1"; then + echo "achou" + exit 0 +else + echo "n achou" + exit 1 +fi From df19d6090f1c4f7da46ef6f9ffef7da9f43c94b1 Mon Sep 17 00:00:00 2001 From: Lucas Lima Date: Fri, 21 Apr 2023 18:40:34 -0300 Subject: [PATCH 4/5] Test check --- gdx/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdx/build.gradle b/gdx/build.gradle index 4e3b14bcc..47e331c33 100644 --- a/gdx/build.gradle +++ b/gdx/build.gradle @@ -90,4 +90,4 @@ task copyAndroidNatives { } } -preBuild.dependsOn copyAndroidNatives +//preBuild.dependsOn copyAndroidNatives From 02db63b5267d4cf23646a65ec8b9f4b6b92379fb Mon Sep 17 00:00:00 2001 From: Lucas Lima Date: Fri, 21 Apr 2023 18:43:01 -0300 Subject: [PATCH 5/5] Revert "Test check" This reverts commit df19d6090f1c4f7da46ef6f9ffef7da9f43c94b1. --- gdx/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdx/build.gradle b/gdx/build.gradle index 47e331c33..4e3b14bcc 100644 --- a/gdx/build.gradle +++ b/gdx/build.gradle @@ -90,4 +90,4 @@ task copyAndroidNatives { } } -//preBuild.dependsOn copyAndroidNatives +preBuild.dependsOn copyAndroidNatives