refs #6188 feat:UI changes

This commit is contained in:
Sergio De la torre 2024-02-21 12:45:37 +01:00
parent 9cda22a4d9
commit 131dd2421b
9 changed files with 287 additions and 170 deletions

View File

@ -55,8 +55,9 @@ object ConstAndValues {
const val BASE_URL_SALIX = "https://salix.verdnatura.es"
const val BASE_URL = "https://app.verdnatura.es"
const val ENTRY = "ENTRY"
const val RENEWINTERVAL="renewInterval"
const val RENEWPERIOD="renewPeriod"
const val RENEWINTERVAL = "renewInterval"
const val RENEWPERIOD = "renewPeriod"
const val MENUBYDEFAULTSELECTED = "MENUBYDEFAULTSELECTED"
}

View File

@ -1,18 +1,15 @@
package es.verdnatura.presentation.view.feature.ajustes.adapter
import android.content.Context
import android.content.res.Resources
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.content.ContextCompat
import androidx.core.content.res.ResourcesCompat.getColor
import androidx.recyclerview.widget.RecyclerView
import es.verdnatura.R
import es.verdnatura.databinding.ItemAjustesRowBinding
import es.verdnatura.presentation.common.OnAjustesItemClickListener
import es.verdnatura.presentation.view.feature.ajustes.model.AjustesItemVO
import java.security.AccessController.getContext
class AjustesAdapter (
private val items: List<AjustesItemVO>,

View File

@ -14,6 +14,7 @@ import es.verdnatura.R
import es.verdnatura.databinding.FragmentAjustesBinding
import es.verdnatura.domain.ConstAndValues.ANDROID_ID
import es.verdnatura.domain.ConstAndValues.ITEMPACKING
import es.verdnatura.domain.ConstAndValues.MENUBYDEFAULTSELECTED
import es.verdnatura.domain.ConstAndValues.NUMBEROFWAGONS
import es.verdnatura.domain.ConstAndValues.PRINTERFK
import es.verdnatura.domain.ConstAndValues.PRINTERNAME
@ -36,6 +37,7 @@ import es.verdnatura.presentation.view.feature.ajustes.model.SectorItemVO
import es.verdnatura.presentation.view.feature.ajustes.model.Train
import es.verdnatura.presentation.view.feature.articulo.model.ItemPackingType
import es.verdnatura.presentation.view.feature.login.fragment.LoginViewModel
import es.verdnatura.presentation.view.feature.pasillero.fragment.PasilleroViewModel
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
@ -54,6 +56,7 @@ class AjustesFragment :
private var itemPackingList: List<ItemPackingType> = listOf()
private var messagePrinter: String? = null
private lateinit var loginViewModel: LoginViewModel
private lateinit var pasilleroViewModel: PasilleroViewModel
//añadido
private var wagonList: List<String> = listOf()
@ -153,7 +156,10 @@ class AjustesFragment :
viewModel.train_get()
} else if (item.id == 7) {
viewModel.getItemPackingTypeSalix()
} else if (item.title == getString(R.string.menuByDefault)) {
showMenuByDefault()
}
}
}
@ -212,8 +218,8 @@ class AjustesFragment :
)
}
binding.ajustessItems.adapter = ajustesAdapter
binding.ajustessItems.layoutManager =
binding.setttingsItems.adapter = ajustesAdapter
binding.setttingsItems.layoutManager =
LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
loadSectorList.observe(viewLifecycleOwner) { event ->
@ -343,6 +349,44 @@ class AjustesFragment :
super.observeViewModel()
}
private fun showMenuByDefault() {
pasilleroViewModel = PasilleroViewModel(mobileApplication)
pasilleroViewModel!!.inititializeDefaultDataInit()
var arrayList: ArrayList<String> = arrayListOf()
pasilleroViewModel!!.pasillerositem.forEach {
arrayList.add(it.title)
}
arrayList.add(getString(R.string.all))
arrayList.sorted()
val builder = AlertDialog.Builder(this.context)
builder.setTitle(getString(R.string.menuByDefault))
builder.setItems((arrayList).toTypedArray()) { _, which ->
val selected = arrayList[which]
arrayList.forEach {
if (it == selected) {
runBlocking {
mobileApplication.dataStoreApp.editDataStoreKey(
MENUBYDEFAULTSELECTED, if (it != getString(R.string.all)) {
it
} else {
""
}
)
}
viewModel.ajustesitem[6].selected = it
ajustesAdapter!!.notifyDataSetChanged()
return@forEach
}
}
}
val dialog = builder.create()
dialog.show()
}
private fun setSettings(actionIsAllowed: Boolean = false) {
runBlocking {
@ -367,7 +411,10 @@ class AjustesFragment :
mobileApplication.dataStoreApp.readDataStoreKey<String>(PRINTERNAME).toString(),
mobileApplication.dataStoreApp.readDataStoreKey<String>(TRAINNAME),
mobileApplication.dataStoreApp.readDataStoreKey<String>(ITEMPACKING),
actionIsAllowed = actionIsAllowed
actionIsAllowed = actionIsAllowed,
menuDefault = mobileApplication.dataStoreApp.readDataStoreKey(
MENUBYDEFAULTSELECTED
)
)
}

