|
16 | 16 |
|
17 | 17 | package com.android.systemui.statusbar.phone; |
18 | 18 |
|
| 19 | +import android.animation.Animator; |
| 20 | +import android.animation.AnimatorListenerAdapter; |
| 21 | +import android.animation.AnimatorSet; |
19 | 22 | import android.animation.ObjectAnimator; |
20 | 23 | import android.app.ActivityManager; |
21 | 24 | import android.app.ActivityManagerNative; |
|
55 | 58 | import android.view.Window; |
56 | 59 | import android.view.WindowManager; |
57 | 60 | import android.view.WindowManagerImpl; |
| 61 | +import android.view.animation.AccelerateInterpolator; |
58 | 62 | import android.view.animation.Animation; |
59 | 63 | import android.view.animation.AnimationUtils; |
60 | 64 | import android.widget.ImageView; |
@@ -207,6 +211,8 @@ public class PhoneStatusBar extends BaseStatusBar { |
207 | 211 | int[] mAbsPos = new int[2]; |
208 | 212 | Runnable mPostCollapseCleanup = null; |
209 | 213 |
|
| 214 | + private AnimatorSet mLightsOutAnimation; |
| 215 | + private AnimatorSet mLightsOnAnimation; |
210 | 216 |
|
211 | 217 | // for disabling the status bar |
212 | 218 | int mDisabled = 0; |
@@ -935,7 +941,26 @@ private void setAreThereNotifications() { |
935 | 941 | mClearButton.setAlpha(clearable ? 1.0f : 0.0f); |
936 | 942 | } |
937 | 943 | mClearButton.setEnabled(clearable); |
938 | | - |
| 944 | + |
| 945 | + final View nlo = mStatusBarView.findViewById(R.id.notification_lights_out); |
| 946 | + final boolean showDot = (any&&!areLightsOn()); |
| 947 | + if (showDot != (nlo.getAlpha() == 1.0f)) { |
| 948 | + if (showDot) { |
| 949 | + nlo.setAlpha(0f); |
| 950 | + nlo.setVisibility(View.VISIBLE); |
| 951 | + } |
| 952 | + nlo.animate() |
| 953 | + .alpha(showDot?1:0) |
| 954 | + .setDuration(showDot?750:250) |
| 955 | + .setInterpolator(new AccelerateInterpolator(2.0f)) |
| 956 | + .setListener(showDot ? null : new AnimatorListenerAdapter() { |
| 957 | + @Override |
| 958 | + public void onAnimationEnd(Animator _a) { |
| 959 | + nlo.setVisibility(View.GONE); |
| 960 | + } |
| 961 | + }) |
| 962 | + .start(); |
| 963 | + } |
939 | 964 | } |
940 | 965 |
|
941 | 966 | public void showClock(boolean show) { |
@@ -1372,6 +1397,10 @@ boolean interceptTouchEvent(MotionEvent event) { |
1372 | 1397 | final int hitSize = statusBarSize*2; |
1373 | 1398 | final int y = (int)event.getRawY(); |
1374 | 1399 | if (action == MotionEvent.ACTION_DOWN) { |
| 1400 | + if (!areLightsOn()) { |
| 1401 | + setLightsOn(true); |
| 1402 | + } |
| 1403 | + |
1375 | 1404 | if (!mExpanded) { |
1376 | 1405 | mViewDelta = statusBarSize - y; |
1377 | 1406 | } else { |
@@ -1470,16 +1499,64 @@ public void setSystemUiVisibility(int vis, int mask) { |
1470 | 1499 | final boolean lightsOut = (0 != (vis & View.SYSTEM_UI_FLAG_LOW_PROFILE)); |
1471 | 1500 | if (lightsOut) { |
1472 | 1501 | animateCollapse(); |
| 1502 | + if (mTicking) { |
| 1503 | + mTicker.halt(); |
| 1504 | + } |
1473 | 1505 | } |
| 1506 | + |
1474 | 1507 | if (mNavigationBarView != null) { |
1475 | 1508 | mNavigationBarView.setLowProfile(lightsOut); |
1476 | 1509 | } |
| 1510 | + |
| 1511 | + setStatusBarLowProfile(lightsOut); |
1477 | 1512 | } |
1478 | 1513 |
|
1479 | 1514 | notifyUiVisibilityChanged(); |
1480 | 1515 | } |
1481 | 1516 | } |
1482 | 1517 |
|
| 1518 | + private void setStatusBarLowProfile(boolean lightsOut) { |
| 1519 | + if (mLightsOutAnimation == null) { |
| 1520 | + final View notifications = mStatusBarView.findViewById(R.id.notification_icon_area); |
| 1521 | + final View systemIcons = mStatusBarView.findViewById(R.id.statusIcons); |
| 1522 | + final View signal = mStatusBarView.findViewById(R.id.signal_cluster); |
| 1523 | + final View battery = mStatusBarView.findViewById(R.id.battery); |
| 1524 | + final View clock = mStatusBarView.findViewById(R.id.clock); |
| 1525 | + |
| 1526 | + mLightsOutAnimation = new AnimatorSet(); |
| 1527 | + mLightsOutAnimation.playTogether( |
| 1528 | + ObjectAnimator.ofFloat(notifications, View.ALPHA, 0), |
| 1529 | + ObjectAnimator.ofFloat(systemIcons, View.ALPHA, 0), |
| 1530 | + ObjectAnimator.ofFloat(signal, View.ALPHA, 0), |
| 1531 | + ObjectAnimator.ofFloat(battery, View.ALPHA, 0.5f), |
| 1532 | + ObjectAnimator.ofFloat(clock, View.ALPHA, 0.5f) |
| 1533 | + ); |
| 1534 | + mLightsOutAnimation.setDuration(750); |
| 1535 | + |
| 1536 | + mLightsOnAnimation = new AnimatorSet(); |
| 1537 | + mLightsOnAnimation.playTogether( |
| 1538 | + ObjectAnimator.ofFloat(notifications, View.ALPHA, 1), |
| 1539 | + ObjectAnimator.ofFloat(systemIcons, View.ALPHA, 1), |
| 1540 | + ObjectAnimator.ofFloat(signal, View.ALPHA, 1), |
| 1541 | + ObjectAnimator.ofFloat(battery, View.ALPHA, 1), |
| 1542 | + ObjectAnimator.ofFloat(clock, View.ALPHA, 1) |
| 1543 | + ); |
| 1544 | + mLightsOnAnimation.setDuration(250); |
| 1545 | + } |
| 1546 | + |
| 1547 | + mLightsOutAnimation.cancel(); |
| 1548 | + mLightsOnAnimation.cancel(); |
| 1549 | + |
| 1550 | + final Animator a = lightsOut ? mLightsOutAnimation : mLightsOnAnimation; |
| 1551 | + a.start(); |
| 1552 | + |
| 1553 | + setAreThereNotifications(); |
| 1554 | + } |
| 1555 | + |
| 1556 | + private boolean areLightsOn() { |
| 1557 | + return 0 == (mSystemUiVisibility & View.SYSTEM_UI_FLAG_LOW_PROFILE); |
| 1558 | + } |
| 1559 | + |
1483 | 1560 | public void setLightsOn(boolean on) { |
1484 | 1561 | Log.v(TAG, "setLightsOn(" + on + ")"); |
1485 | 1562 | if (on) { |
@@ -1580,6 +1657,9 @@ public void onClick(View v) { |
1580 | 1657 | } |
1581 | 1658 |
|
1582 | 1659 | private void tick(StatusBarNotification n) { |
| 1660 | + // no ticking in lights-out mode |
| 1661 | + if (!areLightsOn()) return; |
| 1662 | + |
1583 | 1663 | // Show the ticker if one is requested. Also don't do this |
1584 | 1664 | // until status bar window is attached to the window manager, |
1585 | 1665 | // because... well, what's the point otherwise? And trying to |
|
0 commit comments