Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7cf35abe authored by Stephen Bird's avatar Stephen Bird Committed by Nir Bruderman
Browse files

CM Easy Mode File Manager Navigation fixes

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
(cherry picked from commit c5c68522)
parent 25ef6f70
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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
+39 −3
Original line number Diff line number Diff line
@@ -471,6 +471,8 @@ public class NavigationActivity extends Activity

    private int mOrientation;

    private boolean mNeedsEasyMode = false;

    /**
     * @hide
     */
@@ -682,6 +684,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);
    }

@@ -967,6 +979,7 @@ public class NavigationActivity extends Activity
    private void performShowEasyMode() {
        mEasyModeListView.setVisibility(View.VISIBLE);
        getCurrentNavigationView().setVisibility(View.GONE);
        performShowBackArrow(false);
    }

    /**
@@ -977,6 +990,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
@@ -1083,6 +1106,7 @@ public class NavigationActivity extends Activity
                        } else {
                            performHideEasyMode();
                        }
                        performShowBackArrow(!mDrawerToggle.isDrawerIndicatorEnabled());
                        getCurrentNavigationView().open(fso);
                        mDrawerLayout.closeDrawer(Gravity.START);
                    }
@@ -1458,7 +1482,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 {
@@ -1656,8 +1682,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 {
@@ -1747,6 +1774,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
@@ -2133,8 +2165,12 @@ 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);
            if (mNeedsEasyMode) {
                return isEasyModeVisible();
            } else {
                return true;
            }
        }

        //Back action not applied
        return !this.mExitFlag;