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
Show 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(
...
@@ -123,6 +123,7 @@ class ChatRoomPresenter @Inject constructor(
private
var
lastState
=
manager
.
state
private
var
lastState
=
manager
.
state
private
var
typingStatusList
=
arrayListOf
<
String
>()
private
var
typingStatusList
=
arrayListOf
<
String
>()
private
val
roomChangesChannel
=
Channel
<
Room
>(
Channel
.
CONFLATED
)
private
val
roomChangesChannel
=
Channel
<
Room
>(
Channel
.
CONFLATED
)
private
lateinit
var
unfinishedMessageKey
:
String
fun
setupChatRoom
(
fun
setupChatRoom
(
roomId
:
String
,
roomId
:
String
,
...
@@ -132,9 +133,12 @@ class ChatRoomPresenter @Inject constructor(
...
@@ -132,9 +133,12 @@ class ChatRoomPresenter @Inject constructor(
)
{
)
{
launch
(
CommonPool
+
strategy
.
jobs
)
{
launch
(
CommonPool
+
strategy
.
jobs
)
{
try
{
try
{
unfinishedMessageKey
=
"${currentServer}_${LocalRepository.UNFINISHED_MSG_KEY}$roomId"
chatRoles
=
if
(
roomTypeOf
(
roomType
)
!
is
RoomType
.
DirectMessage
)
{
chatRoles
=
if
(
roomTypeOf
(
roomType
)
!
is
RoomType
.
DirectMessage
)
{
client
.
chatRoomRoles
(
roomType
=
roomTypeOf
(
roomType
),
roomName
=
roomName
)
client
.
chatRoomRoles
(
roomType
=
roomTypeOf
(
roomType
),
roomName
=
roomName
)
}
else
emptyList
()
}
else
{
emptyList
()
}
}
catch
(
ex
:
RocketChatException
)
{
}
catch
(
ex
:
RocketChatException
)
{
Timber
.
e
(
ex
)
Timber
.
e
(
ex
)
chatRoles
=
emptyList
()
chatRoles
=
emptyList
()
...
@@ -364,6 +368,7 @@ class ChatRoomPresenter @Inject constructor(
...
@@ -364,6 +368,7 @@ class ChatRoomPresenter @Inject constructor(
client
.
updateMessage
(
chatRoomId
,
messageId
,
text
)
client
.
updateMessage
(
chatRoomId
,
messageId
,
text
)
}
}
clearUnfinishedMessage
()
view
.
enableSendMessageButton
()
view
.
enableSendMessageButton
()
}
catch
(
ex
:
Exception
)
{
}
catch
(
ex
:
Exception
)
{
Timber
.
d
(
ex
,
"Error sending message..."
)
Timber
.
d
(
ex
,
"Error sending message..."
)
...
@@ -1281,31 +1286,26 @@ class ChatRoomPresenter @Inject constructor(
...
@@ -1281,31 +1286,26 @@ class ChatRoomPresenter @Inject constructor(
}
}
/**
/**
* Save unfinished message, when user left chat room without sending a message. It also clears
* Save unfinished message, when user left chat room without sending a message.
* saved message from local repository when unfinishedMessage is blank.
*
*
* @param chatRoomId Chat room Id.
* @param unfinishedMessage The unfinished message to save.
* @param unfinishedMessage The unfinished message to save.
*/
*/
fun
saveUnfinishedMessage
(
chatRoomId
:
String
,
unfinishedMessage
:
String
)
{
fun
saveUnfinishedMessage
(
unfinishedMessage
:
String
)
{
val
key
=
"${currentServer}_${LocalRepository.UNFINISHED_MSG_KEY}$chatRoomId"
if
(
unfinishedMessage
.
isNotBlank
())
{
if
(
unfinishedMessage
.
isNotBlank
())
{
localRepository
.
save
(
key
,
unfinishedMessage
)
localRepository
.
save
(
unfinishedMessageKey
,
unfinishedMessage
)
}
else
{
localRepository
.
clear
(
key
)
}
}
}
}
fun
clearUnfinishedMessage
()
{
localRepository
.
clear
(
unfinishedMessageKey
)
}
/**
/**
* Get unfinished message from local repository, when user left chat room without
* Get unfinished message from local repository, when user left chat room without
* sending a message and now the user is back.
* sending a message and now the user is back.
*
*
* @param chatRoomId Chat room Id.
* @return Returns the unfinished message, null otherwise.
*
* @return Returns the unfinished message.
*/
*/
fun
getUnfinishedMessage
(
chatRoomId
:
String
):
String
{
fun
getUnfinishedMessage
():
String
?
{
val
key
=
"${currentServer}_${LocalRepository.UNFINISHED_MSG_KEY}$chatRoomId"
return
localRepository
.
get
(
unfinishedMessageKey
)
return
localRepository
.
get
(
key
)
?:
""
}
}
}
}
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
...
@@ -76,6 +76,7 @@ import chat.rocket.android.util.extensions.fadeOut
import
chat.rocket.android.util.extensions.getBitmpap
import
chat.rocket.android.util.extensions.getBitmpap
import
chat.rocket.android.util.extensions.hideKeyboard
import
chat.rocket.android.util.extensions.hideKeyboard
import
chat.rocket.android.util.extensions.inflate
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.rotateBy
import
chat.rocket.android.util.extensions.showToast
import
chat.rocket.android.util.extensions.showToast
import
chat.rocket.android.util.extensions.textContent
import
chat.rocket.android.util.extensions.textContent
...
@@ -242,6 +243,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
...
@@ -242,6 +243,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
presenter
.
setupChatRoom
(
chatRoomId
,
chatRoomName
,
chatRoomType
,
chatRoomMessage
)
presenter
.
setupChatRoom
(
chatRoomId
,
chatRoomName
,
chatRoomType
,
chatRoomMessage
)
presenter
.
loadChatRooms
()
presenter
.
loadChatRooms
()
getUnfinishedMessage
()
setupRecyclerView
()
setupRecyclerView
()
setupFab
()
setupFab
()
setupSuggestionsView
()
setupSuggestionsView
()
...
@@ -264,9 +266,9 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
...
@@ -264,9 +266,9 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
recycler_view
.
removeOnScrollListener
(
onScrollListener
)
recycler_view
.
removeOnScrollListener
(
onScrollListener
)
recycler_view
.
removeOnLayoutChangeListener
(
layoutChangeListener
)
recycler_view
.
removeOnLayoutChangeListener
(
layoutChangeListener
)
presenter
.
disconnect
()
presenter
.
saveUnfinishedMessage
(
text_message
.
text
.
toString
())
presenter
.
saveUnfinishedMessage
(
chatRoomId
,
text_message
.
text
.
toString
())
handler
.
removeCallbacksAndMessages
(
null
)
handler
.
removeCallbacksAndMessages
(
null
)
presenter
.
disconnect
()
unsubscribeComposeTextMessage
()
unsubscribeComposeTextMessage
()
// Hides the keyboard (if it's opened) before going to any view.
// Hides the keyboard (if it's opened) before going to any view.
...
@@ -953,15 +955,9 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
...
@@ -953,15 +955,9 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
}
}
private
fun
getUnfinishedMessage
()
{
private
fun
getUnfinishedMessage
()
{
val
unfinishedMessage
=
presenter
.
getUnfinishedMessage
(
chatRoomId
)
val
unfinishedMessage
=
presenter
.
getUnfinishedMessage
()
if
(
unfinishedMessage
.
isNot
Blank
())
{
if
(
unfinishedMessage
.
isNot
NullNorEmpty
())
{
text_message
.
setText
(
unfinishedMessage
)
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