diff --git a/app/build.gradle b/app/build.gradle index 9def5cd4..36925322 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -14,8 +14,8 @@ android { applicationId "es.verdnatura" minSdkVersion 21 targetSdkVersion 29 - versionCode 54 - versionName "5.4.4" + versionCode 55 + versionName "5.4.5" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } diff --git a/app/src/main/java/es/verdnatura/di/viewModelModule.kt b/app/src/main/java/es/verdnatura/di/viewModelModule.kt index ccce720d..ac6133d8 100644 --- a/app/src/main/java/es/verdnatura/di/viewModelModule.kt +++ b/app/src/main/java/es/verdnatura/di/viewModelModule.kt @@ -23,111 +23,112 @@ import es.verdnatura.presentation.view.feature.sacador.fragment.SacadorViewModel import es.verdnatura.presentation.view.feature.shelvingparking.fragment.ShelvingParkingViewModel import es.verdnatura.presentation.view.feature.ubicador.fragment.AutomaticAddItemViewModel import es.verdnatura.presentation.view.feature.ubicador.fragment.UbicadorViewModel +import org.koin.android.ext.koin.androidContext import org.koin.androidx.viewmodel.dsl.viewModel import org.koin.dsl.module val viewModelModule = module{ // Login viewModel { - LoginViewModel() + LoginViewModel(androidContext()) } // Pasilleros viewModel { - PasilleroViewModel() + PasilleroViewModel(androidContext()) } // Pasilleros / Item Card viewModel { - ItemCardViewModel() + ItemCardViewModel(androidContext()) } // Pasilleros / Item Card / Historico viewModel { - HistoricoViewModel() + HistoricoViewModel(androidContext()) } // Pasilleros / Buscar Item viewModel { - BuscarItemViewModel() + BuscarItemViewModel(androidContext()) } // Pasilleros / Inventario viewModel { - InventaryViewModel() + InventaryViewModel(androidContext()) } // Pasilleros / Faltas viewModel { - FaltasViewModel() + FaltasViewModel(androidContext()) } // ShelvingParking viewModel { - ShelvingParkingViewModel() + ShelvingParkingViewModel(androidContext()) } // Ubicador viewModel { - UbicadorViewModel() + UbicadorViewModel(androidContext()) } // Ubicador // Automatic viewModel { - AutomaticAddItemViewModel() + AutomaticAddItemViewModel(androidContext()) } // Ajustes viewModel { - AjustesViewModel() + AjustesViewModel(androidContext()) } // PALETIZADOR viewModel { - ExpeditionTruckListViewModel() + ExpeditionTruckListViewModel(androidContext()) } viewModel { - ExpeditionPalletViewModel() + ExpeditionPalletViewModel(androidContext()) } viewModel { - ExpeditionPalletDetailViewModel() + ExpeditionPalletDetailViewModel(androidContext()) } viewModel { - ExpeditionScanViewModel() + ExpeditionScanViewModel(androidContext()) } // SACADOR viewModel { - SacadorViewModel() + SacadorViewModel(androidContext()) } viewModel { - CollectionViewModel() + CollectionViewModel(androidContext()) } viewModel { - ControladorViewModel() + ControladorViewModel(androidContext()) } viewModel { - ParkingViewModel() + ParkingViewModel(androidContext()) } viewModel { - PreSacadorViewModel() + PreSacadorViewModel(androidContext()) } viewModel { - ReposicionViewModel() + ReposicionViewModel(androidContext()) } viewModel { - BuyersViewModel() + BuyersViewModel(androidContext()) } viewModel { - QaualityViewModel() + QaualityViewModel(androidContext()) } } \ No newline at end of file diff --git a/app/src/main/java/es/verdnatura/domain/ApiUtils.kt b/app/src/main/java/es/verdnatura/domain/ApiUtils.kt index d3a3b4ac..85ca6443 100644 --- a/app/src/main/java/es/verdnatura/domain/ApiUtils.kt +++ b/app/src/main/java/es/verdnatura/domain/ApiUtils.kt @@ -1,5 +1,8 @@ package es.verdnatura.domain +import android.content.Context +import android.content.SharedPreferences +import android.preference.PreferenceManager import okhttp3.OkHttpClient import retrofit2.Retrofit import retrofit2.converter.gson.GsonConverterFactory @@ -10,15 +13,26 @@ class ApiUtils { companion object { //const val BASE_URL:String = "http://192.168.1.54:8009/" const val BASE_URL:String = "https://app.verdnatura.es/" - fun getApiService():VerdnaturaService{ + + + + fun getApiService(context: Context):VerdnaturaService{ val retrofit = Retrofit.Builder() - .baseUrl(BASE_URL) + .baseUrl(getBaseUrlLocal(context)) .addConverterFactory(GsonConverterFactory.create()) .client(getRequestHeader()) .build() return retrofit.create(VerdnaturaService::class.java) } + fun getBaseUrlLocal(context: Context): String { + var url = this.getDefaults("base_url",context) + if (url.isNullOrEmpty()){ + setDefaults("base_url", BASE_URL,context) + } + return if (url.isNullOrEmpty()) BASE_URL else url + } + fun getRequestHeader(): OkHttpClient? { val client = OkHttpClient.Builder() .connectTimeout(10, TimeUnit.SECONDS) @@ -27,6 +41,19 @@ class ApiUtils { .build() return client } + + fun setDefaults(key: String?, value: String?, context: Context?) { + val preferences: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(context) + val editor = preferences.edit() + editor.putString(key, value) + editor.commit() + } + + fun getDefaults(key: String?, context: Context?): String? { + val preferences = PreferenceManager.getDefaultSharedPreferences(context) + return preferences.getString(key, null) + } + } } \ No newline at end of file diff --git a/app/src/main/java/es/verdnatura/domain/GetAjustesUserCase.kt b/app/src/main/java/es/verdnatura/domain/GetAjustesUserCase.kt index 9d778ae4..3a5a2f55 100644 --- a/app/src/main/java/es/verdnatura/domain/GetAjustesUserCase.kt +++ b/app/src/main/java/es/verdnatura/domain/GetAjustesUserCase.kt @@ -1,9 +1,10 @@ package es.verdnatura.domain +import android.content.Context import es.verdnatura.presentation.view.feature.ajustes.model.SectorItemVO import retrofit2.Call -class GetAjustesUserCase : RestClient() { +class GetAjustesUserCase(context: Context) : RestClient(context) { fun getSectors(usuario:String,password:String) : Call> { return restClient!!.getSectors("json","1",usuario,password,"application/json") diff --git a/app/src/main/java/es/verdnatura/domain/GetBuscarItemUserCase.kt b/app/src/main/java/es/verdnatura/domain/GetBuscarItemUserCase.kt index 9685b511..5448f6bc 100644 --- a/app/src/main/java/es/verdnatura/domain/GetBuscarItemUserCase.kt +++ b/app/src/main/java/es/verdnatura/domain/GetBuscarItemUserCase.kt @@ -1,9 +1,10 @@ package es.verdnatura.domain +import android.content.Context import es.verdnatura.presentation.view.feature.buscaritem.model.ItemLocationVO import retrofit2.Call -class GetBuscarItemUserCase : RestClient() { +class GetBuscarItemUserCase(context: Context) : RestClient(context) { fun searchItemsUbicador(usuario:String,password:String,itemFk:String) : Call> { val params:ArrayList = ArrayList(); diff --git a/app/src/main/java/es/verdnatura/domain/GetInventaryUserCase.kt b/app/src/main/java/es/verdnatura/domain/GetInventaryUserCase.kt index 8d7dd6fd..13880dc4 100644 --- a/app/src/main/java/es/verdnatura/domain/GetInventaryUserCase.kt +++ b/app/src/main/java/es/verdnatura/domain/GetInventaryUserCase.kt @@ -1,10 +1,11 @@ package es.verdnatura.domain +import android.content.Context import es.verdnatura.presentation.view.feature.faltas.model.ItemFaltasVO import es.verdnatura.presentation.view.feature.inventario.model.ItemInventaryVO import retrofit2.Call -class GetInventaryUserCase : RestClient() { +class GetInventaryUserCase(context: Context) : RestClient(context) { fun itemShelvingRadar(usuario:String,password:String,sectorFk:String) : Call> { val params:ArrayList = ArrayList(); diff --git a/app/src/main/java/es/verdnatura/domain/GetItemCardUserCase.kt b/app/src/main/java/es/verdnatura/domain/GetItemCardUserCase.kt index 7afee210..15fb3923 100644 --- a/app/src/main/java/es/verdnatura/domain/GetItemCardUserCase.kt +++ b/app/src/main/java/es/verdnatura/domain/GetItemCardUserCase.kt @@ -1,10 +1,11 @@ package es.verdnatura.domain +import android.content.Context import es.verdnatura.presentation.view.feature.articulo.model.ItemCardVO import es.verdnatura.presentation.view.feature.historico.model.ItemHistoricoVO import retrofit2.Call -class GetItemCardUserCase : RestClient() { +class GetItemCardUserCase(context: Context) : RestClient(context) { fun getItemCard(usuario:String,password:String,itemFk:String,warehouseFk:String) : Call { val params:ArrayList = ArrayList(); diff --git a/app/src/main/java/es/verdnatura/domain/GetLoginUserCase.kt b/app/src/main/java/es/verdnatura/domain/GetLoginUserCase.kt index c9c303a4..f8d0a6de 100644 --- a/app/src/main/java/es/verdnatura/domain/GetLoginUserCase.kt +++ b/app/src/main/java/es/verdnatura/domain/GetLoginUserCase.kt @@ -1,10 +1,11 @@ package es.verdnatura.domain +import android.content.Context import es.verdnatura.presentation.view.feature.login.model.LoginSalixVO import es.verdnatura.presentation.view.feature.login.model.SalixMessageVO import retrofit2.Call -class GetLoginUserCase() : RestClient() { +class GetLoginUserCase(context: Context) : RestClient(context) { fun login(usuario:String,password:String) : Call{ val params:ArrayList = ArrayList(); diff --git a/app/src/main/java/es/verdnatura/domain/GetPaletizadoresUserCase.kt b/app/src/main/java/es/verdnatura/domain/GetPaletizadoresUserCase.kt index c720e18e..bd268a6a 100644 --- a/app/src/main/java/es/verdnatura/domain/GetPaletizadoresUserCase.kt +++ b/app/src/main/java/es/verdnatura/domain/GetPaletizadoresUserCase.kt @@ -1,9 +1,10 @@ package es.verdnatura.domain +import android.content.Context import es.verdnatura.presentation.view.feature.paletizador.model.* import retrofit2.Call -class GetPaletizadoresUserCase: RestClient() { +class GetPaletizadoresUserCase(context: Context) : RestClient(context) { fun expeditionTruckList(usuario:String,password:String) : Call> { val params:ArrayList = ArrayList(); diff --git a/app/src/main/java/es/verdnatura/domain/GetPreSacadorUseCase.kt b/app/src/main/java/es/verdnatura/domain/GetPreSacadorUseCase.kt index 3390ea32..4880ed77 100644 --- a/app/src/main/java/es/verdnatura/domain/GetPreSacadorUseCase.kt +++ b/app/src/main/java/es/verdnatura/domain/GetPreSacadorUseCase.kt @@ -1,9 +1,10 @@ package es.verdnatura.domain +import android.content.Context import es.verdnatura.presentation.view.feature.presacador.model.PreSacadorItemVO import retrofit2.Call -class GetPreSacadorUseCase() : RestClient() { +class GetPreSacadorUseCase(context: Context) : RestClient(context) { fun ticketToPrePrepare(usuario:String,password:String,ticketFk:String,sectorFk:String) : Call> { val params:ArrayList = ArrayList(); diff --git a/app/src/main/java/es/verdnatura/domain/GetQualityUserCase.kt b/app/src/main/java/es/verdnatura/domain/GetQualityUserCase.kt index bbf260fb..ee2264f8 100644 --- a/app/src/main/java/es/verdnatura/domain/GetQualityUserCase.kt +++ b/app/src/main/java/es/verdnatura/domain/GetQualityUserCase.kt @@ -1,10 +1,11 @@ package es.verdnatura.domain +import android.content.Context import es.verdnatura.presentation.view.feature.calidad.model.BuyerVO import es.verdnatura.presentation.view.feature.calidad.model.ItemBuyerVO import retrofit2.Call -class GetQualityUserCase() : RestClient() { +class GetQualityUserCase(context: Context) : RestClient(context) { fun itemShelvingBuyerGet(usuario:String,password:String) : Call> { return restClient!!.itemShelvingBuyerGet("json","1",usuario,password,"application/json") diff --git a/app/src/main/java/es/verdnatura/domain/GetSacadorControladorUserCase.kt b/app/src/main/java/es/verdnatura/domain/GetSacadorControladorUserCase.kt index 46881ff7..d603bbb2 100644 --- a/app/src/main/java/es/verdnatura/domain/GetSacadorControladorUserCase.kt +++ b/app/src/main/java/es/verdnatura/domain/GetSacadorControladorUserCase.kt @@ -1,12 +1,13 @@ package es.verdnatura.domain +import android.content.Context import es.verdnatura.presentation.view.feature.collection.ItemVO import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO import es.verdnatura.presentation.view.feature.sacador.model.MistakeTypeVO import es.verdnatura.presentation.view.feature.sacador.model.PlacementSupplyVO import retrofit2.Call -class GetSacadorControladorUserCase : RestClient() { +class GetSacadorControladorUserCase(context: Context) : RestClient(context) { fun collectionTicketGet(usuario:String,password:String,collectionFk:String,sectorFk:String,print:String) : Call { val params:ArrayList = ArrayList(); diff --git a/app/src/main/java/es/verdnatura/domain/GetShelvingParkingUserCase.kt b/app/src/main/java/es/verdnatura/domain/GetShelvingParkingUserCase.kt index cbbb9256..5e8d499e 100644 --- a/app/src/main/java/es/verdnatura/domain/GetShelvingParkingUserCase.kt +++ b/app/src/main/java/es/verdnatura/domain/GetShelvingParkingUserCase.kt @@ -1,9 +1,10 @@ package es.verdnatura.domain +import android.content.Context import es.verdnatura.presentation.view.feature.shelvingparking.model.ItemShelvingParkingVO import retrofit2.Call -class GetShelvingParkingUserCase : RestClient() { +class GetShelvingParkingUserCase(context: Context) : RestClient(context) { fun shelvingParking_get(usuario:String,password:String,vShelvingFk:String,vWarehouseFk:String,vDayRange:String) : Call> { val params:ArrayList = ArrayList(); diff --git a/app/src/main/java/es/verdnatura/domain/GetUbicadorUserCase.kt b/app/src/main/java/es/verdnatura/domain/GetUbicadorUserCase.kt index 11fc3818..e2565189 100644 --- a/app/src/main/java/es/verdnatura/domain/GetUbicadorUserCase.kt +++ b/app/src/main/java/es/verdnatura/domain/GetUbicadorUserCase.kt @@ -1,9 +1,10 @@ package es.verdnatura.domain +import android.content.Context import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicadorVO import retrofit2.Call -class GetUbicadorUserCase : RestClient() { +class GetUbicadorUserCase(context: Context) : RestClient(context) { fun itemShelvingList(usuario:String,password:String,vShelvingFk:String) : Call> { val params:ArrayList = ArrayList(); diff --git a/app/src/main/java/es/verdnatura/domain/RestClient.kt b/app/src/main/java/es/verdnatura/domain/RestClient.kt index 1c95a2f8..79c36af2 100644 --- a/app/src/main/java/es/verdnatura/domain/RestClient.kt +++ b/app/src/main/java/es/verdnatura/domain/RestClient.kt @@ -1,11 +1,13 @@ package es.verdnatura.domain -open class RestClient { +import android.content.Context + +open class RestClient(context:Context) { var restClient:VerdnaturaService? = null var salixClient:SalixService? = null init { - restClient = ApiUtils.getApiService() + restClient = ApiUtils.getApiService(context) salixClient = ApiSalixUtils.getApiService() } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/ajustes/fragment/AjustesFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/ajustes/fragment/AjustesFragment.kt index 32c172e3..87534f85 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/ajustes/fragment/AjustesFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/ajustes/fragment/AjustesFragment.kt @@ -1,8 +1,11 @@ package es.verdnatura.presentation.view.feature.ajustes.fragment import android.app.AlertDialog +import android.content.Context import android.content.SharedPreferences import android.os.Bundle +import android.preference.PreferenceManager +import android.view.KeyEvent import android.view.View import androidx.lifecycle.Observer import androidx.recyclerview.widget.LinearLayoutManager @@ -12,12 +15,15 @@ import es.verdnatura.domain.notNull import es.verdnatura.domain.toast import es.verdnatura.presentation.base.BaseFragment import es.verdnatura.presentation.common.OnAjustesItemClickListener +import es.verdnatura.presentation.common.hideKeyboard import es.verdnatura.presentation.view.component.CustomDialog import es.verdnatura.presentation.view.feature.ajustes.adapter.AjustesAdapter import es.verdnatura.presentation.view.feature.ajustes.model.AjustesItemVO import es.verdnatura.presentation.view.feature.ajustes.model.SectorItemVO import kotlinx.android.synthetic.main.activity_main.* import kotlinx.android.synthetic.main.fragment_ajustes.* +import kotlinx.android.synthetic.main.fragment_ajustes.splash_progress +import kotlinx.android.synthetic.main.fragment_login.* class AjustesFragment : BaseFragment(AjustesViewModel::class) { @@ -49,6 +55,19 @@ class AjustesFragment : BaseFragment(Aj item_version.setText(versionName) user = prefs!!.getString(USER,"") password = prefs!!.getString(PASSWORD,"") + + + txtserver.setText(this.getDefaults("base_url",this.requireContext())) + txtserver.setOnKeyListener(View.OnKeyListener { v, keyCode, event -> + if (keyCode == KeyEvent.KEYCODE_ENTER && event.action == KeyEvent.ACTION_UP) { + this.setDefaults("base_url",txtserver.text.toString(),this.requireContext()) + this.setDefaults("base_url", edittext_server.text.toString(), this.requireContext()) + this.hideKeyboard() + return@OnKeyListener false + } + false + }) + super.init() } @@ -167,6 +186,17 @@ class AjustesFragment : BaseFragment(Aj } + fun setDefaults(key: String?, value: String?, context: Context?) { + val preferences: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(context) + val editor = preferences.edit() + editor.putString(key, value) + editor.commit() + } + + fun getDefaults(key: String?, context: Context?): String? { + val preferences = PreferenceManager.getDefaultSharedPreferences(context) + return preferences.getString(key, null) + } } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/ajustes/fragment/AjustesViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/ajustes/fragment/AjustesViewModel.kt index 711db855..d595d1a8 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/ajustes/fragment/AjustesViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/ajustes/fragment/AjustesViewModel.kt @@ -1,6 +1,7 @@ package es.verdnatura.presentation.view.feature.ajustes.fragment +import android.content.Context import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.Transformations @@ -15,9 +16,9 @@ import retrofit2.Callback import retrofit2.Response -class AjustesViewModel : BaseViewModel() { +class AjustesViewModel(context: Context) : BaseViewModel() { - private val getAjustesUserCase:GetAjustesUserCase = GetAjustesUserCase() + private val getAjustesUserCase:GetAjustesUserCase = GetAjustesUserCase(context) val version : String = "5.0.0"; private val _ajustesitem by lazy { ArrayList() } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/fragment/ItemCardViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/fragment/ItemCardViewModel.kt index 33c5bbd2..91a5909a 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/fragment/ItemCardViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/fragment/ItemCardViewModel.kt @@ -1,6 +1,7 @@ package es.verdnatura.presentation.view.feature.articulo.fragment +import android.content.Context import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import es.verdnatura.domain.GetItemCardUserCase @@ -11,8 +12,8 @@ import retrofit2.Call import retrofit2.Callback import retrofit2.Response -class ItemCardViewModel : BaseViewModel() { - private val getItemCardUserCase:GetItemCardUserCase = GetItemCardUserCase() +class ItemCardViewModel(context: Context) : BaseViewModel() { + private val getItemCardUserCase:GetItemCardUserCase = GetItemCardUserCase(context) val version : String = "5.0.0"; private val _itemcard by lazy { MutableLiveData() } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/buscaritem/fragment/BuscarItemViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/buscaritem/fragment/BuscarItemViewModel.kt index fa396ac2..5446e2ae 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/buscaritem/fragment/BuscarItemViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/buscaritem/fragment/BuscarItemViewModel.kt @@ -1,5 +1,6 @@ package es.verdnatura.presentation.view.feature.buscaritem.fragment +import android.content.Context import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.Transformations @@ -12,8 +13,8 @@ import retrofit2.Call import retrofit2.Callback import retrofit2.Response -class BuscarItemViewModel : BaseViewModel() { - private val getBuscarItemUserCase: GetBuscarItemUserCase = GetBuscarItemUserCase() +class BuscarItemViewModel(context: Context) : BaseViewModel() { + private val getBuscarItemUserCase: GetBuscarItemUserCase = GetBuscarItemUserCase(context) private val _locationList by lazy { MutableLiveData() } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/calidad/fragment/BuyersViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/calidad/fragment/BuyersViewModel.kt index d1ae0db4..f35c48a2 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/calidad/fragment/BuyersViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/calidad/fragment/BuyersViewModel.kt @@ -1,5 +1,6 @@ package es.verdnatura.presentation.view.feature.calidad.fragment +import android.content.Context import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import es.verdnatura.domain.GetQualityUserCase @@ -12,9 +13,9 @@ import retrofit2.Call import retrofit2.Callback import retrofit2.Response -class BuyersViewModel : BaseViewModel() { +class BuyersViewModel(context: Context) : BaseViewModel() { - private val getQualityUserCase: GetQualityUserCase = GetQualityUserCase() + private val getQualityUserCase: GetQualityUserCase = GetQualityUserCase(context) private val _buyersList by lazy { MutableLiveData() } val buyersList: LiveData diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/calidad/fragment/QaualityViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/calidad/fragment/QaualityViewModel.kt index a86a866c..a29dcc76 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/calidad/fragment/QaualityViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/calidad/fragment/QaualityViewModel.kt @@ -1,5 +1,6 @@ package es.verdnatura.presentation.view.feature.calidad.fragment +import android.content.Context import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import es.verdnatura.domain.GetQualityUserCase @@ -13,9 +14,9 @@ import retrofit2.Call import retrofit2.Callback import retrofit2.Response -class QaualityViewModel : BaseViewModel() { +class QaualityViewModel(context: Context) : BaseViewModel() { - private val getQualityUserCase: GetQualityUserCase = GetQualityUserCase() + private val getQualityUserCase: GetQualityUserCase = GetQualityUserCase(context) private val _buyersList by lazy { MutableLiveData() } val buyersList: LiveData diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionViewModel.kt index 4d768b61..861a89d1 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionViewModel.kt @@ -1,5 +1,6 @@ package es.verdnatura.presentation.view.feature.collection.fragment +import android.content.Context import android.util.Log import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData @@ -15,13 +16,13 @@ import retrofit2.Call import retrofit2.Callback import retrofit2.Response -class CollectionViewModel : BaseViewModel() { +class CollectionViewModel(context: Context) : BaseViewModel() { val emptyMessage = "La colección no tiene tickets"; - private val getSacadorControladorUserCase: GetSacadorControladorUserCase = GetSacadorControladorUserCase() - private val getUbicadorUserCase: GetUbicadorUserCase = GetUbicadorUserCase() - private val getLoginUserCase: GetLoginUserCase = GetLoginUserCase() + private val getSacadorControladorUserCase: GetSacadorControladorUserCase = GetSacadorControladorUserCase(context) + private val getUbicadorUserCase: GetUbicadorUserCase = GetUbicadorUserCase(context) + private val getLoginUserCase: GetLoginUserCase = GetLoginUserCase(context) private val _collectionTicketList by lazy { MutableLiveData() } val collectionTicketList: LiveData diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/controlador/fragment/ControladorViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/controlador/fragment/ControladorViewModel.kt index 53ee7a7b..aed5770b 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/controlador/fragment/ControladorViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/controlador/fragment/ControladorViewModel.kt @@ -1,5 +1,6 @@ package es.verdnatura.presentation.view.feature.controlador.fragment +import android.content.Context import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import es.verdnatura.domain.GetSacadorControladorUserCase @@ -10,10 +11,10 @@ import retrofit2.Call import retrofit2.Callback import retrofit2.Response -class ControladorViewModel : BaseViewModel() { +class ControladorViewModel(context: Context) : BaseViewModel() { private val _collectionTicketList by lazy { MutableLiveData() } - private val getSacadorControladorUserCase: GetSacadorControladorUserCase = GetSacadorControladorUserCase() + private val getSacadorControladorUserCase: GetSacadorControladorUserCase = GetSacadorControladorUserCase(context) val collectionTicketList: LiveData get() = _collectionTicketList diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/faltas/fragment/FaltasViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/faltas/fragment/FaltasViewModel.kt index bc8e60de..a0206bd3 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/faltas/fragment/FaltasViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/faltas/fragment/FaltasViewModel.kt @@ -1,5 +1,6 @@ package es.verdnatura.presentation.view.feature.faltas.fragment +import android.content.Context import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.Transformations @@ -14,11 +15,11 @@ import retrofit2.Call import retrofit2.Callback import retrofit2.Response -class FaltasViewModel : BaseViewModel() { +class FaltasViewModel(context: Context) : BaseViewModel() { - private val getInventaryUserCase: GetInventaryUserCase = GetInventaryUserCase() - private val getItemCardUserCase: GetItemCardUserCase = GetItemCardUserCase() + private val getInventaryUserCase: GetInventaryUserCase = GetInventaryUserCase(context) + private val getItemCardUserCase: GetItemCardUserCase = GetItemCardUserCase(context) private val _faltasList by lazy { MutableLiveData() } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/historico/fragment/HistoricoViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/historico/fragment/HistoricoViewModel.kt index 4b7bdb8e..b945c868 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/historico/fragment/HistoricoViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/historico/fragment/HistoricoViewModel.kt @@ -1,5 +1,6 @@ package es.verdnatura.presentation.view.feature.historico.fragment +import android.content.Context import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.Transformations @@ -12,8 +13,8 @@ import retrofit2.Call import retrofit2.Callback import retrofit2.Response -class HistoricoViewModel : BaseViewModel() { - private val getItemCardUserCase: GetItemCardUserCase = GetItemCardUserCase() +class HistoricoViewModel(context: Context) : BaseViewModel() { + private val getItemCardUserCase: GetItemCardUserCase = GetItemCardUserCase(context) diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/inventario/fragment/InventaryViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/inventario/fragment/InventaryViewModel.kt index f2df56e8..d5c1db6e 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/inventario/fragment/InventaryViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/inventario/fragment/InventaryViewModel.kt @@ -1,5 +1,6 @@ package es.verdnatura.presentation.view.feature.inventario.fragment +import android.content.Context import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.Transformations @@ -14,11 +15,11 @@ import retrofit2.Call import retrofit2.Callback import retrofit2.Response -class InventaryViewModel : BaseViewModel() { +class InventaryViewModel(context: Context) : BaseViewModel() { - private val getInventaryUserCase: GetInventaryUserCase = GetInventaryUserCase() - private val getItemCardUserCase: GetItemCardUserCase = GetItemCardUserCase() + private val getInventaryUserCase: GetInventaryUserCase = GetInventaryUserCase(context) + private val getItemCardUserCase: GetItemCardUserCase = GetItemCardUserCase(context) private val _inventaryList by lazy { MutableLiveData() } val inventaryList: LiveData diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/login/fragment/LoginFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/login/fragment/LoginFragment.kt index ab6e7406..586e68e3 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/login/fragment/LoginFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/login/fragment/LoginFragment.kt @@ -1,20 +1,30 @@ package es.verdnatura.presentation.view.feature.login.fragment +import android.app.AlarmManager +import android.app.PendingIntent +import android.content.Context import android.content.Intent import android.content.SharedPreferences import android.net.Uri +import android.preference.PreferenceManager +import android.view.KeyEvent import android.view.View import androidx.lifecycle.Observer import es.verdnatura.R import es.verdnatura.databinding.FragmentLoginBinding import es.verdnatura.presentation.base.BaseFragment +import es.verdnatura.presentation.common.hideKeyboard import es.verdnatura.presentation.view.component.CustomDialog +import es.verdnatura.presentation.view.feature.login.activity.LoginActivity import es.verdnatura.presentation.view.feature.login.model.LoginItemVO import es.verdnatura.presentation.view.feature.main.activity.MainActivity +import kotlinx.android.synthetic.main.fragment_ajustes.* import kotlinx.android.synthetic.main.fragment_login.* +import kotlinx.android.synthetic.main.fragment_login.splash_progress -class LoginFragment : BaseFragment (LoginViewModel::class) { + +class LoginFragment : BaseFragment(LoginViewModel::class) { private lateinit var customDialog: CustomDialog companion object { @@ -28,7 +38,7 @@ class LoginFragment : BaseFragment (LoginVi checkUser() button_login.setOnClickListener(View.OnClickListener { splash_progress.visibility = View.VISIBLE - viewModel.login(edittext_username.text.toString(),edittext_password.text.toString()) + viewModel.login(edittext_username.text.toString(), edittext_password.text.toString()) }) textview_remember_password.setOnClickListener { @@ -38,13 +48,26 @@ class LoginFragment : BaseFragment (LoginVi saveRemember(false) } + + + edittext_server.setText(this.getDefaults("base_url", this.requireContext())) + edittext_server.setOnKeyListener(View.OnKeyListener { v, keyCode, event -> + if (keyCode == KeyEvent.KEYCODE_ENTER && event.action == KeyEvent.ACTION_UP) { + this.setDefaults("base_url", edittext_server.text.toString(), this.requireContext()) + this.hideKeyboard() + restartapp() + return@OnKeyListener false + } + false + }) + } private fun checkUser(){ - val prefs: SharedPreferences = activity!!.getSharedPreferences(PREFS_USER,0) - if (prefs.getBoolean(RECORDAR,false)){ - edittext_username.setText(prefs.getString(USER,"")) - edittext_password.setText(prefs.getString(PASSWORD,"")) + val prefs: SharedPreferences = activity!!.getSharedPreferences(PREFS_USER, 0) + if (prefs.getBoolean(RECORDAR, false)){ + edittext_username.setText(prefs.getString(USER, "")) + edittext_password.setText(prefs.getString(PASSWORD, "")) if (edittext_password.text.toString().isNotEmpty()){ switch_remember.isChecked = true } @@ -56,33 +79,44 @@ class LoginFragment : BaseFragment (LoginVi with(viewModel){ loginitem.observe(viewLifecycleOwner, Observer { splash_progress.visibility = View.INVISIBLE - if (it.isError){ - customDialog.setTitle("Error").setDescription(it.errorMessage).setOkButton("Cerrar"){ - customDialog.dismiss() - }.show() - }else{ + if (it.isError) { + customDialog.setTitle("Error").setDescription(it.errorMessage) + .setOkButton("Cerrar") { + customDialog.dismiss() + }.show() + } else { splash_progress.visibility = View.VISIBLE saveUserFkPref(it) if (switch_remember.isChecked) { saveRemember(true) - }else{ + } else { saveRemember(false) } - saveUserAccesPref(edittext_username.text.toString(),edittext_password.text.toString()) - loginSalix(user = edittext_username.text.toString(),password = edittext_password.text.toString()) + saveUserAccesPref( + edittext_username.text.toString(), + edittext_password.text.toString() + ) + loginSalix( + user = edittext_username.text.toString(), + password = edittext_password.text.toString() + ) } }) loginsalixitem.observe(viewLifecycleOwner, Observer { splash_progress.visibility = View.INVISIBLE - if (it.isError){ + if (it.isError) { saveTokenPref("") - customDialog.setTitle("Error").setDescription(it.errorMessage+". Puedes continuar pero algunas funcionalidades no estarán disponibles.").setOkButton("Entendido"){ - customDialog.dismiss() - getVersion() - }.show() - }else{ + customDialog.setTitle("Error") + .setDescription(it.errorMessage + ". Puedes continuar pero algunas funcionalidades no estarán disponibles.") + .setOkButton( + "Entendido" + ) { + customDialog.dismiss() + getVersion() + }.show() + } else { saveTokenPref(it.token) getVersion() } @@ -90,8 +124,8 @@ class LoginFragment : BaseFragment (LoginVi version.observe(viewLifecycleOwner, Observer { splash_progress.visibility = View.INVISIBLE - if (it){ - /* customDialog.setTitle("Atención").setDescription("La aplicación se encuentra en fase de desarrollo. Algunas funcionalidades están desactivadas y se van a ir añadiendo de forma progresiva.").setOkButton("Entrar"){ + if (it) { + /* customDialog.setTitle("Atención").setDescription("La aplicación se encuentra en fase de desarrollo. Algunas funcionalidades están desactivadas y se van a ir añadiendo de forma progresiva.").setOkButton("Entrar"){ goToMain() customDialog.dismiss() }.setKoButton("Cancelar"){ @@ -99,12 +133,17 @@ class LoginFragment : BaseFragment (LoginVi }.show()*/ goToMain() - }else{ - customDialog.setTitle(getString(R.string.Actualizar)).setDescription(getString(R.string.updatemng)).setOkButton(getString(R.string.Actualizar)){ + } else { + customDialog.setTitle(getString(R.string.Actualizar)) + .setDescription(getString(R.string.updatemng)).setOkButton( + getString( + R.string.Actualizar + ) + ) { val openURL = Intent(Intent.ACTION_VIEW) openURL.data = Uri.parse("https://app.verdnatura.es/bin/vn-picking.apk") startActivity(openURL) - }.setKoButton("Cancelar"){ + }.setKoButton("Cancelar") { customDialog.dismiss() goToMain() }.show() @@ -114,44 +153,74 @@ class LoginFragment : BaseFragment (LoginVi super.observeViewModel() } - private fun saveTokenPref(token:String){ - val prefs: SharedPreferences = activity!!.getSharedPreferences(PREFS_USER,0) + private fun saveTokenPref(token: String){ + val prefs: SharedPreferences = activity!!.getSharedPreferences(PREFS_USER, 0) val editor = prefs.edit() - editor.putString(TOKEN,token) + editor.putString(TOKEN, token) editor.apply() } - private fun saveUserFkPref(loginitem : LoginItemVO){ - val prefs: SharedPreferences = activity!!.getSharedPreferences(PREFS_USER,0) + private fun saveUserFkPref(loginitem: LoginItemVO){ + val prefs: SharedPreferences = activity!!.getSharedPreferences(PREFS_USER, 0) val editor = prefs.edit() - editor.putString(USERFK,loginitem.id) + editor.putString(USERFK, loginitem.id) editor.apply() } - private fun saveUserAccesPref(user:String,password:String){ - val prefs: SharedPreferences = activity!!.getSharedPreferences(PREFS_USER,0) + private fun saveUserAccesPref(user: String, password: String){ + val prefs: SharedPreferences = activity!!.getSharedPreferences(PREFS_USER, 0) val editor = prefs.edit() - editor.putString(USER,user) - editor.putString(PASSWORD,password) + editor.putString(USER, user) + editor.putString(PASSWORD, password) editor.apply() } - private fun saveRemember(remember:Boolean){ - val prefs: SharedPreferences = activity!!.getSharedPreferences(PREFS_USER,0) + private fun saveRemember(remember: Boolean){ + val prefs: SharedPreferences = activity!!.getSharedPreferences(PREFS_USER, 0) val editor = prefs.edit() - editor.putBoolean(RECORDAR,remember) + editor.putBoolean(RECORDAR, remember) editor.apply() } private fun goToMain(){ - val intent = Intent(activity,MainActivity::class.java) + val intent = Intent(activity, MainActivity::class.java) startActivity(intent) } private fun getVersion(){ - val versionName = activity!!.packageManager.getPackageInfo(activity!!.packageName,0).versionName + val versionName = activity!!.packageManager.getPackageInfo(activity!!.packageName, 0).versionName splash_progress.visibility = View.VISIBLE - viewModel.checkVersion(user = edittext_username.text.toString(),password = edittext_password.text.toString(),version = versionName) + viewModel.checkVersion( + user = edittext_username.text.toString(), + password = edittext_password.text.toString(), + version = versionName + ) + } + + fun setDefaults(key: String?, value: String?, context: Context?) { + val preferences: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(context) + val editor = preferences.edit() + editor.putString(key, value) + editor.commit() + } + + fun getDefaults(key: String?, context: Context?): String? { + val preferences = PreferenceManager.getDefaultSharedPreferences(context) + return preferences.getString(key, null) + } + + fun restartapp(){ + val mStartActivity = Intent(context, LoginActivity::class.java) + val mPendingIntentId = 123456 + val mPendingIntent = PendingIntent.getActivity( + context, + mPendingIntentId, + mStartActivity, + PendingIntent.FLAG_CANCEL_CURRENT + ) + val mgr = context!!.getSystemService(Context.ALARM_SERVICE) as AlarmManager + mgr[AlarmManager.RTC, System.currentTimeMillis() + 100] = mPendingIntent + System.exit(0) } } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/login/fragment/LoginViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/login/fragment/LoginViewModel.kt index e7ee2363..437bfbe4 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/login/fragment/LoginViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/login/fragment/LoginViewModel.kt @@ -1,5 +1,6 @@ package es.verdnatura.presentation.view.feature.login.fragment +import android.content.Context import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import es.verdnatura.domain.GetLoginUserCase @@ -10,9 +11,9 @@ import retrofit2.Call import retrofit2.Callback import retrofit2.Response -class LoginViewModel() : BaseViewModel() { +class LoginViewModel(context: Context) : BaseViewModel() { - private val getLoginUserCase: GetLoginUserCase = GetLoginUserCase() + private val getLoginUserCase: GetLoginUserCase = GetLoginUserCase(context) private val _loginitem by lazy { MutableLiveData ()} diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionPalletDetailViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionPalletDetailViewModel.kt index 0068dbb5..5d618926 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionPalletDetailViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionPalletDetailViewModel.kt @@ -1,5 +1,6 @@ package es.verdnatura.presentation.view.feature.paletizador.fragment +import android.content.Context import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.Transformations @@ -13,9 +14,9 @@ import retrofit2.Call import retrofit2.Callback import retrofit2.Response -class ExpeditionPalletDetailViewModel: BaseViewModel() { +class ExpeditionPalletDetailViewModel(context: Context): BaseViewModel() { - private val getPaletizadoresUserCase: GetPaletizadoresUserCase = GetPaletizadoresUserCase() + private val getPaletizadoresUserCase: GetPaletizadoresUserCase = GetPaletizadoresUserCase(context) private val _expeditionPalletList by lazy { MutableLiveData() } val loadExpeditionPalletList = Transformations.map(_expeditionPalletList) { Event(it) } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionPalletViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionPalletViewModel.kt index 3e3fc8a9..f7584c15 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionPalletViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionPalletViewModel.kt @@ -1,5 +1,6 @@ package es.verdnatura.presentation.view.feature.paletizador.fragment +import android.content.Context import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.Transformations @@ -15,9 +16,9 @@ import retrofit2.Call import retrofit2.Callback import retrofit2.Response -class ExpeditionPalletViewModel : BaseViewModel() { +class ExpeditionPalletViewModel (context: Context) : BaseViewModel() { - private val getPaletizadoresUserCase: GetPaletizadoresUserCase = GetPaletizadoresUserCase() + private val getPaletizadoresUserCase: GetPaletizadoresUserCase = GetPaletizadoresUserCase(context) private val _expeditionPalletList by lazy { MutableLiveData() } val loadExpeditionPalletList = Transformations.map(_expeditionPalletList) { Event(it) } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionScanViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionScanViewModel.kt index dd97632d..41663d0e 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionScanViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionScanViewModel.kt @@ -1,5 +1,6 @@ package es.verdnatura.presentation.view.feature.paletizador.fragment +import android.content.Context import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.Transformations @@ -15,9 +16,9 @@ import retrofit2.Call import retrofit2.Callback import retrofit2.Response -class ExpeditionScanViewModel : BaseViewModel() { +class ExpeditionScanViewModel(context: Context) : BaseViewModel() { - private val getPaletizadoresUserCase: GetPaletizadoresUserCase = GetPaletizadoresUserCase() + private val getPaletizadoresUserCase: GetPaletizadoresUserCase = GetPaletizadoresUserCase(context) private val _expeditionScanList by lazy { MutableLiveData() } val loadExpeditionScanList = Transformations.map(_expeditionScanList) { Event(it) } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionTruckListViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionTruckListViewModel.kt index 9192e478..3c8955c5 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionTruckListViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/paletizador/fragment/ExpeditionTruckListViewModel.kt @@ -1,6 +1,7 @@ package es.verdnatura.presentation.view.feature.paletizador.fragment +import android.content.Context import androidx.lifecycle.MutableLiveData import androidx.lifecycle.Transformations import es.verdnatura.domain.GetPaletizadoresUserCase @@ -13,9 +14,9 @@ import retrofit2.Call import retrofit2.Callback import retrofit2.Response -class ExpeditionTruckListViewModel : BaseViewModel() { +class ExpeditionTruckListViewModel(context: Context) : BaseViewModel() { - private val getPaletizadoresUserCase: GetPaletizadoresUserCase = GetPaletizadoresUserCase() + private val getPaletizadoresUserCase: GetPaletizadoresUserCase = GetPaletizadoresUserCase(context) private val _expeditionTruckList by lazy { MutableLiveData() } val loadExpeditionTruckList = Transformations.map(_expeditionTruckList) { Event(it) } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/parking/fragment/ParkingViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/parking/fragment/ParkingViewModel.kt index 4f8f8d8e..b6a6bfe2 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/parking/fragment/ParkingViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/parking/fragment/ParkingViewModel.kt @@ -1,5 +1,6 @@ package es.verdnatura.presentation.view.feature.parking.fragment +import android.content.Context import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import es.verdnatura.domain.GetUbicadorUserCase @@ -9,8 +10,8 @@ import retrofit2.Call import retrofit2.Callback import retrofit2.Response -class ParkingViewModel : BaseViewModel() { - private val getUbicadorUserCase: GetUbicadorUserCase = GetUbicadorUserCase() +class ParkingViewModel(context: Context) : BaseViewModel() { + private val getUbicadorUserCase: GetUbicadorUserCase = GetUbicadorUserCase(context) private val _response by lazy { MutableLiveData() } val response: LiveData diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/pasillero/fragment/PasilleroViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/pasillero/fragment/PasilleroViewModel.kt index ae94169a..1d71bce0 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/pasillero/fragment/PasilleroViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/pasillero/fragment/PasilleroViewModel.kt @@ -1,11 +1,12 @@ package es.verdnatura.presentation.view.feature.pasillero.fragment +import android.content.Context import es.verdnatura.R import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO -class PasilleroViewModel : BaseViewModel() { +class PasilleroViewModel(context: Context) : BaseViewModel() { private val _pasillerositem by lazy { ArrayList() } val pasillerositem: List get() = _pasillerositem diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/presacador/fragment/PreSacadorViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/presacador/fragment/PreSacadorViewModel.kt index d04d7671..f08c51ff 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/presacador/fragment/PreSacadorViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/presacador/fragment/PreSacadorViewModel.kt @@ -1,5 +1,6 @@ package es.verdnatura.presentation.view.feature.presacador.fragment +import android.content.Context import android.util.Log import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData @@ -16,11 +17,11 @@ import retrofit2.Call import retrofit2.Callback import retrofit2.Response -class PreSacadorViewModel : BaseViewModel() { - private val getPreSacadorUseCase: GetPreSacadorUseCase = GetPreSacadorUseCase() - private val getSacadorControladorUserCase: GetSacadorControladorUserCase = GetSacadorControladorUserCase() - private val getUbicadorUserCase: GetUbicadorUserCase = GetUbicadorUserCase() - private val getLoginUserCase: GetLoginUserCase = GetLoginUserCase() +class PreSacadorViewModel (context: Context): BaseViewModel() { + private val getPreSacadorUseCase: GetPreSacadorUseCase = GetPreSacadorUseCase(context) + private val getSacadorControladorUserCase: GetSacadorControladorUserCase = GetSacadorControladorUserCase(context) + private val getUbicadorUserCase: GetUbicadorUserCase = GetUbicadorUserCase(context) + private val getLoginUserCase: GetLoginUserCase = GetLoginUserCase(context) private val _salesList by lazy { MutableLiveData>() } val salesList: LiveData> diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/reposicion/fragment/ReposicionViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/reposicion/fragment/ReposicionViewModel.kt index b671a06a..e1aea6d2 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/reposicion/fragment/ReposicionViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/reposicion/fragment/ReposicionViewModel.kt @@ -1,5 +1,6 @@ package es.verdnatura.presentation.view.feature.reposicion.fragment +import android.content.Context import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import es.verdnatura.domain.GetPreSacadorUseCase @@ -14,10 +15,10 @@ import retrofit2.Call import retrofit2.Callback import retrofit2.Response -class ReposicionViewModel : BaseViewModel() { - private val getPreSacadorUseCase: GetPreSacadorUseCase = GetPreSacadorUseCase() - private val getUbicadorUserCase: GetUbicadorUserCase = GetUbicadorUserCase() - private val getSacadorControladorUserCase: GetSacadorControladorUserCase = GetSacadorControladorUserCase() +class ReposicionViewModel(context: Context) : BaseViewModel() { + private val getPreSacadorUseCase: GetPreSacadorUseCase = GetPreSacadorUseCase(context) + private val getUbicadorUserCase: GetUbicadorUserCase = GetUbicadorUserCase(context) + private val getSacadorControladorUserCase: GetSacadorControladorUserCase = GetSacadorControladorUserCase(context) private val _salesList by lazy { MutableLiveData>() } val salesList: LiveData> diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/fragment/SacadorViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/fragment/SacadorViewModel.kt index 0a8ded89..0f9605cc 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/fragment/SacadorViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/fragment/SacadorViewModel.kt @@ -1,6 +1,7 @@ package es.verdnatura.presentation.view.feature.sacador.fragment +import android.content.Context import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import es.verdnatura.domain.GetSacadorControladorUserCase @@ -14,11 +15,11 @@ import retrofit2.Call import retrofit2.Callback import retrofit2.Response -class SacadorViewModel : BaseViewModel() { +class SacadorViewModel(context: Context) : BaseViewModel() { val emptyMessage = "No tienes colecciones pendientes. Presiona sobre el + para crear colección"; - private val getSacadorControladorUserCase: GetSacadorControladorUserCase = GetSacadorControladorUserCase() + private val getSacadorControladorUserCase: GetSacadorControladorUserCase = GetSacadorControladorUserCase(context) private val _collectionList by lazy { MutableLiveData() } val collectionList: LiveData diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/shelvingparking/fragment/ShelvingParkingViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/shelvingparking/fragment/ShelvingParkingViewModel.kt index e6ae371c..a0275501 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/shelvingparking/fragment/ShelvingParkingViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/shelvingparking/fragment/ShelvingParkingViewModel.kt @@ -1,5 +1,6 @@ package es.verdnatura.presentation.view.feature.shelvingparking.fragment +import android.content.Context import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.Transformations @@ -12,10 +13,10 @@ import retrofit2.Call import retrofit2.Callback import retrofit2.Response -class ShelvingParkingViewModel : BaseViewModel() { +class ShelvingParkingViewModel(context: Context) : BaseViewModel() { - private val getShelvingParkingUserCase: GetShelvingParkingUserCase = GetShelvingParkingUserCase() + private val getShelvingParkingUserCase: GetShelvingParkingUserCase = GetShelvingParkingUserCase(context) diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/transferencia/fragment/TransferenciaViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/transferencia/fragment/TransferenciaViewModel.kt index 53861a54..1ffc688a 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/transferencia/fragment/TransferenciaViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/transferencia/fragment/TransferenciaViewModel.kt @@ -1,5 +1,6 @@ package es.verdnatura.presentation.view.feature.transferencia.fragment +import android.content.Context import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import es.verdnatura.domain.GetUbicadorUserCase @@ -9,9 +10,9 @@ import retrofit2.Call import retrofit2.Callback import retrofit2.Response -class TransferenciaViewModel : BaseViewModel() { +class TransferenciaViewModel(context: Context) : BaseViewModel() { - private val getUbicadorUserCase: GetUbicadorUserCase = GetUbicadorUserCase() + private val getUbicadorUserCase: GetUbicadorUserCase = GetUbicadorUserCase(context) private val _response by lazy { MutableLiveData() } val response: LiveData diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/AutomaticAddItemViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/AutomaticAddItemViewModel.kt index f13a1879..06455888 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/AutomaticAddItemViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/AutomaticAddItemViewModel.kt @@ -1,5 +1,6 @@ package es.verdnatura.presentation.view.feature.ubicador.fragment +import android.content.Context import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import es.verdnatura.domain.GetUbicadorUserCase @@ -9,10 +10,10 @@ import retrofit2.Call import retrofit2.Callback import retrofit2.Response -class AutomaticAddItemViewModel : BaseViewModel() { +class AutomaticAddItemViewModel (context: Context): BaseViewModel() { - private val getUbicadorUserCase: GetUbicadorUserCase = GetUbicadorUserCase() + private val getUbicadorUserCase: GetUbicadorUserCase = GetUbicadorUserCase(context) private val _response by lazy { MutableLiveData() } val response: LiveData get() = _response diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorViewModel.kt index 238b72cf..32e8f039 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/ubicador/fragment/UbicadorViewModel.kt @@ -1,5 +1,6 @@ package es.verdnatura.presentation.view.feature.ubicador.fragment +import android.content.Context import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.Transformations @@ -13,10 +14,10 @@ import retrofit2.Call import retrofit2.Callback import retrofit2.Response -class UbicadorViewModel : BaseViewModel() { +class UbicadorViewModel(context: Context) : BaseViewModel() { - private val getUbicadorUserCase: GetUbicadorUserCase = GetUbicadorUserCase() + private val getUbicadorUserCase: GetUbicadorUserCase = GetUbicadorUserCase(context) private val _shelvingList by lazy { MutableLiveData() } diff --git a/app/src/main/res/layout/fragment_ajustes.xml b/app/src/main/res/layout/fragment_ajustes.xml index a8611206..8a830d80 100644 --- a/app/src/main/res/layout/fragment_ajustes.xml +++ b/app/src/main/res/layout/fragment_ajustes.xml @@ -75,6 +75,38 @@ + + + + + + + + + + + diff --git a/app/src/main/res/layout/fragment_login.xml b/app/src/main/res/layout/fragment_login.xml index b4fb65a7..6776d085 100644 --- a/app/src/main/res/layout/fragment_login.xml +++ b/app/src/main/res/layout/fragment_login.xml @@ -35,25 +35,48 @@ android:layout_marginTop="16dp" android:text="@string/Bienvenido" android:textColor="@android:color/white" - android:textSize="@dimen/h3" + android:textSize="14dp" android:textStyle="bold" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> + + + + + +