Gallery2: Replace hamburger menu with bottom bar

Change-Id: I20caa58fe11ee6f4148cb0bcb0ccbcdcf3a9612e
Signed-off-by: Joey Rizzoli <joey@cyanogenmoditalia.it>
diff --git a/Android.mk b/Android.mk
index bd22166..9519c72 100644
--- a/Android.mk
+++ b/Android.mk
@@ -7,6 +7,7 @@
 LOCAL_JAVA_LIBRARIES := telephony-common
 
 LOCAL_STATIC_ANDROID_LIBRARIES := \
+    $(ANDROID_SUPPORT_DESIGN_TARGETS) \
     androidx.heifwriter_heifwriter \
     android-support-fragment \
     android-support-core-ui \
diff --git a/res/drawable/ic_album.xml b/res/drawable/ic_album.xml
new file mode 100644
index 0000000..3f0cfa2
--- /dev/null
+++ b/res/drawable/ic_album.xml
@@ -0,0 +1,9 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+        android:width="24dp"
+        android:height="24dp"
+        android:viewportWidth="24.0"
+        android:viewportHeight="24.0">
+    <path
+        android:fillColor="@color/tab_icon_2"
+        android:pathData="M17.999,2h-12c-1.1,0 -2,0.9 -2,2v16c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2V4C19.999,2.9 19.099,2 17.999,2zM5.999,4h5v8l-2.5,-1.5l-2.5,1.5V4zM5.999,19l3,-3.859l2.141,2.58l3,-3.861L17.999,19H5.999z"/>
+</vector>
diff --git a/res/drawable/ic_timeline.xml b/res/drawable/ic_timeline.xml
new file mode 100644
index 0000000..7c30ffa
--- /dev/null
+++ b/res/drawable/ic_timeline.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="24dp"
+    android:height="24dp"
+    android:viewportWidth="24"
+    android:viewportHeight="24">
+
+    <path
+        android:fillColor="@color/tab_icon_1"
+        android:pathData="M9.45605,12.4586 L16.2515,12.4586 L16.2515,19.7214 L9.45608,19.7214 Z M20,8 L4,8
+L4,6 L20,6 L20,8 Z M18,2 L6,2 L6,4 L18,4 L18,2 Z M22,12 L22,20
+C22,21.1,21.1,22,20,22 L4,22 C2.9,22,2,21.1,2,20 L2,12 C2,10.9,2.9,10,4,10
+L20,10 C21.1,10,22,10.9,22,12 Z M16,16 L10,12.73 L10,19.26 L16,16 Z" />
+</vector>
diff --git a/res/drawable/ic_video.xml b/res/drawable/ic_video.xml
new file mode 100644
index 0000000..1904d8b
--- /dev/null
+++ b/res/drawable/ic_video.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="24dp"
+    android:height="24dp"
+    android:viewportWidth="24"
+    android:viewportHeight="24">
+
+    <path
+        android:fillColor="@color/tab_icon_3"
+        android:pathData="M18,4 L20,8 L17,8 L15,4 L13,4 L15,8 L12,8 L10,4 L8,4 L10,8 L7,8 L5,4 L4,4
+C2.9,4,2.01,4.9,2.01,6 L2,18 C2,19.1,2.9,20,4,20 L20,20 C21.1,20,22,19.1,22,18
+L22,4 L18,4 Z" />
+</vector>
diff --git a/res/drawable/item_bg.xml b/res/drawable/item_bg.xml
new file mode 100644
index 0000000..d518cbf
--- /dev/null
+++ b/res/drawable/item_bg.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:color="@color/navigation_accent_enabled" android:state_checked="true" />
+    <item android:color="@color/navigation_accent_disabled" />
+</selector>
diff --git a/res/layout/gallery_main.xml b/res/layout/gallery_main.xml
index 677c5b6..cd47ee3 100755
--- a/res/layout/gallery_main.xml
+++ b/res/layout/gallery_main.xml
@@ -28,68 +28,42 @@
   IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 -->
 
-<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
     android:id="@+id/drawerLayout"
+    android:orientation="vertical"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:fitsSystemWindows="true">
 
-    <!-- MAIN CONTENT -->
-
     <RelativeLayout
-        android:id="@+id/gallery_root"
         android:layout_width="match_parent"
-        android:layout_height="match_parent" >
+        android:layout_height="match_parent">
 
