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
531c5a0f
Commit
531c5a0f
authored
Dec 17, 2018
by
Filipe de Lima Brito
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Draft messages improvements
parent
61318332
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
25 deletions
+21
-25
ChatRoomPresenter.kt
...rocket/android/chatroom/presentation/ChatRoomPresenter.kt
+15
-15
ChatRoomFragment.kt
.../java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
+6
-10
No files found.
app/src/main/java/chat/rocket/android/chatroom/presentation/ChatRoomPresenter.kt
View file @
531c5a0f
...
...
@@ -123,6 +123,7 @@ class ChatRoomPresenter @Inject constructor(
private
var
lastState
=
manager
.
state
private
var
typingStatusList
=
arrayListOf
<
String
>()
private
val
roomChangesChannel
=
Channel
<
Room
>(
Channel
.
CONFLATED
)
private
lateinit
var
unfinishedMessageKey
:
String
fun
setupChatRoom
(
roomId
:
String
,
...
...
@@ -132,9 +133,12 @@ class ChatRoomPresenter @Inject constructor(
)
{
launch
(
CommonPool
+
strategy
.
jobs
)
{
try
{
unfinishedMessageKey
=
"${currentServer}_${LocalRepository.UNFINISHED_MSG_KEY}$roomId"
chatRoles
=
if
(
roomTypeOf
(
roomType
)
!
is
RoomType
.
DirectMessage
)
{
client
.
chatRoomRoles
(
roomType
=
roomTypeOf
(
roomType
),
roomName
=
roomName
)
}
else
emptyList
()
}
else
{
emptyList
()
}
}
catch
(
ex
:
RocketChatException
)
{
Timber
.
e
(
ex
)
chatRoles
=
emptyList
()
...
...
@@ -364,6 +368,7 @@ class ChatRoomPresenter @Inject constructor(
client
.
updateMessage
(
chatRoomId
,
messageId
,
text
)
}
clearUnfinishedMessage
()
view
.
enableSendMessageButton
()
}
catch
(
ex
:
Exception
)
{
Timber
.
d
(
ex
,
"Error sending message..."
)
...
...
@@ -1281,31 +1286,26 @@ class ChatRoomPresenter @Inject constructor(
}
/**
* Save unfinished message, when user left chat room without sending a message. It also clears
* saved message from local repository when unfinishedMessage is blank.
* Save unfinished message, when user left chat room without sending a message.
*
* @param chatRoomId Chat room Id.
* @param unfinishedMessage The unfinished message to save.
*/
fun
saveUnfinishedMessage
(
chatRoomId
:
String
,
unfinishedMessage
:
String
)
{
val
key
=
"${currentServer}_${LocalRepository.UNFINISHED_MSG_KEY}$chatRoomId"
fun
saveUnfinishedMessage
(
unfinishedMessage
:
String
)
{
if
(
unfinishedMessage
.
isNotBlank
())
{
localRepository
.
save
(
key
,
unfinishedMessage
)
}
else
{
localRepository
.
clear
(
key
)
localRepository
.
save
(
unfinishedMessageKey
,
unfinishedMessage
)
}
}
fun
clearUnfinishedMessage
()
{
localRepository
.
clear
(
unfinishedMessageKey
)
}
/**
* Get unfinished message from local repository, when user left chat room without
* sending a message and now the user is back.
*
* @param chatRoomId Chat room Id.
*
* @return Returns the unfinished message.
* @return Returns the unfinished message, null otherwise.
*/
fun
getUnfinishedMessage
(
chatRoomId
:
String
):
String
{
val
key
=
"${currentServer}_${LocalRepository.UNFINISHED_MSG_KEY}$chatRoomId"
return
localRepository
.
get
(
key
)
?:
""
fun
getUnfinishedMessage
():
String
?
{
return
localRepository
.
get
(
unfinishedMessageKey
)
}
}
app/src/main/java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
View file @
531c5a0f
...
...
@@ -76,6 +76,7 @@ import chat.rocket.android.util.extensions.fadeOut
import
chat.rocket.android.util.extensions.getBitmpap
import
chat.rocket.android.util.extensions.hideKeyboard
import
chat.rocket.android.util.extensions.inflate
import
chat.rocket.android.util.extensions.isNotNullNorEmpty
import
chat.rocket.android.util.extensions.rotateBy
import
chat.rocket.android.util.extensions.showToast
import
chat.rocket.android.util.extensions.textContent
...
...
@@ -242,6 +243,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
presenter
.
setupChatRoom
(
chatRoomId
,
chatRoomName
,
chatRoomType
,
chatRoomMessage
)
presenter
.
loadChatRooms
()
getUnfinishedMessage
()
setupRecyclerView
()
setupFab
()
setupSuggestionsView
()
...
...
@@ -264,9 +266,9 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
recycler_view
.
removeOnScrollListener
(
onScrollListener
)
recycler_view
.
removeOnLayoutChangeListener
(
layoutChangeListener
)
presenter
.
disconnect
()
presenter
.
saveUnfinishedMessage
(
chatRoomId
,
text_message
.
text
.
toString
())
presenter
.
saveUnfinishedMessage
(
text_message
.
text
.
toString
())
handler
.
removeCallbacksAndMessages
(
null
)
presenter
.
disconnect
()
unsubscribeComposeTextMessage
()
// Hides the keyboard (if it's opened) before going to any view.
...
...
@@ -953,15 +955,9 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
}
private
fun
getUnfinishedMessage
()
{
val
unfinishedMessage
=
presenter
.
getUnfinishedMessage
(
chatRoomId
)
if
(
unfinishedMessage
.
isNot
Blank
())
{
val
unfinishedMessage
=
presenter
.
getUnfinishedMessage
()
if
(
unfinishedMessage
.
isNot
NullNorEmpty
())
{
text_message
.
setText
(
unfinishedMessage
)
val
orientation
=
resources
.
configuration
.
orientation
if
(
orientation
==
Configuration
.
ORIENTATION_PORTRAIT
)
{
KeyboardHelper
.
showSoftKeyboard
(
text_message
)
}
else
{
//TODO show keyboard in full screen mode when landscape orientation
}
}
}
...
...
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