Skip to content

Commit bfa75a1

Browse files
authored
Merge pull request #489 from lucasnlm/fix-lint
Add new theme and fix bugs
2 parents 48f4dac + d4d6cbc commit bfa75a1

File tree

22 files changed

+97
-83
lines changed

22 files changed

+97
-83
lines changed

app/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ android {
1313

1414
defaultConfig {
1515
// versionCode and versionName must be hardcoded to support F-droid
16-
versionCode = 1706031
17-
versionName = "17.6.3"
16+
versionCode = 1706041
17+
versionName = "17.6.4"
1818
minSdk = libs.versions.minSdk.get().toInt()
1919
targetSdk = libs.versions.targetSdk.get().toInt()
2020
compileSdk = libs.versions.compileSdk.get().toInt()

app/src/main/AndroidManifest.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
android:smallScreens="true"
1313
android:xlargeScreens="true" />
1414

15+
<uses-permission
16+
android:name="${applicationId}.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION"
17+
tools:node="remove" />
18+
1519
<uses-permission android:name="android.permission.VIBRATE" />
1620

1721
<uses-feature

app/src/main/java/dev/lucasnlm/antimine/custom/CustomLevelDialogFragment.kt

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@ import android.content.DialogInterface
55
import android.os.Bundle
66
import android.view.LayoutInflater
77
import android.view.View
8-
import android.view.animation.AnimationUtils
98
import androidx.appcompat.app.AppCompatDialogFragment
109
import androidx.core.widget.doAfterTextChanged
1110
import com.google.android.material.dialog.MaterialAlertDialogBuilder
1211
import com.google.android.material.textfield.TextInputEditText
13-
import dev.lucasnlm.antimine.R
1412
import dev.lucasnlm.antimine.core.models.Difficulty
1513
import dev.lucasnlm.antimine.custom.viewmodel.CreateGameViewModel
1614
import dev.lucasnlm.antimine.custom.viewmodel.CustomEvent
@@ -127,56 +125,6 @@ class CustomLevelDialogFragment : AppCompatDialogFragment() {
127125
}.create()
128126
}
129127

130-
private fun checkLimitFeedbacks(): Boolean {
131-
val wantedWidth = binding.mapWidth.text.toString().toIntOrNull()
132-
var allValid = true
133-
if (wantedWidth == null) {
134-
binding.mapWidth.startAnimation(AnimationUtils.loadAnimation(context, R.anim.fast_shake))
135-
allValid = false
136-
} else if (wantedWidth >= MAX_WIDTH) {
137-
binding.mapWidth.setText(MAX_WIDTH.toString())
138-
binding.mapWidth.startAnimation(AnimationUtils.loadAnimation(context, R.anim.fast_shake))
139-
allValid = false
140-
} else if (wantedWidth <= MIN_WIDTH) {
141-
binding.mapWidth.setText(MIN_WIDTH.toString())
142-
binding.mapWidth.startAnimation(AnimationUtils.loadAnimation(context, R.anim.fast_shake))
143-
allValid = false
144-
}
145-
146-
val wantedHeight = binding.mapHeight.text.toString().toIntOrNull()
147-
if (wantedHeight == null) {
148-
binding.mapHeight.startAnimation(AnimationUtils.loadAnimation(context, R.anim.fast_shake))
149-
allValid = false
150-
} else if (wantedHeight >= MAX_HEIGHT) {
151-
binding.mapHeight.setText(MAX_HEIGHT.toString())
152-
binding.mapHeight.startAnimation(AnimationUtils.loadAnimation(context, R.anim.fast_shake))
153-
allValid = false
154-
} else if (wantedHeight <= MIN_HEIGHT) {
155-
binding.mapHeight.setText(MIN_HEIGHT.toString())
156-
binding.mapHeight.startAnimation(AnimationUtils.loadAnimation(context, R.anim.fast_shake))
157-
allValid = false
158-
}
159-
160-
if (allValid && wantedWidth != null && wantedHeight != null) {
161-
val wantedMines = binding.mapMines.text.toString().toIntOrNull()
162-
val maxMines = wantedWidth * wantedHeight - MIN_SAFE_AREA
163-
if (wantedMines == null) {
164-
binding.mapMines.startAnimation(AnimationUtils.loadAnimation(context, R.anim.fast_shake))
165-
allValid = false
166-
} else if (wantedMines >= maxMines) {
167-
binding.mapMines.setText((wantedWidth * wantedHeight - MIN_SAFE_AREA).toString())
168-
binding.mapMines.startAnimation(AnimationUtils.loadAnimation(context, R.anim.fast_shake))
169-
allValid = false
170-
} else if (wantedMines <= MIN_MINES) {
171-
binding.mapMines.setText(MIN_MINES.toString())
172-
binding.mapMines.startAnimation(AnimationUtils.loadAnimation(context, R.anim.fast_shake))
173-
allValid = false
174-
}
175-
}
176-
177-
return allValid
178-
}
179-
180128
override fun onDismiss(dialog: DialogInterface) {
181129
if (activity is DialogInterface.OnDismissListener) {
182130
(activity as DialogInterface.OnDismissListener).onDismiss(dialog)

app/src/main/java/dev/lucasnlm/antimine/stats/viewmodel/StatsViewModel.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ class StatsViewModel(
2525
private val expertSize = sizeOf(Difficulty.Expert)
2626
private val intermediateSize = sizeOf(Difficulty.Intermediate)
2727
private val beginnerSize = sizeOf(Difficulty.Beginner)
28-
private val standardSize = minefieldRepository.baseStandardSize(dimensionRepository, 0)
28+
private val standardSize =
29+
minefieldRepository.baseStandardSize(
30+
dimensionRepository = dimensionRepository,
31+
progressiveMines = 0,
32+
limitToMax = false,
33+
)
2934

3035
private fun sizeOf(difficulty: Difficulty): Minefield {
3136
return minefieldRepository.fromDifficulty(

app/src/test/java/dev/lucasnlm/antimine/mocks/FixedMinefieldRepository.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class FixedMinefieldRepository : MinefieldRepository {
1010
override fun baseStandardSize(
1111
dimensionRepository: DimensionRepository,
1212
progressiveMines: Int,
13+
limitToMax: Boolean,
1314
): Minefield = Minefield(9, 9, 9 + progressiveMines)
1415

1516
override fun fromDifficulty(

app/src/test/java/dev/lucasnlm/antimine/stats/viewmodel/StatsViewModelTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class StatsViewModelTest : IntentViewModelTest() {
4242
override fun setup() {
4343
super.setup()
4444
every { prefsRepository.isPremiumEnabled() } returns false
45-
every { minefieldRepository.baseStandardSize(any(), any()) } returns Minefield(6, 12, 9)
45+
every { minefieldRepository.baseStandardSize(any(), any(), any()) } returns Minefield(6, 12, 9)
4646
every { minefieldRepository.fromDifficulty(any(), any(), any()) } returns Minefield(6, 12, 9)
4747
}
4848

common/src/main/java/dev/lucasnlm/antimine/common/level/repository/MinefieldRepository.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ interface MinefieldRepository {
1515
fun baseStandardSize(
1616
dimensionRepository: DimensionRepository,
1717
progressiveMines: Int,
18+
limitToMax: Boolean,
1819
): Minefield
1920

2021
/**

common/src/main/java/dev/lucasnlm/antimine/common/level/repository/MinefieldRepositoryImpl.kt

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ import dev.lucasnlm.antimine.core.models.Difficulty
44
import dev.lucasnlm.antimine.core.repository.DimensionRepository
55
import dev.lucasnlm.antimine.preferences.PreferencesRepository
66
import dev.lucasnlm.antimine.preferences.models.Minefield
7+
import java.lang.Integer.min
78

89
class MinefieldRepositoryImpl : MinefieldRepository {
910
override fun baseStandardSize(
1011
dimensionRepository: DimensionRepository,
1112
progressiveMines: Int,
13+
limitToMax: Boolean,
1214
): Minefield {
1315
val fieldSize = dimensionRepository.areaSize()
1416
val horizontalGap =
@@ -33,7 +35,13 @@ class MinefieldRepositoryImpl : MinefieldRepository {
3335
val fitWidth = calculatedWidth.coerceAtLeast(MIN_STANDARD_WIDTH)
3436
val fitHeight = calculatedHeight.coerceAtLeast(MIN_STANDARD_HEIGHT)
3537
val fieldArea = fitWidth * fitHeight
36-
val fitMines = ((fieldArea * CUSTOM_LEVEL_MINE_RATIO).toInt() + progressiveMines)
38+
val maxMines =
39+
if (limitToMax) {
40+
(fieldArea * 0.75).toInt()
41+
} else {
42+
Int.MAX_VALUE
43+
}
44+
val fitMines = min(maxMines, ((fieldArea * CUSTOM_LEVEL_MINE_RATIO).toInt() + progressiveMines))
3745
return Minefield(fitWidth, fitHeight, fitMines)
3846
}
3947

@@ -49,7 +57,12 @@ class MinefieldRepositoryImpl : MinefieldRepository {
4957
Difficulty.Expert -> expertMinefield
5058
Difficulty.Master -> masterMinefield
5159
Difficulty.Legend -> legendMinefield
52-
Difficulty.FixedSize -> baseStandardSize(dimensionRepository, preferencesRepository.getProgressiveValue())
60+
Difficulty.FixedSize ->
61+
baseStandardSize(
62+
dimensionRepository = dimensionRepository,
63+
progressiveMines = preferencesRepository.getProgressiveValue(),
64+
limitToMax = true,
65+
)
5366
Difficulty.Custom -> preferencesRepository.customGameMode()
5467
}
5568

@@ -59,8 +72,9 @@ class MinefieldRepositoryImpl : MinefieldRepository {
5972
): Minefield {
6073
var result: Minefield =
6174
baseStandardSize(
62-
dimensionRepository,
63-
preferencesRepository.getProgressiveValue(),
75+
dimensionRepository = dimensionRepository,
76+
progressiveMines = preferencesRepository.getProgressiveValue(),
77+
limitToMax = false,
6478
)
6579
var resultWidth = result.width
6680
var resultHeight = result.height

common/src/main/java/dev/lucasnlm/antimine/common/level/view/GameRenderFragment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ open class GameRenderFragment : AndroidFragmentApplication() {
7474
navigationBarHeight = dimensionRepository.navigationBarHeight().toFloat(),
7575
appBarWithStatusHeight = dimensionRepository.actionBarSizeWithStatus().toFloat(),
7676
appBarHeight = appBarHeight(context),
77-
joinAreas = themeRepository.getSkin().hasPadding,
77+
joinAreas = themeRepository.getSkin().joinAreas,
7878
appSkin = themeRepository.getSkin(),
7979
)
8080
}

gdx/src/main/assets/glass.png

18.5 KB
Loading

0 commit comments

Comments
 (0)