Merge "TabletStatusBar: Hide notifications during Setup Wizard" into jb-dev

This commit is contained in:
John Spurlock
2012-06-25 14:58:22 -07:00
committed by Android (Google) Code Review
5 changed files with 46 additions and 28 deletions

View File

@ -65,6 +65,7 @@ import com.android.systemui.recent.RecentsPanelView;
import com.android.systemui.recent.RecentTasksLoader;
import com.android.systemui.recent.TaskDescription;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.NotificationData.Entry;
import com.android.systemui.statusbar.policy.NotificationRowLayout;
import com.android.systemui.statusbar.tablet.StatusBarPanel;
@ -904,4 +905,21 @@ public abstract class BaseStatusBar extends SystemUI implements
}
}
}
// Q: What kinds of notifications should show during setup?
// A: Almost none! Only things coming from the system (package is "android") that also
// have special "kind" tags marking them as relevant for setup (see below).
protected boolean showNotificationEvenIfUnprovisioned(StatusBarNotification sbn) {
if ("android".equals(sbn.pkg)) {
if (sbn.notification.kind != null) {
for (String aKind : sbn.notification.kind) {
// IME switcher, created by InputMethodManagerService
if ("android.system.imeswitcher".equals(aKind)) return true;
// OTA availability & errors, created by SystemUpdateService
if ("android.system.update".equals(aKind)) return true;
}
}
}
return false;
}
}

View File

@ -821,23 +821,6 @@ public class PhoneStatusBar extends BaseStatusBar {
R.integer.config_show_search_delay);
}
// Q: What kinds of notifications should show during setup?
// A: Almost none! Only things coming from the system (package is "android") that also
// have special "kind" tags marking them as relevant for setup (see below).
private boolean showNotificationEvenIfUnprovisioned(StatusBarNotification sbn) {
if ("android".equals(sbn.pkg)) {
if (sbn.notification.kind != null) {
for (String aKind : sbn.notification.kind) {
// IME switcher, created by InputMethodManagerService
if ("android.system.imeswitcher".equals(aKind)) return true;
// OTA availability & errors, created by SystemUpdateService
if ("android.system.update".equals(aKind)) return true;
}
}
}
return false;
}
private void loadNotificationShade() {
if (mPile == null) return;

View File

@ -217,7 +217,7 @@ public class NotificationPanel extends RelativeLayout implements StatusBarPanel,
*/
public void onClick(View v) {
if (v == mTitleArea) {
if (mSettingsButton.isEnabled() && v == mTitleArea) {
swapPanels();
}
}
@ -280,7 +280,7 @@ public class NotificationPanel extends RelativeLayout implements StatusBarPanel,
public void updatePanelModeButtons() {
final boolean settingsVisible = (mSettingsView != null);
mSettingsButton.setVisibility(!settingsVisible ? View.VISIBLE : View.GONE);
mSettingsButton.setVisibility(!settingsVisible && mSettingsButton.isEnabled() ? View.VISIBLE : View.GONE);
mNotificationButton.setVisibility(settingsVisible ? View.VISIBLE : View.GONE);
}
@ -421,5 +421,12 @@ public class NotificationPanel extends RelativeLayout implements StatusBarPanel,
super.onTouchEvent(ev);
return handled;
}
public void setSettingsEnabled(boolean settingsEnabled) {
if (mSettingsButton != null) {
mSettingsButton.setEnabled(settingsEnabled);
mSettingsButton.setVisibility(settingsEnabled ? View.VISIBLE : View.GONE);
}
}
}

View File

@ -32,7 +32,7 @@ import com.android.systemui.R;
public class NotificationPanelTitle extends RelativeLayout implements View.OnClickListener {
private NotificationPanel mPanel;
private ArrayList<View> buttons;
private View mNotificationsButton;
private View mSettingsButton;
public NotificationPanelTitle(Context context, AttributeSet attrs) {
super(context, attrs);
@ -47,7 +47,7 @@ public class NotificationPanelTitle extends RelativeLayout implements View.OnCli
@Override
public void onFinishInflate() {
super.onFinishInflate();
buttons.add(findViewById(R.id.settings_button));
buttons.add(mSettingsButton = findViewById(R.id.settings_button));
buttons.add(findViewById(R.id.notification_button));
}
@ -63,6 +63,8 @@ public class NotificationPanelTitle extends RelativeLayout implements View.OnCli
@Override
public boolean onTouchEvent(MotionEvent e) {
if (!mSettingsButton.isEnabled())
return false;
switch (e.getAction()) {
case MotionEvent.ACTION_DOWN:
setPressed(true);
@ -88,7 +90,7 @@ public class NotificationPanelTitle extends RelativeLayout implements View.OnCli
@Override
public void onClick(View v) {
if (v == this) {
if (mSettingsButton.isEnabled() && v == this) {
mPanel.swapPanels();
}
}

View File

@ -1235,7 +1235,7 @@ public class TabletStatusBar extends BaseStatusBar implements
@Override
protected void setAreThereNotifications() {
if (mNotificationPanel != null) {
mNotificationPanel.setClearable(mNotificationData.hasClearableItems());
mNotificationPanel.setClearable(isDeviceProvisioned() && mNotificationData.hasClearableItems());
}
}
@ -1533,10 +1533,13 @@ public class TabletStatusBar extends BaseStatusBar implements
if (mInputMethodSwitchButton.getVisibility() != View.GONE) maxNotificationIconsCount --;
if (mCompatModeButton.getVisibility() != View.GONE) maxNotificationIconsCount --;
final boolean provisioned = isDeviceProvisioned();
// If the device hasn't been through Setup, we only show system notifications
for (int i=0; toShow.size()< maxNotificationIconsCount; i++) {
if (i >= N) break;
Entry ent = mNotificationData.get(N-i-1);
if (ent.notification.score >= HIDE_ICONS_BELOW_SCORE) {
if ((provisioned && ent.notification.score >= HIDE_ICONS_BELOW_SCORE)
|| showNotificationEvenIfUnprovisioned(ent.notification)) {
toShow.add(ent.icon);
}
}
@ -1567,9 +1570,13 @@ public class TabletStatusBar extends BaseStatusBar implements
ArrayList<View> toShow = new ArrayList<View>();
final boolean provisioned = isDeviceProvisioned();
// If the device hasn't been through Setup, we only show system notifications
for (int i=0; i<N; i++) {
View row = mNotificationData.get(N-i-1).row;
toShow.add(row);
Entry ent = mNotificationData.get(N-i-1);
if (provisioned || showNotificationEvenIfUnprovisioned(ent.notification)) {
toShow.add(ent.row);
}
}
ArrayList<View> toRemove = new ArrayList<View>();
@ -1588,11 +1595,12 @@ public class TabletStatusBar extends BaseStatusBar implements
View v = toShow.get(i);
if (v.getParent() == null) {
// the notification panel has the most important things at the bottom
mPile.addView(v, N-1-i);
mPile.addView(v, Math.min(toShow.size()-1-i, mPile.getChildCount()));
}
}
mNotificationPanel.setNotificationCount(N);
mNotificationPanel.setNotificationCount(toShow.size());
mNotificationPanel.setSettingsEnabled(isDeviceProvisioned());
}
@Override