Skip to content

Commit

Permalink
Merge pull request #264 from lucasnlm/post-release-fixes
Browse files Browse the repository at this point in the history
Post release fixes
  • Loading branch information
lucasnlm authored Apr 9, 2021
2 parents 0f5103c + 6290373 commit 5f323ac
Show file tree
Hide file tree
Showing 30 changed files with 70 additions and 559 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ android {

defaultConfig {
// versionCode and versionName must be hardcoded to support F-droid
versionCode 1000031
versionName '10.0.3'
versionCode 1000041
versionName '10.0.4'
minSdkVersion 21
targetSdkVersion 30
multiDexEnabled true
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/dev/lucasnlm/antimine/GameActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -372,15 +372,15 @@ class GameActivity :

if (applicationContext.isPortrait()) {
minesCount.setCompoundDrawablesWithIntrinsicBounds(
ContextCompat.getDrawable(this, usingTheme.assets.toolbarMine),
ContextCompat.getDrawable(this, R.drawable.mine),
null,
null,
null,
)
} else {
minesCount.setCompoundDrawablesWithIntrinsicBounds(
null,
ContextCompat.getDrawable(this, usingTheme.assets.toolbarMine),
ContextCompat.getDrawable(this, R.drawable.mine),
null,
null,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import android.view.View
import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.TextView
import android.widget.Toast
import androidx.appcompat.app.AppCompatDialogFragment
import androidx.appcompat.widget.AppCompatButton
import androidx.constraintlayout.widget.ConstraintLayout
Expand All @@ -32,6 +33,7 @@ import dev.lucasnlm.antimine.core.isAndroidTv
import dev.lucasnlm.antimine.level.view.NewGameFragment
import dev.lucasnlm.antimine.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.preferences.PreferencesActivity
import dev.lucasnlm.antimine.themes.ThemeActivity
import dev.lucasnlm.antimine.tutorial.TutorialActivity
import dev.lucasnlm.antimine.ui.ext.toAndroidColor
import dev.lucasnlm.antimine.ui.model.AppTheme
Expand Down Expand Up @@ -230,6 +232,17 @@ class GameOverDialogFragment : AppCompatDialogFragment() {
}
}
}
} else if (!preferencesRepository.isPremiumEnabled() &&
instantAppManager.isEnabled(context)
) {
removeAdsButton.apply {
visibility = View.VISIBLE
text = getString(R.string.themes)
setOnClickListener {
val intent = Intent(context, ThemeActivity::class.java)
startActivity(intent)
}
}
}
}
}
Expand Down Expand Up @@ -281,6 +294,9 @@ class GameOverDialogFragment : AppCompatDialogFragment() {
activity,
onDismiss = {
continueGame()
},
onError = {
Toast.makeText(context, R.string.no_network, Toast.LENGTH_SHORT).show()
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class EndGameDialogViewModel(
gameResult = GameResult.Completed,
showContinueButton = false,
received = 0,
showTutorial = true,
showTutorial = false,
)

override suspend fun mapEventToState(event: EndGameDialogEvent) = flow {
Expand All @@ -107,7 +107,7 @@ class EndGameDialogViewModel(
gameResult = event.gameResult,
showContinueButton = event.showContinueButton,
received = event.received,
showTutorial = event.turn in 0..4,
showTutorial = event.turn in 1..2,
)
}
GameResult.Completed -> {
Expand Down
6 changes: 3 additions & 3 deletions control/src/main/res/layout/activity_control.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@
android:id="@+id/doubleClick"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:max="1000"
android:min="300"
android:progress="400"
android:max="700"
android:min="100"
android:progress="250"
app:layout_constraintBottom_toBottomOf="@+id/doubleClickLabel"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
Expand Down
3 changes: 2 additions & 1 deletion gdx/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/build
/build
/libs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ object AreaAssetBuilder {

// top, top-left, left
x = textureSize * 7
y = textureSize
y = textureSize * 3
textureRegions[FormNames.fillTopLeft] = GridPoint2(x, y)
setColor(transparent)
fillRectangle(x, y, textureSize, textureSize)
Expand All @@ -263,7 +263,7 @@ object AreaAssetBuilder {

// top, top-right, right
x = textureSize * 6
y = textureSize
y = textureSize * 3
textureRegions[FormNames.fillTopRight] = GridPoint2(x, y)
setColor(transparent)
fillRectangle(x, y, textureSize, textureSize)
Expand All @@ -272,7 +272,7 @@ object AreaAssetBuilder {

// bottom, bottom-right, right
x = 0
y = textureSize * 2
y = textureSize * 4
textureRegions[FormNames.fillBottomRight] = GridPoint2(x, y)
setColor(transparent)
fillRectangle(x, y, textureSize, textureSize)
Expand All @@ -281,7 +281,7 @@ object AreaAssetBuilder {

// bottom, bottom-left, left
x = textureSize
y = textureSize * 2
y = textureSize * 4
textureRegions[FormNames.fillBottomLeft] = GridPoint2(x, y)
setColor(transparent)
fillRectangle(x, y, textureSize, textureSize)
Expand Down
4 changes: 2 additions & 2 deletions i18n/src/main/res/values-ku-rTR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,6 @@
<string name="app_description">پێویستە تەختەیەکی لاکێشەیی پاک کە مینی شاراوەی تێدایە بەبێ ئەوەی هیچ کام لەوان بتەقێتەوە.</string>
<string name="app_name">دژە مین</string>
<string name="do_you_know_how_to_play" comment="It will be shown in a window before show or not the tutorial.&#13;&#10;May also be translated as &quot;Do you want to read the tutorial?&quot;">دەزانی چۆن یاری دژە مین بکەیت؟</string>
<string name="close">Close</string>
<string name="open_tutorial">Open Tutorial</string>
<string name="close">داخستن</string>
<string name="open_tutorial">کردنەوەی فێرکاری</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class PreferencesRepository(
}

override fun getDoubleClickTimeout(): Long {
return preferencesManager.getInt(PreferenceKeys.PREFERENCE_DOUBLE_CLICK_TIMEOUT, 400).toLong()
return preferencesManager.getInt(PreferenceKeys.PREFERENCE_DOUBLE_CLICK_TIMEOUT, 250).toLong()
}

override fun setDoubleClickTimeout(value: Long) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ class AdMobAdsManager(
) {
interstitialAd?.fullScreenContentCallback = object : FullScreenContentCallback() {
override fun onAdDismissedFullScreenContent() {
// Dismiss
loadInterstitialAd()
onDismiss.invoke()
}
Expand All @@ -134,19 +133,19 @@ class AdMobAdsManager(
"Fail to show InterstitialAd \nCode:${it.code} \nMessage: ${it.message} \nCause: ${it.cause}"
)
}
if (onError != null) {
onError.invoke()
} else {
onDismiss.invoke()
}
(onError ?: onDismiss).invoke()
}

override fun onAdShowedFullScreenContent() {
// Empty
}
}

interstitialAd?.show(activity)
if (interstitialAd == null) {
(onError ?: onDismiss).invoke()
} else {
interstitialAd?.show(activity)
}
}

override fun createBannerAd(context: Context): View? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.app.Activity
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.recyclerview.widget.RecyclerView
import dev.lucasnlm.antimine.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.themes.R
Expand Down Expand Up @@ -114,6 +115,9 @@ class ThemeAdapter(
activity,
onDismiss = {
themeViewModel.sendEvent(ThemeEvent.ChangeTheme(theme))
},
onError = {
Toast.makeText(activity.applicationContext, R.string.no_network, Toast.LENGTH_SHORT).show()
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ import dev.lucasnlm.antimine.themes.viewmodel.ThemeState
import dev.lucasnlm.antimine.themes.viewmodel.ThemeViewModel
import dev.lucasnlm.antimine.ui.model.AppTheme
import dev.lucasnlm.antimine.ui.model.AreaPalette
import dev.lucasnlm.antimine.ui.model.Assets
import dev.lucasnlm.antimine.ui.repository.IThemeRepository
import dev.lucasnlm.external.IAnalyticsManager
import dev.lucasnlm.external.IBillingManager
import io.mockk.every
import io.mockk.mockk
import io.mockk.verify
Expand Down Expand Up @@ -42,7 +40,6 @@ class ThemeViewModelTest {
theme = R.style.CustomLightTheme,
palette = AreaPalette(
accent = 0xD32F2F,
border = 0x424242,
background = 0xFFFFFF,
covered = 0x424242,
coveredOdd = 0x424242,
Expand All @@ -59,24 +56,13 @@ class ThemeViewModelTest {
highlight = 0x212121,
focus = 0xD32F2F
),
assets = Assets(
wrongFlag = R.drawable.red_flag,
flag = R.drawable.flag,
questionMark = R.drawable.question,
toolbarMine = R.drawable.mine,
mine = R.drawable.mine,
mineExploded = R.drawable.mine_exploded_red,
mineLow = R.drawable.mine_low,
revealed = R.drawable.mine_revealed,
)
)

private val darkTheme = AppTheme(
id = 2L,
theme = R.style.CustomDarkTheme,
palette = AreaPalette(
accent = 0xFFFFFF,
border = 0x171717,
background = 0x212121,
covered = 0x171717,
coveredOdd = 0x171717,
Expand All @@ -93,24 +79,13 @@ class ThemeViewModelTest {
highlight = 0xFFFFFF,
focus = 0xFFFFFF
),
assets = Assets(
wrongFlag = R.drawable.flag,
flag = R.drawable.flag,
questionMark = R.drawable.question,
toolbarMine = R.drawable.mine_low,
mine = R.drawable.mine,
mineExploded = R.drawable.mine_exploded_white,
mineLow = R.drawable.mine_low,
revealed = R.drawable.mine_revealed,
)
)

private val gardenTheme = AppTheme(
id = 3L,
theme = R.style.CustomGardenTheme,
palette = AreaPalette(
accent = 0x689f38,
border = 0x171717,
background = 0xefebe9,
covered = 0x689f38,
coveredOdd = 0x558b2f,
Expand All @@ -127,16 +102,6 @@ class ThemeViewModelTest {
highlight = 0xFFFFFF,
focus = 0xFFFFFF
),
assets = Assets(
wrongFlag = R.drawable.flag,
flag = R.drawable.flag,
questionMark = R.drawable.question,
toolbarMine = R.drawable.mine_low,
mine = R.drawable.mine,
mineExploded = R.drawable.mine_exploded_white,
mineLow = R.drawable.mine_low,
revealed = R.drawable.mine_revealed,
)
)

private val allThemes = listOf(
Expand All @@ -152,14 +117,16 @@ class ThemeViewModelTest {
every { getTheme() } returns gardenTheme
}

val billingManager = mockk<IBillingManager>()

val preferencesRepository = mockk<IPreferencesRepository> { }
val preferencesRepository = mockk<IPreferencesRepository> {
every { squareSize() } returns 55
every { squareDivider() } returns 0
every { squareRadius() } returns 3
}

val analyticsManager = mockk<IAnalyticsManager> { }

val viewModel = ThemeViewModel(themeRepository, billingManager, preferencesRepository, analyticsManager)
assertEquals(ThemeState(gardenTheme, allThemes), viewModel.singleState())
val viewModel = ThemeViewModel(themeRepository, preferencesRepository, analyticsManager)
assertEquals(ThemeState(gardenTheme, 3, 15, 0, allThemes), viewModel.singleState())
}

@Test
Expand All @@ -170,23 +137,22 @@ class ThemeViewModelTest {
every { setTheme(any()) } returns Unit
}

val billingManager = mockk<IBillingManager> {
every { isEnabled() } returns false
}

val preferencesRepository = mockk<IPreferencesRepository> {
every { isPremiumEnabled() } returns true
every { squareSize() } returns 55
every { squareDivider() } returns 0
every { squareRadius() } returns 3
}

val analyticsManager = mockk<IAnalyticsManager> {
every { sentEvent(any()) } returns Unit
}

val state = ThemeViewModel(themeRepository, billingManager, preferencesRepository, analyticsManager).run {
val state = ThemeViewModel(themeRepository, preferencesRepository, analyticsManager).run {
sendEvent(ThemeEvent.ChangeTheme(darkTheme))
singleState()
}
assertEquals(ThemeState(darkTheme, allThemes), state)
assertEquals(ThemeState(darkTheme, 3, 15, 0, allThemes), state)

verify { themeRepository.setTheme(darkTheme.id) }
}
Expand All @@ -199,20 +165,22 @@ class ThemeViewModelTest {
every { setTheme(any()) } returns Unit
}

val billingManager = mockk<IBillingManager>()

val preferencesRepository = mockk<IPreferencesRepository> {
every { isPremiumEnabled() } returns false
every { squareSize() } returns 55
every { squareDivider() } returns 0
every { squareRadius() } returns 3
every { addUnlockedTheme(2) } returns Unit
}

val analyticsManager = mockk<IAnalyticsManager> {
every { sentEvent(any()) } returns Unit
}

val state = ThemeViewModel(themeRepository, billingManager, preferencesRepository, analyticsManager).run {
sendEvent(ThemeEvent.ChangeTheme(darkTheme))
val state = ThemeViewModel(themeRepository, preferencesRepository, analyticsManager).run {
sendEvent(ThemeEvent.ChangeTheme(gardenTheme))
singleState()
}
assertEquals(ThemeState(gardenTheme, allThemes), state)
assertEquals(ThemeState(gardenTheme, 3, 15, 0, allThemes), state)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import androidx.annotation.StyleRes
data class AppTheme(
val id: Long,
@StyleRes val theme: Int,
val assets: Assets,
val palette: AreaPalette,
val isPaid: Boolean = true,
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package dev.lucasnlm.antimine.ui.model
import androidx.annotation.ColorInt

data class AreaPalette(
@ColorInt val border: Int, // REMOVE
@ColorInt val background: Int,
@ColorInt val accent: Int,
@ColorInt val covered: Int,
Expand Down
Loading

0 comments on commit 5f323ac

Please sign in to comment.