-        <include layout="@layout/gl_root_group" />
-    </RelativeLayout>
-
-    <LinearLayout
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:orientation="vertical" >
-
-        <include
-            android:id="@+id/toolbar"
-            layout="@layout/toolbar" />
-    </LinearLayout>
-
-    <RelativeLayout
-        android:id="@+id/drawerPane"
-        android:layout_width="270dp"
-        android:layout_height="match_parent"
-        android:layout_gravity="start"
-        android:background="@color/white"
-        android:clickable="true" >
-
-        <!-- Header -->
-
+        <!-- MAIN CONTENT -->
         <RelativeLayout
-            android:id="@+id/header"
+            android:id="@+id/gallery_root"
             android:layout_width="match_parent"
-            android:layout_height="150dp"
-            android:background="@drawable/drawer_bg" >
+            android:layout_height="match_parent">
 
-            <TextView
-                android:id="@+id/appName"
-                android:layout_width="wrap_content"
+            <android.support.design.widget.BottomNavigationView
+                android:id="@+id/bottom_navigation"
+                android:elevation="8dp"
+                android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 android:layout_alignParentBottom="true"
-                android:layout_marginBottom="16dp"
-                android:layout_marginStart="16dp"
-                android:fontFamily="sans-serif"
-                android:text="@string/navigation_drawer_title"
-                android:textColor="@color/white"
-                android:textSize="24sp" />
+                app:menu="@menu/navigation_items"
+                app:itemBackground="@color/primary"
+                app:itemIconTint="@drawable/item_bg"
+                app:itemTextColor="@drawable/item_bg" />
+
+            <include layout="@layout/gl_root_group"/>
         </RelativeLayout>
 
-        <ListView
-            android:id="@+id/navList"
-            android:layout_width="270dp"
-            android:layout_height="match_parent"
-            android:layout_below="@id/header"
-            android:layout_marginTop="4dp"
-            android:divider="@android:color/transparent" />
+        <!-- This layout will overlap all the others -->
+        <include
+            android:id="@+id/toolbar"
+            layout="@layout/toolbar"  />
     </RelativeLayout>
-
-</android.support.v4.widget.DrawerLayout>
\ No newline at end of file
+</LinearLayout>
diff --git a/res/layout/gl_root_group.xml b/res/layout/gl_root_group.xml
index de0f66a..eee2b49 100644
--- a/res/layout/gl_root_group.xml
+++ b/res/layout/gl_root_group.xml
@@ -15,13 +15,19 @@
 -->
 
 <merge xmlns:android="http://schemas.android.com/apk/res/android">
-    <com.android.gallery3d.ui.GLRootView
+
+    <RelativeLayout
+        android:id="@+id/gl_parent_layout"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:layout_marginBottom="56dp">
+        <com.android.gallery3d.ui.GLRootView
             android:id="@+id/gl_root_view"
             android:layout_width="match_parent"
             android:layout_height="match_parent"/>
+    </RelativeLayout>
     <View android:id="@+id/gl_root_cover"
             android:layout_width="match_parent"
             android:layout_height="match_parent"
-            android:background="#fafafa"
-           />
+            android:background="#fafafa"/>
 </merge>
diff --git a/res/menu/navigation_items.xml b/res/menu/navigation_items.xml
new file mode 100644
index 0000000..b4f39dc
--- /dev/null
+++ b/res/menu/navigation_items.xml
@@ -0,0 +1,11 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+     <item android:id="@+id/action_timeline"
+          android:title="@string/timeline_title"
+          android:icon="@drawable/ic_timeline" />
+     <item android:id="@+id/action_album"
+          android:title="@string/albums_title"
+          android:icon="@drawable/ic_album" />
+     <item android:id="@+id/action_videos"
+          android:title="@string/videos_title"
+          android:icon="@drawable/ic_video" />
+</menu>
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 80079dd..52ac78f 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -14,16 +14,11 @@
      limitations under the License.
 -->
 <resources>
-    <declare-styleable name="Theme.GalleryBase">
-        <attr name="listPreferredItemHeightSmall" format="dimension" />
-        <attr name="switchStyle" format="reference" />
-    </declare-styleable>
+    <declare-styleable name="Theme.GalleryBase"/>
 
     <!-- Camera resources below -->
 
