disable focus/click on current account in mini-drawer

And clean up some mini-drawer (the stub current-account view was just
tossed in Gmail) focus shenanigans (assumed 0th mini-drawer child was
focusable).

Bug: 17536935
Change-Id: I5246afd650da728601cece4339357557dac3de37
diff --git a/res/layout/folder_list.xml b/res/layout/folder_list.xml
index acc375d..a5097ba 100644
--- a/res/layout/folder_list.xml
+++ b/res/layout/folder_list.xml
@@ -32,19 +32,12 @@
         android:layout_width="@dimen/two_pane_drawer_width_mini"
         android:layout_height="match_parent"
         android:focusable="true"
+        android:descendantFocusability="afterDescendants"
         android:paddingTop="20dp"
         android:paddingBottom="18dp"
         android:orientation="vertical">
 
-        <ImageView
-            android:id="@+id/current_account_avatar"
-            android:layout_width="match_parent"
-            android:layout_height="64dp"
-            android:paddingTop="16dp"
-            android:paddingBottom="16dp"
-            android:paddingLeft="20dp"
-            android:paddingRight="20dp"
-            style="@style/MiniDrawerItemStyleBase" />
+        <include layout="@layout/mini_drawer_recent_account_item" />
 
         <ImageView
             android:id="@+id/dotdotdot"
diff --git a/src/com/android/mail/ui/MiniDrawerView.java b/src/com/android/mail/ui/MiniDrawerView.java
index 34483cc..7544c30 100644
--- a/src/com/android/mail/ui/MiniDrawerView.java
+++ b/src/com/android/mail/ui/MiniDrawerView.java
@@ -71,6 +71,22 @@
         });
     }
 
+    @Override
+    public boolean requestFocus(int direction, Rect previouslyFocusedRect) {
+        // This ViewGroup is focusable purely so it can act as a stable target for other views to
+        // designate as their left/right focus ID. When focus comes to this view, the XML
+        // declaration of descendantFocusability=FOCUS_AFTER_DESCENDANTS means it will always try
+        // to focus one of its children before resorting to this (great! we basically never want
+        // this container to gain focus).
+        //
+        // But the usual focus search towards the LEFT (in LTR) actually starts at the bottom,
+        // which is weird. So override all focus requests that land on this parent to use the
+        // FORWARD direction so the top-most item gets first focus. This will not affect focus
+        // traversal within this ViewGroup as the descendantFocusability prevents the parent from
+        // gaining focus.
+        return super.requestFocus(FOCUS_DOWN, previouslyFocusedRect);
+    }
+
     public void setController(FolderListFragment flf) {
         mController = flf;
         final ListAdapter adapter = mController.getMiniDrawerAccountsAdapter();
@@ -99,6 +115,8 @@
                 removeView(oldCurrentAccountView);
             }
             final View newCurrentAccountView = adapter.getView(0, oldCurrentAccountView, this);
+            newCurrentAccountView.setClickable(false);
+            newCurrentAccountView.setFocusable(false);
             addView(newCurrentAccountView, 0);
         }
 
@@ -142,15 +160,6 @@
         }
     }
 
-    @Override
-    protected void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect) {
-        if (gainFocus && getFocusedChild() == null) {
-            if (getChildCount() > 0) {
-                getChildAt(0).requestFocus();
-            }
-        }
-    }
-
     private class FolderItem implements View.OnClickListener {
         public final Folder folder;
         public final ImageView view;
diff --git a/src/com/android/mail/ui/TwoPaneController.java b/src/com/android/mail/ui/TwoPaneController.java
index f2ccd71..4dc77b6 100644
--- a/src/com/android/mail/ui/TwoPaneController.java
+++ b/src/com/android/mail/ui/TwoPaneController.java
@@ -134,7 +134,7 @@
         fragmentTransaction.commitAllowingStateLoss();
         // Set default navigation here once the ConversationListFragment is created.
         conversationListFragment.setNextFocusStartId(
-                getClfNextFocusStartId(getFolderListFragment().isMinimized()));
+                getClfNextFocusStartId());
     }
 
     @Override
@@ -271,7 +271,7 @@
 
         final ConversationListFragment clf = getConversationListFragment();
         if (clf != null) {
-            clf.setNextFocusStartId(getClfNextFocusStartId(flf.isMinimized()));
+            clf.setNextFocusStartId(getClfNextFocusStartId());
 
             final SwipeableListView list = clf.getListView();
             if (list != null) {
@@ -315,8 +315,8 @@
         }
     }
 
-    private @IdRes int getClfNextFocusStartId(boolean drawerMinimized) {
-        return (drawerMinimized) ? R.id.mini_drawer : android.R.id.list;
+    private @IdRes int getClfNextFocusStartId() {
+        return (isDrawerOpen()) ? android.R.id.list : R.id.mini_drawer;
     }
 
     @Override