Extract code to other modules

This commit is contained in:
Lucas Lima 2020-12-31 15:01:51 -03:00 committed by Lucas Nunes
parent 108afb0842
commit 748ea2ba1e
149 changed files with 929 additions and 258 deletions

1
about/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/build

70
about/build.gradle Normal file
View file

@ -0,0 +1,70 @@
plugins {
id 'com.android.library'
id 'kotlin-android'
id 'kotlin-android-extensions'
}
android {
compileSdkVersion 30
defaultConfig {
minSdkVersion 21
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
implementation project(':core')
implementation project(':i18n')
implementation project(':preferences')
implementation project(':ui')
// AndroidX
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.activity:activity-ktx:1.1.0'
implementation 'androidx.fragment:fragment-ktx:1.2.5'
// RecyclerView
implementation 'androidx.recyclerview:recyclerview:1.2.0-beta01'
// Constraint
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
// Lifecycle
api 'android.arch.lifecycle:extensions:1.1.1'
implementation 'android.arch.lifecycle:viewmodel:1.1.1'
// Koin
implementation 'org.koin:koin-android:2.2.1'
implementation 'org.koin:koin-androidx-viewmodel:2.2.1'
testImplementation 'org.koin:koin-test:2.2.1'
// Coroutines
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.1'
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.4.2'
// Kotlin Lib
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.10'
}

0
about/consumer-rules.pro Normal file
View file

21
about/proguard-rules.pro vendored Normal file
View file

@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

View file

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="dev.lucasnlm.antimine.about">
<application>
<activity
android:name="dev.lucasnlm.antimine.text.TextActivity"
android:theme="@style/AppTheme">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="dev.lucasnlm.antimine.about.AboutActivity" />
</activity>
<activity
android:name="dev.lucasnlm.antimine.about.AboutActivity"
android:label="@string/about"
android:theme="@style/AppTheme">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="dev.lucasnlm.antimine.GameActivity" />
</activity>
</application>
</manifest>

View file

@ -4,14 +4,12 @@ import android.os.Bundle
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentTransaction
import androidx.lifecycle.lifecycleScope
import dev.lucasnlm.antimine.R
import dev.lucasnlm.antimine.ThematicActivity
import dev.lucasnlm.antimine.ui.ThematicActivity
import dev.lucasnlm.antimine.about.viewmodel.AboutEvent
import dev.lucasnlm.antimine.about.viewmodel.AboutViewModel
import dev.lucasnlm.antimine.about.views.info.AboutInfoFragment
import dev.lucasnlm.antimine.about.views.licenses.LicensesFragment
import dev.lucasnlm.antimine.about.views.translators.TranslatorsFragment
import dev.lucasnlm.antimine.support.SupportAppDialogFragment
import kotlinx.coroutines.flow.collect
import org.koin.androidx.viewmodel.ext.android.viewModel
@ -26,9 +24,6 @@ class AboutActivity : ThematicActivity(R.layout.activity_empty) {
lifecycleScope.launchWhenCreated {
aboutViewModel.observeEvent().collect { event ->
when (event) {
AboutEvent.SupportUs -> {
showSupportAppDialog()
}
AboutEvent.ThirdPartyLicenses -> {
replaceFragment(LicensesFragment(), LicensesFragment.TAG)
}
@ -50,11 +45,4 @@ class AboutActivity : ThematicActivity(R.layout.activity_empty) {
replace(R.id.content, fragment)
}.commitAllowingStateLoss()
}
private fun showSupportAppDialog() {
if (supportFragmentManager.findFragmentByTag(SupportAppDialogFragment.TAG) == null) {
SupportAppDialogFragment.newRequestSupportDialog(applicationContext)
.show(supportFragmentManager, SupportAppDialogFragment.TAG)
}
}
}

View file

@ -1,7 +1,6 @@
package dev.lucasnlm.antimine.about.viewmodel
enum class AboutEvent {
SupportUs,
ThirdPartyLicenses,
SourceCode,
Translators,

View file

@ -3,7 +3,7 @@ package dev.lucasnlm.antimine.about.viewmodel
import android.content.Context
import android.content.Intent
import android.net.Uri
import dev.lucasnlm.antimine.R
import dev.lucasnlm.antimine.about.R
import dev.lucasnlm.antimine.core.viewmodel.IntentViewModel
class AboutViewModel(

View file

@ -5,20 +5,15 @@ import android.os.Bundle
import android.view.View
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment
import dev.lucasnlm.antimine.BuildConfig
import dev.lucasnlm.antimine.R
import dev.lucasnlm.antimine.about.BuildConfig
import dev.lucasnlm.antimine.about.R
import dev.lucasnlm.antimine.about.viewmodel.AboutEvent
import dev.lucasnlm.antimine.about.viewmodel.AboutViewModel
import dev.lucasnlm.antimine.core.preferences.IPreferencesRepository
import dev.lucasnlm.external.IBillingManager
import kotlinx.android.synthetic.main.fragment_about_info.*
import org.koin.android.ext.android.inject
import org.koin.androidx.viewmodel.ext.android.sharedViewModel
class AboutInfoFragment : Fragment(R.layout.fragment_about_info) {
private val aboutViewModel: AboutViewModel by sharedViewModel()
private val preferencesRepository: IPreferencesRepository by inject()
private val billingManager: IBillingManager by inject()
override fun onResume() {
super.onResume()
@ -40,14 +35,6 @@ class AboutInfoFragment : Fragment(R.layout.fragment_about_info) {
}
}
if (preferencesRepository.isPremiumEnabled() && billingManager.isEnabled()) {
supportUs.visibility = View.GONE
} else {
supportUs.setOnClickListener {
aboutViewModel.sendEvent(AboutEvent.SupportUs)
}
}
thirdsParties.setOnClickListener {
aboutViewModel.sendEvent(AboutEvent.ThirdPartyLicenses)
}

View file

@ -5,7 +5,7 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import dev.lucasnlm.antimine.R
import dev.lucasnlm.antimine.about.R
import dev.lucasnlm.antimine.text.TextActivity
import dev.lucasnlm.antimine.about.viewmodel.License

View file

@ -6,7 +6,7 @@ import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager
import dev.lucasnlm.antimine.R
import dev.lucasnlm.antimine.about.R
import dev.lucasnlm.antimine.about.viewmodel.AboutViewModel
import kotlinx.android.synthetic.main.fragment_licenses.*
import kotlinx.coroutines.flow.collect

View file

@ -3,7 +3,7 @@ package dev.lucasnlm.antimine.about.views.translators
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import dev.lucasnlm.antimine.R
import dev.lucasnlm.antimine.about.R
import dev.lucasnlm.antimine.about.viewmodel.TranslationInfo
class TranslatorsAdapter(

View file

@ -8,7 +8,7 @@ import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import dev.lucasnlm.antimine.R
import dev.lucasnlm.antimine.about.R
import dev.lucasnlm.antimine.about.viewmodel.AboutViewModel
import kotlinx.android.synthetic.main.fragment_translators.*
import kotlinx.android.synthetic.main.view_translator.view.*

View file

@ -6,10 +6,10 @@ import android.os.Bundle
import android.view.View
import androidx.annotation.RawRes
import androidx.lifecycle.lifecycleScope
import dev.lucasnlm.antimine.R
import dev.lucasnlm.antimine.ThematicActivity
import dev.lucasnlm.antimine.about.R
import dev.lucasnlm.antimine.text.viewmodel.TextEvent
import dev.lucasnlm.antimine.text.viewmodel.TextViewModel
import dev.lucasnlm.antimine.ui.ThematicActivity
import kotlinx.android.synthetic.main.activity_text.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.collect

View file

@ -1,8 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="dev.lucasnlm.antimine.about.AboutActivity" />
android:fitsSystemWindows="true" />

View file

@ -66,18 +66,6 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/version_layout">
<Button
android:id="@+id/supportUs"
style="?android:attr/borderlessButtonStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/support_title"
android:textStyle="bold" />
<Space
android:layout_width="match_parent"
android:layout_height="24dp" />
<Button
android:id="@+id/thirdsParties"
style="?android:attr/borderlessButtonStyle"

View file

@ -5,7 +5,6 @@ plugins {
id 'kotlin-kapt'
}
if (System.getenv('IS_GOOGLE_BUILD')) {
apply plugin: 'com.google.firebase.crashlytics'
}
@ -102,6 +101,10 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':external')
implementation project(':common')
implementation project(':about')
implementation project(':ui')
implementation project(':preferences')
implementation project(':core')
googleImplementation project(':proprietary')
googleInstantImplementation project(':proprietary')

View file

@ -85,23 +85,6 @@
</intent-filter>
</activity>
<activity
android:name="dev.lucasnlm.antimine.text.TextActivity"
android:theme="@style/AppTheme">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="dev.lucasnlm.antimine.about.AboutActivity" />
</activity>
<activity
android:name="dev.lucasnlm.antimine.about.AboutActivity"
android:label="@string/about"
android:theme="@style/AppTheme">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="dev.lucasnlm.antimine.GameActivity" />
</activity>
<activity
android:label="@string/themes"
android:name="dev.lucasnlm.antimine.theme.ThemeActivity"

View file

@ -37,8 +37,8 @@ import dev.lucasnlm.antimine.common.level.viewmodel.GameViewModel
import dev.lucasnlm.antimine.control.ControlDialogFragment
import dev.lucasnlm.antimine.core.analytics.IAnalyticsManager
import dev.lucasnlm.antimine.core.analytics.models.Analytics
import dev.lucasnlm.antimine.core.control.ControlStyle
import dev.lucasnlm.antimine.core.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.preferences.models.ControlStyle
import dev.lucasnlm.antimine.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.custom.CustomLevelDialogFragment
import dev.lucasnlm.antimine.history.HistoryActivity
import dev.lucasnlm.antimine.gameover.EndGameDialogFragment
@ -53,6 +53,7 @@ import dev.lucasnlm.antimine.support.SupportAppDialogFragment
import dev.lucasnlm.antimine.theme.ThemeActivity
import dev.lucasnlm.antimine.tutorial.view.TutorialCompleteDialogFragment
import dev.lucasnlm.antimine.tutorial.view.TutorialLevelFragment
import dev.lucasnlm.antimine.ui.ThematicActivity
import dev.lucasnlm.external.IBillingManager
import dev.lucasnlm.external.IInstantAppManager
import dev.lucasnlm.external.IFeatureFlagManager
@ -60,9 +61,6 @@ import dev.lucasnlm.external.IPlayGamesManager
import dev.lucasnlm.external.ReviewWrapper
import dev.lucasnlm.external.model.PurchaseInfo
import kotlinx.android.synthetic.main.activity_game.*
import kotlinx.android.synthetic.main.activity_game.minesCount
import kotlinx.android.synthetic.main.activity_game.timer
import kotlinx.android.synthetic.main.activity_tv_game.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.delay
@ -412,7 +410,7 @@ class GameActivity : ThematicActivity(R.layout.activity_game), DialogInterface.O
ActionBarDrawerToggle(
this@GameActivity,
drawer,
toolbar,
null,
R.string.open_menu,
R.string.close_menu
).apply {
@ -607,7 +605,7 @@ class GameActivity : ThematicActivity(R.layout.activity_game), DialogInterface.O
private fun showAbout() {
analyticsManager.sentEvent(Analytics.OpenAbout)
Intent(this, AboutActivity::class.java).apply {
Intent(this, dev.lucasnlm.antimine.about.AboutActivity::class.java).apply {
startActivity(this)
}
}

View file

@ -5,7 +5,7 @@ import dev.lucasnlm.antimine.common.level.di.LevelModule
import dev.lucasnlm.antimine.core.analytics.IAnalyticsManager
import dev.lucasnlm.antimine.core.analytics.models.Analytics
import dev.lucasnlm.antimine.core.di.CommonModule
import dev.lucasnlm.antimine.core.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.di.AppModule
import dev.lucasnlm.antimine.di.ViewModelModule
import dev.lucasnlm.external.IAdsManager

View file

@ -2,7 +2,7 @@ package dev.lucasnlm.antimine.cloud
import dev.lucasnlm.antimine.common.level.database.models.toHashMap
import dev.lucasnlm.antimine.common.level.repository.IStatsRepository
import dev.lucasnlm.antimine.core.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.preferences.IPreferencesRepository
import dev.lucasnlm.external.ICloudStorageManager
import dev.lucasnlm.external.IPlayGamesManager
import dev.lucasnlm.external.model.CloudSave

View file

@ -14,7 +14,7 @@ import dev.lucasnlm.antimine.control.view.ControlItemView
import dev.lucasnlm.antimine.control.view.SimpleControlItemView
import dev.lucasnlm.antimine.control.viewmodel.ControlEvent
import dev.lucasnlm.antimine.control.viewmodel.ControlViewModel
import dev.lucasnlm.antimine.core.control.ControlStyle
import dev.lucasnlm.antimine.preferences.models.ControlStyle
import org.koin.android.ext.android.inject
import org.koin.androidx.viewmodel.ext.android.viewModel

View file

@ -1,7 +1,7 @@
package dev.lucasnlm.antimine.control.models
import androidx.annotation.StringRes
import dev.lucasnlm.antimine.core.control.ControlStyle
import dev.lucasnlm.antimine.preferences.models.ControlStyle
data class ControlDetails(
val id: Long,

View file

@ -1,6 +1,6 @@
package dev.lucasnlm.antimine.control.viewmodel
import dev.lucasnlm.antimine.core.control.ControlStyle
import dev.lucasnlm.antimine.preferences.models.ControlStyle
sealed class ControlEvent {
data class SelectControlStyle(

View file

@ -1,7 +1,7 @@
package dev.lucasnlm.antimine.control.viewmodel
import dev.lucasnlm.antimine.control.models.ControlDetails
import dev.lucasnlm.antimine.core.control.ControlStyle
import dev.lucasnlm.antimine.preferences.models.ControlStyle
data class ControlState(
val selectedIndex: Int,

View file

@ -2,8 +2,8 @@ package dev.lucasnlm.antimine.control.viewmodel
import dev.lucasnlm.antimine.R
import dev.lucasnlm.antimine.control.models.ControlDetails
import dev.lucasnlm.antimine.core.control.ControlStyle
import dev.lucasnlm.antimine.core.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.preferences.models.ControlStyle
import dev.lucasnlm.antimine.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.core.viewmodel.IntentViewModel
import kotlinx.coroutines.flow.flow

View file

@ -11,9 +11,9 @@ import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatDialogFragment
import dev.lucasnlm.antimine.R
import dev.lucasnlm.antimine.common.level.models.Difficulty
import dev.lucasnlm.antimine.common.level.models.Minefield
import dev.lucasnlm.antimine.preferences.models.Minefield
import dev.lucasnlm.antimine.common.level.viewmodel.GameViewModel
import dev.lucasnlm.antimine.core.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.custom.viewmodel.CreateGameViewModel
import dev.lucasnlm.antimine.custom.viewmodel.CustomEvent
import org.koin.android.ext.android.inject

View file

@ -1,6 +1,6 @@
package dev.lucasnlm.antimine.custom.viewmodel
import dev.lucasnlm.antimine.core.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.core.viewmodel.IntentViewModel
import kotlinx.coroutines.flow.flow

View file

@ -1,6 +1,6 @@
package dev.lucasnlm.antimine.custom.viewmodel
import dev.lucasnlm.antimine.common.level.models.Minefield
import dev.lucasnlm.antimine.preferences.models.Minefield
sealed class CustomEvent {
data class UpdateCustomGameEvent(

View file

@ -18,7 +18,7 @@ import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.viewModelScope
import dev.lucasnlm.antimine.R
import dev.lucasnlm.antimine.common.level.viewmodel.GameViewModel
import dev.lucasnlm.antimine.core.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.gameover.model.GameResult
import dev.lucasnlm.antimine.gameover.viewmodel.EndGameDialogEvent
import dev.lucasnlm.antimine.gameover.viewmodel.EndGameDialogViewModel
@ -42,7 +42,7 @@ class EndGameDialogFragment : AppCompatDialogFragment() {
private val instantAppManager: IInstantAppManager by inject()
private val endGameViewModel by viewModel<EndGameDialogViewModel>()
private val gameViewModel by sharedViewModel<GameViewModel>()
private val preferencesRepository: IPreferencesRepository by inject()
private val preferencesRepository: dev.lucasnlm.antimine.preferences.IPreferencesRepository by inject()
private val billingManager: IBillingManager by inject()
override fun onCreate(savedInstanceState: Bundle?) {

View file

@ -2,7 +2,7 @@ package dev.lucasnlm.antimine.history
import android.os.Bundle
import dev.lucasnlm.antimine.R
import dev.lucasnlm.antimine.ThematicActivity
import dev.lucasnlm.antimine.ui.ThematicActivity
import dev.lucasnlm.antimine.history.views.HistoryFragment
class HistoryActivity : ThematicActivity(R.layout.activity_empty) {

View file

@ -5,7 +5,7 @@ import android.content.Intent
import android.net.Uri
import dev.lucasnlm.antimine.DeepLink
import dev.lucasnlm.antimine.common.level.repository.ISavesRepository
import dev.lucasnlm.antimine.core.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.core.viewmodel.IntentViewModel
import kotlinx.coroutines.flow.flow

View file

@ -7,9 +7,8 @@ import android.view.MenuItem
import androidx.preference.PreferenceFragmentCompat
import androidx.preference.PreferenceManager
import dev.lucasnlm.antimine.R
import dev.lucasnlm.antimine.ThematicActivity
import dev.lucasnlm.antimine.ui.ThematicActivity
import dev.lucasnlm.antimine.cloud.CloudSaveManager
import dev.lucasnlm.antimine.core.preferences.IPreferencesRepository
import org.koin.android.ext.android.inject
class PreferencesActivity :

View file

@ -15,9 +15,9 @@ import dev.lucasnlm.antimine.BuildConfig
import dev.lucasnlm.antimine.R
import dev.lucasnlm.antimine.common.level.models.Area
import dev.lucasnlm.antimine.common.level.models.AreaPaintSettings
import dev.lucasnlm.antimine.common.level.models.Minefield
import dev.lucasnlm.antimine.preferences.models.Minefield
import dev.lucasnlm.antimine.common.level.view.paintOnCanvas
import dev.lucasnlm.antimine.core.themes.repository.IThemeRepository
import dev.lucasnlm.antimine.ui.repository.IThemeRepository
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import java.io.File

View file

@ -5,8 +5,8 @@ import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import dev.lucasnlm.antimine.common.level.database.models.Stats
import dev.lucasnlm.antimine.common.level.repository.IStatsRepository
import dev.lucasnlm.antimine.core.control.ControlStyle
import dev.lucasnlm.antimine.core.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.preferences.models.ControlStyle
import dev.lucasnlm.antimine.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.support.IapHandler
import dev.lucasnlm.external.ICloudStorageManager
import dev.lucasnlm.external.model.CloudSave

View file

@ -8,8 +8,8 @@ import androidx.appcompat.app.AlertDialog
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
import dev.lucasnlm.antimine.R
import dev.lucasnlm.antimine.ThematicActivity
import dev.lucasnlm.antimine.core.themes.repository.IThemeRepository
import dev.lucasnlm.antimine.ui.ThematicActivity
import dev.lucasnlm.antimine.ui.repository.IThemeRepository
import dev.lucasnlm.antimine.stats.view.StatsAdapter
import dev.lucasnlm.antimine.stats.viewmodel.StatsEvent
import dev.lucasnlm.antimine.stats.viewmodel.StatsViewModel
@ -23,7 +23,7 @@ import org.koin.androidx.viewmodel.ext.android.viewModel
class StatsActivity : ThematicActivity(R.layout.activity_stats) {
private val statsViewModel by viewModel<StatsViewModel>()
private val instantAppManager: IInstantAppManager by inject()
private val themeRepository: IThemeRepository by inject()
private val themeRepository: dev.lucasnlm.antimine.ui.repository.IThemeRepository by inject()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

View file

@ -8,7 +8,7 @@ import android.widget.TextView
import androidx.cardview.widget.CardView
import androidx.recyclerview.widget.RecyclerView
import dev.lucasnlm.antimine.R
import dev.lucasnlm.antimine.core.themes.repository.IThemeRepository
import dev.lucasnlm.antimine.ui.repository.IThemeRepository
import dev.lucasnlm.antimine.stats.model.StatsModel
import kotlinx.android.synthetic.main.view_stats.view.*

View file

@ -3,11 +3,11 @@ package dev.lucasnlm.antimine.stats.viewmodel
import dev.lucasnlm.antimine.R
import dev.lucasnlm.antimine.common.level.database.models.Stats
import dev.lucasnlm.antimine.common.level.models.Difficulty
import dev.lucasnlm.antimine.common.level.models.Minefield
import dev.lucasnlm.antimine.preferences.models.Minefield
import dev.lucasnlm.antimine.common.level.repository.IDimensionRepository
import dev.lucasnlm.antimine.common.level.repository.IMinefieldRepository
import dev.lucasnlm.antimine.common.level.repository.IStatsRepository
import dev.lucasnlm.antimine.core.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.core.viewmodel.IntentViewModel
import dev.lucasnlm.antimine.stats.model.StatsModel
import dev.lucasnlm.antimine.stats.model.StatsState

View file

@ -3,7 +3,7 @@ package dev.lucasnlm.antimine.support
import android.content.Context
import android.widget.Toast
import dev.lucasnlm.antimine.R
import dev.lucasnlm.antimine.core.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.preferences.IPreferencesRepository
import dev.lucasnlm.external.IBillingManager
import dev.lucasnlm.external.model.PurchaseInfo
import kotlinx.coroutines.Dispatchers

View file

@ -14,7 +14,7 @@ import androidx.lifecycle.lifecycleScope
import dev.lucasnlm.antimine.R
import dev.lucasnlm.antimine.core.analytics.IAnalyticsManager
import dev.lucasnlm.antimine.core.analytics.models.Analytics
import dev.lucasnlm.antimine.core.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.preferences.IPreferencesRepository
import dev.lucasnlm.external.Ads
import dev.lucasnlm.external.IAdsManager
import dev.lucasnlm.external.IBillingManager

View file

@ -6,15 +6,15 @@ import android.view.MenuItem
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.GridLayoutManager
import dev.lucasnlm.antimine.R
import dev.lucasnlm.antimine.ThematicActivity
import dev.lucasnlm.antimine.cloud.CloudSaveManager
import dev.lucasnlm.antimine.common.level.repository.IDimensionRepository
import dev.lucasnlm.antimine.common.level.view.SpaceItemDecoration
import dev.lucasnlm.antimine.core.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.support.SupportAppDialogFragment
import dev.lucasnlm.antimine.theme.view.ThemeAdapter
import dev.lucasnlm.antimine.theme.viewmodel.ThemeEvent
import dev.lucasnlm.antimine.theme.viewmodel.ThemeViewModel
import dev.lucasnlm.antimine.ui.ThematicActivity
import dev.lucasnlm.external.IBillingManager
import kotlinx.android.synthetic.main.activity_game.*
import kotlinx.android.synthetic.main.activity_theme.*

View file

@ -10,7 +10,7 @@ import dev.lucasnlm.antimine.common.level.models.Area
import dev.lucasnlm.antimine.common.level.models.AreaPaintSettings
import dev.lucasnlm.antimine.common.level.view.AreaAdapter
import dev.lucasnlm.antimine.common.level.view.AreaView
import dev.lucasnlm.antimine.core.themes.model.AppTheme
import dev.lucasnlm.antimine.ui.model.AppTheme
import dev.lucasnlm.antimine.theme.viewmodel.ThemeEvent
import dev.lucasnlm.antimine.theme.viewmodel.ThemeViewModel
import kotlinx.android.synthetic.main.view_theme.view.*

View file

@ -1,6 +1,6 @@
package dev.lucasnlm.antimine.theme.viewmodel
import dev.lucasnlm.antimine.core.themes.model.AppTheme
import dev.lucasnlm.antimine.ui.model.AppTheme
sealed class ThemeEvent {
data class Unlock(

View file

@ -1,6 +1,6 @@
package dev.lucasnlm.antimine.theme.viewmodel
import dev.lucasnlm.antimine.core.themes.model.AppTheme
import dev.lucasnlm.antimine.ui.model.AppTheme
data class ThemeState(
val current: AppTheme,

View file

@ -2,10 +2,10 @@ package dev.lucasnlm.antimine.theme.viewmodel
import dev.lucasnlm.antimine.core.analytics.IAnalyticsManager
import dev.lucasnlm.antimine.core.analytics.models.Analytics
import dev.lucasnlm.antimine.core.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.core.themes.model.AppTheme
import dev.lucasnlm.antimine.core.themes.repository.IThemeRepository
import dev.lucasnlm.antimine.core.themes.repository.Themes
import dev.lucasnlm.antimine.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.ui.model.AppTheme
import dev.lucasnlm.antimine.ui.repository.IThemeRepository
import dev.lucasnlm.antimine.ui.repository.Themes
import dev.lucasnlm.antimine.core.viewmodel.IntentViewModel
import dev.lucasnlm.external.IBillingManager
import kotlinx.coroutines.flow.Flow

View file

@ -14,8 +14,8 @@ import dev.lucasnlm.antimine.common.level.repository.IDimensionRepository
import dev.lucasnlm.antimine.common.level.view.AreaAdapter
import dev.lucasnlm.antimine.common.level.view.AreaView
import dev.lucasnlm.antimine.common.level.view.AreaViewHolder
import dev.lucasnlm.antimine.core.control.ControlStyle
import dev.lucasnlm.antimine.core.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.preferences.models.ControlStyle
import dev.lucasnlm.antimine.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.tutorial.viewmodel.TutorialViewModel
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch

View file

@ -15,7 +15,7 @@ import dev.lucasnlm.antimine.common.level.models.Event
import dev.lucasnlm.antimine.common.level.repository.IDimensionRepository
import dev.lucasnlm.antimine.common.level.view.SpaceItemDecoration
import dev.lucasnlm.antimine.common.level.viewmodel.GameViewModel
import dev.lucasnlm.antimine.core.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.tutorial.viewmodel.TutorialViewModel
import kotlinx.android.synthetic.main.fragment_tutorial_level.*
import kotlinx.coroutines.flow.asFlow

View file

@ -13,10 +13,10 @@ import dev.lucasnlm.antimine.common.level.utils.IHapticFeedbackManager
import dev.lucasnlm.antimine.common.level.viewmodel.GameViewModel
import dev.lucasnlm.antimine.core.analytics.IAnalyticsManager
import dev.lucasnlm.antimine.core.analytics.models.Analytics
import dev.lucasnlm.antimine.core.control.ControlStyle
import dev.lucasnlm.antimine.core.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.preferences.models.ControlStyle
import dev.lucasnlm.antimine.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.core.sound.ISoundManager
import dev.lucasnlm.antimine.core.themes.repository.IThemeRepository
import dev.lucasnlm.antimine.ui.repository.IThemeRepository
import dev.lucasnlm.antimine.tutorial.view.TutorialField
import dev.lucasnlm.external.IPlayGamesManager
import kotlinx.coroutines.channels.ConflatedBroadcastChannel
@ -26,7 +26,7 @@ class TutorialViewModel(
savesRepository: ISavesRepository,
statsRepository: IStatsRepository,
dimensionRepository: IDimensionRepository,
themeRepository: IThemeRepository,
themeRepository: dev.lucasnlm.antimine.ui.repository.IThemeRepository,
soundManager: ISoundManager,
minefieldRepository: IMinefieldRepository,
analyticsManager: IAnalyticsManager,

View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Splash" parent="Theme.AppCompat.DayNight.NoActionBar">
<item name="android:windowBackground">@drawable/splash</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
</style>
</resources>

View file

@ -3,9 +3,8 @@ package dev.lucasnlm.antimine.control
import dev.lucasnlm.antimine.IntentViewModelTest
import dev.lucasnlm.antimine.control.viewmodel.ControlEvent
import dev.lucasnlm.antimine.control.viewmodel.ControlViewModel
import dev.lucasnlm.antimine.core.control.ControlStyle
import dev.lucasnlm.antimine.core.preferences.IPreferencesRepository
import io.mockk.every
import dev.lucasnlm.antimine.preferences.models.ControlStyle
import dev.lucasnlm.antimine.preferences.IPreferencesRepository
import io.mockk.mockk
import io.mockk.verify
import org.junit.Assert.assertEquals

View file

@ -1,11 +1,10 @@
package dev.lucasnlm.antimine.custom
import dev.lucasnlm.antimine.IntentViewModelTest
import dev.lucasnlm.antimine.common.level.models.Minefield
import dev.lucasnlm.antimine.core.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.preferences.models.Minefield
import dev.lucasnlm.antimine.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.custom.viewmodel.CreateGameViewModel
import dev.lucasnlm.antimine.custom.viewmodel.CustomEvent
import io.mockk.every
import io.mockk.mockk
import org.junit.Assert.assertEquals
import org.junit.Test
@ -26,7 +25,7 @@ class CreateGameViewModelTest : IntentViewModelTest() {
@Test
fun testSetNewCustomValues() {
val preferenceRepository: IPreferencesRepository = mockk {
val preferenceRepository: dev.lucasnlm.antimine.preferences.IPreferencesRepository = mockk {
every { customGameMode() } returns Minefield(10, 12, 9)
every { updateCustomGameMode(any()) } returns Unit
}

View file

@ -1,11 +1,11 @@
package dev.lucasnlm.antimine.di
import dev.lucasnlm.antimine.common.level.repository.IDimensionRepository
import dev.lucasnlm.antimine.core.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.core.sound.ISoundManager
import dev.lucasnlm.antimine.core.themes.model.AppTheme
import dev.lucasnlm.antimine.core.themes.repository.IThemeRepository
import dev.lucasnlm.antimine.core.themes.repository.Themes.LightTheme
import dev.lucasnlm.antimine.ui.model.AppTheme
import dev.lucasnlm.antimine.ui.repository.IThemeRepository
import dev.lucasnlm.antimine.ui.repository.Themes.LightTheme
import dev.lucasnlm.antimine.mocks.FixedDimensionRepository
import dev.lucasnlm.antimine.mocks.MockPreferencesRepository
import org.koin.dsl.bind
@ -23,7 +23,7 @@ val TestCommonModule = module {
} bind ISoundManager::class
single {
object : IThemeRepository {
object : dev.lucasnlm.antimine.ui.repository.IThemeRepository {
override fun getCustomTheme(): AppTheme? = null
override fun getTheme(): AppTheme = LightTheme
@ -34,5 +34,5 @@ val TestCommonModule = module {
override fun reset(): AppTheme = LightTheme
}
} bind IThemeRepository::class
} bind dev.lucasnlm.antimine.ui.repository.IThemeRepository::class
}

View file

@ -5,7 +5,7 @@ import dev.lucasnlm.antimine.common.level.database.models.FirstOpen
import dev.lucasnlm.antimine.common.level.database.models.Save
import dev.lucasnlm.antimine.common.level.database.models.SaveStatus
import dev.lucasnlm.antimine.common.level.models.Difficulty
import dev.lucasnlm.antimine.common.level.models.Minefield
import dev.lucasnlm.antimine.preferences.models.Minefield
import dev.lucasnlm.antimine.common.level.repository.ISavesRepository
import dev.lucasnlm.antimine.history.viewmodel.HistoryEvent
import dev.lucasnlm.antimine.history.viewmodel.HistoryState

View file

@ -1,17 +1,18 @@
package dev.lucasnlm.antimine.mocks
import dev.lucasnlm.antimine.common.level.models.Difficulty
import dev.lucasnlm.antimine.common.level.models.Minefield
import dev.lucasnlm.antimine.preferences.models.Minefield
import dev.lucasnlm.antimine.common.level.repository.IDimensionRepository
import dev.lucasnlm.antimine.common.level.repository.IMinefieldRepository
import dev.lucasnlm.antimine.core.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.preferences.IPreferencesRepository
class FixedMinefieldRepository : IMinefieldRepository {
override fun fromDifficulty(
difficulty: Difficulty,
dimensionRepository: IDimensionRepository,
preferencesRepository: IPreferencesRepository
): Minefield = Minefield(9, 9, 9)
): Minefield =
Minefield(9, 9, 9)
override fun randomSeed(): Long = 0L
}

View file

@ -1,8 +1,8 @@
package dev.lucasnlm.antimine.mocks
import dev.lucasnlm.antimine.common.level.models.Minefield
import dev.lucasnlm.antimine.core.control.ControlStyle
import dev.lucasnlm.antimine.core.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.preferences.models.Minefield
import dev.lucasnlm.antimine.preferences.models.ControlStyle
import dev.lucasnlm.antimine.preferences.IPreferencesRepository
class MockPreferencesRepository : IPreferencesRepository {
private var customMinefield = Minefield(9, 9, 9)

View file

@ -2,11 +2,11 @@ package dev.lucasnlm.antimine.stats.viewmodel
import dev.lucasnlm.antimine.IntentViewModelTest
import dev.lucasnlm.antimine.common.level.database.models.Stats
import dev.lucasnlm.antimine.common.level.models.Minefield
import dev.lucasnlm.antimine.preferences.models.Minefield
import dev.lucasnlm.antimine.common.level.repository.IDimensionRepository
import dev.lucasnlm.antimine.common.level.repository.IMinefieldRepository
import dev.lucasnlm.antimine.common.level.repository.MemoryStatsRepository
import dev.lucasnlm.antimine.core.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.preferences.IPreferencesRepository
import io.mockk.every
import io.mockk.mockk
import kotlinx.coroutines.test.runBlockingTest
@ -47,7 +47,11 @@ class StatsViewModelTest : IntentViewModelTest() {
super.setup()
every { prefsRepository.getStatsBase() } returns 0
every { prefsRepository.isPremiumEnabled() } returns false
every { minefieldRepository.fromDifficulty(any(), any(), any()) } returns Minefield(6, 12, 9)
every { minefieldRepository.fromDifficulty(any(), any(), any()) } returns Minefield(
6,
12,
9
)
}
@Test

View file

@ -3,11 +3,11 @@ package dev.lucasnlm.antimine.theme
import dev.lucasnlm.antimine.IntentViewModelTest
import dev.lucasnlm.antimine.common.R
import dev.lucasnlm.antimine.core.analytics.IAnalyticsManager
import dev.lucasnlm.antimine.core.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.core.themes.model.AppTheme
import dev.lucasnlm.antimine.core.themes.model.AreaPalette
import dev.lucasnlm.antimine.core.themes.model.Assets
import dev.lucasnlm.antimine.core.themes.repository.IThemeRepository
import dev.lucasnlm.antimine.preferences.IPreferencesRepository
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.antimine.theme.viewmodel.ThemeEvent
import dev.lucasnlm.antimine.theme.viewmodel.ThemeState
import dev.lucasnlm.antimine.theme.viewmodel.ThemeViewModel
@ -129,7 +129,7 @@ class ThemeViewModelTest : IntentViewModelTest() {
@Test
fun testInitialValue() {
val themeRepository = mockk<IThemeRepository> {
val themeRepository = mockk<dev.lucasnlm.antimine.ui.repository.IThemeRepository> {
every { getAllThemes() } returns allThemes
every { getTheme() } returns gardenTheme
}
@ -146,7 +146,7 @@ class ThemeViewModelTest : IntentViewModelTest() {
@Test
fun testChangeValue() {
val themeRepository = mockk<IThemeRepository> {
val themeRepository = mockk<dev.lucasnlm.antimine.ui.repository.IThemeRepository> {
every { getAllThemes() } returns allThemes
every { getTheme() } returns gardenTheme
every { setTheme(any()) } returns Unit
@ -175,7 +175,7 @@ class ThemeViewModelTest : IntentViewModelTest() {
@Test
fun testChangeValueWithoutExtras() {
val themeRepository = mockk<IThemeRepository> {
val themeRepository = mockk<dev.lucasnlm.antimine.ui.repository.IThemeRepository> {
every { getAllThemes() } returns allThemes
every { getTheme() } returns gardenTheme
every { setTheme(any()) } returns Unit

View file

@ -7,7 +7,7 @@ buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:4.0.2'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.10'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.21'
if (System.getenv('IS_GOOGLE_BUILD')) {
classpath 'com.google.gms:google-services:4.3.4'

View file

@ -40,6 +40,8 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':external')
implementation project(':i18n')
implementation project(':preferences')
implementation project(':ui')
// AndroidX
implementation 'androidx.appcompat:appcompat:1.2.0'

View file

@ -10,7 +10,7 @@ import dev.lucasnlm.antimine.common.level.models.Area
import dev.lucasnlm.antimine.common.level.models.Mark
import dev.lucasnlm.antimine.common.level.view.AreaAdapter
import dev.lucasnlm.antimine.common.level.view.paintOnCanvas
import dev.lucasnlm.antimine.core.themes.repository.Themes.LightTheme
import dev.lucasnlm.antimine.ui.repository.Themes.LightTheme
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Test

View file

@ -9,11 +9,11 @@ import dev.lucasnlm.antimine.common.level.logic.MinefieldCreator
import dev.lucasnlm.antimine.common.level.logic.MinefieldHandler
import dev.lucasnlm.antimine.common.level.models.Area
import dev.lucasnlm.antimine.common.level.models.Difficulty
import dev.lucasnlm.antimine.common.level.models.Minefield
import dev.lucasnlm.antimine.preferences.models.Minefield
import dev.lucasnlm.antimine.common.level.models.Score
import dev.lucasnlm.antimine.common.level.solver.LimitedBruteForceSolver
import dev.lucasnlm.antimine.core.control.ActionResponse
import dev.lucasnlm.antimine.core.control.GameControl
import dev.lucasnlm.antimine.preferences.models.ActionResponse
import dev.lucasnlm.antimine.preferences.models.GameControl
import kotlinx.coroutines.flow.flow
import kotlin.random.Random

View file

@ -4,7 +4,7 @@ import androidx.room.TypeConverter
import com.squareup.moshi.JsonAdapter
import com.squareup.moshi.Moshi
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
import dev.lucasnlm.antimine.common.level.models.Minefield
import dev.lucasnlm.antimine.preferences.models.Minefield
class MinefieldConverter {
private val moshi: Moshi = Moshi.Builder().add(KotlinJsonAdapterFactory()).build()
@ -14,7 +14,11 @@ class MinefieldConverter {
@TypeConverter
fun toMinefield(jsonInput: String): Minefield =
jsonAdapter.fromJson(jsonInput) ?: Minefield(9, 9, 9)
jsonAdapter.fromJson(jsonInput) ?: Minefield(
9,
9,
9
)
@TypeConverter
fun toJsonString(field: Minefield): String = jsonAdapter.toJson(field)

View file

@ -6,7 +6,7 @@ import androidx.room.PrimaryKey
import androidx.room.TypeConverters
import dev.lucasnlm.antimine.common.level.models.Area
import dev.lucasnlm.antimine.common.level.models.Difficulty
import dev.lucasnlm.antimine.common.level.models.Minefield
import dev.lucasnlm.antimine.preferences.models.Minefield
import dev.lucasnlm.antimine.common.level.database.converters.AreaConverter
import dev.lucasnlm.antimine.common.level.database.converters.FirstOpenConverter
import dev.lucasnlm.antimine.common.level.database.converters.SaveStatusConverter

View file

@ -1,7 +1,7 @@
package dev.lucasnlm.antimine.common.level.logic
import dev.lucasnlm.antimine.common.level.models.Area
import dev.lucasnlm.antimine.common.level.models.Minefield
import dev.lucasnlm.antimine.preferences.models.Minefield
import kotlin.math.floor
import kotlin.random.Random

View file

@ -4,7 +4,7 @@ import android.content.Context
import android.content.res.Resources
import android.content.res.TypedArray
import dev.lucasnlm.antimine.common.R
import dev.lucasnlm.antimine.core.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.preferences.IPreferencesRepository
interface IDimensionRepository {
fun areaSize(): Float

View file

@ -1,8 +1,8 @@
package dev.lucasnlm.antimine.common.level.repository
import dev.lucasnlm.antimine.common.level.models.Difficulty
import dev.lucasnlm.antimine.common.level.models.Minefield
import dev.lucasnlm.antimine.core.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.preferences.models.Minefield
import dev.lucasnlm.antimine.preferences.IPreferencesRepository
import kotlin.random.Random
interface IMinefieldRepository {

View file

@ -1,6 +1,6 @@
package dev.lucasnlm.antimine.common.level.repository
import dev.lucasnlm.antimine.core.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.preferences.IPreferencesRepository
interface ITipRepository {
fun setExtraTips(amount: Int)

View file

@ -16,8 +16,8 @@ import dev.lucasnlm.antimine.common.level.models.Area
import dev.lucasnlm.antimine.common.level.models.AreaPaintSettings
import dev.lucasnlm.antimine.common.level.repository.IDimensionRepository
import dev.lucasnlm.antimine.common.level.viewmodel.GameViewModel
import dev.lucasnlm.antimine.core.control.ControlStyle
import dev.lucasnlm.antimine.core.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.preferences.models.ControlStyle
import dev.lucasnlm.antimine.preferences.IPreferencesRepository
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch

View file

@ -10,7 +10,7 @@ import dev.lucasnlm.antimine.common.R
import dev.lucasnlm.antimine.common.level.models.Area
import dev.lucasnlm.antimine.common.level.models.AreaPaintSettings
import dev.lucasnlm.antimine.common.level.models.Mark
import dev.lucasnlm.antimine.core.themes.model.AppTheme
import dev.lucasnlm.antimine.ui.model.AppTheme
fun Area.paintOnCanvas(
context: Context,

View file

@ -16,7 +16,7 @@ import dev.lucasnlm.antimine.common.R
import dev.lucasnlm.antimine.common.level.models.Area
import dev.lucasnlm.antimine.common.level.models.AreaPaintSettings
import dev.lucasnlm.antimine.common.level.models.Mark
import dev.lucasnlm.antimine.core.themes.model.AppTheme
import dev.lucasnlm.antimine.ui.model.AppTheme
class AreaView : View {
// Used on Wear OS

View file

@ -7,11 +7,11 @@ import androidx.annotation.LayoutRes
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.RecyclerView
import dev.lucasnlm.antimine.common.R
import dev.lucasnlm.antimine.common.level.models.Minefield
import dev.lucasnlm.antimine.preferences.models.Minefield
import dev.lucasnlm.antimine.common.level.repository.IDimensionRepository
import dev.lucasnlm.antimine.common.level.viewmodel.GameViewModel
import dev.lucasnlm.antimine.common.level.widget.FixedGridLayoutManager
import dev.lucasnlm.antimine.core.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.preferences.IPreferencesRepository
import org.koin.android.ext.android.inject
import org.koin.androidx.viewmodel.ext.android.sharedViewModel
import kotlin.math.nextDown

View file

@ -10,7 +10,7 @@ import dev.lucasnlm.antimine.common.level.database.models.Save
import dev.lucasnlm.antimine.common.level.models.Area
import dev.lucasnlm.antimine.common.level.models.Difficulty
import dev.lucasnlm.antimine.common.level.models.Event
import dev.lucasnlm.antimine.common.level.models.Minefield
import dev.lucasnlm.antimine.preferences.models.Minefield
import dev.lucasnlm.antimine.common.level.repository.IDimensionRepository
import dev.lucasnlm.antimine.common.level.repository.IMinefieldRepository
import dev.lucasnlm.antimine.common.level.repository.ISavesRepository
@ -20,12 +20,12 @@ import dev.lucasnlm.antimine.common.level.utils.Clock
import dev.lucasnlm.antimine.common.level.utils.IHapticFeedbackManager
import dev.lucasnlm.antimine.core.analytics.IAnalyticsManager
import dev.lucasnlm.antimine.core.analytics.models.Analytics
import dev.lucasnlm.antimine.core.control.ActionResponse
import dev.lucasnlm.antimine.core.control.GameControl
import dev.lucasnlm.antimine.core.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.core.sound.ISoundManager
import dev.lucasnlm.antimine.core.themes.model.AppTheme
import dev.lucasnlm.antimine.core.themes.repository.IThemeRepository
import dev.lucasnlm.antimine.preferences.models.ActionResponse
import dev.lucasnlm.antimine.preferences.models.GameControl
import dev.lucasnlm.antimine.ui.model.AppTheme
import dev.lucasnlm.antimine.ui.repository.IThemeRepository
import dev.lucasnlm.external.Achievement
import dev.lucasnlm.external.IPlayGamesManager
import dev.lucasnlm.external.Leaderboard

View file

@ -13,24 +13,6 @@ import androidx.recyclerview.widget.LinearSmoothScroller
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.RecyclerView.Recycler
/**
* A [RecyclerView.LayoutManager] implementation
* that places children in a two-dimensional grid, sized to a fixed column count
* value. User scrolling is possible in both horizontal and vertical directions
* to view the data set.
*
*
* The column count is controllable via [.setTotalColumnCount]. The layout manager
* will generate the number of rows necessary to accommodate the data set based on
* the fixed column count.
*
*
* This manager does make some assumptions to simplify the implementation:
*
* * All child views are assumed to be the same size
* * The window of visible views is a constant
*
*/
class FixedGridLayoutManager : RecyclerView.LayoutManager() {
companion object {

View file

@ -2,7 +2,7 @@ package dev.lucasnlm.antimine.core.analytics.models
import dev.lucasnlm.antimine.common.level.models.Difficulty
import dev.lucasnlm.antimine.common.level.models.Score
import dev.lucasnlm.antimine.common.level.models.Minefield
import dev.lucasnlm.antimine.preferences.models.Minefield
sealed class Analytics(
val name: String,

View file

@ -3,14 +3,14 @@ package dev.lucasnlm.antimine.core.di
import android.view.ViewConfiguration
import dev.lucasnlm.antimine.common.level.repository.DimensionRepository
import dev.lucasnlm.antimine.common.level.repository.IDimensionRepository
import dev.lucasnlm.antimine.core.preferences.IPreferencesManager
import dev.lucasnlm.antimine.core.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.core.preferences.PreferencesManager
import dev.lucasnlm.antimine.core.preferences.PreferencesRepository
import dev.lucasnlm.antimine.preferences.IPreferencesManager
import dev.lucasnlm.antimine.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.preferences.PreferencesManager
import dev.lucasnlm.antimine.preferences.PreferencesRepository
import dev.lucasnlm.antimine.core.sound.ISoundManager
import dev.lucasnlm.antimine.core.sound.SoundManager
import dev.lucasnlm.antimine.core.themes.repository.IThemeRepository
import dev.lucasnlm.antimine.core.themes.repository.ThemeRepository
import dev.lucasnlm.antimine.ui.repository.IThemeRepository
import dev.lucasnlm.antimine.ui.repository.ThemeRepository
import org.koin.dsl.bind
import org.koin.dsl.module
@ -19,9 +19,16 @@ val CommonModule = module {
single { DimensionRepository(get(), get()) } bind IDimensionRepository::class
single { PreferencesRepository(get(), ViewConfiguration.getLongPressTimeout()) } bind IPreferencesRepository::class
single {
PreferencesRepository(
get(),
ViewConfiguration.getLongPressTimeout()
)
} bind IPreferencesRepository::class
single { SoundManager(get()) } bind ISoundManager::class
single { ThemeRepository(get(), get()) } bind IThemeRepository::class
single {
ThemeRepository(get(), get())
} bind IThemeRepository::class
}

View file

@ -1,6 +1,6 @@
package dev.lucasnlm.antimine.common.level.database.converters
import dev.lucasnlm.antimine.common.level.models.Minefield
import dev.lucasnlm.antimine.preferences.models.Minefield
import org.junit.Test
import org.junit.Assert.assertEquals

View file

@ -1,10 +1,10 @@
package dev.lucasnlm.antimine.common.level.di
import dev.lucasnlm.antimine.common.level.models.Difficulty
import dev.lucasnlm.antimine.common.level.models.Minefield
import dev.lucasnlm.antimine.preferences.models.Minefield
import dev.lucasnlm.antimine.common.level.repository.IDimensionRepository
import dev.lucasnlm.antimine.common.level.repository.IMinefieldRepository
import dev.lucasnlm.antimine.core.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.preferences.IPreferencesRepository
class FixedMinefieldRepository : IMinefieldRepository {
override fun fromDifficulty(

View file

@ -1,6 +1,6 @@
package dev.lucasnlm.antimine.common.level.logic
import dev.lucasnlm.antimine.common.level.models.Minefield
import dev.lucasnlm.antimine.preferences.models.Minefield
import kotlinx.coroutines.test.runBlockingTest
import org.junit.Assert.assertEquals
import org.junit.Test
@ -10,7 +10,14 @@ class FlagAssistantTest {
@Test
fun testRunAssistant() = runBlockingTest {
repeat(20) { takeMines ->
val creator = MinefieldCreator(Minefield(8, 8, 25), Random(200))
val creator = MinefieldCreator(
Minefield(
8,
8,
25
),
Random(200)
)
val map = creator.create(50, false).toMutableList()
map.filter { it.hasMine }
@ -43,7 +50,14 @@ class FlagAssistantTest {
repeat(20) { takeMines ->
val seed = 10 * takeMines
val creator = MinefieldCreator(Minefield(8, 8, 25), Random(seed))
val creator = MinefieldCreator(
Minefield(
8,
8,
25
),
Random(seed)
)
val map = creator.create(50, false).toMutableList()
map.filter { it.hasMine }

View file

@ -2,11 +2,10 @@ package dev.lucasnlm.antimine.common.level.logic
import dev.lucasnlm.antimine.common.level.GameController
import dev.lucasnlm.antimine.common.level.models.Area
import dev.lucasnlm.antimine.common.level.models.Minefield
import dev.lucasnlm.antimine.preferences.models.Minefield
import dev.lucasnlm.antimine.common.level.models.Score
import dev.lucasnlm.antimine.core.control.ControlStyle
import dev.lucasnlm.antimine.preferences.models.ControlStyle
import dev.lucasnlm.antimine.core.control.GameControl
import kotlinx.coroutines.flow.single
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.test.runBlockingTest

View file

@ -1,6 +1,6 @@
package dev.lucasnlm.antimine.common.level.logic
import dev.lucasnlm.antimine.common.level.models.Minefield
import dev.lucasnlm.antimine.preferences.models.Minefield
import org.junit.Assert.assertEquals
import org.junit.Test
import kotlin.random.Random

View file

@ -3,11 +3,11 @@ package dev.lucasnlm.antimine.common.level.logic
import com.nhaarman.mockitokotlin2.doReturn
import com.nhaarman.mockitokotlin2.mock
import dev.lucasnlm.antimine.common.level.models.Difficulty
import dev.lucasnlm.antimine.common.level.models.Minefield
import dev.lucasnlm.antimine.preferences.models.Minefield
import dev.lucasnlm.antimine.common.level.repository.MinefieldRepository
import dev.lucasnlm.antimine.common.level.repository.IDimensionRepository
import dev.lucasnlm.antimine.common.level.repository.Size
import dev.lucasnlm.antimine.core.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.preferences.IPreferencesRepository
import org.junit.Assert.assertEquals
import org.junit.Test

View file

@ -1,7 +1,7 @@
package dev.lucasnlm.antimine.common.level.logic
import dev.lucasnlm.antimine.common.level.models.Mark
import dev.lucasnlm.antimine.common.level.models.Minefield
import dev.lucasnlm.antimine.preferences.models.Minefield
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue

View file

@ -1,8 +1,8 @@
package dev.lucasnlm.antimine.common.level.repository
import dev.lucasnlm.antimine.common.level.models.Difficulty
import dev.lucasnlm.antimine.common.level.models.Minefield
import dev.lucasnlm.antimine.core.preferences.IPreferencesRepository
import dev.lucasnlm.antimine.preferences.models.Minefield
import dev.lucasnlm.antimine.preferences.IPreferencesRepository
import io.mockk.every
import io.mockk.mockk
import org.junit.Assert.assertEquals

View file

@ -2,7 +2,7 @@ package dev.lucasnlm.antimine.common.level.solver
import dev.lucasnlm.antimine.common.level.logic.MinefieldCreator
import dev.lucasnlm.antimine.common.level.logic.MinefieldHandler
import dev.lucasnlm.antimine.common.level.models.Minefield
import dev.lucasnlm.antimine.preferences.models.Minefield
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test

View file

@ -2,7 +2,7 @@ package dev.lucasnlm.antimine.common.level.solver
import dev.lucasnlm.antimine.common.level.logic.MinefieldCreator
import dev.lucasnlm.antimine.common.level.logic.MinefieldHandler
import dev.lucasnlm.antimine.common.level.models.Minefield
import dev.lucasnlm.antimine.preferences.models.Minefield
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test

View file

@ -5,7 +5,7 @@ import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test
private class TestPreferenceManager : IPreferencesManager {
private class TestPreferenceManager : dev.lucasnlm.antimine.preferences.IPreferencesManager {
val values = mutableMapOf<String, Any>()
override fun getBoolean(key: String, defaultValue: Boolean): Boolean {
@ -37,7 +37,8 @@ class PreferencesRepositoryTest {
@Test
fun testProgressValue() {
val preferenceManager = TestPreferenceManager()
val preferencesRepository = PreferencesRepository(preferenceManager, 400)
val preferencesRepository =
dev.lucasnlm.antimine.preferences.PreferencesRepository(preferenceManager, 400)
assertEquals(0, preferencesRepository.getProgressiveValue())
@ -63,7 +64,8 @@ class PreferencesRepositoryTest {
preferenceManager.putBoolean("preference_double_click_open", true)
assertTrue(preferenceManager.values["preference_double_click_open"] as Boolean)
val preferencesRepository = PreferencesRepository(preferenceManager, 400)
val preferencesRepository =
dev.lucasnlm.antimine.preferences.PreferencesRepository(preferenceManager, 400)
assertTrue(preferenceManager.values["preference_double_click_open"] == null)
assertEquals(1, preferenceManager.values["preference_control_style"])
@ -76,7 +78,8 @@ class PreferencesRepositoryTest {
preferenceManager.putBoolean("preference_double_click_open", false)
assertFalse(preferenceManager.values["preference_double_click_open"] as Boolean)
val preferencesRepository = PreferencesRepository(preferenceManager, 400)
val preferencesRepository =
dev.lucasnlm.antimine.preferences.PreferencesRepository(preferenceManager, 400)
assertTrue(preferenceManager.values["preference_double_click_open"] == null)
assertFalse(preferenceManager.getBoolean("preference_double_click_open", false))
@ -88,7 +91,8 @@ class PreferencesRepositoryTest {
preferenceManager.putBoolean("preference_large_area", true)
assertTrue(preferenceManager.values["preference_large_area"] as Boolean)
val preferencesRepository = PreferencesRepository(preferenceManager, 400)
val preferencesRepository =
dev.lucasnlm.antimine.preferences.PreferencesRepository(preferenceManager, 400)
assertTrue(preferenceManager.values["preference_large_area"] == null)
assertEquals(63, preferenceManager.getInt("preference_area_size", -1))
@ -97,7 +101,7 @@ class PreferencesRepositoryTest {
@Test
fun testMigrationLargeAreaOff() {
val preferenceManager = TestPreferenceManager()
PreferencesRepository(preferenceManager, 400)
dev.lucasnlm.antimine.preferences.PreferencesRepository(preferenceManager, 400)
assertTrue(preferenceManager.values["preference_large_area"] == null)
assertEquals(50, preferenceManager.getInt("preference_area_size", -1))
@ -109,7 +113,7 @@ class PreferencesRepositoryTest {
preferenceManager.putBoolean("preference_large_area", false)
assertEquals(false, preferenceManager.values["preference_large_area"] as Boolean)
PreferencesRepository(preferenceManager, 400)
dev.lucasnlm.antimine.preferences.PreferencesRepository(preferenceManager, 400)
assertTrue(preferenceManager.values["preference_large_area"] == null)
assertEquals(50, preferenceManager.getInt("preference_area_size", -1))

View file

@ -6,7 +6,7 @@ import org.junit.Test
class ThemeRepositoryTest {
@Test
fun getAllThemesMustNotHaveDuplicatedIds() {
val customThemes = Themes.getAllCustom()
val customThemes = dev.lucasnlm.antimine.ui.repository.Themes.getAllCustom()
customThemes.distinctBy { it.id }.count()
assertEquals(customThemes.size, customThemes.distinctBy { it.id }.count())
}

Some files were not shown because too many files have changed in this diff Show more