Commit c038a3df authored by Grigory Fedorov's avatar Grigory Fedorov

Drawer header image added. Title text style changed.

parent b3215cb0
...@@ -15,6 +15,7 @@ import android.widget.ListView; ...@@ -15,6 +15,7 @@ import android.widget.ListView;
import com.xabber.android.data.Application; import com.xabber.android.data.Application;
import com.xabber.android.data.account.OnAccountChangedListener; import com.xabber.android.data.account.OnAccountChangedListener;
import com.xabber.android.ui.adapter.NavigationDrawerAccountAdapter; import com.xabber.android.ui.adapter.NavigationDrawerAccountAdapter;
import com.xabber.android.ui.helper.AccountPainter;
import com.xabber.androiddev.R; import com.xabber.androiddev.R;
import java.util.Collection; import java.util.Collection;
...@@ -26,6 +27,7 @@ public class ContactListDrawerFragment extends Fragment implements View.OnClickL ...@@ -26,6 +27,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;
@Override @Override
public void onAttach(Activity activity) { public void onAttach(Activity activity) {
...@@ -38,6 +40,7 @@ public class ContactListDrawerFragment extends Fragment implements View.OnClickL ...@@ -38,6 +40,7 @@ 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);
listView = (ListView) view.findViewById(R.id.drawer_account_list); listView = (ListView) view.findViewById(R.id.drawer_account_list);
...@@ -69,15 +72,7 @@ public class ContactListDrawerFragment extends Fragment implements View.OnClickL ...@@ -69,15 +72,7 @@ public class ContactListDrawerFragment extends Fragment implements View.OnClickL
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
Application.getInstance().addUIListener(OnAccountChangedListener.class, this); Application.getInstance().addUIListener(OnAccountChangedListener.class, this);
adapter.onChange(); update();
if (adapter.getCount() == 0) {
headerTitle.setVisibility(View.GONE);
divider.setVisibility(View.GONE);
} else {
headerTitle.setVisibility(View.VISIBLE);
divider.setVisibility(View.VISIBLE);
}
} }
@Override @Override
...@@ -99,7 +94,20 @@ public class ContactListDrawerFragment extends Fragment implements View.OnClickL ...@@ -99,7 +94,20 @@ public class ContactListDrawerFragment extends Fragment implements View.OnClickL
@Override @Override
public void onAccountsChanged(Collection<String> accounts) { public void onAccountsChanged(Collection<String> accounts) {
update();
}
private void update() {
adapter.onChange(); adapter.onChange();
drawerHeader.getBackground().setLevel(AccountPainter.getDefaultAccountColorLevel());
if (adapter.getCount() == 0) {
headerTitle.setVisibility(View.GONE);
divider.setVisibility(View.GONE);
} else {
headerTitle.setVisibility(View.VISIBLE);
divider.setVisibility(View.VISIBLE);
}
} }
@Override @Override
......
...@@ -40,6 +40,19 @@ public class AccountPainter { ...@@ -40,6 +40,19 @@ public class AccountPainter {
} }
} }
private static int getAccountColorLevel(String account) {
return AccountManager.getInstance().getColorLevel(account);
}
public static int getDefaultAccountColorLevel() {
String firstAccount = getFirstAccount();
if (firstAccount == null) {
return 5;
} else {
return getAccountColorLevel(firstAccount);
}
}
private int getThemeMainColor(Context context) { private int getThemeMainColor(Context context) {
TypedArray a = context.getTheme().obtainStyledAttributes(R.style.Theme, new int[]{R.attr.colorPrimary}); TypedArray a = context.getTheme().obtainStyledAttributes(R.style.Theme, new int[]{R.attr.colorPrimary});
int attributeResourceId = a.getResourceId(0, 0); int attributeResourceId = a.getResourceId(0, 0);
...@@ -55,7 +68,7 @@ public class AccountPainter { ...@@ -55,7 +68,7 @@ public class AccountPainter {
} }
public int getAccountMainColor(String account) { public int getAccountMainColor(String account) {
return accountMainColors[AccountManager.getInstance().getColorLevel(account)]; return accountMainColors[getAccountColorLevel(account)];
} }
public int getDefaultMainColor() { public int getDefaultMainColor() {
...@@ -68,7 +81,7 @@ public class AccountPainter { ...@@ -68,7 +81,7 @@ public class AccountPainter {
} }
public int getAccountDarkColor(String account) { public int getAccountDarkColor(String account) {
return accountDarkColors[AccountManager.getInstance().getColorLevel(account)]; return accountDarkColors[getAccountColorLevel(account)];
} }
public int getDefaultDarkColor() { public int getDefaultDarkColor() {
......
<?xml version="1.0" encoding="utf-8"?>
<level-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@drawable/drawer_green"
android:maxLevel="0"
android:minLevel="0" />
<item
android:drawable="@drawable/drawer_orange"
android:maxLevel="1"
android:minLevel="1" />
<item
android:drawable="@drawable/drawer_red"
android:maxLevel="2"
android:minLevel="2" />
<item
android:drawable="@drawable/drawer_blue"
android:maxLevel="3"
android:minLevel="3" />
<item
android:drawable="@drawable/drawer_indigo"
android:maxLevel="4"
android:minLevel="4" />
<item
android:drawable="@drawable/drawer_blue_grey"
android:maxLevel="5"
android:minLevel="5" />
<item
android:drawable="@drawable/drawer_cyan"
android:maxLevel="6"
android:minLevel="6" />
<item
android:drawable="@drawable/drawer_teal"
android:maxLevel="7"
android:minLevel="7" />
</level-list>
\ No newline at end of file
...@@ -7,9 +7,10 @@ ...@@ -7,9 +7,10 @@
android:orientation="vertical"> android:orientation="vertical">
<RelativeLayout <RelativeLayout
android:id="@+id/drawer_header"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="170dp" android:layout_height="170dp"
android:background="@color/grey_300"> android:background="@drawable/drawer_image">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -28,8 +29,13 @@ ...@@ -28,8 +29,13 @@
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:shadowColor="@color/grey_700"
android:shadowDx="1"
android:shadowDy="1"
android:shadowRadius="2"
android:text="@string/production_title" android:text="@string/production_title"
android:textSize="32sp" /> android:textColor="@color/grey_50"
android:textSize="40sp" />
</LinearLayout> </LinearLayout>
</RelativeLayout> </RelativeLayout>
......
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