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
c113af7b
Commit
c113af7b
authored
Feb 22, 2018
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement backspace from emoji keyboard
parent
c79c635d
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
145 additions
and
52 deletions
+145
-52
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+1
-1
ChatRoomPresenter.kt
...rocket/android/chatroom/presentation/ChatRoomPresenter.kt
+6
-6
ChatRoomFragment.kt
.../java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
+11
-0
ChatRoomsPresenter.kt
...cket/android/chatrooms/presentation/ChatRoomsPresenter.kt
+2
-2
SharedPreferencesSettingsRepository.kt
...er/infraestructure/SharedPreferencesSettingsRepository.kt
+4
-4
EmojiFragment.kt
...in/java/chat/rocket/android/widget/emoji/EmojiFragment.kt
+64
-31
ic_backspace_gray_24dp.xml
app/src/main/res/drawable/ic_backspace_gray_24dp.xml
+1
-1
ic_search_gray_24px.xml
app/src/main/res/drawable/ic_search_gray_24px.xml
+10
-0
ic_search_white_24px.xml
app/src/main/res/drawable/ic_search_white_24px.xml
+9
-4
emoji_category_layout.xml
app/src/main/res/layout/emoji_category_layout.xml
+0
-2
emoji_popup_layout.xml
app/src/main/res/layout/emoji_popup_layout.xml
+36
-1
colors.xml
app/src/main/res/values/colors.xml
+1
-0
No files found.
app/src/main/AndroidManifest.xml
View file @
c113af7b
...
...
@@ -45,7 +45,7 @@
<activity
android:name=
".chatroom.ui.ChatRoomActivity"
android:windowSoftInputMode=
"adjust
Nothing
"
android:windowSoftInputMode=
"adjust
Pan
"
android:theme=
"@style/AppTheme"
/>
<activity
...
...
app/src/main/java/chat/rocket/android/chatroom/presentation/ChatRoomPresenter.kt
View file @
c113af7b
...
...
@@ -15,7 +15,7 @@ import chat.rocket.common.util.ifNull
import
chat.rocket.core.internal.realtime.State
import
chat.rocket.core.internal.realtime.connect
import
chat.rocket.core.internal.realtime.subscribeRoomMessages
import
chat.rocket.core.internal.realtime.unsubsc
ibr
e
import
chat.rocket.core.internal.realtime.unsubsc
rib
e
import
chat.rocket.core.internal.rest.*
import
chat.rocket.core.model.Message
import
chat.rocket.core.model.Value
...
...
@@ -47,7 +47,7 @@ class ChatRoomPresenter @Inject constructor(private val view: ChatRoomView,
view
.
showLoading
()
try
{
val
messages
=
client
.
messages
(
chatRoomId
,
roomTypeOf
(
chatRoomType
),
offset
,
30
).
result
client
.
messages
(
chatRoomId
,
roomTypeOf
(
chatRoomType
),
offset
,
30
).
result
messagesRepository
.
saveAll
(
messages
)
val
messagesViewModels
=
mapper
.
mapToViewModelList
(
messages
,
settings
)
...
...
@@ -180,7 +180,7 @@ class ChatRoomPresenter @Inject constructor(private val view: ChatRoomView,
launch
(
CommonPool
)
{
client
.
removeStateChannel
(
stateChannel
)
subId
?.
let
{
subscriptionId
->
client
.
unsubsc
ibr
e
(
subscriptionId
)
client
.
unsubsc
rib
e
(
subscriptionId
)
}
}
}
...
...
@@ -239,9 +239,9 @@ class ChatRoomPresenter @Inject constructor(private val view: ChatRoomView,
is
RoomType
.
Custom
->
"custom"
//TODO: put appropriate callback string here.
}
view
.
showReplyingAction
(
user
,
"[ ](${serverUrl}/${room}/${roomName}?msg=${id}) ${mention} "
,
m
.
message
user
,
"[ ](${serverUrl}/${room}/${roomName}?msg=${id}) ${mention} "
,
m
.
message
)
}
}
...
...
app/src/main/java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
View file @
c113af7b
...
...
@@ -247,6 +247,17 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiFragment.EmojiKeyboardLi
}
}
override
fun
onKeyPressed
(
keyCode
:
Int
)
{
when
(
keyCode
)
{
KeyEvent
.
KEYCODE_BACK
->
with
(
text_message
)
{
if
(
selectionStart
>
0
)
{
text
.
delete
(
selectionStart
-
1
,
selectionStart
)
}
}
else
->
throw
IllegalArgumentException
(
"pressed key not expected"
)
}
}
private
fun
setReactionButtonIcon
(
@DrawableRes
drawableId
:
Int
)
{
button_add_reaction
.
setImageResource
(
drawableId
)
button_add_reaction
.
setTag
(
drawableId
)
...
...
app/src/main/java/chat/rocket/android/chatrooms/presentation/ChatRoomsPresenter.kt
View file @
c113af7b
...
...
@@ -202,7 +202,7 @@ class ChatRoomsPresenter @Inject constructor(private val view: ChatRoomsView,
room
.
readonly
,
room
.
updatedAt
?:
updatedAt
,
timestamp
,
last
Modified
,
last
Seen
,
room
.
topic
,
room
.
announcement
,
default
,
...
...
@@ -232,7 +232,7 @@ class ChatRoomsPresenter @Inject constructor(private val view: ChatRoomsView,
subscription
.
readonly
?:
readonly
,
subscription
.
updatedAt
?:
updatedAt
,
subscription
.
timestamp
?:
timestamp
,
subscription
.
lastModified
?:
last
Modified
,
subscription
.
lastModified
?:
last
Seen
,
topic
,
announcement
,
subscription
.
isDefault
,
...
...
app/src/main/java/chat/rocket/android/server/infraestructure/SharedPreferencesSettingsRepository.kt
View file @
c113af7b
...
...
@@ -6,16 +6,16 @@ import chat.rocket.android.server.domain.SettingsRepository
import
chat.rocket.core.internal.SettingsAdapter
import
chat.rocket.core.model.Value
class
SharedPreferencesSettingsRepository
(
private
val
localRe
s
pository
:
LocalRepository
)
:
SettingsRepository
{
class
SharedPreferencesSettingsRepository
(
private
val
localRepository
:
LocalRepository
)
:
SettingsRepository
{
private
val
adapter
=
SettingsAdapter
()
private
val
adapter
=
SettingsAdapter
()
.
lenient
()
override
fun
save
(
url
:
String
,
settings
:
Map
<
String
,
Value
<
Any
>>)
{
localRe
s
pository
.
save
(
"$SETTINGS_KEY$url"
,
adapter
.
toJson
(
settings
))
localRepository
.
save
(
"$SETTINGS_KEY$url"
,
adapter
.
toJson
(
settings
))
}
override
fun
get
(
url
:
String
):
Map
<
String
,
Value
<
Any
>>?
{
val
settings
=
localRe
s
pository
.
get
(
"$SETTINGS_KEY$url"
)
val
settings
=
localRepository
.
get
(
"$SETTINGS_KEY$url"
)
settings
?.
let
{
return
adapter
.
fromJson
(
it
)
}
...
...
app/src/main/java/chat/rocket/android/widget/emoji/EmojiFragment.kt
View file @
c113af7b
...
...
@@ -9,10 +9,7 @@ import android.support.v4.app.FragmentActivity
import
android.support.v4.view.ViewPager
import
android.text.Editable
import
android.text.TextWatcher
import
android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
import
android.view.ViewTreeObserver
import
android.view.*
import
android.widget.EditText
import
android.widget.ImageView
import
chat.rocket.android.R
...
...
@@ -22,6 +19,8 @@ import chat.rocket.android.util.extensions.setVisible
class
EmojiFragment
:
Fragment
()
{
private
lateinit
var
viewPager
:
ViewPager
private
lateinit
var
tabLayout
:
TabLayout
private
lateinit
var
searchView
:
View
private
lateinit
var
backspaceView
:
View
private
lateinit
var
parentContainer
:
ViewGroup
private
var
editor
:
View
?
=
null
private
var
decorLayoutListener
:
ViewTreeObserver
.
OnGlobalLayoutListener
?
=
null
...
...
@@ -55,6 +54,8 @@ class EmojiFragment : Fragment() {
val
view
=
inflater
.
inflate
(
R
.
layout
.
emoji_popup_layout
,
container
,
false
)
parentContainer
=
view
.
findViewById
(
R
.
id
.
emoji_keyboard_container
)
viewPager
=
view
.
findViewById
(
R
.
id
.
pager_categories
)
searchView
=
view
.
findViewById
(
R
.
id
.
emoji_search
)
backspaceView
=
view
.
findViewById
(
R
.
id
.
emoji_backspace
)
tabLayout
=
view
.
findViewById
(
R
.
id
.
tabs
)
tabLayout
.
setupWithViewPager
(
viewPager
)
return
view
...
...
@@ -68,17 +69,12 @@ class EmojiFragment : Fragment() {
}
override
fun
onViewCreated
(
view
:
View
,
savedInstanceState
:
Bundle
?)
{
val
callback
=
when
(
activity
)
{
is
EmojiKeyboardListener
->
activity
as
EmojiKeyboardListener
else
->
{
val
fragments
=
activity
?.
supportFragmentManager
?.
fragments
if
(
fragments
==
null
||
fragments
.
size
==
0
||
!(
fragments
[
0
]
is
EmojiKeyboardListener
))
{
throw
IllegalStateException
(
"activity/fragment should implement EmojiKeyboardListener interface"
)
}
fragments
[
0
]
as
EmojiKeyboardListener
}
}
setupLayout
()
setupViewPager
()
setupBottomBar
()
}
private
fun
setupLayout
()
{
activity
?.
let
{
val
decorView
=
it
.
getWindow
().
decorView
decorLayoutListener
=
object
:
ViewTreeObserver
.
OnGlobalLayoutListener
{
...
...
@@ -119,25 +115,53 @@ class EmojiFragment : Fragment() {
if
(
storedHeight
>
0
)
{
setKeyboardHeight
(
storedHeight
)
}
}
private
fun
setupBottomBar
()
{
searchView
.
setOnClickListener
{
viewPager
.
adapter
=
CategoryPagerAdapter
(
object
:
EmojiKeyboardListener
{
override
fun
onEmojiAdded
(
emoji
:
Emoji
)
{
EmojiRepository
.
addToRecents
(
emoji
)
callback
.
onEmojiAdded
(
emoji
)
}
})
for
(
category
in
EmojiCategory
.
values
())
{
val
tab
=
tabLayout
.
getTabAt
(
category
.
ordinal
)
val
tabView
=
layoutInflater
.
inflate
(
R
.
layout
.
emoji_picker_tab
,
null
)
tab
?.
setCustomView
(
tabView
)
val
textView
=
tabView
.
findViewById
(
R
.
id
.
image_category
)
as
ImageView
textView
.
setImageResource
(
category
.
resourceIcon
())
}
val
currentTab
=
if
(
EmojiRepository
.
getRecents
().
isEmpty
())
EmojiCategory
.
PEOPLE
.
ordinal
else
EmojiCategory
.
RECENTS
.
ordinal
viewPager
.
setCurrentItem
(
currentTab
)
backspaceView
.
setOnClickListener
{
listener
?.
onKeyPressed
(
KeyEvent
.
KEYCODE_BACK
)
}
}
private
fun
setupViewPager
()
{
activity
?.
let
{
val
callback
=
when
(
it
)
{
is
EmojiKeyboardListener
->
it
as
EmojiKeyboardListener
else
->
{
val
fragments
=
it
.
supportFragmentManager
.
fragments
if
(
fragments
==
null
||
fragments
.
size
==
0
||
!(
fragments
[
0
]
is
EmojiKeyboardListener
))
{
throw
IllegalStateException
(
"activity/fragment should implement EmojiKeyboardListener interface"
)
}
fragments
[
0
]
as
EmojiKeyboardListener
}
}
viewPager
.
adapter
=
CategoryPagerAdapter
(
object
:
EmojiKeyboardListener
{
override
fun
onKeyPressed
(
keyCode
:
Int
)
{
// do nothing
}
override
fun
onEmojiAdded
(
emoji
:
Emoji
)
{
EmojiRepository
.
addToRecents
(
emoji
)
callback
.
onEmojiAdded
(
emoji
)
}
})
for
(
category
in
EmojiCategory
.
values
())
{
val
tab
=
tabLayout
.
getTabAt
(
category
.
ordinal
)
val
tabView
=
layoutInflater
.
inflate
(
R
.
layout
.
emoji_picker_tab
,
null
)
tab
?.
setCustomView
(
tabView
)
val
textView
=
tabView
.
findViewById
(
R
.
id
.
image_category
)
as
ImageView
textView
.
setImageResource
(
category
.
resourceIcon
())
}
val
currentTab
=
if
(
EmojiRepository
.
getRecents
().
isEmpty
())
EmojiCategory
.
PEOPLE
.
ordinal
else
EmojiCategory
.
RECENTS
.
ordinal
viewPager
.
setCurrentItem
(
currentTab
)
}
}
private
fun
setKeyboardHeight
(
height
:
Int
)
{
...
...
@@ -229,10 +253,19 @@ class EmojiFragment : Fragment() {
interface
EmojiKeyboardListener
{
/**
*
Callback after
an emoji is selected on the picker.
*
When
an emoji is selected on the picker.
*
* @param emoji The selected emoji
*/
fun
onEmojiAdded
(
emoji
:
Emoji
)
/**
* When backspace key is clicked.
*
* @param keyCode The key code pressed as defined
*
* @see android.view.KeyEvent
*/
fun
onKeyPressed
(
keyCode
:
Int
)
}
}
\ No newline at end of file
app/src/main/res/drawable/ic_backspace_
black
_24dp.xml
→
app/src/main/res/drawable/ic_backspace_
gray
_24dp.xml
View file @
c113af7b
...
...
@@ -7,7 +7,7 @@
<path
android:pathData=
"M0,0 L24,0 L24,24 L0,24 Z"
/>
<path
android:fillColor=
"
#000000
"
android:fillColor=
"
@color/colorEmojiIcon
"
android:pathData=
"M22,3 L7,3 C6.31,3,5.77,3.35,5.41,3.88 L0,12 L5.41,20.11
C5.77,20.64,6.31,21,7,21 L22,21 C23.1,21,24,20.1,24,19 L24,5 C24,3.9,23.1,3,22,3
Z M19,15.59 L17.59,17 L14,13.41 L10.41,17 L9,15.59 L12.59,12 L9,8.41 L10.41,7
...
...
app/src/main/res/drawable/ic_search_gray_24px.xml
0 → 100644
View file @
c113af7b
<vector
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:width=
"24dp"
android:height=
"24dp"
android:autoMirrored=
"true"
android:viewportHeight=
"24.0"
android:viewportWidth=
"24.0"
>
<path
android:fillColor=
"@color/colorEmojiIcon"
android:pathData=
"M15.5,14h-0.79l-0.28,-0.27C15.41,12.59 16,11.11 16,9.5 16,5.91 13.09,3 9.5,3S3,5.91 3,9.5 5.91,16 9.5,16c1.61,0 3.09,-0.59 4.23,-1.57l0.27,0.28v0.79l5,4.99L20.49,19l-4.99,-5zM9.5,14C7.01,14 5,11.99 5,9.5S7.01,5 9.5,5 14,7.01 14,9.5 11.99,14 9.5,14z"
/>
</vector>
app/src/main/res/drawable/ic_search_white_24px.xml
View file @
c113af7b
<vector
android:autoMirrored=
"true"
android:height=
"24dp"
android:viewportHeight=
"24.0"
android:viewportWidth=
"24.0"
android:width=
"24dp"
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<path
android:fillColor=
"#FFFFFF"
android:pathData=
"M15.5,14h-0.79l-0.28,-0.27C15.41,12.59 16,11.11 16,9.5 16,5.91 13.09,3 9.5,3S3,5.91 3,9.5 5.91,16 9.5,16c1.61,0 3.09,-0.59 4.23,-1.57l0.27,0.28v0.79l5,4.99L20.49,19l-4.99,-5zM9.5,14C7.01,14 5,11.99 5,9.5S7.01,5 9.5,5 14,7.01 14,9.5 11.99,14 9.5,14z"
/>
<vector
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:width=
"24dp"
android:height=
"24dp"
android:autoMirrored=
"true"
android:viewportHeight=
"24.0"
android:viewportWidth=
"24.0"
>
<path
android:fillColor=
"#FFFFFF"
android:pathData=
"M15.5,14h-0.79l-0.28,-0.27C15.41,12.59 16,11.11 16,9.5 16,5.91 13.09,3 9.5,3S3,5.91 3,9.5 5.91,16 9.5,16c1.61,0 3.09,-0.59 4.23,-1.57l0.27,0.28v0.79l5,4.99L20.49,19l-4.99,-5zM9.5,14C7.01,14 5,11.99 5,9.5S7.01,5 9.5,5 14,7.01 14,9.5 11.99,14 9.5,14z"
/>
</vector>
app/src/main/res/layout/emoji_category_layout.xml
View file @
c113af7b
...
...
@@ -5,8 +5,6 @@
android:layout_height=
"wrap_content"
>
<android.support.v7.widget.RecyclerView
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:id=
"@+id/emojiRecyclerView"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
...
...
app/src/main/res/layout/emoji_popup_layout.xml
View file @
c113af7b
...
...
@@ -37,9 +37,44 @@
android:layout_marginEnd=
"8dp"
android:layout_marginStart=
"8dp"
android:background=
"@color/white"
app:layout_constraintBottom_to
BottomOf=
"parent
"
app:layout_constraintBottom_to
TopOf=
"@+id/emoji_actions_container
"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/tabs"
/>
<RelativeLayout
android:id=
"@+id/emoji_actions_container"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:background=
"@color/whitesmoke"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
>
<ImageView
android:id=
"@+id/emoji_search"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignParentStart=
"true"
android:layout_centerVertical=
"true"
android:background=
"@color/whitesmoke"
android:clickable=
"true"
android:focusable=
"true"
android:padding=
"8dp"
android:src=
"@drawable/ic_search_gray_24px"
/>
<ImageView
android:id=
"@+id/emoji_backspace"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignParentEnd=
"true"
android:layout_centerVertical=
"true"
android:background=
"@color/whitesmoke"
android:clickable=
"true"
android:focusable=
"true"
android:padding=
"8dp"
android:src=
"@drawable/ic_backspace_gray_24dp"
/>
</RelativeLayout>
</android.support.constraint.ConstraintLayout>
\ No newline at end of file
app/src/main/res/values/colors.xml
View file @
c113af7b
...
...
@@ -31,5 +31,6 @@
<color
name=
"linkTextColor"
>
#FF074481
</color>
<color
name=
"linkBackgroundColor"
>
#30074481
</color>
<color
name=
"colorEmojiIcon"
>
#FF767676
</color>
</resources>
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