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

Commit 44a4616b authored by Daniel Sandler's avatar Daniel Sandler
Browse files

Remove longpress support from the software Home key.

(Rendered unnecessary by the recents button.)

Bug: 5131723
Change-Id: I9f8f34ab8b96f750ec4bdf75daeb97c0971b5404
parent 2fd1f816
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -66,6 +66,7 @@
                android:layout_height="match_parent"
                android:src="@drawable/ic_sysbar_home"
                systemui:keyCode="3"
                systemui:keyRepeat="false"
                android:layout_weight="0"
                systemui:glowBackground="@drawable/ic_sysbar_highlight"
                android:contentDescription="@string/accessibility_home"
@@ -148,6 +149,7 @@
                android:layout_width="match_parent"
                android:src="@drawable/ic_sysbar_home_land"
                systemui:keyCode="3"
                systemui:keyRepeat="false"
                android:layout_weight="0"
                android:contentDescription="@string/accessibility_home"
                systemui:glowBackground="@drawable/ic_sysbar_highlight_land"
+4 −0
Original line number Diff line number Diff line
@@ -16,7 +16,11 @@

<resources>
    <declare-styleable name="KeyButtonView">
        <!-- key code to send when pressed; if absent or 0, no key is sent -->
        <attr name="keyCode" format="integer" />
        <!-- does this button generate longpress / repeat events? -->
        <attr name="keyRepeat" format="boolean" />
        <!-- drawable to use for a swelling, glowing background on press -->
        <attr name="glowBackground" format="reference" />
    </declare-styleable>
    <declare-styleable name="ToggleSlider">
+21 −8
Original line number Diff line number Diff line
@@ -57,11 +57,12 @@ public class KeyButtonView extends ImageView {
    int mTouchSlop;
    Drawable mGlowBG;
    float mGlowAlpha = 0f, mGlowScale = 1f, mDrawingAlpha = 1f;
    boolean mSupportsLongpress = true;

    Runnable mCheckLongPress = new Runnable() {
        public void run() {
            if (isPressed()) {

                // Slog.d("KeyButtonView", "longpressed: " + this);
                if (mCode != 0) {
                    mRepeat++;
                    sendEvent(KeyEvent.ACTION_DOWN,
@@ -90,6 +91,8 @@ public class KeyButtonView extends ImageView {

        mCode = a.getInteger(R.styleable.KeyButtonView_keyCode, 0);
        
        mSupportsLongpress = a.getBoolean(R.styleable.KeyButtonView_keyRepeat, true);

        mGlowBG = a.getDrawable(R.styleable.KeyButtonView_glowBackground);
        if (mGlowBG != null) {
            mDrawingAlpha = 0.5f;
@@ -207,11 +210,19 @@ public class KeyButtonView extends ImageView {
                mDownTime = SystemClock.uptimeMillis();
                mRepeat = 0;
                mSending = true;
                setPressed(true);
                sendEvent(KeyEvent.ACTION_DOWN,
                        KeyEvent.FLAG_FROM_SYSTEM | KeyEvent.FLAG_VIRTUAL_HARD_KEY, mDownTime);
                setPressed(true);
                if (mSupportsLongpress) {
                    removeCallbacks(mCheckLongPress);
                    postDelayed(mCheckLongPress, ViewConfiguration.getLongPressTimeout());
                } else {
                    mSending = false;
                    sendEvent(KeyEvent.ACTION_UP,
                            KeyEvent.FLAG_FROM_SYSTEM | KeyEvent.FLAG_VIRTUAL_HARD_KEY, mDownTime);
                    sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED);
                    playSoundEffect(SoundEffectConstants.CLICK);
                }
                break;
            case MotionEvent.ACTION_MOVE:
                if (mSending) {
@@ -230,8 +241,10 @@ public class KeyButtonView extends ImageView {
                    sendEvent(KeyEvent.ACTION_UP,
                            KeyEvent.FLAG_FROM_SYSTEM | KeyEvent.FLAG_VIRTUAL_HARD_KEY
                                | KeyEvent.FLAG_CANCELED);
                    if (mSupportsLongpress) {
                        removeCallbacks(mCheckLongPress);
                    }
                }
                break;
            case MotionEvent.ACTION_UP:
                final boolean doIt = isPressed();
@@ -239,15 +252,15 @@ public class KeyButtonView extends ImageView {
                if (mSending) {
                    mSending = false;
                    final int flags = KeyEvent.FLAG_FROM_SYSTEM | KeyEvent.FLAG_VIRTUAL_HARD_KEY;
                    if (mSupportsLongpress) {
                        removeCallbacks(mCheckLongPress);
                    }

                    if (mCode != 0) {
                        if (doIt) {
                            sendEvent(KeyEvent.ACTION_UP, flags);
                            sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED);
                            playSoundEffect(SoundEffectConstants.CLICK);
                        } else {
                            sendEvent(KeyEvent.ACTION_UP, flags | KeyEvent.FLAG_CANCELED);
                        }
                    } else {
                        // no key code, just a regular ImageView