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