Skip to content

Commit

Permalink
Merge pull request #485 from lucasnlm/bump-gdx
Browse files Browse the repository at this point in the history
Add Android Auto support
  • Loading branch information
lucasnlm authored Nov 30, 2023
2 parents 49840ac + bd6cf4c commit dd462a3
Show file tree
Hide file tree
Showing 58 changed files with 550 additions and 212 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Feel free to contribute with [issues](https://github.com/lucasnlm/antimine-andro
## Features

- Support to [Android Wear OS](https://developer.android.com/wear)
- Support to [Android Auto](https://www.android.com/auto/)
- No guessing algorithm
- Multiple themes colors (including dynamic colors and AMOLED)
- Multiple skins (including the classic)
Expand Down
2 changes: 2 additions & 0 deletions about/src/main/res/layout/activity_container.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingVertical="@dimen/root_vertical_spacing"
android:paddingHorizontal="@dimen/root_horizontal_spacing"
android:fitsSystemWindows="true">

<com.google.android.material.appbar.MaterialToolbar
Expand Down
11 changes: 7 additions & 4 deletions about/src/main/res/layout/fragment_about_info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:paddingHorizontal="@dimen/main_activity_padding"
android:paddingHorizontal="@dimen/root_horizontal_spacing"
tools:context="dev.lucasnlm.antimine.about.AboutActivity">

<LinearLayout
android:id="@+id/version_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:layout_height="0dp"
android:gravity="center"
android:orientation="vertical"
app:layout_constraintBottom_toTopOf="@+id/buttons"
app:layout_constraintBottom_toTopOf="@+id/musicCard"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
Expand All @@ -39,6 +39,7 @@
android:textAllCaps="true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="?android:attr/textColorPrimary"
android:textSize="@dimen/base_font_size"
android:textStyle="bold" />

<TextView
Expand All @@ -47,6 +48,7 @@
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="?android:attr/textColorPrimary"
android:textSize="@dimen/base_font_size"
tools:text="Version 7.1.0" />

<TextView
Expand All @@ -55,6 +57,7 @@
android:layout_height="wrap_content"
android:text="Instant Build"
android:textColor="?android:attr/textColorSecondary"
android:textSize="@dimen/base_font_size"
tools:ignore="HardcodedText" />
</LinearLayout>

Expand Down
2 changes: 2 additions & 0 deletions about/src/main/res/layout/fragment_licenses.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="false"
android:paddingVertical="@dimen/root_vertical_spacing"
android:paddingHorizontal="@dimen/root_horizontal_spacing"
tools:context="dev.lucasnlm.antimine.licenses.LicenseActivity">

<androidx.recyclerview.widget.RecyclerView
Expand Down
1 change: 1 addition & 0 deletions about/src/main/res/layout/view_third_party.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
android:padding="16dp"
android:textColor="?android:attr/textColorSecondary"
android:textStyle="bold"
android:textSize="@dimen/base_font_size"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
Expand Down
21 changes: 18 additions & 3 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ android {

defaultConfig {
// versionCode and versionName must be hardcoded to support F-droid
versionCode = 1706001
versionName = "17.6.0"
versionCode = 1706031
versionName = "17.6.3"
minSdk = libs.versions.minSdk.get().toInt()
targetSdk = libs.versions.targetSdk.get().toInt()
compileSdk = libs.versions.compileSdk.get().toInt()
Expand Down Expand Up @@ -90,7 +90,7 @@ android {
}

create("googleInstant") {
versionCode = 163
versionCode = 164
dimension = "version"
applicationId = "dev.lucasnlm.antimine"
versionNameSuffix = " I"
Expand All @@ -100,6 +100,17 @@ android {
}
}

create("auto") {
dimension = "version"
applicationId = "dev.lucasnlm.antimine"
versionNameSuffix = " C"

if (isGoogleBuild) {
plugins.apply("com.google.gms.google-services")
plugins.apply("com.bugsnag.android.gradle")
}
}

create("foss") {
dimension = "version"
// There"s a typo on F-Droid release :(
Expand All @@ -114,6 +125,7 @@ android {
}

val googleImplementation by configurations
val autoImplementation by configurations
val googleInstantImplementation by configurations
val fossImplementation by configurations

Expand All @@ -131,11 +143,14 @@ dependencies {
implementation(project(":gdx"))

googleImplementation(project(":proprietary"))
autoImplementation(project(":proprietary"))
googleInstantImplementation(project(":proprietary"))
googleInstantImplementation(project(":instant"))
fossImplementation(project(":foss"))
fossImplementation(project(":donation"))

autoImplementation(project(":audio"))
autoImplementation(project(":auto"))
googleImplementation(project(":audio"))
fossImplementation(project(":audio"))
googleInstantImplementation(project(":audio-low"))
Expand Down
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
android:hardwareAccelerated="true"
android:icon="@mipmap/ic_launcher"
android:isGame="true"
android:appCategory="game"
android:label="@string/app_name"
android:localeConfig="@xml/locales_config"
android:roundIcon="@mipmap/ic_launcher_round"
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/dev/lucasnlm/antimine/GameActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import androidx.lifecycle.lifecycleScope
import com.badlogic.gdx.backends.android.AndroidFragmentApplication
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.snackbar.Snackbar
import dev.lucasnlm.antimine.common.auto.AutoExt.isAndroidAuto
import dev.lucasnlm.antimine.common.level.view.GameRenderFragment
import dev.lucasnlm.antimine.common.level.viewmodel.GameEvent
import dev.lucasnlm.antimine.common.level.viewmodel.GameViewModel
Expand Down Expand Up @@ -789,7 +790,7 @@ class GameActivity :
}

lifecycleScope.launch {
if (preferencesRepository.showTutorialDialog()) {
if (preferencesRepository.showTutorialDialog() && !isAndroidAuto()) {
val firstLocale = ConfigurationCompat.getLocales(resources.configuration).get(0)
val lang = firstLocale?.language

Expand Down
7 changes: 6 additions & 1 deletion app/src/main/java/dev/lucasnlm/antimine/MainApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package dev.lucasnlm.antimine
import androidx.multidex.MultiDexApplication
import com.badlogic.gdx.utils.GdxNativesLoader
import com.google.android.material.color.DynamicColors
import dev.lucasnlm.antimine.common.auto.AutoExt.isAndroidAuto
import dev.lucasnlm.antimine.common.io.di.CommonIoModule
import dev.lucasnlm.antimine.common.level.di.LevelModule
import dev.lucasnlm.antimine.core.di.CommonModule
Expand Down Expand Up @@ -55,7 +56,11 @@ open class MainApplication : MultiDexApplication() {
if (featureFlagManager.isFoss) {
preferencesRepository.setPremiumFeatures(true)
} else {
adsManager.start(this)
if (applicationContext.isAndroidAuto()) {
preferencesRepository.setPremiumFeatures(true)
} else {
adsManager.start(this)
}
}

val lastAppVersion = preferencesRepository.lastAppVersion()
Expand Down
6 changes: 4 additions & 2 deletions app/src/main/java/dev/lucasnlm/antimine/main/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import androidx.lifecycle.lifecycleScope
import dev.lucasnlm.antimine.GameActivity
import dev.lucasnlm.antimine.R
import dev.lucasnlm.antimine.about.AboutActivity
import dev.lucasnlm.antimine.common.auto.AutoExt.isAndroidAuto
import dev.lucasnlm.antimine.common.io.models.SaveStatus
import dev.lucasnlm.antimine.common.level.repository.MinefieldRepository
import dev.lucasnlm.antimine.common.level.repository.SavesRepository
Expand Down Expand Up @@ -284,7 +285,7 @@ class MainActivity : ThemedActivity() {
startActivity(intent)
}

if (playGamesManager.hasGooglePlayGames()) {
if (playGamesManager.hasGooglePlayGames() && !isAndroidAuto()) {
binding.playGames.setOnClickListener {
soundManager.playClickSound()
analyticsManager.sentEvent(Analytics.OpenGooglePlayGames)
Expand Down Expand Up @@ -384,7 +385,8 @@ class MainActivity : ThemedActivity() {
private fun launchGooglePlayGames() {
if (playGamesManager.hasGooglePlayGames() &&
playGamesManager.shouldRequestLogin() &&
preferenceRepository.keepRequestPlayGames()
preferenceRepository.keepRequestPlayGames() &&
!isAndroidAuto()
) {
playGamesManager.keepRequestingLogin(false)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ class PlayGamesButtonView : FrameLayout {
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr)

val binding: ViewPlayGamesButtonBinding

init {
val layoutInflater = LayoutInflater.from(context)
binding = ViewPlayGamesButtonBinding.inflate(layoutInflater, this, true)
}

val binding: ViewPlayGamesButtonBinding
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import androidx.core.view.isVisible
import androidx.preference.PreferenceManager
import com.google.android.material.materialswitch.MaterialSwitch
import dev.lucasnlm.antimine.R
import dev.lucasnlm.antimine.common.auto.AutoExt.isAndroidAuto
import dev.lucasnlm.antimine.core.audio.GameAudioManager
import dev.lucasnlm.antimine.core.cloud.CloudSaveManager
import dev.lucasnlm.antimine.databinding.ActivityPreferencesBinding
Expand Down Expand Up @@ -223,42 +224,48 @@ class PreferencesActivity :
binding.playGames.isVisible = false
}

binding.exportSettings.setOnClickListener {
val exportIntent =
Intent(Intent.ACTION_CREATE_DOCUMENT).apply {
addCategory(Intent.CATEGORY_OPENABLE)
putExtra(Intent.EXTRA_TITLE, SettingsBackupManager.FILE_NAME)
type = "application/json"

androidOreo {
val documentsDir =
Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_DOCUMENTS,
)
putExtra(DocumentsContract.EXTRA_INITIAL_URI, documentsDir.toUri())
binding.exportSettings.apply {
isVisible = !isAndroidAuto()
setOnClickListener {
val exportIntent =
Intent(Intent.ACTION_CREATE_DOCUMENT).apply {
addCategory(Intent.CATEGORY_OPENABLE)
putExtra(Intent.EXTRA_TITLE, SettingsBackupManager.FILE_NAME)
type = "application/json"

androidOreo {
val documentsDir =
Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_DOCUMENTS,
)
putExtra(DocumentsContract.EXTRA_INITIAL_URI, documentsDir.toUri())
}
}
}

exportResultLauncher.launch(exportIntent)
exportResultLauncher.launch(exportIntent)
}
}

binding.importSettings.setOnClickListener {
val exportIntent =
Intent(Intent.ACTION_OPEN_DOCUMENT).apply {
addCategory(Intent.CATEGORY_OPENABLE)
putExtra(Intent.EXTRA_TITLE, SettingsBackupManager.FILE_NAME)
type = "application/json"

androidOreo {
val documentsDir =
Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_DOCUMENTS,
)
putExtra(DocumentsContract.EXTRA_INITIAL_URI, documentsDir.toUri())
binding.importSettings.apply {
isVisible = !isAndroidAuto()
setOnClickListener {
val exportIntent =
Intent(Intent.ACTION_OPEN_DOCUMENT).apply {
addCategory(Intent.CATEGORY_OPENABLE)
putExtra(Intent.EXTRA_TITLE, SettingsBackupManager.FILE_NAME)
type = "application/json"

androidOreo {
val documentsDir =
Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_DOCUMENTS,
)
putExtra(DocumentsContract.EXTRA_INITIAL_URI, documentsDir.toUri())
}
}
}

importResultLauncher.launch(exportIntent)
importResultLauncher.launch(exportIntent)
}
}
}

Expand Down
14 changes: 8 additions & 6 deletions app/src/main/res/layout-land/activity_game.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
android:text="@string/loading"
android:textAllCaps="true"
android:textStyle="bold"
android:textSize="@dimen/base_font_size"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand All @@ -46,6 +47,7 @@
android:paddingVertical="8dp"
android:textAllCaps="true"
android:textStyle="bold"
android:textSize="@dimen/base_font_size"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand All @@ -70,10 +72,10 @@

<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/back"
android:layout_width="?attr/actionBarSize"
android:layout_height="?attr/actionBarSize"
android:layout_width="@dimen/base_icon_bar_size"
android:layout_height="@dimen/base_icon_bar_size"
android:contentDescription="@string/back"
android:padding="20dp"
android:padding="16dp"
app:srcCompat="@drawable/arrow_left" />

<LinearLayout
Expand Down Expand Up @@ -140,13 +142,13 @@

<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/shortcutIcon"
android:layout_width="?attr/actionBarSize"
android:layout_height="?attr/actionBarSize"
android:layout_width="@dimen/base_icon_bar_size"
android:layout_height="@dimen/base_icon_bar_size"
android:layout_gravity="center_horizontal"
android:alpha="0.0"
android:clickable="false"
android:contentDescription="@string/new_game"
android:padding="20dp"
android:padding="16dp"
app:srcCompat="@drawable/retry"
tools:alpha="1.0" />

Expand Down
Loading

0 comments on commit dd462a3

Please sign in to comment.