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
d1b4d63b
Commit
d1b4d63b
authored
Apr 18, 2019
by
Filipe de Lima Brito
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds the search view.
parent
0bb00cbc
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
86 additions
and
37 deletions
+86
-37
ChatRoomFragment.kt
.../java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
+11
-29
DirectoryPresenter.kt
...cket/android/directory/presentation/DirectoryPresenter.kt
+16
-6
DirectoryFragment.kt
...ava/chat/rocket/android/directory/ui/DirectoryFragment.kt
+46
-2
String.kt
...c/main/java/chat/rocket/android/util/extensions/String.kt
+2
-0
directory.xml
app/src/main/res/menu/directory.xml
+11
-0
No files found.
app/src/main/java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
View file @
d1b4d63b
...
@@ -141,14 +141,10 @@ private const val BUNDLE_CHAT_ROOM_MESSAGE = "chat_room_message"
...
@@ -141,14 +141,10 @@ private const val BUNDLE_CHAT_ROOM_MESSAGE = "chat_room_message"
class
ChatRoomFragment
:
Fragment
(),
ChatRoomView
,
EmojiKeyboardListener
,
EmojiReactionListener
,
class
ChatRoomFragment
:
Fragment
(),
ChatRoomView
,
EmojiKeyboardListener
,
EmojiReactionListener
,
ChatRoomAdapter
.
OnActionSelected
,
Drawable
.
Callback
{
ChatRoomAdapter
.
OnActionSelected
,
Drawable
.
Callback
{
@Inject
@Inject
lateinit
var
presenter
:
ChatRoomPresenter
lateinit
var
presenter
:
ChatRoomPresenter
@Inject
lateinit
var
parser
:
MessageParser
@Inject
@Inject
lateinit
var
analyticsManager
:
AnalyticsManager
lateinit
var
parser
:
MessageParser
@Inject
lateinit
var
navigator
:
ChatRoomNavigator
@Inject
lateinit
var
analyticsManager
:
AnalyticsManager
@Inject
lateinit
var
navigator
:
ChatRoomNavigator
private
lateinit
var
adapter
:
ChatRoomAdapter
private
lateinit
var
adapter
:
ChatRoomAdapter
internal
lateinit
var
chatRoomId
:
String
internal
lateinit
var
chatRoomId
:
String
private
lateinit
var
chatRoomName
:
String
private
lateinit
var
chatRoomName
:
String
...
@@ -597,45 +593,31 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
...
@@ -597,45 +593,31 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
}
}
override
fun
showMessage
(
message
:
String
)
{
override
fun
showMessage
(
message
:
String
)
{
ui
{
ui
{
showToast
(
message
)
}
showToast
(
message
)
}
}
}
override
fun
showMessage
(
resId
:
Int
)
{
override
fun
showMessage
(
resId
:
Int
)
{
ui
{
ui
{
showToast
(
resId
)
}
showToast
(
resId
)
}
}
}
override
fun
showGenericErrorMessage
()
{
override
fun
showGenericErrorMessage
()
{
ui
{
ui
{
showMessage
(
getString
(
R
.
string
.
msg_generic_error
))
}
showMessage
(
getString
(
R
.
string
.
msg_generic_error
))
}
}
}
override
fun
populatePeopleSuggestions
(
members
:
List
<
PeopleSuggestionUiModel
>)
{
override
fun
populatePeopleSuggestions
(
members
:
List
<
PeopleSuggestionUiModel
>)
{
ui
{
ui
{
suggestions_view
.
addItems
(
"@"
,
members
)
}
suggestions_view
.
addItems
(
"@"
,
members
)
}
}
}
override
fun
populateRoomSuggestions
(
chatRooms
:
List
<
ChatRoomSuggestionUiModel
>)
{
override
fun
populateRoomSuggestions
(
chatRooms
:
List
<
ChatRoomSuggestionUiModel
>)
{
ui
{
ui
{
suggestions_view
.
addItems
(
"#"
,
chatRooms
)
}
suggestions_view
.
addItems
(
"#"
,
chatRooms
)
}
}
}
override
fun
populateCommandSuggestions
(
commands
:
List
<
CommandSuggestionUiModel
>)
{
override
fun
populateCommandSuggestions
(
commands
:
List
<
CommandSuggestionUiModel
>)
{
ui
{
ui
{
suggestions_view
.
addItems
(
"/"
,
commands
)
}
suggestions_view
.
addItems
(
"/"
,
commands
)
}
}
}
override
fun
populateEmojiSuggestions
(
emojis
:
List
<
EmojiSuggestionUiModel
>)
{
override
fun
populateEmojiSuggestions
(
emojis
:
List
<
EmojiSuggestionUiModel
>)
{
ui
{
ui
{
suggestions_view
.
addItems
(
":"
,
emojis
)
}
suggestions_view
.
addItems
(
":"
,
emojis
)
}
}
}
override
fun
copyToClipboard
(
message
:
String
)
{
override
fun
copyToClipboard
(
message
:
String
)
{
...
...
app/src/main/java/chat/rocket/android/directory/presentation/DirectoryPresenter.kt
View file @
d1b4d63b
...
@@ -37,11 +37,12 @@ class DirectoryPresenter @Inject constructor(
...
@@ -37,11 +37,12 @@ class DirectoryPresenter @Inject constructor(
private
val
client
:
RocketChatClient
=
factory
.
get
(
currentServer
)
private
val
client
:
RocketChatClient
=
factory
.
get
(
currentServer
)
private
var
offset
:
Long
=
0
private
var
offset
:
Long
=
0
fun
loadAllDirectoryChannels
()
{
fun
loadAllDirectoryChannels
(
query
:
String
?
=
null
)
{
launchUI
(
strategy
)
{
launchUI
(
strategy
)
{
try
{
try
{
view
.
showLoading
()
view
.
showLoading
()
val
directoryResult
=
client
.
directory
(
val
directoryResult
=
client
.
directory
(
text
=
query
,
directoryRequestType
=
DirectoryRequestType
.
Channels
(),
directoryRequestType
=
DirectoryRequestType
.
Channels
(),
offset
=
offset
,
offset
=
offset
,
count
=
60
count
=
60
...
@@ -61,13 +62,18 @@ class DirectoryPresenter @Inject constructor(
...
@@ -61,13 +62,18 @@ class DirectoryPresenter @Inject constructor(
}
}
}
}
fun
loadAllDirectoryUsers
(
isSearchForGlobalUsers
:
Boolean
)
{
fun
loadAllDirectoryUsers
(
isSearchForGlobalUsers
:
Boolean
,
query
:
String
?
=
null
)
{
launchUI
(
strategy
)
{
launchUI
(
strategy
)
{
try
{
try
{
view
.
showLoading
()
view
.
showLoading
()
val
directoryResult
=
client
.
directory
(
val
directoryResult
=
client
.
directory
(
text
=
query
,
directoryRequestType
=
DirectoryRequestType
.
Users
(),
directoryRequestType
=
DirectoryRequestType
.
Users
(),
directoryWorkspaceType
=
if
(
isSearchForGlobalUsers
)
DirectoryWorkspaceType
.
All
()
else
DirectoryWorkspaceType
.
Local
(),
directoryWorkspaceType
=
if
(
isSearchForGlobalUsers
)
{
DirectoryWorkspaceType
.
All
()
}
else
{
DirectoryWorkspaceType
.
Local
()
},
offset
=
offset
,
offset
=
offset
,
count
=
60
count
=
60
)
)
...
@@ -86,12 +92,16 @@ class DirectoryPresenter @Inject constructor(
...
@@ -86,12 +92,16 @@ class DirectoryPresenter @Inject constructor(
}
}
}
}
fun
updateSorting
(
isSortByChannels
:
Boolean
,
isSearchForGlobalUsers
:
Boolean
)
{
fun
updateSorting
(
isSortByChannels
:
Boolean
,
isSearchForGlobalUsers
:
Boolean
,
query
:
String
?
=
null
)
{
resetOffset
()
resetOffset
()
if
(
isSortByChannels
)
{
if
(
isSortByChannels
)
{
loadAllDirectoryChannels
()
loadAllDirectoryChannels
(
query
)
}
else
{
}
else
{
loadAllDirectoryUsers
(
isSearchForGlobalUsers
)
loadAllDirectoryUsers
(
isSearchForGlobalUsers
,
query
)
}
}
}
}
...
...
app/src/main/java/chat/rocket/android/directory/ui/DirectoryFragment.kt
View file @
d1b4d63b
...
@@ -2,9 +2,13 @@ package chat.rocket.android.directory.ui
...
@@ -2,9 +2,13 @@ package chat.rocket.android.directory.ui
import
android.os.Bundle
import
android.os.Bundle
import
android.view.LayoutInflater
import
android.view.LayoutInflater
import
android.view.Menu
import
android.view.MenuInflater
import
android.view.MenuItem
import
android.view.View
import
android.view.View
import
android.view.ViewGroup
import
android.view.ViewGroup
import
androidx.appcompat.app.AppCompatActivity
import
androidx.appcompat.app.AppCompatActivity
import
androidx.appcompat.widget.SearchView
import
androidx.core.view.isVisible
import
androidx.core.view.isVisible
import
androidx.fragment.app.Fragment
import
androidx.fragment.app.Fragment
import
androidx.recyclerview.widget.DividerItemDecoration
import
androidx.recyclerview.widget.DividerItemDecoration
...
@@ -19,7 +23,9 @@ import chat.rocket.android.directory.presentation.DirectoryPresenter
...
@@ -19,7 +23,9 @@ import chat.rocket.android.directory.presentation.DirectoryPresenter
import
chat.rocket.android.directory.presentation.DirectoryView
import
chat.rocket.android.directory.presentation.DirectoryView
import
chat.rocket.android.directory.uimodel.DirectoryUiModel
import
chat.rocket.android.directory.uimodel.DirectoryUiModel
import
chat.rocket.android.helper.EndlessRecyclerViewScrollListener
import
chat.rocket.android.helper.EndlessRecyclerViewScrollListener
import
chat.rocket.android.util.extension.onQueryTextListener
import
chat.rocket.android.util.extensions.inflate
import
chat.rocket.android.util.extensions.inflate
import
chat.rocket.android.util.extensions.isNotNullNorBlank
import
chat.rocket.android.util.extensions.showToast
import
chat.rocket.android.util.extensions.showToast
import
chat.rocket.android.util.extensions.ui
import
chat.rocket.android.util.extensions.ui
import
dagger.android.support.AndroidSupportInjection
import
dagger.android.support.AndroidSupportInjection
...
@@ -62,6 +68,7 @@ class DirectoryFragment : Fragment(), DirectoryView {
...
@@ -62,6 +68,7 @@ class DirectoryFragment : Fragment(), DirectoryView {
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
super
.
onCreate
(
savedInstanceState
)
AndroidSupportInjection
.
inject
(
this
)
AndroidSupportInjection
.
inject
(
this
)
setHasOptionsMenu
(
true
)
}
}
override
fun
onCreateView
(
override
fun
onCreateView
(
...
@@ -79,6 +86,33 @@ class DirectoryFragment : Fragment(), DirectoryView {
...
@@ -79,6 +86,33 @@ class DirectoryFragment : Fragment(), DirectoryView {
analyticsManager
.
logScreenView
(
ScreenViewEvent
.
Directory
)
analyticsManager
.
logScreenView
(
ScreenViewEvent
.
Directory
)
}
}
override
fun
onCreateOptionsMenu
(
menu
:
Menu
,
inflater
:
MenuInflater
)
{
super
.
onCreateOptionsMenu
(
menu
,
inflater
)
inflater
.
inflate
(
R
.
menu
.
directory
,
menu
)
val
searchMenuItem
=
menu
.
findItem
(
R
.
id
.
action_search
)
val
searchView
=
searchMenuItem
?.
actionView
as
SearchView
with
(
searchView
)
{
setIconifiedByDefault
(
false
)
maxWidth
=
Integer
.
MAX_VALUE
onQueryTextListener
{
updateSorting
(
isSortByChannels
,
isSearchForGlobalUsers
,
it
)
}
}
searchMenuItem
.
setOnActionExpandListener
(
object
:
MenuItem
.
OnActionExpandListener
{
override
fun
onMenuItemActionCollapse
(
item
:
MenuItem
):
Boolean
{
updateSorting
(
isSortByChannels
,
isSearchForGlobalUsers
,
reload
=
true
)
return
true
}
override
fun
onMenuItemActionExpand
(
item
:
MenuItem
):
Boolean
{
return
true
}
})
}
override
fun
showChannels
(
dataSet
:
List
<
DirectoryUiModel
>)
{
override
fun
showChannels
(
dataSet
:
List
<
DirectoryUiModel
>)
{
ui
{
ui
{
if
(
directoryAdapter
.
itemCount
==
0
)
{
if
(
directoryAdapter
.
itemCount
==
0
)
{
...
@@ -141,7 +175,17 @@ class DirectoryFragment : Fragment(), DirectoryView {
...
@@ -141,7 +175,17 @@ class DirectoryFragment : Fragment(), DirectoryView {
view_loading
.
isVisible
=
false
view_loading
.
isVisible
=
false
}
}
fun
updateSorting
(
isSortByChannels
:
Boolean
,
isSearchForGlobalUsers
:
Boolean
)
{
fun
updateSorting
(
isSortByChannels
:
Boolean
,
isSearchForGlobalUsers
:
Boolean
,
query
:
String
?
=
null
,
reload
:
Boolean
=
false
)
{
if
(
query
.
isNotNullNorBlank
()
||
reload
)
{
directoryAdapter
.
clearData
()
presenter
.
updateSorting
(
isSortByChannels
,
isSearchForGlobalUsers
,
query
)
}
if
(
this
.
isSortByChannels
!=
isSortByChannels
||
if
(
this
.
isSortByChannels
!=
isSortByChannels
||
this
.
isSearchForGlobalUsers
!=
isSearchForGlobalUsers
this
.
isSearchForGlobalUsers
!=
isSearchForGlobalUsers
)
{
)
{
...
@@ -152,7 +196,7 @@ class DirectoryFragment : Fragment(), DirectoryView {
...
@@ -152,7 +196,7 @@ class DirectoryFragment : Fragment(), DirectoryView {
clearData
()
clearData
()
setSorting
(
isSortByChannels
,
isSearchForGlobalUsers
)
setSorting
(
isSortByChannels
,
isSearchForGlobalUsers
)
}
}
presenter
.
updateSorting
(
isSortByChannels
,
isSearchForGlobalUsers
)
presenter
.
updateSorting
(
isSortByChannels
,
isSearchForGlobalUsers
,
query
)
}
}
}
}
...
...
app/src/main/java/chat/rocket/android/util/extensions/String.kt
View file @
d1b4d63b
...
@@ -75,6 +75,8 @@ fun String.lowercaseUrl(): String? = HttpUrl.parse(this)?.run {
...
@@ -75,6 +75,8 @@ fun String.lowercaseUrl(): String? = HttpUrl.parse(this)?.run {
fun
String
?.
isNotNullNorEmpty
():
Boolean
=
this
!=
null
&&
this
.
isNotEmpty
()
fun
String
?.
isNotNullNorEmpty
():
Boolean
=
this
!=
null
&&
this
.
isNotEmpty
()
fun
String
?.
isNotNullNorBlank
():
Boolean
=
this
!=
null
&&
this
.
isNotBlank
()
inline
fun
String
?.
ifNotNullNotEmpty
(
block
:
(
String
)
->
Unit
)
{
inline
fun
String
?.
ifNotNullNotEmpty
(
block
:
(
String
)
->
Unit
)
{
if
(
this
!=
null
&&
this
.
isNotEmpty
())
{
if
(
this
!=
null
&&
this
.
isNotEmpty
())
{
block
(
this
)
block
(
this
)
...
...
app/src/main/res/menu/directory.xml
0 → 100644
View file @
d1b4d63b
<?xml version="1.0" encoding="utf-8"?>
<menu
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
>
<item
android:id=
"@+id/action_search"
android:icon=
"@drawable/ic_search_white_24dp"
android:title=
"@string/action_search"
app:actionViewClass=
"androidx.appcompat.widget.SearchView"
app:showAsAction=
"ifRoom|collapseActionView"
/>
</menu>
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