1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
|
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.documentsui;
import android.app.PendingIntent;
import android.content.ContentProvider;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.view.DragEvent;
import androidx.annotation.IntDef;
import androidx.recyclerview.selection.ItemDetailsLookup.ItemDetails;
import com.android.documentsui.base.BooleanConsumer;
import com.android.documentsui.base.DocumentInfo;
import com.android.documentsui.base.DocumentStack;
import com.android.documentsui.base.RootInfo;
import com.android.documentsui.base.UserId;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.List;
import java.util.function.Consumer;
import javax.annotation.Nullable;
/**
* Interface to handle action for document.
*/
public interface ActionHandler {
@IntDef({
VIEW_TYPE_NONE,
VIEW_TYPE_REGULAR,
VIEW_TYPE_PREVIEW
})
@Retention(RetentionPolicy.SOURCE)
public @interface ViewType {}
public static final int VIEW_TYPE_NONE = 0;
public static final int VIEW_TYPE_REGULAR = 1;
public static final int VIEW_TYPE_PREVIEW = 2;
void onActivityResult(int requestCode, int resultCode, Intent data);
void openSettings(RootInfo root);
/**
* Drops documents on a root.
*/
boolean dropOn(DragEvent event, RootInfo root);
/**
* Attempts to eject the identified root. Returns a boolean answer to listener.
*/
void ejectRoot(RootInfo root, BooleanConsumer listener);
/**
* Attempts to fetch the DocumentInfo for the supplied root. Returns the DocumentInfo to the
* callback. If the task times out, callback will be called with null DocumentInfo. Supply
* {@link TimeoutTask#DEFAULT_TIMEOUT} if you don't want to the task to ever time out.
*/
void getRootDocument(RootInfo root, int timeout, Consumer<DocumentInfo> callback);
/**
* Attempts to refresh the given DocumentInfo, which should be at the top of the state stack.
* Returns a boolean answer to the callback, given by {@link ContentProvider#refresh}.
*/
void refreshDocument(DocumentInfo doc, BooleanConsumer callback);
/**
* Attempts to start the authentication process caused by
* {@link android.app.AuthenticationRequiredException}.
*/
void startAuthentication(PendingIntent intent);
void requestQuietModeDisabled(RootInfo info, UserId userId);
void showAppDetails(ResolveInfo info, UserId userId);
void openRoot(RootInfo root);
void openRoot(ResolveInfo app, UserId userId);
void loadRoot(Uri uri, UserId userId);
void loadCrossProfileRoot(RootInfo info, UserId selectedUser);
void loadFirstRoot(Uri uri);
void openSelectedInNewWindow();
void openInNewWindow(DocumentStack path);
void pasteIntoFolder(RootInfo root);
void selectAllFiles();
/**
* Attempts to deselect all selected files.
*/
void deselectAllFiles();
void showCreateDirectoryDialog();
void showPreview(DocumentInfo doc);
@Nullable DocumentInfo renameDocument(String name, DocumentInfo document);
/**
* If container, then opens the container, otherwise views using the specified type of view.
* If the primary view type is unavailable, then fallback to the alternative type of view.
*/
boolean openItem(ItemDetails<String> doc, @ViewType int type, @ViewType int fallback);
/**
* Similar to openItem but takes DocumentInfo instead of DocumentItemDetails and uses
* VIEW_TYPE_VIEW with no fallback.
*/
void openDocumentViewOnly(DocumentInfo doc);
/**
* This is called when user hovers over a doc for enough time during a drag n' drop, to open a
* folder that accepts drop. We should only open a container that's not an archive, since archives
* do not accept dropping.
*/
void springOpenDirectory(DocumentInfo doc);
void showChooserForDoc(DocumentInfo doc);
void openRootDocument(@Nullable DocumentInfo rootDoc);
void openContainerDocument(DocumentInfo doc);
boolean previewItem(ItemDetails<String> doc);
void cutToClipboard();
void copyToClipboard();
/**
* Show delete dialog
*/
void showDeleteDialog();
/**
* Delete the selected document(s)
*/
void deleteSelectedDocuments(List<DocumentInfo> docs, DocumentInfo srcParent);
void shareSelectedDocuments();
/**
* Called when initial activity setup is complete. Implementations
* should override this method to set the initial location of the
* app.
*/
void initLocation(Intent intent);
void registerDisplayStateChangedListener(Runnable l);
void unregisterDisplayStateChangedListener(Runnable l);
void loadDocumentsForCurrentStack();
void viewInOwner();
void setDebugMode(boolean enabled);
void showDebugMessage();
void showSortDialog();
/**
* Switch launch icon show/hide status.
*/
void switchLauncherIcon();
/**
* Allow action handler to be initialized in a new scope.
* @return this
*/
<T extends ActionHandler> T reset(ContentLock contentLock);
}
|