diff --git a/.idea/gradle.xml b/.idea/gradle.xml index fed8fa3..7b46144 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -7,8 +7,7 @@ - - + diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 0423065..2f39eef 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -4,10 +4,12 @@ + android:required="false" /> + + android:required="false" /> + @@ -53,5 +55,4 @@ android:value="" /> - \ No newline at end of file diff --git a/app/src/main/java/com/navinfo/volvo/http/DefaultResponse.kt b/app/src/main/java/com/navinfo/volvo/http/DefaultResponse.kt index 891d756..fc19aa9 100644 --- a/app/src/main/java/com/navinfo/volvo/http/DefaultResponse.kt +++ b/app/src/main/java/com/navinfo/volvo/http/DefaultResponse.kt @@ -2,6 +2,6 @@ package com.navinfo.volvo.http class DefaultResponse { var code: Int = 0 - var message: String = "" + var msg: String = "" var data: T? = null } \ No newline at end of file diff --git a/app/src/main/java/com/navinfo/volvo/http/NavinfoVolvoCall.kt b/app/src/main/java/com/navinfo/volvo/http/NavinfoVolvoCall.kt index 3e1bf0c..3efa75b 100644 --- a/app/src/main/java/com/navinfo/volvo/http/NavinfoVolvoCall.kt +++ b/app/src/main/java/com/navinfo/volvo/http/NavinfoVolvoCall.kt @@ -1,10 +1,7 @@ package com.navinfo.volvo.http -import com.navinfo.volvo.db.dao.entity.Attachment import retrofit2.Retrofit import retrofit2.converter.gson.GsonConverterFactory -import retrofit2.create -import java.io.File class NavinfoVolvoCall { companion object { diff --git a/app/src/main/java/com/navinfo/volvo/ui/MainActivity.kt b/app/src/main/java/com/navinfo/volvo/ui/MainActivity.kt index ef554b7..5775985 100644 --- a/app/src/main/java/com/navinfo/volvo/ui/MainActivity.kt +++ b/app/src/main/java/com/navinfo/volvo/ui/MainActivity.kt @@ -1,7 +1,5 @@ package com.navinfo.volvo.ui -import android.content.DialogInterface -import android.content.Intent import android.content.DialogInterface import android.os.Bundle import android.view.View @@ -11,10 +9,26 @@ import androidx.navigation.findNavController import androidx.navigation.ui.AppBarConfiguration import androidx.navigation.ui.setupActionBarWithNavController import androidx.navigation.ui.setupWithNavController +import com.easytools.tools.FileUtils +import com.elvishew.xlog.LogConfiguration +import com.elvishew.xlog.LogLevel +import com.elvishew.xlog.XLog +import com.elvishew.xlog.interceptor.BlacklistTagsFilterInterceptor +import com.elvishew.xlog.printer.AndroidPrinter +import com.elvishew.xlog.printer.ConsolePrinter +import com.elvishew.xlog.printer.Printer +import com.elvishew.xlog.printer.file.FilePrinter +import com.elvishew.xlog.printer.file.backup.NeverBackupStrategy +import com.elvishew.xlog.printer.file.naming.DateFileNameGenerator import com.google.android.material.bottomnavigation.BottomNavigationView import com.google.android.material.dialog.MaterialAlertDialogBuilder +import com.hjq.permissions.OnPermissionCallback +import com.hjq.permissions.Permission +import com.hjq.permissions.XXPermissions +import com.navinfo.volvo.BuildConfig import com.navinfo.volvo.R import com.navinfo.volvo.databinding.ActivityMainBinding +import com.navinfo.volvo.utils.SystemConstant import dagger.hilt.android.AndroidEntryPoint @AndroidEntryPoint diff --git a/app/src/main/java/com/navinfo/volvo/ui/camera/CameraFragment.kt b/app/src/main/java/com/navinfo/volvo/ui/camera/CameraFragment.kt index d4d5bed..1ce309f 100644 --- a/app/src/main/java/com/navinfo/volvo/ui/camera/CameraFragment.kt +++ b/app/src/main/java/com/navinfo/volvo/ui/camera/CameraFragment.kt @@ -13,7 +13,7 @@ import com.easytools.tools.DateUtils import com.easytools.tools.FileUtils import com.elvishew.xlog.XLog import com.navinfo.volvo.databinding.FragmentCameraBinding -import com.navinfo.volvo.ui.message.ObtainMessageViewModel +import com.navinfo.volvo.ui.fragments.message.ObtainMessageViewModel import com.navinfo.volvo.utils.SystemConstant import com.otaliastudios.cameraview.CameraListener import com.otaliastudios.cameraview.CameraView diff --git a/app/src/main/java/com/navinfo/volvo/ui/fragments/message/ObtainMessageFragment.kt b/app/src/main/java/com/navinfo/volvo/ui/fragments/message/ObtainMessageFragment.kt index 223996b..43a4a65 100644 --- a/app/src/main/java/com/navinfo/volvo/ui/fragments/message/ObtainMessageFragment.kt +++ b/app/src/main/java/com/navinfo/volvo/ui/fragments/message/ObtainMessageFragment.kt @@ -17,6 +17,7 @@ import androidx.lifecycle.Observer import androidx.lifecycle.ViewModelProvider import androidx.navigation.Navigation import com.bumptech.glide.Glide +import com.bumptech.glide.load.engine.DiskCacheStrategy import com.easytools.tools.DateUtils import com.easytools.tools.ToastUtils import com.elvishew.xlog.XLog @@ -28,10 +29,10 @@ import com.hjq.permissions.XXPermissions import com.navinfo.volvo.R import com.navinfo.volvo.RecorderLifecycleObserver import com.navinfo.volvo.databinding.FragmentObtainMessageBinding -import com.navinfo.volvo.db.dao.entity.Attachment -import com.navinfo.volvo.db.dao.entity.AttachmentType -import com.navinfo.volvo.db.dao.entity.Message import com.navinfo.volvo.http.NavinfoVolvoCall +import com.navinfo.volvo.model.Attachment +import com.navinfo.volvo.model.AttachmentType +import com.navinfo.volvo.model.Message import com.navinfo.volvo.ui.markRequiredInRed import com.navinfo.volvo.utils.EasyMediaFile import com.navinfo.volvo.utils.SystemConstant @@ -75,7 +76,13 @@ class ObtainMessageFragment: Fragment() { if(it.title?.isNotEmpty() == true) binding.tvMessageTitle?.setText(it.title) if (it.sendDate?.isNotEmpty() == true) { - binding.btnSendTime.text = it.sendDate + // 获取当前发送时间,如果早于当前时间,则显示现在 + val sendDate = DateUtils.str2Date(it.sendDate, "yyyy-MM-dd HH:mm:ss") + if (sendDate<=Date()) { + binding.btnSendTime.text = "现在" + } else { + binding.btnSendTime.text = it.sendDate + } } var hasPhoto = false var hasAudio = false @@ -86,6 +93,7 @@ class ObtainMessageFragment: Fragment() { Glide.with(context!!) .asBitmap().fitCenter() .load(attachment.pathUrl) + .diskCacheStrategy(DiskCacheStrategy.ALL) .into(binding.imgMessageAttachment) // 显示名称 hasPhoto = true @@ -130,14 +138,20 @@ class ObtainMessageFragment: Fragment() { fun initView() { // 设置问候信息提示的红色星号 - binding.tiLayoutTitle.markRequiredInRed() - binding.tvMessageTitle.addTextChangedListener { - obtainMessageViewModel.updateMessageTitle(it.toString()) +// binding.tiLayoutTitle.markRequiredInRed() +// binding.tvMessageTitle.addTextChangedListener(afterTextChanged = { +// obtainMessageViewModel.updateMessageTitle(it.toString()) +// }) + + binding.tvMessageTitle.setOnFocusChangeListener { view, b -> + if (!b) { + obtainMessageViewModel.updateMessageTitle(binding.tvMessageTitle.text.toString()) + } } - binding.edtSendFrom.addTextChangedListener { + binding.edtSendFrom.addTextChangedListener (afterTextChanged = { obtainMessageViewModel.updateMessageSendFrom(it.toString()) - } + }) binding.imgPhotoDelete.setOnClickListener { obtainMessageViewModel.updateMessagePic(null) @@ -167,9 +181,9 @@ class ObtainMessageFragment: Fragment() { override fun onClickListener(selectTime: String) { val sendDate = DateUtils.str2Date(selectTime, "yyyy-MM-dd HH:mm") if (sendDate <= Date()) { - obtainMessageViewModel.updateMessageSendTime("现在") + obtainMessageViewModel.updateMessageSendTime(DateUtils.date2Str(Date(), "yyyy-MM-dd HH:mm:ss")) } else { - obtainMessageViewModel.updateMessageSendTime(selectTime) + obtainMessageViewModel.updateMessageSendTime(DateUtils.date2Str(sendDate, "yyyy-MM-dd HH:mm:ss")) } } diff --git a/app/src/main/java/com/navinfo/volvo/ui/fragments/message/ObtainMessageViewModel.kt b/app/src/main/java/com/navinfo/volvo/ui/fragments/message/ObtainMessageViewModel.kt index f63571b..3a026b1 100644 --- a/app/src/main/java/com/navinfo/volvo/ui/fragments/message/ObtainMessageViewModel.kt +++ b/app/src/main/java/com/navinfo/volvo/ui/fragments/message/ObtainMessageViewModel.kt @@ -3,12 +3,13 @@ package com.navinfo.volvo.ui.fragments.message import androidx.lifecycle.* import com.easytools.tools.ToastUtils import com.elvishew.xlog.XLog -import com.navinfo.volvo.db.dao.entity.Attachment -import com.navinfo.volvo.db.dao.entity.AttachmentType -import com.navinfo.volvo.db.dao.entity.Message import com.navinfo.volvo.http.NavinfoVolvoCall +import com.navinfo.volvo.model.Attachment +import com.navinfo.volvo.model.AttachmentType +import com.navinfo.volvo.model.Message import kotlinx.coroutines.launch import okhttp3.MediaType +import okhttp3.MediaType.Companion.toMediaTypeOrNull import okhttp3.MultipartBody import okhttp3.RequestBody import java.io.File @@ -122,7 +123,7 @@ class ObtainMessageViewModel: ViewModel() { viewModelScope.launch { try { val requestFile: RequestBody = - RequestBody.create(MediaType.parse("multipart/form-data"), attachmentFile) + RequestBody.create("multipart/form-data".toMediaTypeOrNull(), attachmentFile) val body = MultipartBody.Part.createFormData("picture", attachmentFile.getName(), requestFile) val result = NavinfoVolvoCall.getApi().uploadAttachment(body) XLog.d(result.code) @@ -133,7 +134,7 @@ class ObtainMessageViewModel: ViewModel() { downloadAttachment(fileKey, attachmentType) } } else { - ToastUtils.showToast(result.message) + ToastUtils.showToast(result.msg) } } catch (e: Exception) { ToastUtils.showToast(e.message) @@ -163,7 +164,7 @@ class ObtainMessageViewModel: ViewModel() { } } } else { - ToastUtils.showToast(result.message) + ToastUtils.showToast(result.msg) } } catch (e: Exception) { ToastUtils.showToast(e.message) @@ -192,7 +193,7 @@ class ObtainMessageViewModel: ViewModel() { message.netId = netId!! // 尝试保存数据到本地 } else { - ToastUtils.showToast(result.message) + ToastUtils.showToast(result.msg) } } catch (e: Exception) { ToastUtils.showToast(e.message) @@ -206,6 +207,7 @@ class ObtainMessageViewModel: ViewModel() { try { val message = msgLiveData.value val insertData = mapOf( + "id" to message?.netId, "name" to message?.title, "imageUrl" to getImageAttachment(message?.attachment!!)?.pathUrl, "mediaUrl" to getAudioAttachment(message?.attachment!!)?.pathUrl, @@ -221,7 +223,7 @@ class ObtainMessageViewModel: ViewModel() { message.netId = netId!! // 尝试保存数据到本地 } else { - ToastUtils.showToast(result.message) + ToastUtils.showToast(result.msg) } } catch (e: Exception) { ToastUtils.showToast(e.message) diff --git a/app/src/main/res/layout/fragment_obtain_message.xml b/app/src/main/res/layout/fragment_obtain_message.xml index 0a482c1..b40c6bb 100644 --- a/app/src/main/res/layout/fragment_obtain_message.xml +++ b/app/src/main/res/layout/fragment_obtain_message.xml @@ -27,7 +27,7 @@ app:counterEnabled="true" app:counterMaxLength="10" app:errorEnabled="true" - android:hint="请输入问候信息" + android:hint="问候信息" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent"