From 5f614e0d6d70d4735279334345d24b97e91511e6 Mon Sep 17 00:00:00 2001 From: Sergio De la torre Date: Mon, 4 Nov 2024 09:19:23 +0100 Subject: [PATCH] feat: refs #6845 userIterface --- .../es/verdnatura/dataStore/DataStoreLocal.kt | 7 +- .../java/es/verdnatura/domain/Extensions.kt | 27 ++++ .../presentation/common/UICallbacks.kt | 4 + .../presentation/common/UIExtensions.kt | 17 ++- .../ajustes/fragment/AjustesFragment.kt | 74 +++++++---- .../ajustes/fragment/AjustesViewModel.kt | 29 ++-- .../feature/collection/adapter/SaleAdapter.kt | 39 +++++- .../fragment/CollectionFragmentPicker.kt | 62 +++++---- .../collection/fragment/ShowTicketFragment.kt | 65 +++++---- .../collection/mapper/CollectionMapper.kt | 2 + .../inventario/fragment/InventaryFragment.kt | 2 +- .../feature/sacador/model/TicketItemVO.kt | 12 +- app/src/main/res/drawable/ic_logout.xml | 11 ++ .../layout/component_custom_list_dialog.xml | 72 +++++++--- app/src/main/res/layout/fragment_ajustes.xml | 125 +----------------- .../res/layout/item_article_row_fragment.xml | 28 ++-- .../main/res/layout/item_placement_row.xml | 3 +- app/src/main/res/values-es/strings.xml | 11 +- app/src/main/res/values-fr/strings.xml | 11 +- app/src/main/res/values-pt/strings.xml | 11 +- app/src/main/res/values/strings.xml | 11 +- 21 files changed, 360 insertions(+), 263 deletions(-) create mode 100644 app/src/main/res/drawable/ic_logout.xml diff --git a/app/src/main/java/es/verdnatura/dataStore/DataStoreLocal.kt b/app/src/main/java/es/verdnatura/dataStore/DataStoreLocal.kt index 45ef7c9c..1077b911 100644 --- a/app/src/main/java/es/verdnatura/dataStore/DataStoreLocal.kt +++ b/app/src/main/java/es/verdnatura/dataStore/DataStoreLocal.kt @@ -124,7 +124,7 @@ class DataStoreLocal(var mobileApplication: MobileApplication) { SECTORFKDEFAULT } ) - + if (operator.sector?.isOnReservationMode != null) { editDataStoreKey( SECTORISONRESERVATIONMODE, @@ -178,7 +178,10 @@ class DataStoreLocal(var mobileApplication: MobileApplication) { editDataStoreKey( RESERVATIONMODE, operator.isOnReservationMode ) - + editDataStoreKey( + ITEMPACKING, + operator.itemPackingTypeFk + ) } suspend fun isPreferenceExists(key: String): Boolean { diff --git a/app/src/main/java/es/verdnatura/domain/Extensions.kt b/app/src/main/java/es/verdnatura/domain/Extensions.kt index a2951380..9e739a20 100644 --- a/app/src/main/java/es/verdnatura/domain/Extensions.kt +++ b/app/src/main/java/es/verdnatura/domain/Extensions.kt @@ -2,11 +2,16 @@ package es.verdnatura.domain import android.content.Context import android.graphics.Color +import android.graphics.drawable.GradientDrawable import android.os.Build import android.text.Html +import android.view.Gravity +import android.view.LayoutInflater import android.widget.EditText +import android.widget.TextView import android.widget.Toast import androidx.annotation.RequiresApi +import es.verdnatura.R import java.text.SimpleDateFormat import java.time.ZonedDateTime import java.time.format.DateTimeFormatter @@ -41,6 +46,28 @@ fun Any.toast( return toast.apply { show() } } +fun Context.showToastCenterWithBackground(textToShow: String) { + val inflater = LayoutInflater.from(this) + val layout = inflater.inflate(R.layout.ticket_toast_layout, null) + val text = layout.findViewById(R.id.toast_text) + text.text = "$textToShow" + text.setTextColor(this.getColor(R.color.verdnatura_orange_salix)) + text.textSize = 18f + + val background = GradientDrawable().apply { + setColor(Color.parseColor("#000000")) + cornerRadius = 16f + } + layout.background = background + + Toast(this).apply { + duration = Toast.LENGTH_LONG + view = layout + setGravity(Gravity.CENTER, 0, 0) + show() + } +} + fun T?.notNull(f: (it: T) -> Unit) { if (this != null) f(this) } diff --git a/app/src/main/java/es/verdnatura/presentation/common/UICallbacks.kt b/app/src/main/java/es/verdnatura/presentation/common/UICallbacks.kt index ced5df1e..6a72c014 100644 --- a/app/src/main/java/es/verdnatura/presentation/common/UICallbacks.kt +++ b/app/src/main/java/es/verdnatura/presentation/common/UICallbacks.kt @@ -263,6 +263,10 @@ interface OnTicketClickListener { fun onTicketClickListener(sale: SaleVO) } +interface OnTicketColorListener { + fun onTicketColorListener(sale: SaleVO) +} + interface OnTicketClickSaleListener { fun onTicketClickListener(sale: Sale) } diff --git a/app/src/main/java/es/verdnatura/presentation/common/UIExtensions.kt b/app/src/main/java/es/verdnatura/presentation/common/UIExtensions.kt index 074d0eaa..a5660544 100644 --- a/app/src/main/java/es/verdnatura/presentation/common/UIExtensions.kt +++ b/app/src/main/java/es/verdnatura/presentation/common/UIExtensions.kt @@ -10,6 +10,8 @@ import android.graphics.drawable.Drawable import android.media.AudioManager import android.os.Build import android.os.Bundle +import android.os.Handler +import android.os.Looper import android.text.InputType import android.view.View import android.view.ViewGroup @@ -153,8 +155,12 @@ fun Activity.showKeyboardIn() { } fun Context.hideKeyboard(view: View) { - val inputMethodManager = getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager - inputMethodManager.hideSoftInputFromWindow(view.windowToken, 0) + Handler(Looper.getMainLooper()).postDelayed({ + val inputMethodManager = + getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager + inputMethodManager.hideSoftInputFromWindow(view.windowToken, 0) + }, 100L) + } fun Context.showKeyboard() { @@ -213,7 +219,7 @@ fun PackageManager.getPackageInfoCompat(packageName: String, flags: Int = 0): Pa if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { getPackageInfo(packageName, PackageManager.PackageInfoFlags.of(flags.toLong())) } else { - getPackageInfo(packageName, flags) + getPackageInfo(packageName, flags) } fun convertToDateString(date: String?): String? { @@ -221,8 +227,9 @@ fun convertToDateString(date: String?): String? { if (date.isNullOrEmpty()) { return date } - val formatoEntrada = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.getDefault()) // Formato de entrada - val formatoSalida = SimpleDateFormat("yyyy-MM-dd",Locale.getDefault()) // Formato de salida + val formatoEntrada = + SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.getDefault()) // Formato de entrada + val formatoSalida = SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()) // Formato de salida val dateToConvert = formatoEntrada.parse(date) // Convertir fecha de String a objeto Date return formatoSalida.format(dateToConvert!!) // Convertir fecha a String con formato deseado } 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 7f07d592..6410cdf6 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 @@ -76,13 +76,6 @@ class AjustesFragment : binding.mainToolbar.toolbarTitle.text = getString(R.string.settings) hideBackButton(binding.mainToolbar) getUserData() - binding.userText.text = mobileApplication.userName - binding.itemVersion.text = requireActivity().packageManager.getPackageInfo( - requireActivity().packageName, 0 - ).versionName!! - binding.androididText.text = - mobileApplication.dataStoreApp.readDataStoreKey(ANDROID_ID) - binding.serialNumber.text = mobileApplication.serialNumber pasilleroViewModel = PasilleroViewModel(mobileApplication) setToolBar() super.init() @@ -132,34 +125,44 @@ class AjustesFragment : val listIcons: ArrayList = ArrayList() val iconInfo = ImageView(context) iconInfo.setImageResource(R.drawable.ic_info_delivery) + val iconLogout = ImageView(context) + iconLogout.setImageResource(R.drawable.ic_logout) listIcons.add(iconInfo) + listIcons.add(iconLogout) binding.mainToolbar.toolbarIcons.adapter = ToolBarAdapterTooltip(listIcons, object : OnOptionsSelectedListener { override fun onOptionsItemSelected(item: Drawable) { - customDialog.setTitle(getString(R.string.info)) - .setDescription( - getString(R.string.version) + ":\t" + - requireActivity().packageManager.getPackageInfo( - requireActivity().packageName, 0 - ).versionName!! + "(${getVersionCode()})" + "\n" + - getString(R.string.user) + ":\t" + - mobileApplication.userName + "\n" + - getString(R.string.androidid) + ":\t" + - mobileApplication.dataStoreApp.readDataStoreKey( - ANDROID_ID - ) + "\n" + - if (!mobileApplication.serialNumber.isNullOrBlank()) { - getString(R.string.serialNumber) + "\t" + - mobileApplication.serialNumber - } else "" + when (item) { + iconInfo.drawable -> { + customDialog.setTitle(getString(R.string.info)) + .setDescription( + getString(R.string.version) + ":\t" + + requireActivity().packageManager.getPackageInfo( + requireActivity().packageName, 0 + ).versionName!! + "(${getVersionCode()})" + "\n" + + getString(R.string.user) + ":\t" + + mobileApplication.userName + "\n" + + getString(R.string.androidid) + ":\t" + + mobileApplication.dataStoreApp.readDataStoreKey( + ANDROID_ID + ) + "\n" + + if (!mobileApplication.serialNumber.isNullOrBlank()) { + getString(R.string.serialNumber) + "\t" + + mobileApplication.serialNumber + } else "" - ) - .setOkButton(getString(R.string.Close)) { - customDialog.dismiss() - }.show() + ) + .setOkButton(getString(R.string.Close)) { + customDialog.dismiss() + }.show() + } + iconLogout.drawable -> { + ma.onMyBackPressed() + } + } } }) binding.mainToolbar.toolbarIcons.layoutManager = @@ -217,6 +220,23 @@ class AjustesFragment : CodeWorkerAction.STOP ) + getString(R.string.holdpositionAuto) -> { + + runBlocking { + mobileApplication.dataStoreApp.editDataStoreKey( + HOLDPOSITION, + viewModel.settingsItem[5].selected != getString(R.string.yes) + ) + } + viewModel.settingsItem[5].holdPosition = + !viewModel.settingsItem[5].holdPosition + viewModel.settingsItem[5].selected = + if (viewModel.settingsItem[5].holdPosition) getString(R.string.yes) else getString( + R.string.no + ) + settingsAdapter!!.notifyItemChanged(5) + } + else -> {} } 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 c20a4863..8ac8ca71 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 @@ -100,14 +100,17 @@ class AjustesViewModel(val context: Context) : BaseViewModel(context) { action = false ) ) - /*Tarea 5443 - _settingsItem.add( - AjustesItemVO( - "Bajar línea al revisar", - holdPosition = holdPosition, - action = true - ) - )*/ + //Tarea 5443 + _settingsItem.add( + AjustesItemVO( + context.getString(R.string.holdpositionAuto), + holdPosition = holdPosition, + selected = if (holdPosition) context.getString(R.string.yes) else context.getString( + R.string.no + ), + action = true + ) + ) _settingsItem.add( AjustesItemVO( @@ -124,11 +127,11 @@ class AjustesViewModel(val context: Context) : BaseViewModel(context) { context.getString(R.string.runActivityStop), action = true ) ) - _settingsItem.add( - AjustesItemVO( - context.getString(R.string.closeSession), action = true - ) - ) + /* _settingsItem.add( + AjustesItemVO( + context.getString(R.string.closeSession), action = true + ) + )*/ } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/adapter/SaleAdapter.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/adapter/SaleAdapter.kt index 9c0f3658..60026bec 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/adapter/SaleAdapter.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/adapter/SaleAdapter.kt @@ -6,6 +6,8 @@ import android.graphics.Color import android.graphics.drawable.Drawable import android.view.LayoutInflater import android.view.View +import android.view.View.GONE +import android.view.View.VISIBLE import android.view.ViewGroup import androidx.core.content.ContextCompat.getColor import androidx.core.graphics.drawable.DrawableCompat @@ -13,6 +15,7 @@ import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import es.verdnatura.R import es.verdnatura.databinding.ItemArticleRowFragmentBinding +import es.verdnatura.domain.ConstAndValues.CONTROLADOR import es.verdnatura.domain.ConstAndValues.SACADOR import es.verdnatura.presentation.common.OnMistakeClickListener import es.verdnatura.presentation.common.OnPackingClickListener @@ -20,11 +23,12 @@ import es.verdnatura.presentation.common.OnPasillerosItemClickListener import es.verdnatura.presentation.common.OnQuantityClickListener import es.verdnatura.presentation.common.OnSaleClickListener import es.verdnatura.presentation.common.OnTicketClickListener +import es.verdnatura.presentation.common.OnTicketColorListener import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO import es.verdnatura.presentation.view.feature.sacador.model.SaleVO class SaleAdapter( - private val items: List, + private var items: MutableList, private val onPasillerosItemClickListener: OnPasillerosItemClickListener, private val onQuantityClick: OnQuantityClickListener, private val onSaleClickListener: OnSaleClickListener, @@ -33,8 +37,9 @@ class SaleAdapter( private var onTicketClick: OnTicketClickListener? = null, private var SaleAdapter: SaleAdapter? = null, private var type: String? = null, + private var onTicketColorClickListener: OnTicketColorListener? = null - ) : RecyclerView.Adapter() { +) : RecyclerView.Adapter() { var context: Context? = null var position: Int = 0 @@ -396,8 +401,26 @@ class SaleAdapter( } else { View.GONE }*/ - + println("sale ${sale.parkingCode} : ${sale.isAdvanced}") //ASIGNAMOS VALOR A LA VSITA + ticketFk.setTextColor( + getColor( + context!!, + if (sale.isAdvanced != null && sale.isAdvanced == 1) { + R.color.verdnatura_red_salix + } else { + R.color.verdnatura_black + } + ) + ) + parkingCode.visibility = if (sale.parkingCode == null) GONE else VISIBLE + + itemTicketColor.setOnClickListener { + onTicketColorClickListener?.onTicketColorListener(sale) + } + if (type == SACADOR || type == CONTROLADOR) { + itemTicketColor.tooltipText = context!!.getString(R.string.filterLevelColor) + } this.sale = sale } @@ -468,4 +491,14 @@ class SaleAdapter( // itemTicketColor.setBackgroundResource((R.drawable.rectangle)) } + + fun updateSales(newSales: List) { + items = newSales.toMutableList() + notifyDataSetChanged() // Notifica al adaptador que los datos han cambiado + } + + fun orderSales(newSales: List) { + + notifyDataSetChanged() // Notifica al adaptador que los datos han cambiado + } } \ No newline at end of file diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPicker.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPicker.kt index 60281503..2545f799 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPicker.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragmentPicker.kt @@ -1,6 +1,5 @@ package es.verdnatura.presentation.view.feature.collection.fragment -import android.app.AlertDialog import android.content.Context import android.graphics.drawable.Drawable import android.media.MediaPlayer @@ -38,6 +37,7 @@ import es.verdnatura.domain.notNull import es.verdnatura.domain.toast import es.verdnatura.presentation.base.BaseFragment import es.verdnatura.presentation.common.ItemScanned +import es.verdnatura.presentation.common.LabelDialogHelper import es.verdnatura.presentation.common.OnBarcodeRowClickListener import es.verdnatura.presentation.common.OnMistakeClickListener import es.verdnatura.presentation.common.OnOptionsSelectedListener @@ -46,6 +46,7 @@ import es.verdnatura.presentation.common.OnPasillerosItemClickListener import es.verdnatura.presentation.common.OnQuantityClickListener import es.verdnatura.presentation.common.OnSaleClickListener import es.verdnatura.presentation.common.OnTicketClickListener +import es.verdnatura.presentation.common.OnTicketColorListener import es.verdnatura.presentation.common.ToolBarAdapterTooltip import es.verdnatura.presentation.common.hideKeyboard import es.verdnatura.presentation.common.itemScanIsQr @@ -126,11 +127,14 @@ class CollectionFragmentPicker( private var recylerViewState: Parcelable? = null private var isScanned: Boolean? = null private var myPosition: Int = 0 + private var changePosition = false private lateinit var myGroupList: List private var canChangeState = true private var isVerifiedCollection = false + private var hasFilterByLevel = false + companion object { fun newInstance(collection: CollectionVO, type: String) = CollectionFragmentPicker(collection, type) @@ -841,7 +845,7 @@ class CollectionFragmentPicker( } else { // pintar línea saleAdapter!!.notifyDataSetChanged() - myPosition = storedPosition + myPosition = storedBackPosition ReviewQuantityForRefreshingAndSorting( sales[storedPosition].quantity!!.toInt(), @@ -926,7 +930,7 @@ class CollectionFragmentPicker( } saleAdapter = SaleAdapter( - myGroupList, + myGroupList as MutableList, pasillerosItemClickListener!!, object : OnQuantityClickListener { @@ -1001,17 +1005,25 @@ class CollectionFragmentPicker( } } }, - type = type + type = type, + onTicketColorClickListener = object : OnTicketColorListener { + override fun onTicketColorListener(sale: SaleVO) { + hasFilterByLevel = !hasFilterByLevel + + if (hasFilterByLevel) { + saleAdapter!!.updateSales(myGroupList.filter { it.level == sale.level } as MutableList) + myGroupList = myGroupList.filter { it.level == sale.level } + } else { + createCollectionList() + + } + } + } ) - - lm = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false) - - binding.fragmentSacadorCollections.adapter = saleAdapter - binding.fragmentSacadorCollections.layoutManager = lm setTotalLines() //Tarea #4628 @@ -1111,6 +1123,7 @@ class CollectionFragmentPicker( RecyclerView.OnScrollListener() { override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) { storedBackPosition = lm.findFirstVisibleItemPosition() + myPosition = lm.findFirstVisibleItemPosition() super.onScrolled(recyclerView, dx, dy) } }) @@ -1368,7 +1381,7 @@ class CollectionFragmentPicker( } //nuevo - var mySale = sales[position].saleFk + val mySale = sales[position].saleFk for (indice in myGroupList.indices) { if (!myGroupList[indice].isParent && myGroupList[indice].saleFk == mySale) { @@ -1533,11 +1546,11 @@ class CollectionFragmentPicker( if (!myGroupList[indice].isParent && myGroupList[indice].saleFk == mySale) { storedBackPosition = indice + myPosition = storedBackPosition } } storedBackPosition = position - myPosition = position setListPosition(position, false) if (type != PRECHECKER) { @@ -2075,7 +2088,7 @@ class CollectionFragmentPicker( "" + totalMark + "/" + total if (totalMark == sales.size) { - getString(R.string.Coleccióncompleta).toast(this.context, Toast.LENGTH_SHORT) + getString(R.string.completCollection).toast(this.context, Toast.LENGTH_SHORT) saleAdapter!!.notifyDataSetChanged() if (!goBack) ticketCollection_setUsedShelves() @@ -2341,20 +2354,19 @@ class CollectionFragmentPicker( } } if (isTicket) { - val builder = AlertDialog.Builder(context) - builder.setTitle(getString(R.string.selectLabeltoPrint)) - val labelCount = arrayOf("1", "2", "3", "4", "5", "6", "7", "8", "9", "10") - builder.setItems(labelCount) { dialog, which -> - viewModel.collectionStickerPrint( - collectionFk = collection.collectionFk, labelCount = (which + 1) - ) - (getString(R.string.Imprimiendo) + mobileApplication.dataStoreApp.readDataStoreKey( - PRINTERNAME - )).toast(requireContext()) + val labelDialogHelper = LabelDialogHelper(requireContext()) + labelDialogHelper.showLabelDialog( + onItemSelected = { labelCount -> + viewModel.collectionStickerPrint( + collectionFk = collection.collectionFk, + labelCount = labelCount + ) - } - val dialog = builder.create() - dialog.show() + (getString(R.string.Imprimiendo) + mobileApplication.dataStoreApp.readDataStoreKey( + PRINTERNAME + )).toast(requireContext()) + } + ) } else { viewModel.collectionStickerPrint( collectionFk = collection.collectionFk, null diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/ShowTicketFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/ShowTicketFragment.kt index fd894712..eedd3c29 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/ShowTicketFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/ShowTicketFragment.kt @@ -7,7 +7,6 @@ import android.view.View.VISIBLE import android.view.inputmethod.EditorInfo import android.widget.ImageView import android.widget.Toast -import androidx.lifecycle.Observer import androidx.recyclerview.widget.LinearLayoutManager import es.verdnatura.R import es.verdnatura.databinding.FragmentCollectionBinding @@ -170,7 +169,7 @@ class CollectionShowTicketFragment( binding.scanInput.setOnEditorActionListener { _, actionId, _ -> if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {//ID=0 ACTION_NEXT ID=5 ACTION_UNESPECEFIED) - if (!binding.scanInput.text.toString().isNullOrEmpty()) { + if (binding.scanInput.text.toString().isNotEmpty()) { buttonPushedGetCollection = false try { viewModel.getSales( @@ -213,13 +212,14 @@ class CollectionShowTicketFragment( try { requireActivity().hideKeyboard() } catch (e: Exception) { + e.message!!.toast(requireContext()) } } override fun observeViewModel() { with(viewModel) { - collectionTicketList.observe(viewLifecycleOwner, Observer { + collectionTicketList.observe(viewLifecycleOwner) { if (!it.isError) { if (it.tickets.isNotEmpty()) { @@ -232,18 +232,18 @@ class CollectionShowTicketFragment( } } else { - ma.messageWithSound(it.errorMessage, it.isError, false) + ma.messageWithSound(it.errorMessage, isError = true, false) if (activity != null) ma.onMyBackPressed() } - }) + } - responsePrint.observe(viewLifecycleOwner, Observer { + responsePrint.observe(viewLifecycleOwner) { if (it.isError) { ma.messageWithSound( - it.errorMessage, it.isError, true + it.errorMessage, isError = true, true ) } else { (getString(R.string.Imprimiendo) + mobileApplication.dataStoreApp.readDataStoreKey( @@ -251,7 +251,7 @@ class CollectionShowTicketFragment( )).toast(requireContext()) } - }) + } } } @@ -277,27 +277,30 @@ class CollectionShowTicketFragment( } } - sales = salesList.sortedWith(compareBy({ it.saleOrder })) - /*salesList.sortedWith(compareBy { it.isPrepared == "0" } - .thenBy { it.isControlled == "0" }*/ - + sales = salesList.sortedWith(compareBy { it.saleOrder }) saleAdapter = - SaleAdapter(sales, pasillerosItemClickListener!!, object : OnQuantityClickListener { + SaleAdapter( + sales as MutableList, + pasillerosItemClickListener!!, + object : OnQuantityClickListener { - override fun onQuantityClick(sale: SaleVO) { - } - }, object : OnSaleClickListener { - override fun onSaleClick(sale: SaleVO) { - } + override fun onQuantityClick(sale: SaleVO) { + } + }, + object : OnSaleClickListener { + override fun onSaleClick(sale: SaleVO) { + } - }, object : OnMistakeClickListener { - override fun onMistakeClickListener(sale: SaleVO) { - } - }, object : OnPackingClickListener { - override fun onPackingClick(sale: SaleVO) { - } + }, + object : OnMistakeClickListener { + override fun onMistakeClickListener(sale: SaleVO) { + } + }, + object : OnPackingClickListener { + override fun onPackingClick(sale: SaleVO) { + } - }) + }) lm = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false) binding.fragmentSacadorCollections.adapter = saleAdapter @@ -310,8 +313,13 @@ class CollectionShowTicketFragment( private fun setPosition() { val firstIndex = - sales.indexOfFirst { it.isPreviousPrepared == "0" && (it.isPrepared == "0" || it.isControlled == "0") } - lm!!.scrollToPositionWithOffset(firstIndex, 0) + sales.indexOfFirst { it.isPreviousPrepared == "0" && it.isPrepared == "0" && it.isControlled == "0" } + val resultIndex = if (firstIndex != -1) { + firstIndex + } else { + sales.indexOfFirst { it.isPreviousPrepared == "0" && it.isPrepared == "0" } + } + lm!!.scrollToPositionWithOffset(resultIndex, 0) } private fun printObservations(observations: String) { @@ -331,7 +339,8 @@ class CollectionShowTicketFragment( if (it.isControlled == "1") totalMark += 1 } binding.mainToolbar.toolbarTitle.text = collection.collectionFk.toString() - binding.mainToolbar.toolbarSubtitle.text = "" + totalMark + "/" + sales.size + binding.mainToolbar.toolbarSubtitle.text = + getString(R.string.totalsPicker, totalMark, sales.size) if (totalMark == sales.size) { getString(R.string.completCollection).toast(this.context, Toast.LENGTH_SHORT) diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/mapper/CollectionMapper.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/mapper/CollectionMapper.kt index ff09cdb7..0a564adf 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/mapper/CollectionMapper.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/mapper/CollectionMapper.kt @@ -15,6 +15,8 @@ fun CollectionVO.map(context: Context): CollectionVO { this.tickets.forEach { ticket -> // if (ticket.sales.size>0){ ticket.sales.forEach { + it.parkingCode = ticket.parkingCode + it.isAdvanced = ticket.isAdvanced it.ticketFk = ticket.ticketFk it.level = ticket.level it.rgb = ticket.rgb diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/inventario/fragment/InventaryFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/inventario/fragment/InventaryFragment.kt index ce578998..1e90aab1 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/inventario/fragment/InventaryFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/inventario/fragment/InventaryFragment.kt @@ -157,7 +157,7 @@ class InventaryFragment : setFilterItem() } - adapter!!.notifyDataSetChanged() + adapter?.notifyDataSetChanged() return@setOnKeyListener false } } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/model/TicketItemVO.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/model/TicketItemVO.kt index 157576ff..7bb60ab5 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/model/TicketItemVO.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/model/TicketItemVO.kt @@ -89,7 +89,9 @@ class CollectionVO( var errorMessage: String = "", var itemPackingTypeFk: String = "", var rgb: String? = null, - var ticketTotalCount: Int? = null + var ticketTotalCount: Int? = null, + var parkingCode: String? = null, + var idAdvanced: Boolean? = null ) class CollectionSalix( @@ -162,7 +164,9 @@ class SaleVO( var code: String? = "", var hasMistake: Any? = false, var sectorFk: Int? = null, - var packingChecked: Int = 1 + var packingChecked: Int = 1, + var isAdvanced: Int? = 0, + var parkingCode: String? = "" ) @@ -175,8 +179,10 @@ class TicketVO( var sales: List = listOf(), @SerializedName(value = "observations", alternate = ["observaciones"]) var observations: String = "", + var isAdvanced: Int? = 0, + var parkingCode: String? = "" - ) +) data class CollectionIdSalix( var id: Int diff --git a/app/src/main/res/drawable/ic_logout.xml b/app/src/main/res/drawable/ic_logout.xml new file mode 100644 index 00000000..18a1b704 --- /dev/null +++ b/app/src/main/res/drawable/ic_logout.xml @@ -0,0 +1,11 @@ + + + diff --git a/app/src/main/res/layout/component_custom_list_dialog.xml b/app/src/main/res/layout/component_custom_list_dialog.xml index cb688df3..f532c281 100644 --- a/app/src/main/res/layout/component_custom_list_dialog.xml +++ b/app/src/main/res/layout/component_custom_list_dialog.xml @@ -11,24 +11,24 @@ + android:focusableInTouchMode="true" + android:orientation="vertical" + android:padding="@dimen/default_layout_margin"> + android:id="@+id/custom_dialog_title" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="@dimen/layout_margin_1" + android:layout_marginBottom="@dimen/layout_margin_min" + android:textAlignment="center" + android:textColor="@color/verdnatura_white" + android:textSize="@dimen/h6" + android:textStyle="bold" + android:visibility="gone" + tools:text="¿Estás seguro de que deseas eliminar el dispositivo de celia?" + tools:visibility="visible" /> - + android:layout_marginTop="@dimen/layout_margin_min" + android:textColorHint="@android:color/darker_gray"> + android:textColorHint="@android:color/darker_gray" /> + + + + + @@ -69,9 +89,10 @@ android:id="@+id/textinputlayout_two" android:layout_width="match_parent" android:layout_height="wrap_content" - android:textColorHint="@android:color/darker_gray" android:layout_marginTop="@dimen/layout_margin_min" + android:textColorHint="@android:color/darker_gray" android:visibility="gone"> + + tools:listitem="@layout/item_barcode_row" />