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"
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

View File

@ -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<T : ViewDataBinding, V : BaseViewModel>(viewModelClass: KClass<V>) :
Fragment(), TextToSpeech.OnInitListener, RecognitionListener {
Fragment() {
protected val TAG = "VERDNATURA::"
protected val PREFS_USER = "es.verdnatura.user.prefs"
@ -79,22 +71,23 @@ abstract class BaseFragment<T : ViewDataBinding, V : BaseViewModel>(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 textToSpeech: TextToSpeech? = null
private var mAudioManager: AudioManager? = 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 CANCEL = 2
protected val VOLVER = 3
protected val REPITE = 4
protected val OTRO = 5
protected val FALTA = 6
protected val ERROR = -1
protected val ERROR = -1*/
/*val allowedStrings =
@ -140,7 +133,7 @@ abstract class BaseFragment<T : ViewDataBinding, V : BaseViewModel>(viewModelCla
initDataBinding()
getBundleArguments()
observeViewModel()
runSound()
//runSound()
//requestRecordAudioPermission()
//requestRecordAudioPermissionNew()
@ -158,11 +151,11 @@ abstract class BaseFragment<T : ViewDataBinding, V : BaseViewModel>(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,7 +172,7 @@ abstract class BaseFragment<T : ViewDataBinding, V : BaseViewModel>(viewModelCla
}
open fun initialize() {
/* open fun initialize() {
//ESCUCHA
try {
mSpeechRecognizer = SpeechRecognizer.createSpeechRecognizer(requireContext())
@ -200,7 +193,7 @@ abstract class BaseFragment<T : ViewDataBinding, V : BaseViewModel>(viewModelCla
cancelSpeech()
}
}
}*/
private fun initDataBinding() {
binding = DataBindingUtil.bind<T>(requireView())!!
@ -268,7 +261,7 @@ abstract class BaseFragment<T : ViewDataBinding, V : BaseViewModel>(viewModelCla
}
}
/*
override fun onInit(status: Int) {
/* if (status == TextToSpeech.SUCCESS) {
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())
}*/
}
private fun runSound() {
*/
/* 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() {
/* 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() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
muteSound()
//muteSound()
}
mSpeechRecognizer!!.startListening(mSpeechRecognizerIntent)
}
@ -355,7 +348,7 @@ abstract class BaseFragment<T : ViewDataBinding, V : BaseViewModel>(viewModelCla
//Log.i("Speech", "onError " + error)
if (mSpeechRecognizer != null) mSpeechRecognizer!!.destroy()
mSpeechRecognizer = null
initialize()
//initialize()
}
}
@ -366,11 +359,13 @@ abstract class BaseFragment<T : ViewDataBinding, V : BaseViewModel>(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")
@ -434,7 +429,7 @@ abstract class BaseFragment<T : ViewDataBinding, V : BaseViewModel>(viewModelCla
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<T : ViewDataBinding, V : BaseViewModel>(viewModelCla
tool.backButton.visibility = View.INVISIBLE
}
fun cancelSpeech() {
/* fun cancelSpeech() {
if (mSpeechRecognizer != null) {
mSpeechRecognizer!!.destroy()
mSpeechRecognizer = null
}
}
}*/
private fun getDefaults(key: String?, context: Context?): String? {
val preferences = PreferenceManager.getDefaultSharedPreferences(context)
@ -612,6 +607,7 @@ abstract class BaseFragment<T : ViewDataBinding, V : BaseViewModel>(viewModelCla
editor.remove(nameWorkForm).commit()
}
fun getWorkForm(): List<WorkForms> {
var listForms: ArrayList<WorkForms> = ArrayList()
val prefs: SharedPreferences = requireActivity().getSharedPreferences(PREFS_SERVER, 0)

View File

@ -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<String>) {
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)

View File

@ -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<SaleVO> = 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()
}
}*/
}