Add control module

This commit is contained in:
Lucas Lima 2020-12-31 15:47:34 -03:00 committed by Lucas Nunes
parent 27ec68097f
commit 8cdf295fd4
21 changed files with 114 additions and 11 deletions

View file

@ -101,6 +101,7 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':external')
implementation project(':common')
implementation project(':control')
implementation project(':about')
implementation project(':ui')
implementation project(':preferences')

View file

@ -26,7 +26,6 @@ import androidx.lifecycle.Transformations
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.viewModelScope
import androidx.preference.PreferenceManager
import dev.lucasnlm.antimine.about.AboutActivity
import dev.lucasnlm.antimine.cloud.CloudSaveManager
import dev.lucasnlm.antimine.common.level.models.Difficulty
import dev.lucasnlm.antimine.common.level.models.Event

View file

@ -2,6 +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.cloud.ICloudSaveManager
import dev.lucasnlm.antimine.preferences.IPreferencesRepository
import dev.lucasnlm.external.ICloudStorageManager
import dev.lucasnlm.external.IPlayGamesManager
@ -16,8 +17,8 @@ class CloudSaveManager(
private val preferencesRepository: IPreferencesRepository,
private val statsRepository: IStatsRepository,
private val cloudStorageManager: ICloudStorageManager,
) {
fun uploadSave() {
) : ICloudSaveManager {
override fun uploadSave() {
GlobalScope.launch {
withContext(Dispatchers.IO) {
getCloudSave()?.let {

View file

@ -6,6 +6,7 @@ import dev.lucasnlm.antimine.common.BuildConfig
import dev.lucasnlm.antimine.core.analytics.DebugAnalyticsManager
import dev.lucasnlm.antimine.core.analytics.IAnalyticsManager
import dev.lucasnlm.antimine.core.analytics.ProdAnalyticsManager
import dev.lucasnlm.antimine.core.cloud.ICloudSaveManager
import dev.lucasnlm.antimine.share.ShareManager
import dev.lucasnlm.external.AdsManager
import dev.lucasnlm.external.BillingManager
@ -42,7 +43,7 @@ val AppModule = module {
single { IapHandler(get(), get(), get()) }
single { CloudSaveManager(get(), get(), get(), get()) }
single { CloudSaveManager(get(), get(), get(), get()) } bind ICloudSaveManager::class
single { FeatureFlagManager() } bind IFeatureFlagManager::class

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'

1
control/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/build

69
control/build.gradle Normal file
View file

@ -0,0 +1,69 @@
plugins {
id 'com.android.library'
id 'kotlin-android'
}
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'
}

View file

21
control/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,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="dev.lucasnlm.antimine.control">
</manifest>

View file

@ -8,18 +8,17 @@ import android.view.ViewGroup
import android.widget.BaseAdapter
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatDialogFragment
import dev.lucasnlm.antimine.R
import dev.lucasnlm.antimine.cloud.CloudSaveManager
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.cloud.ICloudSaveManager
import dev.lucasnlm.antimine.preferences.models.ControlStyle
import org.koin.android.ext.android.inject
import org.koin.androidx.viewmodel.ext.android.viewModel
class ControlDialogFragment : AppCompatDialogFragment() {
private val cloudSaveManager by inject<CloudSaveManager>()
private val cloudSaveManager by inject<ICloudSaveManager>()
private val controlViewModel by viewModel<ControlViewModel>()
private val adapter by lazy { ControlListAdapter(controlViewModel) }

View file

@ -7,7 +7,7 @@ import android.view.View
import android.widget.FrameLayout
import android.widget.TextView
import androidx.appcompat.widget.AppCompatRadioButton
import dev.lucasnlm.antimine.R
import dev.lucasnlm.antimine.control.R
import dev.lucasnlm.antimine.control.models.ControlDetails
class ControlItemView : FrameLayout {

View file

@ -7,7 +7,7 @@ import android.view.View
import android.widget.FrameLayout
import android.widget.TextView
import androidx.appcompat.widget.AppCompatRadioButton
import dev.lucasnlm.antimine.R
import dev.lucasnlm.antimine.control.R
import dev.lucasnlm.antimine.control.models.ControlDetails
class SimpleControlItemView : FrameLayout {

View file

@ -1,6 +1,6 @@
package dev.lucasnlm.antimine.control.viewmodel
import dev.lucasnlm.antimine.R
import dev.lucasnlm.antimine.control.R
import dev.lucasnlm.antimine.control.models.ControlDetails
import dev.lucasnlm.antimine.preferences.models.ControlStyle
import dev.lucasnlm.antimine.preferences.IPreferencesRepository

View file

@ -0,0 +1,5 @@
package dev.lucasnlm.antimine.core.cloud
interface ICloudSaveManager {
fun uploadSave()
}

View file

@ -6,3 +6,4 @@ include ':i18n'
include ':ui'
include ':preferences'
include ':core'
include ':control'