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

Commit ed31bbf6 authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Clean up some edge cases in the compat mode UI:

- Don't put up multiple dialogs if a switch happens between activities
  that both can use compat mode.
- Remove the help dialog if the user switches away from an app that
  can use compat mode.
- Don't set the "don't show" preference until the user explicitly hits
  the button.
- Hide the compat mode switch UI if the compat mode button is hidden.

Change-Id: I8dd2aab1385a264232a9256284d4a75b8e058e47
parent 5994bff9
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -107,9 +107,14 @@ public class CompatModePanel extends FrameLayout implements StatusBarPanel,

    private void refresh() {
        int mode = mAM.getFrontActivityScreenCompatMode();
        if (mode == ActivityManager.COMPAT_MODE_ALWAYS
                || mode == ActivityManager.COMPAT_MODE_NEVER) {
            // No longer have something to switch.
            closePanel();
            return;
        }
        final boolean on = (mode == ActivityManager.COMPAT_MODE_ENABLED);
        mOnButton.setChecked(on);
        mOffButton.setChecked(!on);
    }

}
+23 −8
Original line number Diff line number Diff line
@@ -165,6 +165,8 @@ public class TabletStatusBar extends StatusBar implements
    View mFakeSpaceBar;
    KeyEvent mSpaceBarKeyEvent = null;

    View mCompatibilityHelpDialog = null;
    
    // for disabling the status bar
    int mDisabled = 0;

@@ -1012,17 +1014,27 @@ public class TabletStatusBar extends StatusBar implements
            if (! Prefs.read(mContext).getBoolean(Prefs.SHOWN_COMPAT_MODE_HELP, false)) {
                showCompatibilityHelp();
            }
        } else {
            hideCompatibilityHelp();
            mCompatModePanel.closePanel();
        }
    }

    private void showCompatibilityHelp() {
        final View dlg = View.inflate(mContext, R.layout.compat_mode_help, null);
        View button = dlg.findViewById(R.id.button);
        if (mCompatibilityHelpDialog != null) {
            return;
        }
        
        mCompatibilityHelpDialog = View.inflate(mContext, R.layout.compat_mode_help, null);
        View button = mCompatibilityHelpDialog.findViewById(R.id.button);

        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                WindowManagerImpl.getDefault().removeView(dlg);
                hideCompatibilityHelp();
                SharedPreferences.Editor editor = Prefs.edit(mContext);
                editor.putBoolean(Prefs.SHOWN_COMPAT_MODE_HELP, true);
                editor.apply();
            }
        });

@@ -1039,11 +1051,14 @@ public class TabletStatusBar extends StatusBar implements
                | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING;
        lp.windowAnimations = com.android.internal.R.style.Animation_ZoomButtons; // simple fade

        WindowManagerImpl.getDefault().addView(dlg, lp);
        WindowManagerImpl.getDefault().addView(mCompatibilityHelpDialog, lp);
    }

        SharedPreferences.Editor editor = Prefs.edit(mContext);
        editor.putBoolean(Prefs.SHOWN_COMPAT_MODE_HELP, true);
        editor.apply();
    private void hideCompatibilityHelp() {
        if (mCompatibilityHelpDialog != null) {
            WindowManagerImpl.getDefault().removeView(mCompatibilityHelpDialog);
            mCompatibilityHelpDialog = null;
        }
    }
    
    public void setImeWindowStatus(IBinder token, int vis, int backDisposition) {