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
15b6c490
Commit
15b6c490
authored
Apr 03, 2018
by
Aniket Singh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adds code to create channel
parent
1c9017ae
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
79 additions
and
20 deletions
+79
-20
CreateNewChannelPresenter.kt
...d/createChannel/presentation/CreateNewChannelPresenter.kt
+28
-1
CreateNewChannelActivity.kt
...cket/android/createChannel/ui/CreateNewChannelActivity.kt
+21
-7
ic_hashtag_black.xml
app/src/main/res/drawable/ic_hashtag_black.xml
+1
-1
ic_person_add_black_24dp.xml
app/src/main/res/drawable/ic_person_add_black_24dp.xml
+1
-1
activity_create_new_channel.xml
app/src/main/res/layout/activity_create_new_channel.xml
+28
-10
No files found.
app/src/main/java/chat/rocket/android/createChannel/presentation/CreateNewChannelPresenter.kt
View file @
15b6c490
package
chat.rocket.android.createChannel.presentation
package
chat.rocket.android.createChannel.presentation
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.server.domain.GetCurrentServerInteractor
import
chat.rocket.android.server.infraestructure.RocketChatClientFactory
import
chat.rocket.android.util.extensions.launchUI
import
chat.rocket.common.RocketChatException
import
chat.rocket.common.model.RoomType
import
chat.rocket.core.RocketChatClient
import
chat.rocket.core.internal.rest.createChannel
import
javax.inject.Inject
import
javax.inject.Inject
class
CreateNewChannelPresenter
@Inject
constructor
()
{
class
CreateNewChannelPresenter
@Inject
constructor
(
private
val
view
:
CreateNewChannelView
,
private
val
strategy
:
CancelStrategy
,
private
val
serverInteractor
:
GetCurrentServerInteractor
,
factory
:
RocketChatClientFactory
)
{
private
val
client
:
RocketChatClient
=
factory
.
create
(
serverInteractor
.
get
()
!!
)
fun
createNewChannel
(
roomType
:
RoomType
,
channelName
:
String
,
usersList
:
List
<
String
>,
readOnly
:
Boolean
)
{
launchUI
(
strategy
)
{
view
.
showLoading
()
try
{
client
.
createChannel
(
roomType
,
channelName
,
usersList
,
readOnly
)
view
.
showMessage
(
"Channel Created successfully"
)
}
catch
(
ex
:
RocketChatException
)
{
//TODO remove this and add Log message instead
ex
.
printStackTrace
()
}
finally
{
view
.
hideLoading
()
}
}
}
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/createChannel/ui/CreateNewChannelActivity.kt
View file @
15b6c490
...
@@ -4,9 +4,12 @@ import android.graphics.drawable.GradientDrawable
...
@@ -4,9 +4,12 @@ import android.graphics.drawable.GradientDrawable
import
android.os.Bundle
import
android.os.Bundle
import
android.support.v7.app.AppCompatActivity
import
android.support.v7.app.AppCompatActivity
import
android.view.MenuItem
import
android.view.MenuItem
import
android.widget.Toast
import
chat.rocket.android.R
import
chat.rocket.android.R
import
chat.rocket.android.createChannel.presentation.CreateNewChannelPresenter
import
chat.rocket.android.createChannel.presentation.CreateNewChannelPresenter
import
chat.rocket.android.createChannel.presentation.CreateNewChannelView
import
chat.rocket.android.createChannel.presentation.CreateNewChannelView
import
chat.rocket.android.util.extensions.setVisible
import
chat.rocket.common.model.roomTypeOf
import
com.jakewharton.rxbinding2.widget.RxTextView
import
com.jakewharton.rxbinding2.widget.RxTextView
import
dagger.android.AndroidInjection
import
dagger.android.AndroidInjection
import
kotlinx.android.synthetic.main.activity_create_new_channel.*
import
kotlinx.android.synthetic.main.activity_create_new_channel.*
...
@@ -16,11 +19,15 @@ import javax.inject.Inject
...
@@ -16,11 +19,15 @@ import javax.inject.Inject
class
CreateNewChannelActivity
:
AppCompatActivity
(),
CreateNewChannelView
{
class
CreateNewChannelActivity
:
AppCompatActivity
(),
CreateNewChannelView
{
override
fun
showLoading
()
{
override
fun
showLoading
()
{
TODO
(
"not implemented"
)
//To change body of created functions use File | Settings | File Templates.
view_loading
.
setVisible
(
true
)
layout_container
.
alpha
=
0.5f
layout_container
.
isEnabled
=
false
}
}
override
fun
hideLoading
()
{
override
fun
hideLoading
()
{
TODO
(
"not implemented"
)
//To change body of created functions use File | Settings | File Templates.
view_loading
.
setVisible
(
false
)
layout_container
.
alpha
=
1.0f
layout_container
.
isEnabled
=
true
}
}
override
fun
showMessage
(
resId
:
Int
)
{
override
fun
showMessage
(
resId
:
Int
)
{
...
@@ -28,7 +35,7 @@ class CreateNewChannelActivity : AppCompatActivity(), CreateNewChannelView {
...
@@ -28,7 +35,7 @@ class CreateNewChannelActivity : AppCompatActivity(), CreateNewChannelView {
}
}
override
fun
showMessage
(
message
:
String
)
{
override
fun
showMessage
(
message
:
String
)
{
T
ODO
(
"not implemented"
)
//To change body of created functions use File | Settings | File Templates.
T
oast
.
makeText
(
this
,
message
,
Toast
.
LENGTH_LONG
).
show
()
}
}
override
fun
showGenericErrorMessage
()
{
override
fun
showGenericErrorMessage
()
{
...
@@ -66,16 +73,17 @@ class CreateNewChannelActivity : AppCompatActivity(), CreateNewChannelView {
...
@@ -66,16 +73,17 @@ class CreateNewChannelActivity : AppCompatActivity(), CreateNewChannelView {
supportActionBar
?.
setDisplayHomeAsUpEnabled
(
true
)
supportActionBar
?.
setDisplayHomeAsUpEnabled
(
true
)
RxTextView
.
textChanges
(
channel_name_edit_text
).
subscribe
{
text
->
RxTextView
.
textChanges
(
channel_name_edit_text
).
subscribe
{
text
->
toolbar_action_text
.
isEnabled
=
text
.
isNotEmpty
()
toolbar_action_text
.
isEnabled
=
text
.
isNotEmpty
()
if
(
text
.
isEmpty
())
if
(
text
.
isEmpty
())
{
toolbar_action_text
.
alpha
=
0.8f
toolbar_action_text
.
alpha
=
0.8f
else
}
else
{
toolbar_action_text
.
alpha
=
1.0f
toolbar_action_text
.
alpha
=
1.0f
}
}
}
}
}
private
fun
setUpOnClickListeners
()
{
private
fun
setUpOnClickListeners
()
{
public_channel
.
setOnClickListener
{
public_channel
.
setOnClickListener
{
channelType
=
"
publi
c"
channelType
=
"c"
channel_type
.
text
=
getString
(
R
.
string
.
public_channel_type
)
channel_type
.
text
=
getString
(
R
.
string
.
public_channel_type
)
channel_description
.
text
=
getString
(
R
.
string
.
private_channel_type_description
)
channel_description
.
text
=
getString
(
R
.
string
.
private_channel_type_description
)
...
@@ -93,7 +101,7 @@ class CreateNewChannelActivity : AppCompatActivity(), CreateNewChannelView {
...
@@ -93,7 +101,7 @@ class CreateNewChannelActivity : AppCompatActivity(), CreateNewChannelView {
}
}
private_channel
.
setOnClickListener
{
private_channel
.
setOnClickListener
{
channelType
=
"p
rivate
"
channelType
=
"p"
channel_type
.
text
=
getString
(
R
.
string
.
private_channel_type
)
channel_type
.
text
=
getString
(
R
.
string
.
private_channel_type
)
channel_description
.
text
=
getString
(
R
.
string
.
public_channel_description
)
channel_description
.
text
=
getString
(
R
.
string
.
public_channel_description
)
...
@@ -110,5 +118,11 @@ class CreateNewChannelActivity : AppCompatActivity(), CreateNewChannelView {
...
@@ -110,5 +118,11 @@ class CreateNewChannelActivity : AppCompatActivity(), CreateNewChannelView {
private_channel
.
setTextColor
(
resources
.
getColor
(
R
.
color
.
colorLightTheme
))
private_channel
.
setTextColor
(
resources
.
getColor
(
R
.
color
.
colorLightTheme
))
public_channel
.
setTextColor
(
resources
.
getColor
(
R
.
color
.
red
))
public_channel
.
setTextColor
(
resources
.
getColor
(
R
.
color
.
red
))
}
}
toolbar_action_text
.
setOnClickListener
{
if
(
toolbar_action_text
.
isEnabled
)
{
presenter
.
createNewChannel
(
roomTypeOf
(
channelType
),
channel_name_edit_text
.
text
.
toString
(),
listOf
(
"aniket03"
),
false
)
}
}
}
}
}
}
\ No newline at end of file
app/src/main/res/drawable/ic_hashtag_black.xml
View file @
15b6c490
...
@@ -7,6 +7,6 @@
...
@@ -7,6 +7,6 @@
android:pathData=
"M6.626,11.495L4.505,11.495L3.714,16L1.703,16L2.495,11.495L0,11.495L0,9.604L2.824,9.604L3.374,6.484L0.824,6.484L0.824,4.571L3.714,4.571L4.516,0L6.516,0L5.714,4.571L7.846,4.571L8.648,0L10.659,0L9.857,4.571L12.264,4.571L12.264,6.484L9.516,6.484L8.967,9.604L11.429,9.604L11.429,11.495L8.637,11.495L7.846,16L5.835,16L6.626,11.495ZM4.835,9.604L6.956,9.604L7.505,6.484L5.374,6.484L4.835,9.604Z"
android:pathData=
"M6.626,11.495L4.505,11.495L3.714,16L1.703,16L2.495,11.495L0,11.495L0,9.604L2.824,9.604L3.374,6.484L0.824,6.484L0.824,4.571L3.714,4.571L4.516,0L6.516,0L5.714,4.571L7.846,4.571L8.648,0L10.659,0L9.857,4.571L12.264,4.571L12.264,6.484L9.516,6.484L8.967,9.604L11.429,9.604L11.429,11.495L8.637,11.495L7.846,16L5.835,16L6.626,11.495ZM4.835,9.604L6.956,9.604L7.505,6.484L5.374,6.484L4.835,9.604Z"
android:strokeColor=
"#00000000"
android:strokeColor=
"#00000000"
android:fillType=
"evenOdd"
android:fillType=
"evenOdd"
android:fillColor=
"
#000000
"
android:fillColor=
"
@color/colorSecondaryText
"
android:strokeWidth=
"1"
/>
android:strokeWidth=
"1"
/>
</vector>
</vector>
app/src/main/res/drawable/ic_person_add_black_24dp.xml
View file @
15b6c490
...
@@ -4,6 +4,6 @@
...
@@ -4,6 +4,6 @@
android:viewportWidth=
"24.0"
android:viewportWidth=
"24.0"
android:viewportHeight=
"24.0"
>
android:viewportHeight=
"24.0"
>
<path
<path
android:fillColor=
"
#FF000000
"
android:fillColor=
"
@color/colorSecondaryText
"
android:pathData=
"M15,12c2.21,0 4,-1.79 4,-4s-1.79,-4 -4,-4 -4,1.79 -4,4 1.79,4 4,4zM6,10L6,7L4,7v3L1,10v2h3v3h2v-3h3v-2L6,10zM15,14c-2.67,0 -8,1.34 -8,4v2h16v-2c0,-2.66 -5.33,-4 -8,-4z"
/>
android:pathData=
"M15,12c2.21,0 4,-1.79 4,-4s-1.79,-4 -4,-4 -4,1.79 -4,4 1.79,4 4,4zM6,10L6,7L4,7v3L1,10v2h3v3h2v-3h3v-2L6,10zM15,14c-2.67,0 -8,1.34 -8,4v2h16v-2c0,-2.66 -5.33,-4 -8,-4z"
/>
</vector>
</vector>
app/src/main/res/layout/activity_create_new_channel.xml
View file @
15b6c490
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
<android.support.constraint.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
android:layout_height=
"match_parent"
>
...
@@ -12,11 +13,24 @@
...
@@ -12,11 +13,24 @@
app:layout_constraintBottom_toTopOf=
"@+id/layout_container"
app:layout_constraintBottom_toTopOf=
"@+id/layout_container"
app:layout_constraintTop_toTopOf=
"parent"
/>
app:layout_constraintTop_toTopOf=
"parent"
/>
<com.wang.avi.AVLoadingIndicatorView
android:id=
"@+id/view_loading"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:visibility=
"gone"
app:indicatorColor=
"@color/black"
app:indicatorName=
"BallPulseIndicator"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/toolbar_layout"
tools:visibility=
"visible"
/>
<android.support.constraint.ConstraintLayout
<android.support.constraint.ConstraintLayout
android:id=
"@+id/layout_container"
android:id=
"@+id/layout_container"
android:layout_width=
"0dp"
android:layout_width=
"0dp"
android:layout_height=
"0dp"
android:layout_height=
"0dp"
android:padding=
"
8
dp"
android:padding=
"
16
dp"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.0"
app:layout_constraintHorizontal_bias=
"0.0"
...
@@ -67,8 +81,9 @@
...
@@ -67,8 +81,9 @@
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"16dp"
android:layout_marginTop=
"16dp"
android:text=
"@string/private_channel_type"
android:text=
"@string/public_channel_type"
android:textColor=
"@color/black"
android:textColor=
"@color/colorPrimaryText"
android:textSize=
"16sp"
app:layout_constraintTop_toBottomOf=
"@id/public_channel"
/>
app:layout_constraintTop_toBottomOf=
"@id/public_channel"
/>
<TextView
<TextView
...
@@ -76,14 +91,15 @@
...
@@ -76,14 +91,15 @@
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"4dp"
android:layout_marginTop=
"4dp"
android:text=
"@string/private_channel_type_description"
android:text=
"@string/public_channel_description"
android:textColor=
"@color/black"
android:textColor=
"@color/colorSecondaryText"
android:textSize=
"12sp"
app:layout_constraintTop_toBottomOf=
"@id/channel_type"
/>
app:layout_constraintTop_toBottomOf=
"@id/channel_type"
/>
<View
<View
android:id=
"@+id/separator_1"
android:id=
"@+id/separator_1"
android:layout_width=
"0dp"
android:layout_width=
"0dp"
android:layout_height=
"0.
2
dp"
android:layout_height=
"0.
5
dp"
android:layout_marginTop=
"8dp"
android:layout_marginTop=
"8dp"
android:background=
"@color/colorDividerMessageComposer"
android:background=
"@color/colorDividerMessageComposer"
app:layout_constraintTop_toBottomOf=
"@id/channel_description"
/>
app:layout_constraintTop_toBottomOf=
"@id/channel_description"
/>
...
@@ -114,13 +130,14 @@
...
@@ -114,13 +130,14 @@
<android.support.design.widget.TextInputEditText
<android.support.design.widget.TextInputEditText
android:id=
"@+id/channel_name_edit_text"
android:id=
"@+id/channel_name_edit_text"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
/>
android:layout_height=
"match_parent"
android:textSize=
"16sp"
/>
</android.support.design.widget.TextInputLayout>
</android.support.design.widget.TextInputLayout>
<View
<View
android:id=
"@+id/separator_2"
android:id=
"@+id/separator_2"
android:layout_width=
"0dp"
android:layout_width=
"0dp"
android:layout_height=
"0.
2
dp"
android:layout_height=
"0.
5
dp"
android:layout_marginTop=
"8dp"
android:layout_marginTop=
"8dp"
android:background=
"@color/colorDividerMessageComposer"
android:background=
"@color/colorDividerMessageComposer"
app:layout_constraintTop_toBottomOf=
"@id/channel_name_text_input_layout"
/>
app:layout_constraintTop_toBottomOf=
"@id/channel_name_text_input_layout"
/>
...
@@ -140,7 +157,8 @@
...
@@ -140,7 +157,8 @@
android:layout_width=
"0dp"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"@string/msg_add_members"
android:text=
"@string/msg_add_members"
android:textColor=
"@color/black"
android:textColor=
"@color/colorSecondaryText"
android:textSize=
"16sp"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintHorizontal_chainStyle=
"spread"
app:layout_constraintHorizontal_chainStyle=
"spread"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
...
@@ -158,7 +176,7 @@
...
@@ -158,7 +176,7 @@
<View
<View
android:id=
"@+id/separator_3"
android:id=
"@+id/separator_3"
android:layout_width=
"0dp"
android:layout_width=
"0dp"
android:layout_height=
"0.
2
dp"
android:layout_height=
"0.
5
dp"
android:layout_marginTop=
"8dp"
android:layout_marginTop=
"8dp"
android:background=
"@color/colorDividerMessageComposer"
android:background=
"@color/colorDividerMessageComposer"
app:layout_constraintTop_toBottomOf=
"@id/add_members_view"
/>
app:layout_constraintTop_toBottomOf=
"@id/add_members_view"
/>
...
...
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