-    <declare-styleable name="CameraPreference">
-        <attr name="title" format="string" />
-    </declare-styleable>
+    <declare-styleable name="CameraPreference"/>
     <declare-styleable name="ListPreference">
         <attr name="key" format="string" />
         <attr name="defaultValue" format="string|reference" />
@@ -44,7 +39,6 @@
     </declare-styleable>
     <declare-styleable name="Knob">
         <attr name="label" format="string" />
-        <attr name="background" format="integer" />
         <attr name="foreground" format="integer" />
     </declare-styleable>
     <declare-styleable name="FillColor">
diff --git a/res/values/cm_colors.xml b/res/values/cm_colors.xml
index 70fc269..4eb65ae 100644
--- a/res/values/cm_colors.xml
+++ b/res/values/cm_colors.xml
@@ -24,6 +24,13 @@
 
     <color name="light_black">#424242</color>
 
+    <color name="tab_1">@color/primary</color>
+    <color name="tab_2">@color/primary</color>
+    <color name="tab_3">@color/primary</color>
+    <color name="tab_icon_1">@color/white</color>
+    <color name="tab_icon_2">@color/white</color>
+    <color name="tab_icon_3">@color/white</color>
+
     <color name="black_transparent_1">#1a000000</color>
     <color name="black_transparent_2">#26000000</color>
     <color name="black_transparent_3">#75000000</color>
diff --git a/res/values/codeaurora_strings.xml b/res/values/codeaurora_strings.xml
index b05aaf4..540707e 100644
--- a/res/values/codeaurora_strings.xml
+++ b/res/values/codeaurora_strings.xml
@@ -122,19 +122,13 @@
 
     <string name="drm_license_info">DRM license info</string>
 
-    <string-array name="title_array_nav_items">
-        <item>Timeline</item>
-        <item>Albums</item>
-        <item>Videos</item>
-    </string-array>
-
-    <string name="navigation_drawer_title" translatable="false">@string/app_name</string>
     <!-- Timeline screen title -->
     <string name="timeline_title">Timeline</string>
     <!-- Albums screen title -->
-    <string name="albums_title" translatable="false">@string/tab_albums</string>
+    <string name="albums_title">Albums</string>
     <!-- Videos screen title -->
     <string name="videos_title">Videos</string>
+
     <string name="action_viewtype_list">List view</string>
     <string name="action_viewtype_grid" translatable="false">@string/switch_photo_grid</string>
     <string name="tvEmptyAlbum">No photos found</string>
@@ -144,7 +138,7 @@
     <string name="text_makeup_Soften">Soften</string>
     <string name="text_makeup_trimface">Trimface</string>
     <string name="text_makeup_bigeye">Bigeye</string>
-    <string name="drawer_desc" translatable="false">drawer</string>
+
     <string name="truescanner_normal">Normal</string>
     <string name="truescanner_white">Whiteboard</string>
     <string name="truescanner">TrueScanner</string>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index d509fe8..429348e 100755
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -88,4 +88,7 @@
     <color name="timeline_title_text_color">@color/black_transparent_4</color>
     <color name="timeline_title_number_text_color">@color/black_transparent_3</color>
     <color name="timeline_title_background_color">@color/white</color>
+
+    <color name="navigation_accent_disabled">#747474</color>
+    <color name="navigation_accent_enabled">@color/white</color>
 </resources>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 28af6c7..1bc7fbe 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -315,7 +315,7 @@
         <item name="android:background">@drawable/bg_pressed</item>
     </style>
 
-    <style name="AppTheme" parent="android:Theme.Material.Light">
+    <style name="AppTheme" parent="Theme.AppCompat.Light">
         <item name="android:windowDrawsSystemBarBackgrounds">true</item>
         <item name="android:windowBackground">@android:color/black</item>
         <item name="android:statusBarColor">@android:color/transparent</item>
