Version 9.2.1 en producción. Borrada Voz y Ajustes impresora

This commit is contained in:
Sergio De la torre 2022-10-11 08:33:30 +02:00
parent 840abbcd2b
commit 841974a026
5 changed files with 204 additions and 214 deletions

View File

@ -13,8 +13,9 @@ android {
applicationId "es.verdnatura" applicationId "es.verdnatura"
minSdkVersion 21 //21 minSdkVersion 21 //21
targetSdkVersion 30 targetSdkVersion 30
versionCode 135 versionCode 136
versionName = "9.2.1Beta" versionName = "9.1"
//versionName = "9.2.1Beta" versioncode 135
//versionName = "9.2Beta" versionCode 133 //versionName = "9.2Beta" versionCode 133
//versionName = "9" versionCode 133 //versionName = "9" versionCode 133

View File

@ -6,13 +6,7 @@ import android.app.PendingIntent
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.content.SharedPreferences import android.content.SharedPreferences
import android.media.AudioManager
import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.speech.RecognitionListener
import android.speech.RecognizerIntent
import android.speech.SpeechRecognizer
import android.speech.tts.TextToSpeech
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
@ -28,8 +22,6 @@ import es.verdnatura.R
import es.verdnatura.databinding.ToolbarFragmentBinding import es.verdnatura.databinding.ToolbarFragmentBinding
import es.verdnatura.domain.ConstAndValues.SECTORFKDEFAULT import es.verdnatura.domain.ConstAndValues.SECTORFKDEFAULT
import es.verdnatura.domain.ConstAndValues.WAREHOUSEFKDEFAULT import es.verdnatura.domain.ConstAndValues.WAREHOUSEFKDEFAULT
import es.verdnatura.domain.toast
import es.verdnatura.presentation.common.mediaCurrentVolume
import es.verdnatura.presentation.view.feature.login.model.WorkForms import es.verdnatura.presentation.view.feature.login.model.WorkForms
import es.verdnatura.presentation.view.feature.main.activity.MainActivity import es.verdnatura.presentation.view.feature.main.activity.MainActivity
import org.json.JSONObject import org.json.JSONObject
@ -41,7 +33,7 @@ import kotlin.reflect.KClass
abstract class BaseFragment<T : ViewDataBinding, V : BaseViewModel>(viewModelClass: KClass<V>) : abstract class BaseFragment<T : ViewDataBinding, V : BaseViewModel>(viewModelClass: KClass<V>) :
Fragment(), TextToSpeech.OnInitListener, RecognitionListener { Fragment() {
protected val TAG = "VERDNATURA::" protected val TAG = "VERDNATURA::"
protected val PREFS_USER = "es.verdnatura.user.prefs" protected val PREFS_USER = "es.verdnatura.user.prefs"
@ -61,7 +53,7 @@ abstract class BaseFragment<T : ViewDataBinding, V : BaseViewModel>(viewModelCla
protected val DEVICENAME = "devicename" protected val DEVICENAME = "devicename"
protected val TRAINNAME = "trainName" protected val TRAINNAME = "trainName"
protected val TRAINFK = "trainFk" protected val TRAINFK = "trainFk"
protected val WORKFORMSELECTED="workFormSelected" protected val WORKFORMSELECTED = "workFormSelected"
protected val ITEMPACKING = "itemPackingType" protected val ITEMPACKING = "itemPackingType"
protected val ITEMPACKINGFK = "itemPackingTypeFk" protected val ITEMPACKINGFK = "itemPackingTypeFk"
@ -79,22 +71,23 @@ abstract class BaseFragment<T : ViewDataBinding, V : BaseViewModel>(viewModelCla
protected val viewModel: V by viewModel(viewModelClass) protected val viewModel: V by viewModel(viewModelClass)
protected lateinit var binding: T protected lateinit var binding: T
private var isOnReadyForSpeech = false
// private var isOnReadyForSpeech = false
protected lateinit var ma: MainActivity protected lateinit var ma: MainActivity
private var textToSpeech: TextToSpeech? = null /* private var textToSpeech: TextToSpeech? = null
private var mAudioManager: AudioManager? = null private var mAudioManager: AudioManager? = null
protected var mSpeechRecognizer: SpeechRecognizer? = null protected var mSpeechRecognizer: SpeechRecognizer? = null
private var mSpeechRecognizerIntent: Intent? = null private var mSpeechRecognizerIntent: Intent? = null*/
protected val NEW_COLLECTION = 0 /* protected val NEW_COLLECTION = 0
protected val LISTO = 1 protected val LISTO = 1
protected val CANCEL = 2 protected val CANCEL = 2
protected val VOLVER = 3 protected val VOLVER = 3
protected val REPITE = 4 protected val REPITE = 4
protected val OTRO = 5 protected val OTRO = 5
protected val FALTA = 6 protected val FALTA = 6
protected val ERROR = -1 protected val ERROR = -1*/
/*val allowedStrings = /*val allowedStrings =
@ -140,7 +133,7 @@ abstract class BaseFragment<T : ViewDataBinding, V : BaseViewModel>(viewModelCla
initDataBinding() initDataBinding()
getBundleArguments() getBundleArguments()
observeViewModel() observeViewModel()
runSound() //runSound()
//requestRecordAudioPermission() //requestRecordAudioPermission()
//requestRecordAudioPermissionNew() //requestRecordAudioPermissionNew()
@ -158,11 +151,11 @@ abstract class BaseFragment<T : ViewDataBinding, V : BaseViewModel>(viewModelCla
open fun getBundleArguments() {} open fun getBundleArguments() {}
open fun addBindingVariables() {} open fun addBindingVariables() {}
open fun setSpeak() { /*open fun setSpeak() {
//VOZ //VOZ
textToSpeech = TextToSpeech(requireContext(), this) // textToSpeech = TextToSpeech(requireContext(), this)
mAudioManager = requireActivity().getSystemService(Context.AUDIO_SERVICE) as AudioManager // mAudioManager = requireActivity().getSystemService(Context.AUDIO_SERVICE) as AudioManager
} }*/
open fun restartapp(f: Fragment) { open fun restartapp(f: Fragment) {
val mStartActivity = Intent(context, f::class.java) val mStartActivity = Intent(context, f::class.java)
@ -179,7 +172,7 @@ abstract class BaseFragment<T : ViewDataBinding, V : BaseViewModel>(viewModelCla
} }
open fun initialize() { /* open fun initialize() {
//ESCUCHA //ESCUCHA
try { try {
mSpeechRecognizer = SpeechRecognizer.createSpeechRecognizer(requireContext()) mSpeechRecognizer = SpeechRecognizer.createSpeechRecognizer(requireContext())
@ -200,7 +193,7 @@ abstract class BaseFragment<T : ViewDataBinding, V : BaseViewModel>(viewModelCla
cancelSpeech() cancelSpeech()
} }
} }*/
private fun initDataBinding() { private fun initDataBinding() {
binding = DataBindingUtil.bind<T>(requireView())!! binding = DataBindingUtil.bind<T>(requireView())!!
@ -261,14 +254,14 @@ abstract class BaseFragment<T : ViewDataBinding, V : BaseViewModel>(viewModelCla
R.drawable.ic_flash_auto_black_24dp -> getString(R.string.allowAutomaticAddItem) R.drawable.ic_flash_auto_black_24dp -> getString(R.string.allowAutomaticAddItem)
R.drawable.ic_logo_salix -> getString(R.string.accessSalix) R.drawable.ic_logo_salix -> getString(R.string.accessSalix)
R.drawable.ic_eye_ui -> getString(R.string.icViewCollection) R.drawable.ic_eye_ui -> getString(R.string.icViewCollection)
R.drawable.ic_collection->getString(R.string.icViewCollection) R.drawable.ic_collection -> getString(R.string.icViewCollection)
else -> { else -> {
"" ""
} }
} }
} }
/*
override fun onInit(status: Int) { override fun onInit(status: Int) {
/* if (status == TextToSpeech.SUCCESS) { /* if (status == TextToSpeech.SUCCESS) {
val spanish = Locale("es", "ES") val spanish = Locale("es", "ES")
@ -301,28 +294,28 @@ abstract class BaseFragment<T : ViewDataBinding, V : BaseViewModel>(viewModelCla
"La voz no se ha podido iniciar".toast(requireContext()) "La voz no se ha podido iniciar".toast(requireContext())
}*/ }*/
} }
*/
private fun runSound() { /* private fun runSound() {
// Get the maximum media/music volume // Get the maximum media/music volume
//sergio: se quita por no utilizar //sergio: se quita por no utilizar
// val maxVolume = mAudioManager?.mediaMaxVolume // val maxVolume = mAudioManager?.mediaMaxVolume
// mAudioManager?.setMediaVolume(maxVolume!!) // mAudioManager?.setMediaVolume(maxVolume!!)
} }*/
private fun muteSound() { /* private fun muteSound() {
if (mAudioManager?.mediaCurrentVolume != 0) { if (mAudioManager?.mediaCurrentVolume != 0) {
// mAudioManager?.setMediaVolume(0) // mAudioManager?.setMediaVolume(0)
} }
} }*/
fun speak(frase: String) { /* fun speak(frase: String) {
textToSpeech!!.speak(frase, TextToSpeech.QUEUE_FLUSH, null, "frase") textToSpeech!!.speak(frase, TextToSpeech.QUEUE_FLUSH, null, "frase")
} }
open fun startListening() { open fun startListening() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
muteSound() //muteSound()
} }
mSpeechRecognizer!!.startListening(mSpeechRecognizerIntent) mSpeechRecognizer!!.startListening(mSpeechRecognizerIntent)
} }
@ -355,7 +348,7 @@ abstract class BaseFragment<T : ViewDataBinding, V : BaseViewModel>(viewModelCla
//Log.i("Speech", "onError " + error) //Log.i("Speech", "onError " + error)
if (mSpeechRecognizer != null) mSpeechRecognizer!!.destroy() if (mSpeechRecognizer != null) mSpeechRecognizer!!.destroy()
mSpeechRecognizer = null mSpeechRecognizer = null
initialize() //initialize()
} }
} }
@ -366,11 +359,13 @@ abstract class BaseFragment<T : ViewDataBinding, V : BaseViewModel>(viewModelCla
//Log.i("Speech", "onPartialResults") //Log.i("Speech", "onPartialResults")
} }
override fun onEvent(eventType: Int, params: Bundle?) { override fun onEvent(eventType: Int, params: Bundle?) {
//Log.i("Speech", "onEvent") //Log.i("Speech", "onEvent")
} }*/
open fun checkText(text: String): Int { /* open fun checkText(text: String): Int {
//check for nuevo //check for nuevo
val nuevo = getMatch(text, "nuevo") val nuevo = getMatch(text, "nuevo")
@ -434,7 +429,7 @@ abstract class BaseFragment<T : ViewDataBinding, V : BaseViewModel>(viewModelCla
return count * 100 / numChar return count * 100 / numChar
else else
return 100 return 100
} }*/
/* private fun requestReadPhoneStatePermission(){ /* private fun requestReadPhoneStatePermission(){
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
@ -513,12 +508,12 @@ abstract class BaseFragment<T : ViewDataBinding, V : BaseViewModel>(viewModelCla
tool.backButton.visibility = View.INVISIBLE tool.backButton.visibility = View.INVISIBLE
} }
fun cancelSpeech() { /* fun cancelSpeech() {
if (mSpeechRecognizer != null) { if (mSpeechRecognizer != null) {
mSpeechRecognizer!!.destroy() mSpeechRecognizer!!.destroy()
mSpeechRecognizer = null mSpeechRecognizer = null
} }
} }*/
private fun getDefaults(key: String?, context: Context?): String? { private fun getDefaults(key: String?, context: Context?): String? {
val preferences = PreferenceManager.getDefaultSharedPreferences(context) val preferences = PreferenceManager.getDefaultSharedPreferences(context)
@ -551,7 +546,7 @@ abstract class BaseFragment<T : ViewDataBinding, V : BaseViewModel>(viewModelCla
TRAINNAME -> prefs.getString(name, "").toString() TRAINNAME -> prefs.getString(name, "").toString()
ITEMPACKING -> prefs.getString(name, "").toString() ITEMPACKING -> prefs.getString(name, "").toString()
ITEMPACKINGFK -> prefs.getString(name, "").toString() ITEMPACKINGFK -> prefs.getString(name, "").toString()
WORKFORMSELECTED->prefs.getString(name, "Producción").toString() WORKFORMSELECTED -> prefs.getString(name, "Producción").toString()
"base_url" -> { "base_url" -> {
@ -612,6 +607,7 @@ abstract class BaseFragment<T : ViewDataBinding, V : BaseViewModel>(viewModelCla
editor.remove(nameWorkForm).commit() editor.remove(nameWorkForm).commit()
} }
fun getWorkForm(): List<WorkForms> { fun getWorkForm(): List<WorkForms> {
var listForms: ArrayList<WorkForms> = ArrayList() var listForms: ArrayList<WorkForms> = ArrayList()
val prefs: SharedPreferences = requireActivity().getSharedPreferences(PREFS_SERVER, 0) val prefs: SharedPreferences = requireActivity().getSharedPreferences(PREFS_SERVER, 0)
@ -659,7 +655,7 @@ abstract class BaseFragment<T : ViewDataBinding, V : BaseViewModel>(viewModelCla
urlSalix = "https://test-salix.verdnatura.es/api/" urlSalix = "https://test-salix.verdnatura.es/api/"
) )
) )
/*saveWorkForm( /* saveWorkForm(
WorkForms( WorkForms(
"TestLocalhost", "TestLocalhost",
"http://10.1.4.42:9000", "http://10.1.4.42:9000",
@ -679,7 +675,7 @@ abstract class BaseFragment<T : ViewDataBinding, V : BaseViewModel>(viewModelCla
"Añadir...", "Añadir...",
"", "",
"", "",
created = Calendar.getInstance().timeInMillis+Calendar.getInstance().timeInMillis created = Calendar.getInstance().timeInMillis + Calendar.getInstance().timeInMillis
) )

View File

@ -7,6 +7,7 @@ import android.content.Context.CLIPBOARD_SERVICE
import android.content.SharedPreferences import android.content.SharedPreferences
import android.os.Bundle import android.os.Bundle
import android.view.View import android.view.View
import android.view.View.VISIBLE
import androidx.appcompat.widget.TooltipCompat.setTooltipText import androidx.appcompat.widget.TooltipCompat.setTooltipText
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import es.verdnatura.R import es.verdnatura.R
@ -62,7 +63,6 @@ class AjustesFragment :
hideBackButton(binding.mainToolbar) hideBackButton(binding.mainToolbar)
viewModel.worker_isF11Allowed(getData(USER), getData(PASSWORD)) viewModel.worker_isF11Allowed(getData(USER), getData(PASSWORD))
binding.userText.setText(getData(USER)) binding.userText.setText(getData(USER))
val versionName = requireActivity().packageManager.getPackageInfo( val versionName = requireActivity().packageManager.getPackageInfo(
requireActivity().packageName, requireActivity().packageName,
@ -203,6 +203,7 @@ class AjustesFragment :
} }
setSettings(isWorkerAllowed) setSettings(isWorkerAllowed)
} }
actionUpdate.observe(viewLifecycleOwner) { actionUpdate.observe(viewLifecycleOwner) {
@ -213,6 +214,12 @@ class AjustesFragment :
getString(R.string.itemUpdated) getString(R.string.itemUpdated)
}, it.isError, false }, it.isError, false
) )
binding.splashProgress.visibility = VISIBLE
viewModel.printer_get(getData(USER), getData(PASSWORD))
// viewModel.worker_isF11Allowed(getData(USER), getData(PASSWORD))
} }
workerupdatePrinter.observe(viewLifecycleOwner) { workerupdatePrinter.observe(viewLifecycleOwner) {
@ -378,7 +385,6 @@ class AjustesFragment :
private fun showDialogPrinters(array: Array<String>) { private fun showDialogPrinters(array: Array<String>) {
val builder = AlertDialog.Builder(this.context) val builder = AlertDialog.Builder(this.context)
builder.setTitle(getString(R.string.Selecccionaimpresoara)) builder.setTitle(getString(R.string.Selecccionaimpresoara))
builder.setItems(array) { _, which -> builder.setItems(array) { _, which ->
val selected = array[which] val selected = array[which]
@ -448,6 +454,12 @@ class AjustesFragment :
val selected = array[which] val selected = array[which]
sectorListVO.forEach { sectorListVO.forEach {
if (it.description.equals(selected)) { if (it.description.equals(selected)) {
//borra la impresora
viewModel.ajustesitem.get(2).selected = getString(R.string.noprinter)
saveData(PRINTERNAME, getString(R.string.noprinter))
saveDataInt(PRINTERFK, -1)
val editor = prefs!!.edit() val editor = prefs!!.edit()
editor.putString(SECTORDESCRIP, it.description) editor.putString(SECTORDESCRIP, it.description)
editor.putInt(SECTORFK, it.id) editor.putInt(SECTORFK, it.id)
@ -555,19 +567,6 @@ class AjustesFragment :
} }
/* fun setDefaults(key: String?, value: String?, context: Context?) {
val preferences: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
val editor = preferences.edit()
editor.putString(key, value)
editor.commit()
}*/
/* private fun getDefaults(key: String?, context: Context?): String? {
val preferences = PreferenceManager.getDefaultSharedPreferences(context)
return preferences.getString(key, null)
}*/
private fun copyanddrag(string: String): Boolean { private fun copyanddrag(string: String): Boolean {
val clipboard = getActivity()?.getSystemService(CLIPBOARD_SERVICE) as ClipboardManager val clipboard = getActivity()?.getSystemService(CLIPBOARD_SERVICE) as ClipboardManager
val clip: ClipData = ClipData.newPlainText(getString(R.string.androidid), string) val clip: ClipData = ClipData.newPlainText(getString(R.string.androidid), string)

View File

@ -1001,14 +1001,8 @@ class CollectionFragment(
//CREATE LIST //CREATE LIST
private fun createCollectionList() { private fun createCollectionList() {
state = 0 state = 0
/* if (type == SACADOR && getData(VOZ) != "NO") {
// initialize()
speak("Colección cargada, diga listo para empezar.")
}*/
binding.mainToolbar.toolbarTitle.text = collection.collectionFk binding.mainToolbar.toolbarTitle.text = collection.collectionFk
binding.splashProgress.visibility = View.GONE binding.splashProgress.visibility = View.GONE
var salesList: ArrayList<SaleVO> = ArrayList() var salesList: ArrayList<SaleVO> = ArrayList()
tickets = ArrayList() tickets = ArrayList()
@ -1656,7 +1650,7 @@ class CollectionFragment(
.setHintValueTwo(getString(R.string.scanItem)) .setHintValueTwo(getString(R.string.scanItem))
.setValueTwo("").show() .setValueTwo("").show()
} catch (e: Exception) { } catch (e: Exception) {
//////Log.i("VERDNATURA:","${e.message.toString()}")
} }
try { try {
customDialogList.getEditTextTwo().post(Runnable { customDialogList.getEditTextTwo().post(Runnable {
@ -2775,7 +2769,7 @@ class CollectionFragment(
} }
//VOZ //VOZ
override fun onResults(results: Bundle) { /* override fun onResults(results: Bundle) {
super.onResults(results) super.onResults(results)
//Log.i("Speech", "onResults") //Log.i("Speech", "onResults")
val matches = results val matches = results
@ -2786,9 +2780,9 @@ class CollectionFragment(
mSpeechRecognizer!!.cancel() mSpeechRecognizer!!.cancel()
getText(matches[0]) getText(matches[0])
} }
} }*/
private fun getText(text: String) { /* private fun getText(text: String) {
val pos = checkText(text) val pos = checkText(text)
when (pos) { when (pos) {
NEW_COLLECTION -> { NEW_COLLECTION -> {
@ -2814,7 +2808,7 @@ class CollectionFragment(
// speak("Orden no registrada") // speak("Orden no registrada")
} }
} }
} }*/
/*private fun speakOrder() { /*private fun speakOrder() {
if (type == SACADOR) { if (type == SACADOR) {
@ -2951,9 +2945,9 @@ class CollectionFragment(
} }
}*/ }*/
override fun onDestroy() { /* override fun onDestroy() {
cancelSpeech() //cancelSpeech()
super.onDestroy() super.onDestroy()
} }*/
} }

View File

@ -250,7 +250,7 @@ class PasilleroViewModel(context: Context) : BaseViewModel() {
) )
//Tarea 3335 Borrat proced(Carles) //Tarea 3335 Borrat proced(Carles)
/* _pasillerositem.add( /* _pasillerositem.add(
PasillerosItemVO( PasillerosItemVO(
8, 8,
R.drawable.ic_baseline_star_24, R.drawable.ic_baseline_star_24,