2 * Copyright (C) 2015 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package com.android.launcher3.accessibility;
19 import com.android.launcher3.CellLayout;
20 import com.android.launcher3.FolderPagedView;
21 import com.android.launcher3.R;
24 * Implementation of {@link DragAndDropAccessibilityDelegate} to support DnD in a folder.
26 public class FolderAccessibilityHelper extends DragAndDropAccessibilityDelegate {
29 * 0-index position for the first cell in {@link #mView} in {@link #mParent}.
31 private final int mStartPosition;
33 private final FolderPagedView mParent;
35 public FolderAccessibilityHelper(CellLayout layout) {
37 mParent = (FolderPagedView) layout.getParent();
39 int index = mParent.indexOfChild(layout);
40 mStartPosition = index * layout.getCountX() * layout.getCountY();
43 protected int intersectsValidDropTarget(int id) {
44 return Math.min(id, mParent.getAllocatedContentSize() - mStartPosition - 1);
48 protected String getLocationDescriptionForIconDrop(int id) {
49 return mContext.getString(R.string.move_to_position, id + mStartPosition + 1);
53 protected String getConfirmationForIconDrop(int id) {
54 return mContext.getString(R.string.item_moved);