Lock drawer when in search/sync mode

Drawer will no longer pull out when the view mode is:
-search_results_conversation
-search_results_list
-waiting_for_account_initialization

Bug: 8373497
Change-Id: Ifaf0ada4802fcf772df2a91415ce898eebdedf44
diff --git a/src/com/android/mail/ui/OnePaneController.java b/src/com/android/mail/ui/OnePaneController.java
index fc33b8d..5650f99 100644
--- a/src/com/android/mail/ui/OnePaneController.java
+++ b/src/com/android/mail/ui/OnePaneController.java
@@ -191,8 +191,14 @@
     public void onViewModeChanged(int newMode) {
         super.onViewModeChanged(newMode);
 
-        // When view mode changes, we should wait for drawer to close and
-        // repopulate folders.
+        // When view mode changes, lock drawer if viewing search results or
+        // waiting for sync. Afterward, reset drawer state and load the folder
+        // fragment into the drawer pullout.
+        if (ViewMode.isSearchMode(newMode) || ViewMode.isWaitingForSync(newMode)) {
+            mDrawerContainer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
+        } else {
+            mDrawerContainer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
+        }
         resetAndLoadDrawer();
 
         // When entering conversation list mode, hide and clean up any currently visible
diff --git a/src/com/android/mail/ui/ViewMode.java b/src/com/android/mail/ui/ViewMode.java
index 9644fdc..62dfa59 100644
--- a/src/com/android/mail/ui/ViewMode.java
+++ b/src/com/android/mail/ui/ViewMode.java
@@ -170,7 +170,7 @@
         return isListMode(mMode);
     }
 
-    public static final boolean isListMode(int mode) {
+    public static boolean isListMode(final int mode) {
         return mode == CONVERSATION_LIST || mode == SEARCH_RESULTS_LIST;
     }
 
@@ -178,12 +178,20 @@
         return isConversationMode(mMode);
     }
 
-    public static final boolean isConversationMode(int mode) {
+    public static boolean isConversationMode(final int mode) {
         return mode == CONVERSATION || mode == SEARCH_RESULTS_CONVERSATION;
     }
 
+    public static boolean isSearchMode(final int mode) {
+        return mode == SEARCH_RESULTS_LIST || mode == SEARCH_RESULTS_CONVERSATION;
+    }
+
     public boolean isWaitingForSync() {
-        return mMode == WAITING_FOR_ACCOUNT_INITIALIZATION;
+        return isWaitingForSync(mMode);
+    }
+
+    public static boolean isWaitingForSync(final int mode) {
+        return mode == WAITING_FOR_ACCOUNT_INITIALIZATION;
     }
 
     /**