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
c657147f
Unverified
Commit
c657147f
authored
Sep 25, 2018
by
Leonardo Aramaki
Committed by
GitHub
Sep 25, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into autocomplete-emojis
parents
7cb33644
c8a957fe
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
63 additions
and
23 deletions
+63
-23
ChatRoomPresenter.kt
...rocket/android/chatroom/presentation/ChatRoomPresenter.kt
+36
-6
ChatRoomFragment.kt
.../java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
+24
-16
KeyboardHelper.kt
...rc/main/java/chat/rocket/android/helper/KeyboardHelper.kt
+2
-1
LocalRepository.kt
...ava/chat/rocket/android/infrastructure/LocalRepository.kt
+1
-0
No files found.
app/src/main/java/chat/rocket/android/chatroom/presentation/ChatRoomPresenter.kt
View file @
c657147f
...
@@ -418,11 +418,12 @@ class ChatRoomPresenter @Inject constructor(
...
@@ -418,11 +418,12 @@ class ChatRoomPresenter @Inject constructor(
}
}
}
}
}
}
}
catch
(
ex
:
Exception
)
{
}
catch
(
ex
:
RocketChatException
)
{
Timber
.
d
(
ex
,
"Error uploading file"
)
Timber
.
d
(
ex
)
when
(
ex
)
{
ex
.
message
?.
let
{
is
RocketChatException
->
view
.
showMessage
(
ex
)
view
.
showMessage
(
it
)
else
->
view
.
showGenericErrorMessage
()
}.
ifNull
{
view
.
showGenericErrorMessage
()
}
}
}
finally
{
}
finally
{
view
.
hideLoading
()
view
.
hideLoading
()
...
@@ -1139,4 +1140,33 @@ class ChatRoomPresenter @Inject constructor(
...
@@ -1139,4 +1140,33 @@ class ChatRoomPresenter @Inject constructor(
navigator
.
toMessageInformation
(
messageId
=
messageId
)
navigator
.
toMessageInformation
(
messageId
=
messageId
)
}
}
}
}
/**
* 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
=
"${currentServer}_${LocalRepository.UNFINISHED_MSG_KEY}$chatRoomId"
if
(
unfinishedMessage
.
isNotBlank
())
{
localRepository
.
save
(
key
,
unfinishedMessage
)
}
else
{
localRepository
.
clear
(
key
)
}
}
/**
* 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.
*/
fun
getUnfinishedMessage
(
chatRoomId
:
String
):
String
{
val
key
=
"${currentServer}_${LocalRepository.UNFINISHED_MSG_KEY}$chatRoomId"
return
localRepository
.
get
(
key
)
?:
""
}
}
}
app/src/main/java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
View file @
c657147f
...
@@ -6,13 +6,11 @@ import android.content.ClipData
...
@@ -6,13 +6,11 @@ import android.content.ClipData
import
android.content.ClipboardManager
import
android.content.ClipboardManager
import
android.content.Context
import
android.content.Context
import
android.content.Intent
import
android.content.Intent
import
android.content.res.Configuration
import
android.graphics.drawable.Drawable
import
android.graphics.drawable.Drawable
import
android.os.Bundle
import
android.os.Bundle
import
android.os.Handler
import
android.os.Handler
import
android.os.SystemClock
import
android.text.Spannable
import
android.text.SpannableStringBuilder
import
android.text.SpannableStringBuilder
import
android.text.style.ImageSpan
import
android.view.KeyEvent
import
android.view.KeyEvent
import
android.view.LayoutInflater
import
android.view.LayoutInflater
import
android.view.Menu
import
android.view.Menu
...
@@ -65,7 +63,6 @@ import chat.rocket.android.helper.ImageHelper
...
@@ -65,7 +63,6 @@ import chat.rocket.android.helper.ImageHelper
import
chat.rocket.android.helper.KeyboardHelper
import
chat.rocket.android.helper.KeyboardHelper
import
chat.rocket.android.helper.MessageParser
import
chat.rocket.android.helper.MessageParser
import
chat.rocket.android.util.extension.asObservable
import
chat.rocket.android.util.extension.asObservable
import
chat.rocket.android.util.extension.launchUI
import
chat.rocket.android.util.extensions.circularRevealOrUnreveal
import
chat.rocket.android.util.extensions.circularRevealOrUnreveal
import
chat.rocket.android.util.extensions.fadeIn
import
chat.rocket.android.util.extensions.fadeIn
import
chat.rocket.android.util.extensions.fadeOut
import
chat.rocket.android.util.extensions.fadeOut
...
@@ -78,8 +75,6 @@ import chat.rocket.android.util.extensions.ui
...
@@ -78,8 +75,6 @@ import chat.rocket.android.util.extensions.ui
import
chat.rocket.common.model.RoomType
import
chat.rocket.common.model.RoomType
import
chat.rocket.common.model.roomTypeOf
import
chat.rocket.common.model.roomTypeOf
import
chat.rocket.core.internal.realtime.socket.model.State
import
chat.rocket.core.internal.realtime.socket.model.State
import
chat.rocket.core.model.ChatRoom
import
com.bumptech.glide.load.resource.gif.GifDrawable
import
dagger.android.support.AndroidSupportInjection
import
dagger.android.support.AndroidSupportInjection
import
io.reactivex.Observable
import
io.reactivex.Observable
import
io.reactivex.disposables.CompositeDisposable
import
io.reactivex.disposables.CompositeDisposable
...
@@ -88,8 +83,6 @@ import kotlinx.android.synthetic.main.fragment_chat_room.*
...
@@ -88,8 +83,6 @@ import kotlinx.android.synthetic.main.fragment_chat_room.*
import
kotlinx.android.synthetic.main.message_attachment_options.*
import
kotlinx.android.synthetic.main.message_attachment_options.*
import
kotlinx.android.synthetic.main.message_composer.*
import
kotlinx.android.synthetic.main.message_composer.*
import
kotlinx.android.synthetic.main.message_list.*
import
kotlinx.android.synthetic.main.message_list.*
import
kotlinx.coroutines.experimental.android.UI
import
kotlinx.coroutines.experimental.launch
import
java.util.concurrent.TimeUnit
import
java.util.concurrent.TimeUnit
import
java.util.concurrent.atomic.AtomicInteger
import
java.util.concurrent.atomic.AtomicInteger
import
javax.inject.Inject
import
javax.inject.Inject
...
@@ -260,6 +253,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
...
@@ -260,6 +253,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
recycler_view
.
removeOnLayoutChangeListener
(
layoutChangeListener
)
recycler_view
.
removeOnLayoutChangeListener
(
layoutChangeListener
)
presenter
.
disconnect
()
presenter
.
disconnect
()
presenter
.
saveUnfinishedMessage
(
chatRoomId
,
text_message
.
text
.
toString
())
handler
.
removeCallbacksAndMessages
(
null
)
handler
.
removeCallbacksAndMessages
(
null
)
unsubscribeComposeTextMessage
()
unsubscribeComposeTextMessage
()
...
@@ -796,6 +790,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
...
@@ -796,6 +790,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
)
)
subscribeComposeTextMessage
()
subscribeComposeTextMessage
()
getUnfinishedMessage
()
emojiKeyboardPopup
=
EmojiKeyboardPopup
(
activity
!!
,
activity
!!
.
findViewById
(
R
.
id
.
fragment_container
))
emojiKeyboardPopup
=
EmojiKeyboardPopup
(
activity
!!
,
activity
!!
.
findViewById
(
R
.
id
.
fragment_container
))
emojiKeyboardPopup
.
listener
=
this
emojiKeyboardPopup
.
listener
=
this
text_message
.
listener
=
object
:
ComposerEditText
.
ComposerEditTextListener
{
text_message
.
listener
=
object
:
ComposerEditText
.
ComposerEditTextListener
{
...
@@ -863,6 +858,19 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
...
@@ -863,6 +858,19 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
}
}
}
}
private
fun
getUnfinishedMessage
()
{
val
unfinishedMessage
=
presenter
.
getUnfinishedMessage
(
chatRoomId
)
if
(
unfinishedMessage
.
isNotBlank
())
{
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
}
}
}
private
fun
setupSuggestionsView
()
{
private
fun
setupSuggestionsView
()
{
suggestions_view
.
anchorTo
(
text_message
)
suggestions_view
.
anchorTo
(
text_message
)
.
setMaximumHeight
(
resources
.
getDimensionPixelSize
(
R
.
dimen
.
suggestions_box_max_height
))
.
setMaximumHeight
(
resources
.
getDimensionPixelSize
(
R
.
dimen
.
suggestions_box_max_height
))
...
...
app/src/main/java/chat/rocket/android/helper/KeyboardHelper.kt
View file @
c657147f
...
@@ -4,6 +4,7 @@ import android.app.Activity
...
@@ -4,6 +4,7 @@ import android.app.Activity
import
android.content.Context
import
android.content.Context
import
android.graphics.Rect
import
android.graphics.Rect
import
android.view.View
import
android.view.View
import
android.view.WindowManager
import
android.view.inputmethod.InputMethodManager
import
android.view.inputmethod.InputMethodManager
...
...
app/src/main/java/chat/rocket/android/infrastructure/LocalRepository.kt
View file @
c657147f
...
@@ -27,6 +27,7 @@ interface LocalRepository {
...
@@ -27,6 +27,7 @@ interface LocalRepository {
const
val
SETTINGS_KEY
=
"settings_"
const
val
SETTINGS_KEY
=
"settings_"
const
val
PERMISSIONS_KEY
=
"permissions_"
const
val
PERMISSIONS_KEY
=
"permissions_"
const
val
USER_KEY
=
"user_"
const
val
USER_KEY
=
"user_"
const
val
UNFINISHED_MSG_KEY
=
"unfinished_msg_"
const
val
CURRENT_USERNAME_KEY
=
"username_"
const
val
CURRENT_USERNAME_KEY
=
"username_"
const
val
LAST_CHATROOMS_REFRESH
=
"_chatrooms_refresh"
const
val
LAST_CHATROOMS_REFRESH
=
"_chatrooms_refresh"
}
}
...
...
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