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

Commit 4e3bee76 authored by Svetoslav Ganov's avatar Svetoslav Ganov Committed by Android (Google) Code Review
Browse files

Merge "MiltiWaveView accessibility improvement." into ics-factoryrom

parents 2a6798ad 2a671ac9
Loading
Loading
Loading
Loading
+38 −51
Original line number Diff line number Diff line
@@ -35,7 +35,6 @@ import android.util.Log;
import android.util.TypedValue;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;

@@ -109,9 +108,6 @@ public class MultiWaveView extends View {
    private boolean mDragging;
    private int mNewTargetResources;

    private boolean mWaveHovered = false;
    private long mLastHoverExitTimeMillis = 0;

    private AnimatorListener mResetListener = new AnimatorListenerAdapter() {
        public void onAnimationEnd(Animator animator) {
            switchToState(STATE_IDLE, mWaveCenterX, mWaveCenterY);
@@ -660,59 +656,13 @@ public class MultiWaveView extends View {
    }

    private void handleDown(MotionEvent event) {
        final float x = event.getX();
        final float y = event.getY();
        final float dx = x - mWaveCenterX;
        final float dy = y - mWaveCenterY;
        if (dist2(dx,dy) <= getScaledTapRadiusSquared()) {
            if (DEBUG) Log.v(TAG, "** Handle HIT");
            switchToState(STATE_FIRST_TOUCH, x, y);
            moveHandleTo(x, y, false);
            mDragging = true;
        } else {
       if (!trySwitchToFirstTouchState(event)) {
            mDragging = false;
            stopTargetAnimation();
            ping();
        }
    }

    @Override
    public boolean onHoverEvent(MotionEvent event) {
        if (AccessibilityManager.getInstance(mContext).isTouchExplorationEnabled()) {
            final int action = event.getAction();
            switch (action) {
                case MotionEvent.ACTION_HOVER_ENTER:
                case MotionEvent.ACTION_HOVER_MOVE:
                    final float dx = event.getX() - mWaveCenterX;
                    final float dy = event.getY() - mWaveCenterY;
                    if (dist2(dx,dy) <= getScaledTapRadiusSquared()) {
                        if (!mWaveHovered) {
                            mWaveHovered = true;
                            final long timeSinceLastHoverExitMillis =
                                event.getEventTime() - mLastHoverExitTimeMillis;
                            final long recurringEventsInterval =
                                ViewConfiguration.getSendRecurringAccessibilityEventsInterval();
                            if (timeSinceLastHoverExitMillis > recurringEventsInterval) {
                                String text =
                                    mContext.getString(R.string.content_description_sliding_handle);
                                announceText(text);
                            }
                        }
                    } else {
                        mWaveHovered = false;
                    }
                    break;
                case MotionEvent.ACTION_HOVER_EXIT:
                    mLastHoverExitTimeMillis = event.getEventTime();
                    mWaveHovered = false;
                    break;
                default:
                    mWaveHovered = false;
            }
        }
        return super.onHoverEvent(event);
    }

    private void handleUp(MotionEvent event) {
        if (DEBUG && mDragging) Log.v(TAG, "** Handle RELEASE");
        switchToState(STATE_FINISH, event.getX(), event.getY());
@@ -720,6 +670,7 @@ public class MultiWaveView extends View {

    private void handleMove(MotionEvent event) {
        if (!mDragging) {
            trySwitchToFirstTouchState(event);
            return;
        }

@@ -792,6 +743,27 @@ public class MultiWaveView extends View {
        mActiveTarget = activeTarget;
    }

    @Override
    public boolean onHoverEvent(MotionEvent event) {
        if (AccessibilityManager.getInstance(mContext).isTouchExplorationEnabled()) {
            final int action = event.getAction();
            switch (action) {
                case MotionEvent.ACTION_HOVER_ENTER:
                    event.setAction(MotionEvent.ACTION_DOWN);
                    break;
                case MotionEvent.ACTION_HOVER_MOVE:
                    event.setAction(MotionEvent.ACTION_MOVE);
                    break;
                case MotionEvent.ACTION_HOVER_EXIT:
                    event.setAction(MotionEvent.ACTION_UP);
                    break;
            }
            onTouchEvent(event);
            event.setAction(action);
        }
        return super.onHoverEvent(event);
    }

    /**
     * Sets the current grabbed state, and dispatches a grabbed state change
     * event to our listener.
@@ -808,6 +780,21 @@ public class MultiWaveView extends View {
        }
    }

    private boolean trySwitchToFirstTouchState(MotionEvent event) {
        final float x = event.getX();
        final float y = event.getY();
        final float dx = x - mWaveCenterX;
        final float dy = y - mWaveCenterY;
        if (dist2(dx,dy) <= getScaledTapRadiusSquared()) {
            if (DEBUG) Log.v(TAG, "** Handle HIT");
            switchToState(STATE_FIRST_TOUCH, x, y);
            moveHandleTo(x, y, false);
            mDragging = true;
            return true;
        }
        return false;
    }

    private void performInitialLayout(float centerX, float centerY) {
        if (mOuterRadius == 0.0f) {
            mOuterRadius = 0.5f*(float) Math.sqrt(dist2(centerX, centerY));
+0 −1
Original line number Diff line number Diff line
@@ -1467,7 +1467,6 @@
    <string name="keyboardview_keycode_mode_change" msgid="4547387741906537519">"Modus verander"</string>
    <string name="keyboardview_keycode_shift" msgid="2270748814315147690">"Shift"</string>
    <string name="keyboardview_keycode_enter" msgid="2985864015076059467">"Invoersleutel"</string>
    <string name="content_description_sliding_handle" msgid="7311938669217173870">"Glyhandvatsel. Tik en hou."</string>
    <string name="description_direction_up" msgid="1983114130441878529">"Op na <xliff:g id="TARGET_DESCRIPTION">%s</xliff:g>."</string>
    <string name="description_direction_down" msgid="4294993639091088240">"Af vir <xliff:g id="TARGET_DESCRIPTION">%s</xliff:g>."</string>
    <string name="description_direction_left" msgid="6814008463839915747">"Links vir <xliff:g id="TARGET_DESCRIPTION">%s</xliff:g>."</string>
+0 −1
Original line number Diff line number Diff line
@@ -1467,7 +1467,6 @@
    <string name="keyboardview_keycode_mode_change" msgid="4547387741906537519">"ሞድ ለውጥ"</string>
    <string name="keyboardview_keycode_shift" msgid="2270748814315147690">"ቀይር"</string>
    <string name="keyboardview_keycode_enter" msgid="2985864015076059467">"አስገባ"</string>
    <string name="content_description_sliding_handle" msgid="7311938669217173870">"Sliding handle. Tap and hold."</string>
    <string name="description_direction_up" msgid="1983114130441878529">"<xliff:g id="TARGET_DESCRIPTION">%s</xliff:g> ወደላይ።"</string>
    <string name="description_direction_down" msgid="4294993639091088240">"<xliff:g id="TARGET_DESCRIPTION">%s</xliff:g> ወደታች።"</string>
    <string name="description_direction_left" msgid="6814008463839915747">"<xliff:g id="TARGET_DESCRIPTION">%s</xliff:g> ወደግራ።"</string>
+0 −1
Original line number Diff line number Diff line
@@ -1141,7 +1141,6 @@
    <string name="keyboardview_keycode_mode_change" msgid="4547387741906537519">"تغيير الوضع"</string>
    <string name="keyboardview_keycode_shift" msgid="2270748814315147690">"العالي"</string>
    <string name="keyboardview_keycode_enter" msgid="2985864015076059467">"Enter"</string>
    <string name="content_description_sliding_handle" msgid="7311938669217173870">"مقبض التمرير. انقر وامسك."</string>
    <string name="description_direction_up" msgid="1983114130441878529">"أعلى إلى <xliff:g id="TARGET_DESCRIPTION">%s</xliff:g>."</string>
    <string name="description_direction_down" msgid="4294993639091088240">"أسفل إلى <xliff:g id="TARGET_DESCRIPTION">%s</xliff:g>."</string>
    <string name="description_direction_left" msgid="6814008463839915747">"يسارًا إلى <xliff:g id="TARGET_DESCRIPTION">%s</xliff:g>."</string>
+0 −1
Original line number Diff line number Diff line
@@ -1158,7 +1158,6 @@
    <string name="keyboardview_keycode_mode_change" msgid="4547387741906537519">"Промяна на режима"</string>
    <string name="keyboardview_keycode_shift" msgid="2270748814315147690">"Shift"</string>
    <string name="keyboardview_keycode_enter" msgid="2985864015076059467">"Enter"</string>
    <string name="content_description_sliding_handle" msgid="7311938669217173870">"Плъзгаща се дръжка. Докоснете и задръжте."</string>
    <!-- no translation found for description_direction_up (1983114130441878529) -->
    <skip />
    <!-- no translation found for description_direction_down (4294993639091088240) -->
Loading