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
This commit is contained in:
@@ -107,9 +107,14 @@ public class CompatModePanel extends FrameLayout implements StatusBarPanel,
|
|||||||
|
|
||||||
private void refresh() {
|
private void refresh() {
|
||||||
int mode = mAM.getFrontActivityScreenCompatMode();
|
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);
|
final boolean on = (mode == ActivityManager.COMPAT_MODE_ENABLED);
|
||||||
mOnButton.setChecked(on);
|
mOnButton.setChecked(on);
|
||||||
mOffButton.setChecked(!on);
|
mOffButton.setChecked(!on);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -165,6 +165,8 @@ public class TabletStatusBar extends StatusBar implements
|
|||||||
View mFakeSpaceBar;
|
View mFakeSpaceBar;
|
||||||
KeyEvent mSpaceBarKeyEvent = null;
|
KeyEvent mSpaceBarKeyEvent = null;
|
||||||
|
|
||||||
|
View mCompatibilityHelpDialog = null;
|
||||||
|
|
||||||
// for disabling the status bar
|
// for disabling the status bar
|
||||||
int mDisabled = 0;
|
int mDisabled = 0;
|
||||||
|
|
||||||
@@ -1012,17 +1014,27 @@ public class TabletStatusBar extends StatusBar implements
|
|||||||
if (! Prefs.read(mContext).getBoolean(Prefs.SHOWN_COMPAT_MODE_HELP, false)) {
|
if (! Prefs.read(mContext).getBoolean(Prefs.SHOWN_COMPAT_MODE_HELP, false)) {
|
||||||
showCompatibilityHelp();
|
showCompatibilityHelp();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
hideCompatibilityHelp();
|
||||||
|
mCompatModePanel.closePanel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showCompatibilityHelp() {
|
private void showCompatibilityHelp() {
|
||||||
final View dlg = View.inflate(mContext, R.layout.compat_mode_help, null);
|
if (mCompatibilityHelpDialog != null) {
|
||||||
View button = dlg.findViewById(R.id.button);
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mCompatibilityHelpDialog = View.inflate(mContext, R.layout.compat_mode_help, null);
|
||||||
|
View button = mCompatibilityHelpDialog.findViewById(R.id.button);
|
||||||
|
|
||||||
button.setOnClickListener(new View.OnClickListener() {
|
button.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
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,13 +1051,16 @@ public class TabletStatusBar extends StatusBar implements
|
|||||||
| WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING;
|
| WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING;
|
||||||
lp.windowAnimations = com.android.internal.R.style.Animation_ZoomButtons; // simple fade
|
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) {
|
public void setImeWindowStatus(IBinder token, int vis, int backDisposition) {
|
||||||
mInputMethodSwitchButton.setImeWindowStatus(token,
|
mInputMethodSwitchButton.setImeWindowStatus(token,
|
||||||
(vis & InputMethodService.IME_ACTIVE) != 0);
|
(vis & InputMethodService.IME_ACTIVE) != 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user