Commit b0ac3a7d authored by Grigory Fedorov's avatar Grigory Fedorov

Chat and Recent chats fragments toolbar color set brighter in tablet mode. AccountPainter modified.

parent 0accf923
......@@ -372,7 +372,7 @@ public class ChatViewerFragment extends Fragment implements PopupMenu.OnMenuItem
public void updateChat() {
ContactTitleInflater.updateTitle(contactTitleView, getActivity(), abstractContact);
toolbar.setBackgroundColor(accountPainter.getAccountMainColor(account));
setToolbarColor();
int itemCountBeforeUpdate = chatMessageAdapter.getItemCount();
chatMessageAdapter.onChange();
scrollChat(itemCountBeforeUpdate);
......@@ -380,6 +380,16 @@ public class ChatViewerFragment extends Fragment implements PopupMenu.OnMenuItem
updateSecurityButton();
}
private void setToolbarColor() {
int toolbarColor;
if (getResources().getBoolean(R.bool.tablet_mode)) {
toolbarColor = accountPainter.getAccountLightColor(account);
} else {
toolbarColor = accountPainter.getAccountMainColor(account);
}
toolbar.setBackgroundColor(toolbarColor);
}
private void scrollChat(int itemCountBeforeUpdate) {
int lastVisibleItemPosition = layoutManager.findLastVisibleItemPosition();
if (lastVisibleItemPosition == -1 || lastVisibleItemPosition == (itemCountBeforeUpdate - 1)) {
......
......@@ -89,7 +89,17 @@ public class RecentChatFragment extends ListFragment implements Toolbar.OnMenuIt
if (null != listener.getChatScroller()) {
listener.getChatScroller().registerRecentChatsList(this);
}
toolbar.setBackgroundColor(accountPainter.getDefaultMainColor());
setToolbarColor();
}
private void setToolbarColor() {
int toolbarColor;
if (getResources().getBoolean(R.bool.tablet_mode)) {
toolbarColor = accountPainter.getDefaultLightColor();
} else {
toolbarColor = accountPainter.getDefaultMainColor();
}
toolbar.setBackgroundColor(toolbarColor);
}
@Override
......
......@@ -19,12 +19,18 @@ public class AccountPainter {
private int[] accountDarkColors;
private int[] accountDarkestColors;
private int[] accountLightColors;
private int[] accountLightestColors;
public AccountPainter(Context context) {
accountMainColors = context.getResources().getIntArray(R.array.account_action_bar);
accountDarkColors = context.getResources().getIntArray(R.array.account_status_bar);
accountDarkestColors = context.getResources().getIntArray(R.array.account_900);
accountLightColors = context.getResources().getIntArray(R.array.account_200);
accountLightestColors = context.getResources().getIntArray(R.array.account_50);
accountColorNames = context.getResources().getStringArray(R.array.account_color_names);
themeMainColor = getThemeMainColor(context);
......@@ -82,6 +88,15 @@ public class AccountPainter {
}
}
public int getDefaultLightColor() {
String firstAccount = getFirstAccount();
if (firstAccount == null) {
return themeMainColor;
} else {
return getAccountLightColor(firstAccount);
}
}
public int getAccountDarkColor(String account) {
return accountDarkColors[getAccountColorLevel(account)];
}
......@@ -90,6 +105,13 @@ public class AccountPainter {
return accountDarkestColors[getAccountColorLevel(account)];
}
public int getAccountLightColor(String account) {
return accountLightColors[getAccountColorLevel(account)];
}
public int getAccountLightestColor(String account) {
return accountLightestColors[getAccountColorLevel(account)];
}
public int getDefaultDarkColor() {
String firstAccount = getFirstAccount();
......
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