Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
Simple-Sms
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhangchengbo
Simple-Sms
Commits
179394eb
Commit
179394eb
authored
Dec 01, 2025
by
zhangchengbo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:增加彩信输入框-仅支持选择照片与拍照
parent
67ffa9d7
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
42 deletions
+58
-42
ThreadActivity.kt
...main/kotlin/com/secspace/sms/activities/ThreadActivity.kt
+29
-29
AttachmentsAdapter.kt
...in/kotlin/com/secspace/sms/adapters/AttachmentsAdapter.kt
+23
-10
layout_attachment_picker.xml
app/src/main/res/layout/layout_attachment_picker.xml
+6
-0
layout_thread_send_message_holder.xml
...src/main/res/layout/layout_thread_send_message_holder.xml
+0
-3
No files found.
app/src/main/kotlin/com/secspace/sms/activities/ThreadActivity.kt
View file @
179394eb
...
...
@@ -159,7 +159,7 @@ class ThreadActivity : SimpleActivity() {
}
}
//
setupAttachmentPickerView()
setupAttachmentPickerView
()
setupKeyboardListener
()
hideAttachmentPicker
()
maybeSetupRecycleBinView
()
...
...
@@ -353,9 +353,9 @@ class ThreadActivity : SimpleActivity() {
addAttachment
(
capturedImageUri
!!
)
}
else
if
(
data
!=
null
)
{
when
(
requestCode
)
{
CAPTURE_VIDEO_INTENT
,
PICK_DOCUMENT_INTENT
,
CAPTURE_AUDIO_INTENT
,
PICK_PHOTO_INTENT
,
PICK_VIDE
O_INTENT
->
addAttachment
(
data
)
PICK_CONTACT_INTENT
->
addContactAttachment
(
data
)
PICK_SAVE_FILE_INTENT
->
saveAttachment
(
resultData
)
/*CAPTURE_VIDEO_INTENT, PICK_DOCUMENT_INTENT, CAPTURE_AUDIO_INTENT, PICK_VIDEO_INTENT ,*/
PICK_PHOT
O_INTENT
->
addAttachment
(
data
)
//
PICK_CONTACT_INTENT -> addContactAttachment(data)
//
PICK_SAVE_FILE_INTENT -> saveAttachment(resultData)
}
}
}
...
...
@@ -1620,13 +1620,13 @@ class ThreadActivity : SimpleActivity() {
}
private
fun
updateMessageType
()
{
val
text
=
binding
.
messageHolder
.
threadTypeMessage
.
text
.
toString
()
/*
val text = binding.messageHolder.threadTypeMessage.text.toString()
val stringId = if (isMmsMessage(text)) {
R.string.mms
} else {
R.string.sms
}
binding
.
messageHolder
.
threadSendMessage
.
setText
(
stringId
)
}
*/
binding
.
messageHolder
.
threadSendMessage
.
setText
(
R
.
string
.
sms
)
}
private
fun
showScheduledMessageInfo
(
message
:
Message
)
{
...
...
@@ -1793,31 +1793,31 @@ class ThreadActivity : SimpleActivity() {
choosePhoto
.
setOnClickListener
{
launchGetContentIntent
(
arrayOf
(
"image/*"
),
PICK_PHOTO_INTENT
)
}
chooseVideo
.
setOnClickListener
{
launchGetContentIntent
(
arrayOf
(
"video/*"
),
PICK_VIDEO_INTENT
)
}
takePhoto
.
setOnClickListener
{
launchCapturePhotoIntent
()
}
recordVideo
.
setOnClickListener
{
launchCaptureVideoIntent
()
}
recordAudio
.
setOnClickListener
{
launchCaptureAudioIntent
()
}
pickFile
.
setOnClickListener
{
launchGetContentIntent
(
arrayOf
(
"*/*"
),
PICK_DOCUMENT_INTENT
)
}
pickContact
.
setOnClickListener
{
launchPickContactIntent
()
}
scheduleMessage
.
setOnClickListener
{
if
(
isScheduledMessage
)
{
launchScheduleSendDialog
(
scheduledDateTime
)
}
else
{
launchScheduleSendDialog
()
}
}
/* chooseVideo.setOnClickListener {
launchGetContentIntent(arrayOf("video/*"), PICK_VIDEO_INTENT)
}
recordVideo.setOnClickListener {
launchCaptureVideoIntent()
}
recordAudio.setOnClickListener {
launchCaptureAudioIntent()
}
pickFile.setOnClickListener {
launchGetContentIntent(arrayOf("*/
*
"), PICK_DOCUMENT_INTENT)
}
pickContact
.
setOnClickListener
{
launchPickContactIntent
()
}
scheduleMessage
.
setOnClickListener
{
if
(
isScheduledMessage
)
{
launchScheduleSendDialog
(
scheduledDateTime
)
}
else
{
launchScheduleSendDialog
()
}
}*/
}
private
fun
showAttachmentPicker
()
{
...
...
app/src/main/kotlin/com/secspace/sms/adapters/AttachmentsAdapter.kt
View file @
179394eb
package
com.secspace.sms.adapters
import
android.content.Intent
import
android.graphics.drawable.Drawable
import
android.util.Log
import
android.view.LayoutInflater
import
android.view.ViewGroup
import
android.widget.Toast
import
androidx.recyclerview.widget.DiffUtil
import
androidx.recyclerview.widget.ListAdapter
import
androidx.recyclerview.widget.RecyclerView
...
...
@@ -18,15 +21,12 @@ import com.bumptech.glide.request.RequestListener
import
com.bumptech.glide.request.RequestOptions
import
com.bumptech.glide.request.target.Target
import
com.secspace.sms.R
import
com.secspace.sms.activities.VCardViewerActivity
import
com.secspace.sms.databinding.ItemAttachmentDocumentPreviewBinding
import
com.secspace.sms.databinding.ItemAttachmentMediaPreviewBinding
import
com.secspace.sms.databinding.ItemAttachmentVcardPreviewBinding
import
com.secspace.sms.extensions.config
import
com.secspace.sms.extensions.isVideoMimeType
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.extensions.*
import
com.secspace.sms.helpers.*
import
com.secspace.sms.models.AttachmentSelection
import
com.simplemobiletools.commons.activities.BaseSimpleActivity
import
com.simplemobiletools.commons.extensions.*
...
...
@@ -42,6 +42,8 @@ class AttachmentsAdapter(
private
val
resources
=
activity
.
resources
private
val
primaryColor
=
activity
.
getProperPrimaryColor
()
private
val
imageCompressor
by
lazy
{
ImageCompressor
(
activity
)
}
private
val
TAG
=
"AttachmentsAdapter"
private
var
isShowToast
=
false
val
attachments
=
mutableListOf
<
AttachmentSelection
>()
...
...
@@ -64,7 +66,7 @@ class AttachmentsAdapter(
override
fun
onBindViewHolder
(
holder
:
AttachmentsViewHolder
,
position
:
Int
)
{
val
attachment
=
getItem
(
position
)
holder
.
bindView
{
binding
,
_
->
/*
when (attachment.viewType) {
when
(
attachment
.
viewType
)
{
ATTACHMENT_DOCUMENT
->
{
(
binding
as
ItemAttachmentDocumentPreviewBinding
).
setupDocumentPreview
(
uri
=
attachment
.
uri
,
...
...
@@ -74,6 +76,7 @@ class AttachmentsAdapter(
onRemoveButtonClicked
=
{
removeAttachment
(
attachment
)
}
)
}
ATTACHMENT_VCARD
->
{
(
binding
as
ItemAttachmentVcardPreviewBinding
).
setupVCardPreview
(
activity
=
activity
,
...
...
@@ -87,11 +90,12 @@ class AttachmentsAdapter(
onRemoveButtonClicked
=
{
removeAttachment
(
attachment
)
}
)
}
ATTACHMENT_MEDIA
->
setupMediaPreview
(
binding
=
binding
as
ItemAttachmentMediaPreviewBinding
,
attachment
=
attachment
)
}
*/
}
}
}
...
...
@@ -107,18 +111,26 @@ class AttachmentsAdapter(
attachments
.
removeAll
{
AttachmentSelection
.
areItemsTheSame
(
it
,
attachment
)
}
attachments
.
add
(
attachment
)
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
)
{
attachments
.
removeAll
{
AttachmentSelection
.
areItemsTheSame
(
it
,
attachment
)
}
Log
.
d
(
TAG
,
"removeAttachment: attachments = ${attachments.size}"
)
if
(
attachments
.
isEmpty
())
{
isShowToast
=
false
Toast
.
makeText
(
activity
,
"正在转换为短信..."
,
Toast
.
LENGTH_SHORT
).
show
()
clear
()
}
else
{
submitList
(
attachments
.
toList
())
}
}
/*
private fun setupMediaPreview(binding: ItemAttachmentMediaPreviewBinding, attachment: AttachmentSelection) {
private
fun
setupMediaPreview
(
binding
:
ItemAttachmentMediaPreviewBinding
,
attachment
:
AttachmentSelection
)
{
binding
.
apply
{
mediaAttachmentHolder
.
background
.
applyColorFilter
(
primaryColor
.
darkenColor
())
mediaAttachmentHolder
.
setOnClickListener
{
...
...
@@ -153,6 +165,7 @@ class AttachmentsAdapter(
else
->
{
attachments
.
remove
(
attachment
)
Log
.
d
(
TAG
,
"setupMediaPreview: "
)
addAttachment
(
attachment
.
copy
(
uri
=
compressedUri
,
isPending
=
false
))
}
}
...
...
@@ -163,7 +176,7 @@ class AttachmentsAdapter(
loadMediaPreview
(
this
,
attachment
)
}
}
}
*/
}
private
fun
loadMediaPreview
(
binding
:
ItemAttachmentMediaPreviewBinding
,
attachment
:
AttachmentSelection
)
{
val
roundedCornersRadius
=
resources
.
getDimension
(
com
.
simplemobiletools
.
commons
.
R
.
dimen
.
activity_margin
).
toInt
()
...
...
app/src/main/res/layout/layout_attachment_picker.xml
View file @
179394eb
...
...
@@ -53,6 +53,7 @@
android:layout_height=
"wrap_content"
android:background=
"?selectableItemBackgroundBorderless"
android:minHeight=
"@dimen/attachment_button_height"
android:visibility=
"gone"
android:orientation=
"vertical"
android:paddingHorizontal=
"@dimen/medium_margin"
android:paddingVertical=
"@dimen/medium_margin"
>
...
...
@@ -117,6 +118,7 @@
android:layout_height=
"wrap_content"
android:background=
"?selectableItemBackgroundBorderless"
android:minHeight=
"@dimen/attachment_button_height"
android:visibility=
"gone"
android:orientation=
"vertical"
android:paddingHorizontal=
"@dimen/medium_margin"
android:paddingVertical=
"@dimen/medium_margin"
>
...
...
@@ -149,6 +151,7 @@
android:layout_height=
"wrap_content"
android:background=
"?selectableItemBackgroundBorderless"
android:minHeight=
"@dimen/attachment_button_height"
android:visibility=
"gone"
android:orientation=
"vertical"
android:paddingHorizontal=
"@dimen/medium_margin"
android:paddingVertical=
"@dimen/medium_margin"
>
...
...
@@ -181,6 +184,7 @@
android:layout_height=
"wrap_content"
android:background=
"?selectableItemBackgroundBorderless"
android:minHeight=
"@dimen/attachment_button_height"
android:visibility=
"gone"
android:orientation=
"vertical"
android:paddingHorizontal=
"@dimen/medium_margin"
android:paddingVertical=
"@dimen/medium_margin"
...
...
@@ -214,6 +218,7 @@
android:layout_height=
"wrap_content"
android:background=
"?selectableItemBackgroundBorderless"
android:minHeight=
"@dimen/attachment_button_height"
android:visibility=
"gone"
android:orientation=
"vertical"
android:paddingHorizontal=
"@dimen/medium_margin"
android:paddingVertical=
"@dimen/medium_margin"
...
...
@@ -247,6 +252,7 @@
android:layout_height=
"wrap_content"
android:background=
"?selectableItemBackgroundBorderless"
android:minHeight=
"@dimen/attachment_button_height"
android:visibility=
"gone"
android:orientation=
"vertical"
android:paddingHorizontal=
"@dimen/medium_margin"
android:paddingVertical=
"@dimen/medium_margin"
>
...
...
app/src/main/res/layout/layout_thread_send_message_holder.xml
View file @
179394eb
...
...
@@ -93,7 +93,6 @@
android:layout_height=
"@dimen/normal_icon_size"
android:layout_marginStart=
"@dimen/small_margin"
android:alpha=
"0.9"
android:visibility=
"gone"
android:background=
"?selectableItemBackgroundBorderless"
android:contentDescription=
"@string/attachment"
android:padding=
"@dimen/normal_margin"
...
...
@@ -198,7 +197,6 @@
android:layout_height=
"wrap_content"
android:layout_marginHorizontal=
"@dimen/small_margin"
android:overScrollMode=
"always"
android:visibility=
"gone"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
...
...
@@ -208,7 +206,6 @@
android:id=
"@+id/attachment_picker"
layout=
"@layout/layout_attachment_picker"
android:layout_width=
"match_parent"
android:visibility=
"gone"
android:layout_height=
"wrap_content"
/>
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment