Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AloqaIM-Android
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
Administrator
AloqaIM-Android
Commits
9009db4b
Commit
9009db4b
authored
Jun 18, 2018
by
divyanshu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Send message with attachments
parent
d3ab9c1f
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
173 additions
and
15 deletions
+173
-15
ChatRoomView.kt
...chat/rocket/android/chatroom/presentation/ChatRoomView.kt
+2
-1
ChatRoomFragment.kt
.../java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
+48
-14
rounded_color_accent.xml
app/src/main/res/drawable/rounded_color_accent.xml
+6
-0
file_attachments_dialog.xml
app/src/main/res/layout/file_attachments_dialog.xml
+99
-0
strings.xml
app/src/main/res/values-es/strings.xml
+3
-0
strings.xml
app/src/main/res/values-fr/strings.xml
+3
-0
strings.xml
app/src/main/res/values-hi-rIN/strings.xml
+3
-0
strings.xml
app/src/main/res/values-pt-rBR/strings.xml
+3
-0
strings.xml
app/src/main/res/values-uk-rRU/strings.xml
+3
-0
strings.xml
app/src/main/res/values/strings.xml
+3
-0
No files found.
app/src/main/java/chat/rocket/android/chatroom/presentation/ChatRoomView.kt
View file @
9009db4b
...
...
@@ -47,8 +47,9 @@ interface ChatRoomView : LoadingView, MessageView {
* Uploads a file to a chat room.
*
* @param uri The file URI to send.
* @param msg Message to send with attachments
*/
fun
uploadFile
(
uri
:
Uri
)
fun
uploadFile
(
uri
:
Uri
,
msg
:
String
)
/**
* Shows a invalid file message.
...
...
app/src/main/java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
View file @
9009db4b
package
chat.rocket.android.chatroom.ui
import
android.app.Activity
import
android.app.AlertDialog
import
android.content.ClipData
import
android.content.ClipboardManager
import
android.content.Context
...
...
@@ -15,6 +16,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
import
androidx.recyclerview.widget.RecyclerView
import
android.text.SpannableStringBuilder
import
android.view.*
import
android.widget.*
import
androidx.core.text.bold
import
androidx.core.view.isVisible
import
chat.rocket.android.R
...
...
@@ -29,16 +31,7 @@ import chat.rocket.android.chatroom.uimodel.suggestion.PeopleSuggestionUiModel
import
chat.rocket.android.helper.EndlessRecyclerViewScrollListener
import
chat.rocket.android.helper.KeyboardHelper
import
chat.rocket.android.helper.MessageParser
import
chat.rocket.android.util.extensions.asObservable
import
chat.rocket.android.util.extensions.circularRevealOrUnreveal
import
chat.rocket.android.util.extensions.fadeIn
import
chat.rocket.android.util.extensions.fadeOut
import
chat.rocket.android.util.extensions.hideKeyboard
import
chat.rocket.android.util.extensions.inflate
import
chat.rocket.android.util.extensions.rotateBy
import
chat.rocket.android.util.extensions.showToast
import
chat.rocket.android.util.extensions.textContent
import
chat.rocket.android.util.extensions.ui
import
chat.rocket.android.util.extensions.*
import
chat.rocket.android.widget.emoji.*
import
chat.rocket.common.model.RoomType
import
chat.rocket.common.model.roomTypeOf
...
...
@@ -200,11 +193,53 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
override
fun
onActivityResult
(
requestCode
:
Int
,
resultCode
:
Int
,
resultData
:
Intent
?)
{
if
(
requestCode
==
REQUEST_CODE_FOR_PERFORM_SAF
&&
resultCode
==
Activity
.
RESULT_OK
)
{
if
(
resultData
!=
null
)
{
uploadFile
(
resultData
.
data
)
fileAttachmentDialog
(
resultData
.
data
)
}
}
}
private
fun
fileAttachmentDialog
(
data
:
Uri
)
{
val
builder
=
AlertDialog
.
Builder
(
activity
)
val
dialogView
=
View
.
inflate
(
context
,
R
.
layout
.
file_attachments_dialog
,
null
)
builder
.
setView
(
dialogView
)
val
alertDialog
=
builder
.
create
()
dialogView
?.
let
{
val
imagePreview
:
ImageView
=
it
.
findViewById
(
R
.
id
.
image_preview
)
val
sendButton
:
Button
=
it
.
findViewById
(
R
.
id
.
button_send
)
val
cancelButton
:
Button
=
it
.
findViewById
(
R
.
id
.
button_cancel
)
val
description
:
EditText
=
it
.
findViewById
(
R
.
id
.
text_file_description
)
val
audioVideoAttachment
:
FrameLayout
=
it
.
findViewById
(
R
.
id
.
audio_video_attachment
)
val
textFile
:
TextView
=
it
.
findViewById
(
R
.
id
.
text_file_name
)
activity
?.
let
{
data
.
getMimeType
(
it
).
apply
{
when
{
this
.
startsWith
(
"image"
)
->
{
imagePreview
.
isVisible
=
true
imagePreview
.
setImageURI
(
data
)
}
this
.
startsWith
(
"video"
)
->
{
audioVideoAttachment
.
isVisible
=
true
}
else
->
{
textFile
.
isVisible
=
true
textFile
.
text
=
data
.
getFileName
(
it
)
}
}
}
}
sendButton
.
setOnClickListener
{
uploadFile
(
data
,
description
.
text
.
toString
())
alertDialog
.
dismiss
()
}
cancelButton
.
setOnClickListener
{
alertDialog
.
dismiss
()
}
}
alertDialog
.
show
()
}
override
fun
onCreateOptionsMenu
(
menu
:
Menu
,
inflater
:
MenuInflater
)
{
super
.
onCreateOptionsMenu
(
menu
,
inflater
)
inflater
.
inflate
(
R
.
menu
.
chatroom_actions
,
menu
)
...
...
@@ -395,9 +430,8 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
}
}
override
fun
uploadFile
(
uri
:
Uri
)
{
// TODO Just leaving a blank message that comes with the file for now. In the future lets add the possibility to add a message with the file to be uploaded.
presenter
.
uploadFile
(
chatRoomId
,
uri
,
""
)
override
fun
uploadFile
(
uri
:
Uri
,
msg
:
String
)
{
presenter
.
uploadFile
(
chatRoomId
,
uri
,
msg
)
}
override
fun
showInvalidFileMessage
()
{
...
...
app/src/main/res/drawable/rounded_color_accent.xml
0 → 100644
View file @
9009db4b
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:shape=
"rectangle"
>
<solid
android:color=
"@color/colorAccent"
/>
<corners
android:radius=
"4dp"
/>
</shape>
\ No newline at end of file
app/src/main/res/layout/file_attachments_dialog.xml
0 → 100644
View file @
9009db4b
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:orientation=
"vertical"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:paddingBottom=
"16dp"
>
<TextView
android:id=
"@+id/text_dialog_title"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"@string/msg_upload_file"
style=
"@style/Base.DialogWindowTitle.AppCompat"
android:layout_margin=
"16dp"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
/>
<TextView
android:id=
"@+id/text_file_name"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:textColor=
"@color/colorAccent"
android:textAppearance=
"@style/TextAppearance.AppCompat.Body2"
android:drawableStart=
"@drawable/ic_files_24dp"
android:drawablePadding=
"6dp"
app:layout_constraintTop_toBottomOf=
"@id/text_dialog_title"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
android:layout_margin=
"16dp"
android:textDirection=
"locale"
android:visibility=
"gone"
tools:text=
"This is a very, very, very long filename, to test how the layout will work on very very very long filenames.pdf"
/>
<FrameLayout
android:id=
"@+id/audio_video_attachment"
android:layout_width=
"0dp"
android:layout_height=
"150dp"
android:background=
"@color/colorBlack"
android:visibility=
"gone"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/text_file_name"
android:layout_margin=
"16dp"
>
<ImageView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:src=
"@drawable/exo_controls_play"
/>
</FrameLayout>
<ImageView
android:id=
"@+id/image_preview"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
app:layout_constraintHeight_max=
"240dp"
app:layout_constrainedHeight=
"true"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/audio_video_attachment"
android:layout_margin=
"16dp"
android:adjustViewBounds=
"true"
android:visibility=
"gone"
tools:visibility=
"visible"
/>
<EditText
android:id=
"@+id/text_file_description"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/image_preview"
android:layout_margin=
"16dp"
android:hint=
"@string/msg_file_description"
/>
<Button
android:id=
"@+id/button_send"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/text_file_description"
android:layout_margin=
"16dp"
android:background=
"@drawable/rounded_color_accent"
android:text=
"@string/msg_send"
android:textColor=
"@color/colorWhite"
/>
<Button
android:id=
"@+id/button_cancel"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
app:layout_constraintTop_toBottomOf=
"@+id/text_file_description"
app:layout_constraintEnd_toStartOf=
"@id/button_send"
android:layout_margin=
"16dp"
style=
"@style/Base.Widget.AppCompat.Button.Borderless"
android:text=
"@string/msg_cancel"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
app/src/main/res/values-es/strings.xml
View file @
9009db4b
...
...
@@ -124,6 +124,9 @@
<string
name=
"msg_several_users_are_typing"
>
Several users are typing…
</string>
<string
name=
"msg_no_search_found"
>
No se han encontrado resultados
</string>
<string
name=
"msg_message_copied"
>
Mensaje copiado
</string>
<string
name=
"msg_upload_file"
>
Subir archivo
</string>
<string
name=
"msg_file_description"
>
Descripción del archivo
</string>
<string
name=
"msg_send"
>
enviar
</string>
<!-- System messages -->
<string
name=
"message_room_name_changed"
>
Nombre de la sala cambiado para: %1$s por %2$s
</string>
...
...
app/src/main/res/values-fr/strings.xml
View file @
9009db4b
...
...
@@ -123,6 +123,9 @@
<string
name=
"msg_several_users_are_typing"
>
Several users are typing…
</string>
<string
name=
"msg_no_search_found"
>
Aucun résultat trouvé
</string>
<string
name=
"msg_message_copied"
>
Message copié
</string>
<string
name=
"msg_upload_file"
>
Téléverser un fichier
</string>
<string
name=
"msg_file_description"
>
Description du fichier
</string>
<string
name=
"msg_send"
>
envoyer
</string>
<!-- System messages -->
<string
name=
"message_room_name_changed"
>
Le nom de le salle a changé à: %1$s par %2$s
</string>
...
...
app/src/main/res/values-hi-rIN/strings.xml
View file @
9009db4b
...
...
@@ -114,6 +114,9 @@
<string
name=
"msg_several_users_are_typing"
>
कई उपयोगकर्ता टाइप कर रहे हैं…
</string>
<string
name=
"msg_no_search_found"
>
कोई परिणाम नहीं मिला
</string>
<string
name=
"msg_message_copied"
>
संदेश कॉपी किया गया
</string>
<string
name=
"msg_upload_file"
>
फाइल अपलोड करें
</string>
<string
name=
"msg_file_description"
>
फाइल विवरण
</string>
<string
name=
"msg_send"
>
भेजें
</string>
<!-- System messages -->
<string
name=
"message_room_name_changed"
>
%2$s ने रूम का नाम बदलकर %1$s किया
</string>
...
...
app/src/main/res/values-pt-rBR/strings.xml
View file @
9009db4b
...
...
@@ -114,6 +114,9 @@
<string
name=
"msg_several_users_are_typing"
>
Vários usuários estão digitando…
</string>
<string
name=
"msg_no_search_found"
>
nenhum resultado encontrado
</string>
<string
name=
"msg_message_copied"
>
Mensagem copiada
</string>
<string
name=
"msg_upload_file"
>
Subir arquivo
</string>
<string
name=
"msg_file_description"
>
Descrição do arquivo
</string>
<string
name=
"msg_send"
>
Enviar
</string>
<!-- System messages -->
<string
name=
"message_room_name_changed"
>
Nome da sala alterado para: %1$s por %2$s
</string>
...
...
app/src/main/res/values-uk-rRU/strings.xml
View file @
9009db4b
...
...
@@ -113,6 +113,9 @@
<string
name=
"msg_several_users_are_typing"
>
Несколько пользователей печатают…
</string>
<string
name=
"msg_no_search_found"
>
Результатов не найдено
</string>
<string
name=
"msg_message_copied"
>
Сообщение скопировано
</string>
<string
name=
"msg_upload_file"
>
Загрузить файл
</string>
<string
name=
"msg_file_description"
>
Описание файла
</string>
<string
name=
"msg_send"
>
послать
</string>
<!-- System messages -->
<string
name=
"message_room_name_changed"
>
Название канала изменено на: %1$s by %2$s
</string>
...
...
app/src/main/res/values/strings.xml
View file @
9009db4b
...
...
@@ -115,6 +115,9 @@
<string
name=
"msg_several_users_are_typing"
>
Several users are typing…
</string>
<string
name=
"msg_no_search_found"
>
No result found
</string>
<string
name=
"msg_message_copied"
>
Message copied
</string>
<string
name=
"msg_upload_file"
>
Upload file
</string>
<string
name=
"msg_file_description"
>
File description
</string>
<string
name=
"msg_send"
>
Send
</string>
<!-- System messages -->
<string
name=
"message_room_name_changed"
>
Room name changed to: %1$s by %2$s
</string>
...
...
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