Skip to content

Commit

Permalink
Merge pull request #259 from lucasnlm/gdx
Browse files Browse the repository at this point in the history
Gdx
  • Loading branch information
lucasnlm authored Apr 6, 2021
2 parents c5f5916 + 8edc872 commit 9b6955c
Show file tree
Hide file tree
Showing 10 changed files with 76 additions and 14 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 1000011
versionName '10.0.1'
versionCode 1000021
versionName '10.0.2'
minSdkVersion 21
targetSdkVersion 30
multiDexEnabled true
Expand Down
4 changes: 1 addition & 3 deletions app/src/main/java/dev/lucasnlm/antimine/GameActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,7 @@ class GameActivity :
}

private fun backToMainActivity() {
val intent = Intent(this, MainActivity::class.java).apply {
flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
}
val intent = Intent(this, MainActivity::class.java)
startActivity(intent)
}

Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/dev/lucasnlm/antimine/main/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import dev.lucasnlm.antimine.ui.ext.toAndroidColor
import dev.lucasnlm.external.IAnalyticsManager
import dev.lucasnlm.external.IBillingManager
import dev.lucasnlm.external.IFeatureFlagManager
import dev.lucasnlm.external.IInAppUpdateManager
import dev.lucasnlm.external.IPlayGamesManager
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.coroutines.Dispatchers
Expand All @@ -51,6 +52,7 @@ class MainActivity : ThematicActivity(R.layout.activity_main) {
private val featureFlagManager: IFeatureFlagManager by inject()
private val billingManager: IBillingManager by inject()
private val savesRepository: ISavesRepository by inject()
private val inAppUpdateManager: IInAppUpdateManager by inject()

private lateinit var viewPager: ViewPager2

Expand Down Expand Up @@ -354,6 +356,10 @@ class MainActivity : ThematicActivity(R.layout.activity_main) {
}
}

private fun afterGooglePlayGames() {
inAppUpdateManager.checkUpdate(this)
}

