Commit e346bc80 authored by Grigory Fedorov's avatar Grigory Fedorov

Chats scroll indicators colored into the chat's account color (new icons).

parent 028edf9d
...@@ -122,7 +122,7 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener ...@@ -122,7 +122,7 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
chatScrollIndicatorAdapter = new ChatScrollIndicatorAdapter(this, chatScrollIndicatorAdapter = new ChatScrollIndicatorAdapter(this,
(LinearLayout)findViewById(R.id.chat_scroll_indicator)); (LinearLayout)findViewById(R.id.chat_scroll_indicator));
chatScrollIndicatorAdapter.update(chatViewerAdapter.getRealCount()); chatScrollIndicatorAdapter.update(chatViewerAdapter.getActiveChats());
viewPager = (ViewPager) findViewById(R.id.pager); viewPager = (ViewPager) findViewById(R.id.pager);
viewPager.setAdapter(chatViewerAdapter); viewPager.setAdapter(chatViewerAdapter);
...@@ -139,7 +139,8 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener ...@@ -139,7 +139,8 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
return; return;
chatViewerAdapter.updateChats(); chatViewerAdapter.updateChats();
chatScrollIndicatorAdapter.update(chatViewerAdapter.getRealCount()); ;
chatScrollIndicatorAdapter.update(chatViewerAdapter.getActiveChats());
String account = getAccount(intent); String account = getAccount(intent);
String user = getUser(intent); String user = getUser(intent);
...@@ -212,7 +213,7 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener ...@@ -212,7 +213,7 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
if (chatViewerAdapter.updateChats()) { if (chatViewerAdapter.updateChats()) {
selectPage(currentAccount, currentUser, false); selectPage(currentAccount, currentUser, false);
chatScrollIndicatorAdapter.update(chatViewerAdapter.getRealCount()); chatScrollIndicatorAdapter.update(chatViewerAdapter.getActiveChats());
} else { } else {
updateRegisteredChats(); updateRegisteredChats();
......
package com.xabber.android.ui.adapter; package com.xabber.android.ui.adapter;
import android.app.Activity; import android.app.Activity;
import android.graphics.drawable.ColorDrawable;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.message.AbstractChat;
import com.xabber.androiddev.R; import com.xabber.androiddev.R;
import java.util.ArrayList;
public class ChatScrollIndicatorAdapter { public class ChatScrollIndicatorAdapter {
private final Activity activity; private final Activity activity;
...@@ -29,37 +32,44 @@ public class ChatScrollIndicatorAdapter { ...@@ -29,37 +32,44 @@ public class ChatScrollIndicatorAdapter {
} }
} }
public void update(int size) { public void update(ArrayList<AbstractChat> activeChats) {
final LayoutInflater inflater final LayoutInflater inflater
= (LayoutInflater) activity.getSystemService(Activity.LAYOUT_INFLATER_SERVICE); = (LayoutInflater) activity.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
while (linearLayout.getChildCount() < size) { final int size = activeChats.size() + 1;
linearLayout.removeAllViews();
for (int i = 0; i < size; i++) {
View view; View view;
if (linearLayout.getChildCount() == 0) { if (i == 0) {
view = inflater.inflate(R.layout.chat_scroll_indicator_item_square, linearLayout, false); view = inflater.inflate(R.layout.chat_scroll_indicator_item_square, linearLayout, false);
} else { } else {
view = inflater.inflate(R.layout.chat_scroll_indicator_item_circle, linearLayout, false); view = inflater.inflate(R.layout.chat_scroll_indicator_item_circle, linearLayout, false);
} }
linearLayout.addView(view); linearLayout.addView(view);
final AccountViewHolder accountViewHolder = new AccountViewHolder(view); final AccountViewHolder accountViewHolder = new AccountViewHolder(view);
view.setTag(accountViewHolder); if (i > 0) {
int colorLevel = AccountManager.getInstance().getColorLevel(activeChats.get(i - 1).getAccount());
accountViewHolder.body.setImageLevel(colorLevel);
accountViewHolder.selection.setImageLevel(colorLevel);
} }
while (linearLayout.getChildCount() > size) { view.setTag(accountViewHolder);
linearLayout.removeViewAt(size);
} }
} }
private static class AccountViewHolder { private static class AccountViewHolder {
final View body; final ImageView body;
final View selection; final ImageView selection;
public AccountViewHolder(View view) { public AccountViewHolder(View view) {
body = view.findViewById(R.id.indicator_item_body); body = (ImageView) view.findViewById(R.id.indicator_item_body);
selection = view.findViewById(R.id.indicator_item_selection); selection = (ImageView) view.findViewById(R.id.indicator_item_selection);
} }
} }
} }
<level-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/ic_scroll_indicator_circle_green_12dp" android:minLevel="0" android:maxLevel="0" />
<item android:drawable="@drawable/ic_scroll_indicator_circle_orange_12dp" android:minLevel="1" android:maxLevel="1" />
<item android:drawable="@drawable/ic_scroll_indicator_circle_red_12dp" android:minLevel="2" android:maxLevel="2" />
<item android:drawable="@drawable/ic_scroll_indicator_circle_blue_12dp" android:minLevel="3" android:maxLevel="3" />
<item android:drawable="@drawable/ic_scroll_indicator_circle_indigo_12dp" android:minLevel="4" android:maxLevel="4" />
<item android:drawable="@drawable/ic_scroll_indicator_circle_blue_grey_12dp" android:minLevel="5" android:maxLevel="5" />
<item android:drawable="@drawable/ic_scroll_indicator_circle_cyan_12dp" android:minLevel="6" android:maxLevel="6" />
<item android:drawable="@drawable/ic_scroll_indicator_circle_teal_12dp" android:minLevel="7" android:maxLevel="7" />
</level-list>
\ No newline at end of file
<level-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/ic_scroll_indicator_circle_green_8dp" android:minLevel="0" android:maxLevel="0" />
<item android:drawable="@drawable/ic_scroll_indicator_circle_orange_8dp" android:minLevel="1" android:maxLevel="1" />
<item android:drawable="@drawable/ic_scroll_indicator_circle_red_8dp" android:minLevel="2" android:maxLevel="2" />
<item android:drawable="@drawable/ic_scroll_indicator_circle_blue_8dp" android:minLevel="3" android:maxLevel="3" />
<item android:drawable="@drawable/ic_scroll_indicator_circle_indigo_8dp" android:minLevel="4" android:maxLevel="4" />
<item android:drawable="@drawable/ic_scroll_indicator_circle_blue_grey_8dp" android:minLevel="5" android:maxLevel="5" />
<item android:drawable="@drawable/ic_scroll_indicator_circle_cyan_8dp" android:minLevel="6" android:maxLevel="6" />
<item android:drawable="@drawable/ic_scroll_indicator_circle_teal_8dp" android:minLevel="7" android:maxLevel="7" />
</level-list>
\ No newline at end of file
...@@ -13,15 +13,17 @@ ...@@ -13,15 +13,17 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="2dp" android:layout_margin="2dp"
android:src="@drawable/ic_scroll_indicator_circle_8dp" android:src="@drawable/ic_scroll_indicator_circle_small"
android:alpha="0.5"
/> />
<ImageView <ImageView
android:id="@+id/indicator_item_selection" android:id="@+id/indicator_item_selection"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:src="@drawable/ic_scroll_indicator_circle_12dp" android:src="@drawable/ic_scroll_indicator_circle_large"
android:visibility="gone" android:visibility="gone"
android:alpha="0.5"
/> />
</RelativeLayout> </RelativeLayout>
\ 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