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
Hide 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
...
@@ -37,11 +37,11 @@ import timber.log.Timber
import
java.io.File
import
java.io.File
class
ImageAttachmentViewHolder
(
itemView
:
View
,
class
ImageAttachmentViewHolder
(
listener
:
ActionsListener
,
itemView
:
View
,
reactionListener
:
EmojiReactionListener
?
=
null
)
listener
:
ActionsListener
,
:
BaseViewHolder
<
ImageAttachmentViewModel
>(
itemView
,
listener
,
reactionListener
)
{
reactionListener
:
EmojiReactionListener
?
=
null
)
:
BaseViewHolder
<
ImageAttachmentViewModel
>(
itemView
,
listener
,
reactionListener
)
{
private
var
cacheKey
:
CacheKey
?
=
null
private
var
cacheKey
:
CacheKey
?
=
null
init
{
init
{
...
@@ -63,16 +63,19 @@ class ImageAttachmentViewHolder(itemView: View,
...
@@ -63,16 +63,19 @@ class ImageAttachmentViewHolder(itemView: View,
// TODO - implement a proper image viewer with a proper Transition
// TODO - implement a proper image viewer with a proper Transition
// TODO - We should definitely write our own ImageViewer
// TODO - We should definitely write our own ImageViewer
var
imageViewer
:
ImageViewer
?
=
null
var
imageViewer
:
ImageViewer
?
=
null
val
request
=
ImageRequestBuilder
.
newBuilderWithSource
(
Uri
.
parse
(
data
.
attachmentUrl
))
val
request
=
.
setLowestPermittedRequestLevel
(
ImageRequest
.
RequestLevel
.
DISK_CACHE
)
ImageRequestBuilder
.
newBuilderWithSource
(
Uri
.
parse
(
data
.
attachmentUrl
))
.
build
()
.
setLowestPermittedRequestLevel
(
ImageRequest
.
RequestLevel
.
DISK_CACHE
)
.
build
()
cacheKey
=
DefaultCacheKeyFactory
.
getInstance
()
cacheKey
=
DefaultCacheKeyFactory
.
getInstance
()
.
getEncodedCacheKey
(
request
,
null
)
.
getEncodedCacheKey
(
request
,
null
)
val
pad
=
context
.
resources
val
pad
=
context
.
resources
.
getDimensionPixelSize
(
R
.
dimen
.
viewer_toolbar_padding
)
.
getDimensionPixelSize
(
R
.
dimen
.
viewer_toolbar_padding
)
val
lparams
=
AppBarLayout
.
LayoutParams
(
ViewGroup
.
LayoutParams
.
MATCH_PARENT
,
val
lparams
=
AppBarLayout
.
LayoutParams
(
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
)
ViewGroup
.
LayoutParams
.
MATCH_PARENT
,
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
)
val
toolbar
=
Toolbar
(
context
).
also
{
val
toolbar
=
Toolbar
(
context
).
also
{
it
.
inflateMenu
(
R
.
menu
.
image_actions
)
it
.
inflateMenu
(
R
.
menu
.
image_actions
)
it
.
overflowIcon
?.
setTint
(
Color
.
WHITE
)
it
.
overflowIcon
?.
setTint
(
Color
.
WHITE
)
...
@@ -98,7 +101,7 @@ class ImageAttachmentViewHolder(itemView: View,
...
@@ -98,7 +101,7 @@ class ImageAttachmentViewHolder(itemView: View,
val
backArrowView
=
ImageView
(
context
).
also
{
val
backArrowView
=
ImageView
(
context
).
also
{
it
.
setImageResource
(
R
.
drawable
.
ic_arrow_back_white_24dp
)
it
.
setImageResource
(
R
.
drawable
.
ic_arrow_back_white_24dp
)
it
.
setOnClickListener
{
imageViewer
?.
onDismiss
()
}
it
.
setOnClickListener
{
imageViewer
?.
onDismiss
()
}
it
.
setPadding
(
0
,
pad
,
pad
,
pad
)
it
.
setPadding
(
0
,
pad
,
pad
,
pad
)
}
}
val
layoutParams
=
AppBarLayout
.
LayoutParams
(
val
layoutParams
=
AppBarLayout
.
LayoutParams
(
...
@@ -113,10 +116,12 @@ class ImageAttachmentViewHolder(itemView: View,
...
@@ -113,10 +116,12 @@ class ImageAttachmentViewHolder(itemView: View,
val
appBarLayout
=
AppBarLayout
(
context
).
also
{
val
appBarLayout
=
AppBarLayout
(
context
).
also
{
it
.
layoutParams
=
lparams
it
.
layoutParams
=
lparams
it
.
setBackgroundColor
(
Color
.
BLACK
)
it
.
setBackgroundColor
(
Color
.
BLACK
)
it
.
addView
(
toolbar
,
AppBarLayout
.
LayoutParams
(
it
.
addView
(
AppBarLayout
.
LayoutParams
.
MATCH_PARENT
,
toolbar
,
AppBarLayout
.
LayoutParams
(
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
AppBarLayout
.
LayoutParams
.
MATCH_PARENT
,
))
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
)
)
}
}
val
builder
=
ImageViewer
.
createPipelineDraweeControllerBuilder
()
val
builder
=
ImageViewer
.
createPipelineDraweeControllerBuilder
()
...
@@ -144,12 +149,17 @@ class ImageAttachmentViewHolder(itemView: View,
...
@@ -144,12 +149,17 @@ class ImageAttachmentViewHolder(itemView: View,
val
imageFormat
=
ImageFormatChecker
.
getImageFormat
(
resource
.
openStream
())
val
imageFormat
=
ImageFormatChecker
.
getImageFormat
(
resource
.
openStream
())
val
imageDir
=
"${Environment.DIRECTORY_PICTURES}/Rocket.Chat Images/"
val
imageDir
=
"${Environment.DIRECTORY_PICTURES}/Rocket.Chat Images/"
val
imagePath
=
Environment
.
getExternalStoragePublicDirectory
(
imageDir
)
val
imagePath
=
Environment
.
getExternalStoragePublicDirectory
(
imageDir
)
val
imageFile
=
File
(
imagePath
,
"${cachedFile.nameWithoutExtension}.${imageFormat.fileExtension}"
)
val
imageFile
=
File
(
imagePath
,
"${cachedFile.nameWithoutExtension}.${imageFormat.fileExtension}"
)
imagePath
.
mkdirs
()
imagePath
.
mkdirs
()
imageFile
.
createNewFile
()
imageFile
.
createNewFile
()
try
{
try
{
cachedFile
.
copyTo
(
imageFile
,
true
)
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
(
"Scanned $path:"
)
Timber
.
i
(
"-> uri=$uri"
)
Timber
.
i
(
"-> uri=$uri"
)
}
}
...
@@ -166,16 +176,21 @@ class ImageAttachmentViewHolder(itemView: View,
...
@@ -166,16 +176,21 @@ class ImageAttachmentViewHolder(itemView: View,
}
}
private
fun
canWriteToExternalStorage
():
Boolean
{
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
()
{
private
fun
checkWritingPermission
()
{
val
context
=
itemView
.
context
val
context
=
itemView
.
context
if
(
context
is
ContextThemeWrapper
&&
context
.
baseContext
is
Activity
)
{
if
(
context
is
ContextThemeWrapper
&&
context
.
baseContext
is
Activity
)
{
val
activity
=
context
.
baseContext
as
Activity
val
activity
=
context
.
baseContext
as
Activity
AndroidPermissionsHelper
.
requestPermission
(
activity
,
AndroidPermissionsHelper
.
requestPermission
(
activity
,
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
,
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
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.chatroom.viewmodel.ViewModelMapper
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.server.domain.GetChatRoomsInteractor
import
chat.rocket.android.server.domain.GetChatRoomsInteractor
...
@@ -40,8 +38,7 @@ class FavoriteMessagesPresenter @Inject constructor(
...
@@ -40,8 +38,7 @@ class FavoriteMessagesPresenter @Inject constructor(
val
favoriteMessages
=
val
favoriteMessages
=
client
.
getFavoriteMessages
(
roomId
,
room
.
type
,
offset
)
client
.
getFavoriteMessages
(
roomId
,
room
.
type
,
offset
)
offset
=
favoriteMessages
.
offset
.
toInt
()
offset
=
favoriteMessages
.
offset
.
toInt
()
val
messageList
=
val
messageList
=
mapper
.
map
(
favoriteMessages
.
result
)
mapper
.
map
(
favoriteMessages
.
result
)
view
.
showFavoriteMessages
(
messageList
)
view
.
showFavoriteMessages
(
messageList
)
view
.
hideLoading
()
view
.
hideLoading
()
}.
ifNull
{
}.
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