Permalink
Browse files

Merge branch 'feature/navigation_drawer' into develop

  • Loading branch information...
2 parents cb19cc9 + ad4274b commit 93c0cd6d11e13b1a034b00ed38c0c29ff91bdd6b @codestream committed Feb 16, 2014
Showing with 541 additions and 9 deletions.
  1. +4 −0 Scrumboard/build.gradle
  2. +2 −1 Scrumboard/src/main/AndroidManifest.xml
  3. BIN Scrumboard/src/main/assets/fonts/Roboto-Black.ttf
  4. BIN Scrumboard/src/main/assets/fonts/Roboto-BlackItalic.ttf
  5. BIN Scrumboard/src/main/assets/fonts/Roboto-Bold.ttf
  6. BIN Scrumboard/src/main/assets/fonts/Roboto-BoldItalic.ttf
  7. BIN Scrumboard/src/main/assets/fonts/Roboto-Italic.ttf
  8. BIN Scrumboard/src/main/assets/fonts/Roboto-Light.ttf
  9. BIN Scrumboard/src/main/assets/fonts/Roboto-LightItalic.ttf
  10. BIN Scrumboard/src/main/assets/fonts/Roboto-Medium.ttf
  11. BIN Scrumboard/src/main/assets/fonts/Roboto-MediumItalic.ttf
  12. BIN Scrumboard/src/main/assets/fonts/Roboto-Regular.ttf
  13. BIN Scrumboard/src/main/assets/fonts/Roboto-Thin.ttf
  14. BIN Scrumboard/src/main/assets/fonts/Roboto-ThinItalic.ttf
  15. +182 −4 Scrumboard/src/main/java/com/scrumboard/MainActivity.java
  16. +20 −0 Scrumboard/src/main/java/com/scrumboard/ScrumBoardApplication.java
  17. +80 −0 Scrumboard/src/main/java/com/scrumboard/models/modules/NavigationDrawerItem.java
  18. +80 −0 Scrumboard/src/main/java/com/scrumboard/ui/adapter/NavigationDrawerAdapter.java
  19. +26 −0 Scrumboard/src/main/java/com/scrumboard/ui/widget/RobotoTextView.java
  20. +28 −0 Scrumboard/src/main/java/com/scrumboard/util/Injector.java
  21. BIN Scrumboard/src/main/res/drawable-hdpi/ic_drawer.png
  22. BIN Scrumboard/src/main/res/drawable-mdpi/ic_drawer.png
  23. BIN Scrumboard/src/main/res/drawable-xhdpi/ic_drawer.png
  24. +19 −0 Scrumboard/src/main/res/drawable/counter_bg.xml
  25. +7 −0 Scrumboard/src/main/res/drawable/list_item_bg_normal.xml
  26. +7 −0 Scrumboard/src/main/res/drawable/list_item_bg_pressed.xml
  27. +8 −0 Scrumboard/src/main/res/drawable/list_selector.xml
  28. +21 −3 Scrumboard/src/main/res/layout/activity_main.xml
  29. +36 −0 Scrumboard/src/main/res/layout/drawer_layout_items.xml
  30. +9 −0 Scrumboard/src/main/res/values/color.xml
  31. +12 −1 Scrumboard/src/main/res/values/strings.xml
