OSDN Git Service

CM Easy Mode File Manager Navigation fixes
authorStephen Bird <sebirdman@gmail.com>
Wed, 13 May 2015 00:30:16 +0000 (17:30 -0700)
committerMartin Brabham <mbrabham@cyngn.com>
Thu, 14 May 2015 23:23:40 +0000 (23:23 +0000)
This patch fixes an issue where the user cannot
get back to easy mode without exiting and re-entering
the application in certain situations

Repro Steps:
1) Select "All" in the easy mode list
2) Action Bar arrow is gone, pressing back on the navbar
does not return you to easy mode

Change-Id: I5f6b47b8b69e57cffac77f7bfa24f8a75d8ff1d4

res/layout/navigation.xml
src/com/cyanogenmod/filemanager/activities/NavigationActivity.java

index e457d1b..fad876a 100644 (file)
@@ -46,7 +46,7 @@
                     android:layout_width="match_parent"
                     android:minHeight="?android:attr/actionBarSize"
                     android:background="?android:attr/colorPrimary"
-                    android:theme="@style/FileManager.Widget.ActionBar.White"/>
+                    android:theme="@android:style/Theme.Material"/>
 
             <!-- Navigation View -->
             <com.cyanogenmod.filemanager.ui.widgets.NavigationView
index 4d028c4..741e759 100755 (executable)
@@ -473,6 +473,8 @@ public class NavigationActivity extends Activity
 
     private int mOrientation;
 
+    private boolean mNeedsEasyMode = false;
+
     /**
      * @hide
      */
@@ -688,6 +690,16 @@ public class NavigationActivity extends Activity
         if (mDrawerToggle.onOptionsItemSelected(item)) {
           return true;
         }
+
+        if (mNeedsEasyMode) {
+            if (item.getItemId() == android.R.id.home) {
+                if (mHistory.size() == 0 && !isEasyModeVisible()) {
+                    performShowEasyMode();
+                } else {
+                    back();
+                }
+            }
+        }
         return super.onOptionsItemSelected(item);
     }
 
@@ -995,6 +1007,7 @@ public class NavigationActivity extends Activity
     private void performShowEasyMode() {
         mEasyModeListView.setVisibility(View.VISIBLE);
         getCurrentNavigationView().setVisibility(View.GONE);
+        performShowBackArrow(false);
     }
 
     /**
@@ -1005,6 +1018,16 @@ public class NavigationActivity extends Activity
         getCurrentNavigationView().setVisibility(View.VISIBLE);
     }
 
+    private void performShowBackArrow(boolean showBackArrow) {
+        if (mNeedsEasyMode) {
+            mDrawerToggle.setDrawerIndicatorEnabled(!showBackArrow);
+        }
+    }
+
+    private boolean isEasyModeVisible() {
+        return mEasyModeListView.getVisibility() != View.GONE;
+    }
+
     /**
      * Method takes a bookmark as argument and adds it to the bookmark list in
      * the drawer
@@ -1111,6 +1134,7 @@ public class NavigationActivity extends Activity
                         } else {
                             performHideEasyMode();
                         }
+                        performShowBackArrow(!mDrawerToggle.isDrawerIndicatorEnabled());
                         getCurrentNavigationView().open(fso);
                         mDrawerLayout.closeDrawer(Gravity.START);
                     }
@@ -1486,7 +1510,9 @@ public class NavigationActivity extends Activity
         intent.putExtra(SearchManager.QUERY, "*"); // Use wild-card '*'
 
         if (position == 0) {
+            // the user has selected all items, they want to see their folders so let's do that.
             performHideEasyMode();
+            performShowBackArrow(true);
             return;
 
         } else {
@@ -1684,8 +1710,9 @@ public class NavigationActivity extends Activity
             }
         }
 
-        needsEasyMode = needsEasyMode
-                && getResources().getBoolean(R.bool.cmcc_show_easy_mode);
+        mNeedsEasyMode = getResources().getBoolean(R.bool.cmcc_show_easy_mode);
+
+        needsEasyMode = needsEasyMode && mNeedsEasyMode;
         if (needsEasyMode) {
             performShowEasyMode();
         } else {
@@ -1775,6 +1802,11 @@ public class NavigationActivity extends Activity
         if (checkBackAction()) {
             performHideEasyMode();
             return;
+        } else {
+            if (mNeedsEasyMode && !isEasyModeVisible()) {
+                performShowEasyMode();
+                return;
+            }
         }
 
         // An exit event has occurred, force the destroy the consoles
@@ -2161,7 +2193,11 @@ public class NavigationActivity extends Activity
             //Communicate the user that the next time the application will be closed
             this.mExitBackTimeout = System.currentTimeMillis();
             DialogHelper.showToast(this, R.string.msgs_push_again_to_exit, Toast.LENGTH_SHORT);
-            return true;
+            if (mNeedsEasyMode) {
+                return isEasyModeVisible();
+            } else {
+                return true;
+            }
         }
 
         //Back action not applied