diff options
Diffstat (limited to 'packages/SystemUI/src')
23 files changed, 415 insertions, 118 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java b/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java index 3574877..d5c90d0 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java @@ -132,6 +132,7 @@ public class QSTileView extends ViewGroup { mDualLabel = new QSDualTileLabel(mContext); mDualLabel.setId(android.R.id.title); mDualLabel.setBackgroundResource(R.drawable.btn_borderless_rect); + mDualLabel.setFirstLineCaret(res.getDrawable(R.drawable.qs_dual_tile_caret)); mDualLabel.setTextColor(res.getColor(R.color.qs_tile_text)); mDualLabel.setPadding(0, mDualTileVerticalPaddingPx, 0, mDualTileVerticalPaddingPx); mDualLabel.setTypeface(CONDENSED); diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java index e99b4c5..84bfb8f 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java @@ -77,7 +77,7 @@ public class BluetoothTile extends QSTile<QSTile.BooleanState> { @Override protected void handleSecondaryClick() { - mHost.startSettingsActivity(BLUETOOTH_SETTINGS); + showDetail(true); } @Override diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java index 0985812..20c4ee8 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java @@ -87,7 +87,15 @@ public class WifiTile extends QSTile<QSTile.SignalState> { @Override protected void handleSecondaryClick() { - mHost.startSettingsActivity(WIFI_SETTINGS); + if (!mController.canConfigWifi()) { + mHost.startSettingsActivity(new Intent(Settings.ACTION_WIFI_SETTINGS)); + return; + } + if (!mState.enabled) { + mController.setWifiEnabled(true); + mState.enabled = true; + } + showDetail(true); } @Override @@ -279,7 +287,9 @@ public class WifiTile extends QSTile<QSTile.SignalState> { if (item == null || item.tag == null) return; final AccessPoint ap = (AccessPoint) item.tag; if (!ap.isConnected) { - mController.connect(ap); + if (mController.connect(ap)) { + mHost.collapsePanels(); + } } showDetail(false); } diff --git a/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoader.java b/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoader.java index 594eb0e..b4f62d5 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoader.java +++ b/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoader.java @@ -171,6 +171,9 @@ class TaskResourceLoader implements Runnable { } } else { SystemServicesProxy ssp = mSystemServicesProxy; + // If we've stopped the loader, then fall thorugh to the above logic to wait on + // the load thread + if (ssp == null) continue; // Load the next item from the queue final Task t = mLoadQueue.nextTask(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java index 7c74246..1b4bdf8 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java @@ -297,7 +297,8 @@ public abstract class BaseStatusBar extends SystemUI implements // close the shade if it was open if (handled) { - animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE, true /* force */); + animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL, + true /* force */); visibilityChanged(false); } // Wait for activity start. @@ -374,7 +375,8 @@ public abstract class BaseStatusBar extends SystemUI implements Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.SHOW_NOTE_ABOUT_NOTIFICATION_HIDING, 0); if (BANNER_ACTION_SETUP.equals(action)) { - animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE, true /* force */); + animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL, + true /* force */); mContext.startActivity(new Intent(Settings.ACTION_APP_NOTIFICATION_REDACTION) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) @@ -799,7 +801,7 @@ public abstract class BaseStatusBar extends SystemUI implements } } }); - animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE, true /* force */); + animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL, true /* force */); return true; } }, false /* afterKeyguardGone */); @@ -1564,7 +1566,8 @@ public abstract class BaseStatusBar extends SystemUI implements }.start(); // close the shade if it was open - animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE, true /* force */); + animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL, + true /* force */); visibilityChanged(false); return mIntent != null && mIntent.isActivity(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/DemoStatusIcons.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/DemoStatusIcons.java index c5d06b9..682c01c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/DemoStatusIcons.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/DemoStatusIcons.java @@ -122,9 +122,14 @@ public class DemoStatusIcons extends LinearLayout implements DemoMode { } String cast = args.getString("cast"); if (cast != null) { - int iconId = cast.equals("cast") ? R.drawable.stat_sys_cast : 0; + int iconId = cast.equals("show") ? R.drawable.stat_sys_cast : 0; updateSlot("cast", null, iconId); } + String hotspot = args.getString("hotspot"); + if (hotspot != null) { + int iconId = hotspot.equals("show") ? R.drawable.stat_sys_hotspot : 0; + updateSlot("hotspot", null, iconId); + } } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeParameters.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeParameters.java index b566bbc..a956151 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeParameters.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeParameters.java @@ -72,6 +72,10 @@ public class DozeParameters { return getInt("doze.pulse.duration.in", R.integer.doze_pulse_duration_in); } + public int getPulseInDelay() { + return getInt("doze.pulse.delay.in", R.integer.doze_pulse_delay_in); + } + public int getPulseVisibleDuration() { return getInt("doze.pulse.duration.visible", R.integer.doze_pulse_duration_visible); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java index dd5df12..fddbee2 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java @@ -39,6 +39,8 @@ import android.util.TypedValue; import android.view.View; import android.view.ViewGroup; import android.view.accessibility.AccessibilityNodeInfo; +import android.view.animation.AnimationUtils; +import android.view.animation.Interpolator; import android.widget.FrameLayout; import android.widget.TextView; @@ -72,6 +74,8 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL private static final Intent INSECURE_CAMERA_INTENT = new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA); private static final Intent PHONE_INTENT = new Intent(Intent.ACTION_DIAL); + private static final int DOZE_ANIMATION_STAGGER_DELAY = 48; + private static final int DOZE_ANIMATION_ELEMENT_DURATION = 250; private KeyguardAffordanceView mCameraImageView; private KeyguardAffordanceView mPhoneImageView; @@ -92,7 +96,7 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL private PhoneStatusBar mPhoneStatusBar; private final TrustDrawable mTrustDrawable; - + private final Interpolator mLinearOutSlowInInterpolator; private int mLastUnlockIconRes = 0; public KeyguardBottomAreaView(Context context) { @@ -111,6 +115,8 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); mTrustDrawable = new TrustDrawable(mContext); + mLinearOutSlowInInterpolator = + AnimationUtils.loadInterpolator(context, android.R.interpolator.linear_out_slow_in); } private AccessibilityDelegate mAccessibilityDelegate = new AccessibilityDelegate() { @@ -133,7 +139,7 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL if (action == ACTION_CLICK) { if (host == mLockIcon) { mPhoneStatusBar.animateCollapsePanels( - CommandQueue.FLAG_EXCLUDE_NONE, true /* force */); + CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL, true /* force */); return true; } else if (host == mCameraImageView) { launchCamera(); @@ -450,6 +456,35 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL } } + public void startFinishDozeAnimation() { + long delay = 0; + if (mPhoneImageView.getVisibility() == View.VISIBLE) { + startFinishDozeAnimationElement(mPhoneImageView, delay); + delay += DOZE_ANIMATION_STAGGER_DELAY; + } + startFinishDozeAnimationElement(mLockIcon, delay); + delay += DOZE_ANIMATION_STAGGER_DELAY; + if (mCameraImageView.getVisibility() == View.VISIBLE) { + startFinishDozeAnimationElement(mCameraImageView, delay); + } + mIndicationText.setAlpha(0f); + mIndicationText.animate() + .alpha(1f) + .setInterpolator(mLinearOutSlowInInterpolator) + .setDuration(NotificationPanelView.DOZE_ANIMATION_DURATION); + } + + private void startFinishDozeAnimationElement(View element, long delay) { + element.setAlpha(0f); + element.setTranslationY(element.getHeight() / 2); + element.animate() + .alpha(1f) + .translationY(0f) + .setInterpolator(mLinearOutSlowInInterpolator) + .setStartDelay(delay) + .setDuration(DOZE_ANIMATION_ELEMENT_DURATION); + } + private final BroadcastReceiver mDevicePolicyReceiver = new BroadcastReceiver() { public void onReceive(Context context, Intent intent) { post(new Runnable() { @@ -477,6 +512,11 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL public void onScreenTurnedOff(int why) { updateLockIcon(); } + + @Override + public void onKeyguardVisibilityChanged(boolean showing) { + updateLockIcon(); + } }; public void setKeyguardIndicationController( diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java index 88e71e2..9bb52e7 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java @@ -33,12 +33,14 @@ import android.os.Message; import android.util.AttributeSet; import android.util.Log; import android.view.Display; +import android.view.Gravity; import android.view.MotionEvent; import android.view.Surface; import android.view.View; import android.view.ViewGroup; import android.view.WindowManager; import android.view.inputmethod.InputMethodManager; +import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.LinearLayout; import com.android.systemui.R; @@ -503,15 +505,31 @@ public class NavigationBarView extends LinearLayout { // We swap all children of the 90 and 270 degree layouts, since they are vertical View rotation90 = mRotatedViews[Surface.ROTATION_90]; swapChildrenOrderIfVertical(rotation90.findViewById(R.id.nav_buttons)); + adjustExtraKeyGravity(rotation90, isLayoutRtl); View rotation270 = mRotatedViews[Surface.ROTATION_270]; if (rotation90 != rotation270) { swapChildrenOrderIfVertical(rotation270.findViewById(R.id.nav_buttons)); + adjustExtraKeyGravity(rotation270, isLayoutRtl); } mIsLayoutRtl = isLayoutRtl; } } + private void adjustExtraKeyGravity(View navBar, boolean isLayoutRtl) { + View menu = navBar.findViewById(R.id.menu); + View imeSwitcher = navBar.findViewById(R.id.ime_switcher); + if (menu != null) { + FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) menu.getLayoutParams(); + lp.gravity = isLayoutRtl ? Gravity.BOTTOM : Gravity.TOP; + menu.setLayoutParams(lp); + } + if (imeSwitcher != null) { + FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) imeSwitcher.getLayoutParams(); + lp.gravity = isLayoutRtl ? Gravity.BOTTOM : Gravity.TOP; + imeSwitcher.setLayoutParams(lp); + } + } /** * Swaps the children order of a LinearLayout if it's orientation is Vertical diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java index c19bdff..0bde7ef 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java @@ -64,7 +64,7 @@ public class NotificationPanelView extends PanelView implements private static final int DOZE_BACKGROUND_COLOR = 0xff000000; private static final int TAG_KEY_ANIM = R.id.scrim; - private static final long DOZE_BACKGROUND_ANIM_DURATION = ScrimController.ANIMATION_DURATION; + public static final long DOZE_ANIMATION_DURATION = 700; private KeyguardAffordanceHelper mAfforanceHelper; private StatusBarHeaderView mHeader; @@ -132,6 +132,7 @@ public class NotificationPanelView extends PanelView implements private Interpolator mFastOutSlowInInterpolator; private Interpolator mFastOutLinearInterpolator; + private Interpolator mDozeAnimationInterpolator; private ObjectAnimator mClockAnimator; private int mClockAnimationTarget = -1; private int mTopPaddingAdjustment; @@ -167,6 +168,8 @@ public class NotificationPanelView extends PanelView implements private boolean mQsTouchAboveFalsingThreshold; private int mQsFalsingThreshold; + private float mKeyguardStatusBarAnimateAlpha = 1f; + public NotificationPanelView(Context context, AttributeSet attrs) { super(context, attrs); } @@ -199,6 +202,8 @@ public class NotificationPanelView extends PanelView implements android.R.interpolator.fast_out_slow_in); mFastOutLinearInterpolator = AnimationUtils.loadInterpolator(getContext(), android.R.interpolator.fast_out_linear_in); + mDozeAnimationInterpolator = AnimationUtils.loadInterpolator(getContext(), + android.R.interpolator.linear_out_slow_in); mKeyguardBottomArea = (KeyguardBottomAreaView) findViewById(R.id.keyguard_bottom_area); mQsNavbarScrim = findViewById(R.id.qs_navbar_scrim); mAfforanceHelper = new KeyguardAffordanceHelper(this, getContext()); @@ -909,6 +914,8 @@ public class NotificationPanelView extends PanelView implements @Override public void run() { mKeyguardStatusBar.setVisibility(View.INVISIBLE); + mKeyguardStatusBar.setAlpha(1f); + mKeyguardStatusBarAnimateAlpha = 1f; } }; @@ -918,10 +925,31 @@ public class NotificationPanelView extends PanelView implements .setStartDelay(mStatusBar.getKeyguardFadingAwayDelay()) .setDuration(mStatusBar.getKeyguardFadingAwayDuration()/2) .setInterpolator(PhoneStatusBar.ALPHA_OUT) + .setUpdateListener(mStatusBarAnimateAlphaListener) .withEndAction(mAnimateKeyguardStatusBarInvisibleEndRunnable) .start(); } + private final ValueAnimator.AnimatorUpdateListener mStatusBarAnimateAlphaListener = + new ValueAnimator.AnimatorUpdateListener() { + @Override + public void onAnimationUpdate(ValueAnimator animation) { + mKeyguardStatusBarAnimateAlpha = mKeyguardStatusBar.getAlpha(); + } + }; + + private void animateKeyguardStatusBarIn() { + mKeyguardStatusBar.setVisibility(View.VISIBLE); + mKeyguardStatusBar.setAlpha(0f); + mKeyguardStatusBar.animate() + .alpha(1f) + .setStartDelay(0) + .setDuration(DOZE_ANIMATION_DURATION) + .setInterpolator(mDozeAnimationInterpolator) + .setUpdateListener(mStatusBarAnimateAlphaListener) + .start(); + } + private final Runnable mAnimateKeyguardBottomAreaInvisibleEndRunnable = new Runnable() { @Override public void run() { @@ -1012,7 +1040,7 @@ public class NotificationPanelView extends PanelView implements ? View.VISIBLE : View.INVISIBLE); if (mKeyguardUserSwitcher != null && mQsExpanded && !mStackScrollerOverscrolling) { - mKeyguardUserSwitcher.hide(true /* animate */); + mKeyguardUserSwitcher.hideIfNotSimple(true /* animate */); } } @@ -1387,7 +1415,8 @@ public class NotificationPanelView extends PanelView implements alphaNotifications = MathUtils.constrain(alphaNotifications, 0, 1); alphaNotifications = (float) Math.pow(alphaNotifications, 0.75); float alphaQsExpansion = 1 - Math.min(1, getQsExpansionFraction() * 2); - mKeyguardStatusBar.setAlpha(Math.min(alphaNotifications, alphaQsExpansion)); + mKeyguardStatusBar.setAlpha(Math.min(alphaNotifications, alphaQsExpansion) + * mKeyguardStatusBarAnimateAlpha); mKeyguardBottomArea.setAlpha(Math.min(1 - getQsExpansionFraction(), alphaNotifications)); setQsTranslation(mQsExpansionHeight); } @@ -1736,19 +1765,22 @@ public class NotificationPanelView extends PanelView implements return (1 - t) * start + t * end; } - private void updateKeyguardStatusBarVisibility() { - mKeyguardStatusBar.setVisibility(mKeyguardShowing && !mDozing ? VISIBLE : INVISIBLE); - } - - public void setDozing(boolean dozing) { + public void setDozing(boolean dozing, boolean animate) { if (dozing == mDozing) return; mDozing = dozing; if (mDozing) { - setBackgroundColorAlpha(this, DOZE_BACKGROUND_COLOR, 0xff, false /*animate*/); + setBackgroundColorAlpha(DOZE_BACKGROUND_COLOR, 0xff, false /*animate*/); + mKeyguardStatusBar.setVisibility(View.INVISIBLE); + mKeyguardBottomArea.setVisibility(View.INVISIBLE); } else { - setBackgroundColorAlpha(this, DOZE_BACKGROUND_COLOR, 0, true /*animate*/); + setBackgroundColorAlpha(DOZE_BACKGROUND_COLOR, 0, animate); + mKeyguardBottomArea.setVisibility(View.VISIBLE); + mKeyguardStatusBar.setVisibility(View.VISIBLE); + if (animate) { + animateKeyguardStatusBarIn(); + mKeyguardBottomArea.startFinishDozeAnimation(); + } } - updateKeyguardStatusBarVisibility(); } @Override @@ -1756,21 +1788,21 @@ public class NotificationPanelView extends PanelView implements return mDozing; } - private static void setBackgroundColorAlpha(final View target, int rgb, int targetAlpha, + private void setBackgroundColorAlpha(int rgb, int targetAlpha, boolean animate) { - int currentAlpha = getBackgroundAlpha(target); + int currentAlpha = getBackgroundAlpha(this); if (currentAlpha == targetAlpha) { return; } final int r = Color.red(rgb); final int g = Color.green(rgb); final int b = Color.blue(rgb); - Object runningAnim = target.getTag(TAG_KEY_ANIM); + Object runningAnim = getTag(TAG_KEY_ANIM); if (runningAnim instanceof ValueAnimator) { ((ValueAnimator) runningAnim).cancel(); } if (!animate) { - target.setBackgroundColor(Color.argb(targetAlpha, r, g, b)); + setBackgroundColor(Color.argb(targetAlpha, r, g, b)); return; } ValueAnimator anim = ValueAnimator.ofInt(currentAlpha, targetAlpha); @@ -1778,18 +1810,19 @@ public class NotificationPanelView extends PanelView implements @Override public void onAnimationUpdate(ValueAnimator animation) { int value = (int) animation.getAnimatedValue(); - target.setBackgroundColor(Color.argb(value, r, g, b)); + setBackgroundColor(Color.argb(value, r, g, b)); } }); - anim.setDuration(DOZE_BACKGROUND_ANIM_DURATION); + anim.setInterpolator(mDozeAnimationInterpolator); + anim.setDuration(DOZE_ANIMATION_DURATION); anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { - target.setTag(TAG_KEY_ANIM, null); + setTag(TAG_KEY_ANIM, null); } }); anim.start(); - target.setTag(TAG_KEY_ANIM, anim); + setTag(TAG_KEY_ANIM, anim); } private static int getBackgroundAlpha(View view) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index be27ddc..eb48754 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -584,7 +584,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, addNavigationBar(); // Lastly, call to the icon policy to install/update all the icons. - mIconPolicy = new PhoneStatusBarPolicy(mContext, mCastController); + mIconPolicy = new PhoneStatusBarPolicy(mContext, mCastController, mHotspotController); mSettingsObserver.onChange(false); // set up mHeadsUpObserver.onChange(true); // set up @@ -3052,7 +3052,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, } }); if (dismissShade) { - animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE, true /* force */); + animateCollapsePanels( + CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL, true /* force */); } return true; } @@ -3680,15 +3681,13 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, if (mState != StatusBarState.KEYGUARD && !mNotificationPanel.isDozing()) { return; } - mNotificationPanel.setDozing(mDozing); + mNotificationPanel.setDozing(mDozing, mScrimController.isPulsing() /*animate*/); if (mDozing) { - mKeyguardBottomArea.setVisibility(View.INVISIBLE); mStackScroller.setDark(true, false /*animate*/); } else { - mKeyguardBottomArea.setVisibility(View.VISIBLE); mStackScroller.setDark(false, false /*animate*/); } - mScrimController.setDozing(mDozing); + mScrimController.setDozing(mDozing, mScrimController.isPulsing() /*animate*/); } public void updateStackScrollerState(boolean goingToFullShade) { @@ -3741,7 +3740,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, public boolean onSpacePressed() { if (mScreenOn != null && mScreenOn && (mState == StatusBarState.KEYGUARD || mState == StatusBarState.SHADE_LOCKED)) { - animateCollapsePanels(0 /* flags */, true /* force */); + animateCollapsePanels( + CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL /* flags */, true /* force */); return true; } return false; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java index 47e1ab5..60d23ce 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java @@ -35,6 +35,7 @@ import com.android.internal.telephony.TelephonyIntents; import com.android.systemui.R; import com.android.systemui.statusbar.policy.CastController; import com.android.systemui.statusbar.policy.CastController.CastDevice; +import com.android.systemui.statusbar.policy.HotspotController; /** * This class contains all of the policy about which icons are installed in the status @@ -49,6 +50,7 @@ public class PhoneStatusBarPolicy { private static final String SLOT_SYNC_ACTIVE = "sync_active"; private static final String SLOT_CAST = "cast"; + private static final String SLOT_HOTSPOT = "hotspot"; private static final String SLOT_BLUETOOTH = "bluetooth"; private static final String SLOT_TTY = "tty"; private static final String SLOT_ZEN = "zen"; @@ -60,6 +62,7 @@ public class PhoneStatusBarPolicy { private final StatusBarManager mService; private final Handler mHandler = new Handler(); private final CastController mCast; + private final HotspotController mHotspot; // Assume it's all good unless we hear otherwise. We don't always seem // to get broadcasts that it *is* there. @@ -102,9 +105,10 @@ public class PhoneStatusBarPolicy { } }; - public PhoneStatusBarPolicy(Context context, CastController cast) { + public PhoneStatusBarPolicy(Context context, CastController cast, HotspotController hotspot) { mContext = context; mCast = cast; + mHotspot = hotspot; mService = (StatusBarManager)context.getSystemService(Context.STATUS_BAR_SERVICE); // listen for broadcasts @@ -152,6 +156,11 @@ public class PhoneStatusBarPolicy { mService.setIcon(SLOT_CAST, R.drawable.stat_sys_cast, 0, null); mService.setIconVisibility(SLOT_CAST, false); mCast.addCallback(mCastCallback); + + // hotspot + mService.setIcon(SLOT_HOTSPOT, R.drawable.stat_sys_hotspot, 0, null); + mService.setIconVisibility(SLOT_HOTSPOT, mHotspot.isHotspotEnabled()); + mHotspot.addCallback(mHotspotCallback); } public void setZenMode(int zen) { @@ -300,6 +309,13 @@ public class PhoneStatusBarPolicy { mService.setIconVisibility(SLOT_CAST, isCasting); } + private final HotspotController.Callback mHotspotCallback = new HotspotController.Callback() { + @Override + public void onHotspotChanged(boolean enabled) { + mService.setIconVisibility(SLOT_HOTSPOT, enabled); + } + }; + private final CastController.Callback mCastCallback = new CastController.Callback() { @Override public void onCastDevicesChanged() { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QSTileHost.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QSTileHost.java index 2dc08d4..a4db46a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QSTileHost.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QSTileHost.java @@ -120,6 +120,7 @@ public class QSTileHost implements QSTile.Host { tile.userSwitch(newUserId); } mSecurity.onUserSwitched(newUserId); + mNetwork.onUserSwitched(newUserId); mObserver.register(); } }; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java index 54adbf4..10d6594 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java @@ -28,6 +28,7 @@ import android.view.ViewTreeObserver; import android.view.animation.AnimationUtils; import android.view.animation.DecelerateInterpolator; import android.view.animation.Interpolator; +import android.view.animation.PathInterpolator; import com.android.systemui.R; import com.android.systemui.doze.DozeHost; @@ -70,9 +71,12 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener { private Runnable mOnAnimationFinished; private boolean mAnimationStarted; private boolean mDozing; + private boolean mPulsingOut; private DozeHost.PulseCallback mPulseCallback; private final Interpolator mInterpolator = new DecelerateInterpolator(); private final Interpolator mLinearOutSlowInInterpolator; + private final Interpolator mPulseInInterpolator = PhoneStatusBar.ALPHA_OUT; + private final Interpolator mPulseOutInterpolator = PhoneStatusBar.ALPHA_IN; private BackDropView mBackDropView; private boolean mScrimSrcEnabled; @@ -130,14 +134,12 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener { scheduleUpdate(); } - public void setDozing(boolean dozing) { + public void setDozing(boolean dozing, boolean animate) { if (mDozing == dozing) return; mDozing = dozing; if (!mDozing) { cancelPulsing(); - mAnimateChange = true; - } else { - mAnimateChange = false; + mAnimateChange = animate; } scheduleUpdate(); } @@ -181,6 +183,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener { } private void pulseFinished() { + mPulsingOut = false; if (mPulseCallback != null) { mPulseCallback.onPulseFinished(); mPulseCallback = null; @@ -220,8 +223,12 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener { } else if (mBouncerShowing) { setScrimInFrontColor(SCRIM_IN_FRONT_ALPHA); setScrimBehindColor(0f); + } else if (mDozing && isPulsing() && !mPulsingOut) { + setScrimInFrontColor(0); + setScrimBehindColor(SCRIM_BEHIND_ALPHA_KEYGUARD); } else if (mDozing) { setScrimInFrontColor(1); + setScrimBehindColor(SCRIM_BEHIND_ALPHA_KEYGUARD); } else { float fraction = Math.max(0, Math.min(mFraction, 1)); setScrimInFrontColor(0f); @@ -276,7 +283,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener { private void startScrimAnimation(final ScrimView scrim, int targetColor) { int current = Color.alpha(scrim.getScrimColor()); int target = Color.alpha(targetColor); - if (current == targetColor) { + if (current == target) { return; } ValueAnimator anim = ValueAnimator.ofInt(current, target); @@ -287,9 +294,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener { scrim.setScrimColor(Color.argb(value, 0, 0, 0)); } }); - anim.setInterpolator(mAnimateKeyguardFadingOut - ? mLinearOutSlowInInterpolator - : mInterpolator); + anim.setInterpolator(getInterpolator()); anim.setStartDelay(mAnimationDelay); anim.setDuration(mDurationOverride != -1 ? mDurationOverride : ANIMATION_DURATION); anim.addListener(new AnimatorListenerAdapter() { @@ -307,6 +312,18 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener { mAnimationStarted = true; } + private Interpolator getInterpolator() { + if (mAnimateKeyguardFadingOut) { + return mLinearOutSlowInInterpolator; + } else if (isPulsing() && !mPulsingOut) { + return mPulseInInterpolator; + } else if (isPulsing()) { + return mPulseOutInterpolator; + } else { + return mInterpolator; + } + } + @Override public boolean onPreDraw() { mScrimBehind.getViewTreeObserver().removeOnPreDrawListener(this); @@ -332,10 +349,10 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener { if (!mDozing) return; DozeLog.tracePulseStart(); mDurationOverride = mDozeParameters.getPulseInDuration(); - mAnimationDelay = 0; + mAnimationDelay = mDozeParameters.getPulseInDelay(); mAnimateChange = true; mOnAnimationFinished = mPulseInFinished; - setScrimColor(mScrimInFront, 0); + scheduleUpdate(); // Signal that the pulse is ready to turn the screen on and draw. pulseStarted(); @@ -357,10 +374,10 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener { if (DEBUG) Log.d(TAG, "Pulse out, mDozing=" + mDozing); if (!mDozing) return; mDurationOverride = mDozeParameters.getPulseOutDuration(); - mAnimationDelay = 0; mAnimateChange = true; mOnAnimationFinished = mPulseOutFinished; - setScrimColor(mScrimInFront, 1); + mPulsingOut = true; + scheduleUpdate(); } }; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/WifiAccessPointController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/AccessPointController.java index b800fbf..0a385d7 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/WifiAccessPointController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/AccessPointController.java @@ -16,15 +16,20 @@ package com.android.systemui.statusbar.policy; +import android.app.ActivityManager; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.net.wifi.ScanResult; import android.net.wifi.WifiConfiguration; +import android.net.wifi.WifiConfiguration.KeyMgmt; import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; import android.net.wifi.WifiManager.ActionListener; +import android.os.UserHandle; +import android.os.UserManager; +import android.provider.Settings; import android.text.TextUtils; import android.util.ArrayMap; import android.util.ArraySet; @@ -39,9 +44,13 @@ import java.util.Collections; import java.util.Comparator; import java.util.List; -public class WifiAccessPointController { - private static final String TAG = "WifiAccessPointController"; - private static final boolean DEBUG = false; +public class AccessPointController { + private static final String TAG = "AccessPointController"; + private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); + + // This string extra specifies a network to open the connect dialog on, so the user can enter + // network credentials. This is used by quick settings for secured networks. + private static final String EXTRA_START_CONNECT_SSID = "wifi_start_connect_ssid"; private static final int[] ICONS = { R.drawable.ic_qs_wifi_0, @@ -54,13 +63,26 @@ public class WifiAccessPointController { private final Context mContext; private final ArrayList<AccessPointCallback> mCallbacks = new ArrayList<AccessPointCallback>(); private final WifiManager mWifiManager; + private final UserManager mUserManager; private final Receiver mReceiver = new Receiver(); private boolean mScanning; + private int mCurrentUser; - public WifiAccessPointController(Context context) { + public AccessPointController(Context context) { mContext = context; mWifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE); + mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE); + mCurrentUser = ActivityManager.getCurrentUser(); + } + + public boolean canConfigWifi() { + return !mUserManager.hasUserRestriction(UserManager.DISALLOW_CONFIG_WIFI, + new UserHandle(mCurrentUser)); + } + + void onUserSwitched(int newUserId) { + mCurrentUser = newUserId; } public void addCallback(AccessPointCallback callback) { @@ -81,22 +103,31 @@ public class WifiAccessPointController { if (mScanning) return; if (DEBUG) Log.d(TAG, "scan!"); mScanning = mWifiManager.startScan(); + // Grab current networks immediately while we wait for scan. + updateAccessPoints(); } - public void connect(AccessPoint ap) { - if (ap == null || ap.networkId < 0) return; + public boolean connect(AccessPoint ap) { + if (ap == null) return false; if (DEBUG) Log.d(TAG, "connect networkId=" + ap.networkId); - mWifiManager.connect(ap.networkId, new ActionListener() { - @Override - public void onSuccess() { - if (DEBUG) Log.d(TAG, "connect success"); - } - - @Override - public void onFailure(int reason) { - if (DEBUG) Log.d(TAG, "connect failure reason=" + reason); + if (ap.networkId < 0) { + // Unknown network, need to add it. + if (ap.hasSecurity) { + Intent intent = new Intent(Settings.ACTION_WIFI_SETTINGS); + intent.putExtra(EXTRA_START_CONNECT_SSID, ap.ssid); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + mContext.startActivity(intent); + return true; + } else { + WifiConfiguration config = new WifiConfiguration(); + config.SSID = "\"" + ap.ssid + "\""; + config.allowedKeyManagement.set(KeyMgmt.NONE); + mWifiManager.connect(config, mConnectListener); } - }); + } else { + mWifiManager.connect(ap.networkId, mConnectListener); + } + return false; } private void fireCallback(AccessPoint[] aps) { @@ -139,23 +170,40 @@ public class WifiAccessPointController { } final String ssid = scanResult.SSID; if (TextUtils.isEmpty(ssid) || ssids.contains(ssid)) continue; - if (!configured.containsKey(ssid)) continue; ssids.add(ssid); final WifiConfiguration config = configured.get(ssid); final int level = WifiManager.calculateSignalLevel(scanResult.level, ICONS.length); final AccessPoint ap = new AccessPoint(); + ap.isConfigured = config != null; ap.networkId = config != null ? config.networkId : AccessPoint.NO_NETWORK; ap.ssid = ssid; ap.iconId = ICONS[level]; ap.isConnected = ap.networkId != AccessPoint.NO_NETWORK && ap.networkId == connectedNetworkId; ap.level = level; + // Based on Settings AccessPoint#getSecurity, keep up to date + // with better methods of determining no security or not. + ap.hasSecurity = scanResult.capabilities.contains("WEP") + || scanResult.capabilities.contains("PSK") + || scanResult.capabilities.contains("EAP"); aps.add(ap); } Collections.sort(aps, mByStrength); fireCallback(aps.toArray(new AccessPoint[aps.size()])); } + private final ActionListener mConnectListener = new ActionListener() { + @Override + public void onSuccess() { + if (DEBUG) Log.d(TAG, "connect success"); + } + + @Override + public void onFailure(int reason) { + if (DEBUG) Log.d(TAG, "connect failure reason=" + reason); + } + }; + private final Comparator<AccessPoint> mByStrength = new Comparator<AccessPoint> () { @Override public int compare(AccessPoint lhs, AccessPoint rhs) { @@ -163,7 +211,7 @@ public class WifiAccessPointController { } private int score(AccessPoint ap) { - return ap.level + (ap.isConnected ? 10 : 0); + return ap.level + (ap.isConnected ? 20 : 0) + (ap.isConfigured ? 10 : 0); } }; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/FlashlightController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/FlashlightController.java index 6f021ac..33f7aff 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/FlashlightController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/FlashlightController.java @@ -308,7 +308,11 @@ public class FlashlightController { new CameraCaptureSession.StateListener() { @Override public void onConfigured(CameraCaptureSession session) { - mSession = session; + if (session.getDevice() == mCameraDevice) { + mSession = session; + } else { + session.close(); + } postUpdateFlashlight(); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonRipple.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonRipple.java index a3765aa..6998791 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonRipple.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonRipple.java @@ -102,7 +102,6 @@ public class KeyButtonRipple extends Drawable { } } - @Override public void draw(Canvas canvas) { mSupportHardware = canvas.isHardwareAccelerated(); @@ -176,6 +175,11 @@ public class KeyButtonRipple extends Drawable { } @Override + public void jumpToCurrentState() { + cancelAnimations(); + } + + @Override public boolean isStateful() { return true; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java index 7cc75da..b9cc0f9 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java @@ -17,38 +17,27 @@ package com.android.systemui.statusbar.policy; import android.animation.Animator; -import android.animation.AnimatorSet; import android.animation.ObjectAnimator; -import android.animation.TimeInterpolator; import android.app.ActivityManager; import android.content.Context; import android.content.res.TypedArray; -import android.graphics.Canvas; -import android.graphics.CanvasProperty; -import android.graphics.Paint; -import android.graphics.RectF; import android.hardware.input.InputManager; import android.media.AudioManager; import android.os.Bundle; import android.os.SystemClock; import android.util.AttributeSet; import android.util.Log; -import android.util.MathUtils; import android.view.HapticFeedbackConstants; -import android.view.HardwareCanvas; import android.view.InputDevice; import android.view.KeyCharacterMap; import android.view.KeyEvent; import android.view.MotionEvent; -import android.view.RenderNodeAnimator; import android.view.SoundEffectConstants; import android.view.View; import android.view.ViewConfiguration; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityNodeInfo; import android.widget.ImageView; -import java.lang.Math; -import java.util.ArrayList; import com.android.systemui.R; @@ -124,6 +113,14 @@ public class KeyButtonView extends ImageView { } @Override + protected void onWindowVisibilityChanged(int visibility) { + super.onWindowVisibilityChanged(visibility); + if (visibility != View.VISIBLE) { + jumpDrawablesToCurrentState(); + } + } + + @Override public boolean performAccessibilityAction(int action, Bundle arguments) { if (action == ACTION_CLICK && mCode != 0) { sendEvent(KeyEvent.ACTION_DOWN, 0, SystemClock.uptimeMillis()); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcher.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcher.java index 8f0000f..297ff70 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcher.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcher.java @@ -19,15 +19,16 @@ package com.android.systemui.statusbar.policy; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; -import android.animation.ValueAnimator; import android.content.Context; import android.database.DataSetObserver; +import android.util.AttributeSet; import android.view.LayoutInflater; +import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.view.ViewStub; import android.view.animation.AnimationUtils; -import android.widget.TextView; +import android.widget.FrameLayout; import com.android.keyguard.AppearAnimationUtils; import com.android.systemui.R; @@ -35,8 +36,6 @@ import com.android.systemui.qs.tiles.UserDetailItemView; import com.android.systemui.statusbar.phone.KeyguardStatusBarView; import com.android.systemui.statusbar.phone.NotificationPanelView; import com.android.systemui.statusbar.phone.PhoneStatusBar; -import com.android.systemui.statusbar.phone.StatusBarHeaderView; -import com.android.systemui.statusbar.phone.UserAvatarView; /** * Manages the user switcher on the Keyguard. @@ -46,6 +45,7 @@ public class KeyguardUserSwitcher { private static final String TAG = "KeyguardUserSwitcher"; private static final boolean ALWAYS_ON = false; + private final Container mUserSwitcherContainer; private final ViewGroup mUserSwitcher; private final KeyguardStatusBarView mStatusBarView; private final Adapter mAdapter; @@ -53,24 +53,29 @@ public class KeyguardUserSwitcher { private final KeyguardUserSwitcherScrim mBackground; private ObjectAnimator mBgAnimator; private UserSwitcherController mUserSwitcherController; + private boolean mAnimating; public KeyguardUserSwitcher(Context context, ViewStub userSwitcher, KeyguardStatusBarView statusBarView, NotificationPanelView panelView, UserSwitcherController userSwitcherController) { if (context.getResources().getBoolean(R.bool.config_keyguardUserSwitcher) || ALWAYS_ON) { - mUserSwitcher = (ViewGroup) userSwitcher.inflate(); + mUserSwitcherContainer = (Container) userSwitcher.inflate(); + mUserSwitcher = (ViewGroup) + mUserSwitcherContainer.findViewById(R.id.keyguard_user_switcher_inner); mBackground = new KeyguardUserSwitcherScrim(mUserSwitcher); mUserSwitcher.setBackground(mBackground); mStatusBarView = statusBarView; mStatusBarView.setKeyguardUserSwitcher(this); panelView.setKeyguardUserSwitcher(this); - mAdapter = new Adapter(context, userSwitcherController); + mAdapter = new Adapter(context, userSwitcherController, this); mAdapter.registerDataSetObserver(mDataSetObserver); mUserSwitcherController = userSwitcherController; mAppearAnimationUtils = new AppearAnimationUtils(context, 400, -0.5f, 0.5f, AnimationUtils.loadInterpolator( context, android.R.interpolator.fast_out_slow_in)); + mUserSwitcherContainer.setKeyguardUserSwitcher(this); } else { + mUserSwitcherContainer = null; mUserSwitcher = null; mStatusBarView = null; mAdapter = null; @@ -98,9 +103,9 @@ public class KeyguardUserSwitcher { } public void show(boolean animate) { - if (mUserSwitcher != null && mUserSwitcher.getVisibility() != View.VISIBLE) { + if (mUserSwitcher != null && mUserSwitcherContainer.getVisibility() != View.VISIBLE) { cancelAnimations(); - mUserSwitcher.setVisibility(View.VISIBLE); + mUserSwitcherContainer.setVisibility(View.VISIBLE); mStatusBarView.setKeyguardUserSwitcherShowing(true, animate); if (animate) { startAppearAnimation(); @@ -108,13 +113,13 @@ public class KeyguardUserSwitcher { } } - public void hide(boolean animate) { - if (mUserSwitcher != null && mUserSwitcher.getVisibility() == View.VISIBLE) { + private void hide(boolean animate) { + if (mUserSwitcher != null && mUserSwitcherContainer.getVisibility() == View.VISIBLE) { cancelAnimations(); if (animate) { startDisappearAnimation(); } else { - mUserSwitcher.setVisibility(View.GONE); + mUserSwitcherContainer.setVisibility(View.GONE); } mStatusBarView.setKeyguardUserSwitcherShowing(false, animate); } @@ -129,6 +134,7 @@ public class KeyguardUserSwitcher { mBgAnimator.cancel(); } mUserSwitcher.animate().cancel(); + mAnimating = false; } private void startAppearAnimation() { @@ -146,6 +152,7 @@ public class KeyguardUserSwitcher { mUserSwitcher.setClipToPadding(true); } }); + mAnimating = true; mBgAnimator = ObjectAnimator.ofInt(mBackground, "alpha", 0, 255); mBgAnimator.setDuration(400); mBgAnimator.setInterpolator(PhoneStatusBar.ALPHA_IN); @@ -153,12 +160,14 @@ public class KeyguardUserSwitcher { @Override public void onAnimationEnd(Animator animation) { mBgAnimator = null; + mAnimating = false; } }); mBgAnimator.start(); } private void startDisappearAnimation() { + mAnimating = true; mUserSwitcher.animate() .alpha(0f) .setDuration(300) @@ -166,8 +175,9 @@ public class KeyguardUserSwitcher { .withEndAction(new Runnable() { @Override public void run() { - mUserSwitcher.setVisibility(View.GONE); + mUserSwitcherContainer.setVisibility(View.GONE); mUserSwitcher.setAlpha(1f); + mAnimating = false; } }); } @@ -198,6 +208,16 @@ public class KeyguardUserSwitcher { } } + public void hideIfNotSimple(boolean animate) { + if (mUserSwitcherContainer != null && !mUserSwitcherController.isSimpleUserSwitcher()) { + hide(animate); + } + } + + boolean isAnimating() { + return mAnimating; + } + public final DataSetObserver mDataSetObserver = new DataSetObserver() { @Override public void onChanged() { @@ -209,10 +229,13 @@ public class KeyguardUserSwitcher { View.OnClickListener { private Context mContext; + private KeyguardUserSwitcher mKeyguardUserSwitcher; - public Adapter(Context context, UserSwitcherController controller) { + public Adapter(Context context, UserSwitcherController controller, + KeyguardUserSwitcher kgu) { super(controller); mContext = context; + mKeyguardUserSwitcher = kgu; } @Override @@ -240,7 +263,37 @@ public class KeyguardUserSwitcher { @Override public void onClick(View v) { - switchTo(((UserSwitcherController.UserRecord)v.getTag())); + UserSwitcherController.UserRecord user = (UserSwitcherController.UserRecord) v.getTag(); + if (user.isCurrent && !user.isGuest) { + // Close the switcher if tapping the current user. Guest is excluded because + // tapping the guest user while it's current clears the session. + mKeyguardUserSwitcher.hideIfNotSimple(true /* animate */); + } else { + switchTo(user); + } + } + } + + public static class Container extends FrameLayout { + + private KeyguardUserSwitcher mKeyguardUserSwitcher; + + public Container(Context context, AttributeSet attrs) { + super(context, attrs); + setClipChildren(false); + } + + public void setKeyguardUserSwitcher(KeyguardUserSwitcher keyguardUserSwitcher) { + mKeyguardUserSwitcher = keyguardUserSwitcher; + } + + @Override + public boolean onTouchEvent(MotionEvent ev) { + // Hide switcher if it didn't handle the touch event (and let the event go through). + if (mKeyguardUserSwitcher != null && !mKeyguardUserSwitcher.isAnimating()) { + mKeyguardUserSwitcher.hideIfNotSimple(true /* animate */); + } + return false; } } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcherScrim.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcherScrim.java index 4363037..a5fc2fe 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcherScrim.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcherScrim.java @@ -42,7 +42,7 @@ public class KeyguardUserSwitcherScrim extends Drawable private int mDarkColor; private int mTop; - private int mAlpha; + private int mAlpha = 255; private Paint mRadialGradientPaint = new Paint(); private int mLayoutWidth; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java index 2ed9366..bb29d01 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java @@ -39,11 +39,13 @@ public interface NetworkController { void addAccessPointCallback(AccessPointCallback callback); void removeAccessPointCallback(AccessPointCallback callback); void scanForAccessPoints(); - void connect(AccessPoint ap); + boolean connect(AccessPoint ap); boolean isMobileDataSupported(); boolean isMobileDataEnabled(); void setMobileDataEnabled(boolean enabled); DataUsageInfo getDataUsageInfo(); + boolean canConfigWifi(); + void onUserSwitched(int newUserId); public interface AccessPointCallback { void onAccessPointsChanged(AccessPoint[] accessPoints); @@ -56,6 +58,8 @@ public interface NetworkController { public int iconId; public String ssid; public boolean isConnected; + public boolean isConfigured; + public boolean hasSecurity; public int level; // 0 - 5 } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java index b2198f6..6c0b425 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java @@ -168,7 +168,7 @@ public class NetworkControllerImpl extends BroadcastReceiver void setIsAirplaneMode(boolean is, int airplaneIcon); } - private final WifiAccessPointController mAccessPoints; + private final AccessPointController mAccessPoints; private final MobileDataController mMobileDataController; /** @@ -239,7 +239,7 @@ public class NetworkControllerImpl extends BroadcastReceiver updateAirplaneMode(); mLastLocale = mContext.getResources().getConfiguration().locale; - mAccessPoints = new WifiAccessPointController(mContext); + mAccessPoints = new AccessPointController(mContext); mMobileDataController = new MobileDataController(mContext); mMobileDataController.setCallback(new MobileDataController.Callback() { @Override @@ -249,6 +249,16 @@ public class NetworkControllerImpl extends BroadcastReceiver }); } + @Override + public boolean canConfigWifi() { + return mAccessPoints.canConfigWifi(); + } + + @Override + public void onUserSwitched(int newUserId) { + mAccessPoints.onUserSwitched(newUserId); + } + private void notifyMobileDataEnabled(boolean enabled) { for (NetworkSignalChangedCallback cb : mSignalsChangedCallbacks) { cb.onMobileDataEnabled(enabled); @@ -313,8 +323,8 @@ public class NetworkControllerImpl extends BroadcastReceiver } @Override - public void connect(AccessPoint ap) { - mAccessPoints.connect(ap); + public boolean connect(AccessPoint ap) { + return mAccessPoints.connect(ap); } @Override diff --git a/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java b/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java index 69be377..c840f17 100644 --- a/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java +++ b/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java @@ -31,6 +31,7 @@ import android.provider.Settings; import android.provider.Settings.Global; import android.service.notification.Condition; import android.service.notification.ZenModeConfig; +import android.text.TextUtils; import android.util.AttributeSet; import android.util.Log; import android.util.MathUtils; @@ -220,7 +221,8 @@ public class ZenModePanel extends LinearLayout { mBucketIndex = -1; } else { mBucketIndex = DEFAULT_BUCKET_INDEX; - mTimeCondition = ZenModeConfig.toTimeCondition(MINUTE_BUCKETS[mBucketIndex]); + mTimeCondition = ZenModeConfig.toTimeCondition(mContext, + MINUTE_BUCKETS[mBucketIndex]); } if (DEBUG) Log.d(mTag, "Initial bucket index: " + mBucketIndex); mConditions = null; // reset conditions @@ -339,9 +341,11 @@ public class ZenModePanel extends LinearLayout { if (condition == null) return null; final long time = ZenModeConfig.tryParseCountdownConditionId(condition.id); if (time == 0) return null; - final long span = time - System.currentTimeMillis(); + final long now = System.currentTimeMillis(); + final long span = time - now; if (span <= 0 || span > MAX_BUCKET_MINUTES * MINUTES_MS) return null; - return ZenModeConfig.toTimeCondition(time, Math.round(span / (float) MINUTES_MS)); + return ZenModeConfig.toTimeCondition(mContext, + time, Math.round(span / (float) MINUTES_MS), now); } private void handleUpdateConditions(Condition[] conditions) { @@ -395,7 +399,7 @@ public class ZenModePanel extends LinearLayout { if (favoriteIndex == -1) { getConditionTagAt(FOREVER_CONDITION_INDEX).rb.setChecked(true); } else { - mTimeCondition = ZenModeConfig.toTimeCondition(MINUTE_BUCKETS[favoriteIndex]); + mTimeCondition = ZenModeConfig.toTimeCondition(mContext, MINUTE_BUCKETS[favoriteIndex]); mBucketIndex = favoriteIndex; bind(mTimeCondition, mZenConditions.getChildAt(TIME_CONDITION_INDEX)); getConditionTagAt(TIME_CONDITION_INDEX).rb.setChecked(true); @@ -451,16 +455,32 @@ public class ZenModePanel extends LinearLayout { } }); - if (tag.title == null) { - tag.title = (TextView) row.findViewById(android.R.id.title); + if (tag.lines == null) { + tag.lines = row.findViewById(android.R.id.content); } + if (tag.line1 == null) { + tag.line1 = (TextView) row.findViewById(android.R.id.text1); + } + if (tag.line2 == null) { + tag.line2 = (TextView) row.findViewById(android.R.id.text2); + } + final String line1, line2; if (condition == null) { - tag.title.setText(mContext.getString(com.android.internal.R.string.zen_mode_forever)); + line1 = mContext.getString(com.android.internal.R.string.zen_mode_forever); + line2 = null; + } else { + line1 = !TextUtils.isEmpty(condition.line1) ? condition.line1 : condition.summary; + line2 = condition.line2; + } + tag.line1.setText(line1); + if (TextUtils.isEmpty(line2)) { + tag.line2.setVisibility(GONE); } else { - tag.title.setText(condition.summary); + tag.line2.setVisibility(VISIBLE); + tag.line2.setText(line2); } - tag.title.setEnabled(enabled); - tag.title.setAlpha(enabled ? 1 : .4f); + tag.lines.setEnabled(enabled); + tag.lines.setAlpha(enabled ? 1 : .4f); final ImageView button1 = (ImageView) row.findViewById(android.R.id.button1); button1.setOnClickListener(new OnClickListener() { @@ -477,7 +497,7 @@ public class ZenModePanel extends LinearLayout { onClickTimeButton(row, tag, true /*up*/); } }); - tag.title.setOnClickListener(new OnClickListener() { + tag.lines.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { tag.rb.setChecked(true); @@ -492,7 +512,8 @@ public class ZenModePanel extends LinearLayout { } else { final long span = time - System.currentTimeMillis(); button1.setEnabled(span > MIN_BUCKET_MINUTES * MINUTES_MS); - final Condition maxCondition = ZenModeConfig.toTimeCondition(MAX_BUCKET_MINUTES); + final Condition maxCondition = ZenModeConfig.toTimeCondition(mContext, + MAX_BUCKET_MINUTES); button2.setEnabled(!Objects.equals(condition.summary, maxCondition.summary)); } @@ -505,7 +526,7 @@ public class ZenModePanel extends LinearLayout { // wire up interaction callbacks for newly-added condition rows if (convertView == null) { Interaction.register(tag.rb, mInteractionCallback); - Interaction.register(tag.title, mInteractionCallback); + Interaction.register(tag.lines, mInteractionCallback); Interaction.register(button1, mInteractionCallback); Interaction.register(button2, mInteractionCallback); } @@ -525,7 +546,7 @@ public class ZenModePanel extends LinearLayout { return; } announceForAccessibility(mContext.getString(R.string.zen_mode_and_condition, modeText, - tag.title.getText())); + tag.line1.getText())); } private void onClickTimeButton(View row, ConditionTag tag, boolean up) { @@ -542,18 +563,21 @@ public class ZenModePanel extends LinearLayout { final long bucketTime = now + bucketMinutes * MINUTES_MS; if (up && bucketTime > time || !up && bucketTime < time) { mBucketIndex = j; - newCondition = ZenModeConfig.toTimeCondition(bucketTime, bucketMinutes); + newCondition = ZenModeConfig.toTimeCondition(mContext, + bucketTime, bucketMinutes, now); break; } } if (newCondition == null) { mBucketIndex = DEFAULT_BUCKET_INDEX; - newCondition = ZenModeConfig.toTimeCondition(MINUTE_BUCKETS[mBucketIndex]); + newCondition = ZenModeConfig.toTimeCondition(mContext, + MINUTE_BUCKETS[mBucketIndex]); } } else { // on a known index, simply increment or decrement mBucketIndex = Math.max(0, Math.min(N - 1, mBucketIndex + (up ? 1 : -1))); - newCondition = ZenModeConfig.toTimeCondition(MINUTE_BUCKETS[mBucketIndex]); + newCondition = ZenModeConfig.toTimeCondition(mContext, + MINUTE_BUCKETS[mBucketIndex]); } mTimeCondition = newCondition; bind(mTimeCondition, row); @@ -640,7 +664,9 @@ public class ZenModePanel extends LinearLayout { // used as the view tag on condition rows private static class ConditionTag { RadioButton rb; - TextView title; + View lines; + TextView line1; + TextView line2; Condition condition; } |
