Merge "DO NOT MERGE: Fixed an issue about notification icons on AOD" into qt-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
c65d4b728c
@@ -144,10 +144,9 @@ public class SystemUIFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public NotificationIconAreaController createNotificationIconAreaController(Context context,
|
public NotificationIconAreaController createNotificationIconAreaController(Context context,
|
||||||
StatusBar statusBar, StatusBarStateController statusBarStateController,
|
StatusBar statusBar, StatusBarStateController statusBarStateController) {
|
||||||
NotificationListener listener) {
|
|
||||||
return new NotificationIconAreaController(context, statusBar, statusBarStateController,
|
return new NotificationIconAreaController(context, statusBar, statusBarStateController,
|
||||||
listener, Dependency.get(NotificationMediaManager.class));
|
Dependency.get(NotificationMediaManager.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
public KeyguardIndicationController createKeyguardIndicationController(Context context,
|
public KeyguardIndicationController createKeyguardIndicationController(Context context,
|
||||||
|
|||||||
@@ -48,19 +48,6 @@ public class NotificationIconAreaController implements DarkReceiver,
|
|||||||
private final Runnable mUpdateStatusBarIcons = this::updateStatusBarIcons;
|
private final Runnable mUpdateStatusBarIcons = this::updateStatusBarIcons;
|
||||||
private final StatusBarStateController mStatusBarStateController;
|
private final StatusBarStateController mStatusBarStateController;
|
||||||
private final NotificationMediaManager mMediaManager;
|
private final NotificationMediaManager mMediaManager;
|
||||||
@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 int mIconSize;
|
private int mIconSize;
|
||||||
private int mIconHPadding;
|
private int mIconHPadding;
|
||||||
@@ -78,7 +65,6 @@ public class NotificationIconAreaController implements DarkReceiver,
|
|||||||
private ViewGroup mNotificationScrollLayout;
|
private ViewGroup mNotificationScrollLayout;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private boolean mFullyDark;
|
private boolean mFullyDark;
|
||||||
private boolean mShowLowPriority = true;
|
|
||||||
private boolean mAnimationsEnabled;
|
private boolean mAnimationsEnabled;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -88,7 +74,6 @@ public class NotificationIconAreaController implements DarkReceiver,
|
|||||||
|
|
||||||
public NotificationIconAreaController(Context context, StatusBar statusBar,
|
public NotificationIconAreaController(Context context, StatusBar statusBar,
|
||||||
StatusBarStateController statusBarStateController,
|
StatusBarStateController statusBarStateController,
|
||||||
NotificationListener notificationListener,
|
|
||||||
NotificationMediaManager notificationMediaManager) {
|
NotificationMediaManager notificationMediaManager) {
|
||||||
mStatusBar = statusBar;
|
mStatusBar = statusBar;
|
||||||
mContrastColorUtil = ContrastColorUtil.getInstance(context);
|
mContrastColorUtil = ContrastColorUtil.getInstance(context);
|
||||||
@@ -97,7 +82,6 @@ public class NotificationIconAreaController implements DarkReceiver,
|
|||||||
mStatusBarStateController = statusBarStateController;
|
mStatusBarStateController = statusBarStateController;
|
||||||
mStatusBarStateController.addCallback(this);
|
mStatusBarStateController.addCallback(this);
|
||||||
mMediaManager = notificationMediaManager;
|
mMediaManager = notificationMediaManager;
|
||||||
notificationListener.addNotificationSettingsListener(mSettingsListener);
|
|
||||||
|
|
||||||
initializeNotificationAreaViews(context);
|
initializeNotificationAreaViews(context);
|
||||||
}
|
}
|
||||||
@@ -258,7 +242,7 @@ public class NotificationIconAreaController implements DarkReceiver,
|
|||||||
private void updateShelfIcons() {
|
private void updateShelfIcons() {
|
||||||
updateIconsForLayout(entry -> entry.expandedIcon, mShelfIcons,
|
updateIconsForLayout(entry -> entry.expandedIcon, mShelfIcons,
|
||||||
true /* showAmbient */,
|
true /* showAmbient */,
|
||||||
!mFullyDark /* showLowPriority */,
|
true /* showLowPriority */,
|
||||||
false /* hideDismissed */,
|
false /* hideDismissed */,
|
||||||
mFullyDark /* hideRepliedMessages */,
|
mFullyDark /* hideRepliedMessages */,
|
||||||
mFullyDark /* hideCurrentMedia */,
|
mFullyDark /* hideCurrentMedia */,
|
||||||
@@ -268,7 +252,7 @@ public class NotificationIconAreaController implements DarkReceiver,
|
|||||||
public void updateStatusBarIcons() {
|
public void updateStatusBarIcons() {
|
||||||
updateIconsForLayout(entry -> entry.icon, mNotificationIcons,
|
updateIconsForLayout(entry -> entry.icon, mNotificationIcons,
|
||||||
false /* showAmbient */,
|
false /* showAmbient */,
|
||||||
mShowLowPriority /* showLowPriority */,
|
true /* showLowPriority */,
|
||||||
true /* hideDismissed */,
|
true /* hideDismissed */,
|
||||||
true /* hideRepliedMessages */,
|
true /* hideRepliedMessages */,
|
||||||
false /* hideCurrentMedia */,
|
false /* hideCurrentMedia */,
|
||||||
@@ -278,7 +262,7 @@ public class NotificationIconAreaController implements DarkReceiver,
|
|||||||
private void updateCenterIcon() {
|
private void updateCenterIcon() {
|
||||||
updateIconsForLayout(entry -> entry.centeredIcon, mCenteredIcon,
|
updateIconsForLayout(entry -> entry.centeredIcon, mCenteredIcon,
|
||||||
false /* showAmbient */,
|
false /* showAmbient */,
|
||||||
!mFullyDark /* showLowPriority */,
|
true /* showLowPriority */,
|
||||||
false /* hideDismissed */,
|
false /* hideDismissed */,
|
||||||
false /* hideRepliedMessages */,
|
false /* hideRepliedMessages */,
|
||||||
mFullyDark /* hideCurrentMedia */,
|
mFullyDark /* hideCurrentMedia */,
|
||||||
@@ -304,11 +288,6 @@ public class NotificationIconAreaController implements DarkReceiver,
|
|||||||
mNotificationIcons.setAnimationsEnabled(mAnimationsEnabled && inShade);
|
mNotificationIcons.setAnimationsEnabled(mAnimationsEnabled && inShade);
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
|
||||||
boolean shouldShouldLowPriorityIcons() {
|
|
||||||
return mShowLowPriority;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the notification icons for a host layout. This will ensure that the notification
|
* 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.
|
* host layout will have the same icons like the ones in here.
|
||||||
|
|||||||
@@ -795,8 +795,7 @@ public class StatusBar extends SystemUI implements DemoMode,
|
|||||||
mNotificationLogger.setUpWithContainer(notifListContainer);
|
mNotificationLogger.setUpWithContainer(notifListContainer);
|
||||||
|
|
||||||
mNotificationIconAreaController = SystemUIFactory.getInstance()
|
mNotificationIconAreaController = SystemUIFactory.getInstance()
|
||||||
.createNotificationIconAreaController(context, this,
|
.createNotificationIconAreaController(context, this, mStatusBarStateController);
|
||||||
mStatusBarStateController, mNotificationListener);
|
|
||||||
inflateShelf();
|
inflateShelf();
|
||||||
mNotificationIconAreaController.setupShelf(mNotificationShelf);
|
mNotificationIconAreaController.setupShelf(mNotificationShelf);
|
||||||
|
|
||||||
|
|||||||
@@ -1,88 +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 android.provider.Settings;
|
|
||||||
import android.testing.AndroidTestingRunner;
|
|
||||||
import android.testing.TestableLooper;
|
|
||||||
|
|
||||||
import androidx.test.filters.SmallTest;
|
|
||||||
|
|
||||||
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 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
|
|
||||||
StatusBarStateController mStatusBarStateController;
|
|
||||||
@Mock
|
|
||||||
private NotificationMediaManager mMediaManager;
|
|
||||||
private NotificationIconAreaController mController;
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setup() {
|
|
||||||
MockitoAnnotations.initMocks(this);
|
|
||||||
|
|
||||||
mController = new NotificationIconAreaController(mContext, mStatusBar,
|
|
||||||
mStatusBarStateController, 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