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
54afdeb2
Unverified
Commit
54afdeb2
authored
Jan 15, 2018
by
Lucio Maciel
Committed by
GitHub
Jan 15, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #702 from RocketChat/spotlight-on-toolbar
Spotlight on toolbar
parents
8fef2381
8745f233
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
66 additions
and
29 deletions
+66
-29
ChatRoomsFragment.kt
...ava/chat/rocket/android/chatrooms/ui/ChatRoomsFragment.kt
+40
-14
ic_search_white_24px.xml
app/src/main/res/drawable/ic_search_white_24px.xml
+5
-0
fragment_chat_rooms.xml
app/src/main/res/layout/fragment_chat_rooms.xml
+9
-15
chatrooms_menu.xml
app/src/main/res/menu/chatrooms_menu.xml
+10
-0
strings.xml
app/src/main/res/values-pt-rBR/strings.xml
+1
-0
strings.xml
app/src/main/res/values/strings.xml
+1
-0
No files found.
app/src/main/java/chat/rocket/android/chatrooms/ui/ChatRoomsFragment.kt
View file @
54afdeb2
...
...
@@ -2,12 +2,12 @@ package chat.rocket.android.chatrooms.ui
import
android.os.Bundle
import
android.support.v4.app.Fragment
import
android.support.v7.app.AppCompatActivity
import
android.support.v7.util.DiffUtil
import
android.support.v7.widget.DefaultItemAnimator
import
android.support.v7.widget.LinearLayoutManager
import
android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
import
android.support.v7.widget.SearchView
import
android.view.*
import
android.widget.Toast
import
chat.rocket.android.R
import
chat.rocket.android.chatrooms.presentation.ChatRoomsPresenter
...
...
@@ -16,6 +16,7 @@ import chat.rocket.android.util.setVisibility
import
chat.rocket.android.widget.DividerItemDecoration
import
chat.rocket.core.model.ChatRoom
import
dagger.android.support.AndroidSupportInjection
import
kotlinx.android.synthetic.main.app_bar.*
import
kotlinx.android.synthetic.main.fragment_chat_rooms.*
import
kotlinx.coroutines.experimental.CommonPool
import
kotlinx.coroutines.experimental.android.UI
...
...
@@ -24,7 +25,9 @@ import kotlinx.coroutines.experimental.launch
import
javax.inject.Inject
class
ChatRoomsFragment
:
Fragment
(),
ChatRoomsView
{
@Inject
lateinit
var
presenter
:
ChatRoomsPresenter
private
var
searchView
:
SearchView
?
=
null
companion
object
{
fun
newInstance
()
=
ChatRoomsFragment
()
...
...
@@ -33,6 +36,7 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView {
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
AndroidSupportInjection
.
inject
(
this
)
setHasOptionsMenu
(
true
)
}
override
fun
onCreateView
(
inflater
:
LayoutInflater
,
container
:
ViewGroup
?,
savedInstanceState
:
Bundle
?):
View
?
=
inflater
.
inflate
(
R
.
layout
.
fragment_chat_rooms
,
container
,
false
)
...
...
@@ -40,27 +44,45 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView {
override
fun
onViewCreated
(
view
:
View
,
savedInstanceState
:
Bundle
?)
{
super
.
onViewCreated
(
view
,
savedInstanceState
)
floating_search_view
.
setOnQueryChangeListener
{
oldQuery
,
newQuery
->
floating_search_view
.
showProgress
()
presenter
.
chatRoomsByName
(
newQuery
)
if
(
oldQuery
.
isNotEmpty
()
&&
newQuery
.
isEmpty
())
{
floating_search_view
.
clearSuggestions
()
floating_search_view
.
hideProgress
()
}
}
activity
?.
apply
{
(
activity
as
AppCompatActivity
).
apply
{
recycler_view
.
layoutManager
=
LinearLayoutManager
(
this
,
LinearLayoutManager
.
VERTICAL
,
false
)
recycler_view
.
addItemDecoration
(
DividerItemDecoration
(
this
,
144
,
32
))
recycler_view
.
itemAnimator
=
DefaultItemAnimator
()
recycler_view
.
adapter
=
ChatRoomsAdapter
(
this
)
{
chatRoom
->
presenter
.
loadChatRoom
(
chatRoom
)
}
if
(
supportActionBar
==
null
)
{
setSupportActionBar
(
toolbar
)
supportActionBar
?.
setDisplayHomeAsUpEnabled
(
false
)
supportActionBar
?.
setDisplayShowHomeEnabled
(
true
)
//TODO: should display the current server "SiteName" setting?
supportActionBar
?.
setDisplayShowTitleEnabled
(
true
)
supportActionBar
?.
title
=
"Rocket.Chat"
}
}
presenter
.
loadChatRooms
()
}
override
fun
onCreateOptionsMenu
(
menu
:
Menu
?,
inflater
:
MenuInflater
?)
{
inflater
?.
inflate
(
R
.
menu
.
chatrooms_menu
,
menu
)
val
searchItem
=
menu
?.
findItem
(
R
.
id
.
action_search
)
searchView
=
searchItem
?.
actionView
as
SearchView
val
sv
=
searchView
sv
?.
setOnQueryTextListener
(
object
:
SearchView
.
OnQueryTextListener
{
override
fun
onQueryTextSubmit
(
query
:
String
?):
Boolean
{
return
queryChatRoomsByName
(
query
)
}
override
fun
onQueryTextChange
(
newText
:
String
?):
Boolean
{
return
queryChatRoomsByName
(
newText
)
}
})
}
override
suspend
fun
updateChatRooms
(
newDataSet
:
List
<
ChatRoom
>)
{
activity
.
apply
{
launch
(
UI
)
{
...
...
@@ -69,7 +91,6 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView {
DiffUtil
.
calculateDiff
(
RoomsDiffCallback
(
adapter
.
dataSet
,
newDataSet
))
}.
await
()
floating_search_view
.
hideProgress
()
adapter
.
updateRooms
(
newDataSet
)
diff
.
dispatchUpdatesTo
(
adapter
)
}
...
...
@@ -84,6 +105,11 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView {
override
fun
showGenericErrorMessage
()
=
showMessage
(
getString
(
R
.
string
.
msg_generic_error
))
private
fun
queryChatRoomsByName
(
name
:
String
?):
Boolean
{
presenter
.
chatRoomsByName
(
name
?:
""
)
return
true
}
class
RoomsDiffCallback
(
private
val
oldRooms
:
List
<
ChatRoom
>,
private
val
newRooms
:
List
<
ChatRoom
>)
:
DiffUtil
.
Callback
()
{
...
...
app/src/main/res/drawable/ic_search_white_24px.xml
0 → 100644
View file @
54afdeb2
<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>
app/src/main/res/layout/fragment_chat_rooms.xml
View file @
54afdeb2
<?xml version="1.0" encoding="utf-8"?>
<
Relative
Layout
xmlns:android=
"http://schemas.android.com/apk/res/android"
<
android.support.design.widget.Coordinator
Layout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:fitsSystemWindows=
"true"
tools:context=
".chatrooms.ui.ChatRoomsFragment"
>
<include
android:id=
"@+id/layout_app_bar"
layout=
"@layout/app_bar"
android:background=
"@color/black"
/>
<android.support.v7.widget.RecyclerView
android:id=
"@+id/recycler_view"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:clipToPadding=
"false"
android:gravity=
"center_horizontal"
android:paddingTop=
"84dp"
/>
<com.arlib.floatingsearchview.FloatingSearchView
android:id=
"@+id/floating_search_view"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
app:floatingSearch_close_search_on_keyboard_dismiss=
"true"
app:floatingSearch_dimBackground=
"false"
app:floatingSearch_dismissOnOutsideTouch=
"true"
app:floatingSearch_leftActionMode=
"showSearch"
app:floatingSearch_searchBarMarginLeft=
"4dp"
app:floatingSearch_searchBarMarginRight=
"4dp"
app:floatingSearch_searchBarMarginTop=
"28dp"
/>
app:layout_behavior=
"@string/appbar_scrolling_view_behavior"
/>
<com.wang.avi.AVLoadingIndicatorView
android:id=
"@+id/view_loading"
...
...
@@ -36,4 +30,4 @@
app:indicatorName=
"BallPulseIndicator"
tools:visibility=
"visible"
/>
</RelativeLayout>
\ No newline at end of file
</android.support.design.widget.CoordinatorLayout>
\ No newline at end of file
app/src/main/res/menu/chatrooms_menu.xml
0 → 100644
View file @
54afdeb2
<?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_24px"
android:title=
"@string/search"
app:actionViewClass=
"android.support.v7.widget.SearchView"
app:showAsAction=
"always|collapseActionView"
/>
</menu>
\ No newline at end of file
app/src/main/res/values-pt-rBR/strings.xml
View file @
54afdeb2
...
...
@@ -11,6 +11,7 @@
<string
name=
"action_send"
>
Enviar
</string>
<string
name=
"action_terms_of_service"
>
Termos de Serviço
</string>
<string
name=
"action_privacy_policy"
>
Política de Privacidade
</string>
<string
name=
"search"
>
Pesquisar
</string>
<!-- Regular information messages -->
<string
name=
"msg_no_internet_connection"
>
Sem conexão à internet
</string>
...
...
app/src/main/res/values/strings.xml
View file @
54afdeb2
...
...
@@ -12,6 +12,7 @@
<string
name=
"action_send"
>
Send
</string>
<string
name=
"action_terms_of_service"
>
Terms of Service
</string>
<string
name=
"action_privacy_policy"
>
Privacy Policy
</string>
<string
name=
"search"
>
Search
</string>
<!-- Regular information messages -->
<string
name=
"msg_no_internet_connection"
>
No internet connection
</string>
...
...
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