Skip to content

Commit 192b98c

Browse files
dsandlerAndroid (Google) Code Review
authored andcommitted
Merge "Fix disappearing BACK button."
2 parents 4e2134b + 6da2b76 commit 192b98c

File tree

2 files changed

+52
-33
lines changed

2 files changed

+52
-33
lines changed

packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
public class NavigationBarView extends LinearLayout {
4444
final static boolean DEBUG = false;
45-
final static String TAG = "NavigationBarView";
45+
final static String TAG = "PhoneStatusBar/NavigationBarView";
4646

4747
final static boolean DEBUG_DEADZONE = false;
4848

@@ -60,6 +60,7 @@ public class NavigationBarView extends LinearLayout {
6060
boolean mVertical;
6161

6262
boolean mHidden, mLowProfile;
63+
int mDisabledFlags = 0;
6364

6465
public View getRecentsButton() {
6566
return mCurrentView.findViewById(R.id.recent_apps);
@@ -99,7 +100,7 @@ public boolean onTouch(View v, MotionEvent ev) {
99100
// even though setting the systemUI visibility below will turn these views
100101
// on, we need them to come up faster so that they can catch this motion
101102
// event
102-
setLowProfile(false, false);
103+
setLowProfile(false, false, false);
103104

104105
try {
105106
mBarService.setSystemUiVisibility(0);
@@ -110,9 +111,18 @@ public boolean onTouch(View v, MotionEvent ev) {
110111
}
111112
};
112113

113-
public void setNavigationVisibility(int disabledFlags) {
114-
boolean disableNavigation = ((disabledFlags & View.STATUS_BAR_DISABLE_NAVIGATION) != 0);
115-
boolean disableBack = ((disabledFlags & View.STATUS_BAR_DISABLE_BACK) != 0);
114+
public void setDisabledFlags(int disabledFlags) {
115+
Slog.d(TAG, "setDisabledFlags: " + disabledFlags);
116+
setDisabledFlags(disabledFlags, false);
117+
}
118+
119+
public void setDisabledFlags(int disabledFlags, boolean force) {
120+
if (!force && mDisabledFlags == disabledFlags) return;
121+
122+
mDisabledFlags = disabledFlags;
123+
124+
final boolean disableNavigation = ((disabledFlags & View.STATUS_BAR_DISABLE_NAVIGATION) != 0);
125+
final boolean disableBack = ((disabledFlags & View.STATUS_BAR_DISABLE_BACK) != 0);
116126

117127
getBackButton() .setVisibility(disableBack ? View.INVISIBLE : View.VISIBLE);
118128
getHomeButton() .setVisibility(disableNavigation ? View.INVISIBLE : View.VISIBLE);
@@ -121,11 +131,11 @@ public void setNavigationVisibility(int disabledFlags) {
121131
}
122132

123133
public void setLowProfile(final boolean lightsOut) {
124-
setLowProfile(lightsOut, true);
134+
setLowProfile(lightsOut, true, false);
125135
}
126136

127-
public void setLowProfile(final boolean lightsOut, final boolean animate) {
128-
if (lightsOut == mLowProfile) return;
137+
public void setLowProfile(final boolean lightsOut, final boolean animate, final boolean force) {
138+
if (!force && lightsOut == mLowProfile) return;
129139

130140
mLowProfile = lightsOut;
131141

@@ -245,6 +255,10 @@ public void reorient() {
245255
mCurrentView.setVisibility(View.VISIBLE);
246256
mVertical = (rot == Surface.ROTATION_90 || rot == Surface.ROTATION_270);
247257

258+
// force the low profile & disabled states into compliance
259+
setLowProfile(mLowProfile, false, true /* force */);
260+
setDisabledFlags(mDisabledFlags, true /* force */);
261+
248262
if (DEBUG_DEADZONE) {
249263
mCurrentView.findViewById(R.id.deadzone).setBackgroundColor(0x808080FF);
250264
}

packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ protected View makeStatusBarView() {
297297
mNavigationBarView =
298298
(NavigationBarView) View.inflate(context, R.layout.navigation_bar, null);
299299

300-
setNavigationVisibility(mDisabled);
300+
mNavigationBarView.setDisabledFlags(mDisabled);
301301

302302
sb.setOnSystemUiVisibilityChangeListener(
303303
new View.OnSystemUiVisibilityChangeListener() {
@@ -1083,62 +1083,67 @@ public void disable(int state) {
10831083
old, state, diff));
10841084
}
10851085

1086+
StringBuilder flagdbg = new StringBuilder();
1087+
flagdbg.append("disable: < ");
1088+
flagdbg.append(((state & StatusBarManager.DISABLE_EXPAND) != 0) ? "EXPAND" : "expand");
1089+
flagdbg.append(((diff & StatusBarManager.DISABLE_EXPAND) != 0) ? "* " : " ");
1090+
flagdbg.append(((state & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) ? "ICONS" : "icons");
1091+
flagdbg.append(((diff & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) ? "* " : " ");
1092+
flagdbg.append(((state & StatusBarManager.DISABLE_NOTIFICATION_ALERTS) != 0) ? "ALERTS" : "alerts");
1093+
flagdbg.append(((diff & StatusBarManager.DISABLE_NOTIFICATION_ALERTS) != 0) ? "* " : " ");
1094+
flagdbg.append(((state & StatusBarManager.DISABLE_NOTIFICATION_TICKER) != 0) ? "TICKER" : "ticker");
1095+
flagdbg.append(((diff & StatusBarManager.DISABLE_NOTIFICATION_TICKER) != 0) ? "* " : " ");
1096+
flagdbg.append(((state & StatusBarManager.DISABLE_SYSTEM_INFO) != 0) ? "SYSTEM_INFO" : "system_info");
1097+
flagdbg.append(((diff & StatusBarManager.DISABLE_SYSTEM_INFO) != 0) ? "* " : " ");
1098+
flagdbg.append(((state & StatusBarManager.DISABLE_NAVIGATION) != 0) ? "NAVIGATION" : "navigation");
1099+
flagdbg.append(((diff & StatusBarManager.DISABLE_NAVIGATION) != 0) ? "* " : " ");
1100+
flagdbg.append(((state & StatusBarManager.DISABLE_BACK) != 0) ? "BACK" : "back");
1101+
flagdbg.append(((diff & StatusBarManager.DISABLE_BACK) != 0) ? "* " : " ");
1102+
flagdbg.append(((state & StatusBarManager.DISABLE_CLOCK) != 0) ? "CLOCK" : "clock");
1103+
flagdbg.append(((diff & StatusBarManager.DISABLE_CLOCK) != 0) ? "* " : " ");
1104+
flagdbg.append(">");
1105+
Slog.d(TAG, flagdbg.toString());
1106+
10861107
if ((diff & StatusBarManager.DISABLE_CLOCK) != 0) {
10871108
boolean show = (state & StatusBarManager.DISABLE_CLOCK) == 0;
10881109
showClock(show);
10891110
}
10901111
if ((diff & StatusBarManager.DISABLE_EXPAND) != 0) {
10911112
if ((state & StatusBarManager.DISABLE_EXPAND) != 0) {
1092-
Slog.d(TAG, "DISABLE_EXPAND: yes");
10931113
animateCollapse();
10941114
}
10951115
}
10961116

10971117
if ((diff & (StatusBarManager.DISABLE_NAVIGATION | StatusBarManager.DISABLE_BACK)) != 0) {
1098-
setNavigationVisibility(state &
1099-
(StatusBarManager.DISABLE_NAVIGATION | StatusBarManager.DISABLE_BACK));
1118+
// the nav bar will take care of DISABLE_NAVIGATION and DISABLE_BACK
1119+
mNavigationBarView.setDisabledFlags(state);
1120+
1121+
if ((state & StatusBarManager.DISABLE_NAVIGATION) != 0) {
1122+
// close recents if it's visible
1123+
mHandler.removeMessages(MSG_CLOSE_RECENTS_PANEL);
1124+
mHandler.sendEmptyMessage(MSG_CLOSE_RECENTS_PANEL);
1125+
}
11001126
}
11011127

11021128
if ((diff & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) {
11031129
if ((state & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) {
1104-
Slog.d(TAG, "DISABLE_NOTIFICATION_ICONS: yes");
11051130
if (mTicking) {
11061131
mTicker.halt();
11071132
} else {
11081133
setNotificationIconVisibility(false, com.android.internal.R.anim.fade_out);
11091134
}
11101135
} else {
1111-
Slog.d(TAG, "DISABLE_NOTIFICATION_ICONS: no");
11121136
if (!mExpandedVisible) {
11131137
setNotificationIconVisibility(true, com.android.internal.R.anim.fade_in);
11141138
}
11151139
}
11161140
} else if ((diff & StatusBarManager.DISABLE_NOTIFICATION_TICKER) != 0) {
11171141
if (mTicking && (state & StatusBarManager.DISABLE_NOTIFICATION_TICKER) != 0) {
1118-
Slog.d(TAG, "DISABLE_NOTIFICATION_TICKER: yes");
11191142
mTicker.halt();
11201143
}
11211144
}
11221145
}
11231146

1124-
private void setNavigationVisibility(int visibility) {
1125-
boolean disableNavigation = ((visibility & StatusBarManager.DISABLE_NAVIGATION) != 0);
1126-
boolean disableBack = ((visibility & StatusBarManager.DISABLE_BACK) != 0);
1127-
1128-
Slog.i(TAG, "DISABLE_BACK: " + (disableBack ? "yes" : "no"));
1129-
Slog.i(TAG, "DISABLE_NAVIGATION: " + (disableNavigation ? "yes" : "no"));
1130-
1131-
if (mNavigationBarView != null) {
1132-
mNavigationBarView.setNavigationVisibility(visibility);
1133-
}
1134-
1135-
if (disableNavigation) {
1136-
// close recents if it's visible
1137-
mHandler.removeMessages(MSG_CLOSE_RECENTS_PANEL);
1138-
mHandler.sendEmptyMessage(MSG_CLOSE_RECENTS_PANEL);
1139-
}
1140-
}
1141-
11421147
/**
11431148
* All changes to the status bar and notifications funnel through here and are batched.
11441149
*/

0 commit comments

Comments
 (0)