Commit a1e95b4f authored by Grigory Fedorov's avatar Grigory Fedorov

Account group expander: offline contacts indicator always shown, conacts...

Account group expander: offline contacts indicator always shown, conacts number shown on second line.
parent a45e49d0
...@@ -26,6 +26,7 @@ import android.widget.ImageView; ...@@ -26,6 +26,7 @@ import android.widget.ImageView;
import android.widget.ListView; import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
import com.xabber.android.data.SettingsManager;
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.extension.avatar.AvatarManager;
...@@ -218,16 +219,10 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater ...@@ -218,16 +219,10 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
final int level = AccountManager.getInstance().getColorLevel(account); final int level = AccountManager.getInstance().getColorLevel(account);
view.setBackgroundDrawable(new ColorDrawable(accountColors[level])); view.setBackgroundDrawable(new ColorDrawable(accountColors[level]));
final String name = GroupManager.getInstance().getGroupName(account, configuration.getUser()); viewHolder.jid.setText(GroupManager.getInstance().getGroupName(account, configuration.getUser()));
viewHolder.contactCounter.setText(configuration.getOnline() + "/" + configuration.getTotal());
viewHolder.jid.setText(name + " (" + configuration.getOnline()
+ "/" + configuration.getTotal() + ")");
AccountItem accountItem = AccountManager.getInstance().getAccount(account); AccountItem accountItem = AccountManager.getInstance().getAccount(account);
viewHolder.avatar.setImageDrawable(AvatarManager.getInstance().getAccountAvatar(account));
viewHolder.statusIcon.setImageLevel(accountItem.getDisplayStatusMode().getStatusLevel());
String statusText = accountItem.getStatusText().trim(); String statusText = accountItem.getStatusText().trim();
if (statusText.isEmpty()) { if (statusText.isEmpty()) {
...@@ -236,6 +231,20 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater ...@@ -236,6 +231,20 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
viewHolder.status.setText(statusText); viewHolder.status.setText(statusText);
viewHolder.avatar.setImageDrawable(AvatarManager.getInstance().getAccountAvatar(account));
viewHolder.statusIcon.setImageLevel(accountItem.getDisplayStatusMode().getStatusLevel());
ShowOfflineMode showOfflineMode = configuration.getShowOfflineMode();
if (showOfflineMode == ShowOfflineMode.normal) {
if (SettingsManager.contactsShowOffline()) {
showOfflineMode = ShowOfflineMode.always;
} else {
showOfflineMode = ShowOfflineMode.never;
}
}
viewHolder.offlineContactsIndicator.setImageLevel(showOfflineMode.ordinal());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
view.setElevation(accountGroupElevation); view.setElevation(accountGroupElevation);
} }
...@@ -455,14 +464,21 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater ...@@ -455,14 +464,21 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
private static class AccountViewHolder { private static class AccountViewHolder {
final TextView jid; final TextView jid;
final TextView status; final TextView status;
final TextView contactCounter;
final ImageView statusIcon; final ImageView statusIcon;
final ImageView avatar; final ImageView avatar;
final ImageView offlineContactsIndicator;
public AccountViewHolder(View view) { public AccountViewHolder(View view) {
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);
contactCounter = (TextView) view.findViewById(R.id.contact_counter);
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); avatar = (ImageView) view.findViewById(R.id.avatar);
offlineContactsIndicator = (ImageView) view.findViewById(R.id.offline_contacts_indicator);
} }
} }
......
...@@ -58,20 +58,48 @@ ...@@ -58,20 +58,48 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:singleLine="true" android:singleLine="true"
android:ellipsize="marquee" android:ellipsize="marquee"
android:text="name@example.com (0/0)" android:text="name@example.com"
android:textColor="?android:attr/textColorPrimary" android:textColor="?android:attr/textColorPrimary"
android:textAppearance="?android:attr/textAppearanceSmall" android:textAppearance="?android:attr/textAppearanceSmall"
android:textStyle="bold" android:textStyle="bold"
/> />
<TextView <LinearLayout
android:id="@+id/account_status"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:singleLine="true" android:orientation="horizontal"
android:ellipsize="marquee" >
android:text="Online"
/> <ImageView
android:id="@+id/offline_contacts_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_show_offline"
android:layout_gravity="center_horizontal"
android:alpha="0.2"
/>
<TextView
android:id="@+id/contact_counter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="marquee"
android:text="3/9"
android:paddingLeft="4dp"
android:paddingRight="6dp"
/>
<TextView
android:id="@+id/account_status"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="marquee"
android:text="Online"
/>
</LinearLayout>
</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