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
edddc76b
Commit
edddc76b
authored
May 30, 2018
by
aniket
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
makes requested changes
parent
c7dfe315
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
90 additions
and
64 deletions
+90
-64
AddMembersPresenter.kt
...ateChannel/addMembers/presentation/AddMembersPresenter.kt
+16
-20
AddMembersActivity.kt
...android/createChannel/addMembers/ui/AddMembersActivity.kt
+29
-14
CreateNewChannelPresenter.kt
...d/createChannel/presentation/CreateNewChannelPresenter.kt
+3
-6
CreateNewChannelView.kt
...ndroid/createChannel/presentation/CreateNewChannelView.kt
+13
-2
CreateNewChannelActivity.kt
...cket/android/createChannel/ui/CreateNewChannelActivity.kt
+29
-22
No files found.
app/src/main/java/chat/rocket/android/createChannel/addMembers/presentation/AddMembersPresenter.kt
View file @
edddc76b
package
chat.rocket.android.createChannel.addMembers.presentation
import
chat.rocket.android.core.behaviours.showMessage
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.members.viewmodel.MemberViewModelMapper
import
chat.rocket.android.server.domain.GetCurrentServerInteractor
...
...
@@ -19,11 +18,9 @@ class AddMembersPresenter @Inject constructor(
private
val
mapper
:
MemberViewModelMapper
,
factory
:
RocketChatClientFactory
)
{
val
serverUrl
:
String
?
=
serverInteractor
.
get
()
private
val
client
=
if
(
serverUrl
!=
null
)
factory
.
create
(
serverUrl
)
else
null
private
val
client
=
factory
.
create
(
serverInteractor
.
get
()
!!
)
fun
queryUsersFromRegex
(
queryParam
:
String
,
offset
:
Long
=
0
)
{
if
(
client
!=
null
)
{
view
.
showLoading
()
launchUI
(
strategy
)
{
try
{
...
...
@@ -43,5 +40,4 @@ class AddMembersPresenter @Inject constructor(
}
}
}
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/createChannel/addMembers/ui/AddMembersActivity.kt
View file @
edddc76b
...
...
@@ -24,6 +24,7 @@ import com.jakewharton.rxbinding2.widget.RxTextView
import
dagger.android.AndroidInjection
import
io.reactivex.Observable
import
io.reactivex.android.schedulers.AndroidSchedulers
import
io.reactivex.disposables.Disposable
import
io.reactivex.subjects.BehaviorSubject
import
kotlinx.android.synthetic.main.activity_add_members.*
import
kotlinx.android.synthetic.main.layout_toolbar.*
...
...
@@ -46,7 +47,9 @@ class AddMembersActivity : AppCompatActivity(), AddMembersView {
.
show
()
}
}
private
var
linearLayoutManager
=
LinearLayoutManager
(
this
,
LinearLayoutManager
.
VERTICAL
,
false
)
private
lateinit
var
observableForSearchView
:
Disposable
private
lateinit
var
observableForToolbarAction
:
Disposable
private
val
linearLayoutManager
=
LinearLayoutManager
(
this
,
LinearLayoutManager
.
VERTICAL
,
false
)
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
AndroidInjection
.
inject
(
this
)
...
...
@@ -56,17 +59,14 @@ class AddMembersActivity : AppCompatActivity(), AddMembersView {
setUpRecyclerView
()
setOnClickListeners
()
setInitialChips
()
observableFromSearchView
(
search_view
)
.
debounce
(
300
,
TimeUnit
.
MILLISECONDS
)
.
filter
{
item
->
item
.
isNotEmpty
()
}
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
{
query
->
queryParam
=
query
run
{
adapter
.
reAllocateArrayList
()
presenter
.
queryUsersFromRegex
(
query
)
}
setUpObservableForSearchView
()
}
override
fun
onDestroy
()
{
super
.
onDestroy
()
//dispose off the rx disposables
observableForToolbarAction
.
dispose
()
observableForSearchView
.
dispose
()
}
override
fun
onOptionsItemSelected
(
item
:
MenuItem
?):
Boolean
{
...
...
@@ -129,6 +129,20 @@ class AddMembersActivity : AppCompatActivity(), AddMembersView {
updateToolBar
()
}
private
fun
setUpObservableForSearchView
()
{
observableForSearchView
=
observableFromSearchView
(
search_view
)
.
debounce
(
300
,
TimeUnit
.
MILLISECONDS
)
.
filter
{
item
->
item
.
isNotEmpty
()
}
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
{
query
->
queryParam
=
query
run
{
adapter
.
reAllocateArrayList
()
presenter
.
queryUsersFromRegex
(
query
)
}
}
}
private
fun
addNewChip
(
memberViewModel
:
MemberViewModel
)
{
memberViewModel
.
username
?.
let
{
buildNewChip
(
it
)
...
...
@@ -156,7 +170,8 @@ class AddMembersActivity : AppCompatActivity(), AddMembersView {
}
else
{
toolbar_action_text
.
alpha
=
1.0f
}
toolbar_title
.
textContent
=
getString
(
R
.
string
.
title_add_members
,
membersToAdd
.
size
.
toString
())
toolbar_title
.
textContent
=
getString
(
R
.
string
.
title_add_members
,
membersToAdd
.
size
.
toString
())
}
private
fun
setUpToolBar
()
{
...
...
@@ -186,7 +201,7 @@ class AddMembersActivity : AppCompatActivity(), AddMembersView {
private
fun
observableFromSearchView
(
searchView
:
EditText
):
Observable
<
String
>
{
val
observableSubject
:
BehaviorSubject
<
String
>
=
BehaviorSubject
.
create
()
RxTextView
.
textChanges
(
searchView
).
subscribe
{
text
->
observableForToolbarAction
=
RxTextView
.
textChanges
(
searchView
).
subscribe
{
text
->
if
(
text
.
isNotBlank
())
{
observableSubject
.
onNext
(
text
.
toString
())
}
...
...
app/src/main/java/chat/rocket/android/createChannel/presentation/CreateNewChannelPresenter.kt
View file @
edddc76b
package
chat.rocket.android.createChannel.presentation
import
android.widget.Toast
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.server.domain.GetCurrentServerInteractor
import
chat.rocket.android.server.infraestructure.RocketChatClientFactory
...
...
@@ -10,7 +9,6 @@ import chat.rocket.common.model.RoomType
import
chat.rocket.common.util.ifNull
import
chat.rocket.core.RocketChatClient
import
chat.rocket.core.internal.rest.createChannel
import
chat.rocket.core.model.Room
import
javax.inject.Inject
...
...
@@ -31,14 +29,13 @@ class CreateNewChannelPresenter @Inject constructor(
launchUI
(
strategy
)
{
view
.
showLoading
()
try
{
val
channelCreated
:
Room
?
=
client
.
createChannel
(
roomType
,
channelName
,
usersList
,
readOnly
)
view
.
showChannelCreatedSuccessfullyMessage
()
}
catch
(
exception
:
RocketChatException
)
{
exception
.
message
?.
let
{
view
.
showMessage
(
it
)
view
.
showMessage
AndClearText
(
it
)
}.
ifNull
{
view
.
show
Generic
ErrorMessage
()
view
.
showErrorMessage
()
}
}
finally
{
view
.
hideLoading
()
...
...
app/src/main/java/chat/rocket/android/createChannel/presentation/CreateNewChannelView.kt
View file @
edddc76b
package
chat.rocket.android.createChannel.presentation
import
chat.rocket.android.core.behaviours.LoadingView
import
chat.rocket.android.core.behaviours.MessageView
interface
CreateNewChannelView
:
LoadingView
,
MessageView
{
interface
CreateNewChannelView
:
LoadingView
{
/*
Show a message that a channel was successfully created
*/
fun
showChannelCreatedSuccessfullyMessage
()
/*
Show message and clear text in edit text
*/
fun
showMessageAndClearText
(
resId
:
Int
)
fun
showMessageAndClearText
(
message
:
String
)
/*
Show error message
*/
fun
showErrorMessage
()
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/createChannel/ui/CreateNewChannelActivity.kt
View file @
edddc76b
...
...
@@ -13,9 +13,10 @@ import chat.rocket.android.createChannel.presentation.CreateNewChannelPresenter
import
chat.rocket.android.createChannel.presentation.CreateNewChannelView
import
chat.rocket.android.util.extensions.setVisible
import
chat.rocket.android.util.extensions.showToast
import
chat.rocket.common.model.
roomTypeOf
import
chat.rocket.common.model.
RoomType
import
com.jakewharton.rxbinding2.widget.RxTextView
import
dagger.android.AndroidInjection
import
io.reactivex.disposables.Disposable
import
kotlinx.android.synthetic.main.activity_create_new_channel.*
import
kotlinx.android.synthetic.main.layout_toolbar.*
import
javax.inject.Inject
...
...
@@ -25,8 +26,9 @@ internal const val ADD_MEMBERS_ACTIVITY_REQUEST_CODE = 1
class
CreateNewChannelActivity
:
AppCompatActivity
(),
CreateNewChannelView
{
@Inject
lateinit
var
presenter
:
CreateNewChannelPresenter
private
var
channelType
:
String
=
"public"
private
var
channelType
:
RoomType
=
RoomType
.
CHANNEL
private
var
listOfUsers
:
ArrayList
<
String
>
=
ArrayList
()
private
lateinit
var
observableForToolbarAction
:
Disposable
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
AndroidInjection
.
inject
(
this
)
...
...
@@ -36,6 +38,11 @@ class CreateNewChannelActivity : AppCompatActivity(), CreateNewChannelView {
setUpOnClickListeners
()
}
override
fun
onDestroy
()
{
super
.
onDestroy
()
observableForToolbarAction
.
dispose
()
}
override
fun
onOptionsItemSelected
(
item
:
MenuItem
?):
Boolean
{
when
(
item
?.
itemId
)
{
android
.
R
.
id
.
home
->
{
...
...
@@ -75,19 +82,18 @@ class CreateNewChannelActivity : AppCompatActivity(), CreateNewChannelView {
finish
()
}
override
fun
showMessage
(
resId
:
Int
)
{
override
fun
showMessage
AndClearText
(
resId
:
Int
)
{
channel_name_edit_text
.
setText
(
""
)
showToast
(
getString
(
resId
))
}
override
fun
showMessage
(
message
:
String
)
{
override
fun
showMessage
AndClearText
(
message
:
String
)
{
channel_name_edit_text
.
setText
(
""
)
showToast
(
message
)
}
override
fun
showGenericErrorMessage
()
{
channel_name_edit_text
.
setText
(
""
)
showMessage
(
getString
(
R
.
string
.
msg_generic_error
))
override
fun
showErrorMessage
()
{
showMessageAndClearText
(
getString
(
R
.
string
.
msg_generic_error
))
}
...
...
@@ -108,6 +114,7 @@ class CreateNewChannelActivity : AppCompatActivity(), CreateNewChannelView {
toolbar_action_text
.
text
=
getString
(
R
.
string
.
action_create_new_channel
)
supportActionBar
?.
setDisplayHomeAsUpEnabled
(
true
)
observableForToolbarAction
=
RxTextView
.
textChanges
(
channel_name_edit_text
).
subscribe
{
text
->
toolbar_action_text
.
isEnabled
=
(
text
.
isNotEmpty
()
&&
listOfUsers
.
isNotEmpty
())
if
(
text
.
isEmpty
())
{
...
...
@@ -120,7 +127,7 @@ class CreateNewChannelActivity : AppCompatActivity(), CreateNewChannelView {
private
fun
setUpOnClickListeners
()
{
public_channel
.
setOnClickListener
{
channelType
=
"c"
channelType
=
RoomType
.
CHANNEL
channel_type
.
text
=
getString
(
R
.
string
.
public_channel_type
)
channel_description
.
text
=
getString
(
R
.
string
.
public_channel_description
)
...
...
@@ -142,7 +149,7 @@ class CreateNewChannelActivity : AppCompatActivity(), CreateNewChannelView {
}
private_channel
.
setOnClickListener
{
channelType
=
"p"
channelType
=
RoomType
.
PRIVATE_GROUP
channel_type
.
text
=
getString
(
R
.
string
.
private_channel_type
)
channel_description
.
text
=
getString
(
R
.
string
.
private_channel_type_description
)
...
...
@@ -150,11 +157,11 @@ class CreateNewChannelActivity : AppCompatActivity(), CreateNewChannelView {
placeholder
.
setImageDrawable
(
getDrawable
(
R
.
drawable
.
ic_lock_black_12_dp
))
(
getDrawable
(
R
.
drawable
.
button_border
)
as
GradientDrawable
).
setColor
(
resources
.
getColor
(
R
.
color
.
colorRed
resources
.
getColor
(
R
.
color
.
colorRed
)
)
(
getDrawable
(
R
.
drawable
.
button_solid
)
as
GradientDrawable
).
setColor
(
resources
.
getColor
(
R
.
color
.
default_background
)
)
(
getDrawable
(
R
.
drawable
.
button_solid
)
as
GradientDrawable
).
setColor
(
resources
.
getColor
(
R
.
color
.
default_background
))
(
getDrawable
(
R
.
drawable
.
button_solid
)
as
GradientDrawable
).
setStroke
(
1
,
resources
.
getColor
(
R
.
color
.
colorRed
)
...
...
@@ -170,7 +177,7 @@ class CreateNewChannelActivity : AppCompatActivity(), CreateNewChannelView {
toolbar_action_text
.
setOnClickListener
{
if
(
toolbar_action_text
.
isEnabled
)
{
presenter
.
createNewChannel
(
roomTypeOf
(
channelType
)
,
channelType
,
channel_name_edit_text
.
text
.
toString
(),
listOfUsers
,
false
...
...
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