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
0c0b36fb
Unverified
Commit
0c0b36fb
authored
Aug 31, 2018
by
Lucio Maciel
Committed by
GitHub
Aug 31, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'beta' into i18n/russian-translation
parents
4cfa20c3
de7eac9a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
31 deletions
+59
-31
ChatRoomPresenter.kt
...rocket/android/chatroom/presentation/ChatRoomPresenter.kt
+5
-7
Dialog.kt
app/src/main/java/chat/rocket/android/chatroom/ui/Dialog.kt
+32
-9
FileUiModel.kt
...ain/java/chat/rocket/android/files/uimodel/FileUiModel.kt
+2
-2
SharedPreferencesAccountsRepository.kt
...er/infraestructure/SharedPreferencesAccountsRepository.kt
+3
-3
Uri.kt
app/src/main/java/chat/rocket/android/util/extensions/Uri.kt
+17
-10
No files found.
app/src/main/java/chat/rocket/android/chatroom/presentation/ChatRoomPresenter.kt
View file @
0c0b36fb
package
chat.rocket.android.chatroom.presentation
package
chat.rocket.android.chatroom.presentation
import
android.graphics.Bitmap
import
android.net.Uri
import
android.net.Uri
import
chat.rocket.android.R
import
chat.rocket.android.R
import
chat.rocket.android.analytics.AnalyticsManager
import
chat.rocket.android.analytics.AnalyticsManager
...
@@ -80,6 +81,7 @@ import org.threeten.bp.Instant
...
@@ -80,6 +81,7 @@ import org.threeten.bp.Instant
import
timber.log.Timber
import
timber.log.Timber
import
java.io.InputStream
import
java.io.InputStream
import
java.util.*
import
java.util.*
import
java.util.zip.DeflaterInputStream
import
javax.inject.Inject
import
javax.inject.Inject
class
ChatRoomPresenter
@Inject
constructor
(
class
ChatRoomPresenter
@Inject
constructor
(
...
@@ -331,7 +333,7 @@ class ChatRoomPresenter @Inject constructor(
...
@@ -331,7 +333,7 @@ class ChatRoomPresenter @Inject constructor(
view
.
showFileSelection
(
settings
.
uploadMimeTypeFilter
())
view
.
showFileSelection
(
settings
.
uploadMimeTypeFilter
())
}
}
fun
uploadFile
(
roomId
:
String
,
uri
:
Uri
,
msg
:
String
)
{
fun
uploadFile
(
roomId
:
String
,
uri
:
Uri
,
msg
:
String
,
bitmap
:
Bitmap
?
=
null
)
{
launchUI
(
strategy
)
{
launchUI
(
strategy
)
{
view
.
showLoading
()
view
.
showLoading
()
try
{
try
{
...
@@ -348,12 +350,8 @@ class ChatRoomPresenter @Inject constructor(
...
@@ -348,12 +350,8 @@ class ChatRoomPresenter @Inject constructor(
else
->
{
else
->
{
var
inputStream
:
InputStream
?
=
uriInteractor
.
getInputStream
(
uri
)
var
inputStream
:
InputStream
?
=
uriInteractor
.
getInputStream
(
uri
)
if
(
mimeType
.
contains
(
"image"
))
{
bitmap
?.
compressImageAndGetInputStream
(
mimeType
)
?.
let
{
uriInteractor
.
getBitmap
(
uri
)
?.
let
{
inputStream
=
it
it
.
compressImageAndGetInputStream
(
mimeType
)
?.
let
{
inputStream
=
it
}
}
}
}
retryIO
(
"uploadFile($roomId, $fileName, $mimeType"
)
{
retryIO
(
"uploadFile($roomId, $fileName, $mimeType"
)
{
...
...
app/src/main/java/chat/rocket/android/chatroom/ui/Dialog.kt
View file @
0c0b36fb
package
chat.rocket.android.chatroom.ui
package
chat.rocket.android.chatroom.ui
import
android.graphics.Bitmap
import
android.graphics.drawable.Drawable
import
android.graphics.drawable.Drawable
import
android.net.Uri
import
android.net.Uri
import
androidx.core.view.isVisible
import
androidx.core.view.isVisible
import
chat.rocket.android.emoji.internal.GlideApp
import
chat.rocket.android.util.extensions.getFileName
import
chat.rocket.android.util.extensions.getFileName
import
chat.rocket.android.util.extensions.getMimeType
import
chat.rocket.android.util.extensions.getMimeType
import
com.bumptech.glide.request.target.SimpleTarget
import
com.bumptech.glide.request.transition.Transition
fun
ChatRoomFragment
.
showFileAttachmentDialog
(
uri
:
Uri
)
{
fun
ChatRoomFragment
.
showFileAttachmentDialog
(
uri
:
Uri
)
{
activity
?.
let
{
fragmentActivity
->
var
bitmap
:
Bitmap
?
=
null
uri
.
getMimeType
(
fragmentActivity
).
let
{
mimeType
->
activity
?.
let
{
context
->
uri
.
getMimeType
(
context
).
let
{
mimeType
->
description
.
text
.
clear
()
description
.
text
.
clear
()
when
{
when
{
mimeType
.
startsWith
(
"image"
)
->
{
mimeType
.
startsWith
(
"image"
)
->
{
imagePreview
.
isVisible
=
true
GlideApp
imagePreview
.
setImageURI
(
uri
)
.
with
(
context
)
}
.
asBitmap
()
mimeType
.
startsWith
(
"video"
)
->
{
.
load
(
uri
)
audioVideoAttachment
.
isVisible
=
true
.
override
(
500
,
500
)
.
centerCrop
()
.
into
(
object
:
SimpleTarget
<
Bitmap
>()
{
override
fun
onResourceReady
(
resource
:
Bitmap
,
transition
:
Transition
<
in
Bitmap
>?
)
{
bitmap
=
resource
imagePreview
.
isVisible
=
true
imagePreview
.
setImageBitmap
(
resource
)
}
})
}
}
mimeType
.
startsWith
(
"video"
)
->
audioVideoAttachment
.
isVisible
=
true
else
->
{
else
->
{
textFile
.
isVisible
=
true
textFile
.
isVisible
=
true
textFile
.
text
=
uri
.
getFileName
(
fragmentActivity
)
textFile
.
text
=
uri
.
getFileName
(
context
)
}
}
}
}
}
}
}
}
sendButton
.
setOnClickListener
{
sendButton
.
setOnClickListener
{
presenter
.
uploadFile
(
chatRoomId
,
uri
,
(
citation
?:
""
)
+
description
.
text
.
toString
())
presenter
.
uploadFile
(
chatRoomId
,
uri
,
(
citation
?:
""
)
+
description
.
text
.
toString
(),
bitmap
)
alertDialog
.
dismiss
()
alertDialog
.
dismiss
()
}
}
cancelButton
.
setOnClickListener
{
alertDialog
.
dismiss
()
}
cancelButton
.
setOnClickListener
{
alertDialog
.
dismiss
()
}
...
...
app/src/main/java/chat/rocket/android/files/uimodel/FileUiModel.kt
View file @
0c0b36fb
...
@@ -34,8 +34,8 @@ class FileUiModel(
...
@@ -34,8 +34,8 @@ class FileUiModel(
}
}
private
fun
getUserDisplayName
():
String
{
private
fun
getUserDisplayName
():
String
{
val
username
=
"@${genericAttachment.user
?
.username}"
val
username
=
"@${genericAttachment.user.username}"
val
realName
=
genericAttachment
.
user
?
.
name
val
realName
=
genericAttachment
.
user
.
name
val
uploaderName
=
if
(
settings
.
useRealName
())
realName
else
username
val
uploaderName
=
if
(
settings
.
useRealName
())
realName
else
username
return
uploaderName
?:
username
return
uploaderName
?:
username
}
}
...
...
app/src/main/java/chat/rocket/android/server/infraestructure/SharedPreferencesAccountsRepository.kt
View file @
0c0b36fb
...
@@ -14,12 +14,12 @@ class SharedPreferencesAccountsRepository(
...
@@ -14,12 +14,12 @@ class SharedPreferencesAccountsRepository(
private
val
moshi
:
Moshi
private
val
moshi
:
Moshi
)
:
AccountsRepository
{
)
:
AccountsRepository
{
override
fun
save
(
newA
ccount
:
Account
)
{
override
fun
save
(
a
ccount
:
Account
)
{
val
accounts
=
load
()
val
accounts
=
load
()
val
newList
=
accounts
.
filter
{
account
->
newAccount
.
serverUrl
!=
accoun
t
.
serverUrl
}
val
newList
=
accounts
.
filter
{
it
.
serverUrl
!=
i
t
.
serverUrl
}
.
toMutableList
()
.
toMutableList
()
newList
.
add
(
0
,
newA
ccount
)
newList
.
add
(
0
,
a
ccount
)
save
(
newList
)
save
(
newList
)
}
}
...
...
app/src/main/java/chat/rocket/android/util/extensions/Uri.kt
View file @
0c0b36fb
...
@@ -10,15 +10,19 @@ import android.provider.DocumentsContract
...
@@ -10,15 +10,19 @@ import android.provider.DocumentsContract
import
android.provider.MediaStore
import
android.provider.MediaStore
import
android.provider.OpenableColumns
import
android.provider.OpenableColumns
import
android.webkit.MimeTypeMap
import
android.webkit.MimeTypeMap
import
java.io.*
import
java.io.File
import
java.io.FileInputStream
import
java.io.FileNotFoundException
import
java.io.IOException
import
java.io.InputStream
fun
Uri
.
getFileName
(
context
:
Context
):
String
?
{
fun
Uri
.
getFileName
(
context
:
Context
):
String
?
{
val
cursor
=
context
.
contentResolver
.
query
(
this
,
null
,
null
,
null
,
null
,
null
)
val
cursor
=
context
.
contentResolver
.
query
(
this
,
null
,
null
,
null
,
null
,
null
)
var
fileName
:
String
?
=
null
var
fileName
:
String
?
=
null
cursor
.
use
{
cursor
->
cursor
?.
use
{
if
(
cursor
!=
null
&&
cursor
.
moveToFirst
())
{
if
(
it
.
moveToFirst
())
{
fileName
=
cursor
.
getString
(
cursor
.
getColumnIndex
(
OpenableColumns
.
DISPLAY_NAME
))
fileName
=
it
.
getString
(
it
.
getColumnIndex
(
OpenableColumns
.
DISPLAY_NAME
))
}
}
}
}
return
fileName
return
fileName
...
@@ -29,7 +33,7 @@ fun Uri.getFileSize(context: Context): Int {
...
@@ -29,7 +33,7 @@ fun Uri.getFileSize(context: Context): Int {
if
(
scheme
==
ContentResolver
.
SCHEME_CONTENT
)
{
if
(
scheme
==
ContentResolver
.
SCHEME_CONTENT
)
{
try
{
try
{
val
fileInputStream
=
context
.
contentResolver
.
openInputStream
(
this
)
val
fileInputStream
=
context
.
contentResolver
.
openInputStream
(
this
)
fileSize
=
fileInputStream
.
available
().
toString
()
fileSize
=
fileInputStream
?
.
available
().
toString
()
}
catch
(
e
:
Exception
)
{
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
e
.
printStackTrace
()
}
}
...
@@ -67,14 +71,17 @@ fun Uri.isVirtualFile(context: Context): Boolean {
...
@@ -67,14 +71,17 @@ fun Uri.isVirtualFile(context: Context): Boolean {
val
cursor
=
context
.
contentResolver
.
query
(
val
cursor
=
context
.
contentResolver
.
query
(
this
,
this
,
arrayOf
(
DocumentsContract
.
Document
.
COLUMN_FLAGS
),
arrayOf
(
DocumentsContract
.
Document
.
COLUMN_FLAGS
),
null
,
null
,
null
null
,
null
,
null
)
)
var
flags
=
0
var
flags
=
0
if
(
cursor
.
moveToFirst
())
{
cursor
?.
use
{
flags
=
cursor
.
getInt
(
0
)
if
(
it
.
moveToFirst
())
{
flags
=
it
.
getInt
(
0
)
}
}
}
cursor
.
close
()
return
flags
and
DocumentsContract
.
Document
.
FLAG_VIRTUAL_DOCUMENT
!=
0
return
flags
and
DocumentsContract
.
Document
.
FLAG_VIRTUAL_DOCUMENT
!=
0
}
}
...
@@ -104,4 +111,4 @@ fun Uri.getInputStream(context: Context): InputStream? {
...
@@ -104,4 +111,4 @@ fun Uri.getInputStream(context: Context): InputStream? {
fun
Uri
.
getBitmpap
(
context
:
Context
):
Bitmap
?
{
fun
Uri
.
getBitmpap
(
context
:
Context
):
Bitmap
?
{
return
MediaStore
.
Images
.
Media
.
getBitmap
(
context
.
contentResolver
,
this
)
return
MediaStore
.
Images
.
Media
.
getBitmap
(
context
.
contentResolver
,
this
)
}
}
\ No newline at end of file
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