feat: refs #6868 handleUser
This commit is contained in:
parent
aa04349845
commit
0c1f054b7f
|
@ -1,8 +1,11 @@
|
||||||
package es.verdnatura.presentation.view.feature.ajustes.fragment
|
package es.verdnatura.presentation.view.feature.ajustes.fragment
|
||||||
|
|
||||||
import android.app.AlertDialog
|
import android.app.AlertDialog
|
||||||
|
import android.content.pm.PackageInfo
|
||||||
|
import android.content.pm.PackageManager
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
@ -13,6 +16,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import es.verdnatura.R
|
import es.verdnatura.R
|
||||||
import es.verdnatura.databinding.FragmentAjustesBinding
|
import es.verdnatura.databinding.FragmentAjustesBinding
|
||||||
import es.verdnatura.domain.ConstAndValues.ANDROID_ID
|
import es.verdnatura.domain.ConstAndValues.ANDROID_ID
|
||||||
|
import es.verdnatura.domain.ConstAndValues.HOLDPOSITION
|
||||||
import es.verdnatura.domain.ConstAndValues.ITEMPACKING
|
import es.verdnatura.domain.ConstAndValues.ITEMPACKING
|
||||||
import es.verdnatura.domain.ConstAndValues.MENUBYDEFAULTSELECTED
|
import es.verdnatura.domain.ConstAndValues.MENUBYDEFAULTSELECTED
|
||||||
import es.verdnatura.domain.ConstAndValues.NUMBEROFWAGONS
|
import es.verdnatura.domain.ConstAndValues.NUMBEROFWAGONS
|
||||||
|
@ -99,14 +103,14 @@ class AjustesFragment :
|
||||||
getString(R.string.version) + ":\t" +
|
getString(R.string.version) + ":\t" +
|
||||||
requireActivity().packageManager.getPackageInfo(
|
requireActivity().packageManager.getPackageInfo(
|
||||||
requireActivity().packageName, 0
|
requireActivity().packageName, 0
|
||||||
).versionName!! + "\n" +
|
).versionName!! + "(${getVersionCode()})" + "\n" +
|
||||||
getString(R.string.user) + ":\t" +
|
getString(R.string.user) + ":\t" +
|
||||||
mobileApplication.userName + "\n" +
|
mobileApplication.userName + "\n" +
|
||||||
getString(R.string.androidid) + ":\t" +
|
getString(R.string.androidid) + ":\t" +
|
||||||
mobileApplication.dataStoreApp.readDataStoreKey<String>(
|
mobileApplication.dataStoreApp.readDataStoreKey<String>(
|
||||||
ANDROID_ID
|
ANDROID_ID
|
||||||
) + "\n" +
|
) + "\n" +
|
||||||
if (!mobileApplication.serialNumber.isNullOrBlank() ) {
|
if (!mobileApplication.serialNumber.isNullOrBlank()) {
|
||||||
getString(R.string.serialNumber) + "\t" +
|
getString(R.string.serialNumber) + "\t" +
|
||||||
mobileApplication.serialNumber
|
mobileApplication.serialNumber
|
||||||
} else ""
|
} else ""
|
||||||
|
@ -122,6 +126,27 @@ class AjustesFragment :
|
||||||
LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
|
LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getVersionCode(): Long {
|
||||||
|
val context = requireContext()
|
||||||
|
val packageManager: PackageManager = context.packageManager
|
||||||
|
val packageInfo: PackageInfo = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||||
|
packageManager.getPackageInfo(
|
||||||
|
context.packageName,
|
||||||
|
PackageManager.PackageInfoFlags.of(0)
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
|
packageManager.getPackageInfo(context.packageName, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||||
|
packageInfo.longVersionCode
|
||||||
|
} else {
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
|
packageInfo.versionCode.toLong()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun observeViewModel() {
|
override fun observeViewModel() {
|
||||||
with(viewModel) {
|
with(viewModel) {
|
||||||
|
|
||||||
|
@ -241,6 +266,7 @@ class AjustesFragment :
|
||||||
.setDescription(getString(R.string.Noprinters))
|
.setDescription(getString(R.string.Noprinters))
|
||||||
.setOkButton(getString(R.string.Close)) {
|
.setOkButton(getString(R.string.Close)) {
|
||||||
customDialog.dismiss()
|
customDialog.dismiss()
|
||||||
|
handleUserCall()
|
||||||
}.show()
|
}.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -271,7 +297,7 @@ class AjustesFragment :
|
||||||
private fun getUserData() {
|
private fun getUserData() {
|
||||||
|
|
||||||
loginViewModel = LoginViewModel(requireActivity().applicationContext)
|
loginViewModel = LoginViewModel(requireActivity().applicationContext)
|
||||||
try {
|
/* try {
|
||||||
loginViewModel.operatorGetData(mobileApplication.userId!!)
|
loginViewModel.operatorGetData(mobileApplication.userId!!)
|
||||||
} catch (_: Exception) {
|
} catch (_: Exception) {
|
||||||
ma.messageWithSound(
|
ma.messageWithSound(
|
||||||
|
@ -280,10 +306,31 @@ class AjustesFragment :
|
||||||
}
|
}
|
||||||
loginViewModel.workerOperator.observe(this@AjustesFragment) { iti ->
|
loginViewModel.workerOperator.observe(this@AjustesFragment) { iti ->
|
||||||
runBlocking { mobileApplication.dataStoreApp.saveDataOperator(iti) }
|
runBlocking { mobileApplication.dataStoreApp.saveDataOperator(iti) }
|
||||||
|
}*/
|
||||||
|
handleUserCall()
|
||||||
|
loginViewModel.handleUserResponse.observe(this@AjustesFragment) { iti ->
|
||||||
|
runBlocking { mobileApplication.dataStoreApp.saveWorkerData(iti) }
|
||||||
}
|
}
|
||||||
setSettings()
|
setSettings()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun handleUserCall() {
|
||||||
|
val jsonData = mutableMapOf<String, Any>(
|
||||||
|
"androidId" to mobileApplication.androidId,
|
||||||
|
"nameApp" to getString(R.string.nameApp),
|
||||||
|
"versionApp" to getInfoVersionNameApp()
|
||||||
|
)
|
||||||
|
loginViewModel.handleUser(if (getDevicePDA() != null) {
|
||||||
|
jsonData.apply {
|
||||||
|
this["deviceId"] = getDevicePDA().toString() // Añadir nuevo campo
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
jsonData
|
||||||
|
}
|
||||||
|
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
private fun showMenuByDefault() {
|
private fun showMenuByDefault() {
|
||||||
|
|
||||||
pasilleroViewModel.inititializeDefaultDataInit()
|
pasilleroViewModel.inititializeDefaultDataInit()
|
||||||
|
@ -311,7 +358,8 @@ class AjustesFragment :
|
||||||
mobileApplication.dataStoreApp.readDataStoreKey<String>(ITEMPACKING),
|
mobileApplication.dataStoreApp.readDataStoreKey<String>(ITEMPACKING),
|
||||||
menuDefault = mobileApplication.dataStoreApp.readDataStoreKey(
|
menuDefault = mobileApplication.dataStoreApp.readDataStoreKey(
|
||||||
MENUBYDEFAULTSELECTED
|
MENUBYDEFAULTSELECTED
|
||||||
)
|
),
|
||||||
|
holdPosition = mobileApplication.dataStoreApp.readDataStoreKey<Boolean>(HOLDPOSITION),
|
||||||
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -483,6 +531,7 @@ class AjustesFragment :
|
||||||
labelerFk = id
|
labelerFk = id
|
||||||
)
|
)
|
||||||
settingsAdapter!!.notifyItemChanged(2)
|
settingsAdapter!!.notifyItemChanged(2)
|
||||||
|
handleUserCall()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,8 @@ class AjustesViewModel(val context: Context) : BaseViewModel(context) {
|
||||||
printerSelected: String,
|
printerSelected: String,
|
||||||
train: String?,
|
train: String?,
|
||||||
itemPackingType: String?,
|
itemPackingType: String?,
|
||||||
menuDefault: String
|
menuDefault: String,
|
||||||
|
holdPosition: Boolean = false
|
||||||
) {
|
) {
|
||||||
_settingsItem.clear()
|
_settingsItem.clear()
|
||||||
_settingsItem.add(
|
_settingsItem.add(
|
||||||
|
@ -99,6 +100,15 @@ class AjustesViewModel(val context: Context) : BaseViewModel(context) {
|
||||||
action = false
|
action = false
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
/*Tarea 5443
|
||||||
|
_settingsItem.add(
|
||||||
|
AjustesItemVO(
|
||||||
|
"Bajar línea al revisar",
|
||||||
|
holdPosition = holdPosition,
|
||||||
|
action = true
|
||||||
|
)
|
||||||
|
)*/
|
||||||
|
|
||||||
_settingsItem.add(
|
_settingsItem.add(
|
||||||
AjustesItemVO(
|
AjustesItemVO(
|
||||||
context.getString(R.string.vehicleControl), action = true
|
context.getString(R.string.vehicleControl), action = true
|
||||||
|
|
|
@ -8,7 +8,8 @@ class AjustesItemVO(
|
||||||
var sectorFk: Int? = null,
|
var sectorFk: Int? = null,
|
||||||
var printerFk: Int? = null,
|
var printerFk: Int? = null,
|
||||||
var printerSelected: String? = null,
|
var printerSelected: String? = null,
|
||||||
var action: Boolean
|
var action: Boolean,
|
||||||
|
var holdPosition: Boolean = false
|
||||||
)
|
)
|
||||||
|
|
||||||
class SectorItemVO(
|
class SectorItemVO(
|
||||||
|
@ -28,7 +29,7 @@ class PrintersList(
|
||||||
class Printers(
|
class Printers(
|
||||||
var id: Int,
|
var id: Int,
|
||||||
var name: String,
|
var name: String,
|
||||||
var sector:Sector?
|
var sector: Sector?
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue