refs #6004 feat:preferences by dataStore
This commit is contained in:
parent
efd8ea47f5
commit
9cda22a4d9
|
@ -191,9 +191,10 @@ class DataStoreLocal(var mobileApplication: MobileApplication) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (listForms.isEmpty()) {
|
if (listForms.isEmpty() || listForms.size == 1) {
|
||||||
createWorksDefault()
|
createWorksDefault()
|
||||||
}
|
}
|
||||||
|
//createWorksDefault()
|
||||||
|
|
||||||
return listForms.sortedBy { it.created }
|
return listForms.sortedBy { it.created }
|
||||||
}
|
}
|
||||||
|
@ -244,6 +245,13 @@ class DataStoreLocal(var mobileApplication: MobileApplication) {
|
||||||
urlSalix = "http://192.168.1.132:3000"
|
urlSalix = "http://192.168.1.132:3000"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
saveWorkForm(
|
||||||
|
WorkForms(
|
||||||
|
"DEV SALIX",
|
||||||
|
"http://10.1.4.42:9000",
|
||||||
|
urlSalix = "https://dev-salix.verdnatura.es"
|
||||||
|
)
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
//deleteWorkForm("all")
|
//deleteWorkForm("all")
|
||||||
}
|
}
|
||||||
|
@ -279,4 +287,14 @@ class DataStoreLocal(var mobileApplication: MobileApplication) {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getServerSalix(): String {
|
||||||
|
|
||||||
|
var url =
|
||||||
|
readDataStoreKey<String>(BASEURLSALIX)
|
||||||
|
if (url.isNullOrBlank()) {
|
||||||
|
url = BASE_URL_SALIX
|
||||||
|
}
|
||||||
|
return url
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -3,7 +3,9 @@ package es.verdnatura.domain
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import com.google.gson.GsonBuilder
|
import com.google.gson.GsonBuilder
|
||||||
import es.verdnatura.MobileApplication
|
import es.verdnatura.MobileApplication
|
||||||
|
import es.verdnatura.domain.ConstAndValues.BASEURL
|
||||||
import es.verdnatura.domain.ConstAndValues.BASEURLSALIX
|
import es.verdnatura.domain.ConstAndValues.BASEURLSALIX
|
||||||
|
import es.verdnatura.domain.ConstAndValues.BASE_URL
|
||||||
import es.verdnatura.domain.ConstAndValues.BASE_URL_SALIX
|
import es.verdnatura.domain.ConstAndValues.BASE_URL_SALIX
|
||||||
import es.verdnatura.presentation.common.InteceptorListener
|
import es.verdnatura.presentation.common.InteceptorListener
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
|
@ -32,8 +34,37 @@ class ApiSalixUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getBaseUrlLocal(context: Context): String {
|
private fun getBaseUrlLocal(context: Context): String {
|
||||||
|
var myWorkFormSelected =
|
||||||
|
(context as MobileApplication).dataStoreApp.readDataStoreKey(ConstAndValues.WORKFORMSELECTED) as String
|
||||||
|
if (myWorkFormSelected != "Producción" && myWorkFormSelected.isNotBlank()) {
|
||||||
|
runBlocking {
|
||||||
|
var list = (context).dataStoreApp.getWorkForm()
|
||||||
|
for (l in list) {
|
||||||
|
if (l.name == myWorkFormSelected) {
|
||||||
|
context.dataStoreApp.editDataStoreKey(
|
||||||
|
BASEURL,
|
||||||
|
l.urlSilex
|
||||||
|
)
|
||||||
|
context.dataStoreApp.editDataStoreKey(BASEURLSALIX, l.urlSalix)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
runBlocking {
|
||||||
|
context.dataStoreApp.editDataStoreKey(
|
||||||
|
BASEURL,
|
||||||
|
BASE_URL
|
||||||
|
)
|
||||||
|
context.dataStoreApp.editDataStoreKey(
|
||||||
|
BASEURLSALIX,
|
||||||
|
BASE_URL_SALIX
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var url =
|
var url =
|
||||||
(context as MobileApplication).dataStoreApp.readDataStoreKey<String>(BASEURLSALIX)
|
(context as MobileApplication).dataStoreApp.readDataStoreKey<String>(BASEURLSALIX)
|
||||||
|
|
||||||
if (url.isNullOrEmpty()) {
|
if (url.isNullOrEmpty()) {
|
||||||
runBlocking {
|
runBlocking {
|
||||||
(context).dataStoreApp.editDataStoreKey(
|
(context).dataStoreApp.editDataStoreKey(
|
||||||
|
@ -45,6 +76,7 @@ class ApiSalixUtils {
|
||||||
url = "https://" + url
|
url = "https://" + url
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return if (url.isNullOrEmpty()) "$BASE_URL_SALIX/api/" else "$url/api/"
|
return if (url.isNullOrEmpty()) "$BASE_URL_SALIX/api/" else "$url/api/"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,6 @@ import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
import es.verdnatura.R
|
import es.verdnatura.R
|
||||||
import es.verdnatura.databinding.FragmentItemCardBinding
|
import es.verdnatura.databinding.FragmentItemCardBinding
|
||||||
import es.verdnatura.domain.ConstAndValues.BASEURLSALIX
|
|
||||||
import es.verdnatura.domain.ConstAndValues.WAREHOUSEFK
|
import es.verdnatura.domain.ConstAndValues.WAREHOUSEFK
|
||||||
import es.verdnatura.domain.toast
|
import es.verdnatura.domain.toast
|
||||||
import es.verdnatura.presentation.base.BaseFragment
|
import es.verdnatura.presentation.base.BaseFragment
|
||||||
|
@ -131,9 +130,7 @@ class ItemCardFragment(
|
||||||
mutableMapOf(
|
mutableMapOf(
|
||||||
"entryPoint" to itemId,
|
"entryPoint" to itemId,
|
||||||
"web" to "${
|
"web" to "${
|
||||||
mobileApplication.dataStoreApp.readDataStoreKey<String>(
|
mobileApplication.dataStoreApp.getServerSalix()
|
||||||
BASEURLSALIX
|
|
||||||
)
|
|
||||||
}/#!/item/$itemId/summary"
|
}/#!/item/$itemId/summary"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
@ -1058,9 +1058,7 @@ class CollectionFragment(
|
||||||
mutableMapOf(
|
mutableMapOf(
|
||||||
"entryPoint" to sale.ticketFk,
|
"entryPoint" to sale.ticketFk,
|
||||||
"web" to "${
|
"web" to "${
|
||||||
mobileApplication.dataStoreApp.readDataStoreKey<String>(
|
mobileApplication.dataStoreApp.getServerSalix()
|
||||||
ConstAndValues.BASEURLSALIX
|
|
||||||
)
|
|
||||||
}/#!/ticket/${sale.ticketFk}/sale"
|
}/#!/ticket/${sale.ticketFk}/sale"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
@ -1064,9 +1064,7 @@ class CollectionFragmentPicker(
|
||||||
mutableMapOf(
|
mutableMapOf(
|
||||||
"entryPoint" to sale.ticketFk,
|
"entryPoint" to sale.ticketFk,
|
||||||
"web" to "${
|
"web" to "${
|
||||||
mobileApplication.dataStoreApp.readDataStoreKey<String>(
|
mobileApplication.dataStoreApp.getServerSalix()
|
||||||
ConstAndValues.BASEURLSALIX
|
|
||||||
)
|
|
||||||
}/#!/ticket/${sale.ticketFk}/sale"
|
}/#!/ticket/${sale.ticketFk}/sale"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
@ -1088,9 +1088,7 @@ class CollectionFragmentPreChecker(
|
||||||
mutableMapOf(
|
mutableMapOf(
|
||||||
"entryPoint" to sale.ticketFk,
|
"entryPoint" to sale.ticketFk,
|
||||||
"web" to "${
|
"web" to "${
|
||||||
mobileApplication.dataStoreApp.readDataStoreKey<String>(
|
mobileApplication.dataStoreApp.getServerSalix()
|
||||||
BASEURLSALIX
|
|
||||||
)
|
|
||||||
}/#!/ticket/${sale.ticketFk}/sale"
|
}/#!/ticket/${sale.ticketFk}/sale"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
@ -22,7 +22,6 @@ import com.google.gson.Gson
|
||||||
import es.verdnatura.R
|
import es.verdnatura.R
|
||||||
import es.verdnatura.databinding.FragmentTicketsBinding
|
import es.verdnatura.databinding.FragmentTicketsBinding
|
||||||
import es.verdnatura.db.DeliveryDatabase
|
import es.verdnatura.db.DeliveryDatabase
|
||||||
import es.verdnatura.domain.ConstAndValues.BASEURLSALIX
|
|
||||||
import es.verdnatura.domain.ConstAndValues.TOKEN
|
import es.verdnatura.domain.ConstAndValues.TOKEN
|
||||||
import es.verdnatura.domain.notNull
|
import es.verdnatura.domain.notNull
|
||||||
import es.verdnatura.domain.toast
|
import es.verdnatura.domain.toast
|
||||||
|
@ -146,9 +145,7 @@ class TicketsFragment(
|
||||||
mutableMapOf(
|
mutableMapOf(
|
||||||
"entryPoint" to route.id,
|
"entryPoint" to route.id,
|
||||||
"web" to "${
|
"web" to "${
|
||||||
mobileApplication.dataStoreApp.readDataStoreKey<String>(
|
mobileApplication.dataStoreApp.getServerSalix()
|
||||||
BASEURLSALIX
|
|
||||||
)
|
|
||||||
}#!/route/${route.id}/tickets"
|
}#!/route/${route.id}/tickets"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -394,9 +391,7 @@ class TicketsFragment(
|
||||||
mutableMapOf(
|
mutableMapOf(
|
||||||
"entryPoint" to route.id,
|
"entryPoint" to route.id,
|
||||||
"web" to "${
|
"web" to "${
|
||||||
mobileApplication.dataStoreApp.readDataStoreKey<String>(
|
mobileApplication.dataStoreApp.getServerSalix()
|
||||||
BASEURLSALIX
|
|
||||||
)
|
|
||||||
}/api/Routes/${item.cmrFk}/cmr?access_token=${
|
}/api/Routes/${item.cmrFk}/cmr?access_token=${
|
||||||
mobileApplication.dataStoreApp.readDataStoreKey<String>(
|
mobileApplication.dataStoreApp.readDataStoreKey<String>(
|
||||||
TOKEN
|
TOKEN
|
||||||
|
|
|
@ -92,9 +92,7 @@ class ShelvingLogFragment(
|
||||||
entryPoint = Gson().toJson(
|
entryPoint = Gson().toJson(
|
||||||
mutableMapOf(
|
mutableMapOf(
|
||||||
"entryPoint" to itemId,
|
"entryPoint" to itemId,
|
||||||
"web" to "${mobileApplication.dataStoreApp.readDataStoreKey<String>(
|
"web" to "${ mobileApplication.dataStoreApp.getServerSalix()}/#!/shelving/$itemId/log"
|
||||||
BASEURLSALIX
|
|
||||||
)}/#!/shelving/$itemId/log"
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue