Skip to content

Commit

Permalink
Merge pull request #464 from lucasnlm/fix-firebase
Browse files Browse the repository at this point in the history
Fix firebase OOM
  • Loading branch information
lucasnlm authored Oct 8, 2023
2 parents d284533 + 4a4ca3c commit fb0b8f8
Show file tree
Hide file tree
Showing 43 changed files with 300 additions and 178 deletions.
12 changes: 4 additions & 8 deletions about/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,8 @@ android {
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}

kotlin {
jvmToolchain(17)
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

buildFeatures {
Expand All @@ -47,11 +43,11 @@ dependencies {
implementation project(':external')

// Google
implementation 'com.google.android.material:material:1.9.0'
implementation 'com.google.android.material:material:1.10.0'

// AndroidX
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.activity:activity-ktx:1.7.2'
implementation 'androidx.activity:activity-ktx:1.8.0'
implementation 'androidx.fragment:fragment-ktx:1.6.1'

// RecyclerView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.google.android.material.divider.MaterialDividerItemDecoration
import dev.lucasnlm.antimine.about.R
import dev.lucasnlm.antimine.about.databinding.FragmentLicensesBinding
import dev.lucasnlm.antimine.licenses.viewmodel.LicenseViewModel
import kotlinx.coroutines.launch
import org.koin.androidx.viewmodel.ext.android.sharedViewModel

class LicensesFragment : Fragment(R.layout.fragment_licenses) {
Expand All @@ -21,7 +22,7 @@ class LicensesFragment : Fragment(R.layout.fragment_licenses) {
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?,
): View? {
): View {
binding = FragmentLicensesBinding.inflate(inflater, container, false)
return binding.root
}
Expand All @@ -32,7 +33,7 @@ class LicensesFragment : Fragment(R.layout.fragment_licenses) {
) {
super.onViewCreated(view, savedInstanceState)

lifecycleScope.launchWhenResumed {
lifecycleScope.launch {
viewModel
.observeState()
.collect {
Expand Down
50 changes: 31 additions & 19 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
apply plugin: 'com.android.application'

if (System.getenv('IS_GOOGLE_BUILD')) {
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'com.google.firebase.firebase-perf'
plugins {
id 'com.android.application'
id('kotlin-android')
}

apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'

android {
namespace 'dev.lucasnlm.antimine'

defaultConfig {
// versionCode and versionName must be hardcoded to support F-droid
versionCode 1705001
versionName '17.5.0'
versionCode 1705011
versionName '17.5.1'
minSdk 21
targetSdk 34
compileSdk 34
Expand Down Expand Up @@ -56,8 +50,8 @@ android {
}

compileOptions {
targetCompatibility JavaVersion.VERSION_17
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_17
}

kotlinOptions {
Expand All @@ -77,13 +71,21 @@ android {
dimension 'version'
applicationId 'dev.lucasnlm.antimine'
versionNameSuffix ' S'

apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'com.google.firebase.firebase-perf'
}

googleInstant {
versionCode 160
dimension 'version'
applicationId 'dev.lucasnlm.antimine'
versionNameSuffix ' I'

apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'com.google.firebase.firebase-perf'
}

foss {
Expand All @@ -95,10 +97,6 @@ android {
}
}

kapt {
correctErrorTypes true
}

dependencies {
// Dependencies must be hardcoded to support F-droid

Expand Down Expand Up @@ -129,7 +127,7 @@ dependencies {
implementation 'androidx.preference:preference-ktx:1.2.1'
implementation 'androidx.recyclerview:recyclerview:1.3.1'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.activity:activity-ktx:1.7.2'
implementation 'androidx.activity:activity-ktx:1.8.0'
implementation 'androidx.fragment:fragment-ktx:1.6.1'

// Lifecycle
Expand All @@ -142,7 +140,7 @@ dependencies {
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'

// Google
implementation 'com.google.android.material:material:1.9.0'
implementation 'com.google.android.material:material:1.10.0'

// Koin
implementation 'io.insert-koin:koin-android:3.1.2'
Expand Down Expand Up @@ -188,3 +186,17 @@ tasks.withType(Test).configureEach {
println "Executing test ${desc.name} [${desc.className}] with result: ${result.resultType}"
}
}

// The following code disables Google Services when building for F-Droid
if (System.getenv('IS_GOOGLE_BUILD') == null) {
android.applicationVariants.configureEach { variant ->
if (variant.flavorName == 'foss') {
project.tasks.names.findAll { it.contains("Google") }
.forEach { taskName ->
project.tasks.named(taskName).configure {
enabled = false
}
}
}
}
}
7 changes: 6 additions & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
-dontwarn org.openjsse.**

# For Google Play Services
-keepattributes Signature
-keep class com.google.android.gms.** { *; }
-keep class io.grpc.** {*;}
-keep public class com.google.android.gms.ads.** {
public *;
Expand All @@ -54,8 +56,11 @@
-dontwarn sun.nio.ch.**
-dontwarn sun.misc.**

# LibGDX
# Firebase
-keep class com.google.android.gms.** { *; }
-keep class com.google.firebase.** { *; }

# LibGDX
-keep class com.badlogic.gdx.scenes.** { *; }

-dontwarn com.badlogic.gdx.backends.android.AndroidFragmentApplication
Expand Down
12 changes: 11 additions & 1 deletion app/src/main/java/dev/lucasnlm/antimine/GameActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ class GameActivity :
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

themeRepository.getTheme().palette.background.toAndroidColor().let {
window.decorView.setBackgroundColor(it)
}

setContentView(binding.root)

if (!preferencesRepository.isPremiumEnabled()) {
Expand All @@ -126,9 +130,15 @@ class GameActivity :

bindViewModel()
bindToolbar()
loadGameOrTutorial()
bindTapToBegin()

lifecycleScope.launch {
delay(100)
withContext(Dispatchers.Main) {
loadGameOrTutorial()
}
}

playGamesManager.showPlayPopUp(this)
playGamesStartUp()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dev.lucasnlm.antimine.mocks

import dev.lucasnlm.antimine.preferences.PreferencesRepository
import dev.lucasnlm.antimine.preferences.models.Action
import dev.lucasnlm.antimine.preferences.models.ControlStyle
import dev.lucasnlm.antimine.preferences.models.Minefield

Expand Down Expand Up @@ -296,4 +297,10 @@ class MockPreferencesRepository : PreferencesRepository {
override fun setLastAppVersion(versionCode: Int) {
// Not implemented
}

override fun defaultSwitchButton(): Action = Action.SwitchMark

override fun setDefaultSwitchButton(action: Action) {
// Not implemented
}
}
8 changes: 3 additions & 5 deletions audio-low/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@ android {
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

kotlin {
jvmToolchain(17)
}

}

dependencies {}
8 changes: 3 additions & 5 deletions audio/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@ android {
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

kotlin {
jvmToolchain(17)
}

}

dependencies {}
22 changes: 7 additions & 15 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
buildscript {
repositories {
mavenCentral()
google()
}

dependencies {
classpath 'com.android.tools.build:gradle:8.1.2'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.10'
plugins {
id('com.android.application') version '8.1.2' apply false
id('com.android.library') version '8.1.2' apply false
id('org.jetbrains.kotlin.android') version '1.9.10' apply false

if (System.getenv('IS_GOOGLE_BUILD')) {
classpath 'com.google.gms:google-services:4.4.0'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.9'
classpath 'com.google.firebase:perf-plugin:1.4.2'
}
}
id('com.google.gms.google-services') version '4.4.0' apply false
id('com.google.firebase.crashlytics') version '2.9.9' apply false
id('com.google.firebase.firebase-perf') version '1.4.2' apply false
}

allprojects {
Expand Down
15 changes: 5 additions & 10 deletions common/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
plugins {
id 'com.android.library'
id 'kotlin-android'
id 'kotlin-kapt'
}

android {
Expand All @@ -16,8 +15,8 @@ android {
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

kotlinOptions {
Expand All @@ -30,10 +29,6 @@ android {
}
}

kapt {
correctErrorTypes true
}

dependencies {
// Dependencies must be hardcoded to support F-droid

Expand All @@ -45,17 +40,17 @@ dependencies {
implementation project(':ui')
implementation project(':gdx')
implementation project(':sgtatham')
implementation project(':sgtatham')
implementation project(':control')

// AndroidX
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.preference:preference-ktx:1.2.1'
implementation 'androidx.recyclerview:recyclerview:1.3.1'
implementation 'androidx.activity:activity-ktx:1.7.2'
implementation 'androidx.activity:activity-ktx:1.8.0'
implementation 'androidx.fragment:fragment-ktx:1.6.1'

// Google
implementation 'com.google.android.material:material:1.9.0'
implementation 'com.google.android.material:material:1.10.0'

// Constraint
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class GameController {
private var firstOpen: FirstOpen = FirstOpen.Unknown
private var gameControl: GameControl = GameControl.Standard
private var useQuestionMark = true
private var selectedAction = Action.OpenTile
private var selectedAction: Action
private var useClickOnNumbers = true
private var letNumbersPutFlag = true
private var errorTolerance = 0
Expand All @@ -47,6 +47,7 @@ class GameController {
minefield: Minefield,
seed: Long,
useSimonTatham: Boolean,
selectedAction: Action,
saveId: String? = null,
onCreateUnsafeLevel: (() -> Unit)? = null,
) {
Expand All @@ -66,18 +67,21 @@ class GameController {
this.onCreateUnsafeLevel = onCreateUnsafeLevel
this.field = minefieldCreator.createEmpty()
this.useSimonTatham = shouldUseSimonTatham
this.selectedAction = selectedAction
}

constructor(
save: Save,
useSimonTatham: Boolean,
selectedAction: Action,
) {
this.minefield = save.minefield
this.seed = save.seed
this.saveId = save.id
this.firstOpen = save.firstOpen
this.field = save.field
this.actions = save.actions
this.selectedAction = selectedAction
this.fallbackCreator = MinefieldCreatorImpl(minefield, seed)
this.minefieldCreator =
if (useSimonTatham) {
Expand Down Expand Up @@ -535,6 +539,8 @@ class GameController {
this.useQuestionMark = useQuestionMark
}

fun getSelectedAction() = selectedAction

fun useClickOnNumbers(clickNumbers: Boolean) {
this.useClickOnNumbers = clickNumbers
}
Expand Down
Loading

0 comments on commit fb0b8f8

Please sign in to comment.