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