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

Commit d527c916 authored by Danesh Mondegarian's avatar Danesh Mondegarian
Browse files

Settings : Toggle expanded desktop for navbar

If entering the navbar screen with expanded desktop enabled, the navbar
is not shown hence hindering the ability to use the panel

This patchset addresses that by disabling expanded desktop upon entering,
and re-enabling upon exiting if it was previously enabled.

Patchset 2 : Fix state issues

Change-Id: I2776cf971f8899d30a25c0bf6b418793153555fc
parent 2433cb7f
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ public class NavBar extends Fragment {
    private ViewGroup mContainer;
    private Activity mActivity;
    private MenuItem mEditMenu;
    private boolean mWasInExpandedState;
    private final static Intent mIntent = new Intent("android.intent.action.NAVBAR_EDIT");
    private static final int MENU_RESET = Menu.FIRST;
    private static final int MENU_EDIT = Menu.FIRST + 1;
@@ -74,6 +75,9 @@ public class NavBar extends Fragment {
    @Override
    public void onResume() {
        super.onResume();
        mWasInExpandedState = Settings.System.getInt(mActivity.getContentResolver(),
                Settings.System.EXPANDED_DESKTOP_STATE, 0) == 1;
        setExpandedDesktopState(false);
        // If running on a phone, remove padding around container
        if (Utils.isPhone(mActivity)) {
            mContainer.setPadding(0, 0, 0, 0);
@@ -129,21 +133,34 @@ public class NavBar extends Fragment {
        }
    }

    private void setExpandedDesktopState(boolean on) {
        if (mWasInExpandedState) {
            Settings.System.putInt(mActivity.getContentResolver(),
                    Settings.System.EXPANDED_DESKTOP_STATE, on ? 1 : 0);
            if (on) {
                mWasInExpandedState = false;
            }
        }
    }

    @Override
    public void onPause() {
        toggleEditMode(false, false);
        setExpandedDesktopState(true);
        super.onPause();
    }

    @Override
    public void onStop() {
        toggleEditMode(false, false);
        setExpandedDesktopState(true);
        super.onStop();
    }

    @Override
    public void onDestroy() {
        toggleEditMode(false, false);
        setExpandedDesktopState(true);
        super.onDestroy();
    }
}