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
89aad912
Commit
89aad912
authored
May 24, 2018
by
aniket
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
deals with many more cases
parent
2c4dffeb
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
113 additions
and
58 deletions
+113
-58
AddMembersActivity.kt
...android/createChannel/addMembers/ui/AddMembersActivity.kt
+42
-28
CreateNewChannelActivity.kt
...cket/android/createChannel/ui/CreateNewChannelActivity.kt
+42
-25
activity_create_new_channel.xml
app/src/main/res/layout/activity_create_new_channel.xml
+29
-5
No files found.
app/src/main/java/chat/rocket/android/createChannel/addMembers/ui/AddMembersActivity.kt
View file @
89aad912
...
...
@@ -37,9 +37,9 @@ class AddMembersActivity : AppCompatActivity(), AddMembersView {
addNewChip
(
memberViewModel
)
updateToolBar
()
search_view
.
setText
(
""
)
}
else
{
Toast
.
makeText
(
this
,
getString
(
R
.
string
.
msg_member_already_added
),
Toast
.
LENGTH_LONG
)
.
show
()
}
else
{
Toast
.
makeText
(
this
,
getString
(
R
.
string
.
msg_member_already_added
),
Toast
.
LENGTH_LONG
)
.
show
()
}
}
private
var
linearLayoutManager
=
LinearLayoutManager
(
this
,
LinearLayoutManager
.
VERTICAL
,
false
)
...
...
@@ -51,6 +51,7 @@ class AddMembersActivity : AppCompatActivity(), AddMembersView {
setUpToolBar
()
setUpRecyclerView
()
setOnClickListeners
()
setInitialChips
()
observableFromSearchView
(
search_view
)
.
debounce
(
300
,
TimeUnit
.
MILLISECONDS
)
.
filter
{
item
->
item
.
length
>
1
}
...
...
@@ -74,33 +75,10 @@ class AddMembersActivity : AppCompatActivity(), AddMembersView {
return
super
.
onOptionsItemSelected
(
item
)
}
private
fun
addNewChip
(
memberViewModel
:
MemberViewModel
)
{
val
memberChip
=
Chip
(
this
)
memberChip
.
chipText
=
memberViewModel
.
username
memberChip
.
isCloseIconEnabled
=
true
memberChip
.
setChipBackgroundColorResource
(
R
.
color
.
icon_grey
)
memberChip
.
setOnCloseIconClickListener
{
view
->
members_chips
.
removeView
(
view
)
membersToAdd
.
remove
((
view
as
Chip
).
chipText
.
toString
())
updateToolBar
()
}
members_chips
.
addView
(
memberChip
)
memberViewModel
.
username
?.
let
{
membersToAdd
.
add
(
it
)
}
}
private
fun
updateToolBar
()
{
toolbar_action_text
.
isEnabled
=
membersToAdd
.
isNotEmpty
()
if
(
membersToAdd
.
size
==
0
)
{
toolbar_action_text
.
alpha
=
0.8f
}
else
{
toolbar_action_text
.
alpha
=
1.0f
}
toolbar_title
.
text
=
getString
(
R
.
string
.
title_add_members
,
membersToAdd
.
size
)
}
override
fun
showMembers
(
dataSet
:
List
<
MemberViewModel
>,
total
:
Long
)
{
if
(
adapter
.
itemCount
==
0
)
{
adapter
.
prependData
(
dataSet
)
//TODO work on this part after adding support for count and offset in sdk
// if (dataSet.size >= 59) { // TODO Check why the API retorns the specified count -1
// search_results.addOnScrollListener(object :
// EndlessRecyclerViewScrollListener(linearLayoutManager) {
...
...
@@ -139,6 +117,43 @@ class AddMembersActivity : AppCompatActivity(), AddMembersView {
showMessage
(
getString
(
R
.
string
.
msg_generic_error
))
}
private
fun
setInitialChips
()
{
membersToAdd
=
intent
.
getStringArrayListExtra
(
"chips"
)
for
(
element
in
membersToAdd
)
{
buildNewChip
(
element
)
}
updateToolBar
()
}
private
fun
addNewChip
(
memberViewModel
:
MemberViewModel
)
{
memberViewModel
.
username
?.
let
{
buildNewChip
(
it
)
membersToAdd
.
add
(
it
)
}
}
private
fun
buildNewChip
(
chipText
:
String
)
{
val
memberChip
=
Chip
(
this
)
memberChip
.
chipText
=
chipText
memberChip
.
isCloseIconEnabled
=
true
memberChip
.
setChipBackgroundColorResource
(
R
.
color
.
icon_grey
)
memberChip
.
setOnCloseIconClickListener
{
view
->
members_chips
.
removeView
(
view
)
membersToAdd
.
remove
((
view
as
Chip
).
chipText
.
toString
())
updateToolBar
()
}
members_chips
.
addView
(
memberChip
)
}
private
fun
updateToolBar
()
{
toolbar_action_text
.
isEnabled
=
membersToAdd
.
isNotEmpty
()
if
(
membersToAdd
.
size
==
0
)
{
toolbar_action_text
.
alpha
=
0.8f
}
else
{
toolbar_action_text
.
alpha
=
1.0f
}
toolbar_title
.
text
=
getString
(
R
.
string
.
title_add_members
,
membersToAdd
.
size
)
}
private
fun
setUpToolBar
()
{
setSupportActionBar
(
toolbar
)
...
...
@@ -152,7 +167,6 @@ class AddMembersActivity : AppCompatActivity(), AddMembersView {
search_results
.
layoutManager
=
linearLayoutManager
search_results
.
adapter
=
adapter
search_results
.
addItemDecoration
(
DividerItemDecoration
(
this
))
}
private
fun
setOnClickListeners
()
{
...
...
app/src/main/java/chat/rocket/android/createChannel/ui/CreateNewChannelActivity.kt
View file @
89aad912
...
...
@@ -4,6 +4,7 @@ import android.app.Activity
import
android.content.Intent
import
android.graphics.drawable.GradientDrawable
import
android.os.Bundle
import
android.support.design.chip.Chip
import
android.support.v7.app.AppCompatActivity
import
android.view.MenuItem
import
android.widget.Toast
...
...
@@ -28,6 +29,36 @@ class CreateNewChannelActivity : AppCompatActivity(), CreateNewChannelView {
private
var
channelType
:
String
=
"public"
private
var
listOfUsers
:
ArrayList
<
String
>
=
ArrayList
()
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
AndroidInjection
.
inject
(
this
)
super
.
onCreate
(
savedInstanceState
)
setContentView
(
R
.
layout
.
activity_create_new_channel
)
setUpToolBar
()
setUpOnClickListeners
()
}
override
fun
onOptionsItemSelected
(
item
:
MenuItem
?):
Boolean
{
when
(
item
?.
itemId
)
{
android
.
R
.
id
.
home
->
{
finish
()
return
true
}
}
return
super
.
onOptionsItemSelected
(
item
)
}
override
fun
onActivityResult
(
requestCode
:
Int
,
resultCode
:
Int
,
data
:
Intent
?)
{
super
.
onActivityResult
(
requestCode
,
resultCode
,
data
)
if
(
resultCode
==
Activity
.
RESULT_OK
)
{
if
(
requestCode
==
ADD_MEMBERS_ACTIVITY_REQUEST_CODE
&&
data
!=
null
)
{
listOfUsers
=
data
.
getStringArrayListExtra
(
"members"
)
selected_members_chips
.
removeAllViews
()
refreshMembersChips
()
}
}
}
override
fun
showLoading
()
{
view_loading
.
setVisible
(
true
)
layout_container
.
alpha
=
0.5f
...
...
@@ -42,6 +73,8 @@ class CreateNewChannelActivity : AppCompatActivity(), CreateNewChannelView {
override
fun
showChannelCreatedSuccessfullyMessage
()
{
showToast
(
getString
(
R
.
string
.
msg_channel_created_successfully
))
finish
()
//TODO check why the activity is not finishing
}
override
fun
showMessage
(
resId
:
Int
)
{
...
...
@@ -56,32 +89,15 @@ class CreateNewChannelActivity : AppCompatActivity(), CreateNewChannelView {
showMessage
(
getString
(
R
.
string
.
msg_generic_error
))
}
override
fun
onOptionsItemSelected
(
item
:
MenuItem
?):
Boolean
{
when
(
item
?.
itemId
)
{
android
.
R
.
id
.
home
->
{
finish
()
return
true
}
}
return
super
.
onOptionsItemSelected
(
item
)
}
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
AndroidInjection
.
inject
(
this
)
super
.
onCreate
(
savedInstanceState
)
setContentView
(
R
.
layout
.
activity_create_new_channel
)
setUpToolBar
()
setUpOnClickListeners
()
}
override
fun
onActivityResult
(
requestCode
:
Int
,
resultCode
:
Int
,
data
:
Intent
?)
{
super
.
onActivityResult
(
requestCode
,
resultCode
,
data
)
if
(
resultCode
==
Activity
.
RESULT_OK
)
{
if
(
requestCode
==
ADD_MEMBERS_ACTIVITY_REQUEST_CODE
&&
data
!=
null
)
{
listOfUsers
=
data
.
getStringArrayListExtra
(
"members"
)
Toast
.
makeText
(
this
,
listOfUsers
.
size
.
toString
(),
Toast
.
LENGTH_SHORT
).
show
()
}
private
fun
refreshMembersChips
()
{
for
(
element
in
listOfUsers
)
{
val
memberChip
=
Chip
(
this
)
memberChip
.
chipText
=
element
memberChip
.
isCloseIconEnabled
=
false
memberChip
.
isLongClickable
=
false
memberChip
.
setChipBackgroundColorResource
(
R
.
color
.
icon_grey
)
selected_members_chips
.
addView
(
memberChip
)
}
}
...
...
@@ -163,6 +179,7 @@ class CreateNewChannelActivity : AppCompatActivity(), CreateNewChannelView {
add_members_view
.
setOnClickListener
{
val
intent
=
Intent
(
this
,
AddMembersActivity
::
class
.
java
)
intent
.
putExtra
(
"chips"
,
listOfUsers
)
startActivityForResult
(
intent
,
ADD_MEMBERS_ACTIVITY_REQUEST_CODE
)
}
}
...
...
app/src/main/res/layout/activity_create_new_channel.xml
View file @
89aad912
...
...
@@ -30,7 +30,7 @@
android:id=
"@+id/layout_container"
android:layout_width=
"0dp"
android:layout_height=
"0dp"
android:padding=
"16dp"
android:padding
Top
=
"16dp"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.0"
...
...
@@ -80,20 +80,24 @@
android:id=
"@+id/channel_type"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"16dp"
android:layout_marginTop=
"16dp"
android:text=
"@string/public_channel_type"
android:textColor=
"@color/colorPrimaryText"
android:textSize=
"16sp"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/public_channel"
/>
<TextView
android:id=
"@+id/channel_description"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"16dp"
android:layout_marginTop=
"4dp"
android:text=
"@string/public_channel_description"
android:textColor=
"@color/colorSecondaryText"
android:textSize=
"12sp"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/channel_type"
/>
<View
...
...
@@ -108,6 +112,7 @@
android:id=
"@+id/placeholder"
android:layout_width=
"wrap_content"
android:layout_height=
"0dp"
android:layout_marginStart=
"16dp"
android:layout_marginTop=
"8dp"
android:src=
"@drawable/ic_hashtag_black"
app:layout_constraintBottom_toBottomOf=
"@id/channel_name_text_input_layout"
...
...
@@ -119,6 +124,7 @@
android:id=
"@+id/channel_name_text_input_layout"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"16dp"
android:layout_marginStart=
"8dp"
android:layout_marginTop=
"8dp"
android:focusable=
"true"
...
...
@@ -146,9 +152,9 @@
android:id=
"@+id/add_members_view"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:paddingTop=
"8dp"
android:paddingBottom=
"8dp"
android:background=
"?attr/selectableItemBackground"
android:paddingBottom=
"8dp"
android:paddingTop=
"8dp"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/separator_2"
>
...
...
@@ -157,10 +163,11 @@
android:id=
"@+id/add_members_text"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"16dp"
android:layout_marginTop=
"8dp"
android:text=
"@string/msg_add_members"
android:textColor=
"@color/colorSecondaryText"
android:textSize=
"16sp"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintHorizontal_chainStyle=
"spread"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
/>
...
...
@@ -168,10 +175,27 @@
<ImageView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"16dp"
android:layout_marginTop=
"8dp"
android:src=
"@drawable/ic_person_add_black_24dp"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"1"
app:layout_constraintStart_toEndOf=
"@id/add_members_text"
/>
app:layout_constraintStart_toEndOf=
"@id/add_members_text"
app:layout_constraintTop_toTopOf=
"parent"
/>
<android.support.design.chip.ChipGroup
android:id=
"@+id/selected_members_chips"
style=
"@style/Widget.MaterialComponents.Chip.Entry"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"16dp"
android:layout_marginStart=
"16dp"
android:layout_marginTop=
"8dp"
app:chipSpacing=
"3dp"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/add_members_text"
>
</android.support.design.chip.ChipGroup>
</android.support.constraint.ConstraintLayout>
<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