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
68932d74
Commit
68932d74
authored
Mar 23, 2018
by
pancor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor code and add clear message possibility
parent
f9ab2126
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
5 deletions
+14
-5
ChatRoomPresenter.kt
...rocket/android/chatroom/presentation/ChatRoomPresenter.kt
+6
-3
ChatRoomFragment.kt
.../java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
+7
-1
KeyboardHelper.kt
...rc/main/java/chat/rocket/android/helper/KeyboardHelper.kt
+1
-1
No files found.
app/src/main/java/chat/rocket/android/chatroom/presentation/ChatRoomPresenter.kt
View file @
68932d74
...
...
@@ -362,15 +362,18 @@ class ChatRoomPresenter @Inject constructor(private val view: ChatRoomView,
}
/**
* Save unfinished message, when user left chat room without sending a message.
* Save unfinished message, when user left chat room without sending a message. It also clears
* saved message from local repository when unfinishedMessage is blank.
*
* @param chatRoomId Chat room Id.
* @param unfinishedMessage The unfinished message to save.
*/
fun
saveUnfinishedMessage
(
chatRoomId
:
String
,
unfinishedMessage
:
String
)
{
val
key
=
LocalRepository
.
UNFINISHED_MSG_KEY
+
chatRoomId
if
(
unfinishedMessage
.
isNotBlank
())
{
val
key
=
LocalRepository
.
UNFINISHED_MSG_KEY
+
chatRoomId
localRepository
.
save
(
key
,
unfinishedMessage
)
}
else
{
localRepository
.
clear
(
key
)
}
}
...
...
@@ -386,4 +389,4 @@ class ChatRoomPresenter @Inject constructor(private val view: ChatRoomView,
val
key
=
LocalRepository
.
UNFINISHED_MSG_KEY
+
chatRoomId
return
localRepository
.
get
(
key
)
?:
""
}
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
View file @
68932d74
...
...
@@ -5,6 +5,7 @@ import android.content.ClipData
import
android.content.ClipboardManager
import
android.content.Context
import
android.content.Intent
import
android.content.res.Configuration
import
android.net.Uri
import
android.os.Bundle
import
android.os.Handler
...
...
@@ -416,7 +417,12 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardPopup.Listener {
val
unfinishedMessage
=
presenter
.
getUnfinishedMessage
(
chatRoomId
)
if
(
unfinishedMessage
.
isNotBlank
()
&&
activity
!=
null
)
{
text_message
.
setText
(
unfinishedMessage
)
KeyboardHelper
.
showSoftKeyboardOnActivityStart
(
activity
!!
,
text_message
)
val
orientation
=
resources
.
configuration
.
orientation
if
(
orientation
==
Configuration
.
ORIENTATION_PORTRAIT
)
{
KeyboardHelper
.
showSoftKeyboardOnActivityStart
(
activity
!!
,
text_message
)
}
else
if
(
orientation
==
Configuration
.
ORIENTATION_LANDSCAPE
)
{
text_message
.
requestFocus
()
}
}
}
...
...
app/src/main/java/chat/rocket/android/helper/KeyboardHelper.kt
View file @
68932d74
...
...
@@ -59,7 +59,7 @@ object KeyboardHelper {
*/
fun
showSoftKeyboardOnActivityStart
(
activity
:
Activity
,
view
:
View
)
{
if
(
view
.
requestFocus
())
{
activity
.
window
.
setSoftInputMode
(
WindowManager
.
LayoutParams
.
SOFT_INPUT_STATE_
ALWAYS_
VISIBLE
)
activity
.
window
.
setSoftInputMode
(
WindowManager
.
LayoutParams
.
SOFT_INPUT_STATE_VISIBLE
)
}
}
}
\ 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