-
Notifications
You must be signed in to change notification settings - Fork 963
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed the Options menu and placed all items within the Drawer pullout panel. Updated the UI of the pullout panel and sectioned off items to increase usability.
1 parent
2702971
commit 90d5cfb
Showing
11 changed files
with
475 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 115 additions & 0 deletions
115
app/src/main/java/com/SecUpwN/AIMSICD/adapters/DrawerMenuAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
package com.SecUpwN.AIMSICD.adapters; | ||
|
||
import com.SecUpwN.AIMSICD.AIMSICD.NavDrawerItem; | ||
import com.SecUpwN.AIMSICD.R; | ||
import com.SecUpwN.AIMSICD.fragments.DrawerMenuItem; | ||
import com.SecUpwN.AIMSICD.fragments.DrawerMenuSection; | ||
|
||
import android.content.Context; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.ArrayAdapter; | ||
import android.widget.ImageView; | ||
import android.widget.TextView; | ||
|
||
public class DrawerMenuAdapter extends ArrayAdapter<NavDrawerItem> { | ||
private LayoutInflater inflater; | ||
|
||
public DrawerMenuAdapter(Context context, int textViewResourceId, NavDrawerItem[] objects ) { | ||
super(context, textViewResourceId, objects); | ||
this.inflater = LayoutInflater.from(context); | ||
} | ||
|
||
@Override | ||
public View getView(int position, View convertView, ViewGroup parent) { | ||
View view = null ; | ||
NavDrawerItem menuItem = this.getItem(position); | ||
if ( menuItem.getType() == DrawerMenuItem.ITEM_TYPE ) { | ||
view = getItemView(convertView, parent, menuItem ); | ||
} | ||
else { | ||
view = getSectionView(convertView, parent, menuItem); | ||
} | ||
return view ; | ||
} | ||
|
||
public View getItemView( View convertView, ViewGroup parentView, NavDrawerItem navDrawerItem ) { | ||
|
||
DrawerMenuItem menuItem = (DrawerMenuItem) navDrawerItem ; | ||
NavMenuItemHolder navMenuItemHolder = null; | ||
|
||
if (convertView == null) { | ||
convertView = inflater.inflate( R.layout.drawer_item, parentView, false); | ||
TextView labelView = (TextView) convertView | ||
.findViewById( R.id.drawer_menu_item_label ); | ||
ImageView iconView = (ImageView) convertView | ||
.findViewById( R.id.drawer_menu_item_icon ); | ||
|
||
navMenuItemHolder = new NavMenuItemHolder(); | ||
navMenuItemHolder.labelView = labelView ; | ||
navMenuItemHolder.iconView = iconView ; | ||
|
||
convertView.setTag(navMenuItemHolder); | ||
} | ||
|
||
if ( navMenuItemHolder == null ) { | ||
navMenuItemHolder = (NavMenuItemHolder) convertView.getTag(); | ||
} | ||
|
||
navMenuItemHolder.labelView.setText(menuItem.getLabel()); | ||
navMenuItemHolder.iconView.setImageResource(menuItem.getIcon()); | ||
|
||
return convertView ; | ||
} | ||
|
||
public View getSectionView(View convertView, ViewGroup parentView, | ||
NavDrawerItem navDrawerItem) { | ||
|
||
DrawerMenuSection menuSection = (DrawerMenuSection) navDrawerItem ; | ||
NavMenuSectionHolder navMenuItemHolder = null; | ||
|
||
if (convertView == null) { | ||
convertView = inflater.inflate( R.layout.drawer_section, parentView, false); | ||
TextView labelView = (TextView) convertView | ||
.findViewById( R.id.drawer_menu_section_label ); | ||
|
||
navMenuItemHolder = new NavMenuSectionHolder(); | ||
navMenuItemHolder.labelView = labelView ; | ||
convertView.setTag(navMenuItemHolder); | ||
} | ||
|
||
if ( navMenuItemHolder == null ) { | ||
navMenuItemHolder = (NavMenuSectionHolder) convertView.getTag(); | ||
} | ||
|
||
navMenuItemHolder.labelView.setText(menuSection.getLabel()); | ||
|
||
return convertView ; | ||
} | ||
|
||
@Override | ||
public int getViewTypeCount() { | ||
return 2; | ||
} | ||
|
||
@Override | ||
public int getItemViewType(int position) { | ||
return this.getItem(position).getType(); | ||
} | ||
|
||
@Override | ||
public boolean isEnabled(int position) { | ||
return getItem(position).isEnabled(); | ||
} | ||
|
||
|
||
private static class NavMenuItemHolder { | ||
private TextView labelView; | ||
private ImageView iconView; | ||
} | ||
|
||
private class NavMenuSectionHolder { | ||
private TextView labelView; | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
app/src/main/java/com/SecUpwN/AIMSICD/fragments/DrawerMenuItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package com.SecUpwN.AIMSICD.fragments; | ||
|
||
import com.SecUpwN.AIMSICD.AIMSICD.NavDrawerItem; | ||
|
||
import android.content.Context; | ||
|
||
public class DrawerMenuItem implements NavDrawerItem { | ||
|
||
public static final int ITEM_TYPE = 1 ; | ||
|
||
private int id ; | ||
private String label ; | ||
private int icon ; | ||
private boolean updateActionBarTitle ; | ||
|
||
private DrawerMenuItem() { | ||
} | ||
|
||
public static DrawerMenuItem create( int id, String label, String icon, boolean updateActionBarTitle, Context context ) { | ||
DrawerMenuItem item = new DrawerMenuItem(); | ||
item.setId(id); | ||
item.setLabel(label); | ||
item.setIcon(context.getResources().getIdentifier( icon, "drawable", context.getPackageName())); | ||
item.setUpdateActionBarTitle(updateActionBarTitle); | ||
return item; | ||
} | ||
|
||
@Override | ||
public int getType() { | ||
return ITEM_TYPE; | ||
} | ||
|
||
public int getId() { | ||
return id; | ||
} | ||
|
||
public void setId(int id) { | ||
this.id = id; | ||
} | ||
|
||
public String getLabel() { | ||
return label; | ||
} | ||
|
||
public void setLabel(String label) { | ||
this.label = label; | ||
} | ||
|
||
public int getIcon() { | ||
return icon; | ||
} | ||
|
||
public void setIcon(int icon) { | ||
this.icon = icon; | ||
} | ||
|
||
@Override | ||
public boolean isEnabled() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean updateActionBarTitle() { | ||
return this.updateActionBarTitle; | ||
} | ||
|
||
public void setUpdateActionBarTitle(boolean updateActionBarTitle) { | ||
this.updateActionBarTitle = updateActionBarTitle; | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
app/src/main/java/com/SecUpwN/AIMSICD/fragments/DrawerMenuSection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.SecUpwN.AIMSICD.fragments; | ||
|
||
import com.SecUpwN.AIMSICD.AIMSICD.NavDrawerItem; | ||
|
||
public class DrawerMenuSection implements NavDrawerItem { | ||
|
||
public static final int SECTION_TYPE = 0; | ||
private int id; | ||
private String label; | ||
|
||
private DrawerMenuSection() { | ||
} | ||
|
||
public static DrawerMenuSection create( int id, String label ) { | ||
DrawerMenuSection section = new DrawerMenuSection(); | ||
section.setLabel(label); | ||
return section; | ||
} | ||
|
||
@Override | ||
public int getType() { | ||
return SECTION_TYPE; | ||
} | ||
|
||
public String getLabel() { | ||
return label; | ||
} | ||
|
||
public void setLabel(String label) { | ||
this.label = label; | ||
} | ||
|
||
@Override | ||
public boolean isEnabled() { | ||
return false; | ||
} | ||
|
||
public int getId() { | ||
return id; | ||
} | ||
|
||
public void setId(int id) { | ||
this.id = id; | ||
} | ||
|
||
@Override | ||
public boolean updateActionBarTitle() { | ||
return false; | ||
} | ||
} |
82 changes: 82 additions & 0 deletions
82
app/src/main/java/com/SecUpwN/AIMSICD/utils/DrawerMenuActivityConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package com.SecUpwN.AIMSICD.utils; | ||
|
||
import com.SecUpwN.AIMSICD.AIMSICD.NavDrawerItem; | ||
|
||
import android.widget.BaseAdapter; | ||
|
||
public class DrawerMenuActivityConfiguration { | ||
|
||
private int mainLayout; | ||
private int drawerLayoutId; | ||
private int leftDrawerId; | ||
private int[] actionMenuItemsToHideWhenDrawerOpen; | ||
private NavDrawerItem[] navItems; | ||
private int drawerOpenDesc; | ||
private int drawerCloseDesc; | ||
private BaseAdapter baseAdapter; | ||
|
||
public int getMainLayout() { | ||
return mainLayout; | ||
} | ||
|
||
public void setMainLayout(int mainLayout) { | ||
this.mainLayout = mainLayout; | ||
} | ||
|
||
public int getDrawerLayoutId() { | ||
return drawerLayoutId; | ||
} | ||
|
||
public void setDrawerLayoutId(int drawerLayoutId) { | ||
this.drawerLayoutId = drawerLayoutId; | ||
} | ||
|
||
public int getLeftDrawerId() { | ||
return leftDrawerId; | ||
} | ||
|
||
public void setLeftDrawerId(int leftDrawerId) { | ||
this.leftDrawerId = leftDrawerId; | ||
} | ||
|
||
public int[] getActionMenuItemsToHideWhenDrawerOpen() { | ||
return actionMenuItemsToHideWhenDrawerOpen; | ||
} | ||
|
||
public void setActionMenuItemsToHideWhenDrawerOpen( | ||
int[] actionMenuItemsToHideWhenDrawerOpen) { | ||
this.actionMenuItemsToHideWhenDrawerOpen = actionMenuItemsToHideWhenDrawerOpen; | ||
} | ||
|
||
public NavDrawerItem[] getNavItems() { | ||
return navItems; | ||
} | ||
|
||
public void setNavItems(NavDrawerItem[] navItems) { | ||
this.navItems = navItems; | ||
} | ||
|
||
public int getDrawerOpenDesc() { | ||
return drawerOpenDesc; | ||
} | ||
|
||
public void setDrawerOpenDesc(int drawerOpenDesc) { | ||
this.drawerOpenDesc = drawerOpenDesc; | ||
} | ||
|
||
public int getDrawerCloseDesc() { | ||
return drawerCloseDesc; | ||
} | ||
|
||
public void setDrawerCloseDesc(int drawerCloseDesc) { | ||
this.drawerCloseDesc = drawerCloseDesc; | ||
} | ||
|
||
public BaseAdapter getBaseAdapter() { | ||
return baseAdapter; | ||
} | ||
|
||
public void setBaseAdapter(BaseAdapter baseAdapter) { | ||
this.baseAdapter = baseAdapter; | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<RelativeLayout 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:textAppearance="?android:attr/textAppearanceListItemSmall" | ||
android:gravity="center_vertical" | ||
android:paddingRight="10dp" | ||
android:minHeight="?android:attr/listPreferredItemHeightSmall" | ||
> | ||
|
||
<ImageView | ||
android:id="@+id/drawer_menu_item_icon" | ||
android:layout_width="wrap_content" | ||
android:layout_height="30dp" | ||
android:layout_centerVertical="true" | ||
android:paddingLeft="15dp" android:contentDescription="icon"/> | ||
|
||
<TextView | ||
android:id="@+id/drawer_menu_item_label" | ||
android:layout_width="match_parent" | ||
android:layout_height="50dp" | ||
android:layout_toRightOf="@id/drawer_menu_item_icon" | ||
android:gravity="center_vertical" | ||
android:text="TextView" | ||
android:textColor="#FFFFFF"/> | ||
|
||
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content"> | ||
|
||
<TextView | ||
android:id="@+id/drawer_menu_section_label" | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content" | ||
android:text="Section" | ||
android:textSize="18sp" | ||
android:paddingTop="7dp" | ||
android:paddingBottom="7dp" | ||
android:textColor="#FFFFFF" | ||
style="?android:attr/listSeparatorTextViewStyle"/> | ||
|
||
</RelativeLayout> |
This file was deleted.
Oops, something went wrong.