private fun launchGooglePlayGames() {
if (playGamesManager.hasGooglePlayGames() && playGamesManager.shouldRequestLogin()) {
playGamesManager.keepRequestingLogin(false)
Expand Down Expand Up @@ -385,8 +391,12 @@ class MainActivity : ThematicActivity(R.layout.activity_main) {
} catch (e: Exception) {
Log.e(SplashActivity.TAG, "User not logged or doesn't have Play Games", e)
}
} else {
afterGooglePlayGames()
}
}
} else {
afterGooglePlayGames()
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package dev.lucasnlm.external

import android.app.Activity

interface IInAppUpdateManager {
fun checkUpdate(activity: Activity)
}
12 changes: 6 additions & 6 deletions external/src/main/java/dev/lucasnlm/external/model/CloudSave.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ fun CloudSave.toHashMap(): HashMap<String, Any> = hashMapOf(
"uid" to playId,
"completeTutorial" to completeTutorial,
"selectedTheme" to selectedTheme,
"squareRadius" to squareRadius,
"squareSize" to squareSize,
"newSquareRadius" to squareRadius,
"newSquareSize" to squareSize,
"touchTiming" to touchTiming,
"questionMark" to questionMark,
"gameAssistance" to gameAssistance,
Expand All @@ -44,7 +44,7 @@ fun CloudSave.toHashMap(): HashMap<String, Any> = hashMapOf(
"language" to language,
"openDirectly" to openDirectly,
"unlockedThemes" to unlockedThemes,
"squareDivider" to squareDivider,
"newSquareDivider" to squareDivider,
"doubleClickTimeout" to doubleClickTimeout,
)

Expand All @@ -58,8 +58,8 @@ fun cloudSaveOf(id: String, data: Map<String, Any>) =
playId = id,
completeTutorial = data["completeTutorial"].parseInt(),
selectedTheme = data["selectedTheme"].parseInt(),
squareRadius = data["squareRadius"].parseInt(),
squareSize = data["squareSize"].parseInt(),
squareRadius = data["newSquareRadius"].parseInt(3),
squareSize = data["newSquareSize"].parseInt(50),
touchTiming = data["touchTiming"].parseInt(),
questionMark = data["questionMark"].parseInt(),
gameAssistance = data["gameAssistance"].parseInt(),
Expand All @@ -73,6 +73,6 @@ fun cloudSaveOf(id: String, data: Map<String, Any>) =
language = data["language"].parseString(""),
openDirectly = data["openDirectly"].parseInt(0),
unlockedThemes = data["unlockedThemes"].parseString(""),
squareDivider = data["squareDivider"].parseInt(10),
squareDivider = data["newSquareDivider"].parseInt(0),
doubleClickTimeout = data["doubleClickTimeout"].parseInt(400),
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package dev.lucasnlm.external

import android.app.Activity

class InAppUpdateManager : IInAppUpdateManager {
override fun checkUpdate(activity: Activity) {
// F-droid store doesn't support In-App update.
}
}
4 changes: 4 additions & 0 deletions foss/src/main/java/dev/lucasnlm/external/di/ExternalModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ import dev.lucasnlm.external.IBillingManager
import dev.lucasnlm.external.ICloudStorageManager
import dev.lucasnlm.external.ICrashReporter
import dev.lucasnlm.external.IFeatureFlagManager
import dev.lucasnlm.external.IInAppUpdateManager
import dev.lucasnlm.external.IInstantAppManager
import dev.lucasnlm.external.IPlayGamesManager
import dev.lucasnlm.external.IReviewWrapper
import dev.lucasnlm.external.InAppUpdateManager
import dev.lucasnlm.external.InstantAppManager
import dev.lucasnlm.external.NoAdsManager
import dev.lucasnlm.external.PlayGamesManager
Expand All @@ -35,4 +37,6 @@ val ExternalModule = module {
single { CrashReporter() } bind ICrashReporter::class

single { NoAdsManager() } bind IAdsManager::class

single { InAppUpdateManager() } bind IInAppUpdateManager::class
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ object PreferenceKeys {
const val PREFERENCE_ASSISTANT = "preference_assistant"
const val PREFERENCE_ANIMATION = "preference_animation"
const val PREFERENCE_NO_GUESSING = "preference_no_guessing"
const val PREFERENCE_AREA_SIZE = "preference_area_size"
const val PREFERENCE_AREA_SIZE = "preference_new_area_size"
const val PREFERENCE_QUESTION_MARK = "preference_use_question_mark"
const val PREFERENCE_USE_HELP = "preference_use_help"
const val PREFERENCE_CONTROL_STYLE = "preference_control_style"
Expand All @@ -17,7 +17,7 @@ object PreferenceKeys {
const val PREFERENCE_SOUND_EFFECTS = "preference_sound"
const val PREFERENCE_STATS_BASE = "preference_stats_base"
const val PREFERENCE_OLD_LARGE_AREA = "preference_large_area"
const val PREFERENCE_SQUARE_RADIUS = "preference_square_radius"
const val PREFERENCE_SQUARE_RADIUS = "preference_new_square_radius"
const val PREFERENCE_PROGRESSIVE_VALUE = "preference_progressive_value"
const val PREFERENCE_LONG_PRESS_TIMEOUT = "preference_long_press_timeout"
const val PREFERENCE_DOUBLE_CLICK_TIMEOUT = "preference_double_click_timeout"
Expand All @@ -36,6 +36,6 @@ object PreferenceKeys {
const val PREFERENCE_LOCALE = "preference_locale"
const val PREFERENCE_OPEN_DIRECTLY = "preference_open_directly"
const val PREFERENCE_UNLOCKED_THEMES = "preference_unlocked_themes"
const val PREFERENCE_SQUARE_DIVIDER = "preference_square_divider"
const val PREFERENCE_SQUARE_DIVIDER = "preference_new_square_divider"
const val PREFERENCE_OLD_AREA_SIZES = "preference_migration_old_sizes"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package dev.lucasnlm.external

import android.app.Activity
import com.google.android.play.core.appupdate.AppUpdateManagerFactory
import com.google.android.play.core.appupdate.AppUpdateOptions
import com.google.android.play.core.install.model.AppUpdateType
import com.google.android.play.core.install.model.UpdateAvailability

class InAppUpdateManager : IInAppUpdateManager {
private var keepRequesting = true

override fun checkUpdate(activity: Activity) {
if (keepRequesting) {
keepRequesting = false
val appUpdateManager = AppUpdateManagerFactory.create(activity.applicationContext)
val appUpdateInfoTask = appUpdateManager.appUpdateInfo
appUpdateInfoTask.addOnSuccessListener { appUpdateInfo ->
if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE &&
!activity.isFinishing
) {
appUpdateManager.startUpdateFlow(
appUpdateInfo,
activity,
AppUpdateOptions.defaultOptions(AppUpdateType.FLEXIBLE)
)
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ import dev.lucasnlm.external.IBillingManager
import dev.lucasnlm.external.ICloudStorageManager
import dev.lucasnlm.external.ICrashReporter
import dev.lucasnlm.external.IFeatureFlagManager
import dev.lucasnlm.external.IInAppUpdateManager
import dev.lucasnlm.external.IInstantAppManager
import dev.lucasnlm.external.IPlayGamesManager
import dev.lucasnlm.external.IReviewWrapper
import dev.lucasnlm.external.InAppUpdateManager
import dev.lucasnlm.external.InstantAppManager
import dev.lucasnlm.external.PlayGamesManager
import dev.lucasnlm.external.ReviewWrapper
Expand All @@ -35,4 +37,6 @@ val ExternalModule = module {
single { CrashReporter() } bind ICrashReporter::class

single { AdMobAdsManager(get(), get()) } bind IAdsManager::class

single { InAppUpdateManager() } bind IInAppUpdateManager::class
}

0 comments on commit 9b6955c

Please sign in to comment.