Commit aac1f6b4 authored by Grigory Fedorov's avatar Grigory Fedorov

Default account avatars generation improved (not additional background used on layouts).

parent 36f4150b
...@@ -28,6 +28,7 @@ import com.xabber.android.data.OnLoadListener; ...@@ -28,6 +28,7 @@ import com.xabber.android.data.OnLoadListener;
import com.xabber.android.data.OnLowMemoryListener; import com.xabber.android.data.OnLowMemoryListener;
import com.xabber.android.data.SettingsManager; 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.OAuthManager; import com.xabber.android.data.account.OAuthManager;
import com.xabber.android.data.connection.ConnectionItem; import com.xabber.android.data.connection.ConnectionItem;
import com.xabber.android.data.connection.OnPacketListener; import com.xabber.android.data.connection.OnPacketListener;
...@@ -108,6 +109,8 @@ public class AvatarManager implements OnLoadListener, OnLowMemoryListener, OnPac ...@@ -108,6 +109,8 @@ public class AvatarManager implements OnLoadListener, OnLowMemoryListener, OnPac
Application.getInstance().addManager(instance); Application.getInstance().addManager(instance);
} }
private final int[] accountColors;
public static AvatarManager getInstance() { public static AvatarManager getInstance() {
return instance; return instance;
} }
...@@ -116,6 +119,9 @@ public class AvatarManager implements OnLoadListener, OnLowMemoryListener, OnPac ...@@ -116,6 +119,9 @@ public class AvatarManager implements OnLoadListener, OnLowMemoryListener, OnPac
this.application = Application.getInstance(); this.application = Application.getInstance();
userAvatarSet = new BaseAvatarSet(application, R.array.default_avatars_icons, R.array.default_avatars_colors); userAvatarSet = new BaseAvatarSet(application, R.array.default_avatars_icons, R.array.default_avatars_colors);
roomAvatarSet = new BaseAvatarSet(application, R.array.muc_avatars, R.array.default_avatars_colors); roomAvatarSet = new BaseAvatarSet(application, R.array.muc_avatars, R.array.default_avatars_colors);
accountColors = application.getResources().getIntArray(R.array.account_action_bar);
hashes = new HashMap<>(); hashes = new HashMap<>();
bitmaps = new HashMap<>(); bitmaps = new HashMap<>();
contactListDrawables = new HashMap<>(); contactListDrawables = new HashMap<>();
...@@ -269,7 +275,10 @@ public class AvatarManager implements OnLoadListener, OnLowMemoryListener, OnPac ...@@ -269,7 +275,10 @@ public class AvatarManager implements OnLoadListener, OnLowMemoryListener, OnPac
if (value != null) { if (value != null) {
return new BitmapDrawable(application.getResources(), value); return new BitmapDrawable(application.getResources(), value);
} else { } else {
return application.getResources().getDrawable(R.drawable.ic_avatar_1); Drawable[] layers = new Drawable[2];
layers[0] = new ColorDrawable(accountColors[AccountManager.getInstance().getColorLevel(account)]);
layers[1] = application.getResources().getDrawable(R.drawable.ic_avatar_1);
return new LayerDrawable(layers);
} }
} }
......
...@@ -43,8 +43,7 @@ public class AccountChooseAdapter extends BaseAdapter { ...@@ -43,8 +43,7 @@ public class AccountChooseAdapter extends BaseAdapter {
public AccountChooseAdapter(Activity activity) { public AccountChooseAdapter(Activity activity) {
super(); super();
this.activity = activity; this.activity = activity;
accounts = new ArrayList<String>(AccountManager.getInstance() accounts = new ArrayList<>(AccountManager.getInstance().getAccounts());
.getAccounts());
Collections.sort(accounts); Collections.sort(accounts);
accountColors = activity.getResources().getIntArray(R.array.account_action_bar); accountColors = activity.getResources().getIntArray(R.array.account_action_bar);
...@@ -99,13 +98,10 @@ public class AccountChooseAdapter extends BaseAdapter { ...@@ -99,13 +98,10 @@ public class AccountChooseAdapter extends BaseAdapter {
} }
final String account = (String) getItem(position); final String account = (String) getItem(position);
int accountColor = accountColors[accountManager.getColorLevel(account)];
((ImageView) view.findViewById(R.id.avatar_background)).setImageDrawable(new ColorDrawable(accountColor));
((ImageView) view.findViewById(R.id.avatar)) ((ImageView) view.findViewById(R.id.avatar))
.setImageDrawable(AvatarManager.getInstance().getAccountAvatar(account)); .setImageDrawable(AvatarManager.getInstance().getAccountAvatar(account));
((TextView) view.findViewById(R.id.name)).setText(accountManager ((TextView) view.findViewById(R.id.name)).setText(accountManager.getVerboseName(account));
.getVerboseName(account));
return view; return view;
} }
......
...@@ -61,7 +61,6 @@ public class AccountListAdapter extends BaseListEditorAdapter<String> { ...@@ -61,7 +61,6 @@ public class AccountListAdapter extends BaseListEditorAdapter<String> {
int accountColor = accountColors[accountManager.getColorLevel(account)]; int accountColor = accountColors[accountManager.getColorLevel(account)];
((ImageView) view.findViewById(R.id.color)).setImageDrawable(new ColorDrawable(accountColor)); ((ImageView) view.findViewById(R.id.color)).setImageDrawable(new ColorDrawable(accountColor));
((ImageView) view.findViewById(R.id.avatar_background)).setImageDrawable(new ColorDrawable(accountColor));
((ImageView) view.findViewById(R.id.avatar)) ((ImageView) view.findViewById(R.id.avatar))
.setImageDrawable(AvatarManager.getInstance().getAccountAvatar(account)); .setImageDrawable(AvatarManager.getInstance().getAccountAvatar(account));
......
...@@ -6,13 +6,6 @@ ...@@ -6,13 +6,6 @@
android:layout_height="@dimen/avatar_size_toolbar" android:layout_height="@dimen/avatar_size_toolbar"
android:id="@+id/avatar_account" android:id="@+id/avatar_account"
> >
<ImageView
android:id="@+id/avatar_background"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@color/material_deep_teal_500" />
<ImageView <ImageView
android:id="@+id/avatar" android:id="@+id/avatar"
android:layout_width="match_parent" android:layout_width="match_parent"
......
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