Merge changes Ia64238f3,I45056904 into qt-r1-dev
* changes: Fixed an issue about notification icons on AOD Animating the notifications now when they disappear
This commit is contained in:
@@ -150,10 +150,9 @@ public class SystemUIFactory {
|
||||
StatusBar statusBar,
|
||||
NotificationWakeUpCoordinator wakeUpCoordinator,
|
||||
KeyguardBypassController keyguardBypassController,
|
||||
StatusBarStateController statusBarStateController,
|
||||
NotificationListener listener) {
|
||||
StatusBarStateController statusBarStateController) {
|
||||
return new NotificationIconAreaController(context, statusBar, statusBarStateController,
|
||||
wakeUpCoordinator, keyguardBypassController, listener,
|
||||
wakeUpCoordinator, keyguardBypassController,
|
||||
Dependency.get(NotificationMediaManager.class));
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,10 @@ import com.android.systemui.statusbar.notification.stack.StackStateAnimator;
|
||||
public class CrossFadeHelper {
|
||||
public static final long ANIMATION_DURATION_LENGTH = 210;
|
||||
|
||||
public static void fadeOut(final View view) {
|
||||
fadeOut(view, null);
|
||||
}
|
||||
|
||||
public static void fadeOut(final View view, final Runnable endRunnable) {
|
||||
fadeOut(view, ANIMATION_DURATION_LENGTH, 0, endRunnable);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Rect;
|
||||
import android.provider.Settings;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -22,6 +23,7 @@ import com.android.systemui.R;
|
||||
import com.android.systemui.plugins.DarkIconDispatcher;
|
||||
import com.android.systemui.plugins.DarkIconDispatcher.DarkReceiver;
|
||||
import com.android.systemui.plugins.statusbar.StatusBarStateController;
|
||||
import com.android.systemui.statusbar.CrossFadeHelper;
|
||||
import com.android.systemui.statusbar.NotificationListener;
|
||||
import com.android.systemui.statusbar.NotificationMediaManager;
|
||||
import com.android.systemui.statusbar.NotificationShelf;
|
||||
@@ -32,6 +34,7 @@ import com.android.systemui.statusbar.notification.NotificationUtils;
|
||||
import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator;
|
||||
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
|
||||
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
|
||||
import com.android.systemui.tuner.TunerService;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
@@ -56,20 +59,8 @@ public class NotificationIconAreaController implements DarkReceiver,
|
||||
private final NotificationWakeUpCoordinator mWakeUpCoordinator;
|
||||
private final KeyguardBypassController mBypassController;
|
||||
private final DozeParameters mDozeParameters;
|
||||
@VisibleForTesting
|
||||
final NotificationListener.NotificationSettingsListener mSettingsListener =
|
||||
new NotificationListener.NotificationSettingsListener() {
|
||||
@Override
|
||||
public void onStatusBarIconsBehaviorChanged(boolean hideSilentStatusIcons) {
|
||||
if (NotificationUtils.useNewInterruptionModel(mContext)) {
|
||||
mShowLowPriority = !hideSilentStatusIcons;
|
||||
if (mNotificationScrollLayout != null) {
|
||||
updateStatusBarIcons();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private boolean mShowSilentOnLockscreen = true;
|
||||
private int mIconSize;
|
||||
private int mIconHPadding;
|
||||
private int mIconTint = Color.WHITE;
|
||||
@@ -86,18 +77,17 @@ public class NotificationIconAreaController implements DarkReceiver,
|
||||
private final Rect mTintArea = new Rect();
|
||||
private ViewGroup mNotificationScrollLayout;
|
||||
private Context mContext;
|
||||
private boolean mShowLowPriority = true;
|
||||
private int mAodIconAppearTranslation;
|
||||
|
||||
private boolean mAnimationsEnabled;
|
||||
private int mAodIconTint;
|
||||
private boolean mFullyHidden;
|
||||
private boolean mAodIconsVisible;
|
||||
|
||||
public NotificationIconAreaController(Context context, StatusBar statusBar,
|
||||
StatusBarStateController statusBarStateController,
|
||||
NotificationWakeUpCoordinator wakeUpCoordinator,
|
||||
KeyguardBypassController keyguardBypassController,
|
||||
NotificationListener notificationListener,
|
||||
NotificationMediaManager notificationMediaManager) {
|
||||
mStatusBar = statusBar;
|
||||
mContrastColorUtil = ContrastColorUtil.getInstance(context);
|
||||
@@ -106,7 +96,6 @@ public class NotificationIconAreaController implements DarkReceiver,
|
||||
mStatusBarStateController = statusBarStateController;
|
||||
mStatusBarStateController.addCallback(this);
|
||||
mMediaManager = notificationMediaManager;
|
||||
notificationListener.addNotificationSettingsListener(mSettingsListener);
|
||||
mDozeParameters = DozeParameters.getInstance(mContext);
|
||||
mWakeUpCoordinator = wakeUpCoordinator;
|
||||
wakeUpCoordinator.addListener(this);
|
||||
@@ -114,6 +103,11 @@ public class NotificationIconAreaController implements DarkReceiver,
|
||||
|
||||
initializeNotificationAreaViews(context);
|
||||
reloadAodColor();
|
||||
|
||||
TunerService tunerService = Dependency.get(TunerService.class);
|
||||
tunerService.addTunable((key, newValue) -> {
|
||||
mShowSilentOnLockscreen = "1".equals(newValue);
|
||||
}, Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS);
|
||||
}
|
||||
|
||||
protected View inflateIconArea(LayoutInflater inflater) {
|
||||
@@ -147,10 +141,10 @@ public class NotificationIconAreaController implements DarkReceiver,
|
||||
mAodIcons = mStatusBar.getStatusBarWindow().findViewById(
|
||||
R.id.clock_notification_icon_container);
|
||||
mAodIcons.setOnLockScreen(true);
|
||||
updateAodIconsVisibility();
|
||||
updateAodIconsVisibility(false /* animate */);
|
||||
updateAnimations();
|
||||
if (changed) {
|
||||
updateAodIcons();
|
||||
updateAodNotificationIcons();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -293,7 +287,7 @@ public class NotificationIconAreaController implements DarkReceiver,
|
||||
updateStatusBarIcons();
|
||||
updateShelfIcons();
|
||||
updateCenterIcon();
|
||||
updateAodIcons();
|
||||
updateAodNotificationIcons();
|
||||
|
||||
applyNotificationIconsTint();
|
||||
}
|
||||
@@ -312,7 +306,7 @@ public class NotificationIconAreaController implements DarkReceiver,
|
||||
public void updateStatusBarIcons() {
|
||||
updateIconsForLayout(entry -> entry.icon, mNotificationIcons,
|
||||
false /* showAmbient */,
|
||||
mShowLowPriority /* showLowPriority */,
|
||||
true /* showLowPriority */,
|
||||
true /* hideDismissed */,
|
||||
true /* hideRepliedMessages */,
|
||||
false /* hideCurrentMedia */,
|
||||
@@ -331,10 +325,10 @@ public class NotificationIconAreaController implements DarkReceiver,
|
||||
false /* hidePulsing */);
|
||||
}
|
||||
|
||||
public void updateAodIcons() {
|
||||
public void updateAodNotificationIcons() {
|
||||
updateIconsForLayout(entry -> entry.aodIcon, mAodIcons,
|
||||
false /* showAmbient */,
|
||||
mShowLowPriority /* showLowPriority */,
|
||||
mShowSilentOnLockscreen /* showLowPriority */,
|
||||
true /* hideDismissed */,
|
||||
true /* hideRepliedMessages */,
|
||||
true /* hideCurrentMedia */,
|
||||
@@ -342,11 +336,6 @@ public class NotificationIconAreaController implements DarkReceiver,
|
||||
mBypassController.getBypassEnabled() /* hidePulsing */);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
boolean shouldShouldLowPriorityIcons() {
|
||||
return mShowLowPriority;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the notification icons for a host layout. This will ensure that the notification
|
||||
* host layout will have the same icons like the ones in here.
|
||||
@@ -532,7 +521,7 @@ public class NotificationIconAreaController implements DarkReceiver,
|
||||
|
||||
@Override
|
||||
public void onStateChanged(int newState) {
|
||||
updateAodIconsVisibility();
|
||||
updateAodIconsVisibility(false /* animate */);
|
||||
updateAnimations();
|
||||
}
|
||||
|
||||
@@ -583,21 +572,25 @@ public class NotificationIconAreaController implements DarkReceiver,
|
||||
|
||||
@Override
|
||||
public void onFullyHiddenChanged(boolean fullyHidden) {
|
||||
if (fullyHidden && !mBypassController.getBypassEnabled()) {
|
||||
appearAodIcons();
|
||||
boolean animate = true;
|
||||
if (!mBypassController.getBypassEnabled()) {
|
||||
animate = mDozeParameters.getAlwaysOn() && !mDozeParameters.getDisplayNeedsBlanking();
|
||||
// We only want the appear animations to happen when the notifications get fully hidden,
|
||||
// since otherwise the unhide animation overlaps
|
||||
animate &= fullyHidden;
|
||||
}
|
||||
updateAodIconsVisibility();
|
||||
updateAodIcons();
|
||||
updateAodIconsVisibility(animate);
|
||||
updateAodNotificationIcons();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPulseExpansionChanged(boolean expandingChanged) {
|
||||
if (expandingChanged) {
|
||||
updateAodIconsVisibility();
|
||||
updateAodIconsVisibility(true /* animate */);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateAodIconsVisibility() {
|
||||
private void updateAodIconsVisibility(boolean animate) {
|
||||
boolean visible = mBypassController.getBypassEnabled()
|
||||
|| mWakeUpCoordinator.getNotificationsFullyHidden();
|
||||
if (mStatusBarStateController.getState() != StatusBarState.KEYGUARD) {
|
||||
@@ -606,6 +599,28 @@ public class NotificationIconAreaController implements DarkReceiver,
|
||||
if (visible && mWakeUpCoordinator.isPulseExpanding()) {
|
||||
visible = false;
|
||||
}
|
||||
mAodIcons.setVisibility(visible ? View.VISIBLE : View.INVISIBLE);
|
||||
if (mAodIconsVisible != visible) {
|
||||
mAodIconsVisible = visible;
|
||||
mAodIcons.animate().cancel();
|
||||
if (animate) {
|
||||
boolean wasFullyInvisible = mAodIcons.getVisibility() != View.VISIBLE;
|
||||
if (mAodIconsVisible) {
|
||||
if (wasFullyInvisible) {
|
||||
// No fading here, let's just appear the icons instead!
|
||||
mAodIcons.setVisibility(View.VISIBLE);
|
||||
mAodIcons.setAlpha(1.0f);
|
||||
appearAodIcons();
|
||||
} else {
|
||||
// We were fading out, let's fade in instead
|
||||
CrossFadeHelper.fadeIn(mAodIcons);
|
||||
}
|
||||
} else {
|
||||
CrossFadeHelper.fadeOut(mAodIcons);
|
||||
}
|
||||
} else {
|
||||
mAodIcons.setAlpha(1.0f);
|
||||
mAodIcons.setVisibility(visible ? View.VISIBLE : View.INVISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -800,7 +800,7 @@ public class StatusBar extends SystemUI implements DemoMode,
|
||||
mNotificationIconAreaController = SystemUIFactory.getInstance()
|
||||
.createNotificationIconAreaController(context, this,
|
||||
mWakeUpCoordinator, mKeyguardBypassController,
|
||||
mStatusBarStateController, mNotificationListener);
|
||||
mStatusBarStateController);
|
||||
mWakeUpCoordinator.setIconAreaController(mNotificationIconAreaController);
|
||||
inflateShelf();
|
||||
mNotificationIconAreaController.setupShelf(mNotificationShelf);
|
||||
|
||||
@@ -1,102 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.systemui.statusbar.phone;
|
||||
|
||||
import static android.provider.Settings.Secure.NOTIFICATION_NEW_INTERRUPTION_MODEL;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.provider.Settings;
|
||||
import android.testing.AndroidTestingRunner;
|
||||
import android.testing.TestableLooper;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.SysuiTestCase;
|
||||
import com.android.systemui.plugins.statusbar.StatusBarStateController;
|
||||
import com.android.systemui.statusbar.NotificationListener;
|
||||
import com.android.systemui.statusbar.NotificationMediaManager;
|
||||
import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
@SmallTest
|
||||
@RunWith(AndroidTestingRunner.class)
|
||||
@TestableLooper.RunWithLooper
|
||||
public class NotificationIconAreaControllerTest extends SysuiTestCase {
|
||||
|
||||
@Mock
|
||||
private NotificationListener mListener;
|
||||
@Mock
|
||||
StatusBar mStatusBar;
|
||||
@Mock
|
||||
StatusBarWindowView mStatusBarWindowView;
|
||||
@Mock
|
||||
NotificationIconContainer mIconContainer;
|
||||
@Mock
|
||||
StatusBarStateController mStatusBarStateController;
|
||||
@Mock
|
||||
NotificationWakeUpCoordinator mNotificationWakeUpCoordinator;
|
||||
@Mock
|
||||
KeyguardBypassController mBypassController;
|
||||
@Mock
|
||||
private NotificationMediaManager mMediaManager;
|
||||
private NotificationIconAreaController mController;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
when(mStatusBar.getStatusBarWindow()).thenReturn(mStatusBarWindowView);
|
||||
when(mStatusBarWindowView.findViewById(R.id.clock_notification_icon_container)).thenReturn(
|
||||
mIconContainer);
|
||||
mController = new NotificationIconAreaController(mContext, mStatusBar,
|
||||
mStatusBarStateController, mNotificationWakeUpCoordinator, mBypassController,
|
||||
mListener, mMediaManager);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotificationIcons_featureOff() {
|
||||
Settings.Secure.putInt(
|
||||
mContext.getContentResolver(), NOTIFICATION_NEW_INTERRUPTION_MODEL, 0);
|
||||
assertTrue(mController.shouldShouldLowPriorityIcons());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotificationIcons_featureOn_settingHideIcons() {
|
||||
Settings.Secure.putInt(
|
||||
mContext.getContentResolver(), NOTIFICATION_NEW_INTERRUPTION_MODEL, 1);
|
||||
mController.mSettingsListener.onStatusBarIconsBehaviorChanged(true);
|
||||
|
||||
assertFalse(mController.shouldShouldLowPriorityIcons());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotificationIcons_featureOn_settingShowIcons() {
|
||||
Settings.Secure.putInt(
|
||||
mContext.getContentResolver(), NOTIFICATION_NEW_INTERRUPTION_MODEL, 1);
|
||||
mController.mSettingsListener.onStatusBarIconsBehaviorChanged(false);
|
||||
|
||||
assertTrue(mController.shouldShouldLowPriorityIcons());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user