Commit 0547ca99 authored by Grigory Fedorov's avatar Grigory Fedorov

New navigation drawer account list design.

parent 68bebc48
...@@ -14,7 +14,7 @@ import android.widget.ListView; ...@@ -14,7 +14,7 @@ import android.widget.ListView;
import com.xabber.android.data.Application; import com.xabber.android.data.Application;
import com.xabber.android.data.account.OnAccountChangedListener; import com.xabber.android.data.account.OnAccountChangedListener;
import com.xabber.android.ui.adapter.AccountListAdapter; import com.xabber.android.ui.adapter.NavigationDrawerAccountAdapter;
import com.xabber.androiddev.R; import com.xabber.androiddev.R;
import java.util.Collection; import java.util.Collection;
...@@ -22,7 +22,7 @@ import java.util.Collection; ...@@ -22,7 +22,7 @@ import java.util.Collection;
public class ContactListDrawerFragment extends Fragment implements View.OnClickListener, OnAccountChangedListener, AdapterView.OnItemClickListener { public class ContactListDrawerFragment extends Fragment implements View.OnClickListener, OnAccountChangedListener, AdapterView.OnItemClickListener {
ContactListDrawerListener listener; ContactListDrawerListener listener;
private AccountListAdapter adapter; private NavigationDrawerAccountAdapter adapter;
@Override @Override
public void onAttach(Activity activity) { public void onAttach(Activity activity) {
...@@ -37,14 +37,15 @@ public class ContactListDrawerFragment extends Fragment implements View.OnClickL ...@@ -37,14 +37,15 @@ public class ContactListDrawerFragment extends Fragment implements View.OnClickL
ListView listView = (ListView) view.findViewById(R.id.drawer_account_list); 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)) View footerView = ((LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE))
.inflate(R.layout.contact_list_drawer_footer, null, false); .inflate(R.layout.contact_list_drawer_footer, null, false);
listView.addFooterView(footerView); 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_settings).setOnClickListener(this);
footerView.findViewById(R.id.drawer_action_about).setOnClickListener(this); footerView.findViewById(R.id.drawer_action_about).setOnClickListener(this);
footerView.findViewById(R.id.drawer_action_exit).setOnClickListener(this); footerView.findViewById(R.id.drawer_action_exit).setOnClickListener(this);
......
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
<?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>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment