refs #5322 NaturePhotos

This commit is contained in:
Sergio De la torre 2023-06-09 14:07:11 +02:00
parent fd04b7b52f
commit bdec030f66
16 changed files with 500 additions and 329 deletions

View File

@ -83,10 +83,23 @@
</select>
</component>
<component name="ChangeListManager">
<list default="true" id="fa688d1c-dbee-4864-9e33-4d84ef9afca8" name="Default Changelist" comment="version 23.22">
<list default="true" id="fa688d1c-dbee-4864-9e33-4d84ef9afca8" name="Default Changelist" comment="refs #5322 NaturePhotos">
<change afterPath="$PROJECT_DIR$/app/src/main/res/drawable/ic_image_upload.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/beta/release/output-metadata.json" beforeDir="false" afterPath="$PROJECT_DIR$/app/beta/release/output-metadata.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/build.gradle" beforeDir="false" afterPath="$PROJECT_DIR$/app/build.gradle" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/domain/SalixService.kt" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/domain/SalixService.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/base/BaseFragment.kt" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/base/BaseFragment.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/fragment/ItemCardFragment.kt" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/fragment/ItemCardFragment.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/fragment/ItemCardViewModel.kt" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/articulo/fragment/ItemCardViewModel.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/login/activity/LoginActivity.kt" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/login/activity/LoginActivity.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/login/fragment/LoginFragment.kt" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/login/fragment/LoginFragment.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/main/activity/MainActivity.kt" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/main/activity/MainActivity.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/pasillero/fragment/PasilleroViewModel.kt" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/pasillero/fragment/PasilleroViewModel.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/photos/fragment/PhotosFragment.kt" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/photos/fragment/PhotosFragment.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/res/layout/fragment_photos.xml" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/res/layout/fragment_photos.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/res/values-es/strings.xml" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/res/values-es/strings.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/res/values-fr/strings.xml" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/res/values-fr/strings.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/res/values-pt/strings.xml" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/res/values-pt/strings.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/res/values/strings.xml" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/res/values/strings.xml" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -184,7 +197,7 @@
</option>
<option name="RECENT_BRANCH_BY_REPOSITORY">
<map>
<entry key="$PROJECT_DIR$" value="master" />
<entry key="$PROJECT_DIR$" value="4021-gestion_embalajes" />
</map>
</option>
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
@ -232,40 +245,40 @@
<option name="showLibraryContents" value="true" />
<option name="showMembers" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"ApkExportedModule": "Gestor_Almacén.app",
"ExportApk.ApkPathForGestor_Almacén.app": "C:\\Users\\sergiodt\\AndroidStudioProjects\\vn-warehouseManager\\app",
"PROJECT_TRUSTED_KEY": "true",
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"RunOnceActivity.cidr.known.project.marker": "true",
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
"ScreenRecorder.SavePath": "C:\\Users\\sergiodt\\device-2023-03-17-114045.mp4",
"android-custom-viewC:/Users/sergiodt/.gradle/caches/modules-2/files-2.1/androidx.recyclerview/recyclerview/1.2.1/f0f93e67af3f7417bdd560d5142f6dec4fe629c3/recyclerview-1.2.1-sources.jar!/androidx/recyclerview/widget/RecyclerView.java_SELECTED": "RecyclerView",
"cidr.known.project.marker": "true",
"com.developerphil.adbidea.selecteddevices": "21114523025303",
"com.google.services.firebase.aqiPopupShown": "true",
"last_opened_file_path": "C:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable",
"project.structure.last.edited": "Modules",
"project.structure.proportion": "0.17",
"project.structure.side.proportion": "0.2",
"run.code.analysis.last.selected.profile": "pProject Default",
"settings.editor.selected.configurable": "preferences.sourceCode.Shell Script"
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;ApkExportedModule&quot;: &quot;Gestor_Almacén.app&quot;,
&quot;ExportApk.ApkPathForGestor_Almacén.app&quot;: &quot;C:\\Users\\sergiodt\\AndroidStudioProjects\\vn-warehouseManager\\app&quot;,
&quot;PROJECT_TRUSTED_KEY&quot;: &quot;true&quot;,
&quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.cidr.known.project.marker&quot;: &quot;true&quot;,
&quot;SHARE_PROJECT_CONFIGURATION_FILES&quot;: &quot;true&quot;,
&quot;ScreenRecorder.SavePath&quot;: &quot;C:\\Users\\sergiodt\\device-2023-03-17-114045.mp4&quot;,
&quot;android-custom-viewC:/Users/sergiodt/.gradle/caches/modules-2/files-2.1/androidx.recyclerview/recyclerview/1.2.1/f0f93e67af3f7417bdd560d5142f6dec4fe629c3/recyclerview-1.2.1-sources.jar!/androidx/recyclerview/widget/RecyclerView.java_SELECTED&quot;: &quot;RecyclerView&quot;,
&quot;cidr.known.project.marker&quot;: &quot;true&quot;,
&quot;com.developerphil.adbidea.selecteddevices&quot;: &quot;21114523025303&quot;,
&quot;com.google.services.firebase.aqiPopupShown&quot;: &quot;true&quot;,
&quot;last_opened_file_path&quot;: &quot;C:/Users/sergiodt/AndroidStudioProjects/vn-warehouseManager/app/src/main/res/drawable&quot;,
&quot;project.structure.last.edited&quot;: &quot;Modules&quot;,
&quot;project.structure.proportion&quot;: &quot;0.17&quot;,
&quot;project.structure.side.proportion&quot;: &quot;0.2&quot;,
&quot;run.code.analysis.last.selected.profile&quot;: &quot;pProject Default&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;preferences.sourceCode.Shell Script&quot;
},
"keyToStringList": {
"ExportApk.BuildVariants": [
"generalRelease"
&quot;keyToStringList&quot;: {
&quot;ExportApk.BuildVariants&quot;: [
&quot;generalRelease&quot;
],
"com.android.tools.idea.sqlite.queryhistory": [
"select * from expedition e where e.addressFk= 34915",
"select * from expedition e where e.id= 6872921",
"select count(*) from expeditionPending\n",
"select count(*) from expedition\n",
"select count(*) from expedition"
&quot;com.android.tools.idea.sqlite.queryhistory&quot;: [
&quot;select * from expedition e where e.addressFk= 34915&quot;,
&quot;select * from expedition e where e.id= 6872921&quot;,
&quot;select count(*) from expeditionPending\n&quot;,
&quot;select count(*) from expedition\n&quot;,
&quot;select count(*) from expedition&quot;
]
}
}]]></component>
}</component>
<component name="PsdUISettings">
<option name="MODULE_TAB" value="Default Config" />
<option name="LAST_EDITED_SIGNING_CONFIG" value="debug" />
@ -872,12 +885,12 @@
<MESSAGE value="refs #5764 Añadir onclick pantalla Día de venta" />
<MESSAGE value="refs #5322 Nature" />
<MESSAGE value="strings" />
<MESSAGE value="refs #5322 NaturePhotos" />
<MESSAGE value="Translation" />
<MESSAGE value="refs #5513" />
<MESSAGE value="refs #4678" />
<MESSAGE value="refs #5713" />
<option name="LAST_COMMIT_MESSAGE" value="refs #5713" />
<MESSAGE value="refs #5322 NaturePhotos" />
<option name="LAST_COMMIT_MESSAGE" value="refs #5322 NaturePhotos" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
@ -895,16 +908,6 @@
<line>457</line>
<option name="timeStamp" value="3" />
</line-breakpoint>
<line-breakpoint enabled="true" type="kotlin-line">
<url>file://$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/photos/fragment/PhotosFragment.kt</url>
<line>150</line>
<option name="timeStamp" value="8" />
</line-breakpoint>
<line-breakpoint enabled="true" type="kotlin-line">
<url>file://$PROJECT_DIR$/app/src/main/java/es/verdnatura/presentation/view/feature/photos/fragment/PhotosViewModel.kt</url>
<line>55</line>
<option name="timeStamp" value="9" />
</line-breakpoint>
</breakpoints>
</breakpoint-manager>
<pin-to-top-manager>