View
@@ -24,4 +24,8 @@ android {
dependencies {
compile 'com.squareup.dagger:dagger:1.2.0'
+ compile 'com.jakewharton:butterknife:4.0.1'
+ compile 'de.greenrobot:eventbus:2.0.+'
+ compile 'com.android.support:support-v4:18.0.0'
+ compile 'com.squareup.dagger:dagger-compiler:1.1.0'
}
@@ -12,7 +12,8 @@
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
- android:theme="@style/CustomActionBarTheme" >
+ android:theme="@style/CustomActionBarTheme"
+ android:name=".ScrumBoardApplication">
<activity
android:name="com.scrumboard.MainActivity"
android:label="@string/app_name" >
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,21 +1,199 @@
package com.scrumboard;
import android.app.Activity;
-import android.app.ActionBar;
import android.app.Fragment;
+import android.app.FragmentManager;
+import android.content.res.Configuration;
+import android.content.res.TypedArray;
import android.os.Bundle;
-import android.view.LayoutInflater;
+import android.support.v4.app.ActionBarDrawerToggle;
+import android.support.v4.widget.DrawerLayout;
+import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
-import android.view.ViewGroup;
-import android.os.Build;
+import android.widget.AdapterView;
+import android.widget.ListView;
+
+import com.scrumboard.models.modules.NavigationDrawerItem;
+import com.scrumboard.ui.adapter.NavigationDrawerAdapter;
+
+import java.util.ArrayList;
+
+import javax.inject.Inject;
public class MainActivity extends Activity {
+ @Inject
+ NavigationDrawerAdapter adapter;
+
+ private DrawerLayout mDrawerLayout;
+ private ListView mDrawerList;
+ private ActionBarDrawerToggle mDrawerToggle;
+
+ // nav drawer title
+ private CharSequence mDrawerTitle;
+
+ // used to store app title
+ private CharSequence mTitle;
+
+ // slide menu items
+ private String[] navMenuTitles;
+ private TypedArray navMenuIcons;
+
+ private ArrayList<NavigationDrawerItem> navDrawerItems;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
+ mTitle = mDrawerTitle = getTitle();
+
+ // load slide menu items
+ navMenuTitles = getResources().getStringArray(R.array.nav_drawer_items);
+
+ // nav drawer icons from resources
+ navMenuIcons = getResources()
+ .obtainTypedArray(R.array.nav_drawer_icons);
+
+ mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
+ mDrawerList = (ListView) findViewById(R.id.list_slidermenu);
+
+ navDrawerItems = new ArrayList<NavigationDrawerItem>();
+
+ navDrawerItems.add(new NavigationDrawerItem(navMenuTitles[0], navMenuIcons.getResourceId(0, -1)));
+ navDrawerItems.add(new NavigationDrawerItem(navMenuTitles[1], navMenuIcons.getResourceId(1, -1)));
+ navDrawerItems.add(new NavigationDrawerItem(navMenuTitles[2], navMenuIcons.getResourceId(2, -1)));
+ navDrawerItems.add(new NavigationDrawerItem(navMenuTitles[3], navMenuIcons.getResourceId(3, -1)));
+
+ navMenuIcons.recycle();
+
+ mDrawerList.setOnItemClickListener(new SlideMenuClickListener());
+
+ // setting the nav drawer list adapter
+ adapter = new NavigationDrawerAdapter(getApplicationContext(),
+ navDrawerItems);
+ mDrawerList.setAdapter(adapter);
+
+ // enabling action bar app icon and behaving it as toggle button
+ getActionBar().setDisplayHomeAsUpEnabled(true);
+ getActionBar().setHomeButtonEnabled(true);
+
+ mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
+ R.drawable.ic_drawer, //nav menu toggle icon
+ R.string.app_name, // nav drawer open - description for accessibility
+ R.string.app_name // nav drawer close - description for accessibility
+ ) {
+ public void onDrawerClosed(View view) {
+ getActionBar().setTitle(mTitle);
+ // calling onPrepareOptionsMenu() to show action bar icons
+ invalidateOptionsMenu();
+ }
+
+ public void onDrawerOpened(View drawerView) {
+ getActionBar().setTitle(mDrawerTitle);
+ // calling onPrepareOptionsMenu() to hide action bar icons
+ invalidateOptionsMenu();
+ }
+ };
+ mDrawerLayout.setDrawerListener(mDrawerToggle);
+
+ if (savedInstanceState == null) {
+ // on first time display view for first nav item
+ displayView(0);
+ }
+ }
+
+ /**
+ * Slide menu item click listener
+ * */
+ private class SlideMenuClickListener implements
+ ListView.OnItemClickListener {
+ @Override
+ public void onItemClick(AdapterView<?> parent, View view, int position,
+ long id) {
+ // display view for selected nav drawer item
+ displayView(position);
+ }
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ // toggle nav drawer on selecting action bar app icon/title
+ if (mDrawerToggle.onOptionsItemSelected(item)) {
+ return true;
+ }
+ // Handle action bar actions click
+ switch (item.getItemId()) {
+ case R.id.action_settings:
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
+ }
+ }
+
+ /* *
+ * Called when invalidateOptionsMenu() is triggered
+ */
+ @Override
+ public boolean onPrepareOptionsMenu(Menu menu) {
+ // if nav drawer is opened, hide the action items
+ boolean drawerOpen = mDrawerLayout.isDrawerOpen(mDrawerList);
+ menu.findItem(R.id.action_settings).setVisible(!drawerOpen);
+ return super.onPrepareOptionsMenu(menu);
+ }
+
+ /**
+ * Diplaying fragment view for selected nav drawer list item
+ * */
+ private void displayView(int position) {
+ // update the main content by replacing fragments
+ Fragment fragment = null;
+
+ if (fragment != null) {
+ FragmentManager fragmentManager = getFragmentManager();
+ fragmentManager.beginTransaction()
+ .replace(R.id.frame_container, fragment).commit();
+
+ // update selected item and title, then close the drawer
+ mDrawerList.setItemChecked(position, true);
+ mDrawerList.setSelection(position);
+ setTitle(navMenuTitles[position]);
+ mDrawerLayout.closeDrawer(mDrawerList);
+ } else {
+ // error in creating fragment
+ Log.e("MainActivity", "Error in creating fragment");
+ }
+ }
+
+ @Override
+ public void setTitle(CharSequence title) {
+ mTitle = title;
+ getActionBar().setTitle(mTitle);
+ }
+
+ /**
+ * When using the ActionBarDrawerToggle, you must call it during
+ * onPostCreate() and onConfigurationChanged()...
+ */
+
+ @Override
+ protected void onPostCreate(Bundle savedInstanceState) {
+ super.onPostCreate(savedInstanceState);
+ // Sync the toggle state after onRestoreInstanceState has occurred.
+ mDrawerToggle.syncState();
+ }
+
+ @Override
+ public void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ // Pass any configuration change to the drawer toggls
+ mDrawerToggle.onConfigurationChanged(newConfig);
}
}
@@ -0,0 +1,20 @@
+package com.scrumboard;
+
+import android.app.Application;
+
+public class ScrumBoardApplication extends Application {
+
+ /**
+ * Called when the application is starting, before any activity, service,
+ * or receiver objects (excluding content providers) have been created.
+ * Implementations should be as quick as possible (for example using
+ * lazy initialization of state) since the time spent in this function
+ * directly impacts the performance of starting the first activity,
+ * service, or receiver in a process.
+ * If you override this method, be sure to call super.onCreate().
+ */
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ }
+}
@@ -0,0 +1,80 @@
+package com.scrumboard.models.modules;
+
+public class NavigationDrawerItem {
+
+ private String mDrawerItemTitle;
+ private int mDrawerItemIcon;
+ private String mCount = "0";
+ // boolean to set visibility of the counter
+ private boolean isCounterVisible = false;
+
+ public NavigationDrawerItem(){}
+
+ public NavigationDrawerItem(String title, int icon, boolean isCounterVisible, String count){
+ this.mDrawerItemTitle = title;
+ this.mDrawerItemIcon = icon;
+ this.isCounterVisible = isCounterVisible;
+ this.mCount = count;
+ }
+
+ public NavigationDrawerItem(String title, int icon){
+ this.mDrawerItemTitle = title;
+ this.mDrawerItemIcon = icon;
+ }
+
+ public String getDrawerItemTitle() {
+ return mDrawerItemTitle;
+ }
+
+ public void setDrawerItemTitle(String mDrawerItemTitle) {
+ this.mDrawerItemTitle = mDrawerItemTitle;
+ }
+
+ public int getDrawerItemIcon() {
+ return mDrawerItemIcon;
+ }
+
+ public void setDrawerItemIcon(int mDrawerItemIcon) {
+ this.mDrawerItemIcon = mDrawerItemIcon;
+ }
+
+ public String getCount() {
+ return mCount;
+ }
+
+ public void setCount(String mCount) {
+ this.mCount = mCount;
+ }
+
+ public boolean isCounterVisible() {
+ return isCounterVisible;
+ }
+
+ public void setCounterVisible(boolean isCounterVisible) {
+ this.isCounterVisible = isCounterVisible;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof NavigationDrawerItem)) return false;
+
+ NavigationDrawerItem that = (NavigationDrawerItem) o;
+
+ if (isCounterVisible != that.isCounterVisible) return false;
+ if (mDrawerItemIcon != that.mDrawerItemIcon) return false;
+ if (!mCount.equals(that.mCount)) return false;
+ if (!mDrawerItemTitle.equals(that.mDrawerItemTitle)) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = mDrawerItemTitle.hashCode();
+ result = 31 * result + mDrawerItemIcon;
+ result = 31 * result + mCount.hashCode();
+ result = 31 * result + (isCounterVisible ? 1 : 0);
+ return result;
+ }
+}
Oops, something went wrong.

0 comments on commit 93c0cd6

Please sign in to comment.