Commit aebda14d authored by Grigory Fedorov's avatar Grigory Fedorov

ContactLIst: account groups expander now has avatar.

 Expander indicator icon changed and renamed, unused theme attributes removed.
parent 3b23b195
......@@ -17,7 +17,6 @@ package com.xabber.android.ui.adapter;
import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.drawable.ColorDrawable;
import android.os.Build;
import android.view.LayoutInflater;
......@@ -29,6 +28,7 @@ import android.widget.TextView;
import com.xabber.android.data.account.AccountItem;
import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.extension.avatar.AvatarManager;
import com.xabber.android.data.roster.AbstractContact;
import com.xabber.android.data.roster.Group;
import com.xabber.android.data.roster.GroupManager;
......@@ -97,8 +97,8 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
private final int activeChatsColor;
private final OnAccountClickListener onAccountClickListener;
public GroupedContactAdapter(Activity activity, ListView listView,
Inflater inflater, StateProvider groupStateProvider, OnAccountClickListener onAccountClickListener) {
public GroupedContactAdapter(Activity activity, ListView listView, Inflater inflater,
StateProvider groupStateProvider, OnAccountClickListener onAccountClickListener) {
super(activity, listView, inflater);
layoutInflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
this.groupStateProvider = groupStateProvider;
......@@ -146,11 +146,6 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
final GroupViewHolder viewHolder;
if (convertView == null) {
view = layoutInflater.inflate(R.layout.base_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 GroupViewHolder(view);
view.setTag(viewHolder);
} else {
......@@ -201,10 +196,6 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
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);
......@@ -215,27 +206,26 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
final AccountConfiguration configuration = (AccountConfiguration) getItem(position);
final String account = configuration.getAccount();
viewHolder.statusIcon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onAccountClickListener.onAccountClick(v, configuration.getAccount());
onAccountClickListener.onAccountClick(v, account);
}
});
final int level = AccountManager.getInstance().getColorLevel(configuration.getAccount());
final int level = AccountManager.getInstance().getColorLevel(account);
view.setBackgroundDrawable(new ColorDrawable(accountColors[level]));
viewHolder.indicator.setImageLevel(configuration.isExpanded() ? 1 : 0);
final String name = GroupManager.getInstance()
.getGroupName(configuration.getAccount(), configuration.getUser());
final String name = GroupManager.getInstance().getGroupName(account, configuration.getUser());
viewHolder.jid.setText(name + " (" + configuration.getOnline()
+ "/" + configuration.getTotal() + ")");
AccountItem accountItem = AccountManager.getInstance().getAccount(configuration.getAccount());
AccountItem accountItem = AccountManager.getInstance().getAccount(account);
viewHolder.avatar.setImageDrawable(AvatarManager.getInstance().getAccountAvatar(account));
viewHolder.statusIcon.setImageLevel(accountItem.getDisplayStatusMode().getStatusLevel());
String statusText = accountItem.getStatusText().trim();
......@@ -441,10 +431,6 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
/**
* Sets whether group in specified account is expanded.
*
* @param account
* @param group Use {@link #IS_ACCOUNT} to set expanded for account.
* @param expanded
*/
public void setExpanded(String account, String group, boolean expanded) {
groupStateProvider.setExpanded(account, group, expanded);
......@@ -467,16 +453,16 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
}
private static class AccountViewHolder {
final ImageView indicator;
final TextView jid;
final TextView status;
final ImageView statusIcon;
final ImageView avatar;
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);
avatar = (ImageView) view.findViewById(R.id.avatar);
}
}
......
<?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/.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/material_blue_grey_900" />
</selector>
<?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/.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@color/material_blue_grey_900" />
</selector>
<?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/.
-->
<level-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/ic_arrow_drop_right_white_24dp" android:minLevel="0" android:maxLevel="0" />
<item android:drawable="@drawable/ic_arrow_drop_down_white_24dp" android:minLevel="1" android:maxLevel="1" />
</level-list>
\ No newline at end of file
......@@ -14,6 +14,6 @@
-->
<level-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/ic_arrow_drop_right_white_24dp" android:minLevel="0" android:maxLevel="0" />
<item android:drawable="@drawable/ic_arrow_drop_down_white_24dp" android:minLevel="1" android:maxLevel="1" />
<item android:drawable="@drawable/ic_expander_indicator_right_black_24dp" android:minLevel="0" android:maxLevel="0" />
<item android:drawable="@drawable/ic_expander_indicator_down_black_24dp" android:minLevel="1" android:maxLevel="1" />
</level-list>
\ No newline at end of file
......@@ -22,11 +22,27 @@
>
<ImageView
android:id="@+id/indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/expander_indicator_dark"
/>
android:id="@+id/account_color_indicator"
android:layout_width="4dp"
android:layout_height="@dimen/avatar_size_toolbar"
android:layout_marginLeft="2dp"
android:layout_marginStart="2dp"
android:layout_marginRight="2dp"
android:layout_marginEnd="2dp"
android:src="@color/red_500"
android:visibility="invisible"
/>
<ImageView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/avatar"
android:layout_width="@dimen/avatar_size_toolbar"
android:layout_height="@dimen/avatar_size_toolbar"
android:src="@drawable/ic_avatar_1"
/>
<LinearLayout
android:layout_width="0dp"
......@@ -34,6 +50,7 @@
android:layout_weight="1"
android:gravity="center_vertical"
android:orientation="vertical"
android:paddingLeft="@dimen/active_chat_padding_left"
>
<TextView
android:id="@+id/account_jid"
......@@ -42,7 +59,10 @@
android:singleLine="true"
android:ellipsize="marquee"
android:text="name@example.com (0/0)"
/>
android:textColor="?android:attr/textColorPrimary"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textStyle="bold"
/>
<TextView
android:id="@+id/account_status"
......@@ -55,6 +75,12 @@
</LinearLayout>
<View
android:layout_width="1px"
android:layout_height="@dimen/avatar_size_toolbar"
android:background="@color/grey_500"
/>
<ImageView
android:id="@+id/account_status_icon"
android:layout_width="wrap_content"
......
......@@ -31,7 +31,6 @@
android:layout_marginRight="2dp"
android:layout_marginEnd="2dp"
android:src="@color/green_500"
/>
<ImageView
......@@ -69,11 +68,12 @@
android:layout_height="@dimen/contact_name_height_show_status"
android:layout_marginRight="@dimen/status_icon_width"
android:gravity="bottom"
android:textStyle="bold"
android:singleLine="true"
android:ellipsize="marquee"
android:text="name"
android:textColor="?android:attr/textColorPrimary"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textStyle="bold"
/>
<TextView
android:id="@+id/status"
......
......@@ -24,10 +24,12 @@
android:id="@+id/indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/expander_indicator_dark"
android:src="@drawable/ic_expander_indicator"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
android:layout_alignParentStart="true"
android:alpha="0.2"
/>
<ImageView
android:id="@+id/group_offline_indicator"
......
<?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/.
-->
<resources>
<declare-styleable name="ContactList">
<attr name="expanderBackground" format="reference" />
<attr name="expanderGroupColor" format="reference" />
<attr name="expanderAccountColor" format="reference" />
<attr name="expanderIndicator" format="reference" />
<attr name="accountBackground" format="reference" />
<attr name="titleMainBackground" format="reference" />
<attr name="titleAccountBackground" format="reference" />
<attr name="textColorPrimaryNoSelected" format="reference" />
</declare-styleable>
</resources>
......@@ -14,9 +14,6 @@
-->
<resources>
<style name="Theme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="expanderGroupColor">?android:attr/textColorPrimary</item>
<item name="expanderAccountColor">?android:attr/textColorPrimaryInverse</item>
<item name="expanderIndicator">@drawable/expander_indicator_dark</item>
<item name="windowActionBar">false</item>
<!--for text selection toolbar to be above usual toolbar -->
......
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