app version server

This commit is contained in:
Enrique Blasco 2021-03-12 07:58:09 +01:00
parent 706c477ace
commit 1188636818
43 changed files with 362 additions and 142 deletions

View File

@ -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"
}

View File

@ -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())
}
}

View File

@ -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)
}
}
}

View File

@ -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<List<SectorItemVO>> {
return restClient!!.getSectors("json","1",usuario,password,"application/json")

View File

@ -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<List<ItemLocationVO>> {
val params:ArrayList<String> = ArrayList();

View File

@ -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<List<ItemInventaryVO>> {
val params:ArrayList<String> = ArrayList();

View File

@ -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<ItemCardVO> {
val params:ArrayList<String> = ArrayList();

View File

@ -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<String>{
val params:ArrayList<String> = ArrayList();

View File

@ -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<List<ItemExpeditionTruckVO>> {
val params:ArrayList<String> = ArrayList();

View File

@ -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<List<PreSacadorItemVO>> {
val params:ArrayList<String> = ArrayList();

View File

@ -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<List<BuyerVO>> {
return restClient!!.itemShelvingBuyerGet("json","1",usuario,password,"application/json")

View File

@ -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<CollectionVO> {
val params:ArrayList<String> = ArrayList();

View File

@ -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<List<ItemShelvingParkingVO>> {
val params:ArrayList<String> = ArrayList();

View File

@ -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<List<ItemUbicadorVO>> {
val params:ArrayList<String> = ArrayList();

View File

@ -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()
}

View File

@ -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<FragmentAjustesBinding,AjustesViewModel>(AjustesViewModel::class) {
@ -49,6 +55,19 @@ class AjustesFragment : BaseFragment<FragmentAjustesBinding,AjustesViewModel>(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<FragmentAjustesBinding,AjustesViewModel>(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)
}
}

View File

@ -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<AjustesItemVO>() }

View File

@ -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<ItemCardVO>() }

View File

@ -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<LocationListVO>() }

View File

@ -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<BuyerListVO>() }
val buyersList: LiveData<BuyerListVO>

View File

@ -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<ItemBuyerListVO>() }
val buyersList: LiveData<ItemBuyerListVO>

View File

@ -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<CollectionVO>() }
val collectionTicketList: LiveData<CollectionVO>

View File

@ -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<CollectionVO>() }
private val getSacadorControladorUserCase: GetSacadorControladorUserCase = GetSacadorControladorUserCase()
private val getSacadorControladorUserCase: GetSacadorControladorUserCase = GetSacadorControladorUserCase(context)
val collectionTicketList: LiveData<CollectionVO>
get() = _collectionTicketList

View File

@ -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<ItemFaltasListVO>() }

View File

@ -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)

View File

@ -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<InventaryListVO>() }
val inventaryList: LiveData<InventaryListVO>

View File

@ -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<FragmentLoginBinding,LoginViewModel> (LoginViewModel::class) {
class LoginFragment : BaseFragment<FragmentLoginBinding, LoginViewModel>(LoginViewModel::class) {
private lateinit var customDialog: CustomDialog
companion object {
@ -28,7 +38,7 @@ class LoginFragment : BaseFragment<FragmentLoginBinding,LoginViewModel> (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<FragmentLoginBinding,LoginViewModel> (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<FragmentLoginBinding,LoginViewModel> (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<FragmentLoginBinding,LoginViewModel> (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<FragmentLoginBinding,LoginViewModel> (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<FragmentLoginBinding,LoginViewModel> (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)
}
}

View File

@ -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<LoginItemVO> ()}

View File

@ -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<ItemPalletViewListVO>() }
val loadExpeditionPalletList = Transformations.map(_expeditionPalletList) { Event(it) }

View File

@ -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<ItemPalletListVO>() }
val loadExpeditionPalletList = Transformations.map(_expeditionPalletList) { Event(it) }

View File

@ -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<ItemExpeditionScanList>() }
val loadExpeditionScanList = Transformations.map(_expeditionScanList) { Event(it) }

View File

@ -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<ItemExpeditionTruckList>() }
val loadExpeditionTruckList = Transformations.map(_expeditionTruckList) { Event(it) }

View File

@ -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<ResponseItemVO>() }
val response: LiveData<ResponseItemVO>

View File

@ -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<PasillerosItemVO>() }
val pasillerositem: List<PasillerosItemVO>
get() = _pasillerositem

View File

@ -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<List<PreSacadorItemVO>>() }
val salesList: LiveData<List<PreSacadorItemVO>>

View File

@ -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<List<PreSacadorItemVO>>() }
val salesList: LiveData<List<PreSacadorItemVO>>

View File

@ -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<CollectionListVO>() }
val collectionList: LiveData<CollectionListVO>

View File

@ -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)

View File

@ -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<ResponseItemVO>() }
val response: LiveData<ResponseItemVO>

View File

@ -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<ResponseItemVO>() }
val response: LiveData<ResponseItemVO>
get() = _response

View File

@ -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<ItemUbicadorListVO>() }

View File

@ -75,6 +75,38 @@
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Server:"
android:textColor="@color/verdnatura_white"
android:textSize="@dimen/body1"
android:textStyle="bold"
android:layout_marginRight="@dimen/default_layout_margin"/>
<EditText
android:id="@+id/txtserver"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@color/verdnatura_white"
android:padding="5dp"
android:ems="10"
android:inputType="text"
android:layout_marginTop="4dp"/>
</LinearLayout>
</LinearLayout>

View File

@ -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" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/textinputlayout_username"
android:id="@+id/textinputlayout_server"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginTop="0dp"
android:textColorHint="@android:color/darker_gray"
app:layout_constraintStart_toStartOf="@id/textview_welcome"
app:layout_constraintTop_toBottomOf="@id/textview_welcome">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/edittext_server"
style="@style/InputLineText"
android:layout_width="match_parent"
android:layout_margin="8dp"
android:backgroundTint="@android:color/white"
android:hint="Server:"
android:inputType="text"
android:lines="1"
android:maxLines="1"
android:textColor="@color/verdnatura_white"
android:textColorHint="@android:color/darker_gray" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/textinputlayout_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="0dp"
android:textColorHint="@android:color/darker_gray"
app:layout_constraintStart_toStartOf="@id/textinputlayout_server"
app:layout_constraintTop_toBottomOf="@id/textinputlayout_server">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/edittext_username"
style="@style/InputLineText"
android:layout_width="match_parent"
android:layout_margin="@dimen/default_layout_margin"
android:layout_margin="8dp"
android:backgroundTint="@android:color/white"
android:hint="@string/Usuario"
android:inputType="text"
@ -79,7 +102,7 @@
android:id="@+id/edittext_password"
style="@style/InputLineText"
android:layout_width="match_parent"
android:layout_margin="@dimen/default_layout_margin"
android:layout_margin="8dp"
android:backgroundTint="@android:color/white"
android:gravity="center_vertical"
android:hint="Password"
@ -91,6 +114,7 @@
</com.google.android.material.textfield.TextInputLayout>
<TextView
android:id="@+id/textview_remember_user"
android:layout_width="0dp"