Eliminates NotificationEntryManager.getNotificationLongClicker().
This method always returned NotificationGutsManager::openGuts, and only existed so that CarSystemUI could override it to disable long presses. In this change we accomplish this by making NotificationStackScrollLayout injectable and providing a named flag for whether to enable long presses or not as a dependency. This means that NotificationEntryManager is no longer involved in handling long presses, and CarNotificationEntryManager no longer needs to exist. Test: atest SystemUITests, manual Change-Id: Iae78601fea498a37ed47ef9a114e50de1652b6a8
This commit is contained in:
@@ -20,11 +20,9 @@ import android.content.Context;
|
||||
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
import com.android.keyguard.ViewMediatorCallback;
|
||||
import com.android.systemui.car.CarNotificationEntryManager;
|
||||
import com.android.systemui.car.CarNotificationInterruptionStateProvider;
|
||||
import com.android.systemui.statusbar.car.CarFacetButtonController;
|
||||
import com.android.systemui.statusbar.car.CarStatusBarKeyguardViewManager;
|
||||
import com.android.systemui.statusbar.notification.NotificationEntryManager;
|
||||
import com.android.systemui.statusbar.notification.NotificationInterruptionStateProvider;
|
||||
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
|
||||
import com.android.systemui.volume.CarVolumeDialogComponent;
|
||||
@@ -64,17 +62,17 @@ public class CarSystemUIFactory extends SystemUIFactory {
|
||||
return new CarVolumeDialogComponent(systemUi, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NotificationEntryManager provideNotificationEntryManager(Context context) {
|
||||
return new CarNotificationEntryManager(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NotificationInterruptionStateProvider provideNotificationInterruptionStateProvider(
|
||||
Context context) {
|
||||
return new CarNotificationInterruptionStateProvider(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean provideAllowNotificationLongPress() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Module
|
||||
protected static class ContextHolder {
|
||||
private Context mContext;
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.car;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.android.systemui.statusbar.notification.NotificationEntryManager;
|
||||
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
|
||||
|
||||
public class CarNotificationEntryManager extends NotificationEntryManager {
|
||||
public CarNotificationEntryManager(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the
|
||||
* {@link ExpandableNotificationRow.LongPressListener} that will
|
||||
* be triggered when a notification card is long-pressed.
|
||||
*/
|
||||
@Override
|
||||
public ExpandableNotificationRow.LongPressListener getNotificationLongClicker() {
|
||||
// For the automative use case, we do not want to the user to be able to interact with
|
||||
// a notification other than a regular click. As a result, just return null for the
|
||||
// long click listener.
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -156,6 +156,12 @@ public class Dependency extends SystemUI {
|
||||
*/
|
||||
public static final String LEAK_REPORT_EMAIL_NAME = "leak_report_email";
|
||||
|
||||
/**
|
||||
* Whether this platform supports long-pressing notifications to show notification channel
|
||||
* settings.
|
||||
*/
|
||||
public static final String ALLOW_NOTIFICATION_LONG_PRESS_NAME = "allow_notif_longpress";
|
||||
|
||||
/**
|
||||
* Key for getting a background Looper for background work.
|
||||
*/
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.systemui;
|
||||
|
||||
import static com.android.systemui.Dependency.ALLOW_NOTIFICATION_LONG_PRESS_NAME;
|
||||
import static com.android.systemui.Dependency.LEAK_REPORT_EMAIL_NAME;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
@@ -200,6 +201,13 @@ public class SystemUIFactory {
|
||||
return new NotificationInterruptionStateProvider(context);
|
||||
}
|
||||
|
||||
@Singleton
|
||||
@Provides
|
||||
@Named(ALLOW_NOTIFICATION_LONG_PRESS_NAME)
|
||||
public boolean provideAllowNotificationLongPress() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Module
|
||||
protected static class ContextHolder {
|
||||
private Context mContext;
|
||||
|
||||
@@ -41,7 +41,6 @@ import com.android.systemui.statusbar.NotificationRemoteInputManager;
|
||||
import com.android.systemui.statusbar.NotificationUiAdjustment;
|
||||
import com.android.systemui.statusbar.NotificationUpdateHandler;
|
||||
import com.android.systemui.statusbar.notification.NotificationData.KeyguardEnvironment;
|
||||
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
|
||||
import com.android.systemui.statusbar.notification.row.NotificationGutsManager;
|
||||
import com.android.systemui.statusbar.notification.row.NotificationInflater;
|
||||
import com.android.systemui.statusbar.notification.row.NotificationInflater.InflationFlag;
|
||||
@@ -195,10 +194,6 @@ public class NotificationEntryManager implements
|
||||
return mPresenter;
|
||||
}
|
||||
|
||||
public ExpandableNotificationRow.LongPressListener getNotificationLongClicker() {
|
||||
return getRowBinder().getNotificationLongClicker();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReorderingAllowed() {
|
||||
updateNotifications();
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.android.systemui.statusbar.notification;
|
||||
|
||||
import static com.android.internal.util.Preconditions.checkNotNull;
|
||||
import static com.android.systemui.Dependency.ALLOW_NOTIFICATION_LONG_PRESS_NAME;
|
||||
import static com.android.systemui.statusbar.NotificationRemoteInputManager.ENABLE_REMOTE_INPUT;
|
||||
import static com.android.systemui.statusbar.notification.row.NotificationInflater.FLAG_CONTENT_VIEW_AMBIENT;
|
||||
import static com.android.systemui.statusbar.notification.row.NotificationInflater.FLAG_CONTENT_VIEW_HEADS_UP;
|
||||
@@ -51,6 +52,7 @@ import com.android.systemui.statusbar.phone.StatusBar;
|
||||
import com.android.systemui.statusbar.policy.HeadsUpManager;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
/** Handles inflating and updating views for notifications. */
|
||||
@@ -72,6 +74,7 @@ public class NotificationRowBinder {
|
||||
private final NotificationMessagingUtil mMessagingUtil;
|
||||
private final ExpandableNotificationRow.ExpansionLogger mExpansionLogger =
|
||||
this::logNotificationExpansion;
|
||||
private final boolean mAllowLongPress;
|
||||
|
||||
private NotificationRemoteInputManager mRemoteInputManager;
|
||||
private NotificationPresenter mPresenter;
|
||||
@@ -83,9 +86,11 @@ public class NotificationRowBinder {
|
||||
private NotificationClicker mNotificationClicker;
|
||||
|
||||
@Inject
|
||||
public NotificationRowBinder(Context context) {
|
||||
public NotificationRowBinder(Context context,
|
||||
@Named(ALLOW_NOTIFICATION_LONG_PRESS_NAME) boolean allowLongPress) {
|
||||
mContext = context;
|
||||
mMessagingUtil = new NotificationMessagingUtil(context);
|
||||
mAllowLongPress = allowLongPress;
|
||||
mBarService = IStatusBarService.Stub.asInterface(
|
||||
ServiceManager.getService(Context.STATUS_BAR_SERVICE));
|
||||
}
|
||||
@@ -147,7 +152,9 @@ public class NotificationRowBinder {
|
||||
row.setHeadsUpManager(mHeadsUpManager);
|
||||
row.setOnExpandClickListener(mPresenter);
|
||||
row.setInflationCallback(mInflationCallback);
|
||||
row.setLongPressListener(getNotificationLongClicker());
|
||||
if (mAllowLongPress) {
|
||||
row.setLongPressListener(mGutsManager::openGuts);
|
||||
}
|
||||
mListContainer.bindRow(row);
|
||||
getRemoteInputManager().bindRow(row);
|
||||
|
||||
@@ -260,10 +267,6 @@ public class NotificationRowBinder {
|
||||
row.inflateViews();
|
||||
}
|
||||
|
||||
ExpandableNotificationRow.LongPressListener getNotificationLongClicker() {
|
||||
return mGutsManager::openGuts;
|
||||
}
|
||||
|
||||
private void logNotificationExpansion(String key, boolean userAction, boolean expanded) {
|
||||
mUiOffloadThread.submit(() -> {
|
||||
try {
|
||||
|
||||
@@ -16,9 +16,11 @@
|
||||
|
||||
package com.android.systemui.statusbar.notification.stack;
|
||||
|
||||
import static com.android.systemui.Dependency.ALLOW_NOTIFICATION_LONG_PRESS_NAME;
|
||||
import static com.android.systemui.statusbar.notification.ActivityLaunchAnimator.ExpandAnimationParameters;
|
||||
import static com.android.systemui.statusbar.notification.stack.StackStateAnimator.ANIMATION_DURATION_SWIPE;
|
||||
import static com.android.systemui.statusbar.phone.NotificationIconAreaController.LOW_PRIORITY;
|
||||
import static com.android.systemui.util.InjectionInflationController.VIEW_CONTEXT;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
@@ -136,6 +138,9 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
/**
|
||||
* A layout which handles a dynamic amount of notifications and presents them in a scrollable stack.
|
||||
*/
|
||||
@@ -165,6 +170,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
|
||||
private final Paint mBackgroundPaint = new Paint();
|
||||
private final boolean mShouldDrawNotificationBackground;
|
||||
private boolean mLowPriorityBeforeSpeedBump;
|
||||
private final boolean mAllowLongPress;
|
||||
|
||||
private float mExpandedHeight;
|
||||
private int mOwnScrollY;
|
||||
@@ -452,27 +458,16 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
|
||||
private final NotificationGutsManager
|
||||
mNotificationGutsManager = Dependency.get(NotificationGutsManager.class);
|
||||
|
||||
@ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
|
||||
public NotificationStackScrollLayout(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
@ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
|
||||
public NotificationStackScrollLayout(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
@ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
|
||||
public NotificationStackScrollLayout(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
this(context, attrs, defStyleAttr, 0);
|
||||
}
|
||||
|
||||
@ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
|
||||
public NotificationStackScrollLayout(Context context, AttributeSet attrs, int defStyleAttr,
|
||||
int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
@Inject
|
||||
public NotificationStackScrollLayout(
|
||||
@Named(VIEW_CONTEXT) Context context,
|
||||
AttributeSet attrs,
|
||||
@Named(ALLOW_NOTIFICATION_LONG_PRESS_NAME) boolean allowLongPress) {
|
||||
super(context, attrs, 0, 0);
|
||||
Resources res = getResources();
|
||||
|
||||
mAllowLongPress = allowLongPress;
|
||||
|
||||
for (int i = 0; i < NUM_SECTIONS; i++) {
|
||||
mSections[i] = new NotificationSection(this);
|
||||
}
|
||||
@@ -532,7 +527,9 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
|
||||
inflateEmptyShadeView();
|
||||
inflateFooterView();
|
||||
mVisualStabilityManager.setVisibilityLocationProvider(this::isInVisibleLocation);
|
||||
setLongPressListener(mEntryManager.getNotificationLongClicker());
|
||||
if (mAllowLongPress) {
|
||||
setLongPressListener(mGutsManager::openGuts);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -26,6 +26,7 @@ import android.view.View;
|
||||
import com.android.systemui.SystemUIFactory;
|
||||
import com.android.systemui.qs.QSFooterImpl;
|
||||
import com.android.systemui.qs.QuickStatusBarHeader;
|
||||
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
@@ -112,6 +113,11 @@ public class InjectionInflationController {
|
||||
* Creates the QSFooterImpl.
|
||||
*/
|
||||
QSFooterImpl createQsFooter();
|
||||
|
||||
/**
|
||||
* Creates the NotificationStackScrollLayout.
|
||||
*/
|
||||
NotificationStackScrollLayout createNotificationStackScrollLayout();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -135,7 +135,8 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
|
||||
|
||||
|
||||
NotificationShelf notificationShelf = mock(NotificationShelf.class);
|
||||
mStackScroller = spy(new NotificationStackScrollLayout(getContext()));
|
||||
mStackScroller = spy(new NotificationStackScrollLayout(getContext(), null,
|
||||
true /* allowLongPress */));
|
||||
mStackScroller.setShelf(notificationShelf);
|
||||
mStackScroller.setStatusBar(mBar);
|
||||
mStackScroller.setScrimController(mock(ScrimController.class));
|
||||
|
||||
Reference in New Issue
Block a user