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
0547ca99
Commit
0547ca99
authored
Apr 27, 2015
by
Grigory Fedorov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New navigation drawer account list design.
parent
68bebc48
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
145 additions
and
5 deletions
+145
-5
ContactListDrawerFragment.java
...java/com/xabber/android/ui/ContactListDrawerFragment.java
+6
-5
NavigationDrawerAccountAdapter.java
...er/android/ui/adapter/NavigationDrawerAccountAdapter.java
+68
-0
navigation_drawer_account_item.xml
app/src/main/res/layout/navigation_drawer_account_item.xml
+71
-0
No files found.
app/src/main/java/com/xabber/android/ui/ContactListDrawerFragment.java
View file @
0547ca99
...
...
@@ -14,7 +14,7 @@ import android.widget.ListView;
import
com.xabber.android.data.Application
;
import
com.xabber.android.data.account.OnAccountChangedListener
;
import
com.xabber.android.ui.adapter.
AccountLis
tAdapter
;
import
com.xabber.android.ui.adapter.
NavigationDrawerAccoun
tAdapter
;
import
com.xabber.androiddev.R
;
import
java.util.Collection
;
...
...
@@ -22,7 +22,7 @@ import java.util.Collection;
public
class
ContactListDrawerFragment
extends
Fragment
implements
View
.
OnClickListener
,
OnAccountChangedListener
,
AdapterView
.
OnItemClickListener
{
ContactListDrawerListener
listener
;
private
AccountLis
tAdapter
adapter
;
private
NavigationDrawerAccoun
tAdapter
adapter
;
@Override
public
void
onAttach
(
Activity
activity
)
{
...
...
@@ -37,14 +37,15 @@ public class ContactListDrawerFragment extends Fragment implements View.OnClickL
ListView
listView
=
(
ListView
)
view
.
findViewById
(
R
.
id
.
drawer_account_list
);
adapter
=
new
AccountListAdapter
(
getActivity
());
listView
.
setAdapter
(
adapter
);
listView
.
setOnItemClickListener
(
this
);
View
footerView
=
((
LayoutInflater
)
getActivity
().
getSystemService
(
Context
.
LAYOUT_INFLATER_SERVICE
))
.
inflate
(
R
.
layout
.
contact_list_drawer_footer
,
null
,
false
);
listView
.
addFooterView
(
footerView
);
adapter
=
new
NavigationDrawerAccountAdapter
(
getActivity
());
listView
.
setAdapter
(
adapter
);
listView
.
setOnItemClickListener
(
this
);
footerView
.
findViewById
(
R
.
id
.
drawer_action_settings
).
setOnClickListener
(
this
);
footerView
.
findViewById
(
R
.
id
.
drawer_action_about
).
setOnClickListener
(
this
);
footerView
.
findViewById
(
R
.
id
.
drawer_action_exit
).
setOnClickListener
(
this
);
...
...
app/src/main/java/com/xabber/android/ui/adapter/NavigationDrawerAccountAdapter.java
0 → 100644
View file @
0547ca99
package
com
.
xabber
.
android
.
ui
.
adapter
;
import
android.app.Activity
;
import
android.graphics.drawable.ColorDrawable
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.ImageView
;
import
android.widget.TextView
;
import
com.xabber.android.data.account.AccountItem
;
import
com.xabber.android.data.account.AccountManager
;
import
com.xabber.android.data.connection.ConnectionState
;
import
com.xabber.android.data.extension.avatar.AvatarManager
;
import
com.xabber.androiddev.R
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.List
;
public
class
NavigationDrawerAccountAdapter
extends
BaseListEditorAdapter
<
String
>
{
private
final
int
[]
accountColors
;
public
NavigationDrawerAccountAdapter
(
Activity
activity
)
{
super
(
activity
);
accountColors
=
activity
.
getResources
().
getIntArray
(
R
.
array
.
account_action_bar
);
}
@Override
public
View
getView
(
int
position
,
View
convertView
,
ViewGroup
parent
)
{
View
view
;
AccountManager
accountManager
=
AccountManager
.
getInstance
();
if
(
convertView
==
null
)
{
view
=
getActivity
().
getLayoutInflater
().
inflate
(
R
.
layout
.
navigation_drawer_account_item
,
parent
,
false
);
}
else
{
view
=
convertView
;
}
String
account
=
getItem
(
position
);
int
accountColor
=
accountColors
[
accountManager
.
getColorLevel
(
account
)];
((
ImageView
)
view
.
findViewById
(
R
.
id
.
color
)).
setImageDrawable
(
new
ColorDrawable
(
accountColor
));
((
ImageView
)
view
.
findViewById
(
R
.
id
.
avatar
))
.
setImageDrawable
(
AvatarManager
.
getInstance
().
getAccountAvatar
(
account
));
((
TextView
)
view
.
findViewById
(
R
.
id
.
name
)).
setText
(
accountManager
.
getVerboseName
(
account
));
AccountItem
accountItem
=
accountManager
.
getAccount
(
account
);
ConnectionState
state
;
if
(
accountItem
==
null
)
{
state
=
ConnectionState
.
offline
;
}
else
{
state
=
accountItem
.
getState
();
}
((
TextView
)
view
.
findViewById
(
R
.
id
.
status
)).
setText
(
getActivity
().
getString
(
state
.
getStringId
()));
return
view
;
}
@Override
protected
Collection
<
String
>
getTags
()
{
List
<
String
>
list
=
new
ArrayList
<>();
list
.
addAll
(
AccountManager
.
getInstance
().
getAccounts
());
Collections
.
sort
(
list
);
return
list
;
}
}
\ No newline at end of file
app/src/main/res/layout/navigation_drawer_account_item.xml
0 → 100644
View file @
0547ca99
<?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=
"48dp"
android:paddingLeft=
"10dp"
android:paddingRight=
"16dp"
>
<FrameLayout
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
>
<de.hdodenhof.circleimageview.CircleImageView
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:id=
"@+id/color"
android:layout_width=
"36dp"
android:layout_height=
"36dp"
android:src=
"@color/green_500"
/>
<de.hdodenhof.circleimageview.CircleImageView
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:id=
"@+id/avatar"
android:layout_width=
"36dp"
android:layout_height=
"36dp"
android:src=
"@drawable/ic_avatar_1"
app:border_color=
"@android:color/transparent"
app:border_width=
"3dp"
/>
</FrameLayout>
<LinearLayout
android:layout_width=
"0dp"
android:layout_height=
"match_parent"
android:layout_weight=
"1"
android:orientation=
"vertical"
android:paddingLeft=
"32dp"
>
<TextView
android:id=
"@+id/name"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:ellipsize=
"marquee"
android:gravity=
"bottom"
android:singleLine=
"true"
android:text=
"test"
android:textColor=
"?android:attr/textColorPrimary"
android:textStyle=
"bold"
/>
<TextView
android:id=
"@+id/status"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:ellipsize=
"marquee"
android:gravity=
"top"
android:singleLine=
"true"
android:text=
"@android:string/cancel"
android:textColor=
"?android:attr/textColorSecondary"
/>
</LinearLayout>
</LinearLayout>
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