Skip to content

Commit

Permalink
Merge pull request #427 from lucasnlm/fix-bugs
Browse files Browse the repository at this point in the history
Fix bugs
  • Loading branch information
lucasnlm authored Apr 21, 2023
2 parents 74dcedf + 02db63b commit 169be1a
Show file tree
Hide file tree
Showing 16 changed files with 105 additions and 59 deletions.
14 changes: 13 additions & 1 deletion .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions about/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
10 changes: 5 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,16 @@ 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
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
Expand All @@ -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()
Expand Down Expand Up @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
4 changes: 2 additions & 2 deletions control/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ interface GameAudioManager {
fun playRevealBomb()
fun playMonetization()
fun playRevealBombReloaded()
fun playSwitchAction()
fun free()
fun getComposerData(): List<ComposerData>
}
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ class GameAudioManagerImpl(
playSoundFromAssets(fileName)
}

override fun playSwitchAction() {
val fileName = revealBombReloadFile()
playSoundFromAssets(fileName)
}

override fun free() {
stopMusic()
}
Expand Down
4 changes: 2 additions & 2 deletions donation/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions gdx/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
22 changes: 22 additions & 0 deletions gdx/check_import.sh
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions themes/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions tutorial/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions ui/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
6 changes: 3 additions & 3 deletions wear/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand Down

0 comments on commit 169be1a

Please sign in to comment.