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
6af49188
Commit
6af49188
authored
May 11, 2018
by
Filipe de Lima Brito
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix formatting
parent
b6e038ee
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
24 deletions
+36
-24
ImageAttachmentViewHolder.kt
...ket/android/chatroom/adapter/ImageAttachmentViewHolder.kt
+35
-20
FavoriteMessagesPresenter.kt
...avoritemessages/presentation/FavoriteMessagesPresenter.kt
+1
-4
No files found.
app/src/main/java/chat/rocket/android/chatroom/adapter/ImageAttachmentViewHolder.kt
View file @
6af49188
...
...
@@ -37,11 +37,11 @@ import timber.log.Timber
import
java.io.File
class
ImageAttachmentViewHolder
(
itemView
:
View
,
class
ImageAttachmentViewHolder
(
itemView
:
View
,
listener
:
ActionsListener
,
reactionListener
:
EmojiReactionListener
?
=
null
)
:
BaseViewHolder
<
ImageAttachmentViewModel
>(
itemView
,
listener
,
reactionListener
)
{
reactionListener
:
EmojiReactionListener
?
=
null
)
:
BaseViewHolder
<
ImageAttachmentViewModel
>(
itemView
,
listener
,
reactionListener
)
{
private
var
cacheKey
:
CacheKey
?
=
null
init
{
...
...
@@ -63,7 +63,8 @@ class ImageAttachmentViewHolder(itemView: View,
// TODO - implement a proper image viewer with a proper Transition
// TODO - We should definitely write our own ImageViewer
var
imageViewer
:
ImageViewer
?
=
null
val
request
=
ImageRequestBuilder
.
newBuilderWithSource
(
Uri
.
parse
(
data
.
attachmentUrl
))
val
request
=
ImageRequestBuilder
.
newBuilderWithSource
(
Uri
.
parse
(
data
.
attachmentUrl
))
.
setLowestPermittedRequestLevel
(
ImageRequest
.
RequestLevel
.
DISK_CACHE
)
.
build
()
...
...
@@ -71,8 +72,10 @@ class ImageAttachmentViewHolder(itemView: View,
.
getEncodedCacheKey
(
request
,
null
)
val
pad
=
context
.
resources
.
getDimensionPixelSize
(
R
.
dimen
.
viewer_toolbar_padding
)
val
lparams
=
AppBarLayout
.
LayoutParams
(
ViewGroup
.
LayoutParams
.
MATCH_PARENT
,
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
)
val
lparams
=
AppBarLayout
.
LayoutParams
(
ViewGroup
.
LayoutParams
.
MATCH_PARENT
,
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
)
val
toolbar
=
Toolbar
(
context
).
also
{
it
.
inflateMenu
(
R
.
menu
.
image_actions
)
it
.
overflowIcon
?.
setTint
(
Color
.
WHITE
)
...
...
@@ -98,7 +101,7 @@ class ImageAttachmentViewHolder(itemView: View,
val
backArrowView
=
ImageView
(
context
).
also
{
it
.
setImageResource
(
R
.
drawable
.
ic_arrow_back_white_24dp
)
it
.
setOnClickListener
{
imageViewer
?.
onDismiss
()
}
it
.
setPadding
(
0
,
pad
,
pad
,
pad
)
it
.
setPadding
(
0
,
pad
,
pad
,
pad
)
}
val
layoutParams
=
AppBarLayout
.
LayoutParams
(
...
...
@@ -113,10 +116,12 @@ class ImageAttachmentViewHolder(itemView: View,
val
appBarLayout
=
AppBarLayout
(
context
).
also
{
it
.
layoutParams
=
lparams
it
.
setBackgroundColor
(
Color
.
BLACK
)
it
.
addView
(
toolbar
,
AppBarLayout
.
LayoutParams
(
it
.
addView
(
toolbar
,
AppBarLayout
.
LayoutParams
(
AppBarLayout
.
LayoutParams
.
MATCH_PARENT
,
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
))
)
)
}
val
builder
=
ImageViewer
.
createPipelineDraweeControllerBuilder
()
...
...
@@ -144,12 +149,17 @@ class ImageAttachmentViewHolder(itemView: View,
val
imageFormat
=
ImageFormatChecker
.
getImageFormat
(
resource
.
openStream
())
val
imageDir
=
"${Environment.DIRECTORY_PICTURES}/Rocket.Chat Images/"
val
imagePath
=
Environment
.
getExternalStoragePublicDirectory
(
imageDir
)
val
imageFile
=
File
(
imagePath
,
"${cachedFile.nameWithoutExtension}.${imageFormat.fileExtension}"
)
val
imageFile
=
File
(
imagePath
,
"${cachedFile.nameWithoutExtension}.${imageFormat.fileExtension}"
)
imagePath
.
mkdirs
()
imageFile
.
createNewFile
()
try
{
cachedFile
.
copyTo
(
imageFile
,
true
)
MediaScannerConnection
.
scanFile
(
context
,
arrayOf
(
imageFile
.
absolutePath
),
null
)
{
path
,
uri
->
MediaScannerConnection
.
scanFile
(
context
,
arrayOf
(
imageFile
.
absolutePath
),
null
)
{
path
,
uri
->
Timber
.
i
(
"Scanned $path:"
)
Timber
.
i
(
"-> uri=$uri"
)
}
...
...
@@ -166,16 +176,21 @@ class ImageAttachmentViewHolder(itemView: View,
}
private
fun
canWriteToExternalStorage
():
Boolean
{
return
AndroidPermissionsHelper
.
checkPermission
(
itemView
.
context
,
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
)
return
AndroidPermissionsHelper
.
checkPermission
(
itemView
.
context
,
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
)
}
private
fun
checkWritingPermission
()
{
val
context
=
itemView
.
context
if
(
context
is
ContextThemeWrapper
&&
context
.
baseContext
is
Activity
)
{
val
activity
=
context
.
baseContext
as
Activity
AndroidPermissionsHelper
.
requestPermission
(
activity
,
AndroidPermissionsHelper
.
requestPermission
(
activity
,
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
,
AndroidPermissionsHelper
.
WRITE_EXTERNAL_STORAGE_CODE
)
AndroidPermissionsHelper
.
WRITE_EXTERNAL_STORAGE_CODE
)
}
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/favoritemessages/presentation/FavoriteMessagesPresenter.kt
View file @
6af49188
package
chat.rocket.android.favoritemessages.presentation
import
chat.rocket.android.chatroom.viewmodel.BaseViewModel
import
chat.rocket.android.chatroom.viewmodel.ImageAttachmentViewModel
import
chat.rocket.android.chatroom.viewmodel.ViewModelMapper
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.server.domain.GetChatRoomsInteractor
...
...
@@ -40,8 +38,7 @@ class FavoriteMessagesPresenter @Inject constructor(
val
favoriteMessages
=
client
.
getFavoriteMessages
(
roomId
,
room
.
type
,
offset
)
offset
=
favoriteMessages
.
offset
.
toInt
()
val
messageList
=
mapper
.
map
(
favoriteMessages
.
result
)
val
messageList
=
mapper
.
map
(
favoriteMessages
.
result
)
view
.
showFavoriteMessages
(
messageList
)
view
.
hideLoading
()
}.
ifNull
{
...
...
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