Skip to content

Commit cf2f2e7

Browse files
ezio84Genkzsz11
authored andcommitted
Allow to dismiss notifications with back FP left/right swipe [1/2]
if the panel is expanded. The swipe animation follows the swipe gesture direction. Change-Id: I358ba07fa7724f9549145c87a1440916c469ca53 Signed-off-by: Anushek Prasal <anushekprasal@gmail.com>
1 parent 9c87584 commit cf2f2e7

4 files changed

Lines changed: 46 additions & 12 deletions

File tree

core/java/android/provider/Settings.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10347,6 +10347,12 @@ public static boolean putFloatForUser(ContentResolver cr, String name, float val
1034710347
*/
1034810348
public static final String SYSUI_ROUNDED_FWVALS = "sysui_rounded_fwvals";
1034910349

10350+
/**
10351+
* Wheter to dismiss notifications on fingerprint left and right swipe action
10352+
* @hide
10353+
*/
10354+
public static final String FP_SWIPE_TO_DISMISS_NOTIFICATIONS = "fp_swipe_to_dismiss_notifications";
10355+
1035010356
/**
1035110357
* Holds comma separated list of ordering of QS tiles.
1035210358
*

packages/SystemUI/src/com/android/systemui/SwipeHelper.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ public boolean onInterceptTouchEvent(final MotionEvent ev) {
361361
*/
362362
public void dismissChild(final View view, float velocity, boolean useAccelerateInterpolator) {
363363
dismissChild(view, velocity, null /* endAction */, 0 /* delay */,
364-
useAccelerateInterpolator, 0 /* fixedDuration */, false /* isDismissAll */);
364+
useAccelerateInterpolator, 0 /* fixedDuration */, false /* isDismissAll */, false);
365365
}
366366

