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
7db7a3ae
Commit
7db7a3ae
authored
Feb 23, 2018
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix closing keyboard behavior and rename few methods
parent
b6b8ada6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
19 deletions
+52
-19
ChatRoomActivity.kt
.../java/chat/rocket/android/chatroom/ui/ChatRoomActivity.kt
+3
-4
ChatRoomFragment.kt
.../java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
+15
-5
EmojiFragment.kt
...in/java/chat/rocket/android/widget/emoji/EmojiFragment.kt
+34
-10
No files found.
app/src/main/java/chat/rocket/android/chatroom/ui/ChatRoomActivity.kt
View file @
7db7a3ae
...
...
@@ -4,7 +4,6 @@ import android.content.Context
import
android.content.Intent
import
android.os.Bundle
import
android.support.v4.app.Fragment
import
android.support.v7.app.AppCompatActivity
import
chat.rocket.android.R
import
chat.rocket.android.helper.KeyboardHelper
import
chat.rocket.android.util.extensions.addFragment
...
...
@@ -68,13 +67,13 @@ class ChatRoomActivity : SwipeBackActivity(), HasSupportFragmentInjector {
}
override
fun
onBackPressed
()
{
super
.
onBackPressed
()
val
frag
=
supportFragmentManager
.
findFragmentByTag
(
EmojiFragment
.
TAG
)
as
EmojiFragment
?
if
(
frag
!=
null
&&
frag
.
is
Shown
())
{
frag
.
hid
e
()
if
(
frag
!=
null
&&
frag
.
is
Expanded
())
{
frag
.
collaps
e
()
}
else
{
KeyboardHelper
.
hideSoftKeyboard
(
this
)
finishActivity
()
super
.
onBackPressed
()
}
}
...
...
app/src/main/java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
View file @
7db7a3ae
...
...
@@ -261,7 +261,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiFragment.EmojiKeyboardLi
}
}
override
fun
onKeyPressed
(
keyCode
:
Int
)
{
override
fun
on
NonEmoji
KeyPressed
(
keyCode
:
Int
)
{
when
(
keyCode
)
{
KeyEvent
.
KEYCODE_BACK
->
with
(
text_message
)
{
if
(
selectionStart
>
0
)
text
.
delete
(
selectionStart
-
1
,
selectionStart
)
...
...
@@ -270,6 +270,14 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiFragment.EmojiKeyboardLi
}
}
override
fun
onEmojiPanelCollapsed
()
{
setReactionButtonIcon
(
R
.
drawable
.
ic_reaction_24dp
)
}
override
fun
onEmojiPanelExpanded
()
{
}
private
fun
setReactionButtonIcon
(
@DrawableRes
drawableId
:
Int
)
{
button_add_reaction
.
setImageResource
(
drawableId
)
button_add_reaction
.
setTag
(
drawableId
)
...
...
@@ -278,7 +286,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiFragment.EmojiKeyboardLi
private
fun
hideAllKeyboards
()
{
activity
?.
let
{
KeyboardHelper
.
hideSoftKeyboard
(
it
)
attachOrGetEmojiFragment
()
?.
hid
e
()
attachOrGetEmojiFragment
()
?.
collaps
e
()
setReactionButtonIcon
(
R
.
drawable
.
ic_reaction_24dp
)
}
}
...
...
@@ -328,7 +336,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiFragment.EmojiKeyboardLi
activity
?.
let
{
val
fragment
=
EmojiFragment
.
getOrAttach
(
it
,
R
.
id
.
emoji_fragment_placeholder
,
composer
)
if
(
fragment
.
isCollapsed
())
{
fragment
.
open
Hidden
()
fragment
.
expand
Hidden
()
}
setReactionButtonIcon
(
R
.
drawable
.
ic_reaction_24dp
)
}
...
...
@@ -353,7 +361,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiFragment.EmojiKeyboardLi
sendMessage
(
textMessage
)
attachOrGetEmojiFragment
()
?.
let
{
if
(
it
.
softKeyboardVisible
)
{
it
.
hid
e
()
it
.
collaps
e
()
}
}
clearMessageComposition
()
...
...
@@ -390,7 +398,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiFragment.EmojiKeyboardLi
when
(
tag
)
{
R
.
drawable
.
ic_reaction_24dp
->
{
KeyboardHelper
.
hideSoftKeyboard
(
it
)
if
(!
emojiFragment
.
is
Shown
())
{
if
(!
emojiFragment
.
is
Expanded
())
{
emojiFragment
.
show
()
}
setReactionButtonIcon
(
R
.
drawable
.
ic_keyboard_black_24dp
)
...
...
@@ -402,6 +410,8 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiFragment.EmojiKeyboardLi
}
}
}
text_message
.
requestFocus
()
}
}
...
...
app/src/main/java/chat/rocket/android/widget/emoji/EmojiFragment.kt
View file @
7db7a3ae
...
...
@@ -13,7 +13,6 @@ import android.view.*
import
android.widget.EditText
import
android.widget.ImageView
import
chat.rocket.android.R
import
chat.rocket.android.util.extensions.setVisible
class
EmojiFragment
:
Fragment
()
{
...
...
@@ -98,6 +97,9 @@ class EmojiFragment : Fragment() {
EmojiRepository
.
saveKeyboardHeight
(
currentKeyboardHeight
)
setKeyboardHeight
(
currentKeyboardHeight
)
softKeyboardVisible
=
true
parentContainer
.
postDelayed
({
expandHidden
()
},
100
)
}
else
if
(
lastVisibleDecorViewHeight
+
MIN_KEYBOARD_HEIGHT_PX
<
visibleDecorViewHeight
)
{
// Notify listener about keyboard being hidden.
softKeyboardVisible
=
false
...
...
@@ -122,7 +124,7 @@ class EmojiFragment : Fragment() {
}
backspaceView
.
setOnClickListener
{
listener
?.
onKeyPressed
(
KeyEvent
.
KEYCODE_BACK
)
listener
?.
on
NonEmoji
KeyPressed
(
KeyEvent
.
KEYCODE_BACK
)
}
}
...
...
@@ -139,7 +141,15 @@ class EmojiFragment : Fragment() {
}
}
viewPager
.
adapter
=
CategoryPagerAdapter
(
object
:
EmojiKeyboardListener
{
override
fun
onKeyPressed
(
keyCode
:
Int
)
{
override
fun
onEmojiPanelExpanded
()
{
// do nothing
}
override
fun
onEmojiPanelCollapsed
()
{
// do nothing
}
override
fun
onNonEmojiKeyPressed
(
keyCode
:
Int
)
{
// do nothing
}
...
...
@@ -215,25 +225,35 @@ class EmojiFragment : Fragment() {
}
}
private
fun
setKeyboardVisibility
(
visibility
:
Int
)
{
if
(
visibility
!=
parentContainer
.
visibility
)
{
parentContainer
.
visibility
=
visibility
}
}
/**
* Show the emoji keyboard.
*/
fun
show
()
{
parentContainer
.
setVisible
(
true
)
setKeyboardVisibility
(
View
.
VISIBLE
)
}
fun
openHidden
()
{
parentContainer
.
visibility
=
View
.
INVISIBLE
/**
* Expand the emoji keyboard with invisible contents.
*/
fun
expandHidden
()
{
setKeyboardVisibility
(
View
.
INVISIBLE
)
}
/**
* Hide the emoji keyboard.
*/
fun
hid
e
()
{
fun
collaps
e
()
{
// Since the emoji keyboard is always behind the soft keyboard assume it's also dismissed
// when the emoji one is about to get close. Hence we should invoke our listener to update
// the UI as if the soft keyboard is hidden.
parentContainer
.
setVisible
(
false
)
listener
?.
onEmojiPanelCollapsed
()
setKeyboardVisibility
(
View
.
GONE
)
}
/**
...
...
@@ -241,7 +261,7 @@ class EmojiFragment : Fragment() {
*
* @return <code>true</code> if opened.
*/
fun
is
Shown
()
=
parentContainer
.
visibility
==
View
.
VISIBLE
fun
is
Expanded
()
=
parentContainer
.
visibility
==
View
.
VISIBLE
/**
* Whether the emoji keyboard is collapsed.
...
...
@@ -265,6 +285,10 @@ class EmojiFragment : Fragment() {
*
* @see android.view.KeyEvent
*/
fun
onKeyPressed
(
keyCode
:
Int
)
fun
onNonEmojiKeyPressed
(
keyCode
:
Int
)
fun
onEmojiPanelCollapsed
()
fun
onEmojiPanelExpanded
()
}
}
\ 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