Tweak navigation drawer

- make list thinner
- highlight current pane
- show icons in menu
This commit is contained in:
fkloft 2013-09-22 21:27:38 +02:00
parent b83b6a56f8
commit 358c809d07
3 changed files with 39 additions and 3 deletions

View File

@ -18,11 +18,10 @@
android:src="@drawable/iitc"/>
<!-- The navigation drawer -->
<!-- TODO: change color/width? -->
<ListView
android:id="@+id/left_drawer"
android:layout_width="240dp"
android:layout_width="180dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#111"

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/activatedBackgroundIndicator"
android:drawablePadding="?android:attr/listPreferredItemPaddingLeft"
android:gravity="center_vertical"
android:minHeight="?android:attr/listPreferredItemHeightSmall"
android:paddingLeft="?android:attr/listPreferredItemPaddingLeft"
android:paddingRight="?android:attr/listPreferredItemPaddingRight"
android:textAppearance="?android:attr/textAppearanceListItemSmall"/>

View File

@ -50,7 +50,7 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnNa
private class NavigationAdapter extends ArrayAdapter<Pane> {
public NavigationAdapter() {
super(mIitc, android.R.layout.simple_list_item_1);
super(mIitc, R.layout.list_item_selectable);
add(Pane.MAP);
add(Pane.INFO);
@ -71,6 +71,27 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnNa
view.setText("Map");
else
view.setText(getPaneTitle(item));
int icon = 0;
switch (item)
{
case MAP:
icon = R.drawable.location_map;
break;
case INFO:
icon = R.drawable.action_about;
break;
case FULL:
case COMPACT:
case PUBLIC:
case FACTION:
icon = R.drawable.social_group;
break;
}
if (icon != 0)
view.setCompoundDrawablesWithIntrinsicBounds(icon, 0, 0, 0);
return view;
}
}
@ -111,6 +132,7 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnNa
mNavigationAdapter = new NavigationAdapter();
mDrawerList.setAdapter(mNavigationAdapter);
mDrawerList.setOnItemClickListener(this);
mDrawerList.setItemChecked(0, true);
mDrawerLayout.setDrawerListener(this);
onPrefChanged(); // also calls updateActionBar()
@ -119,6 +141,10 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnNa
private void updateActionBar() {
boolean showHighlighter = true;
int position = mNavigationAdapter.getPosition(mPane);
if (position >= 0 && position < mNavigationAdapter.getCount())
mDrawerList.setItemChecked(position, true);
if (mDesktopMode) {
mActionBar.setDisplayHomeAsUpEnabled(false); // Hide "up" indicator
mActionBar.setHomeButtonEnabled(false); // Make icon unclickable