diff --git a/src/com/android/gallery3d/app/AlbumPage.java b/src/com/android/gallery3d/app/AlbumPage.java
index bdd051f..7f947d8 100644
--- a/src/com/android/gallery3d/app/AlbumPage.java
+++ b/src/com/android/gallery3d/app/AlbumPage.java
@@ -285,13 +285,7 @@
         if (mInCameraApp) {
             GalleryUtils.startGalleryActivity(mActivity);
         } else if (mActivity.getStateManager().getStateCount() > 1) {
-            Toolbar toolbar = mActivity.getToolbar();
-            if (toolbar != null) {
-                toolbar.setNavigationContentDescription(
-                        mActivity.getResources().getString(R.string.drawer_desc));
-                toolbar.setNavigationIcon(R.drawable.drawer);
-                ((GalleryActivity) mActivity).toggleNavDrawer(true);
-            }
+            ((GalleryActivity) mActivity).toggleNavBar(true);
             super.onBackPressed();
         } else if (mParentMediaSetString != null) {
             Bundle data = new Bundle(getData());
@@ -498,20 +492,6 @@
 
         setContentPane(mRootPane);
 
-        boolean enableHomeButton = (mActivity.getStateManager().getStateCount() > 1) |
-                mParentMediaSetString != null;
-        //GalleryActionBar actionBar = mActivity.getGalleryActionBar();
-        if (mIsVideoScreen) {
-            //if from video screen, show display navigation icon as home and title
-            mActionBar.setDisplayHome(true, true);
-        } else {
-            mActionBar.setDisplayOptions(enableHomeButton, true);
-        }
-        Toolbar toolBar = mActivity.getToolbar();
-        if (enableHomeButton && toolBar != null) {
-            toolBar.setNavigationContentDescription("back");
-            toolBar.setNavigationIcon(R.drawable.back);
-        }
         // Set the reload bit here to prevent it exit this page in clearLoadingBit().
         setLoadingBit(BIT_LOADING_RELOAD);
         mLoadingFailed = false;
diff --git a/src/com/android/gallery3d/app/AlbumSetPage.java b/src/com/android/gallery3d/app/AlbumSetPage.java
index 185b172..ec65896 100755
--- a/src/com/android/gallery3d/app/AlbumSetPage.java
+++ b/src/com/android/gallery3d/app/AlbumSetPage.java
@@ -694,12 +694,12 @@
                 //mActionBar.disableClusterMenu(true);
                 mActionModeHandler.startActionMode();
                 performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
-                ((GalleryActivity)mActivity).toggleNavDrawer(false);
+                ((GalleryActivity)mActivity).toggleNavBar(false);
                 break;
             }
             case SelectionManager.LEAVE_SELECTION_MODE: {
                 mActionModeHandler.finishActionMode();
-                ((GalleryActivity)mActivity).toggleNavDrawer(true);
+                ((GalleryActivity)mActivity).toggleNavBar(true);
                 /*if (mShowClusterMenu) {
                     mActionBar.enableClusterMenu(mSelectedAction, this);
                 }*/
@@ -725,11 +725,13 @@
         mDetailsHelper.hide();
         mAlbumSetView.setHighlightItemPath(null);
         mSlotView.invalidate();
+        ((GalleryActivity)mActivity).toggleNavBar(true);
     }
 
     private void showDetails() {
         mShowDetails = true;
         if (mDetailsHelper == null) {
+            ((GalleryActivity)mActivity).toggleNavBar(false);
             mDetailsHelper = new DetailsHelper(mActivity, mRootPane, mDetailsSource);
             mDetailsHelper.setCloseListener(new CloseListener() {
                 @Override
diff --git a/src/com/android/gallery3d/app/GalleryActivity.java b/src/com/android/gallery3d/app/GalleryActivity.java
index 6768967..d4b5087 100755
--- a/src/com/android/gallery3d/app/GalleryActivity.java
+++ b/src/com/android/gallery3d/app/GalleryActivity.java
@@ -30,6 +30,7 @@
 import android.graphics.Color;
 import android.net.Uri;
 import android.os.Bundle;
+import android.support.design.widget.BottomNavigationView;
 import android.support.v4.widget.DrawerLayout;
 import android.support.v4.widget.DrawerLayout.DrawerListener;
 import android.text.TextUtils;
@@ -37,6 +38,7 @@
 import android.view.Gravity;
 import android.view.InputDevice;
 import android.view.LayoutInflater;
+import android.view.MenuItem;
 import android.view.MotionEvent;
 import android.view.View;
 import android.view.View.OnClickListener;
@@ -46,6 +48,8 @@
 import android.widget.BaseAdapter;
 import android.widget.ImageView;
 import android.widget.ListView;
+import android.widget.RelativeLayout;
+import android.widget.RelativeLayout.LayoutParams;
 import android.widget.TextView;
 import android.widget.Toast;
 import android.widget.Toolbar;
@@ -92,8 +96,12 @@
     private ListView mDrawerListView;
     private DrawerLayout mDrawerLayout;
     public static boolean mIsparentActivityFInishing;
-    NavigationDrawerListAdapter mNavigationAdapter;
     public Toolbar mToolbar;
+
+    private BottomNavigationView mBottomNavigation;
+    private RelativeLayout mGLParentLayout;
+    private RelativeLayout.LayoutParams params;
+
     /** DrawerLayout is not supported in some entrances.
      * such as Intent.ACTION_VIEW, Intent.ACTION_GET_CONTENT, Intent.PICK. */
     private boolean mDrawerLayoutSupported = true;
@@ -164,76 +172,47 @@
                     R.string.videos_title, R.drawable.videos) };
 
     public void initView() {
-        mDrawerListView = (ListView) findViewById(R.id.navList);
-        mNavigationAdapter = new NavigationDrawerListAdapter(this);
-        mDrawerListView.setAdapter(mNavigationAdapter);
         mToolbar = (Toolbar) findViewById(R.id.toolbar);
         setActionBar(mToolbar);
+        setToolbar(mToolbar);
 
-        mDrawerListView
-                .setOnItemClickListener(new AdapterView.OnItemClickListener() {
-                    @Override
-                    public void onItemClick(AdapterView<?> parent, View view,
-                            int position, long id) {
-                        getGLRoot().lockRenderThread();
-                        showScreen(position);
+        mGLParentLayout = (RelativeLayout) findViewById(R.id.gl_parent_layout);
+        params = (RelativeLayout.LayoutParams) mGLParentLayout.getLayoutParams();
 
-                        mNavigationAdapter.setClickPosition(position);
-                        mDrawerListView.invalidateViews();
-                        mDrawerLayout.closeDrawer(Gravity.START);
-                        getGLRoot().unlockRenderThread();
-                    }
-                });
-        mDrawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout);
-        mDrawerLayout.setDrawerListener(new DrawerListener() {
-                @Override
-                public void onDrawerStateChanged(int arg0) {
-                    toggleNavDrawer(getStateManager().getStateCount() == 1);
-                }
-
-                @Override
-                public void onDrawerSlide(View arg0, float arg1) {
-
-                }
-
-                @Override
-                public void onDrawerOpened(View arg0) {
-
-                }
-
-                @Override
-                public void onDrawerClosed(View arg0) {
-
-                }
-            });
-        mToolbar.setNavigationContentDescription("drawer");
-        mToolbar.setNavigationOnClickListener(new OnClickListener() {
-
+        mBottomNavigation = (BottomNavigationView) findViewById(R.id.bottom_navigation);
+        mBottomNavigation.setOnNavigationItemSelectedListener(
+                new BottomNavigationView.OnNavigationItemSelectedListener() {
             @Override
-            public void onClick(View v) {
-                if (mToolbar.getNavigationContentDescription().equals("drawer")) {
-                    mDrawerLayout.openDrawer(Gravity.START);
-
-                } else {
-                    mToolbar.setNavigationContentDescription("drawer");
-                    mToolbar.setNavigationIcon(R.drawable.drawer);
-                    onBackPressed();
+            public boolean onNavigationItemSelected(MenuItem item) {
+                getGLRoot().lockRenderThread();
+                switch (item.getItemId()) {
+                    case R.id.action_timeline:
+                        showScreen(0);
+                        break;
+                    case R.id.action_album:
+                        showScreen(1);
+                        break;
+                    case R.id.action_videos:
+                        showScreen(2);
+                        break;
                 }
+                getGLRoot().unlockRenderThread();
+                return true;
             }
         });
-        setToolbar(mToolbar);
     }
 
-    public void toggleNavDrawer(boolean setDrawerVisibility) {
-        if (mDrawerLayout != null) {
-            if (setDrawerVisibility && mDrawerLayoutSupported) {
-                mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
-                mToolbar.setNavigationIcon(R.drawable.drawer);
-            } else {
-                mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
-                mToolbar.setNavigationIcon(null);
-            }
+    public void toggleNavBar(boolean show) {
+        if (show) {
+            mBottomNavigation.setVisibility(View.VISIBLE);
+        } else {
+            mBottomNavigation.setVisibility(View.INVISIBLE);
         }
+
+        // Convert dp to pixels
+        float dp = getApplicationContext().getResources().getDisplayMetrics().density;
+
+        params.setMargins(0, 0, 0, show ? Math.round(56 * dp) : 0);
     }
 
     public void showScreen(int position) {
@@ -259,75 +238,6 @@
         default:
             break;
         }
-
-        mNavigationAdapter.setClickPosition(position);
-
-        mDrawerListView.invalidateViews();
-        mToolbar.setTitle(getResources().getStringArray(
-                R.array.title_array_nav_items)[position]);
-
-        mDrawerListView.setItemChecked(position, true);
-        mDrawerListView.setSelection(position);
-        mToolbar.setNavigationContentDescription("drawer");
-        mToolbar.setNavigationIcon(R.drawable.drawer);
-    }
-
-    private class NavigationDrawerListAdapter extends BaseAdapter {
-
-        private int curTab = 0;
-        Context mContext;
-
-        public NavigationDrawerListAdapter(Context context) {
-            mContext = context;
-
-        }
-
-        @Override
-        public int getCount() {
-            return sActionItems.length;
-        }
-
-        @Override
-        public Object getItem(int position) {
-            return sActionItems[position];
-        }
-
-        @Override
-        public long getItemId(int position) {
-            return 0;
-        }
-
-        @Override
-        public View getView(int position, View convertView, ViewGroup parent) {
-            View view;
-
-            if (convertView == null) {
-                LayoutInflater inflater = (LayoutInflater) mContext
-                        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
-                view = inflater.inflate(
-                        org.codeaurora.gallery.R.layout.drawer_list_item, null);
-            } else {
-                view = convertView;
-            }
-
-            TextView titleView = (TextView) view.findViewById(R.id.itemTitle);
-            ImageView iconView = (ImageView) view.findViewById(R.id.ivItem);
-
-            titleView.setText(sActionItems[position].title);
-            iconView.setImageResource(sActionItems[position].icon);
-
-            if (curTab == position) {
-                view.setBackgroundResource(R.drawable.drawer_item_selected_bg);
-            } else {
-                view.setBackgroundColor(android.R.color.transparent);
-            }
-
-            return view;
-        }
-
-        public void setClickPosition(int position) {
-            curTab = position;
-        }
     }
 
     public static int getActionTitle(Context context, int type) {
@@ -346,6 +256,7 @@
         if (Intent.ACTION_GET_CONTENT.equalsIgnoreCase(action)) {
             mDrawerLayoutSupported = false;
             startGetContent(intent);
+            toggleNavBar(false);
         } else if (Intent.ACTION_PICK.equalsIgnoreCase(action)) {
             mDrawerLayoutSupported = false;
             // We do NOT really support the PICK intent. Handle it as
@@ -358,6 +269,7 @@
                 if (type.endsWith("/video")) intent.setType("video/*");
             }
             startGetContent(intent);
+            toggleNavBar(false);
         } else if (Intent.ACTION_VIEW.equalsIgnoreCase(action)
                 || ACTION_REVIEW.equalsIgnoreCase(action)){
             mDrawerLayoutSupported = false;
@@ -377,12 +289,13 @@
                 Log.w(TAG, "uri get from intent is null");
             }
             startViewAction(intent);
+            toggleNavBar(false);
         } else {
             mDrawerLayoutSupported = true;
             startTimelinePage();
             mToolbar.setTitle(R.string.albums_title);
         }
-        toggleNavDrawer(mDrawerLayoutSupported);
+        toggleNavBar(mDrawerLayoutSupported);
     }
 
     public void startAlbumPage() {
diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java
index 6d4a3e9..272f939 100755
--- a/src/com/android/gallery3d/app/PhotoPage.java
+++ b/src/com/android/gallery3d/app/PhotoPage.java
@@ -1030,6 +1030,7 @@
     @Override
     protected void onBackPressed() {
         showBars();
+        ((GalleryActivity)mActivity).toggleNavBar(true);
         if (mShowDetails) {
             hideDetails();
         } else if (mAppBridge == null || !switchWithCaptureAnimation(-1)) {
@@ -1048,10 +1049,7 @@
                 mActionBar.setBackGroundDefault();
                 int count = mActivity.getStateManager().getStateCount();
                 if (mIsFromVideoScreen || count == 1 || mIsFromTimelineScreen) {
-                    mActivity.getToolbar().setNavigationContentDescription(
-                            "drawer");
-                    mActivity.getToolbar().setNavigationIcon(R.drawable.drawer);
-                    ((GalleryActivity)mActivity).toggleNavDrawer(true);
+                    ((GalleryActivity)mActivity).toggleNavBar(true);
                     if (mModel instanceof PhotoDataAdapter) {
                         ((PhotoDataAdapter) mModel).setDataListener(null);
                     }
@@ -1690,12 +1688,11 @@
         }
 
         mActionBar.setDisplayOptions(
-                ((mSecureAlbum == null) && (mSetPathString != null)), true);
+                (false && (mSetPathString != null)), true);
         mActionBar.addOnMenuVisibilityListener(mMenuVisibilityListener);
         refreshBottomControlsWhenReady();
         if (((mSecureAlbum == null) && (mSetPathString != null))) {
-            mActivity.getToolbar().setNavigationContentDescription("back");
-            mActivity.getToolbar().setNavigationIcon(R.drawable.back);
+            ((GalleryActivity)mActivity).toggleNavBar(false);
         }
         // if (mShowSpinner && mPhotoView.getFilmMode()) {
         // mActionBar.enableAlbumModeMenu(
diff --git a/src/com/android/gallery3d/app/SlideshowPage.java b/src/com/android/gallery3d/app/SlideshowPage.java
index e742321..2923ee9 100644
--- a/src/com/android/gallery3d/app/SlideshowPage.java
+++ b/src/com/android/gallery3d/app/SlideshowPage.java
@@ -113,6 +113,8 @@
     @Override
     public void onCreate(Bundle data, Bundle restoreState) {
         super.onCreate(data, restoreState);
+        ((GalleryActivity) mActivity).toggleNavBar(false);
+
         mFlags |= (FLAG_HIDE_ACTION_BAR | FLAG_HIDE_STATUS_BAR | FLAG_SCREEN_FULL);
         if (data.getBoolean(KEY_DREAM)) {
             // Dream screensaver only keeps screen on for plugged devices.
@@ -174,6 +176,7 @@
     @Override
     public void onPause() {
         super.onPause();
+        ((GalleryActivity) mActivity).toggleNavBar(true);
         mIsActive = false;
         mModel.pause();
         mSlideshowView.release();
@@ -185,6 +188,7 @@
     @Override
     public void onResume() {
         super.onResume();
+        ((GalleryActivity) mActivity).toggleNavBar(false);
         mIsActive = true;
         mModel.resume();
 
diff --git a/src/com/android/gallery3d/app/TimeLinePage.java b/src/com/android/gallery3d/app/TimeLinePage.java
index d48bf39..7810a15 100755
--- a/src/com/android/gallery3d/app/TimeLinePage.java
+++ b/src/com/android/gallery3d/app/TimeLinePage.java
@@ -697,12 +697,12 @@
             case SelectionManager.ENTER_SELECTION_MODE: {
                 mActionModeHandler.startActionMode();
                 performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
-                ((GalleryActivity)mActivity).toggleNavDrawer(false);
+                ((GalleryActivity)mActivity).toggleNavBar(false);
                 break;
             }
             case SelectionManager.LEAVE_SELECTION_MODE: {
                 mActionModeHandler.finishActionMode();
-                ((GalleryActivity)mActivity).toggleNavDrawer(true);
+                ((GalleryActivity)mActivity).toggleNavBar(true);
                 mRootPane.invalidate();
                 break;
             }
diff --git a/src/org/codeaurora/gallery3d/video/VideoSettingsActivity.java b/src/org/codeaurora/gallery3d/video/VideoSettingsActivity.java
index c3e54ff..ad73765 100644
--- a/src/org/codeaurora/gallery3d/video/VideoSettingsActivity.java
+++ b/src/org/codeaurora/gallery3d/video/VideoSettingsActivity.java
@@ -49,7 +49,6 @@
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         ActionBar actionBar = getActionBar();
-        actionBar.setDisplayHomeAsUpEnabled(true);
         actionBar.setTitle(getResources().getString(R.string.settings));
         setContentView(R.layout.setting_list);
         ArrayList<HashMap<String, Object>> arrlist = new ArrayList<HashMap<String, Object>>(1);