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
f9ab2126
Commit
f9ab2126
authored
Mar 22, 2018
by
pancor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add show soft keyboard at activity start functionality
parent
7f80a50b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
0 deletions
+22
-0
ChatRoomFragment.kt
.../java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
+10
-0
KeyboardHelper.kt
...rc/main/java/chat/rocket/android/helper/KeyboardHelper.kt
+12
-0
No files found.
app/src/main/java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
View file @
f9ab2126
...
@@ -115,6 +115,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardPopup.Listener {
...
@@ -115,6 +115,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardPopup.Listener {
}
}
override
fun
onDestroyView
()
{
override
fun
onDestroyView
()
{
presenter
.
saveUnfinishedMessage
(
chatRoomId
,
text_message
.
text
.
toString
())
presenter
.
unsubscribeMessages
(
chatRoomId
)
presenter
.
unsubscribeMessages
(
chatRoomId
)
handler
.
removeCallbacksAndMessages
(
null
)
handler
.
removeCallbacksAndMessages
(
null
)
unsubscribeTextMessage
()
unsubscribeTextMessage
()
...
@@ -350,6 +351,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardPopup.Listener {
...
@@ -350,6 +351,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardPopup.Listener {
button_show_attachment_options
.
alpha
=
1f
button_show_attachment_options
.
alpha
=
1f
button_show_attachment_options
.
setVisible
(
true
)
button_show_attachment_options
.
setVisible
(
true
)
getUnfinishedMessage
()
subscribeTextMessage
()
subscribeTextMessage
()
emojiKeyboardPopup
=
EmojiKeyboardPopup
(
activity
!!
,
activity
!!
.
findViewById
(
R
.
id
.
fragment_container
))
emojiKeyboardPopup
=
EmojiKeyboardPopup
(
activity
!!
,
activity
!!
.
findViewById
(
R
.
id
.
fragment_container
))
emojiKeyboardPopup
.
listener
=
this
emojiKeyboardPopup
.
listener
=
this
...
@@ -410,6 +412,14 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardPopup.Listener {
...
@@ -410,6 +412,14 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardPopup.Listener {
}
}
}
}
private
fun
getUnfinishedMessage
()
{
val
unfinishedMessage
=
presenter
.
getUnfinishedMessage
(
chatRoomId
)
if
(
unfinishedMessage
.
isNotBlank
()
&&
activity
!=
null
)
{
text_message
.
setText
(
unfinishedMessage
)
KeyboardHelper
.
showSoftKeyboardOnActivityStart
(
activity
!!
,
text_message
)
}
}
private
fun
openEmojiKeyboardPopup
()
{
private
fun
openEmojiKeyboardPopup
()
{
if
(!
emojiKeyboardPopup
.
isShowing
())
{
if
(!
emojiKeyboardPopup
.
isShowing
())
{
// If keyboard is visible, simply show the popup
// If keyboard is visible, simply show the popup
...
...
app/src/main/java/chat/rocket/android/helper/KeyboardHelper.kt
View file @
f9ab2126
...
@@ -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
...
@@ -50,4 +51,15 @@ object KeyboardHelper {
...
@@ -50,4 +51,15 @@ object KeyboardHelper {
inputMethodManager
.
toggleSoftInput
(
InputMethodManager
.
SHOW_IMPLICIT
,
InputMethodManager
.
SHOW_IMPLICIT
)
inputMethodManager
.
toggleSoftInput
(
InputMethodManager
.
SHOW_IMPLICIT
,
InputMethodManager
.
SHOW_IMPLICIT
)
}
}
}
}
/**
* Show the soft keyboard for the given view at the start of activity or fragment.
*
* @param view View to receive input focus.
*/
fun
showSoftKeyboardOnActivityStart
(
activity
:
Activity
,
view
:
View
)
{
if
(
view
.
requestFocus
())
{
activity
.
window
.
setSoftInputMode
(
WindowManager
.
LayoutParams
.
SOFT_INPUT_STATE_ALWAYS_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