diff --git a/app/build.gradle b/app/build.gradle index 967764be..df4461c2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -13,8 +13,9 @@ android { applicationId "es.verdnatura" minSdkVersion 21 //21 targetSdkVersion 30 - versionCode 135 - versionName = "9.2.1Beta" + versionCode 136 + versionName = "9.1" + //versionName = "9.2.1Beta" versioncode 135 //versionName = "9.2Beta" versionCode 133 //versionName = "9" versionCode 133 diff --git a/app/src/main/java/es/verdnatura/presentation/base/BaseFragment.kt b/app/src/main/java/es/verdnatura/presentation/base/BaseFragment.kt index 5e0b4d12..59d96591 100644 --- a/app/src/main/java/es/verdnatura/presentation/base/BaseFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/base/BaseFragment.kt @@ -6,13 +6,7 @@ import android.app.PendingIntent import android.content.Context import android.content.Intent import android.content.SharedPreferences -import android.media.AudioManager -import android.os.Build 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.View import android.view.ViewGroup @@ -28,8 +22,6 @@ import es.verdnatura.R import es.verdnatura.databinding.ToolbarFragmentBinding import es.verdnatura.domain.ConstAndValues.SECTORFKDEFAULT 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.main.activity.MainActivity import org.json.JSONObject @@ -41,7 +33,7 @@ import kotlin.reflect.KClass abstract class BaseFragment(viewModelClass: KClass) : - Fragment(), TextToSpeech.OnInitListener, RecognitionListener { + Fragment() { protected val TAG = "VERDNATURA::" protected val PREFS_USER = "es.verdnatura.user.prefs" @@ -61,7 +53,7 @@ abstract class BaseFragment(viewModelCla protected val DEVICENAME = "devicename" protected val TRAINNAME = "trainName" protected val TRAINFK = "trainFk" - protected val WORKFORMSELECTED="workFormSelected" + protected val WORKFORMSELECTED = "workFormSelected" protected val ITEMPACKING = "itemPackingType" protected val ITEMPACKINGFK = "itemPackingTypeFk" @@ -79,22 +71,23 @@ abstract class BaseFragment(viewModelCla protected val viewModel: V by viewModel(viewModelClass) protected lateinit var binding: T - private var isOnReadyForSpeech = false + + // private var isOnReadyForSpeech = false protected lateinit var ma: MainActivity - private var textToSpeech: TextToSpeech? = null - private var mAudioManager: AudioManager? = null - protected var mSpeechRecognizer: SpeechRecognizer? = null - private var mSpeechRecognizerIntent: Intent? = null + /* private var textToSpeech: TextToSpeech? = null + private var mAudioManager: AudioManager? = null + protected var mSpeechRecognizer: SpeechRecognizer? = null + private var mSpeechRecognizerIntent: Intent? = null*/ - protected val NEW_COLLECTION = 0 - protected val LISTO = 1 - protected val CANCEL = 2 - protected val VOLVER = 3 - protected val REPITE = 4 - protected val OTRO = 5 - protected val FALTA = 6 - protected val ERROR = -1 + /* protected val NEW_COLLECTION = 0 + protected val LISTO = 1 + protected val CANCEL = 2 + protected val VOLVER = 3 + protected val REPITE = 4 + protected val OTRO = 5 + protected val FALTA = 6 + protected val ERROR = -1*/ /*val allowedStrings = @@ -140,7 +133,7 @@ abstract class BaseFragment(viewModelCla initDataBinding() getBundleArguments() observeViewModel() - runSound() + //runSound() //requestRecordAudioPermission() //requestRecordAudioPermissionNew() @@ -158,11 +151,11 @@ abstract class BaseFragment(viewModelCla open fun getBundleArguments() {} open fun addBindingVariables() {} - open fun setSpeak() { + /*open fun setSpeak() { //VOZ - textToSpeech = TextToSpeech(requireContext(), this) - mAudioManager = requireActivity().getSystemService(Context.AUDIO_SERVICE) as AudioManager - } + // textToSpeech = TextToSpeech(requireContext(), this) + // mAudioManager = requireActivity().getSystemService(Context.AUDIO_SERVICE) as AudioManager + }*/ open fun restartapp(f: Fragment) { val mStartActivity = Intent(context, f::class.java) @@ -179,28 +172,28 @@ abstract class BaseFragment(viewModelCla } - open fun initialize() { - //ESCUCHA - try { - mSpeechRecognizer = SpeechRecognizer.createSpeechRecognizer(requireContext()) - mSpeechRecognizerIntent = Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH) - mSpeechRecognizerIntent!!.putExtra( - RecognizerIntent.EXTRA_LANGUAGE_MODEL, - RecognizerIntent.LANGUAGE_MODEL_FREE_FORM - ) - mSpeechRecognizerIntent!!.putExtra( - RecognizerIntent.EXTRA_LANGUAGE, - Locale.getDefault() - ) - mSpeechRecognizerIntent!!.putExtra(RecognizerIntent.EXTRA_PREFER_OFFLINE, false) - mSpeechRecognizer?.setRecognitionListener(this) - isOnReadyForSpeech = false - startListening() - } catch (e: Exception) { - cancelSpeech() - } + /* open fun initialize() { + //ESCUCHA + try { + mSpeechRecognizer = SpeechRecognizer.createSpeechRecognizer(requireContext()) + mSpeechRecognizerIntent = Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH) + mSpeechRecognizerIntent!!.putExtra( + RecognizerIntent.EXTRA_LANGUAGE_MODEL, + RecognizerIntent.LANGUAGE_MODEL_FREE_FORM + ) + mSpeechRecognizerIntent!!.putExtra( + RecognizerIntent.EXTRA_LANGUAGE, + Locale.getDefault() + ) + mSpeechRecognizerIntent!!.putExtra(RecognizerIntent.EXTRA_PREFER_OFFLINE, false) + mSpeechRecognizer?.setRecognitionListener(this) + isOnReadyForSpeech = false + startListening() + } catch (e: Exception) { + cancelSpeech() + } - } + }*/ private fun initDataBinding() { binding = DataBindingUtil.bind(requireView())!! @@ -261,14 +254,14 @@ abstract class BaseFragment(viewModelCla R.drawable.ic_flash_auto_black_24dp -> getString(R.string.allowAutomaticAddItem) R.drawable.ic_logo_salix -> getString(R.string.accessSalix) 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 -> { "" } } } - +/* override fun onInit(status: Int) { /* if (status == TextToSpeech.SUCCESS) { val spanish = Locale("es", "ES") @@ -301,28 +294,28 @@ abstract class BaseFragment(viewModelCla "La voz no se ha podido iniciar".toast(requireContext()) }*/ } +*/ + /* private fun runSound() { + // Get the maximum media/music volume + //sergio: se quita por no utilizar + // val maxVolume = mAudioManager?.mediaMaxVolume + // mAudioManager?.setMediaVolume(maxVolume!!) + }*/ - private fun runSound() { - // Get the maximum media/music volume - //sergio: se quita por no utilizar - // val maxVolume = mAudioManager?.mediaMaxVolume - // mAudioManager?.setMediaVolume(maxVolume!!) - } + /* private fun muteSound() { + if (mAudioManager?.mediaCurrentVolume != 0) { + // mAudioManager?.setMediaVolume(0) + } - private fun muteSound() { - if (mAudioManager?.mediaCurrentVolume != 0) { - // mAudioManager?.setMediaVolume(0) - } + }*/ - } - - fun speak(frase: String) { + /* fun speak(frase: String) { textToSpeech!!.speak(frase, TextToSpeech.QUEUE_FLUSH, null, "frase") } - open fun startListening() { + open fun startListening() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { - muteSound() + //muteSound() } mSpeechRecognizer!!.startListening(mSpeechRecognizerIntent) } @@ -355,7 +348,7 @@ abstract class BaseFragment(viewModelCla //Log.i("Speech", "onError " + error) if (mSpeechRecognizer != null) mSpeechRecognizer!!.destroy() mSpeechRecognizer = null - initialize() + //initialize() } } @@ -366,75 +359,77 @@ abstract class BaseFragment(viewModelCla //Log.i("Speech", "onPartialResults") } + + override fun onEvent(eventType: Int, params: Bundle?) { //Log.i("Speech", "onEvent") - } + }*/ - open fun checkText(text: String): Int { + /* open fun checkText(text: String): Int { - //check for nuevo - val nuevo = getMatch(text, "nuevo") + //check for nuevo + val nuevo = getMatch(text, "nuevo") - //check for listo - val listo = getMatch(text, "listo") + //check for listo + val listo = getMatch(text, "listo") - //check for cancelar - val cancelar = getMatch(text, getString(R.string.cancel)) + //check for cancelar + val cancelar = getMatch(text, getString(R.string.cancel)) - //check for volver - val volver = getMatch(text, "volver") + //check for volver + val volver = getMatch(text, "volver") - //check for repite - val repite = getMatch(text, "repite") + //check for repite + val repite = getMatch(text, "repite") - //check for siguiente - val otro = getMatch(text, "otro") + //check for siguiente + val otro = getMatch(text, "otro") - //check for FALTA - val falta = getMatch(text, "falta") - val words = IntArray(7) - words[0] = nuevo - words[1] = listo - words[2] = cancelar - words[3] = volver - words[4] = repite - words[5] = otro - words[6] = falta - return getMax(words) - } + //check for FALTA + val falta = getMatch(text, "falta") + val words = IntArray(7) + words[0] = nuevo + words[1] = listo + words[2] = cancelar + words[3] = volver + words[4] = repite + words[5] = otro + words[6] = falta + return getMax(words) + } - private fun getMax(a: IntArray): Int { - var max = a[0] - var pos = 0 - for (i in a.indices) { - if (a[i] > max) { - max = a[i] - pos = i - } - } - return if (max < 80) { - -1 - } else pos - } + private fun getMax(a: IntArray): Int { + var max = a[0] + var pos = 0 + for (i in a.indices) { + if (a[i] > max) { + max = a[i] + pos = i + } + } + return if (max < 80) { + -1 + } else pos + } - private fun getMatch(a: String, b: String): Int { - var count = 0 - val cha = a.toCharArray() - val chb = b.toCharArray() - for (i in cha) { - for (x in chb) { - if (x == i) { - count += 1 - break - } - } - } - val numChar = a.length - if (numChar != 0) - return count * 100 / numChar - else - return 100 - } + private fun getMatch(a: String, b: String): Int { + var count = 0 + val cha = a.toCharArray() + val chb = b.toCharArray() + for (i in cha) { + for (x in chb) { + if (x == i) { + count += 1 + break + } + } + } + val numChar = a.length + if (numChar != 0) + return count * 100 / numChar + else + return 100 + }*/ /* private fun requestReadPhoneStatePermission(){ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { @@ -513,12 +508,12 @@ abstract class BaseFragment(viewModelCla tool.backButton.visibility = View.INVISIBLE } - fun cancelSpeech() { - if (mSpeechRecognizer != null) { - mSpeechRecognizer!!.destroy() - mSpeechRecognizer = null - } - } + /* fun cancelSpeech() { + if (mSpeechRecognizer != null) { + mSpeechRecognizer!!.destroy() + mSpeechRecognizer = null + } + }*/ private fun getDefaults(key: String?, context: Context?): String? { val preferences = PreferenceManager.getDefaultSharedPreferences(context) @@ -551,7 +546,7 @@ abstract class BaseFragment(viewModelCla TRAINNAME -> prefs.getString(name, "").toString() ITEMPACKING -> 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" -> { @@ -612,6 +607,7 @@ abstract class BaseFragment(viewModelCla editor.remove(nameWorkForm).commit() } + fun getWorkForm(): List { var listForms: ArrayList = ArrayList() val prefs: SharedPreferences = requireActivity().getSharedPreferences(PREFS_SERVER, 0) @@ -659,7 +655,7 @@ abstract class BaseFragment(viewModelCla urlSalix = "https://test-salix.verdnatura.es/api/" ) ) - /*saveWorkForm( + /* saveWorkForm( WorkForms( "TestLocalhost", "http://10.1.4.42:9000", @@ -674,12 +670,12 @@ abstract class BaseFragment(viewModelCla ) )*/ - saveWorkForm( + saveWorkForm( WorkForms( "Añadir...", "", "", - created = Calendar.getInstance().timeInMillis+Calendar.getInstance().timeInMillis + created = Calendar.getInstance().timeInMillis + Calendar.getInstance().timeInMillis ) 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 c7e9ef6e..bf556cc0 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 @@ -7,6 +7,7 @@ import android.content.Context.CLIPBOARD_SERVICE import android.content.SharedPreferences import android.os.Bundle import android.view.View +import android.view.View.VISIBLE import androidx.appcompat.widget.TooltipCompat.setTooltipText import androidx.recyclerview.widget.LinearLayoutManager import es.verdnatura.R @@ -62,7 +63,6 @@ class AjustesFragment : hideBackButton(binding.mainToolbar) viewModel.worker_isF11Allowed(getData(USER), getData(PASSWORD)) - binding.userText.setText(getData(USER)) val versionName = requireActivity().packageManager.getPackageInfo( requireActivity().packageName, @@ -203,6 +203,7 @@ class AjustesFragment : } setSettings(isWorkerAllowed) + } actionUpdate.observe(viewLifecycleOwner) { @@ -213,6 +214,12 @@ class AjustesFragment : getString(R.string.itemUpdated) }, it.isError, false ) + + binding.splashProgress.visibility = VISIBLE + viewModel.printer_get(getData(USER), getData(PASSWORD)) + // viewModel.worker_isF11Allowed(getData(USER), getData(PASSWORD)) + + } workerupdatePrinter.observe(viewLifecycleOwner) { @@ -378,7 +385,6 @@ class AjustesFragment : private fun showDialogPrinters(array: Array) { val builder = AlertDialog.Builder(this.context) - builder.setTitle(getString(R.string.Selecccionaimpresoara)) builder.setItems(array) { _, which -> val selected = array[which] @@ -448,6 +454,12 @@ class AjustesFragment : val selected = array[which] sectorListVO.forEach { 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() editor.putString(SECTORDESCRIP, it.description) 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 { val clipboard = getActivity()?.getSystemService(CLIPBOARD_SERVICE) as ClipboardManager val clip: ClipData = ClipData.newPlainText(getString(R.string.androidid), string) diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragment.kt index 55dff078..b9659621 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragment.kt @@ -1001,14 +1001,8 @@ class CollectionFragment( //CREATE LIST private fun createCollectionList() { state = 0 - /* if (type == SACADOR && getData(VOZ) != "NO") { - // initialize() - speak("Colección cargada, diga listo para empezar.") - }*/ - binding.mainToolbar.toolbarTitle.text = collection.collectionFk - binding.splashProgress.visibility = View.GONE var salesList: ArrayList = ArrayList() tickets = ArrayList() @@ -1656,7 +1650,7 @@ class CollectionFragment( .setHintValueTwo(getString(R.string.scanItem)) .setValueTwo("").show() } catch (e: Exception) { - //////Log.i("VERDNATURA:","${e.message.toString()}") + } try { customDialogList.getEditTextTwo().post(Runnable { @@ -2775,7 +2769,7 @@ class CollectionFragment( } //VOZ - override fun onResults(results: Bundle) { + /* override fun onResults(results: Bundle) { super.onResults(results) //Log.i("Speech", "onResults") val matches = results @@ -2786,9 +2780,9 @@ class CollectionFragment( mSpeechRecognizer!!.cancel() getText(matches[0]) } - } + }*/ - private fun getText(text: String) { + /* private fun getText(text: String) { val pos = checkText(text) when (pos) { NEW_COLLECTION -> { @@ -2814,7 +2808,7 @@ class CollectionFragment( // speak("Orden no registrada") } } - } + }*/ /*private fun speakOrder() { if (type == SACADOR) { @@ -2951,9 +2945,9 @@ class CollectionFragment( } }*/ - override fun onDestroy() { - cancelSpeech() + /* override fun onDestroy() { + //cancelSpeech() super.onDestroy() - } + }*/ } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/pasillero/fragment/PasilleroViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/pasillero/fragment/PasilleroViewModel.kt index aa4e7d4a..5390dd4f 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/pasillero/fragment/PasilleroViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/pasillero/fragment/PasilleroViewModel.kt @@ -120,17 +120,17 @@ class PasilleroViewModel(context: Context) : BaseViewModel() { ) //Tarea #3754 --> Falta arreglar la colección que se le pasa a ReubicationCollectionFragment - _pasillerositem.add( - PasillerosItemVO( - 1, - R.drawable.ic_reubication, - contextApp.getString(R.string.titleReUbicator), - R.string.titleReUbicator, - contextApp.getString( - R.string.titleReubicatorDescrip - ) - ) - ) + _pasillerositem.add( + PasillerosItemVO( + 1, + R.drawable.ic_reubication, + contextApp.getString(R.string.titleReUbicator), + R.string.titleReUbicator, + contextApp.getString( + R.string.titleReubicatorDescrip + ) + ) + ) _pasillerositem.add( PasillerosItemVO( @@ -156,17 +156,17 @@ class PasilleroViewModel(context: Context) : BaseViewModel() { ) ) //Tarea 4585 - /* _pasillerositem.add( - PasillerosItemVO( - 7, - R.drawable.ic_packing_mistake, - contextApp.getString(R.string.titlePackingMistake), - R.string.titlePackingMistake, - contextApp.getString( - R.string.titlePackingMistakeDescrip + /* _pasillerositem.add( + PasillerosItemVO( + 7, + R.drawable.ic_packing_mistake, + contextApp.getString(R.string.titlePackingMistake), + R.string.titlePackingMistake, + contextApp.getString( + R.string.titlePackingMistakeDescrip + ) ) - ) - )*/ + )*/ _pasillerositem.add( PasillerosItemVO( @@ -250,17 +250,17 @@ class PasilleroViewModel(context: Context) : BaseViewModel() { ) //Tarea 3335 Borrat proced(Carles) - /* _pasillerositem.add( - PasillerosItemVO( - 8, - R.drawable.ic_baseline_star_24, - contextApp.getString(R.string.titleQuality), - R.string.titleQuality, - contextApp.getString( - R.string.titleQualityDescrip - ) +/* _pasillerositem.add( + PasillerosItemVO( + 8, + R.drawable.ic_baseline_star_24, + contextApp.getString(R.string.titleQuality), + R.string.titleQuality, + contextApp.getString( + R.string.titleQualityDescrip ) - )*/ + ) + )*/ } @@ -313,15 +313,15 @@ class PasilleroViewModel(context: Context) : BaseViewModel() { ) //Tarea #3986 - /* _pasillerositem.add( - PasillerosItemVO( - 31, - R.drawable.ic_cmr, - contextApp.getString(R.string.titleCMRState), - R.string.titleCMRState, - contextApp.getString(R.string.titleCMRDescrip) - ) - )*/ + /* _pasillerositem.add( + PasillerosItemVO( + 31, + R.drawable.ic_cmr, + contextApp.getString(R.string.titleCMRState), + R.string.titleCMRState, + contextApp.getString(R.string.titleCMRDescrip) + ) + )*/ _pasillerositem.add( PasillerosItemVO( 40, @@ -502,15 +502,15 @@ class PasilleroViewModel(context: Context) : BaseViewModel() { 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) - ) - )} + _pasillerositem.add( + PasillerosItemVO( + 6, + R.drawable.ic_star_ko, + contextApp.getString(R.string.testing), + R.string.testing, + contextApp.getString(R.string.testing) + ) + )} }