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

Commit e78e3d73 authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Accessibility fixes

1) Use a different content description for temporary new page
2) Use different accessibility description for add widget toast
3) Announce when an item is deleted
4) Announce when hovering over a drop target
5) Announce state during drag-n-drop and widget resize (similar to seekbar)

Bug: 23573321, 24057944
Change-Id: Icabb317625e70c78e11c0b4f99b9339172d93594
parent 2949fb5b
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -50,6 +50,8 @@
    <!-- Widgets -->
    <!-- Message to tell the user to press and hold on a widget to add it [CHAR_LIMIT=50] -->
    <string name="long_press_widget_to_add">Touch &amp; hold to pick up a widget.</string>
    <!-- Accessibility spoken hint message in widget picker, which allows user to add a widget. Custom action is the label for additional accessibility actions available in this mode [CHAR_LIMIT=100] -->
    <string name="long_accessible_way_to_add">Double-tap &amp; hold to pick up a widget or use custom actions.</string>
    <!-- The format string for the dimensions of a widget in the drawer -->
    <!-- There is a special version of this format string for Farsi -->
    <string name="widget_dims_format">%1$d \u00d7 %2$d</string>
@@ -125,6 +127,8 @@
    <string name="default_scroll_format">Page %1$d of %2$d</string>
    <!-- The format string for Workspace page scroll text [CHAR_LIMIT=none] -->
    <string name="workspace_scroll_format">Home screen %1$d of %2$d</string>
    <!-- Description for a new page on homescreen[CHAR_LIMIT=none] -->
    <string name="workspace_new_page">New home screen page</string>

    <!-- Clings -->
    <!-- The title text for the workspace cling [CHAR_LIMIT=30] -->
+12 −0
Original line number Diff line number Diff line
@@ -14,6 +14,8 @@ import android.view.Gravity;
import android.widget.FrameLayout;
import android.widget.ImageView;

import com.android.launcher3.accessibility.DragViewStateAnnouncer;

public class AppWidgetResizeFrame extends FrameLayout {
    private static final int SNAP_DURATION = 150;
    private static final float DIMMED_HANDLE_ALPHA = 0f;
@@ -40,6 +42,8 @@ public class AppWidgetResizeFrame extends FrameLayout {
    private final int[] mLastDirectionVector = new int[2];
    private final int[] mTmpPt = new int[2];

    private final DragViewStateAnnouncer mStateAnnouncer;

    private boolean mLeftBorderActive;
    private boolean mRightBorderActive;
    private boolean mTopBorderActive;
@@ -78,6 +82,8 @@ public class AppWidgetResizeFrame extends FrameLayout {
        mMinHSpan = info.minSpanX;
        mMinVSpan = info.minSpanY;

        mStateAnnouncer = DragViewStateAnnouncer.createFor(this);

        setBackgroundResource(R.drawable.widget_resize_shadow);
        setForeground(getResources().getDrawable(R.drawable.widget_resize_frame));
        setPadding(0, 0, 0, 0);
@@ -320,12 +326,18 @@ public class AppWidgetResizeFrame extends FrameLayout {

        if (mCellLayout.createAreaForResize(cellX, cellY, spanX, spanY, mWidgetView,
                mDirectionVector, onDismiss)) {
            if (mStateAnnouncer != null && (lp.cellHSpan != spanX || lp.cellVSpan != spanY) ) {
                mStateAnnouncer.announce(
                        mLauncher.getString(R.string.widget_resized, spanX, spanY));
            }

            lp.tmpCellX = cellX;
            lp.tmpCellY = cellY;
            lp.cellHSpan = spanX;
            lp.cellVSpan = spanY;
            mRunningVInc += vSpanDelta;
            mRunningHInc += hSpanDelta;

            if (!onDismiss) {
                updateWidgetSizeRanges(mWidgetView, mLauncher, spanX, spanY);
            }
+2 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import android.util.AttributeSet;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.LinearInterpolator;
import android.widget.TextView;
@@ -123,6 +124,7 @@ public abstract class ButtonDropTarget extends TextView
            mDrawable.setColorFilter(new ColorMatrixColorFilter(mCurrentFilter));
            setTextColor(mHoverColor);
        }
        sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED);
    }

    @Override
+16 −1
Original line number Diff line number Diff line
@@ -1021,7 +1021,7 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler {
    }

    void visualizeDropLocation(View v, Bitmap dragOutline, int originX, int originY, int cellX,
            int cellY, int spanX, int spanY, boolean resize, Point dragOffset, Rect dragRegion) {
            int cellY, int spanX, int spanY, boolean resize, DropTarget.DragObject dragObject) {
        final int oldDragCellX = mDragCell[0];
        final int oldDragCellY = mDragCell[1];

@@ -1030,6 +1030,9 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler {
        }

        if (cellX != oldDragCellX || cellY != oldDragCellY) {
            Point dragOffset = dragObject.dragView.getDragVisualizeOffset();
            Rect dragRegion = dragObject.dragView.getDragRegion();

            mDragCell[0] = cellX;
            mDragCell[1] = cellY;
            // Find the top left corner of the rect the object will occupy
@@ -1081,6 +1084,18 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler {

            mDragOutlineAnims[mDragOutlineCurrent].setTag(dragOutline);
            mDragOutlineAnims[mDragOutlineCurrent].animateIn();

            if (dragObject.stateAnnouncer != null) {
                String msg;
                if (isHotseat()) {
                    msg = getContext().getString(R.string.move_to_hotseat_position,
                            Math.max(cellX, cellY) + 1);
                } else {
                    msg = getContext().getString(R.string.move_to_empty_cell,
                            cellY + 1, cellX + 1);
                }
                dragObject.stateAnnouncer.announce(msg);
            }
        }
    }

+2 −4
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@ package com.android.launcher3;
import android.animation.TimeInterpolator;
import android.content.Context;
import android.graphics.PointF;
import android.os.AsyncTask;
import android.util.AttributeSet;
import android.view.View;
import android.view.animation.AnimationUtils;
@@ -67,15 +66,14 @@ public class DeleteDropTarget extends ButtonDropTarget {

    /**
     * Removes the item from the workspace. If the view is not null, it also removes the view.
     * @return true if the item was removed.
     */
    public static boolean removeWorkspaceOrFolderItem(Launcher launcher, ItemInfo item, View view) {
    public static void removeWorkspaceOrFolderItem(Launcher launcher, ItemInfo item, View view) {
        // Remove the item from launcher and the db, we can ignore the containerInfo in this call
        // because we already remove the drag view from the folder (if the drag originated from
        // a folder) in Folder.beginDrag()
        launcher.removeItem(view, item, true /* deleteFromDb */);
        launcher.getWorkspace().stripEmptyScreens();
        return true;
        launcher.getDragLayer().announceForAccessibility(launcher.getString(R.string.item_removed));
    }

    @Override
Loading