Skip to content

Commit c2ee231

Browse files
dsandlerAndroid (Google) Code Review
authored andcommitted
Merge "Lights out improvements." into jb-dev
2 parents 7e279bc + d7e9686 commit c2ee231

File tree

3 files changed

+95
-4
lines changed

3 files changed

+95
-4
lines changed

packages/SystemUI/res/layout/status_bar.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,17 @@
2929
android:fitsSystemWindows="true"
3030
>
3131

32+
<ImageView
33+
android:id="@+id/notification_lights_out"
34+
android:layout_width="@dimen/status_bar_icon_size"
35+
android:layout_height="match_parent"
36+
android:paddingLeft="6dip"
37+
android:paddingBottom="2dip"
38+
android:src="@drawable/ic_sysbar_lights_out_dot_small"
39+
android:scaleType="center"
40+
android:visibility="gone"
41+
/>
42+
3243
<LinearLayout android:id="@+id/icons"
3344
android:layout_width="match_parent"
3445
android:layout_height="match_parent"
@@ -38,6 +49,7 @@
3849
>
3950

4051
<LinearLayout
52+
android:id="@+id/notification_icon_area"
4153
android:layout_width="0dip"
4254
android:layout_height="match_parent"
4355
android:layout_weight="1"

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ public void setLowProfile(final boolean lightsOut, final boolean animate, final
250250
} else {
251251
navButtons.animate()
252252
.alpha(lightsOut ? 0f : 1f)
253-
.setDuration(lightsOut ? 600 : 200)
253+
.setDuration(lightsOut ? 750 : 250)
254254
.start();
255255

256256
lowLights.setOnTouchListener(mLightsOutListener);
@@ -260,8 +260,7 @@ public void setLowProfile(final boolean lightsOut, final boolean animate, final
260260
}
261261
lowLights.animate()
262262
.alpha(lightsOut ? 1f : 0f)
263-
.setStartDelay(lightsOut ? 500 : 0)
264-
.setDuration(lightsOut ? 1000 : 300)
263+
.setDuration(lightsOut ? 750 : 250)
265264
.setInterpolator(new AccelerateInterpolator(2.0f))
266265
.setListener(lightsOut ? null : new AnimatorListenerAdapter() {
267266
@Override

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

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616

1717
package com.android.systemui.statusbar.phone;
1818

19+
import android.animation.Animator;
20+
import android.animation.AnimatorListenerAdapter;
21+
import android.animation.AnimatorSet;
1922
import android.animation.ObjectAnimator;
2023
import android.app.ActivityManager;
2124
import android.app.ActivityManagerNative;
@@ -55,6 +58,7 @@
5558
import android.view.Window;
5659
import android.view.WindowManager;
5760
import android.view.WindowManagerImpl;
61+
import android.view.animation.AccelerateInterpolator;
5862
import android.view.animation.Animation;
5963
import android.view.animation.AnimationUtils;
6064
import android.widget.ImageView;
@@ -207,6 +211,8 @@ public class PhoneStatusBar extends BaseStatusBar {
207211
int[] mAbsPos = new int[2];
208212
Runnable mPostCollapseCleanup = null;
209213

214+
private AnimatorSet mLightsOutAnimation;
215+
private AnimatorSet mLightsOnAnimation;
210216

211217
// for disabling the status bar
212218
int mDisabled = 0;
@@ -935,7 +941,26 @@ private void setAreThereNotifications() {
935941
mClearButton.setAlpha(clearable ? 1.0f : 0.0f);
936942
}
937943
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+
}
939964
}
940965

941966
public void showClock(boolean show) {
@@ -1372,6 +1397,10 @@ boolean interceptTouchEvent(MotionEvent event) {
13721397
final int hitSize = statusBarSize*2;
13731398
final int y = (int)event.getRawY();
13741399
if (action == MotionEvent.ACTION_DOWN) {
1400+
if (!areLightsOn()) {
1401+
setLightsOn(true);
1402+
}
1403+
13751404
if (!mExpanded) {
13761405
mViewDelta = statusBarSize - y;
13771406
} else {
@@ -1470,16 +1499,64 @@ public void setSystemUiVisibility(int vis, int mask) {
14701499
final boolean lightsOut = (0 != (vis & View.SYSTEM_UI_FLAG_LOW_PROFILE));
14711500
if (lightsOut) {
14721501
animateCollapse();
1502+
if (mTicking) {
1503+
mTicker.halt();
1504+
}
14731505
}
1506+
14741507
if (mNavigationBarView != null) {
14751508
mNavigationBarView.setLowProfile(lightsOut);
14761509
}
1510+
1511+
setStatusBarLowProfile(lightsOut);
14771512
}
14781513

14791514
notifyUiVisibilityChanged();
14801515
}
14811516
}
14821517

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+
14831560
public void setLightsOn(boolean on) {
14841561
Log.v(TAG, "setLightsOn(" + on + ")");
14851562
if (on) {
@@ -1580,6 +1657,9 @@ public void onClick(View v) {
15801657
}
15811658

15821659
private void tick(StatusBarNotification n) {
1660+
// no ticking in lights-out mode
1661+
if (!areLightsOn()) return;
1662+
15831663
// Show the ticker if one is requested. Also don't do this
15841664
// until status bar window is attached to the window manager,
15851665
// because... well, what's the point otherwise? And trying to

0 commit comments

Comments
 (0)