Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xabber-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
xabber-android
Commits
b8d8ee9d
Commit
b8d8ee9d
authored
Apr 02, 2015
by
Grigory Fedorov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ContactList: account groups new design: contact like height, status.
parent
e64a2951
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
181 additions
and
64 deletions
+181
-64
GroupedContactAdapter.java
.../com/xabber/android/ui/adapter/GroupedContactAdapter.java
+115
-54
account_group_item.xml
app/src/main/res/layout/account_group_item.xml
+66
-0
base_group_item.xml
app/src/main/res/layout/base_group_item.xml
+0
-10
No files found.
app/src/main/java/com/xabber/android/ui/adapter/GroupedContactAdapter.java
View file @
b8d8ee9d
...
@@ -27,6 +27,7 @@ import android.widget.ImageView;
...
@@ -27,6 +27,7 @@ import android.widget.ImageView;
import
android.widget.ListView
;
import
android.widget.ListView
;
import
android.widget.TextView
;
import
android.widget.TextView
;
import
com.xabber.android.data.account.AccountItem
;
import
com.xabber.android.data.account.AccountManager
;
import
com.xabber.android.data.account.AccountManager
;
import
com.xabber.android.data.roster.AbstractContact
;
import
com.xabber.android.data.roster.AbstractContact
;
import
com.xabber.android.data.roster.Group
;
import
com.xabber.android.data.roster.Group
;
...
@@ -53,6 +54,8 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
...
@@ -53,6 +54,8 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
*/
*/
static
final
Collection
<
Group
>
NO_GROUP_LIST
;
static
final
Collection
<
Group
>
NO_GROUP_LIST
;
static
final
int
TYPE_COUNT
=
3
;
/**
/**
* View type used for contact items.
* View type used for contact items.
*/
*/
...
@@ -63,6 +66,9 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
...
@@ -63,6 +66,9 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
*/
*/
static
final
int
TYPE_GROUP
=
1
;
static
final
int
TYPE_GROUP
=
1
;
static
final
int
TYPE_ACCOUNT
=
2
;
static
{
static
{
Collection
<
Group
>
groups
=
new
ArrayList
<>(
1
);
Collection
<
Group
>
groups
=
new
ArrayList
<>(
1
);
groups
.
add
(
new
Group
()
{
groups
.
add
(
new
Group
()
{
...
@@ -108,7 +114,7 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
...
@@ -108,7 +114,7 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
@Override
@Override
public
int
getViewTypeCount
()
{
public
int
getViewTypeCount
()
{
return
2
;
return
TYPE_COUNT
;
}
}
@Override
@Override
...
@@ -116,6 +122,8 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
...
@@ -116,6 +122,8 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
Object
object
=
getItem
(
position
);
Object
object
=
getItem
(
position
);
if
(
object
instanceof
AbstractContact
)
{
if
(
object
instanceof
AbstractContact
)
{
return
TYPE_CONTACT
;
return
TYPE_CONTACT
;
}
else
if
(
object
instanceof
AccountConfiguration
)
{
return
TYPE_ACCOUNT
;
}
else
if
(
object
instanceof
GroupConfiguration
)
{
}
else
if
(
object
instanceof
GroupConfiguration
)
{
return
TYPE_GROUP
;
return
TYPE_GROUP
;
}
else
{
}
else
{
...
@@ -125,16 +133,17 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
...
@@ -125,16 +133,17 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
@Override
@Override
public
View
getView
(
int
position
,
View
convertView
,
ViewGroup
parent
)
{
public
View
getView
(
int
position
,
View
convertView
,
ViewGroup
parent
)
{
if
(
getItemViewType
(
position
)
==
TYPE_CONTACT
)
{
switch
(
getItemViewType
(
position
))
{
case
TYPE_CONTACT:
return
super
.
getView
(
position
,
convertView
,
parent
);
return
super
.
getView
(
position
,
convertView
,
parent
);
}
else
if
(
getItemViewType
(
position
)
==
TYPE_GROUP
)
{
case
TYPE_GROUP:
{
final
View
view
;
final
View
view
;
final
GroupViewHolder
viewHolder
;
final
GroupViewHolder
viewHolder
;
if
(
convertView
==
null
)
{
if
(
convertView
==
null
)
{
view
=
layoutInflater
.
inflate
(
R
.
layout
.
base_group_item
,
parent
,
false
);
view
=
layoutInflater
.
inflate
(
R
.
layout
.
base_group_item
,
parent
,
false
);
TypedArray
typedArray
=
activity
.
obtainStyledAttributes
(
R
.
styleable
.
ContactList
);
TypedArray
typedArray
=
activity
.
obtainStyledAttributes
(
R
.
styleable
.
ContactList
);
view
.
setBackgroundDrawable
(
typedArray
.
getDrawable
(
R
.
styleable
.
ContactList_expanderBackground
));
((
ImageView
)
view
.
findViewById
(
R
.
id
.
indicator
)).
setImageDrawable
(
((
ImageView
)
view
.
findViewById
(
R
.
id
.
indicator
)).
setImageDrawable
(
typedArray
.
getDrawable
(
R
.
styleable
.
ContactList_expanderIndicator
));
typedArray
.
getDrawable
(
R
.
styleable
.
ContactList_expanderIndicator
));
typedArray
.
recycle
();
typedArray
.
recycle
();
...
@@ -145,6 +154,7 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
...
@@ -145,6 +154,7 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
view
=
convertView
;
view
=
convertView
;
viewHolder
=
(
GroupViewHolder
)
view
.
getTag
();
viewHolder
=
(
GroupViewHolder
)
view
.
getTag
();
}
}
final
GroupConfiguration
configuration
=
(
GroupConfiguration
)
getItem
(
position
);
final
GroupConfiguration
configuration
=
(
GroupConfiguration
)
getItem
(
position
);
final
int
level
=
AccountManager
.
getInstance
().
getColorLevel
(
configuration
.
getAccount
());
final
int
level
=
AccountManager
.
getInstance
().
getColorLevel
(
configuration
.
getAccount
());
...
@@ -159,7 +169,6 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
...
@@ -159,7 +169,6 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
int
color
;
int
color
;
viewHolder
.
accountStatus
.
setVisibility
(
View
.
GONE
);
viewHolder
.
groupOfflineIndicator
.
setVisibility
(
View
.
GONE
);
viewHolder
.
groupOfflineIndicator
.
setVisibility
(
View
.
GONE
);
if
(
configuration
.
getUser
().
equals
(
GroupManager
.
ACTIVE_CHATS
))
{
if
(
configuration
.
getUser
().
equals
(
GroupManager
.
ACTIVE_CHATS
))
{
...
@@ -170,20 +179,10 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
...
@@ -170,20 +179,10 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
viewHolder
.
name
.
setText
(
name
+
" ("
+
configuration
.
getOnline
()
viewHolder
.
name
.
setText
(
name
+
" ("
+
configuration
.
getOnline
()
+
"/"
+
configuration
.
getTotal
()
+
")"
);
+
"/"
+
configuration
.
getTotal
()
+
")"
);
if
(
configuration
instanceof
AccountConfiguration
)
{
color
=
accountColors
[
level
];
elevation
=
accountGroupElevation
;
viewHolder
.
groupOfflineIndicator
.
setVisibility
(
View
.
INVISIBLE
);
viewHolder
.
accountStatus
.
setVisibility
(
View
.
VISIBLE
);
viewHolder
.
accountStatus
.
setImageLevel
(
AccountManager
.
getInstance
()
.
getAccount
(
configuration
.
getAccount
()).
getDisplayStatusMode
().
getStatusLevel
());
}
else
{
color
=
accountSubgroupColors
[
level
];
color
=
accountSubgroupColors
[
level
];
elevation
=
accountSubgroupElevation
;
elevation
=
accountSubgroupElevation
;
viewHolder
.
groupOfflineIndicator
.
setVisibility
(
View
.
VISIBLE
);
viewHolder
.
groupOfflineIndicator
.
setVisibility
(
View
.
VISIBLE
);
}
}
}
view
.
setBackgroundDrawable
(
new
ColorDrawable
(
color
));
view
.
setBackgroundDrawable
(
new
ColorDrawable
(
color
));
...
@@ -191,9 +190,58 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
...
@@ -191,9 +190,58 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
view
.
setElevation
(
elevation
);
view
.
setElevation
(
elevation
);
}
}
return
view
;
return
view
;
}
case
TYPE_ACCOUNT:
final
View
view
;
final
AccountViewHolder
viewHolder
;
if
(
convertView
==
null
)
{
view
=
layoutInflater
.
inflate
(
R
.
layout
.
account_group_item
,
parent
,
false
);
TypedArray
typedArray
=
activity
.
obtainStyledAttributes
(
R
.
styleable
.
ContactList
);
((
ImageView
)
view
.
findViewById
(
R
.
id
.
indicator
)).
setImageDrawable
(
typedArray
.
getDrawable
(
R
.
styleable
.
ContactList_expanderIndicator
));
typedArray
.
recycle
();
viewHolder
=
new
AccountViewHolder
(
view
);
view
.
setTag
(
viewHolder
);
}
else
{
}
else
{
view
=
convertView
;
viewHolder
=
(
AccountViewHolder
)
view
.
getTag
();
}
final
AccountConfiguration
configuration
=
(
AccountConfiguration
)
getItem
(
position
);
final
int
level
=
AccountManager
.
getInstance
().
getColorLevel
(
configuration
.
getAccount
());
view
.
setBackgroundDrawable
(
new
ColorDrawable
(
accountColors
[
level
]));
viewHolder
.
indicator
.
setImageLevel
(
configuration
.
isExpanded
()
?
1
:
0
);
final
String
name
=
GroupManager
.
getInstance
()
.
getGroupName
(
configuration
.
getAccount
(),
configuration
.
getUser
());
viewHolder
.
jid
.
setText
(
name
+
" ("
+
configuration
.
getOnline
()
+
"/"
+
configuration
.
getTotal
()
+
")"
);
AccountItem
accountItem
=
AccountManager
.
getInstance
().
getAccount
(
configuration
.
getAccount
());
viewHolder
.
statusIcon
.
setImageLevel
(
accountItem
.
getDisplayStatusMode
().
getStatusLevel
());
String
statusText
=
accountItem
.
getStatusText
().
trim
();
if
(
statusText
.
isEmpty
())
{
statusText
=
activity
.
getString
(
accountItem
.
getDisplayStatusMode
().
getStringID
());
}
viewHolder
.
status
.
setText
(
statusText
);
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
LOLLIPOP
)
{
view
.
setElevation
(
accountGroupElevation
);
}
return
view
;
default
:
throw
new
IllegalStateException
();
throw
new
IllegalStateException
();
}
}
}
}
...
@@ -399,14 +447,27 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
...
@@ -399,14 +447,27 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
final
ImageView
indicator
;
final
ImageView
indicator
;
final
TextView
name
;
final
TextView
name
;
final
ImageView
groupOfflineIndicator
;
final
ImageView
groupOfflineIndicator
;
final
ImageView
accountStatus
;
public
GroupViewHolder
(
View
view
)
{
public
GroupViewHolder
(
View
view
)
{
indicator
=
(
ImageView
)
view
.
findViewById
(
R
.
id
.
indicator
);
indicator
=
(
ImageView
)
view
.
findViewById
(
R
.
id
.
indicator
);
name
=
(
TextView
)
view
.
findViewById
(
R
.
id
.
name
);
name
=
(
TextView
)
view
.
findViewById
(
R
.
id
.
name
);
groupOfflineIndicator
=
(
ImageView
)
view
.
findViewById
(
R
.
id
.
group_offline_indicator
);
groupOfflineIndicator
=
(
ImageView
)
view
.
findViewById
(
R
.
id
.
group_offline_indicator
);
accountStatus
=
(
ImageView
)
view
.
findViewById
(
R
.
id
.
account_status
);
}
}
}
}
private
static
class
AccountViewHolder
{
final
ImageView
indicator
;
final
TextView
jid
;
final
TextView
status
;
final
ImageView
statusIcon
;
public
AccountViewHolder
(
View
view
)
{
indicator
=
(
ImageView
)
view
.
findViewById
(
R
.
id
.
indicator
);
jid
=
(
TextView
)
view
.
findViewById
(
R
.
id
.
account_jid
);
status
=
(
TextView
)
view
.
findViewById
(
R
.
id
.
account_status
);
statusIcon
=
(
ImageView
)
view
.
findViewById
(
R
.
id
.
account_status_icon
);
}
}
}
}
app/src/main/res/layout/account_group_item.xml
0 → 100644
View file @
b8d8ee9d
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2013, Redsolution LTD. All rights reserved.
This file is part of Xabber project; you can redistribute it and/or
modify it under the terms of the GNU General Public License, Version 3.
Xabber is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License,
along with this program. If not, see http://www.gnu.org/licenses/.
-->
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"@dimen/contact_list_item_height"
android:orientation=
"horizontal"
android:gravity=
"center_vertical"
android:background=
"@color/green_500"
>
<ImageView
android:id=
"@+id/indicator"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:src=
"@drawable/expander_indicator_dark"
/>
<LinearLayout
android:layout_width=
"0dp"
android:layout_height=
"match_parent"
android:layout_weight=
"1"
android:gravity=
"center_vertical"
android:orientation=
"vertical"
>
<TextView
android:id=
"@+id/account_jid"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:singleLine=
"true"
android:ellipsize=
"marquee"
android:text=
"name@example.com (0/0)"
/>
<TextView
android:id=
"@+id/account_status"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:singleLine=
"true"
android:ellipsize=
"marquee"
android:text=
"Online"
/>
</LinearLayout>
<ImageView
android:id=
"@+id/account_status_icon"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:src=
"@drawable/ic_status"
android:padding=
"16dp"
/>
</LinearLayout>
\ No newline at end of file
app/src/main/res/layout/base_group_item.xml
View file @
b8d8ee9d
...
@@ -54,14 +54,4 @@
...
@@ -54,14 +54,4 @@
android:layout_toStartOf=
"@id/group_offline_indicator"
android:layout_toStartOf=
"@id/group_offline_indicator"
/>
/>
<ImageView
android:id=
"@+id/account_status"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:src=
"@drawable/ic_status"
android:layout_alignParentEnd=
"true"
android:layout_alignParentRight=
"true"
android:layout_centerVertical=
"true"
/>
</RelativeLayout>
</RelativeLayout>
\ No newline at end of file
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