Commit ea6d4ed726409da9942637c47a77deacd39cbef6

Authored by Mauricio Sanchez
1 parent 7483a587d5
Exists in master

02092020 0207

app/src/main/java/com/focasoftware/deboinventariov20/DB/DAO/ArticulosDAO.kt
... ... @@ -77,7 +77,7 @@ interface ServeInvDao {
77 77 @Insert(onConflict = OnConflictStrategy.REPLACE)
78 78 fun insertServer(servidor: ServeInv)
79 79  
80   - @Query("SELECT * FROM $TABLA_SERV_INV")
  80 + @Query("SELECT * FROM $TABLA_SERV_INV ORDER BY SER_NUM")
81 81 suspend fun fetchAllServers(): List<ServeInv>
82 82  
83 83 @Query("DELETE FROM $TABLA_SERV_INV WHERE SER_DESC LIKE :description AND SER_DIR LIKE :dir")
app/src/main/java/com/focasoftware/deboinventariov20/ui/actualizacionMaestros/ActuaMaestrosFragment.kt
... ... @@ -12,6 +12,7 @@ import com.focasoftware.deboinventariov20.Model.Productos
12 12 import com.focasoftware.deboinventariov20.Model.ProductosService
13 13 import com.focasoftware.deboinventariov20.Model.ServeInv
14 14 import com.focasoftware.deboinventariov20.R
  15 +import com.google.android.material.bottomappbar.BottomAppBarTopEdgeTreatment
15 16 import kotlinx.android.synthetic.main.fragment_actua_maestros.*
16 17 import kotlinx.coroutines.*
17 18  
... ... @@ -23,10 +24,12 @@ class ActuaMaestrosFragment : Fragment() {
23 24  
24 25 override fun onCreate(savedInstanceState: Bundle?) {
25 26 super.onCreate(savedInstanceState)
26   - GlobalScope.launch(Dispatchers.Main) {
27   - BASE_URL = fetchServerPre().direccion.toString()
28   - }
29   - mostrarArticulos()
  27 +// GlobalScope.launch(Dispatchers.Main) {
  28 +//
  29 +// BASE_URL = fetchServerPre().direccion.toString()
  30 +// }
  31 + BASE_URL="http://10.0.2.2:3000/"
  32 +// mostrarArticulos()
30 33 }
31 34  
32 35 suspend fun fetchServerPre(): ServeInv {
app/src/main/java/com/focasoftware/deboinventariov20/ui/configuracion/ConfiguracionFragment.kt
... ... @@ -14,7 +14,7 @@ import androidx.navigation.fragment.findNavController
14 14 import com.focasoftware.deboinventariov20.DB.DataBase.AppDb
15 15 import com.focasoftware.deboinventariov20.Model.ServeInv
16 16 import com.focasoftware.deboinventariov20.R
17   -import com.focasoftware.deboinventariov20.ui.servidores.ItemsServidores
  17 +import com.focasoftware.deboinventariov20.ui.servidores.SpinnerAdapterServidor
18 18 import kotlinx.android.synthetic.main.fragment_configuracion.*
19 19 import kotlinx.coroutines.Dispatchers
20 20 import kotlinx.coroutines.GlobalScope
... ... @@ -25,7 +25,9 @@ class ConfiguracionFragment : Fragment() {
25 25  
26 26 lateinit var sharedPreferences: SharedPreferences
27 27 private lateinit var navController: NavController
28   - private lateinit var listaServers : MutableMap<Int,String>
  28 + lateinit var adapterSpinnerServidor: SpinnerAdapterServidor
  29 + var itemSelect: Int = 0
  30 +
29 31 override fun onCreate(savedInstanceState: Bundle?) {
30 32 super.onCreate(savedInstanceState)
31 33 sharedPreferences = requireActivity().getSharedPreferences("SP_INFO", Context.MODE_PRIVATE)
... ... @@ -34,12 +36,11 @@ class ConfiguracionFragment : Fragment() {
34 36 override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
35 37 super.onViewCreated(view, savedInstanceState)
36 38 navController = Navigation.findNavController(view)
  39 +
37 40 }
38 41  
39 42 override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
40 43  
41   - var index=0
42   - val listServerDescription = arrayListOf<String>()
43 44 val v = inflater.inflate(R.layout.fragment_configuracion, container, false)
44 45 val etRuta = v.findViewById<EditText>(R.id.etRuta)
45 46 val btnGuardar = v.findViewById<Button>(R.id.btnGuardar)
... ... @@ -58,16 +59,15 @@ class ConfiguracionFragment : Fragment() {
58 59 val spServidor = v.findViewById<Spinner>(R.id.spServidor)
59 60 val btnValidarServidor = v.findViewById<Button>(R.id.btnValidarServidor)
60 61  
61   - if (sharedPreferences.contains("etRuta"))
62   - if (sharedPreferences.contains("rbProInclu")) {
63   - if (sharedPreferences.getString("rbProInclu", "").toString() == "0") {
64   - rbProInclu.isChecked = false
65   - rbProNoInclu.isChecked = true
66   - } else if (sharedPreferences.getString("rbProInclu", "").toString() == "1") {
67   - rbProInclu.isChecked = true
68   - rbProNoInclu.isChecked = false
69   - }
70   - } else (sharedPreferences.getString("rbProInclu", "").toString() == "")
  62 + if (sharedPreferences.contains("etRuta")) if (sharedPreferences.contains("rbProInclu")) {
  63 + if (sharedPreferences.getString("rbProInclu", "").toString() == "0") {
  64 + rbProInclu.isChecked = false
  65 + rbProNoInclu.isChecked = true
  66 + } else if (sharedPreferences.getString("rbProInclu", "").toString() == "1") {
  67 + rbProInclu.isChecked = true
  68 + rbProNoInclu.isChecked = false
  69 + }
  70 + } else (sharedPreferences.getString("rbProInclu", "").toString() == "")
71 71  
72 72 if (sharedPreferences.contains("rbProNoInclu")) {
73 73 if (sharedPreferences.getString("rbProNoInclu", "").toString() == "0") {
... ... @@ -166,28 +166,19 @@ class ConfiguracionFragment : Fragment() {
166 166 }
167 167 btnAgregarServidor.setOnClickListener { findNavController().navigate(R.id.servidoresFragment) }
168 168 btnValidarServidor.setOnClickListener { Toast.makeText(requireContext(), "Direcciรณn correcta", Toast.LENGTH_LONG).show() }
169   -
  169 + spServidor?.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
  170 + override fun onNothingSelected(parent: AdapterView<*>?) {}
  171 + override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) { itemSelect = position }
  172 + }
170 173 GlobalScope.launch(Dispatchers.Main) {
  174 + adapterSpinnerServidor = SpinnerAdapterServidor(requireContext(), getDescServers())
  175 + spServidor.adapter = adapterSpinnerServidor
171 176  
172   - for (any in getDescServers()) {
173   - listServerDescription.add(any.descripcion.toString())
174   - listaServers[index]=(any.direccion.toString())
175   - index+=index
176   - }
177   -
178   - if (spServidor != null) {
179   - val adapter = ArrayAdapter(requireContext(), android.R.layout.simple_spinner_item, listServerDescription)
180   - spServidor.adapter = adapter
181   - }
  177 + if (sharedPreferences.contains("ServerPredeterminado")) {
  178 + spServidor.setSelection(sharedPreferences.getString("ServerPredeterminado", "").toString().toInt())
  179 + } else (spServidor.setSelection(0))
182 180 }
183   - if (sharedPreferences.contains("ServerPredeterminado")) {
184   - spServidor.setSelection(sharedPreferences.getString("ServerPredeterminado", "").toString().toInt())
185 181  
186   - } else (spServidor.setSelection(2))
187   -
188   - spServidor.setOnItemClickListener { adapterView, view, i, l ->
189   -
190   - }
191 182 return v
192 183 }
193 184  
... ... @@ -215,7 +206,7 @@ class ConfiguracionFragment : Fragment() {
215 206 if (rbCodigoBarras.isChecked) editor?.putString("rbCodigoBarras", "1") else editor?.putString("rbCodigoBarras", "0")
216 207 if (cbMostrarExistencia.isChecked) editor?.putString("cbMostrarExistencia", "1") else editor?.putString("cbMostrarExistencia", "0")
217 208 if (cbMostrarPrecio.isChecked) editor?.putString("cbMostrarPrecio", "1") else editor?.putString("cbMostrarPrecio", "0")
218   - editor?.putString("ServerPredeterminado", spServidor.selectedItemId.toString())
  209 + editor?.putString("ServerPredeterminado", itemSelect.toString())
219 210  
220 211 editor?.apply()
221 212 editor.commit()
app/src/main/java/com/focasoftware/deboinventariov20/ui/main/InventarioListAdapter.kt
... ... @@ -26,6 +26,7 @@ class InventarioListAdapter(private val context: Context, private val inv: List&lt;
26 26 override fun bind(item: InvHead, position: Int) {
27 27 itemView.setOnClickListener {itemClickListener.onItemClick(item.invNum.toString())}
28 28 itemView.tvPrincipalinventario.text = item.invNum.toString()
  29 + itemView.tvDescription.text=item.descripcion.toString()
29 30 }
30 31 }
31 32  
app/src/main/java/com/focasoftware/deboinventariov20/ui/main/ItemPrincipal.kt
1 1 package com.focasoftware.deboinventariov20.ui.main
2 2  
3   -data class ItemInventario(val inventario: String?)
4 3 \ No newline at end of file
  4 +data class ItemInventario(val inventario: String?, val descripcion: String?)
5 5 \ No newline at end of file
app/src/main/java/com/focasoftware/deboinventariov20/ui/main/MainFragment.kt
... ... @@ -134,9 +134,9 @@ private var listIvn2 = ArrayList&lt;InvHead&gt;()
134 134 fun cargarRecicler(inv: InvHead) {
135 135 //TODO CARGO EN LE RV
136 136  
137   - val number = if (inv.invNum.toLong() < 10) "0${inv.invNum.toLong()}" else inv.invNum.toString()
138   - val item = ItemInventario("Nยฐ $number ${inv.descripcion}. Fecha: ${inv.fechaFinal}")
139   - //(articulos.sector, articulos.codigo, articulos.descripcion, cant, articulos.codBar)
  137 +// val number = if (inv.invNum.toLong() < 10) "0${inv.invNum.toLong()}" else inv.invNum.toString()
  138 +// val item = ItemInventario("Nยฐ $number ${inv.descripcion}. Fecha: ${inv.fechaFinal}")
  139 +
140 140 // listIvn.add(item)
141 141 listIvn2.add(inv)
142 142 viewAdapter = InventarioListAdapter(requireContext(), listIvn2, this)
app/src/main/java/com/focasoftware/deboinventariov20/ui/servidores/SpinnerAdapter.kt
... ... @@ -0,0 +1,40 @@
  1 +package com.focasoftware.deboinventariov20.ui.servidores
  2 +
  3 +import android.content.Context
  4 +import android.view.LayoutInflater
  5 +import android.view.View
  6 +import android.view.ViewGroup
  7 +import android.widget.BaseAdapter
  8 +import android.widget.TextView
  9 +import com.focasoftware.deboinventariov20.Model.ServeInv
  10 +import com.focasoftware.deboinventariov20.R
  11 +
  12 +
  13 +class SpinnerAdapterServidor internal constructor(internal var context: Context, internal var list: List<ServeInv>) : BaseAdapter() {
  14 + override fun getCount(): Int {
  15 + return list.size
  16 + }
  17 +
  18 + override fun getItem(i: Int): Any? {
  19 + return null
  20 + }
  21 +
  22 + override fun getItemId(i: Int): Long {
  23 + return 0
  24 + }
  25 +
  26 + override fun getView(i: Int, view1: View?, viewGroup: ViewGroup): View {
  27 + var views=view1
  28 + if (views == null) {
  29 + val inflater = LayoutInflater.from(context)
  30 +
  31 + views = inflater.inflate(R.layout.item_spinner, viewGroup, false)
  32 + }
  33 +
  34 + val tvServidorDesc = views!!.findViewById<TextView>(R.id.tvServidorDesc)
  35 + tvServidorDesc.text=list[i].descripcion
  36 + return tvServidorDesc
  37 +
  38 + }
  39 +}
  40 +
app/src/main/res/drawable-v24/boton_redondo2.xml
... ... @@ -0,0 +1,5 @@
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<shape xmlns:android="http://schemas.android.com/apk/res/android">
  3 + <solid android:color="#B6B7BC"/>
  4 + <corners android:radius="80dp"/>
  5 +</shape>
0 6 \ No newline at end of file
app/src/main/res/drawable/boton_redondo.xml
... ... @@ -2,7 +2,4 @@
2 2 <shape xmlns:android="http://schemas.android.com/apk/res/android">
3 3 <solid android:color="@color/colorAccent"/>
4 4 <corners android:radius="80dp"/>
5   -
6   -
7   -
8 5 </shape>
9 6 \ No newline at end of file
app/src/main/res/layout/fragment_configuracion.xml
... ... @@ -45,24 +45,18 @@
45 45  
46 46 <Spinner
47 47 android:id="@+id/spServidor"
  48 + style="@android:style/Widget.Holo.Light.Spinner"
48 49 android:layout_width="0dp"
49 50 android:layout_height="wrap_content"
50   - android:backgroundTint="@color/LightGray"
51 51 android:elevation="5dp"
52   - android:fadeScrollbars="true"
53   - android:foregroundTint="@android:color/holo_orange_dark"
54   - android:soundEffectsEnabled="true"
55   - android:spinnerMode="dropdown"
56 52  
57   - android:splitMotionEvents="true"
58   - android:textAlignment="textStart"
59 53 android:textSize="@dimen/NormalText"
60 54 app:layout_constraintBottom_toTopOf="@+id/btnAgregarServidor"
61 55 app:layout_constraintEnd_toStartOf="@+id/btnValidarServidor"
62 56 app:layout_constraintHorizontal_chainStyle="packed"
63 57 app:layout_constraintStart_toStartOf="parent"
64 58 app:layout_constraintTop_toBottomOf="@+id/tvSeleccioneServidor"
65   - android:prompt="@string/leyendaSpinner"/>
  59 + />
66 60  
67 61 <Button
68 62 android:id="@+id/btnValidarServidor"
... ... @@ -364,5 +358,6 @@
364 358 android:background="@drawable/boton_borde_redondeado"
365 359 app:layout_constraintStart_toStartOf="parent"
366 360 app:layout_constraintTop_toBottomOf="@+id/cbMostrarPrecio" />
  361 +
367 362 </androidx.constraintlayout.widget.ConstraintLayout>
368 363  
app/src/main/res/layout/item_principal.xml
1 1 <?xml version="1.0" encoding="utf-8"?>
2   -<androidx.cardview.widget.CardView
3   - xmlns:android="http://schemas.android.com/apk/res/android"
  2 +<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
4 3 xmlns:app="http://schemas.android.com/apk/res-auto"
5 4 xmlns:tools="http://schemas.android.com/tools"
6 5 android:layout_width="match_parent"
7 6 android:layout_height="wrap_content"
8 7 android:layout_margin="5dp"
9   - app:cardCornerRadius="2dp"
  8 + app:cardCornerRadius="5dp"
10 9 app:cardElevation="10dp"
11   - app:contentPadding="5dp"
12 10 app:cardPreventCornerOverlap="false">
13 11  
14   - <LinearLayout
15   - android:layout_width="wrap_content"
  12 + <androidx.constraintlayout.widget.ConstraintLayout
  13 + android:layout_width="match_parent"
16 14 android:layout_height="wrap_content"
17 15 android:layout_gravity="center_horizontal|center_vertical"
18 16 android:orientation="vertical">
19 17  
20   - <androidx.appcompat.widget.AppCompatImageView
21   - android:layout_width="wrap_content"
22   - android:layout_height="wrap_content"
23   - android:layout_gravity="center_horizontal"
24   - android:src="@drawable/inventario" />
  18 +<!-- <androidx.appcompat.widget.AppCompatImageView-->
  19 +<!-- android:id="@+id/ivCamara"-->
  20 +<!-- android:layout_width="80dp"-->
  21 +<!-- android:layout_height="80dp"-->
  22 +<!-- android:layout_margin="10dp"-->
  23 +<!-- android:layout_marginTop="15dp"-->
  24 +<!-- android:background="@drawable/boton_redondo2"-->
  25 +<!-- android:clickable="true"-->
  26 +<!-- android:contentDescription="@string/ibBusCB"-->
  27 +<!-- android:elevation="5dp"-->
  28 +<!-- android:focusable="false"-->
  29 +<!-- android:scaleType="fitEnd"-->
  30 +<!-- -->
  31 +<!-- app:layout_constraintBottom_toTopOf="@+id/ivFondo"-->
  32 +<!-- app:layout_constraintCircleRadius="40dp"-->
  33 +<!-- app:layout_constraintStart_toStartOf="parent"-->
  34 +<!-- app:layout_constraintTop_toTopOf="parent"-->
  35 +<!-- />-->
25 36  
26 37 <TextView
27 38 android:id="@+id/tvPrincipalinventario"
28   - android:layout_width="wrap_content"
29   - android:layout_height="wrap_content"
  39 + android:layout_width="50dp"
  40 + android:layout_height="50dp"
  41 + android:layout_margin="10dp"
30 42 android:gravity="center"
31 43 android:lines="2"
32   - tools:text="Demo text"
  44 + android:background="@drawable/boton_redondo2"
33 45 android:textColor="@android:color/black"
34   - android:textStyle="bold" />
35   - </LinearLayout>
  46 + android:textSize="@dimen/TitulosMedios"
  47 + android:textStyle="bold"
  48 + app:layout_constraintBottom_toTopOf="@+id/ivFondo"
  49 + app:layout_constraintStart_toStartOf="parent"
  50 + app:layout_constraintTop_toTopOf="parent"
  51 + tools:text="99" />
  52 +
  53 + <TextView
  54 + android:id="@+id/tvDescription"
  55 + android:layout_width="wrap_content"
  56 + android:layout_height="wrap_content"
  57 + android:text="prueba"
  58 + app:layout_constraintBottom_toTopOf="@id/ivFondo"
  59 + app:layout_constraintEnd_toEndOf="parent"
  60 + app:layout_constraintHorizontal_bias="0.046"
  61 + app:layout_constraintStart_toEndOf="@id/tvPrincipalinventario"
  62 + app:layout_constraintTop_toTopOf="parent"
  63 + app:layout_constraintVertical_bias="0.607" />
  64 +
  65 + <androidx.appcompat.widget.AppCompatImageView
  66 + android:id="@+id/ivFondo"
  67 + android:layout_width="0dp"
  68 + android:layout_height="10dp"
  69 + android:background="@android:drawable/progress_horizontal"
  70 + android:elevation="10dp"
  71 + app:layout_constraintBottom_toBottomOf="parent"
  72 + app:layout_constraintCircleRadius="5dp"
  73 + app:layout_constraintEnd_toEndOf="parent"
  74 + app:layout_constraintStart_toStartOf="parent"
  75 + tools:srcCompat="@android:drawable/progress_horizontal" />
  76 + </androidx.constraintlayout.widget.ConstraintLayout>
36 77 </androidx.cardview.widget.CardView>
app/src/main/res/layout/item_spinner.xml
... ... @@ -0,0 +1,13 @@
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<LinearLayout
  3 + xmlns:android="http://schemas.android.com/apk/res/android"
  4 + android:layout_width="match_parent"
  5 + android:layout_height="match_parent">
  6 +
  7 + <TextView
  8 + android:layout_width="wrap_content"
  9 + android:layout_height="wrap_content"
  10 + android:textSize="18sp"
  11 + android:textStyle="bold"
  12 + android:id="@+id/tvServidorDesc"/>
  13 +</LinearLayout>
app/src/main/res/layout/nav_header_main.xml
... ... @@ -29,7 +29,7 @@
29 29 android:textAppearance="@style/TextAppearance.AppCompat.Body1" />
30 30  
31 31 <TextView
32   - android:id="@+id/textView"
  32 + android:id="@+id/textView1"
33 33 android:layout_width="wrap_content"
34 34 android:layout_height="wrap_content"
35 35 android:text="FocaSoftware SA" />
app/src/main/res/navigation/mobile_navigation.xml
... ... @@ -42,6 +42,7 @@
42 42 android:name="com.focasoftware.deboinventariov20.ui.actualizacionMaestros.ActuaMaestrosFragment"
43 43 android:label="Importaciones Varias"
44 44 tools:layout="@layout/fragment_actua_maestros" />
  45 +
45 46 <fragment
46 47 android:id="@+id/servidoresFragment"
47 48 android:name="com.focasoftware.deboinventariov20.ui.servidores.ServidoresFragment"
... ... @@ -50,11 +51,10 @@
50 51 <action
51 52 android:id="@+id/action_servidoresFragment_to_configuracionFragment"
52 53 app:destination="@id/configuracionFragment"
53   - app:enterAnim="@anim/slide_in_right"
54   - app:exitAnim="@anim/slide_out_left"
55   - app:popEnterAnim="@anim/slide_in_left"
56   - app:popExitAnim="@anim/slide_out_right" />
  54 + app:popUpTo="@id/servidoresFragment"
  55 + app:popUpToInclusive="true" />
57 56 </fragment>
  57 +
58 58 <fragment
59 59 android:id="@+id/inventarioFragment"
60 60 android:name="com.focasoftware.deboinventariov20.ui.inventario.InventarioFragment"
... ... @@ -66,7 +66,9 @@
66 66 app:popEnterAnim="@anim/slide_in_left"
67 67 app:popExitAnim="@anim/slide_out_right"
68 68 app:enterAnim="@anim/slide_in_right"
69   - app:exitAnim="@anim/slide_out_left" />
  69 + app:exitAnim="@anim/slide_out_left"
  70 + app:popUpTo="@+id/inventarioFragment"
  71 + app:popUpToInclusive="true"/>
70 72 <action
71 73 android:id="@+id/action_inventarioFragment_to_mainFragment2"
72 74 app:destination="@id/mainFragment2"
... ... @@ -90,7 +92,9 @@
90 92 app:popEnterAnim="@anim/slide_in_left"
91 93 app:popExitAnim="@anim/slide_out_right"
92 94 app:enterAnim="@anim/slide_in_right"
93   - app:exitAnim="@anim/slide_out_left" />
  95 + app:exitAnim="@anim/slide_out_left"
  96 + app:popUpTo="@id/configuracionFragment"
  97 + app:popUpToInclusive="true" />
94 98 <action
95 99 android:id="@+id/action_configuracionFragment_to_mainFragment2"
96 100 app:destination="@id/mainFragment2" />
... ... @@ -116,12 +120,13 @@
116 120 android:label="DialogNoEncontrado" />
117 121 <fragment
118 122 android:id="@+id/dialogoLogin"
119   - android:name="com.focasoftware.deboinventariov20.ui.dialogos.dialogoLogin"
  123 + android:name="com.focasoftware.deboinventariov20.ui.dialogos.DialogoLogin"
120 124 android:label="dialogoLogin" />
121 125 <fragment
122 126 android:id="@+id/singleChoiceAlertDialog"
123 127 android:name="com.focasoftware.deboinventariov20.ui.dialogos.SingleChoiceAlertDialog"
124 128 android:label="SingleChoiceAlertDialog" />
  129 +
125 130 <fragment
126 131 android:id="@+id/detalleArtFragment"
127 132 android:name="com.focasoftware.deboinventariov20.ui.detalleProducto.DetalleArtFragment"
app/src/main/res/values/arrays.xml
... ... @@ -1,8 +0,0 @@
1   -<?xml version="1.0" encoding="utf-8"?>
2   -<resources>
3   - <string-array name="sort_array">
4   - <item>Suma</item>
5   - <item>Resta</item>
6   - <item>Modifica</item>
7   - </string-array>
8   -</resources>
9 0 \ No newline at end of file
app/src/main/res/values/colors.xml
... ... @@ -5,4 +5,6 @@
5 5 <color name="colorPrimary">#085394</color>
6 6 <color name="backMenu">#dddddd</color>
7 7 <color name="LightGray">#E0E0E0</color>
  8 +<!-- TODO: ITEM PRINCIPAL-->
  9 + <color name="barrainferior">#074865</color>
8 10 </resources>
9 11 \ No newline at end of file