diff options
| author | 2019-01-04 17:18:34 +0000 | |
|---|---|---|
| committer | 2019-01-04 17:18:34 +0000 | |
| commit | 4926466632daf79c3859d91749ef5f6d6cbb43da (patch) | |
| tree | 9cdaa24fd6873367d251d4939271c35cfd1eaba3 | |
| parent | 7e59a7d4219d9cd3b4191d7dd4b348a7b08d84ec (diff) | |
| parent | 59ec2ff4431c7a22f5d2910485563eb100df4c7a (diff) | |
Merge "Eliminates NotificationEntryManager.getNotificationLongClicker()."
9 files changed, 53 insertions, 80 deletions
diff --git a/packages/CarSystemUI/src/com/android/systemui/CarSystemUIFactory.java b/packages/CarSystemUI/src/com/android/systemui/CarSystemUIFactory.java index 3c0a2973ad40..0c352043f2a3 100644 --- a/packages/CarSystemUI/src/com/android/systemui/CarSystemUIFactory.java +++ b/packages/CarSystemUI/src/com/android/systemui/CarSystemUIFactory.java @@ -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; @@ -65,16 +63,16 @@ public class CarSystemUIFactory extends SystemUIFactory { } @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; diff --git a/packages/CarSystemUI/src/com/android/systemui/car/CarNotificationEntryManager.java b/packages/CarSystemUI/src/com/android/systemui/car/CarNotificationEntryManager.java deleted file mode 100644 index 323cae0067d8..000000000000 --- a/packages/CarSystemUI/src/com/android/systemui/car/CarNotificationEntryManager.java +++ /dev/null @@ -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; - } -} diff --git a/packages/SystemUI/src/com/android/systemui/Dependency.java b/packages/SystemUI/src/com/android/systemui/Dependency.java index a8d3763a5413..3d2f838e4872 100644 --- a/packages/SystemUI/src/com/android/systemui/Dependency.java +++ b/packages/SystemUI/src/com/android/systemui/Dependency.java @@ -157,6 +157,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. */ public static final DependencyKey<Looper> BG_LOOPER = new DependencyKey<>(BG_LOOPER_NAME); diff --git a/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java b/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java index e3bfdc911941..073516e5cc18 100644 --- a/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java +++ b/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java @@ -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; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java index e0fa723730c7..ab97e5e25ca1 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java @@ -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(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationRowBinder.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationRowBinder.java index b241b8a70b3f..0bde99b3c114 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationRowBinder.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationRowBinder.java @@ -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 { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java index f982ecf6f103..8deb7d5e8456 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java @@ -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 diff --git a/packages/SystemUI/src/com/android/systemui/util/InjectionInflationController.java b/packages/SystemUI/src/com/android/systemui/util/InjectionInflationController.java index 59aa52242f88..faebf60dc688 100644 --- a/packages/SystemUI/src/com/android/systemui/util/InjectionInflationController.java +++ b/packages/SystemUI/src/com/android/systemui/util/InjectionInflationController.java @@ -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(); } /** diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java index b8c7ee093ecc..06be5f651ded 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java @@ -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)); |