367367
/**
@@ -374,7 +374,7 @@ public void dismissChild(final View view, float velocity, boolean useAccelerateI
374374
*/
375375
public void dismissChild(final View animView, float velocity, final Runnable endAction,
376376
long delay, boolean useAccelerateInterpolator, long fixedDuration,
377-
boolean isDismissAll) {
377+
boolean isDismissAll, boolean forceToLeft) {
378378
final boolean canBeDismissed = mCallback.canChildBeDismissed(animView);
379379
float newPos;
380380
boolean isLayoutRtl = animView.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
@@ -385,8 +385,9 @@ public void dismissChild(final View animView, float velocity, final Runnable end
385385
// if the language is rtl we prefer swiping to the left
386386
boolean animateLeftForRtl = velocity == 0 && (getTranslation(animView) == 0 || isDismissAll)
387387
&& isLayoutRtl;
388-
boolean animateLeft = (Math.abs(velocity) > getEscapeVelocity() && velocity < 0) ||
389-
(getTranslation(animView) < 0 && !isDismissAll);
388+
boolean animateLeft = (isDismissAll && forceToLeft)
389+
|| (Math.abs(velocity) > getEscapeVelocity() && velocity < 0)
390+
|| (getTranslation(animView) < 0 && !isDismissAll);
390391
if (animateLeft || animateLeftForRtl || animateUpForMenu) {
391392
newPos = -getSize(animView);
392393
} else {

packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ public NotificationStackScrollLayout(
599599
mSectionsManager.setOnClearSilentNotifsClickListener(v -> {
600600
// Leave the shade open if there will be other notifs left over to clear
601601
final boolean closeShade = !hasActiveClearableNotifications(ROWS_HIGH_PRIORITY);
602-
clearNotifications(ROWS_GENTLE, closeShade);
602+
clearNotifications(ROWS_GENTLE, closeShade, false/*forceToLeft*/);
603603
});
604604
mSections = mSectionsManager.createSectionsForBuckets();
605605

@@ -1883,9 +1883,9 @@ protected void onConfigurationChanged(Configuration newConfig) {
18831883
}
18841884

18851885
@ShadeViewRefactor(RefactorComponent.STATE_RESOLVER)
1886-
public void dismissViewAnimated(View child, Runnable endRunnable, int delay, long duration) {
1886+
public void dismissViewAnimated(View child, Runnable endRunnable, int delay, long duration, boolean forceToLeft) {
18871887
mSwipeHelper.dismissChild(child, 0, endRunnable, delay, true, duration,
1888-
true /* isDismissAll */);
1888+
true /* isDismissAll */, forceToLeft);
18891889
}
18901890

18911891
@ShadeViewRefactor(RefactorComponent.STATE_RESOLVER)
@@ -5682,9 +5682,9 @@ public void setIconAreaController(NotificationIconAreaController controller) {
56825682

56835683
@ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
56845684
@VisibleForTesting
5685-
void clearNotifications(
5685+
public void clearNotifications(
56865686
@SelectedRows int selection,
5687-
boolean closeShade) {
5687+
boolean closeShade, boolean forceToLeft) {
56885688
// animate-swipe all dismissable notifications, then animate the shade closed
56895689
int numChildren = getChildCount();
56905690

@@ -5739,6 +5739,7 @@ void clearNotifications(
57395739
performDismissAllAnimations(
57405740
viewsToHide,
57415741
closeShade,
5742+
forceToLeft,
57425743
() -> onDismissAllAnimationsEnd(viewsToRemove, selection));
57435744
}
57445745

@@ -5763,6 +5764,7 @@ private boolean includeChildInDismissAll(
57635764
private void performDismissAllAnimations(
57645765
final ArrayList<View> hideAnimatedList,
57655766
final boolean closeShade,
5767+
final boolean forceToLeft,
57665768
final Runnable onAnimationComplete) {
57675769

57685770
final Runnable onSlideAwayAnimationComplete = () -> {
@@ -5799,7 +5801,7 @@ private void performDismissAllAnimations(
57995801
if (i == 0) {
58005802
endRunnable = onSlideAwayAnimationComplete;
58015803
}
5802-
dismissViewAnimated(view, endRunnable, totalDelay, ANIMATION_DURATION_SWIPE);
5804+
dismissViewAnimated(view, endRunnable, totalDelay, ANIMATION_DURATION_SWIPE, forceToLeft);
58035805
currentDelay = Math.max(50, currentDelay - rowDelayDecrement);
58045806
totalDelay += currentDelay;
58055807
}
@@ -5819,7 +5821,7 @@ protected void inflateFooterView() {
58195821
footerView.setDismissButtonClickListener(v -> {
58205822
if (!isDismissAllButtonEnabled()) {
58215823
mMetricsLogger.action(MetricsEvent.ACTION_DISMISS_ALL_NOTES);
5822-
clearNotifications(ROWS_ALL, true /* closeShade */);
5824+
clearNotifications(ROWS_ALL, true /* closeShade */, false/*forceToLeft*/);
58235825
}
58245826
});
58255827
footerView.setManageButtonClickListener(v -> {
@@ -5830,7 +5832,7 @@ protected void inflateFooterView() {
58305832
mStatusBar.getDismissAllButton().setOnClickListener(v -> {
58315833
if (isDismissAllButtonEnabled()) {
58325834
mMetricsLogger.action(MetricsEvent.ACTION_DISMISS_ALL_NOTES);
5833-
clearNotifications(ROWS_ALL, true /* closeShade */);
5835+
clearNotifications(ROWS_ALL, true /* closeShade */, false/*forceToLeft*/);
58345836
}
58355837
});
58365838
}

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@
233233
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
234234
import com.android.systemui.statusbar.notification.row.NotificationGutsManager;
235235
import com.android.systemui.statusbar.notification.stack.NotificationListContainer;
236+
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout;
236237
import com.android.systemui.statusbar.phone.dagger.StatusBarComponent;
237238
import com.android.systemui.statusbar.policy.BatteryController;
238239
import com.android.systemui.statusbar.policy.BrightnessMirrorController;
@@ -450,6 +451,8 @@ public class StatusBar extends SystemUI implements DemoMode,
450451

451452
private boolean mSysuiRoundedFwvals;
452453

454+
private boolean mFpDismissNotifications;
455+
453456
private final int[] mAbsPos = new int[2];
454457

455458
private final NotificationGutsManager mGutsManager;
@@ -2277,6 +2280,9 @@ void observe() {
22772280
resolver.registerContentObserver(Settings.Secure.getUriFor(
22782281
Settings.Secure.SYSUI_ROUNDED_FWVALS),
22792282
false, this, UserHandle.USER_ALL);
2283+
resolver.registerContentObserver(Settings.Secure.getUriFor(
2284+
Settings.Secure.FP_SWIPE_TO_DISMISS_NOTIFICATIONS),
2285+
false, this, UserHandle.USER_ALL);
22802286
}
22812287

22822288
@Override
@@ -2324,6 +2330,9 @@ public void onChange(boolean selfChange, Uri uri) {
23242330
handleCutout(null);
23252331
} else if (uri.equals(Settings.Secure.getUriFor(Settings.Secure.SYSUI_ROUNDED_FWVALS))) {
23262332
updateCorners();
2333+
} else if (uri.equals(Settings.Secure.getUriFor(
2334+
Settings.Secure.FP_SWIPE_TO_DISMISS_NOTIFICATIONS))) {
2335+
setFpToDismissNotifications();
23272336
}
23282337
}
23292338

@@ -2343,6 +2352,7 @@ public void update() {
23432352
setChargingAnimation();
23442353
updateCorners();
23452354
handleCutout(null);
2355+
setFpToDismissNotifications();
23462356
}
23472357
}
23482358

@@ -2534,6 +2544,12 @@ public void setBlockedGesturalNavigation(boolean blocked) {
25342544
}
25352545
}
25362546

2547+
private void setFpToDismissNotifications() {
2548+
mFpDismissNotifications = Settings.Secure.getIntForUser(mContext.getContentResolver(),
2549+
Settings.Secure.FP_SWIPE_TO_DISMISS_NOTIFICATIONS, 0,
2550+
UserHandle.USER_CURRENT) == 1;
2551+
}
2552+
25372553
/**
25382554
* All changes to the status bar and notifications funnel through here and are batched.
25392555
*/
@@ -2619,6 +2635,15 @@ public void handleSystemKey(int key) {
26192635
NotificationPanelView.FLING_EXPAND);
26202636
mMetricsLogger.count(NotificationPanelView.COUNTER_PANEL_OPEN_QS, 1);
26212637
}
2638+
} else if (mFpDismissNotifications && (KeyEvent.KEYCODE_SYSTEM_NAVIGATION_LEFT == key
2639+
|| KeyEvent.KEYCODE_SYSTEM_NAVIGATION_RIGHT == key)) {
2640+
if (!mNotificationPanelViewController.isFullyCollapsed() && !mNotificationPanelViewController.isExpanding()){
2641+
mMetricsLogger.action(MetricsEvent.ACTION_DISMISS_ALL_NOTES);
2642+
((NotificationStackScrollLayout)mStackScroller).clearNotifications(
2643+
((NotificationStackScrollLayout)mStackScroller).ROWS_ALL/*all notifications*/,
2644+
true/*collapse the panel*/,
2645+
KeyEvent.KEYCODE_SYSTEM_NAVIGATION_LEFT == key/*left swipe animation*/);
2646+
}
26222647
}
26232648

26242649
}

0 commit comments

Comments
 (0)