Commit 3296aa30 authored by Grigory Fedorov's avatar Grigory Fedorov

Navigation drawer UI changed. #449

parent d6387788
...@@ -10,6 +10,7 @@ import android.view.LayoutInflater; ...@@ -10,6 +10,7 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.ListView; import android.widget.ListView;
import com.xabber.android.R; import com.xabber.android.R;
...@@ -27,7 +28,7 @@ public class ContactListDrawerFragment extends Fragment implements View.OnClickL ...@@ -27,7 +28,7 @@ public class ContactListDrawerFragment extends Fragment implements View.OnClickL
private ListView listView; private ListView listView;
private View divider; private View divider;
private View headerTitle; private View headerTitle;
private View drawerHeader; private ImageView drawerHeaderImage;
@Override @Override
public void onAttach(Activity activity) { public void onAttach(Activity activity) {
...@@ -40,7 +41,8 @@ public class ContactListDrawerFragment extends Fragment implements View.OnClickL ...@@ -40,7 +41,8 @@ public class ContactListDrawerFragment extends Fragment implements View.OnClickL
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.contact_list_drawer, container, false); View view = inflater.inflate(R.layout.contact_list_drawer, container, false);
drawerHeader = view.findViewById(R.id.drawer_header); View drawerHeader = view.findViewById(R.id.drawer_header);
drawerHeaderImage = (ImageView) drawerHeader.findViewById(R.id.drawer_header_image);
listView = (ListView) view.findViewById(R.id.drawer_account_list); listView = (ListView) view.findViewById(R.id.drawer_account_list);
...@@ -99,7 +101,7 @@ public class ContactListDrawerFragment extends Fragment implements View.OnClickL ...@@ -99,7 +101,7 @@ public class ContactListDrawerFragment extends Fragment implements View.OnClickL
private void update() { private void update() {
adapter.onChange(); adapter.onChange();
drawerHeader.getBackground().setLevel(AccountPainter.getDefaultAccountColorLevel()); drawerHeaderImage.setImageLevel(AccountPainter.getDefaultAccountColorLevel());
if (adapter.getCount() == 0) { if (adapter.getCount() == 0) {
headerTitle.setVisibility(View.GONE); headerTitle.setVisibility(View.GONE);
......
...@@ -12,6 +12,8 @@ import com.xabber.android.data.account.AccountItem; ...@@ -12,6 +12,8 @@ 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.connection.ConnectionState; import com.xabber.android.data.connection.ConnectionState;
import com.xabber.android.data.extension.avatar.AvatarManager; import com.xabber.android.data.extension.avatar.AvatarManager;
import com.xabber.android.data.roster.RosterManager;
import com.xabber.android.ui.helper.AccountPainter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
...@@ -20,12 +22,11 @@ import java.util.List; ...@@ -20,12 +22,11 @@ import java.util.List;
public class NavigationDrawerAccountAdapter extends BaseListEditorAdapter<String> { public class NavigationDrawerAccountAdapter extends BaseListEditorAdapter<String> {
private final int[] accountColors; private final AccountPainter accountPainter;
public NavigationDrawerAccountAdapter(Activity activity) { public NavigationDrawerAccountAdapter(Activity activity) {
super(activity); super(activity);
accountPainter = new AccountPainter(activity);
accountColors = activity.getResources().getIntArray(R.array.account_action_bar);
} }
@Override @Override
...@@ -39,13 +40,16 @@ public class NavigationDrawerAccountAdapter extends BaseListEditorAdapter<String ...@@ -39,13 +40,16 @@ public class NavigationDrawerAccountAdapter extends BaseListEditorAdapter<String
} }
String account = getItem(position); String account = getItem(position);
int accountColor = accountColors[accountManager.getColorLevel(account)]; ((ImageView) view.findViewById(R.id.color)).setImageDrawable(new ColorDrawable((accountPainter.getAccountMainColor(account))));
((ImageView) view.findViewById(R.id.avatar)).setImageDrawable(AvatarManager.getInstance().getAccountAvatar(account));
TextView accountName = (TextView) view.findViewById(R.id.name);
accountName.setText(RosterManager.getInstance().getBestContact(account, accountManager.getVerboseName(account)).getName());
accountName.setTextColor(accountPainter.getAccountDarkColor(account));
((ImageView) view.findViewById(R.id.color)).setImageDrawable(new ColorDrawable(accountColor)); ((TextView) view.findViewById(R.id.account_jid)).setText(accountManager.getVerboseName(account));
((ImageView) view.findViewById(R.id.avatar))
.setImageDrawable(AvatarManager.getInstance().getAccountAvatar(account));
((TextView) view.findViewById(R.id.name)).setText(accountManager.getVerboseName(account));
AccountItem accountItem = accountManager.getAccount(account); AccountItem accountItem = accountManager.getAccount(account);
ConnectionState state; ConnectionState state;
if (accountItem == null) { if (accountItem == null) {
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@android:color/background_light" android:background="@android:color/background_light"
android:clickable="true" android:clickable="true"
android:orientation="vertical"> android:orientation="vertical">
<RelativeLayout <FrameLayout
android:id="@+id/drawer_header" android:id="@+id/drawer_header"
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="170dp" android:layout_height="wrap_content">
android:background="@drawable/drawer_image">
<ImageView
android:id="@+id/drawer_header_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/drawer_image" />
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -19,26 +25,49 @@ ...@@ -19,26 +25,49 @@
<ImageView <ImageView
android:id="@+id/imageView" android:id="@+id/imageView"
android:layout_width="wrap_content" android:layout_width="64dp"
android:layout_height="wrap_content" android:layout_height="64dp"
android:layout_marginLeft="8dp" android:layout_marginLeft="8dp"
android:src="@drawable/ic_connect" /> android:src="@drawable/ic_connect" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="8dp">
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_margin="0dp"
android:shadowColor="@color/grey_700" android:shadowColor="@color/grey_700"
android:shadowDx="1" android:shadowDx="1"
android:shadowDy="1" android:shadowDy="1"
android:shadowRadius="2" android:shadowRadius="2"
android:text="@string/application_title_short" android:text="@string/application_title_short"
android:textColor="@color/grey_50" android:textColor="@color/grey_50"
android:textSize="40sp" /> android:textSize="24sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginTop="-8dp"
android:shadowColor="@color/grey_700"
android:shadowDx="1"
android:shadowDy="1"
android:shadowRadius="2"
android:text="@string/about_open_source_xmpp_client"
android:textColor="@color/grey_300"
android:textSize="12sp" />
</LinearLayout>
</LinearLayout> </LinearLayout>
</RelativeLayout> </FrameLayout>
<ListView <ListView
android:id="@+id/drawer_account_list" android:id="@+id/drawer_account_list"
...@@ -46,5 +75,7 @@ ...@@ -46,5 +75,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:divider="@null" android:divider="@null"
android:dividerHeight="0dp" android:dividerHeight="0dp"
/> tools:listfooter="@layout/contact_list_drawer_footer"
tools:listheader="@layout/contact_list_drawer_header"
tools:listitem="@layout/contact_list_drawer_account_item" />
</LinearLayout> </LinearLayout>
\ No newline at end of file
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
--> -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="48dp" android:layout_height="64dp"
android:paddingLeft="10dp" android:paddingLeft="10dp"
android:paddingRight="16dp"> android:paddingRight="16dp">
...@@ -24,14 +24,14 @@ ...@@ -24,14 +24,14 @@
<de.hdodenhof.circleimageview.CircleImageView xmlns:app="http://schemas.android.com/apk/res-auto" <de.hdodenhof.circleimageview.CircleImageView xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/color" android:id="@+id/color"
android:layout_width="36dp" android:layout_width="40dp"
android:layout_height="36dp" android:layout_height="40dp"
android:src="@color/green_500" /> android:src="@color/green_500" />
<de.hdodenhof.circleimageview.CircleImageView xmlns:app="http://schemas.android.com/apk/res-auto" <de.hdodenhof.circleimageview.CircleImageView xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/avatar" android:id="@+id/avatar"
android:layout_width="36dp" android:layout_width="40dp"
android:layout_height="36dp" android:layout_height="40dp"
android:src="@drawable/ic_avatar_1" android:src="@drawable/ic_avatar_1"
app:border_color="@android:color/transparent" app:border_color="@android:color/transparent"
app:border_width="3dp" /> app:border_width="3dp" />
...@@ -40,10 +40,11 @@ ...@@ -40,10 +40,11 @@
<LinearLayout <LinearLayout
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1" android:layout_weight="1"
android:orientation="vertical" android:orientation="vertical"
android:paddingLeft="26dp"> android:paddingLeft="22dp">
<TextView <TextView
android:id="@+id/name" android:id="@+id/name"
...@@ -51,11 +52,23 @@ ...@@ -51,11 +52,23 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:ellipsize="marquee" android:ellipsize="marquee"
android:gravity="bottom"
android:singleLine="true" android:singleLine="true"
android:text="test" android:text="Some Name"
android:textColor="?android:attr/textColorPrimary" android:textColor="@color/green_700"
android:textStyle="bold" /> android:textSize="18sp" />
<TextView
android:id="@+id/account_jid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="-2dp"
android:layout_marginTop="-4dp"
android:layout_weight="1"
android:ellipsize="marquee"
android:singleLine="true"
android:text="example@example.com"
android:textColor="@color/grey_500"
android:textSize="14sp" />
<TextView <TextView
android:id="@+id/status" android:id="@+id/status"
...@@ -65,7 +78,7 @@ ...@@ -65,7 +78,7 @@
android:ellipsize="marquee" android:ellipsize="marquee"
android:gravity="top" android:gravity="top"
android:singleLine="true" android:singleLine="true"
android:text="@android:string/cancel" android:text="Online"
android:textColor="?android:attr/textColorSecondary" /> android:textColor="?android:attr/textColorSecondary" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
...@@ -9,4 +9,6 @@ ...@@ -9,4 +9,6 @@
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/about_viewer.png --> <!-- http://dl.dropbox.com/u/1029995/com.xabber.android/about_viewer.png -->
<string name="about_version">Версия: %s</string> <string name="about_version">Версия: %s</string>
<string name="about_license">Лицензия: GNU GPLv3\n<a href="https://github.com/redsolution/xabber-android">Программное обеспечение с открытым исходным кодом</a></string> <string name="about_license">Лицензия: GNU GPLv3\n<a href="https://github.com/redsolution/xabber-android">Программное обеспечение с открытым исходным кодом</a></string>
<string name="about_open_source_xmpp_client">open source XMPP client</string>
</resources> </resources>
\ No newline at end of file
...@@ -9,4 +9,6 @@ ...@@ -9,4 +9,6 @@
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/about_viewer.png --> <!-- http://dl.dropbox.com/u/1029995/com.xabber.android/about_viewer.png -->
<string name="about_version">Version: %s</string> <string name="about_version">Version: %s</string>
<string name="about_license">License: GNU GPLv3\n<a href="https://github.com/redsolution/xabber-android">Open source software</a></string> <string name="about_license">License: GNU GPLv3\n<a href="https://github.com/redsolution/xabber-android">Open source software</a></string>
<string name="about_open_source_xmpp_client">open source XMPP client</string>
</resources> </resources>
\ 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