Commit 179394eb by zhangchengbo

feat:增加彩信输入框-仅支持选择照片与拍照

parent 67ffa9d7
...@@ -159,7 +159,7 @@ class ThreadActivity : SimpleActivity() { ...@@ -159,7 +159,7 @@ class ThreadActivity : SimpleActivity() {
} }
} }
// setupAttachmentPickerView() setupAttachmentPickerView()
setupKeyboardListener() setupKeyboardListener()
hideAttachmentPicker() hideAttachmentPicker()
maybeSetupRecycleBinView() maybeSetupRecycleBinView()
...@@ -353,9 +353,9 @@ class ThreadActivity : SimpleActivity() { ...@@ -353,9 +353,9 @@ class ThreadActivity : SimpleActivity() {
addAttachment(capturedImageUri!!) addAttachment(capturedImageUri!!)
} else if (data != null) { } else if (data != null) {
when (requestCode) { when (requestCode) {
CAPTURE_VIDEO_INTENT, PICK_DOCUMENT_INTENT, CAPTURE_AUDIO_INTENT, PICK_PHOTO_INTENT, PICK_VIDEO_INTENT -> addAttachment(data) /*CAPTURE_VIDEO_INTENT, PICK_DOCUMENT_INTENT, CAPTURE_AUDIO_INTENT, PICK_VIDEO_INTENT ,*/ PICK_PHOTO_INTENT -> addAttachment(data)
PICK_CONTACT_INTENT -> addContactAttachment(data) // PICK_CONTACT_INTENT -> addContactAttachment(data)
PICK_SAVE_FILE_INTENT -> saveAttachment(resultData) // PICK_SAVE_FILE_INTENT -> saveAttachment(resultData)
} }
} }
} }
...@@ -1620,13 +1620,13 @@ class ThreadActivity : SimpleActivity() { ...@@ -1620,13 +1620,13 @@ class ThreadActivity : SimpleActivity() {
} }
private fun updateMessageType() { private fun updateMessageType() {
val text = binding.messageHolder.threadTypeMessage.text.toString() /*val text = binding.messageHolder.threadTypeMessage.text.toString()
val stringId = if (isMmsMessage(text)) { val stringId = if (isMmsMessage(text)) {
R.string.mms R.string.mms
} else { } else {
R.string.sms R.string.sms
} }*/
binding.messageHolder.threadSendMessage.setText(stringId) binding.messageHolder.threadSendMessage.setText(R.string.sms)
} }
private fun showScheduledMessageInfo(message: Message) { private fun showScheduledMessageInfo(message: Message) {
...@@ -1793,31 +1793,31 @@ class ThreadActivity : SimpleActivity() { ...@@ -1793,31 +1793,31 @@ class ThreadActivity : SimpleActivity() {
choosePhoto.setOnClickListener { choosePhoto.setOnClickListener {
launchGetContentIntent(arrayOf("image/*"), PICK_PHOTO_INTENT) launchGetContentIntent(arrayOf("image/*"), PICK_PHOTO_INTENT)
} }
chooseVideo.setOnClickListener {
launchGetContentIntent(arrayOf("video/*"), PICK_VIDEO_INTENT)
}
takePhoto.setOnClickListener { takePhoto.setOnClickListener {
launchCapturePhotoIntent() launchCapturePhotoIntent()
} }
recordVideo.setOnClickListener { /* chooseVideo.setOnClickListener {
launchCaptureVideoIntent() launchGetContentIntent(arrayOf("video/*"), PICK_VIDEO_INTENT)
} }
recordAudio.setOnClickListener { recordVideo.setOnClickListener {
launchCaptureAudioIntent() launchCaptureVideoIntent()
} }
pickFile.setOnClickListener { recordAudio.setOnClickListener {
launchGetContentIntent(arrayOf("*/*"), PICK_DOCUMENT_INTENT) launchCaptureAudioIntent()
} }
pickContact.setOnClickListener { pickFile.setOnClickListener {
launchPickContactIntent() launchGetContentIntent(arrayOf("*/*"), PICK_DOCUMENT_INTENT)
} }
scheduleMessage.setOnClickListener { pickContact.setOnClickListener {
if (isScheduledMessage) { launchPickContactIntent()
launchScheduleSendDialog(scheduledDateTime) }
} else { scheduleMessage.setOnClickListener {
launchScheduleSendDialog() if (isScheduledMessage) {
} launchScheduleSendDialog(scheduledDateTime)
} } else {
launchScheduleSendDialog()
}
}*/
} }
private fun showAttachmentPicker() { private fun showAttachmentPicker() {
......
package com.secspace.sms.adapters package com.secspace.sms.adapters
import android.content.Intent
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.util.Log
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.Toast
import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
...@@ -18,15 +21,12 @@ import com.bumptech.glide.request.RequestListener ...@@ -18,15 +21,12 @@ import com.bumptech.glide.request.RequestListener
import com.bumptech.glide.request.RequestOptions import com.bumptech.glide.request.RequestOptions
import com.bumptech.glide.request.target.Target import com.bumptech.glide.request.target.Target
import com.secspace.sms.R import com.secspace.sms.R
import com.secspace.sms.activities.VCardViewerActivity
import com.secspace.sms.databinding.ItemAttachmentDocumentPreviewBinding import com.secspace.sms.databinding.ItemAttachmentDocumentPreviewBinding
import com.secspace.sms.databinding.ItemAttachmentMediaPreviewBinding import com.secspace.sms.databinding.ItemAttachmentMediaPreviewBinding
import com.secspace.sms.databinding.ItemAttachmentVcardPreviewBinding import com.secspace.sms.databinding.ItemAttachmentVcardPreviewBinding
import com.secspace.sms.extensions.config import com.secspace.sms.extensions.*
import com.secspace.sms.extensions.isVideoMimeType import com.secspace.sms.helpers.*
import com.secspace.sms.helpers.ATTACHMENT_DOCUMENT
import com.secspace.sms.helpers.ATTACHMENT_MEDIA
import com.secspace.sms.helpers.ATTACHMENT_VCARD
import com.secspace.sms.helpers.ImageCompressor
import com.secspace.sms.models.AttachmentSelection import com.secspace.sms.models.AttachmentSelection
import com.simplemobiletools.commons.activities.BaseSimpleActivity import com.simplemobiletools.commons.activities.BaseSimpleActivity
import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.extensions.*
...@@ -42,6 +42,8 @@ class AttachmentsAdapter( ...@@ -42,6 +42,8 @@ class AttachmentsAdapter(
private val resources = activity.resources private val resources = activity.resources
private val primaryColor = activity.getProperPrimaryColor() private val primaryColor = activity.getProperPrimaryColor()
private val imageCompressor by lazy { ImageCompressor(activity) } private val imageCompressor by lazy { ImageCompressor(activity) }
private val TAG = "AttachmentsAdapter"
private var isShowToast = false
val attachments = mutableListOf<AttachmentSelection>() val attachments = mutableListOf<AttachmentSelection>()
...@@ -64,7 +66,7 @@ class AttachmentsAdapter( ...@@ -64,7 +66,7 @@ class AttachmentsAdapter(
override fun onBindViewHolder(holder: AttachmentsViewHolder, position: Int) { override fun onBindViewHolder(holder: AttachmentsViewHolder, position: Int) {
val attachment = getItem(position) val attachment = getItem(position)
holder.bindView { binding, _ -> holder.bindView { binding, _ ->
/*when (attachment.viewType) { when (attachment.viewType) {
ATTACHMENT_DOCUMENT -> { ATTACHMENT_DOCUMENT -> {
(binding as ItemAttachmentDocumentPreviewBinding).setupDocumentPreview( (binding as ItemAttachmentDocumentPreviewBinding).setupDocumentPreview(
uri = attachment.uri, uri = attachment.uri,
...@@ -74,6 +76,7 @@ class AttachmentsAdapter( ...@@ -74,6 +76,7 @@ class AttachmentsAdapter(
onRemoveButtonClicked = { removeAttachment(attachment) } onRemoveButtonClicked = { removeAttachment(attachment) }
) )
} }
ATTACHMENT_VCARD -> { ATTACHMENT_VCARD -> {
(binding as ItemAttachmentVcardPreviewBinding).setupVCardPreview( (binding as ItemAttachmentVcardPreviewBinding).setupVCardPreview(
activity = activity, activity = activity,
...@@ -87,11 +90,12 @@ class AttachmentsAdapter( ...@@ -87,11 +90,12 @@ class AttachmentsAdapter(
onRemoveButtonClicked = { removeAttachment(attachment) } onRemoveButtonClicked = { removeAttachment(attachment) }
) )
} }
ATTACHMENT_MEDIA -> setupMediaPreview( ATTACHMENT_MEDIA -> setupMediaPreview(
binding = binding as ItemAttachmentMediaPreviewBinding, binding = binding as ItemAttachmentMediaPreviewBinding,
attachment = attachment attachment = attachment
) )
}*/ }
} }
} }
...@@ -107,18 +111,26 @@ class AttachmentsAdapter( ...@@ -107,18 +111,26 @@ class AttachmentsAdapter(
attachments.removeAll { AttachmentSelection.areItemsTheSame(it, attachment) } attachments.removeAll { AttachmentSelection.areItemsTheSame(it, attachment) }
attachments.add(attachment) attachments.add(attachment)
submitList(attachments.toList()) submitList(attachments.toList())
Log.d(TAG, "addAttachment: attachments = ${attachments.size}")
if (attachments.size == 1 && !isShowToast) {
isShowToast = true
Toast.makeText(activity, "正在转换为彩信...", Toast.LENGTH_SHORT).show()
}
} }
private fun removeAttachment(attachment: AttachmentSelection) { private fun removeAttachment(attachment: AttachmentSelection) {
attachments.removeAll { AttachmentSelection.areItemsTheSame(it, attachment) } attachments.removeAll { AttachmentSelection.areItemsTheSame(it, attachment) }
Log.d(TAG, "removeAttachment: attachments = ${attachments.size}")
if (attachments.isEmpty()) { if (attachments.isEmpty()) {
isShowToast = false
Toast.makeText(activity, "正在转换为短信...", Toast.LENGTH_SHORT).show()
clear() clear()
} else { } else {
submitList(attachments.toList()) submitList(attachments.toList())
} }
} }
/*private fun setupMediaPreview(binding: ItemAttachmentMediaPreviewBinding, attachment: AttachmentSelection) { private fun setupMediaPreview(binding: ItemAttachmentMediaPreviewBinding, attachment: AttachmentSelection) {
binding.apply { binding.apply {
mediaAttachmentHolder.background.applyColorFilter(primaryColor.darkenColor()) mediaAttachmentHolder.background.applyColorFilter(primaryColor.darkenColor())
mediaAttachmentHolder.setOnClickListener { mediaAttachmentHolder.setOnClickListener {
...@@ -153,6 +165,7 @@ class AttachmentsAdapter( ...@@ -153,6 +165,7 @@ class AttachmentsAdapter(
else -> { else -> {
attachments.remove(attachment) attachments.remove(attachment)
Log.d(TAG, "setupMediaPreview: ")
addAttachment(attachment.copy(uri = compressedUri, isPending = false)) addAttachment(attachment.copy(uri = compressedUri, isPending = false))
} }
} }
...@@ -163,7 +176,7 @@ class AttachmentsAdapter( ...@@ -163,7 +176,7 @@ class AttachmentsAdapter(
loadMediaPreview(this, attachment) loadMediaPreview(this, attachment)
} }
} }
}*/ }
private fun loadMediaPreview(binding: ItemAttachmentMediaPreviewBinding, attachment: AttachmentSelection) { private fun loadMediaPreview(binding: ItemAttachmentMediaPreviewBinding, attachment: AttachmentSelection) {
val roundedCornersRadius = resources.getDimension(com.simplemobiletools.commons.R.dimen.activity_margin).toInt() val roundedCornersRadius = resources.getDimension(com.simplemobiletools.commons.R.dimen.activity_margin).toInt()
......
...@@ -53,6 +53,7 @@ ...@@ -53,6 +53,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?selectableItemBackgroundBorderless" android:background="?selectableItemBackgroundBorderless"
android:minHeight="@dimen/attachment_button_height" android:minHeight="@dimen/attachment_button_height"
android:visibility="gone"
android:orientation="vertical" android:orientation="vertical"
android:paddingHorizontal="@dimen/medium_margin" android:paddingHorizontal="@dimen/medium_margin"
android:paddingVertical="@dimen/medium_margin"> android:paddingVertical="@dimen/medium_margin">
...@@ -117,6 +118,7 @@ ...@@ -117,6 +118,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?selectableItemBackgroundBorderless" android:background="?selectableItemBackgroundBorderless"
android:minHeight="@dimen/attachment_button_height" android:minHeight="@dimen/attachment_button_height"
android:visibility="gone"
android:orientation="vertical" android:orientation="vertical"
android:paddingHorizontal="@dimen/medium_margin" android:paddingHorizontal="@dimen/medium_margin"
android:paddingVertical="@dimen/medium_margin"> android:paddingVertical="@dimen/medium_margin">
...@@ -149,6 +151,7 @@ ...@@ -149,6 +151,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?selectableItemBackgroundBorderless" android:background="?selectableItemBackgroundBorderless"
android:minHeight="@dimen/attachment_button_height" android:minHeight="@dimen/attachment_button_height"
android:visibility="gone"
android:orientation="vertical" android:orientation="vertical"
android:paddingHorizontal="@dimen/medium_margin" android:paddingHorizontal="@dimen/medium_margin"
android:paddingVertical="@dimen/medium_margin"> android:paddingVertical="@dimen/medium_margin">
...@@ -181,6 +184,7 @@ ...@@ -181,6 +184,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?selectableItemBackgroundBorderless" android:background="?selectableItemBackgroundBorderless"
android:minHeight="@dimen/attachment_button_height" android:minHeight="@dimen/attachment_button_height"
android:visibility="gone"
android:orientation="vertical" android:orientation="vertical"
android:paddingHorizontal="@dimen/medium_margin" android:paddingHorizontal="@dimen/medium_margin"
android:paddingVertical="@dimen/medium_margin" android:paddingVertical="@dimen/medium_margin"
...@@ -214,6 +218,7 @@ ...@@ -214,6 +218,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?selectableItemBackgroundBorderless" android:background="?selectableItemBackgroundBorderless"
android:minHeight="@dimen/attachment_button_height" android:minHeight="@dimen/attachment_button_height"
android:visibility="gone"
android:orientation="vertical" android:orientation="vertical"
android:paddingHorizontal="@dimen/medium_margin" android:paddingHorizontal="@dimen/medium_margin"
android:paddingVertical="@dimen/medium_margin" android:paddingVertical="@dimen/medium_margin"
...@@ -247,6 +252,7 @@ ...@@ -247,6 +252,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?selectableItemBackgroundBorderless" android:background="?selectableItemBackgroundBorderless"
android:minHeight="@dimen/attachment_button_height" android:minHeight="@dimen/attachment_button_height"
android:visibility="gone"
android:orientation="vertical" android:orientation="vertical"
android:paddingHorizontal="@dimen/medium_margin" android:paddingHorizontal="@dimen/medium_margin"
android:paddingVertical="@dimen/medium_margin"> android:paddingVertical="@dimen/medium_margin">
......
...@@ -93,7 +93,6 @@ ...@@ -93,7 +93,6 @@
android:layout_height="@dimen/normal_icon_size" android:layout_height="@dimen/normal_icon_size"
android:layout_marginStart="@dimen/small_margin" android:layout_marginStart="@dimen/small_margin"
android:alpha="0.9" android:alpha="0.9"
android:visibility="gone"
android:background="?selectableItemBackgroundBorderless" android:background="?selectableItemBackgroundBorderless"
android:contentDescription="@string/attachment" android:contentDescription="@string/attachment"
android:padding="@dimen/normal_margin" android:padding="@dimen/normal_margin"
...@@ -198,7 +197,6 @@ ...@@ -198,7 +197,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginHorizontal="@dimen/small_margin" android:layout_marginHorizontal="@dimen/small_margin"
android:overScrollMode="always" android:overScrollMode="always"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
...@@ -208,7 +206,6 @@ ...@@ -208,7 +206,6 @@
android:id="@+id/attachment_picker" android:id="@+id/attachment_picker"
layout="@layout/layout_attachment_picker" layout="@layout/layout_attachment_picker"
android:layout_width="match_parent" android:layout_width="match_parent"
android:visibility="gone"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
</ScrollView> </ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment