blob: fe85e27e3591343d791f6caaec3a5f171932afcb [file] [log] [blame]
Steve McKay1f199482015-05-20 15:58:42 -07001/*
Ben Lin30b0dc12017-03-07 15:37:16 -08002 * Copyright (C) 2017 The Android Open Source Project
Steve McKay1f199482015-05-20 15:58:42 -07003 *
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
Garfield, Tan9666ce62016-07-12 11:02:09 -070017package com.android.documentsui.clipping;
Steve McKay1f199482015-05-20 15:58:42 -070018
Steve McKay1f199482015-05-20 15:58:42 -070019import android.content.ClipData;
20import android.content.ClipboardManager;
Steve McKay1f199482015-05-20 15:58:42 -070021import android.content.Context;
Steve McKay1f199482015-05-20 15:58:42 -070022import android.net.Uri;
Riddle Hsu0c375982018-06-21 22:06:43 +080023
24import androidx.recyclerview.selection.Selection;
Steve McKay1f199482015-05-20 15:58:42 -070025
Steve McKayd0805062016-09-15 14:30:38 -070026import com.android.documentsui.base.DocumentInfo;
27import com.android.documentsui.base.DocumentStack;
Ben Linff4d5842016-04-18 14:35:28 -070028import com.android.documentsui.services.FileOperationService.OpType;
Garfield, Tan4d009142016-05-12 14:12:18 -070029import com.android.documentsui.services.FileOperations;
Steve McKay1f199482015-05-20 15:58:42 -070030
Garfield Tanda2c0f02017-04-11 13:47:58 -070031import java.util.List;
Steve McKay84769b82016-06-09 10:46:07 -070032import java.util.function.Function;
Steve McKay1f199482015-05-20 15:58:42 -070033
Ben Lin30b0dc12017-03-07 15:37:16 -080034public interface DocumentClipper {
Steve McKay1f199482015-05-20 15:58:42 -070035
Garfield, Tanedce5542016-06-17 15:32:28 -070036 static final String OP_JUMBO_SELECTION_SIZE = "jumboSelection-size";
37 static final String OP_JUMBO_SELECTION_TAG = "jumboSelection-tag";
38
Ben Lin30b0dc12017-03-07 15:37:16 -080039 static public DocumentClipper create(Context context, ClipStore clipStore) {
40 return new RuntimeDocumentClipper(context, clipStore);
Steve McKay1f199482015-05-20 15:58:42 -070041 }
42
Ben Lin30b0dc12017-03-07 15:37:16 -080043 boolean hasItemsToPaste();
Steve McKay1f199482015-05-20 15:58:42 -070044
Garfield, Tanedce5542016-06-17 15:32:28 -070045 /**
46 * Returns {@link ClipData} representing the selection, or null if selection is empty,
47 * or cannot be converted.
Garfield, Tanedce5542016-06-17 15:32:28 -070048 */
Riddle Hsu0c375982018-06-21 22:06:43 +080049 ClipData getClipDataForDocuments(Function<String, Uri> uriBuilder, Selection<String> selection,
Garfield Tanda2c0f02017-04-11 13:47:58 -070050 @OpType int opType);
51
52 /**
53 * Returns {@link ClipData} representing the list of {@link Uri}, or null if the list is empty.
54 */
55 ClipData getClipDataForDocuments(List<Uri> uris, @OpType int opType, DocumentInfo parent);
Vladislav Kaznacheev0859d302016-05-03 15:37:21 -070056
Ben Linff4d5842016-04-18 14:35:28 -070057 /**
Garfield Tan2e81db62017-04-27 15:06:49 -070058 * Returns {@link ClipData} representing the list of {@link Uri}, or null if the list is empty.
59 */
60 ClipData getClipDataForDocuments(List<Uri> uris, @OpType int opType);
61
62 /**
Ben Linff4d5842016-04-18 14:35:28 -070063 * Puts {@code ClipData} in a primary clipboard, describing a copy operation
64 */
Riddle Hsu0c375982018-06-21 22:06:43 +080065 void clipDocumentsForCopy(Function<String, Uri> uriBuilder, Selection<String> selection);
Ben Linff4d5842016-04-18 14:35:28 -070066
67 /**
68 * Puts {@Code ClipData} in a primary clipboard, describing a cut operation
69 */
Ben Lin30b0dc12017-03-07 15:37:16 -080070 void clipDocumentsForCut(
Riddle Hsu0c375982018-06-21 22:06:43 +080071 Function<String, Uri> uriBuilder, Selection<String> selection, DocumentInfo parent);
Ben Linff4d5842016-04-18 14:35:28 -070072
Garfield, Tanedce5542016-06-17 15:32:28 -070073 /**
Garfield, Tan4d009142016-05-12 14:12:18 -070074 * Copies documents from clipboard. It's the same as {@link #copyFromClipData} with clipData
75 * returned from {@link ClipboardManager#getPrimaryClip()}.
76 *
77 * @param destination destination document.
Garfield Tan85a479e2017-03-16 11:22:00 -070078 * @param docStack the document stack to the destination folder (not including the destination
79 * folder)
Garfield Tanda2c0f02017-04-11 13:47:58 -070080 * @param callback callback to notify when operation is scheduled or rejected.
Garfield, Tan4d009142016-05-12 14:12:18 -070081 */
Ben Lin30b0dc12017-03-07 15:37:16 -080082 void copyFromClipboard(
Steve McKay84769b82016-06-09 10:46:07 -070083 DocumentInfo destination,
84 DocumentStack docStack,
Ben Lin30b0dc12017-03-07 15:37:16 -080085 FileOperations.Callback callback);
Garfield, Tan4d009142016-05-12 14:12:18 -070086
87 /**
Ben Lindb7a0e72017-03-02 11:18:22 -080088 * Copies documents from clipboard. It's the same as {@link #copyFromClipData} with clipData
89 * returned from {@link ClipboardManager#getPrimaryClip()}.
90 *
91 * @param docStack the document stack to the destination folder,
Garfield Tanda2c0f02017-04-11 13:47:58 -070092 * @param callback callback to notify when operation is scheduled or rejected.
Ben Lindb7a0e72017-03-02 11:18:22 -080093 */
Ben Lin30b0dc12017-03-07 15:37:16 -080094 void copyFromClipboard(
Ben Lindb7a0e72017-03-02 11:18:22 -080095 DocumentStack docStack,
Ben Lin30b0dc12017-03-07 15:37:16 -080096 FileOperations.Callback callback);
Ben Lindb7a0e72017-03-02 11:18:22 -080097
98 /**
Garfield, Tana5588b62016-07-13 09:23:04 -070099 * Copies documents from given clip data to a folder.
Garfield, Tan4d009142016-05-12 14:12:18 -0700100 *
Garfield, Tana5588b62016-07-13 09:23:04 -0700101 * @param destination destination folder
102 * @param docStack the document stack to the destination folder (not including the destination
103 * folder)
104 * @param clipData the clipData to copy from
Garfield Tanda2c0f02017-04-11 13:47:58 -0700105 * @param callback callback to notify when operation is scheduled or rejected.
Garfield, Tan4d009142016-05-12 14:12:18 -0700106 */
Ben Lin30b0dc12017-03-07 15:37:16 -0800107 void copyFromClipData(
Garfield Tanda2c0f02017-04-11 13:47:58 -0700108 DocumentInfo destination,
109 DocumentStack docStack,
110 ClipData clipData,
111 FileOperations.Callback callback);
112
113 /**
114 * Copies documents from given clip data to a folder, ignoring the op type in clip data.
115 *
116 * @param dstStack the document stack to the destination folder, including the destination
117 * folder.
118 * @param clipData the clipData to copy from
119 * @param opType the operation type
120 * @param callback callback to notify when operation is scheduled or rejected.
121 */
122 void copyFromClipData(
123 DocumentStack dstStack,
124 ClipData clipData,
125 @OpType int opType,
126 FileOperations.Callback callback);
Garfield Tan85a479e2017-03-16 11:22:00 -0700127
128 /**
129 * Copies documents from given clip data to a folder.
130 *
131 * @param dstStack the document stack to the destination folder, including the destination
132 * folder.
133 * @param clipData the clipData to copy from
Garfield Tanda2c0f02017-04-11 13:47:58 -0700134 * @param callback callback to notify when operation is scheduled or rejected.
Garfield Tan85a479e2017-03-16 11:22:00 -0700135 */
136 void copyFromClipData(
Garfield Tanda2c0f02017-04-11 13:47:58 -0700137 DocumentStack dstStack,
138 ClipData clipData,
139 FileOperations.Callback callback);
Steve McKay1f199482015-05-20 15:58:42 -0700140}