FolderAccessibilityHelper.java revision e9b651eef1b9f3647eba94f833bff3fc52f5956b
1/*
2 * Copyright (C) 2015 The Android Open Source Project
3 *
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
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
17package com.android.launcher3.accessibility;
18
19import com.android.launcher3.CellLayout;
20import com.android.launcher3.FolderPagedView;
21import com.android.launcher3.R;
22
23/**
24 * Implementation of {@link DragAndDropAccessibilityDelegate} to support DnD in a folder.
25 */
26public class FolderAccessibilityHelper extends DragAndDropAccessibilityDelegate {
27    private final int mStartPosition;
28
29    public FolderAccessibilityHelper(CellLayout layout) {
30        super(layout);
31        FolderPagedView parent = (FolderPagedView) layout.getParent();
32
33        int index = parent.indexOfChild(layout);
34        mStartPosition = 1 + index * layout.getCountX() * layout.getCountY();
35    }
36    @Override
37    protected int intersectsValidDropTarget(int id) {
38        return id;
39    }
40
41    @Override
42    protected String getLocationDescriptionForIconDrop(int id) {
43        return mContext.getString(R.string.move_to_position, id + mStartPosition);
44    }
45
46    @Override
47    protected String getConfirmationForIconDrop(int id) {
48        return mContext.getString(R.string.item_moved);
49    }
50}
51