View File

@ -3,7 +3,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
import androidx.lifecycle.map
import com.google.gson.JsonObject
import es.verdnatura.MobileApplication
import es.verdnatura.R
@ -76,11 +76,20 @@ class AjustesViewModel(val context: Context) : BaseViewModel(context) {
val trainList: LiveData<TrainList>
get() = _trainList
val loadSectorList = Transformations.map(_sectorList) { Event(it) }
val loadPrintersList = Transformations.map(_printerList) { Event(it) }
val loadItemPackingList = Transformations.map(_itemspackinglist) { Event(it) }
val loadTrainList = Transformations.map(_trainList) { Event(it) }
val loadUpdatePacking = Transformations.map(_actionUpdatePackingTicket) { Event(it) }
//val loadSectorList = Transformations.map(_sectorList) { Event(it) }
val loadSectorList: LiveData<Event<SectorListVO>> = _sectorList.map { Event(it) }
//val loadPrintersList = Transformations.map(_printerList) { Event(it) }
val loadPrintersList: LiveData<Event<PrintersList>> = _printerList.map { Event(it) }
//val loadItemPackingList = Transformations.map(_itemspackinglist) { Event(it) }
val loadItemPackingList: LiveData<Event<ItemPackingTypeList>> = _itemspackinglist.map { Event(it) }
//val loadTrainList = Transformations.map(_trainList) { Event(it) }
val loadTrainList: LiveData<Event<TrainList>> = _trainList.map { Event(it) }
//val loadUpdatePacking = Transformations.map(_actionUpdatePackingTicket) { Event(it) }
val loadUpdatePacking: LiveData<Event<ResponseItemVO>> = _actionUpdatePackingTicket.map { Event(it) }
fun inititializeDefaultAjusts(
sectorDescrip: String,
@ -91,7 +100,8 @@ class AjustesViewModel(val context: Context) : BaseViewModel(context) {
printerSelected: String,
train: String?,
itemPackingType: String?,
actionIsAllowed: Boolean
actionIsAllowed: Boolean,
menuDefault: String
) {
_ajustesitem.clear()
_ajustesitem.add(
@ -165,6 +175,17 @@ class AjustesViewModel(val context: Context) : BaseViewModel(context) {
true
)
)
_ajustesitem.add(
AjustesItemVO(
9,
context.getString(R.string.menuByDefault),
selected = menuDefault,
0,
0,
0, "",
true
)
)
_ajustesitem.add(
AjustesItemVO(
5,

View File

@ -9,6 +9,7 @@ import android.os.Build
import android.os.Environment
import android.provider.Settings
import android.util.Log.d
import android.view.View.VISIBLE
import androidx.annotation.RequiresApi
import androidx.datastore.preferences.core.stringPreferencesKey
import androidx.lifecycle.Observer
@ -116,6 +117,10 @@ class LoginFragment(var imageUri: Uri?) :
//deleteWorkForm("all")
listForms = runBlocking { mobileApplication.dataStoreApp.getWorkForm() }
binding.edittextServer.keyListener = null
binding.textviewWelcome.setOnLongClickListener {
binding.textinputlayoutServer.visibility = VISIBLE
true
}
binding.edittextServer.setOnLongClickListener {
showWorkingForms()
true

View File

@ -17,6 +17,7 @@ import es.verdnatura.MobileApplication
import es.verdnatura.R
import es.verdnatura.databinding.ActivityMainBinding
import es.verdnatura.domain.ConstAndValues.MAINACTIVITY
import es.verdnatura.domain.ConstAndValues.MENUBYDEFAULTSELECTED
import es.verdnatura.domain.ConstAndValues.PREITEMPICKER
import es.verdnatura.domain.ConstAndValues.PRINTERFK
import es.verdnatura.domain.ConstAndValues.PRINTERFKDEFAULT
@ -224,12 +225,17 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
PasilleroFragment.TAG,
false
)
else addFragment(
AjustesFragment.newInstance(),
R.id.main_frame_layout,
AjustesFragment.TAG,
false
)
else {
mobileApplication.dataStoreApp.readDataStoreKey<String>(MENUBYDEFAULTSELECTED)
.ifBlank {
addFragment(
AjustesFragment.newInstance(),
R.id.main_frame_layout,
AjustesFragment.TAG,
false
)
}
}
}

View File

@ -9,10 +9,12 @@ import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager
import es.verdnatura.R
import es.verdnatura.databinding.FragmentPasilleroBinding
import es.verdnatura.domain.ConstAndValues.MENUBYDEFAULTSELECTED
import es.verdnatura.domain.ConstAndValues.WORKFORMSELECTED
import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
import es.verdnatura.presentation.view.feature.pasillero.adapter.PasillerosAdapter
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
class PasilleroFragment(
private var tagName: String = "",
@ -45,8 +47,11 @@ class PasilleroFragment(
var myWorkSelected: String = mobileApplication.dataStoreApp.readDataStoreKey(
WORKFORMSELECTED
)
//6188 modificar apariencia
binding.mainToolbarDesign.layoutTool.visibility = View.GONE
if (myWorkSelected != "Producción") {
binding.pasillerosItems.setBackgroundColor(Color.RED)
binding.mainToolbarDesign.toolbarTitle.setBackgroundColor(Color.RED)
binding.mainToolbarDesign.toolbarTitle.text =
String.format(getString(R.string.mode, myWorkSelected))
@ -56,6 +61,14 @@ class PasilleroFragment(
binding.mainToolbarDesign.backButton.visibility = View.GONE
}
} else {
//6188 modificar apariencia
val toolbarHeight = resources.getDimensionPixelSize(R.dimen.toolbar_height)
binding.pasillerosItems.setPaddingRelative(
binding.pasillerosItems.paddingStart,
toolbarHeight,
binding.pasillerosItems.paddingEnd,
binding.pasillerosItems.paddingBottom
)
if (tagName == getString(R.string.titleCorridors)) {
binding.mainToolbarDesign.backButton.visibility = View.GONE
}
@ -74,7 +87,11 @@ class PasilleroFragment(
override fun onCreate(savedInstanceState: Bundle?) {
when (tagName) {
var showMenu = mobileApplication.dataStoreApp.readDataStoreKey<String>(
MENUBYDEFAULTSELECTED
).ifBlank { tagName }
when (showMenu) {
getString(R.string.titleCorridors) -> {
viewModel.inititializeDefaultData()
}
@ -88,6 +105,32 @@ class PasilleroFragment(
getString(R.string.titleControllers) -> viewModel.inititializeDefaultChecker()
getString(R.string.titleOther) -> viewModel.inititializeDefaultOther()
getString(R.string.historicals) -> viewModel.inititializeDefaultHistorical()
getString(R.string.titlePhotos) -> {
viewModel.inititializeDefaultDataInit(
PasillerosItemVO(
6,
R.drawable.photo_camera,
requireContext().getString(R.string.titlePhotos),
R.string.titlePhotos,
requireContext().getString(R.string.titlePhotos)
)
)
}
getString(R.string.titlePickers) -> {
viewModel.inititializeDefaultDataInit(
PasillerosItemVO(
7,
R.drawable.ic_picker_ui,
requireContext().getString(R.string.titlePickers),
R.string.titlePickers,
requireContext().getString(
R.string.titlePickersDescrip
)
)
)
}
else -> {
//Tarea 5313

View File

@ -2,6 +2,7 @@ package es.verdnatura.presentation.view.feature.pasillero.fragment
import android.annotation.SuppressLint
import android.content.Context
import es.verdnatura.MobileApplication
import es.verdnatura.R
import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
@ -13,35 +14,34 @@ class PasilleroViewModel(context: Context) : BaseViewModel(context) {
val pasillerositem: List<PasillerosItemVO>
get() = _pasillerositem
fun inititializeDefaultData() {
/* _pasillerositem.add(
PasillerosItemVO(
7,
R.drawable.ic_streetview_black_24dp,
contextApp.getString(R.string.titlePrePicker),
R.string.titlePrePicker,
contextApp.getString(
R.string.titlePickerDescrip
)
)
)
/* _pasillerositem.add(
PasillerosItemVO(
7,
R.drawable.ic_streetview_black_24dp,
contextApp.getString(R.string.titlePrePicker),
R.string.titlePrePicker,
contextApp.getString(
R.string.titlePickerDescrip
)
)
)
//sergio para que aparezca el nuevo menu
//sergio para que aparezca el nuevo menu
_pasillerositem.add(
PasillerosItemVO(
10,
R.drawable.ic_ticket,
contextApp.getString(R.string.titleShowTicket),
R.string.titleShowTicket,
contextApp.getString(
R.string.titleShowTicketDescrip
)
)
)*/
_pasillerositem.add(
PasillerosItemVO(
10,
R.drawable.ic_ticket,
contextApp.getString(R.string.titleShowTicket),
R.string.titleShowTicket,
contextApp.getString(
R.string.titleShowTicketDescrip
)
)
)*/
_pasillerositem.add(
PasillerosItemVO(
@ -55,19 +55,18 @@ class PasilleroViewModel(context: Context) : BaseViewModel(context) {
)
)
/*
/*
_pasillerositem.add(
PasillerosItemVO(
6,
R.drawable.ic_local_parking_orange_24dp,
contextApp.getString(R.string.Parking),
R.string.Parking,
contextApp.getString(R.string.titleParkingDescrip)
)
)
*/
_pasillerositem.add(
PasillerosItemVO(
6,
R.drawable.ic_local_parking_orange_24dp,
contextApp.getString(R.string.Parking),
R.string.Parking,
contextApp.getString(R.string.titleParkingDescrip)
)
)
*/
_pasillerositem.add(
PasillerosItemVO(
@ -168,7 +167,6 @@ class PasilleroViewModel(context: Context) : BaseViewModel(context) {
}
fun inititializeDefaultPallet() {
_pasillerositem.add(
@ -251,16 +249,15 @@ class PasilleroViewModel(context: Context) : BaseViewModel(context) {
)
)
/* _pasillerositem.add(
PasillerosItemVO(
33,
R.drawable.qrcode_scan,
contextApp.getString(R.string.titleQrReader),
R.string.titleQrReader,
contextApp.getString(R.string.titleQrDescrip)
)
)*/
/* _pasillerositem.add(
PasillerosItemVO(
33,
R.drawable.qrcode_scan,
contextApp.getString(R.string.titleQrReader),
R.string.titleQrReader,
contextApp.getString(R.string.titleQrDescrip)
)
)*/
}
@ -342,9 +339,11 @@ class PasilleroViewModel(context: Context) : BaseViewModel(context) {
)
}
fun inititializeDefaultDataInit() {
fun inititializeDefaultDataInit(pasillero: PasillerosItemVO? = null) {
if (pasillero != null) {
_pasillerositem.add(pasillero)
} else {
_pasillerositem.add(
PasillerosItemVO(
30,
@ -355,42 +354,43 @@ class PasilleroViewModel(context: Context) : BaseViewModel(context) {
)
)
_pasillerositem.add(
PasillerosItemVO(
7,
R.drawable.ic_corridor_ui,
contextApp.getString(R.string.titleCorridors),
R.string.titleCorridors,
contextApp.getString(R.string.titleCorridorsDescrip)
)
)
//precontrol
_pasillerositem.add(
PasillerosItemVO(
7,
R.drawable.ic_picker_ui,
contextApp.getString(R.string.titlePickers),
R.string.titlePickers,
contextApp.getString(
R.string.titlePickersDescrip
_pasillerositem.add(
PasillerosItemVO(
7,
R.drawable.ic_corridor_ui,
contextApp.getString(R.string.titleCorridors),
R.string.titleCorridors,
contextApp.getString(R.string.titleCorridorsDescrip)
)
)
)
val working_in_testMenu = false
if (working_in_testMenu) {
//precontrol
_pasillerositem.add(
PasillerosItemVO(
7,
R.drawable.ic_picker_ui,
contextApp.getString(R.string.sacador_test),
R.string.sacador_test,
contextApp.getString(R.string.titlePickers),
R.string.titlePickers,
contextApp.getString(
R.string.sacador_test
R.string.titlePickersDescrip
)
)
)
}
//sergio para que aparezca el nuevo menu
//val working_in_testMenu = false
var userId = (contextApp as MobileApplication).userId
if (userId == 19591 || userId == 822) {
_pasillerositem.add(
PasillerosItemVO(
7,
R.drawable.ic_picker_ui,
contextApp.getString(R.string.sacador_test),
R.string.sacador_test,
contextApp.getString(
R.string.sacador_test
)
)
)
}
//sergio para que aparezca el nuevo menu
_pasillerositem.add(
PasillerosItemVO(
@ -404,43 +404,42 @@ class PasilleroViewModel(context: Context) : BaseViewModel(context) {
)
)
_pasillerositem.add(
PasillerosItemVO(
0,
R.drawable.ic_pallet_ui,
contextApp.getString(R.string.titlePalletizers),
R.string.titlePalletizers,
contextApp.getString(
R.string.titlePalletizDescrip
_pasillerositem.add(
PasillerosItemVO(
0,
R.drawable.ic_pallet_ui,
contextApp.getString(R.string.titlePalletizers),
R.string.titlePalletizers,
contextApp.getString(
R.string.titlePalletizDescrip
)
)
)
)
_pasillerositem.add(
PasillerosItemVO(
6,
R.drawable.ic_claim_ui,
contextApp.getString(R.string.titleClaims),
R.string.titleClaims,
contextApp.getString(R.string.titleClaimsDescrip)
_pasillerositem.add(
PasillerosItemVO(
6,
R.drawable.ic_claim_ui,
contextApp.getString(R.string.titleClaims),
R.string.titleClaims,
contextApp.getString(R.string.titleClaimsDescrip)
)
)
)
//Tarea 4678
_pasillerositem.add(
PasillerosItemVO(
6,
R.drawable.ic_delivery_truck,
contextApp.getString(R.string.titleDelivery),
R.string.titleDelivery,
contextApp.getString(R.string.titleDelivery)
//Tarea 4678
_pasillerositem.add(
PasillerosItemVO(
6,
R.drawable.ic_delivery_truck,
contextApp.getString(R.string.titleDelivery),
R.string.titleDelivery,
contextApp.getString(R.string.titleDelivery)
)
)
)
//#tarea4021
/* _pasillerositem.add(
//#tarea4021
/* _pasillerositem.add(
PasillerosItemVO(
6,
R.drawable.ic_packaging,
@ -449,42 +448,42 @@ class PasilleroViewModel(context: Context) : BaseViewModel(context) {
contextApp.getString(R.string.titlePackagingDescrip)
)
)*/
//Tarea 5322
_pasillerositem.add(
PasillerosItemVO(
6,
R.drawable.photo_camera,
contextApp.getString(R.string.titlePhotos),
R.string.titlePhotos,
contextApp.getString(R.string.titlePhotos)
)
)
_pasillerositem.add(
PasillerosItemVO(
50,
R.drawable.ic_other,
contextApp.getString(R.string.titleOther),
R.string.titleOther,
contextApp.getString(R.string.titleOther)
)
)
val working_in_test = false
if (working_in_test) {
//Tarea 5322
_pasillerositem.add(
PasillerosItemVO(
6,
R.drawable.ic_star_ko,
contextApp.getString(R.string.testing),
R.string.testing,
contextApp.getString(R.string.testing)
R.drawable.photo_camera,
contextApp.getString(R.string.titlePhotos),
R.string.titlePhotos,
contextApp.getString(R.string.titlePhotos)
)
)
_pasillerositem.add(
PasillerosItemVO(
50,
R.drawable.ic_other,
contextApp.getString(R.string.titleOther),
R.string.titleOther,
contextApp.getString(R.string.titleOther)
)
)
val working_in_test = false
if (working_in_test) {
_pasillerositem.add(
PasillerosItemVO(
6,
R.drawable.ic_star_ko,
contextApp.getString(R.string.testing),
R.string.testing,
contextApp.getString(R.string.testing)
)
)
}
}
}
fun inititializeDefaultClaim() {
_pasillerositem.add(
@ -512,13 +511,10 @@ class PasilleroViewModel(context: Context) : BaseViewModel(context) {
)
)
}
fun inititializeDefaultDelivery() {
_pasillerositem.add(
PasillerosItemVO(
6,
@ -572,7 +568,6 @@ class PasilleroViewModel(context: Context) : BaseViewModel(context) {
fun inititializeDefaultChecker() {
_pasillerositem.add(
PasillerosItemVO(
7,
@ -610,6 +605,7 @@ class PasilleroViewModel(context: Context) : BaseViewModel(context) {
)
}
fun inititializeDefaultOther() {
_pasillerositem.add(
@ -625,6 +621,7 @@ class PasilleroViewModel(context: Context) : BaseViewModel(context) {
)
}
fun inititializeDefaultHistorical() {
_pasillerositem.add(
PasillerosItemVO(
@ -650,17 +647,17 @@ class PasilleroViewModel(context: Context) : BaseViewModel(context) {
)
//Tarea 5186
/* _pasillerositem.add(
PasillerosItemVO(
7,
R.drawable.ic_parking_previa,
contextApp.getString(R.string.titleParkingTicketPrevia),
R.string.titleParkingTicketPrevia,
contextApp.getString(
R.string.titleParkingTicketPrevia
)
)
)*/
/* _pasillerositem.add(
PasillerosItemVO(
7,
R.drawable.ic_parking_previa,
contextApp.getString(R.string.titleParkingTicketPrevia),
R.string.titleParkingTicketPrevia,
contextApp.getString(
R.string.titleParkingTicketPrevia
)
)
)*/
_pasillerositem.add(
PasillerosItemVO(
@ -674,6 +671,5 @@ class PasilleroViewModel(context: Context) : BaseViewModel(context) {
)
)
}
}

View File

@ -4,6 +4,7 @@
xmlns:tool="http://schemas.android.com/tools">
<LinearLayout
android:id="@+id/layout_tool"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">