Skip to content

Commit b032f9f

Browse files
John SpurlockAndroid (Google) Code Review
authored andcommitted
Merge "TabletStatusBar: Hide notifications during Setup Wizard" into jb-dev
2 parents c8c5e98 + 3623128 commit b032f9f

File tree

5 files changed

+46
-28
lines changed

5 files changed

+46
-28
lines changed

packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
import com.android.systemui.recent.RecentTasksLoader;
6666
import com.android.systemui.recent.TaskDescription;
6767
import com.android.systemui.statusbar.CommandQueue;
68+
import com.android.systemui.statusbar.NotificationData.Entry;
6869
import com.android.systemui.statusbar.policy.NotificationRowLayout;
6970
import com.android.systemui.statusbar.tablet.StatusBarPanel;
7071

@@ -904,4 +905,21 @@ public void updateNotification(IBinder key, StatusBarNotification notification)
904905
}
905906
}
906907
}
908+
909+
// Q: What kinds of notifications should show during setup?
910+
// A: Almost none! Only things coming from the system (package is "android") that also
911+
// have special "kind" tags marking them as relevant for setup (see below).
912+
protected boolean showNotificationEvenIfUnprovisioned(StatusBarNotification sbn) {
913+
if ("android".equals(sbn.pkg)) {
914+
if (sbn.notification.kind != null) {
915+
for (String aKind : sbn.notification.kind) {
916+
// IME switcher, created by InputMethodManagerService
917+
if ("android.system.imeswitcher".equals(aKind)) return true;
918+
// OTA availability & errors, created by SystemUpdateService
919+
if ("android.system.update".equals(aKind)) return true;
920+
}
921+
}
922+
}
923+
return false;
924+
}
907925
}

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

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -821,23 +821,6 @@ private void updateShowSearchHoldoff() {
821821
R.integer.config_show_search_delay);
822822
}
823823

