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

Commit c9074277 authored by Pinyao Ting's avatar Pinyao Ting
Browse files

[a11y] fix the issue where launcher announces item added to homescreen before

it does

Test:
1. long press on home screen -> widgets
2. enable talkback
3. add a custom shortcut to home screen (i.e. 1x1 widgets, e.g. drive
scan in Google Drive, Driving Mode in Google Maps ... e.t.c )
4. verify talkback announces "item addded to homescreen" after it does
get added to the homescreen
5. repeat the same test for widgets (e.g. calendar)

Bug: 141527338
Change-Id: I232e6e796c9edb81128f816c71a33310c3700e73
parent 96ea1a05
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -83,6 +83,7 @@ import android.view.animation.OvershootInterpolator;
import android.widget.Toast;

import androidx.annotation.Nullable;
import androidx.annotation.StringRes;
import androidx.annotation.VisibleForTesting;

import com.android.launcher3.DropTarget.DragObject;
@@ -687,6 +688,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
        switch (requestCode) {
            case REQUEST_CREATE_SHORTCUT:
                completeAddShortcut(intent, info.container, screenId, info.cellX, info.cellY, info);
                announceForAccessibility(R.string.item_added_to_workspace);
                break;
            case REQUEST_CREATE_APPWIDGET:
                completeAddAppWidget(appWidgetId, info, null, null);
@@ -711,7 +713,6 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
                break;
            }
        }

        return screenId;
    }

@@ -1317,6 +1318,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
        hostView.setVisibility(View.VISIBLE);
        prepareAppWidget(hostView, launcherInfo);
        mWorkspace.addInScreen(hostView, launcherInfo);
        announceForAccessibility(R.string.item_added_to_workspace);
    }

    private void prepareAppWidget(AppWidgetHostView hostView, LauncherAppWidgetInfo item) {
@@ -2406,6 +2408,10 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
        return bounceAnim;
    }

    private void announceForAccessibility(@StringRes int stringResId) {
        getDragLayer().announceForAccessibility(getString(stringResId));
    }

    /**
     * Add the icons for all apps.
     *
+1 −1
Original line number Diff line number Diff line
@@ -191,6 +191,7 @@ public class LauncherAccessibilityDelegate extends AccessibilityDelegate impleme
                        ArrayList<ItemInfo> itemList = new ArrayList<>();
                        itemList.add(info);
                        mLauncher.bindItems(itemList, true);
                        announceConfirmation(R.string.item_added_to_workspace);
                    } else if (item instanceof PendingAddItemInfo) {
                        PendingAddItemInfo info = (PendingAddItemInfo) item;
                        Workspace workspace = mLauncher.getWorkspace();
@@ -198,7 +199,6 @@ public class LauncherAccessibilityDelegate extends AccessibilityDelegate impleme
                        mLauncher.addPendingItem(info, Favorites.CONTAINER_DESKTOP,
                                screenId, coordinates, info.spanX, info.spanY);
                    }
                    announceConfirmation(R.string.item_added_to_workspace);
                }
            });
            return true;