Merge "Focus on newly-added workspace items for accessibility." into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
2fd0be4b15
@@ -2154,12 +2154,29 @@ public class Launcher extends StatefulActivity<LauncherState> implements Launche
|
||||
*/
|
||||
@Override
|
||||
public void bindItems(final List<ItemInfo> items, final boolean forceAnimateIcons) {
|
||||
bindItems(items, forceAnimateIcons, /* focusFirstItemForAccessibility= */ false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Bind the items start-end from the list.
|
||||
*
|
||||
* Implementation of the method from LauncherModel.Callbacks.
|
||||
*
|
||||
* @param focusFirstItemForAccessibility true iff the first item to be added to the workspace
|
||||
* should be focused for accessibility.
|
||||
*/
|
||||
public void bindItems(
|
||||
final List<ItemInfo> items,
|
||||
final boolean forceAnimateIcons,
|
||||
final boolean focusFirstItemForAccessibility) {
|
||||
// Get the list of added items and intersect them with the set of items here
|
||||
final Collection<Animator> bounceAnims = new ArrayList<>();
|
||||
final boolean animateIcons = forceAnimateIcons && canRunNewAppsAnimation();
|
||||
Workspace workspace = mWorkspace;
|
||||
int newItemsScreenId = -1;
|
||||
int end = items.size();
|
||||
View newView = null;
|
||||
for (int i = 0; i < end; i++) {
|
||||
final ItemInfo item = items.get(i);
|
||||
|
||||
@@ -2224,12 +2241,25 @@ public class Launcher extends StatefulActivity<LauncherState> implements Launche
|
||||
bounceAnims.add(createNewAppBounceAnimation(view, i));
|
||||
newItemsScreenId = item.screenId;
|
||||
}
|
||||
|
||||
if (newView == null) {
|
||||
newView = view;
|
||||
}
|
||||
}
|
||||
|
||||
// Animate to the correct page
|
||||
View viewToFocus = newView;
|
||||
// Animate to the correct pager
|
||||
if (animateIcons && newItemsScreenId > -1) {
|
||||
AnimatorSet anim = new AnimatorSet();
|
||||
anim.playTogether(bounceAnims);
|
||||
if (focusFirstItemForAccessibility && viewToFocus != null) {
|
||||
anim.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
viewToFocus.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
int currentScreenId = mWorkspace.getScreenIdForPageIndex(mWorkspace.getNextPage());
|
||||
final int newScreenIndex = mWorkspace.getPageIndexForScreenId(newItemsScreenId);
|
||||
@@ -2252,6 +2282,8 @@ public class Launcher extends StatefulActivity<LauncherState> implements Launche
|
||||
} else {
|
||||
mWorkspace.postDelayed(startBounceAnimRunnable, NEW_APPS_ANIMATION_DELAY);
|
||||
}
|
||||
} else if (focusFirstItemForAccessibility && viewToFocus != null) {
|
||||
viewToFocus.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED);
|
||||
}
|
||||
workspace.requestLayout();
|
||||
}
|
||||
|
||||
@@ -230,7 +230,10 @@ public class LauncherAccessibilityDelegate extends AccessibilityDelegate impleme
|
||||
Favorites.CONTAINER_DESKTOP,
|
||||
screenId, coordinates[0], coordinates[1]);
|
||||
|
||||
mLauncher.bindItems(Collections.singletonList(info), true);
|
||||
mLauncher.bindItems(
|
||||
Collections.singletonList(info),
|
||||
/* forceAnimateIcons= */ true,
|
||||
/* focusFirstItemForAccessibility= */ true);
|
||||
announceConfirmation(R.string.item_added_to_workspace);
|
||||
} else if (item instanceof PendingAddItemInfo) {
|
||||
PendingAddItemInfo info = (PendingAddItemInfo) item;
|
||||
|
||||
Reference in New Issue
Block a user