824-
// Q: What kinds of notifications should show during setup?
825-
// A: Almost none! Only things coming from the system (package is "android") that also
826-
// have special "kind" tags marking them as relevant for setup (see below).
827-
private boolean showNotificationEvenIfUnprovisioned(StatusBarNotification sbn) {
828-
if ("android".equals(sbn.pkg)) {
829-
if (sbn.notification.kind != null) {
830-
for (String aKind : sbn.notification.kind) {
831-
// IME switcher, created by InputMethodManagerService
832-
if ("android.system.imeswitcher".equals(aKind)) return true;
833-
// OTA availability & errors, created by SystemUpdateService
834-
if ("android.system.update".equals(aKind)) return true;
835-
}
836-
}
837-
}
838-
return false;
839-
}
840-
841824
private void loadNotificationShade() {
842825
if (mPile == null) return;
843826

packages/SystemUI/src/com/android/systemui/statusbar/tablet/NotificationPanel.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ public void onSizeChanged(int w, int h, int oldw, int oldh) {
217217
*/
218218

219219
public void onClick(View v) {
220-
if (v == mTitleArea) {
220+
if (mSettingsButton.isEnabled() && v == mTitleArea) {
221221
swapPanels();
222222
}
223223
}
@@ -280,7 +280,7 @@ public void setClearable(boolean clearable) {
280280

281281
public void updatePanelModeButtons() {
282282
final boolean settingsVisible = (mSettingsView != null);
283-
mSettingsButton.setVisibility(!settingsVisible ? View.VISIBLE : View.GONE);
283+
mSettingsButton.setVisibility(!settingsVisible && mSettingsButton.isEnabled() ? View.VISIBLE : View.GONE);
284284
mNotificationButton.setVisibility(settingsVisible ? View.VISIBLE : View.GONE);
285285
}
286286

@@ -421,5 +421,12 @@ public boolean onTouchEvent(MotionEvent ev) {
421421
super.onTouchEvent(ev);
422422
return handled;
423423
}
424+
425+
public void setSettingsEnabled(boolean settingsEnabled) {
426+
if (mSettingsButton != null) {
427+
mSettingsButton.setEnabled(settingsEnabled);
428+
mSettingsButton.setVisibility(settingsEnabled ? View.VISIBLE : View.GONE);
429+
}
430+
}
424431
}
425432

packages/SystemUI/src/com/android/systemui/statusbar/tablet/NotificationPanelTitle.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
public class NotificationPanelTitle extends RelativeLayout implements View.OnClickListener {
3333
private NotificationPanel mPanel;
3434
private ArrayList<View> buttons;
35-
private View mNotificationsButton;
35+
private View mSettingsButton;
3636

3737
public NotificationPanelTitle(Context context, AttributeSet attrs) {
3838
super(context, attrs);
@@ -47,7 +47,7 @@ public void setPanel(NotificationPanel p) {
4747
@Override
4848
public void onFinishInflate() {
4949
super.onFinishInflate();
50-
buttons.add(findViewById(R.id.settings_button));
50+
buttons.add(mSettingsButton = findViewById(R.id.settings_button));
5151
buttons.add(findViewById(R.id.notification_button));
5252
}
5353

@@ -63,6 +63,8 @@ public void setPressed(boolean pressed) {
6363

6464
@Override
6565
public boolean onTouchEvent(MotionEvent e) {
66+
if (!mSettingsButton.isEnabled())
67+
return false;
6668
switch (e.getAction()) {
6769
case MotionEvent.ACTION_DOWN:
6870
setPressed(true);
@@ -88,7 +90,7 @@ public boolean onTouchEvent(MotionEvent e) {
8890

8991
@Override
9092
public void onClick(View v) {
91-
if (v == this) {
93+
if (mSettingsButton.isEnabled() && v == this) {
9294
mPanel.swapPanels();
9395
}
9496
}

packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,7 +1235,7 @@ private boolean isImmersive() {
12351235
@Override
12361236
protected void setAreThereNotifications() {
12371237
if (mNotificationPanel != null) {
1238-
mNotificationPanel.setClearable(mNotificationData.hasClearableItems());
1238+
mNotificationPanel.setClearable(isDeviceProvisioned() && mNotificationData.hasClearableItems());
12391239
}
12401240
}
12411241

@@ -1533,10 +1533,13 @@ protected void updateNotificationIcons() {
15331533
if (mInputMethodSwitchButton.getVisibility() != View.GONE) maxNotificationIconsCount --;
15341534
if (mCompatModeButton.getVisibility() != View.GONE) maxNotificationIconsCount --;
15351535

1536+
final boolean provisioned = isDeviceProvisioned();
1537+
// If the device hasn't been through Setup, we only show system notifications
15361538
for (int i=0; toShow.size()< maxNotificationIconsCount; i++) {
15371539
if (i >= N) break;
15381540
Entry ent = mNotificationData.get(N-i-1);
1539-
if (ent.notification.score >= HIDE_ICONS_BELOW_SCORE) {
1541+
if ((provisioned && ent.notification.score >= HIDE_ICONS_BELOW_SCORE)
1542+
|| showNotificationEvenIfUnprovisioned(ent.notification)) {
15401543
toShow.add(ent.icon);
15411544
}
15421545
}
@@ -1567,9 +1570,13 @@ private void loadNotificationPanel() {
15671570

15681571
ArrayList<View> toShow = new ArrayList<View>();
15691572

1573+
final boolean provisioned = isDeviceProvisioned();
1574+
// If the device hasn't been through Setup, we only show system notifications
15701575
for (int i=0; i<N; i++) {
1571-
View row = mNotificationData.get(N-i-1).row;
1572-
toShow.add(row);
1576+
Entry ent = mNotificationData.get(N-i-1);
1577+
if (provisioned || showNotificationEvenIfUnprovisioned(ent.notification)) {
1578+
toShow.add(ent.row);
1579+
}
15731580
}
15741581

15751582
ArrayList<View> toRemove = new ArrayList<View>();
@@ -1588,11 +1595,12 @@ private void loadNotificationPanel() {
15881595
View v = toShow.get(i);
15891596
if (v.getParent() == null) {
15901597
// the notification panel has the most important things at the bottom
1591-
mPile.addView(v, N-1-i);
1598+
mPile.addView(v, Math.min(toShow.size()-1-i, mPile.getChildCount()));
15921599
}
15931600
}
15941601

1595-
mNotificationPanel.setNotificationCount(N);
1602+
mNotificationPanel.setNotificationCount(toShow.size());
1603+
mNotificationPanel.setSettingsEnabled(isDeviceProvisioned());
15961604
}
15971605

15981606
@Override

0 commit comments

Comments
 (0)