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
878305ea
Commit
878305ea
authored
Mar 09, 2019
by
Asel Peiris
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reformatting code
parent
06d2188e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
51 deletions
+43
-51
Menu.kt
app/src/main/java/chat/rocket/android/chatroom/ui/Menu.kt
+43
-51
No files found.
app/src/main/java/chat/rocket/android/chatroom/ui/Menu.kt
View file @
878305ea
...
...
@@ -4,12 +4,10 @@ import android.content.Context
import
android.view.Menu
import
android.view.MenuItem
import
android.widget.EditText
import
android.widget.Toast
import
androidx.appcompat.widget.SearchView
import
androidx.core.content.res.ResourcesCompat
import
chat.rocket.android.R
import
chat.rocket.android.util.extension.onQueryTextListener
import
chat.rocket.android.util.extensions.showToast
internal
fun
ChatRoomFragment
.
setupMenu
(
menu
:
Menu
)
{
setupSearchMessageMenuItem
(
menu
,
requireContext
())
...
...
@@ -20,46 +18,44 @@ internal fun ChatRoomFragment.setupMenu(menu: Menu) {
internal
fun
ChatRoomFragment
.
setOnMenuItemClickListener
(
item
:
MenuItem
)
{
when
(
item
.
itemId
)
{
MENU_ACTION_FAVORITE_UNFAVOURITE_CHAT
->
presenter
.
toggleFavoriteChatRoom
(
chatRoomId
,
isFavorite
chatRoomId
,
isFavorite
)
MENU_ACTION_SHOW_DETAILS
->
presenter
.
toChatDetails
(
chatRoomId
,
chatRoomType
,
isSubscribed
,
disableMenu
chatRoomId
,
chatRoomType
,
isSubscribed
,
disableMenu
)
}
}
private
fun
ChatRoomFragment
.
setupSearchMessageMenuItem
(
menu
:
Menu
,
context
:
Context
)
{
val
searchItem
=
menu
.
add
(
Menu
.
NONE
,
Menu
.
NONE
,
Menu
.
NONE
,
R
.
string
.
title_search_message
Menu
.
NONE
,
Menu
.
NONE
,
Menu
.
NONE
,
R
.
string
.
title_search_message
).
setActionView
(
SearchView
(
context
))
.
setIcon
(
R
.
drawable
.
ic_search_white_24dp
)
.
setShowAsActionFlags
(
MenuItem
.
SHOW_AS_ACTION_IF_ROOM
or
MenuItem
.
SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW
)
.
setOnActionExpandListener
(
object
:
MenuItem
.
OnActionExpandListener
{
override
fun
onMenuItemActionExpand
(
item
:
MenuItem
?):
Boolean
{
dismissEmojiKeyboard
()
removeFavoriteMenuItem
(
menu
)
removeDetailMenuItem
(
menu
)
return
true
}
override
fun
onMenuItemActionCollapse
(
item
:
MenuItem
?):
Boolean
{
dismissEmojiKeyboard
()
setupFavoriteMenuItem
(
menu
)
setupDetailsMenuItem
(
menu
)
return
true
}
})
.
setIcon
(
R
.
drawable
.
ic_search_white_24dp
)
.
setShowAsActionFlags
(
MenuItem
.
SHOW_AS_ACTION_IF_ROOM
or
MenuItem
.
SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW
)
.
setOnActionExpandListener
(
object
:
MenuItem
.
OnActionExpandListener
{
override
fun
onMenuItemActionExpand
(
item
:
MenuItem
?):
Boolean
{
dismissEmojiKeyboard
()
removeFavoriteMenuItem
(
menu
)
removeDetailMenuItem
(
menu
)
return
true
}
override
fun
onMenuItemActionCollapse
(
item
:
MenuItem
?):
Boolean
{
dismissEmojiKeyboard
()
setupFavoriteMenuItem
(
menu
)
setupDetailsMenuItem
(
menu
)
return
true
}
})
(
searchItem
?.
actionView
as
?
SearchView
)
?.
let
{
// TODO: Check why we need to stylize the search text programmatically instead of by defining it in the styles.xml (ChatRoom.SearchView)
...
...
@@ -75,7 +71,7 @@ private fun stylizeSearchView(searchView: SearchView, context: Context) {
val
searchText
=
searchView
.
findViewById
<
EditText
>(
androidx
.
appcompat
.
R
.
id
.
search_src_text
)
searchText
.
setTextColor
(
ResourcesCompat
.
getColor
(
context
.
resources
,
R
.
color
.
color_white
,
null
))
searchText
.
setHintTextColor
(
ResourcesCompat
.
getColor
(
context
.
resources
,
R
.
color
.
color_white
,
null
)
ResourcesCompat
.
getColor
(
context
.
resources
,
R
.
color
.
color_white
,
null
)
)
}
...
...
@@ -94,20 +90,20 @@ private fun ChatRoomFragment.setupSearchViewTextListener(searchView: SearchView)
private
fun
ChatRoomFragment
.
setupFavoriteMenuItem
(
menu
:
Menu
)
{
if
(
isFavorite
)
{
menu
.
add
(
Menu
.
NONE
,
MENU_ACTION_FAVORITE_UNFAVOURITE_CHAT
,
Menu
.
NONE
,
R
.
string
.
title_unfavorite_chat
Menu
.
NONE
,
MENU_ACTION_FAVORITE_UNFAVOURITE_CHAT
,
Menu
.
NONE
,
R
.
string
.
title_unfavorite_chat
).
setIcon
(
R
.
drawable
.
ic_star_yellow_24dp
)
.
setShowAsAction
(
MenuItem
.
SHOW_AS_ACTION_IF_ROOM
)
.
setShowAsAction
(
MenuItem
.
SHOW_AS_ACTION_IF_ROOM
)
}
else
{
menu
.
add
(
Menu
.
NONE
,
MENU_ACTION_FAVORITE_UNFAVOURITE_CHAT
,
Menu
.
NONE
,
R
.
string
.
title_favorite_chat
Menu
.
NONE
,
MENU_ACTION_FAVORITE_UNFAVOURITE_CHAT
,
Menu
.
NONE
,
R
.
string
.
title_favorite_chat
).
setIcon
(
R
.
drawable
.
ic_star_border_white_24dp
)
.
setShowAsAction
(
MenuItem
.
SHOW_AS_ACTION_IF_ROOM
)
.
setShowAsAction
(
MenuItem
.
SHOW_AS_ACTION_IF_ROOM
)
}
}
...
...
@@ -121,14 +117,10 @@ private fun ChatRoomFragment.setupDetailsMenuItem(menu: Menu) {
.
setShowAsAction
(
MenuItem
.
SHOW_AS_ACTION_IF_ROOM
)
}
private
fun
removeFavoriteMenuItem
(
menu
:
Menu
){
private
fun
removeFavoriteMenuItem
(
menu
:
Menu
)
{
menu
.
removeItem
(
MENU_ACTION_FAVORITE_UNFAVOURITE_CHAT
)
}
private
fun
removeDetailMenuItem
(
menu
:
Menu
){
private
fun
removeDetailMenuItem
(
menu
:
Menu
)
{
menu
.
removeItem
(
MENU_ACTION_SHOW_DETAILS
)
}
}
\ 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