Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4848ccb4 authored by Adnan's avatar Adnan Committed by Adnan Begovic
Browse files

HeadsUp: Fix dismiss on back key press.

Change-Id: Ia213aeba114d153f5561622a2bea884963f3d8a1
(cherry picked from commit d84e336f)
parent 964d1bd4
Loading
Loading
Loading
Loading
+14 −0
Original line number Original line Diff line number Diff line
@@ -22,6 +22,7 @@ import android.content.res.Configuration;
import android.graphics.Rect;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.util.AttributeSet;
import android.util.Log;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewConfiguration;
@@ -228,6 +229,19 @@ public class HeadsUpNotificationView extends FrameLayout implements SwipeHelper.
        mBar.onHeadsUpDismissed();
        mBar.onHeadsUpDismissed();
    }
    }


    @Override
    public boolean dispatchKeyEvent(KeyEvent event) {
        boolean down = event.getAction() == KeyEvent.ACTION_DOWN;
        switch (event.getKeyCode()) {
            case KeyEvent.KEYCODE_BACK:
                if (!down && !event.isCanceled()) {
                    mBar.hideHeadsUp();
                }
                return true;
        }
        return super.dispatchKeyEvent(event);
    }

    @Override
    @Override
    public void onBeginDrag(View v) {
    public void onBeginDrag(View v) {
        // We need to prevent any surrounding View from intercepting us now.
        // We need to prevent any surrounding View from intercepting us now.