Skip to content

Commit

Permalink
Merge pull request #296 from lucasnlm/update-code
Browse files Browse the repository at this point in the history
Update code
  • Loading branch information
lucasnlm authored Jun 30, 2021
2 parents 9b30090 + 559c8b7 commit a1794ed
Show file tree
Hide file tree
Showing 91 changed files with 454 additions and 235 deletions.
2 changes: 1 addition & 1 deletion about/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ dependencies {
// AndroidX
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'androidx.activity:activity-ktx:1.2.3'
implementation 'androidx.fragment:fragment-ktx:1.3.4'
implementation 'androidx.fragment:fragment-ktx:1.3.5'

// RecyclerView
implementation 'androidx.recyclerview:recyclerview:1.2.1'
Expand Down
11 changes: 6 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ plugins {

if (System.getenv('IS_GOOGLE_BUILD')) {
apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'com.google.firebase.firebase-perf'
}

android {
compileSdkVersion 30

defaultConfig {
// versionCode and versionName must be hardcoded to support F-droid
versionCode 1202001
versionName '12.2.0'
versionCode 1204001
versionName '12.4.0'
minSdkVersion 21
targetSdkVersion 30
multiDexEnabled true
Expand Down Expand Up @@ -130,7 +131,7 @@ dependencies {
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.activity:activity-ktx:1.2.3'
implementation 'androidx.fragment:fragment-ktx:1.3.4'
implementation 'androidx.fragment:fragment-ktx:1.3.5'
implementation 'androidx.cardview:cardview:1.0.0'

// Lifecycle
Expand Down Expand Up @@ -168,8 +169,8 @@ dependencies {
testImplementation 'androidx.test:runner:1.3.0'
testImplementation 'androidx.test.espresso:espresso-core:3.3.0'
testImplementation 'androidx.test.espresso:espresso-contrib:3.3.0'
testImplementation 'androidx.fragment:fragment-testing:1.3.4'
testImplementation 'org.robolectric:robolectric:4.3.1'
testImplementation 'androidx.fragment:fragment-testing:1.3.5'
testImplementation 'org.robolectric:robolectric:4.4'
testImplementation 'androidx.test.ext:junit:1.1.2'
testImplementation 'io.mockk:mockk:1.11.0'

Expand Down
4 changes: 4 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@
android:theme="@style/AppTheme"
tools:targetApi="lollipop">

<!-- <meta-data-->
<!-- android:name="com.google.android.gms.instant.flavor"-->
<!-- android:value="1337" />-->

<activity
android:name="dev.lucasnlm.antimine.splash.SplashActivity"
android:theme="@style/Theme.Splash">
Expand Down
42 changes: 41 additions & 1 deletion app/src/main/java/dev/lucasnlm/antimine/GameActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import dev.lucasnlm.antimine.control.ControlActivity
import dev.lucasnlm.antimine.gdx.GdxLocal
import dev.lucasnlm.antimine.main.MainActivity
import dev.lucasnlm.antimine.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.preferences.models.ControlStyle
import dev.lucasnlm.antimine.splash.SplashActivity
import dev.lucasnlm.antimine.tutorial.TutorialActivity
import dev.lucasnlm.antimine.ui.ThematicActivity
Expand Down Expand Up @@ -74,6 +75,8 @@ class GameActivity :
private val renderSquareRadius = preferencesRepository.squareRadius()
private val renderSquareDivider = preferencesRepository.squareDivider()
private val renderSquareSize = preferencesRepository.squareSize()
private val showFloatingButtonOnTop = preferencesRepository.showToggleButtonOnTopBar()
private val hasFloatingButton = preferencesRepository.controlStyle() == ControlStyle.SwitchMarkOpen

override fun onNewIntent(intent: Intent?) {
super.onNewIntent(intent)
Expand All @@ -94,6 +97,7 @@ class GameActivity :
bindToolbar()
loadGameOrTutorial()
bindTapToBegin()
bindToggleButton()

playGamesManager.showPlayPopUp(this)
playGamesStartUp()
Expand Down Expand Up @@ -344,7 +348,9 @@ class GameActivity :
super.onResume()
if (renderSquareRadius != preferencesRepository.squareRadius() ||
renderSquareDivider != preferencesRepository.squareDivider() ||
renderSquareSize != preferencesRepository.squareSize()
renderSquareSize != preferencesRepository.squareSize() ||
showFloatingButtonOnTop != preferencesRepository.showToggleButtonOnTopBar() ||
hasFloatingButton != (preferencesRepository.controlStyle() == ControlStyle.SwitchMarkOpen)
) {
// If used changed any currently rendered settings, we
// must recreate the activity to force all sprites are updated.
Expand Down Expand Up @@ -723,6 +729,40 @@ class GameActivity :
}
}

private fun bindToggleButton() {
if (preferencesRepository.controlStyle() == ControlStyle.SwitchMarkOpen) {
if (preferencesRepository.showToggleButtonOnTopBar()) {
topBarToggle.apply {
visibility = View.VISIBLE
contentDescription = getString(R.string.open)
TooltipCompat.setTooltipText(this, getString(R.string.open))
setImageResource(R.drawable.touch)
preferencesRepository.setSwitchControl(true)

setOnClickListener {
if (preferencesRepository.openUsingSwitchControl()) {
contentDescription = getString(R.string.flag_tile)
TooltipCompat.setTooltipText(this, getString(R.string.flag_tile))
setImageResource(R.drawable.flag)
preferencesRepository.setSwitchControl(false)
gameViewModel.refreshUseOpenOnSwitchControl(false)
} else {
contentDescription = getString(R.string.open)
TooltipCompat.setTooltipText(this, getString(R.string.open))
setImageResource(R.drawable.touch)
preferencesRepository.setSwitchControl(true)
gameViewModel.refreshUseOpenOnSwitchControl(true)
}
}
}
} else {
topBarToggle.visibility = View.GONE
}

gameViewModel.refreshUseOpenOnSwitchControl(true)
}
}

override fun exit() {
// LibGDX exit callback
}
Expand Down
7 changes: 6 additions & 1 deletion app/src/main/java/dev/lucasnlm/antimine/di/AppModule.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package dev.lucasnlm.antimine.di

import dev.lucasnlm.antimine.cloud.CloudSaveManagerImpl
import dev.lucasnlm.antimine.common.BuildConfig
import dev.lucasnlm.antimine.BuildConfig
import dev.lucasnlm.antimine.core.IAppVersionManager
import dev.lucasnlm.antimine.core.analytics.DebugAnalyticsManager
import dev.lucasnlm.antimine.core.analytics.ProdAnalyticsManager
import dev.lucasnlm.antimine.core.cloud.CloudSaveManager
import dev.lucasnlm.antimine.support.AppVersionManagerImpl
import dev.lucasnlm.antimine.support.IapHandler
import dev.lucasnlm.external.ExternalAnalyticsWrapper
import dev.lucasnlm.external.IAnalyticsManager
import org.koin.android.ext.koin.androidApplication
import org.koin.dsl.bind
import org.koin.dsl.module

Expand All @@ -16,6 +19,8 @@ val AppModule = module {

single { CloudSaveManagerImpl(get(), get(), get(), get()) } bind CloudSaveManager::class

single { AppVersionManagerImpl(BuildConfig.DEBUG, androidApplication()) } bind IAppVersionManager::class

single {
if (BuildConfig.DEBUG) {
DebugAnalyticsManager()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@ class WinGameDialogFragment : AppCompatDialogFragment() {
receivedMessage.apply {
if (state.received > 0 &&
state.gameResult == GameResult.Victory &&
preferencesRepository.useHelp()
preferencesRepository.useHelp() &&
preferencesRepository.isPremiumEnabled()
) {
visibility = View.VISIBLE
text = getString(R.string.you_have_received, state.received)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package dev.lucasnlm.antimine.support

import android.app.Application
import dev.lucasnlm.antimine.core.IAppVersionManager

class AppVersionManagerImpl(
private val debug: Boolean,
private val application: Application,
) : IAppVersionManager {
private val valid by lazy {
val id = application.packageName
debug || id == "com.logical.minato" || id == "dev.lucasnlm.antimine" || id == "dev.lucanlm.antimine"
}

override fun isValid(): Boolean {
// If you want to distribution a fork of this game,
// please check its LICENSE and conditions before do it.
// Any fork / changed version must also be open sourced.
return valid
}
}
17 changes: 12 additions & 5 deletions app/src/main/res/layout-land/activity_game.xml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,16 @@
tools:visibility="visible" />
</LinearLayout>

<ImageView
android:id="@+id/topBarToggle"
android:layout_width="?attr/actionBarSize"
android:layout_height="?attr/actionBarSize"
android:background="?selectableItemBackgroundBorderless"
android:contentDescription="@string/switch_control"
android:padding="16dp"
android:src="@drawable/touch"
android:visibility="gone" />

<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
Expand All @@ -135,9 +145,9 @@
android:layout_width="?attr/actionBarSize"
android:layout_height="?attr/actionBarSize"
android:layout_gravity="center"
app:trackThickness="3dp"
app:indicatorColor="?attr/colorPrimary"
app:indicatorSize="24dp"
app:indicatorColor="?attr/colorPrimary"/>
app:trackThickness="3dp" />

<ImageView
android:id="@+id/shortcutIcon"
Expand Down Expand Up @@ -167,8 +177,5 @@
</FrameLayout>

</LinearLayout>


</com.google.android.material.appbar.AppBarLayout>

</androidx.constraintlayout.widget.ConstraintLayout>
40 changes: 25 additions & 15 deletions app/src/main/res/layout/activity_game.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,35 @@
android:id="@+id/tapToBegin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/round_background"
android:clickable="false"
android:includeFontPadding="false"
android:paddingHorizontal="12dp"
android:paddingVertical="8dp"
android:text="@string/tap_to_begin"
android:textStyle="bold"
android:textAllCaps="true"
android:paddingVertical="8dp"
android:paddingHorizontal="12dp"
android:background="@drawable/round_background"
android:includeFontPadding="false"
app:layout_constraintStart_toStartOf="parent"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/>
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/controlsToast"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="false"
android:layout_marginVertical="100dp"
android:paddingVertical="8dp"
android:paddingHorizontal="12dp"
android:background="@drawable/round_background"
android:clickable="false"
android:gravity="center_horizontal"
android:lineSpacingExtra="8dp"
android:paddingHorizontal="12dp"
android:paddingVertical="8dp"
android:visibility="gone"
tools:text="Action to Reaction"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/>
tools:text="Action to Reaction" />


<com.google.android.material.appbar.AppBarLayout
Expand Down Expand Up @@ -129,6 +129,16 @@
tools:visibility="visible" />
</LinearLayout>

<ImageView
android:id="@+id/topBarToggle"
android:layout_width="?attr/actionBarSize"
android:layout_height="?attr/actionBarSize"
android:background="?selectableItemBackgroundBorderless"
android:contentDescription="@string/switch_control"
android:padding="16dp"
android:src="@drawable/touch"
android:visibility="gone" />

<FrameLayout
android:layout_width="?attr/actionBarSize"
android:layout_height="?attr/actionBarSize">
Expand All @@ -138,9 +148,9 @@
android:layout_width="?attr/actionBarSize"
android:layout_height="?attr/actionBarSize"
android:layout_gravity="center"
app:trackThickness="3dp"
app:indicatorColor="?attr/colorPrimary"
app:indicatorSize="24dp"
app:indicatorColor="?attr/colorPrimary"/>
app:trackThickness="3dp" />

<ImageView
android:id="@+id/shortcutIcon"
Expand Down
Loading

0 comments on commit a1794ed

Please sign in to comment.