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

Commit 89bfd7eb authored by Stephen Bird's avatar Stephen Bird Committed by Stephen Bird
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
parent 622df265
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
@@ -480,6 +480,8 @@ public class NavigationActivity extends Activity

    private int mOrientation;

    private boolean mNeedsEasyMode = false;

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

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

    /**
@@ -1011,6 +1024,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
@@ -1117,6 +1140,7 @@ public class NavigationActivity extends Activity
                        } else {
                            performHideEasyMode();
                        }
                        performShowBackArrow(!mDrawerToggle.isDrawerIndicatorEnabled());
                        getCurrentNavigationView().open(fso);
                        mDrawerLayout.closeDrawer(Gravity.START);
                    }
@@ -1492,7 +1516,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 {
@@ -1671,8 +1697,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 {
@@ -1762,6 +1789,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
@@ -2148,8 +2180,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;