View File

@ -179,7 +179,6 @@ interface SalixService {
@Multipart
fun uploadImage(
@Query ("collection") collection: String,
//@Query("fileName") file: String,
@Query("id") id: Int,
@Part filePart: MultipartBody.Part,
):

View File

@ -238,6 +238,7 @@ abstract class BaseFragment<T : ViewDataBinding, V : BaseViewModel>(viewModelCla
R.drawable.camion ->getString(R.string.openLoadingConsignee)
R.drawable.exit ->getString(R.string.exitScreen)
R.drawable.ic_image_upload->getString(R.string.messageUpload)
else -> {

View File

@ -190,7 +190,7 @@ class ItemCardFragment(
private fun getItemCard(itemFk: String) {
warehouseFk = getDataInt(WAREHOUSEFK)
binding.splashProgressTwo.visibility = View.VISIBLE
viewModel.getItemCard(itemFk, warehouseFk!!)
viewModel.getItemCard(itemFk.toInt(), warehouseFk!!)
this.itemFk = itemFk
}

View File

@ -16,7 +16,13 @@ import es.verdnatura.presentation.view.feature.articulo.model.ItemCardVO
import es.verdnatura.presentation.view.feature.articulo.model.ItemPackingTypeList
import es.verdnatura.presentation.view.feature.articulo.model.ItemProposal
import es.verdnatura.presentation.view.feature.articulo.model.ItemProposalList
import okhttp3.MediaType
import okhttp3.MultipartBody
import okhttp3.RequestBody
import retrofit2.Response
import java.io.File
import java.util.*
import kotlin.collections.ArrayList
class ItemCardViewModel(var context: Context) : BaseViewModel(context) {
@ -39,7 +45,7 @@ class ItemCardViewModel(var context: Context) : BaseViewModel(context) {
fun getItemCard(
itemFk: String,
itemFk: Int,
warehouseFk: Int,
) {
@ -304,4 +310,39 @@ class ItemCardViewModel(var context: Context) : BaseViewModel(context) {
})
}
private val _responseinsert by lazy { MutableLiveData<ResponseItemVO>() }
val responseinsert: LiveData<ResponseItemVO>
get() = _responseinsert
fun uploadPhoto(
urlImage:String,
itemFK:Int,
file: File = File("$urlImage"),
fileRequestBody: RequestBody = RequestBody.create(MediaType.parse("image/jpeg"), file),
filePart: MultipartBody.Part = MultipartBody.Part.createFormData("file", file.name, fileRequestBody),
) {
salix.uploadImage("catalog",itemFK,filePart)
.enqueue(object : SilexCallback<Any>(context) {
override fun onError(t: Throwable) {
_responseinsert.value = ResponseItemVO(
isError = true,
errorMessage = getMessageFromAllResponse(nameofFunction(this), t.message!!)
)
}
override fun onSuccess(response: Response<Any>) {
_responseinsert.value = ResponseItemVO(
isError = false
)
}
})
}
}

View File

@ -1,6 +1,7 @@
package es.verdnatura.presentation.view.feature.login.activity
import android.content.Intent
import android.net.Uri
import es.verdnatura.R
import es.verdnatura.databinding.ActivityLoginBinding
import es.verdnatura.presentation.base.BaseActivity
@ -9,39 +10,26 @@ import es.verdnatura.presentation.common.addFragment
import es.verdnatura.presentation.view.feature.login.fragment.LoginFragment
import es.verdnatura.presentation.view.feature.main.activity.MainActivity
class LoginActivity : BaseActivity<ActivityLoginBinding>() {
class LoginActivity : BaseActivity<ActivityLoginBinding>() {
private var imageUri: Uri? = null
override fun getLayoutId(): Int = R.layout.activity_login
override fun init() {
/* val intent = intent
val intent = intent
val action = intent.action
val type = intent.type*/
/* val crashButton = Button(this)
crashButton.text = "Crash!"
crashButton.setOnClickListener {
throw RuntimeException("Test Crash") // Force a crash
val type = intent.type
//Tarea 5322
if (Intent.ACTION_SEND == action && type?.startsWith("image/") == true) {
val clipData = intent.clipData
if (clipData != null) {
imageUri = clipData.getItemAt(0).uri
}
}
addContentView(crashButton, ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT))*/
//goToMain()
/*Tarea 5322
if (Intent.ACTION_SEND == action && type?.startsWith("image/") == true) {
val imageUri: Uri? = intent.getParcelableExtra(Intent.EXTRA_STREAM)
imageUri?.let {
// Aquí puedes procesar la imagen recibida
// por ejemplo, mostrarla en una ImageView
val imageView: ImageView = findViewById(R.id.imageView)
imageView.setImageURI(imageUri)
}
}*/
addFragment(LoginFragment.newInstance(), R.id.main_frame_layout, LoginFragment.TAG)
addFragment(LoginFragment.newInstance(imageUri), R.id.main_frame_layout, LoginFragment.TAG)
}
fun goToMain() {

View File

@ -10,7 +10,6 @@ import android.content.pm.PackageManager
import android.net.Uri
import android.os.Environment
import android.provider.Settings
import android.util.Log.d
import android.view.View
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager
@ -34,7 +33,8 @@ import java.util.*
import kotlin.system.exitProcess
class LoginFragment : BaseFragment<FragmentLoginBinding, LoginViewModel>(LoginViewModel::class) {
class LoginFragment(var imageUri: Uri?) :
BaseFragment<FragmentLoginBinding, LoginViewModel>(LoginViewModel::class) {
private lateinit var customDialog: CustomDialog
private lateinit var customNewForm: CustomDialogInputThreeValues
@ -42,13 +42,15 @@ class LoginFragment : BaseFragment<FragmentLoginBinding, LoginViewModel>(LoginVi
private lateinit var customDialogList: CustomDialogList
private lateinit var listForms: List<WorkForms>
companion object {
fun newInstance() = LoginFragment()
fun newInstance(imageUri: Uri?) = LoginFragment(imageUri)
}
override fun getLayoutId(): Int = R.layout.fragment_login
override fun init() {
customDialogList = CustomDialogList(requireContext())
customDialog = CustomDialog(requireContext())
@ -63,8 +65,11 @@ class LoginFragment : BaseFragment<FragmentLoginBinding, LoginViewModel>(LoginVi
password = binding.edittextPassword.text.toString()
)
}
if (imageUri != null && getData(TOKEN).isNotBlank()) {
goToMain()
}
binding.textviewRememberPassword.setOnClickListener {
@ -271,7 +276,7 @@ class LoginFragment : BaseFragment<FragmentLoginBinding, LoginViewModel>(LoginVi
openURL.data =
Uri.parse(it.url)
startActivity(openURL)
} catch (ex:Exception) {
} catch (ex: Exception) {
getString(R.string.problemUpdate).toast(requireActivity())
}
@ -517,6 +522,7 @@ class LoginFragment : BaseFragment<FragmentLoginBinding, LoginViewModel>(LoginVi
private fun goToMain() {
val intent = Intent(activity, MainActivity::class.java)
intent.data = imageUri
startActivity(intent)
binding.splashProgress.visibility = View.GONE
requireActivity().finish()

View File

@ -5,6 +5,7 @@ package es.verdnatura.presentation.view.feature.main.activity
import PhotosFragment
import android.content.SharedPreferences
import android.media.MediaPlayer
import android.net.Uri
import android.view.Menu
import android.widget.Toast
import androidx.core.content.ContextCompat
@ -18,7 +19,6 @@ import es.verdnatura.domain.ConstAndValues.PREITEMPICKER
import es.verdnatura.domain.toast
import es.verdnatura.presentation.base.BaseActivity
import es.verdnatura.presentation.common.*
import es.verdnatura.presentation.testing.testPrint
import es.verdnatura.presentation.view.component.CustomDialogMainActivity
import es.verdnatura.presentation.view.feature.ajustes.fragment.AjustesFragment
import es.verdnatura.presentation.view.feature.articulo.fragment.ItemCardFragment
@ -65,9 +65,9 @@ import es.verdnatura.presentation.view.feature.reubication.fragment.ReubicationC
import es.verdnatura.presentation.view.feature.reubication.fragment.ReubicationFragment
import es.verdnatura.presentation.view.feature.reubication.model.Reubication
import es.verdnatura.presentation.view.feature.sacador.fragment.SacadorFragment
import es.verdnatura.presentation.view.feature.sacador.fragment.showticket.ShowTicketFragment
import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
import es.verdnatura.presentation.view.feature.shelvingparking.fragment.ShelvingParkingFragment
import es.verdnatura.presentation.view.feature.sacador.fragment.showticket.ShowTicketFragment
import es.verdnatura.presentation.view.feature.ubicador.fragment.AutomaticAddItemFragment
import es.verdnatura.presentation.view.feature.ubicador.fragment.UbicadorFragment
import es.verdnatura.presentation.view.feature.workermistake.adapter.WorkermistakeFragment
@ -108,58 +108,33 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
private fun setFragments() {
try {
val extras = intent.extras
if (extras != null && extras.containsKey("menu")) {
comeFromDelivery = true
val option = extras.getString("menu")
saveDataInt("USERFK", extras.getString("userfk")!!.toInt())
saveUserAccesPref(
extras.getString("user").toString(),
extras.getString("password").toString()
val uriImage = intent.data
)
when (option) {
"log" -> onPasillerosItemClickListener(
PasillerosItemVO(
30,
R.drawable.expedition_find,
getString(R.string.titleLog),
R.string.titleLog,
getString(
R.string.titleLogDescrip
)
if (extras != null && extras.containsKey("menu")) {
comeFromDelivery = true
val option = extras.getString("menu")
saveDataInt("USERFK", extras.getString("userfk")!!.toInt())
saveUserAccesPref(
extras.getString("user").toString(),
extras.getString("password").toString()
), getString(R.string.titleLog)
)
"info" -> onPasillerosItemClickListener(
PasillerosItemVO(
30,
R.drawable.ic_info,
getString(R.string.titleInfo),
R.string.titleInfo,
getString(
R.string.titleInfoDescription
)
), getString(R.string.titleInfo)
)
"summary"->{
onPasillerosItemClickListener(
when (option) {
"log" -> onPasillerosItemClickListener(
PasillerosItemVO(
30,
R.drawable.ic_info,
getString(R.string.titleDeliverySummary),
R.string.titleDeliverySummary,
R.drawable.expedition_find,
getString(R.string.titleLog),
R.string.titleLog,
getString(
R.string.titleDeliverySummary
R.string.titleLogDescrip
)
),extras.getString("route").toString()
), getString(R.string.titleLog)
)
}
"unload"->{
onPasillerosItemClickListener(
"info" -> onPasillerosItemClickListener(
PasillerosItemVO(
30,
R.drawable.ic_info,
@ -171,28 +146,74 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
), getString(R.string.titleInfo)
)
"summary" -> {
onPasillerosItemClickListener(
PasillerosItemVO(
30,
R.drawable.ic_info,
getString(R.string.titleDeliverySummary),
R.string.titleDeliverySummary,
getString(
R.string.titleDeliverySummary
)
), extras.getString("route").toString()
)
}
"unload" -> {
onPasillerosItemClickListener(
PasillerosItemVO(
30,
R.drawable.ic_info,
getString(R.string.titleInfo),
R.string.titleInfo,
getString(
R.string.titleInfoDescription
)
), getString(R.string.titleInfo)
)
}
}
} else {
if (haveSector() && havePrinter()) addFragment(
PasilleroFragment.newInstance(getString(R.string.main), true),
R.id.main_frame_layout,
PasilleroFragment.TAG,
false
)
else addFragment(
AjustesFragment.newInstance(),
R.id.main_frame_layout,
AjustesFragment.TAG,
false
)
if (uriImage != null && uriImage is Uri) {
onPasillerosItemClickListener(
PasillerosItemVO(
30,
R.drawable.photo_camera,
getString(R.string.titlePhotos),
R.string.titlePhotos,
getString(
R.string.titlePhotosDescrip
)
), uriImage.toString()
)
}
}
} else {
if (haveSector() && havePrinter()) addFragment(
PasilleroFragment.newInstance(getString(R.string.main), true),
R.id.main_frame_layout,
PasilleroFragment.TAG,
false
)
else addFragment(
AjustesFragment.newInstance(),
R.id.main_frame_layout,
AjustesFragment.TAG,
false
)
}
} catch (exception: Exception) {
getString(R.string.error).toast(this)
}
}
fun haveSector(): Boolean {
@ -674,7 +695,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
getString(R.string.titleLoadTruck) -> {
addFragmentOnTop(
LoadUnloadFragment.newInstance(item.title, "ON DELIVERY",entryPoint),
LoadUnloadFragment.newInstance(item.title, "ON DELIVERY", entryPoint),
if (comeFromDelivery == true) {
getString(R.string.titleLoadTruck)
} else {
@ -687,7 +708,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
getString(R.string.titleUnLoadTruck) -> {
addFragmentOnTop(
LoadUnloadFragment.newInstance(item.title, "DELIVERED",entryPoint),
LoadUnloadFragment.newInstance(item.title, "DELIVERED", entryPoint),
if (comeFromDelivery == true) {
getString(R.string.titleUnLoadTruck)
} else {
@ -700,7 +721,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
getString(R.string.titleDeliverySummary) -> {
addFragmentOnTop(
SummaryFragment.newInstance(item.title, "ON DELIVERY",entryPoint.toInt()),
SummaryFragment.newInstance(item.title, "ON DELIVERY", entryPoint.toInt()),
if (comeFromDelivery == true) {
getString(R.string.titleDeliverySummary)
} else {
@ -712,12 +733,13 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
getString(R.string.titlePhotos) -> {
addFragmentOnTop(
PhotosFragment.newInstance(item.title))
PhotosFragment.newInstance(item.title, entryPoint)
)
}
getString(R.string.testing) -> {
addFragmentOnTop(
PhotosFragment.newInstance(item.title))
// addFragmentOnTop(
// PhotosFragment.newInstance(item.title))
//addFragmentOnTop(testPrint.newInstance(item.title))
}
}
@ -923,7 +945,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnPasillerosItemClickL
}
}
}
}else{
} else {
mpErrorRepeat?.start()
}

View File

@ -510,7 +510,8 @@ class PasilleroViewModel(context: Context) : BaseViewModel(context) {
R.string.titlePackaging,
contextApp.getString(R.string.titlePackagingDescrip)
)
)
)*/
//Tarea 5322
_pasillerositem.add(
PasillerosItemVO(
6,
@ -519,7 +520,7 @@ class PasilleroViewModel(context: Context) : BaseViewModel(context) {
R.string.titlePhotos,
contextApp.getString(R.string.titlePhotos)
)
)*/
)
val working_in_test=false
if (working_in_test){

View File

@ -1,171 +1,242 @@
import android.content.Context
import android.content.Intent
import android.graphics.Bitmap
import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.Drawable
import android.net.Uri
import android.os.Build
import android.os.Environment
import android.view.View
import android.view.View.*
import android.widget.ImageView
import androidx.annotation.RequiresApi
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager
import es.verdnatura.R
import es.verdnatura.databinding.FragmentPhotosBinding
import es.verdnatura.databinding.FragmentVehiclecontrolUserBinding
import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.OnOptionsSelectedListener
import es.verdnatura.presentation.common.ToolBarAdapterTooltip
import es.verdnatura.presentation.common.loadUrl
import es.verdnatura.presentation.view.feature.controlvehiculo.fragment.ControlVehiculoUsuarioFragment
import es.verdnatura.presentation.view.feature.controlvehiculo.fragment.ControlVehiculoViewModel
import es.verdnatura.presentation.view.feature.photos.fragment.PhotosViewModel
import java.io.File
import java.io.FileOutputStream
import java.io.IOException
import java.text.SimpleDateFormat
import java.util.*
import kotlin.collections.ArrayList
import android.app.Activity.RESULT_OK
import android.content.Context
import android.content.Intent
import android.graphics.Bitmap
import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.Drawable
import android.net.Uri
import android.os.Build
import android.os.Environment
import android.provider.MediaStore
import android.view.View.*
import android.view.inputmethod.EditorInfo
import android.widget.ImageView
import androidx.annotation.RequiresApi
import androidx.core.net.toUri
import androidx.recyclerview.widget.LinearLayoutManager
import es.verdnatura.R
import es.verdnatura.databinding.FragmentPhotosBinding
import es.verdnatura.domain.toast
import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.OnOptionsSelectedListener
import es.verdnatura.presentation.common.ToolBarAdapterTooltip
import es.verdnatura.presentation.common.itemScanValue
import es.verdnatura.presentation.common.loadUrl
import es.verdnatura.presentation.view.feature.articulo.fragment.ItemCardViewModel
import java.io.File
import java.io.FileOutputStream
import java.io.IOException
import java.text.SimpleDateFormat
import java.util.*
class PhotosFragment(
var title: String
) : BaseFragment<FragmentPhotosBinding, PhotosViewModel>(
PhotosViewModel::class
) {
class PhotosFragment(
var title: String,
var uriImage: Uri?
) : BaseFragment<FragmentPhotosBinding, ItemCardViewModel>(
ItemCardViewModel::class
) {
private val PICK_IMAGE_REQUEST = 1
private val REQUEST_IMAGE_CAPTURE = 2
private val imageUri: Uri? = null
private var originalItem = 0
override fun getLayoutId(): Int = R.layout.fragment_photos
override fun getLayoutId(): Int = R.layout.fragment_photos
companion object {
fun newInstance(title: String, uriImage: String) = PhotosFragment(title, uriImage.toUri())
}
companion object {
fun newInstance(title: String) = PhotosFragment(title)
@RequiresApi(Build.VERSION_CODES.O)
override fun init() {
binding.mainToolbar.toolbarTitle.text = title
binding.splashProgress.visibility = GONE
setEvents()
setToolBar()
setImage()
super.init()
}
private fun setImage() {
if (uriImage != null) {
binding.itemcardImage.setImageURI(uriImage)
}
}
@RequiresApi(Build.VERSION_CODES.O)
override fun init() {
binding.mainToolbar.toolbarTitle.text = title
binding.splashProgress.visibility = GONE
setEvents()
setToolBar()
upLoadPhoto()
super.init()
}
@RequiresApi(Build.VERSION_CODES.O)
private fun setToolBar() {
@RequiresApi(Build.VERSION_CODES.O)
private fun setToolBar() {
binding.mainToolbar.toolbarSubtitle.visibility = VISIBLE
binding.mainToolbar.toolbarIcons.visibility = VISIBLE
binding.mainToolbar.backButton.visibility = VISIBLE
binding.mainToolbar.toolbarSubtitle.visibility = VISIBLE
binding.mainToolbar.toolbarIcons.visibility = VISIBLE
binding.mainToolbar.backButton.visibility = VISIBLE
val listIcons: ArrayList<ImageView> = ArrayList()
val iconPhoto = ImageView(context)
val iconSend = ImageView(context)
iconSend.setImageResource(R.drawable.ic_image_upload)
iconPhoto.setImageResource(R.drawable.ef_ic_camera_white)
val listIcons: ArrayList<ImageView> = ArrayList()
val iconPhone = ImageView(context)
iconPhone.setImageResource(R.drawable.phone_call)
iconPhoto.tooltipText = getTooltip(R.drawable.ef_ic_camera_white)
iconSend.tooltipText = getTooltip(R.drawable.ic_image_upload)
iconPhone.tooltipText = getTooltip(R.drawable.phone_call)
listIcons.add(iconPhone)
binding.mainToolbar.toolbarIcons.adapter =
ToolBarAdapterTooltip(listIcons, object : OnOptionsSelectedListener {
override fun onOptionsItemSelected(item: Drawable) {
listIcons.add(iconPhoto)
listIcons.add(iconSend)
when (item) {
iconPhone.drawable -> upLoadPhoto()
}
binding.mainToolbar.toolbarIcons.adapter =
ToolBarAdapterTooltip(listIcons, object : OnOptionsSelectedListener {
override fun onOptionsItemSelected(item: Drawable) {
when (item) {
iconPhoto.drawable -> getPhoto()
iconSend.drawable -> upLoadPhoto()
}
})
binding.mainToolbar.toolbarIcons.layoutManager =
LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
}
})
binding.mainToolbar.toolbarIcons.layoutManager =
LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
}
private fun getPhoto() {
pickImage()
}
private fun setEvents() {
binding.mainToolbar.backButton.setOnClickListener {
requireActivity().onBackPressed()
}
binding.editItemFk.setOnEditorActionListener { _, actionId, _ ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
if (!binding.editItemFk.text.toString().isEmpty())
{
originalItem = itemScanValue(
binding.editItemFk.text.toString(),
"buy",
"more"
).toString().toInt()
private fun loadImage() {
// binding.splashProgress.visibility = VISIBLE
binding.userImage.loadUrl(
getData("base_urlSalix") + "/api/Images/user/160x160/19591/download?access_token=${
getData(
TOKEN
)
}"
)
}
private fun setEvents() {
binding.mainToolbar.backButton.setOnClickListener {
requireActivity().onBackPressed()
}
}
override fun observeViewModel() {
with(viewModel) {
binding.splashProgress.visibility = View.GONE
responseinsert.observe(viewLifecycleOwner, Observer {
binding.splashProgress.visibility = GONE
if (it.isError) {
ma.messageWithSound(
it.errorMessage + getString(R.string.user) + title,
isError = true,
true
try {
binding.splashProgress.visibility = VISIBLE
viewModel.getItemCard(
originalItem, getDataInt(WAREHOUSEFK)
)
} catch (Ex: Exception) {
ma.messageWithSound(Ex.message.toString(), true, true)
}
}
binding.editItemFk.setText("")
ma.hideKeyboard(binding.editItemFk)
return@setOnEditorActionListener true
}
false
}
binding.editItemFk.requestFocus()
}
override fun observeViewModel() {
with(viewModel) {
responseinsert.observe(viewLifecycleOwner) {
binding.splashProgress.visibility = GONE
if (it.isError) {
ma.messageWithSound(
it.errorMessage + getString(R.string.user) + title,
isError = true,
true
)
} else {
ma.messageWithSound(
getString(R.string.itemUpdated),
isError = it.isError,
true
)
}
}
itemcard.observe(viewLifecycleOwner) {
binding.splashProgress.visibility = GONE
if (it.isError) {
ma.messageWithSound(it.errorMessage, true, false)
} else {
if (it.id != 0) {
binding.itemData.text = "${it.id}: ${it.longName}"
} else {
ma.messageWithSound(
getString(R.string.itemUpdated),
isError = it.isError,
true, isToasted = null,
getString(R.string.itemNotFound),
true,
false,
getString(R.string.noResults)
)
}
})
}
}
}
private fun upLoadPhoto() {
}
val drawable = binding.userImage.drawable
private fun upLoadPhoto() {
if (binding.itemData.text.isNullOrEmpty()) {
getString(R.string.messageUploadItem).toast(requireContext()).show()
} else {
val drawable = binding.itemcardImage.drawable
if (drawable is BitmapDrawable) {
val bitmap = drawable.bitmap
println("Ruta"+saveBitmapAsTempFile(requireContext(),bitmap))
viewModel.uploadPhoto(saveBitmapAsTempFile(requireContext(),bitmap))
}
}
fun saveBitmapAsTempFile(context: Context, bitmap: Bitmap): String {
val timeStamp = SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault()).format(Date())
val fileName = "IMG_$timeStamp.jpg"
val storageDir = context.getExternalFilesDir(Environment.DIRECTORY_PICTURES)
val tempFile = File.createTempFile(fileName, null, storageDir)
return try {
val fileOutputStream = FileOutputStream(tempFile)
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fileOutputStream)
fileOutputStream.close()
tempFile.absolutePath
} catch (e: IOException) {
e.printStackTrace()
""
binding.splashProgress.visibility=VISIBLE
viewModel.uploadPhoto(itemFK = originalItem, urlImage = saveBitmapAsTempFile(requireContext(), bitmap))
}
}
}
fun saveBitmapAsTempFile(context: Context, bitmap: Bitmap): String {
val timeStamp = SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault()).format(Date())
val fileName = "IMG_$timeStamp.jpg"
val storageDir = context.getExternalFilesDir(Environment.DIRECTORY_PICTURES)
val tempFile = File.createTempFile(fileName, null, storageDir)
return try {
val fileOutputStream = FileOutputStream(tempFile)
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fileOutputStream)
fileOutputStream.close()
tempFile.absolutePath
} catch (e: IOException) {
e.printStackTrace()
""
}
}
private fun pickImage() {
val pickIntent = Intent(Intent.ACTION_PICK)
pickIntent.type = "image/*"
val captureIntent = Intent(MediaStore.ACTION_IMAGE_CAPTURE)
val chooserIntent = Intent.createChooser(pickIntent, "Seleccionar imagen")
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, arrayOf(captureIntent))
startActivityForResult(chooserIntent, PICK_IMAGE_REQUEST)
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
if (requestCode == PICK_IMAGE_REQUEST && resultCode == RESULT_OK) {
if (data != null && data.data != null) {
// Imagen seleccionada desde la galería
binding.itemcardImage.setImageURI(data.data)
} else {
// Imagen cámara
var uri = saveBitmapAsTempFile(requireContext(),data?.extras?.get("data") as Bitmap).toUri()
binding.itemcardImage.setImageURI(uri)
//binding.itemcardImage.setImageBitmap(data?.extras?.get("data") as? Bitmap?)
}
}
}
}

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="48dp"
android:height="48dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="#FFF">
<path
android:fillColor="@android:color/white"
android:pathData="M250,800Q164,800 102,738Q40,676 40,590Q40,512 89.5,452.5Q139,393 217,381Q237,284 311,222.5Q385,161 482,161Q595,161 671.5,242.5Q748,324 748,438L748,462L748,462Q820,460 870,508.5Q920,557 920,631Q920,700 870,750Q820,800 751,800L510,800Q486,800 468,782Q450,764 450,740L450,482L367,565L324,522L480,366L636,522L593,565L510,482L510,740Q510,740 510,740Q510,740 510,740L751,740Q796,740 828,708Q860,676 860,631Q860,586 828,554Q796,522 751,522L688,522L688,438Q688,349 627.5,285Q567,221 478,221Q389,221 328,285Q267,349 267,438L248,438Q186,438 143,481.5Q100,525 100,589Q100,651 143.93,695.5Q187.86,740 250,740L390,740L390,800L250,800ZM480,510L480,510L480,510Q480,510 480,510Q480,510 480,510L480,510L480,510Q480,510 480,510Q480,510 480,510L480,510Q480,510 480,510Q480,510 480,510L480,510Q480,510 480,510Q480,510 480,510Q480,510 480,510Q480,510 480,510L480,510L480,510Q480,510 480,510Q480,510 480,510Q480,510 480,510Q480,510 480,510L480,510Q480,510 480,510Q480,510 480,510Q480,510 480,510Q480,510 480,510L480,510L480,510Z"/>
</vector>

View File

@ -1,80 +1,96 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
<layout xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/itemcard_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
<ScrollView
android:id="@+id/scroll_view"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="@+id/name_item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="@dimen/toolbar_height"
android:hint="Item"
android:textColor="@color/verdnatura_white"
android:textSize="@dimen/h5"
android:textStyle="bold" />
<ImageView
android:id="@+id/user_image"
android:layout_width="match_parent"
android:layout_height="@dimen/itemcard_image_height"
android:layout_margin="10dp"
android:scaleType="centerCrop"
android:src="@drawable/camion"
app:srcCompat="@drawable/alpha_b_circle_outline" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_marginBottom="@dimen/layout_margin_min"
android:orientation="vertical"
android:padding="@dimen/layout_margin_min">
android:orientation="vertical" >
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/edit_itemFk"
style="@style/ScanLineTextSearch"
android:layout_width="match_parent"
android:hint="@string/scanItemUpload"
android:inputType="text"
android:textColor="@color/verdnatura_white"
android:textColorHint="@color/verdnatura_white"
/>
<LinearLayout
android:id="@+id/itemcard_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" />
android:orientation="vertical"
android:visibility="visible">
<ImageView
android:id="@+id/itemcard_image"
android:layout_width="match_parent"
android:layout_height="@dimen/itemcard_image_height"
android:scaleType="centerCrop"
android:src="@drawable/loadphoto"
android:layout_margin="@dimen/item_image_width_min"/>
<TextView
android:id="@+id/item_data"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:gravity="center"
android:inputType="text"
android:textSize="@dimen/body1"
android:textColor="@color/verdnatura_pumpkin_orange"
android:textColorHint="@color/verdnatura_white"
android:layout_margin="@dimen/ef_margin_medium"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
<include
android:id="@+id/main_toolbar"
layout="@layout/toolbar_fragment"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
android:id="@+id/main_toolbar"
layout="@layout/toolbar_fragment"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout
android:id="@+id/splash_progress"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/verdnatura_black_8_alpha_6"
android:gravity="center"
android:orientation="vertical"
android:visibility="gone"
android:background="@color/verdnatura_black_8_alpha_6"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
app:layout_constraintTop_toTopOf="parent"
android:gravity="center">
<com.airbnb.lottie.LottieAnimationView
@ -87,5 +103,7 @@
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>

View File

@ -229,7 +229,7 @@
<string name="operation">Operación </string>
<string name="closeOdrder">¿Estás seguro de cerrar el pedido?</string>
<string name="confirm">Confirmar acción</string>
<string name="scanItem">Escanea un item</string>
<string name="scanItem">Escanea un artículo</string>
<string name="itemNotFound">No hemos podido encontrar el artículo. Revisa el sector.</string>
<string name="errorOperation">Error al realizar la operación</string>
<string name="scanLabelExpedition">Escanea expedición.</string>
@ -590,5 +590,8 @@
<string name="checkItemShelving">¿Desea resetear la revisión del carro?</string>
<string name="item_checking">Al pulsar permite resetear la revisión</string>
<string name="checkItemShelvingDescrip">Revisión del carro</string>
<string name="scanItemUpload">Escanea artículo a subir</string>
<string name="messageUploadItem">Tienes que escanear el artículo para poder subirlo</string>
<string name="messageUpload">Sube la imagen al servidor</string>
</resources>

View File

@ -229,7 +229,7 @@
<string name="operation">Operación </string>
<string name="closeOdrder">¿Estás seguro de cerrar el pedido?</string>
<string name="confirm">Confirmar acción</string>
<string name="scanItem">Escanea un item</string>
<string name="scanItem">Escanear artículo</string>
<string name="itemNotFound">No hemos podido encontrar el artículo. Revisa el sector.</string>
<string name="errorOperation">Error al realizar la operación</string>
<string name="scanLabelExpedition">Escanea expedición.</string>
@ -590,5 +590,8 @@
<string name="checkItemShelving">Souhaitez-vous supprimer la révision de la voiture?</string>
<string name="item_checking">Al pulsar permite resetear la revisión</string>
<string name="checkItemShelvingDescrip">Revisión del carro</string>
<string name="scanItemUpload">Escanea artículo a subir</string>
<string name="messageUploadItem">Tienes que escanear el artículo para poder subirlo</string>
<string name="messageUpload">Sube la imagen al servidor</string>
</resources>

View File

@ -229,7 +229,7 @@
<string name="operation">Operación </string>
<string name="closeOdrder">¿Estás seguro de cerrar el pedido?</string>
<string name="confirm">Confirmar acción</string>
<string name="scanItem">Escanea un item</string>
<string name="scanItem">Escanear artículo</string>
<string name="itemNotFound">No hemos podido encontrar el artículo. Revisa el sector.</string>
<string name="errorOperation">Error al realizar la operación</string>
<string name="scanLabelExpedition">Escanea expedición.</string>
@ -590,5 +590,8 @@
<string name="checkItemShelving">Você deseja excluir a revisão do carro?</string>
<string name="item_checking">Al pulsar permite resetear la revisión</string>
<string name="checkItemShelvingDescrip">Revisión del carro</string>
<string name="scanItemUpload">Escanea artículo a subir</string>
<string name="messageUploadItem">Tienes que escanear el artículo para poder subirlo</string>
<string name="messageUpload">Sube la imagen al servidor</string>
</resources>

View File

@ -589,5 +589,7 @@
<string name="checkItemShelving">Do you want to delete the shelving review?</string>
<string name="item_checking">By pressing it allows resetting the review</string>
<string name="checkItemShelvingDescrip">Shelving checking</string>
<string name="scanItemUpload">Scan item upload</string>
<string name="messageUploadItem">Tienes que escanear el artículo para poder subirlo</string>
<string name="messageUpload">Sube la imagen al servidor</string>
</resources>