Commit 23446ca3 authored by Grigory Fedorov's avatar Grigory Fedorov

Contact list: groups have light accounts color.

parent af11e288
...@@ -16,9 +16,10 @@ package com.xabber.android.ui.adapter; ...@@ -16,9 +16,10 @@ 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.ColorStateList; import android.content.res.Resources;
import android.content.res.TypedArray; import android.content.res.TypedArray;
import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.ColorDrawable;
import android.os.Build;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
...@@ -73,16 +74,6 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater ...@@ -73,16 +74,6 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
NO_GROUP_LIST = Collections.unmodifiableCollection(groups); NO_GROUP_LIST = Collections.unmodifiableCollection(groups);
} }
/**
* Account's color.
*/
private final ColorStateList expanderAccountTextColor;
/**
* Group's color.
*/
private final ColorStateList expanderGroupTextColor;
/** /**
* Group state provider. * Group state provider.
*/ */
...@@ -93,7 +84,11 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater ...@@ -93,7 +84,11 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
*/ */
private final LayoutInflater layoutInflater; private final LayoutInflater layoutInflater;
private int[] accountActionBarColors; private int[] accountColors;
private final int[] accountSubgroupColors;
private final int accountGroupElevation;
private final int accountSubgroupElevation;
private final int activeChatsColor;
public GroupedContactAdapter(Activity activity, ListView listView, public GroupedContactAdapter(Activity activity, ListView listView,
Inflater inflater, StateProvider groupStateProvider) { Inflater inflater, StateProvider groupStateProvider) {
...@@ -101,13 +96,14 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater ...@@ -101,13 +96,14 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
layoutInflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); layoutInflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
this.groupStateProvider = groupStateProvider; this.groupStateProvider = groupStateProvider;
accountActionBarColors = activity.getResources().getIntArray(R.array.account_action_bar); Resources resources = activity.getResources();
accountColors = resources.getIntArray(R.array.account_action_bar);
accountSubgroupColors = resources.getIntArray(R.array.account_background);
activeChatsColor = resources.getColor(R.color.color_primary_light);
TypedArray typedArray; accountGroupElevation = resources.getDimensionPixelSize(R.dimen.account_group_elevation);
typedArray = activity.getTheme().obtainStyledAttributes(R.styleable.ContactList); accountSubgroupElevation = resources.getDimensionPixelSize(R.dimen.account_subgroup_elevation);
expanderAccountTextColor = typedArray.getColorStateList(R.styleable.ContactList_expanderAccountColor);
expanderGroupTextColor = typedArray.getColorStateList(R.styleable.ContactList_expanderGroupColor);
typedArray.recycle();
} }
@Override @Override
...@@ -150,19 +146,32 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater ...@@ -150,19 +146,32 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
viewHolder = (GroupViewHolder) view.getTag(); viewHolder = (GroupViewHolder) view.getTag();
} }
final GroupConfiguration configuration = (GroupConfiguration) getItem(position); final GroupConfiguration configuration = (GroupConfiguration) getItem(position);
final int level; final int level = AccountManager.getInstance().getColorLevel(configuration.getAccount());
if (configuration instanceof AccountConfiguration) {
level = AccountManager.getInstance().getColorLevel(configuration.getAccount()); final String name = GroupManager.getInstance()
view.setBackgroundDrawable(new ColorDrawable(accountActionBarColors[level])); .getGroupName(configuration.getAccount(), configuration.getUser());
int elevation;
int color;
if (configuration.getUser().equals(GroupManager.ACTIVE_CHATS)) {
color = activeChatsColor;
elevation = accountGroupElevation;
} else if (configuration instanceof AccountConfiguration) {
color = accountColors[level];
elevation = accountGroupElevation;
} else { } else {
view.setBackgroundDrawable( color = accountSubgroupColors[level];
new ColorDrawable(activity.getResources().getColor(R.color.group_expander))); elevation = accountSubgroupElevation;
viewHolder.name.setTextColor(expanderGroupTextColor); }
view.setBackgroundDrawable(new ColorDrawable(color));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
view.setElevation(elevation);
} }
viewHolder.name.getBackground().setLevel(configuration.getShowOfflineMode().ordinal()); viewHolder.name.getBackground().setLevel(configuration.getShowOfflineMode().ordinal());
final String name = GroupManager.getInstance().getGroupName(
configuration.getAccount(), configuration.getUser());
viewHolder.name.setText(name + " (" + configuration.getOnline() viewHolder.name.setText(name + " (" + configuration.getOnline()
+ "/" + configuration.getTotal() + ")"); + "/" + configuration.getTotal() + ")");
viewHolder.indicator.setImageLevel(configuration.isExpanded() ? 1 : 0); viewHolder.indicator.setImageLevel(configuration.isExpanded() ? 1 : 0);
......
...@@ -34,6 +34,20 @@ ...@@ -34,6 +34,20 @@
<item>@color/teal_700</item> <item>@color/teal_700</item>
</array> </array>
<array name="account_background">
<item>@color/green_100</item>
<item>@color/orange_100</item>
<item>@color/red_100</item>
<item>@color/blue_100</item>
<item>@color/indigo_100</item>
<item>@color/blue_grey_100</item>
<item>@color/cyan_100</item>
<item>@color/teal_100</item>
</array>
<color name="color_primary_light">@color/red_100</color>
<color name="account_disabled">@color/black_dividers</color> <color name="account_disabled">@color/black_dividers</color>
<color name="group_expander">@color/blue_grey_100</color> <color name="group_expander">@color/blue_grey_100</color>
</resources> </resources>
\ No newline at end of file
...@@ -9,4 +9,7 @@ ...@@ -9,4 +9,7 @@
<dimen name="avatar_large_size">72dp</dimen> <dimen name="avatar_large_size">72dp</dimen>
<dimen name="avatar_normal_size">48dp</dimen> <dimen name="avatar_normal_size">48dp</dimen>
<dimen name="avatar_radius">56dp</dimen> <dimen name="avatar_radius">56dp</dimen>
<dimen name="account_group_elevation">2dp</dimen>
<dimen name="account_subgroup_elevation">1dp</dimen>
</resources> </resources>
\ No newline at end of file
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