Ben Lin | 7c35b03 | 2016-05-31 13:24:01 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 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 | |
| 17 | package com.android.documentsui; |
| 18 | |
Garfield Tan | 239ab97 | 2016-09-16 13:33:48 -0700 | [diff] [blame] | 19 | import android.app.Fragment; |
Ben Lin | 7c35b03 | 2016-05-31 13:24:01 -0700 | [diff] [blame] | 20 | import android.view.Menu; |
Garfield Tan | 239ab97 | 2016-09-16 13:33:48 -0700 | [diff] [blame] | 21 | import android.view.MenuInflater; |
Ben Lin | ebf2a17 | 2016-06-03 13:46:52 -0700 | [diff] [blame] | 22 | import android.view.MenuItem; |
Garfield Tan | 239ab97 | 2016-09-16 13:33:48 -0700 | [diff] [blame] | 23 | import android.view.View; |
Ben Lin | 7c35b03 | 2016-05-31 13:24:01 -0700 | [diff] [blame] | 24 | |
Steve McKay | d9caa6a | 2016-09-15 16:36:45 -0700 | [diff] [blame] | 25 | import com.android.documentsui.base.Menus; |
Steve McKay | d080506 | 2016-09-15 14:30:38 -0700 | [diff] [blame] | 26 | import com.android.documentsui.base.RootInfo; |
Steve McKay | d9caa6a | 2016-09-15 16:36:45 -0700 | [diff] [blame] | 27 | import com.android.documentsui.base.Shared; |
| 28 | import com.android.documentsui.base.State; |
Garfield Tan | 06c4b11 | 2016-09-14 11:05:58 -0700 | [diff] [blame] | 29 | import com.android.documentsui.dirlist.DirectoryFragment; |
Garfield Tan | 239ab97 | 2016-09-16 13:33:48 -0700 | [diff] [blame] | 30 | import com.android.internal.annotations.VisibleForTesting; |
Ben Lin | 5668b86 | 2016-06-28 17:12:52 -0700 | [diff] [blame] | 31 | |
Ben Lin | ebf2a17 | 2016-06-03 13:46:52 -0700 | [diff] [blame] | 32 | public abstract class MenuManager { |
Ben Lin | 7c35b03 | 2016-05-31 13:24:01 -0700 | [diff] [blame] | 33 | |
Garfield Tan | 2567603 | 2016-09-19 13:52:35 -0700 | [diff] [blame] | 34 | final protected SearchViewManager mSearchManager; |
Steve McKay | e5d6ca2 | 2016-09-19 20:27:24 -0700 | [diff] [blame^] | 35 | final protected State mState; |
| 36 | final protected DirectoryDetails mDirDetails; |
Ben Lin | 2567991 | 2016-06-17 11:48:57 -0700 | [diff] [blame] | 37 | |
Steve McKay | e5d6ca2 | 2016-09-19 20:27:24 -0700 | [diff] [blame^] | 38 | public MenuManager( |
| 39 | SearchViewManager searchManager, |
| 40 | State displayState, |
| 41 | DirectoryDetails dirDetails) { |
Ben Lin | 2567991 | 2016-06-17 11:48:57 -0700 | [diff] [blame] | 42 | mSearchManager = searchManager; |
| 43 | mState = displayState; |
Steve McKay | e5d6ca2 | 2016-09-19 20:27:24 -0700 | [diff] [blame^] | 44 | mDirDetails = dirDetails; |
Ben Lin | 2567991 | 2016-06-17 11:48:57 -0700 | [diff] [blame] | 45 | } |
| 46 | |
Garfield Tan | 06c4b11 | 2016-09-14 11:05:58 -0700 | [diff] [blame] | 47 | /** @see ActionModeController */ |
Ben Lin | ebf2a17 | 2016-06-03 13:46:52 -0700 | [diff] [blame] | 48 | public void updateActionMenu(Menu menu, SelectionDetails selection) { |
Garfield Tan | 06c4b11 | 2016-09-14 11:05:58 -0700 | [diff] [blame] | 49 | updateOpenInActionMode(menu.findItem(R.id.menu_open), selection); |
Ben Lin | ebf2a17 | 2016-06-03 13:46:52 -0700 | [diff] [blame] | 50 | updateDelete(menu.findItem(R.id.menu_delete), selection); |
| 51 | updateShare(menu.findItem(R.id.menu_share), selection); |
| 52 | updateRename(menu.findItem(R.id.menu_rename), selection); |
Garfield Tan | 06c4b11 | 2016-09-14 11:05:58 -0700 | [diff] [blame] | 53 | updateSelectAll(menu.findItem(R.id.menu_select_all)); |
Ben Lin | ebf2a17 | 2016-06-03 13:46:52 -0700 | [diff] [blame] | 54 | updateMoveTo(menu.findItem(R.id.menu_move_to), selection); |
| 55 | updateCopyTo(menu.findItem(R.id.menu_copy_to), selection); |
Ben Lin | 7c35b03 | 2016-05-31 13:24:01 -0700 | [diff] [blame] | 56 | |
Ben Lin | ebf2a17 | 2016-06-03 13:46:52 -0700 | [diff] [blame] | 57 | Menus.disableHiddenItems(menu); |
| 58 | } |
Ben Lin | 7c35b03 | 2016-05-31 13:24:01 -0700 | [diff] [blame] | 59 | |
Garfield Tan | 06c4b11 | 2016-09-14 11:05:58 -0700 | [diff] [blame] | 60 | /** @see BaseActivity#onPrepareOptionsMenu */ |
Steve McKay | e5d6ca2 | 2016-09-19 20:27:24 -0700 | [diff] [blame^] | 61 | public void updateOptionMenu(Menu menu) { |
| 62 | updateCreateDir(menu.findItem(R.id.menu_create_dir)); |
| 63 | updateSettings(menu.findItem(R.id.menu_settings)); |
| 64 | updateNewWindow(menu.findItem(R.id.menu_new_window)); |
| 65 | updateModePicker(menu.findItem(R.id.menu_grid), menu.findItem(R.id.menu_list)); |
Garfield, Tan | 11d2348 | 2016-08-05 09:33:29 -0700 | [diff] [blame] | 66 | // Sort menu item is managed by SortMenuManager |
Steve McKay | e5d6ca2 | 2016-09-19 20:27:24 -0700 | [diff] [blame^] | 67 | updateAdvanced(menu.findItem(R.id.menu_advanced)); |
Ben Lin | 7c35b03 | 2016-05-31 13:24:01 -0700 | [diff] [blame] | 68 | |
Ben Lin | ebf2a17 | 2016-06-03 13:46:52 -0700 | [diff] [blame] | 69 | Menus.disableHiddenItems(menu); |
| 70 | } |
Ben Lin | 7c35b03 | 2016-05-31 13:24:01 -0700 | [diff] [blame] | 71 | |
Garfield Tan | 06c4b11 | 2016-09-14 11:05:58 -0700 | [diff] [blame] | 72 | /** |
Garfield Tan | 239ab97 | 2016-09-16 13:33:48 -0700 | [diff] [blame] | 73 | * Called when we needs {@link MenuManager} to ask Android to show context menu for us. |
| 74 | * {@link MenuManager} can choose to defeat this request. |
| 75 | * |
| 76 | * {@link #inflateContextMenuForDocs} and {@link #inflateContextMenuForContainer} are called |
| 77 | * afterwards when Android asks us to provide the content of context menus, so they're not |
| 78 | * correct locations to suppress context menus. |
| 79 | */ |
| 80 | public void showContextMenu(Fragment f, View v, float x, float y) { |
| 81 | // Pickers don't have any context menu at this moment. |
| 82 | } |
| 83 | |
Steve McKay | e5d6ca2 | 2016-09-19 20:27:24 -0700 | [diff] [blame^] | 84 | public void inflateContextMenuForContainer(Menu menu, MenuInflater inflater) { |
Garfield Tan | 239ab97 | 2016-09-16 13:33:48 -0700 | [diff] [blame] | 85 | throw new UnsupportedOperationException("Pickers don't allow context menu."); |
| 86 | } |
| 87 | |
| 88 | public void inflateContextMenuForDocs( |
| 89 | Menu menu, MenuInflater inflater, SelectionDetails selectionDetails) { |
| 90 | throw new UnsupportedOperationException("Pickers don't allow context menu."); |
| 91 | } |
| 92 | |
| 93 | /** |
Garfield Tan | 06c4b11 | 2016-09-14 11:05:58 -0700 | [diff] [blame] | 94 | * @see DirectoryFragment#onCreateContextMenu |
Ben Lin | b2dfa12 | 2016-08-11 17:42:57 -0700 | [diff] [blame] | 95 | * |
Garfield Tan | 06c4b11 | 2016-09-14 11:05:58 -0700 | [diff] [blame] | 96 | * Called when user tries to generate a context menu anchored to a file when the selection |
| 97 | * doesn't contain any folder. |
| 98 | * |
| 99 | * @param selectionDetails |
| 100 | * containsFiles may return false because this may be called when user right clicks on an |
| 101 | * unselectable item in pickers |
| 102 | */ |
Garfield Tan | 239ab97 | 2016-09-16 13:33:48 -0700 | [diff] [blame] | 103 | @VisibleForTesting |
Garfield Tan | 2567603 | 2016-09-19 13:52:35 -0700 | [diff] [blame] | 104 | public void updateContextMenuForFiles(Menu menu, SelectionDetails selectionDetails) { |
Garfield Tan | 06c4b11 | 2016-09-14 11:05:58 -0700 | [diff] [blame] | 105 | assert(selectionDetails != null); |
| 106 | |
| 107 | MenuItem share = menu.findItem(R.id.menu_share); |
| 108 | MenuItem open = menu.findItem(R.id.menu_open); |
| 109 | MenuItem openWith = menu.findItem(R.id.menu_open_with); |
| 110 | MenuItem rename = menu.findItem(R.id.menu_rename); |
| 111 | |
| 112 | updateShare(share, selectionDetails); |
| 113 | updateOpenInContextMenu(open, selectionDetails); |
| 114 | updateOpenWith(openWith, selectionDetails); |
| 115 | updateRename(rename, selectionDetails); |
| 116 | |
| 117 | updateContextMenu(menu, selectionDetails); |
| 118 | } |
| 119 | |
| 120 | /** |
| 121 | * @see DirectoryFragment#onCreateContextMenu |
| 122 | * |
| 123 | * Called when user tries to generate a context menu anchored to a folder when the selection |
| 124 | * doesn't contain any file. |
| 125 | * |
| 126 | * @param selectionDetails |
| 127 | * containDirectories may return false because this may be called when user right clicks on |
| 128 | * an unselectable item in pickers |
| 129 | */ |
Garfield Tan | 239ab97 | 2016-09-16 13:33:48 -0700 | [diff] [blame] | 130 | @VisibleForTesting |
Garfield Tan | 2567603 | 2016-09-19 13:52:35 -0700 | [diff] [blame] | 131 | public void updateContextMenuForDirs(Menu menu, SelectionDetails selectionDetails) { |
Garfield Tan | 06c4b11 | 2016-09-14 11:05:58 -0700 | [diff] [blame] | 132 | assert(selectionDetails != null); |
| 133 | |
| 134 | MenuItem openInNewWindow = menu.findItem(R.id.menu_open_in_new_window); |
| 135 | MenuItem rename = menu.findItem(R.id.menu_rename); |
| 136 | MenuItem pasteInto = menu.findItem(R.id.menu_paste_into_folder); |
| 137 | |
| 138 | updateOpenInNewWindow(openInNewWindow, selectionDetails); |
| 139 | updateRename(rename, selectionDetails); |
| 140 | updatePasteInto(pasteInto, selectionDetails); |
| 141 | |
| 142 | updateContextMenu(menu, selectionDetails); |
| 143 | } |
| 144 | |
| 145 | /** |
| 146 | * @see DirectoryFragment#onCreateContextMenu |
| 147 | * |
| 148 | * Update shared context menu items of both files and folders context menus. |
| 149 | */ |
Garfield Tan | 239ab97 | 2016-09-16 13:33:48 -0700 | [diff] [blame] | 150 | @VisibleForTesting |
Garfield Tan | 2567603 | 2016-09-19 13:52:35 -0700 | [diff] [blame] | 151 | public void updateContextMenu(Menu menu, SelectionDetails selectionDetails) { |
Ben Lin | b2dfa12 | 2016-08-11 17:42:57 -0700 | [diff] [blame] | 152 | assert(selectionDetails != null); |
| 153 | |
| 154 | MenuItem cut = menu.findItem(R.id.menu_cut_to_clipboard); |
| 155 | MenuItem copy = menu.findItem(R.id.menu_copy_to_clipboard); |
Ben Lin | b2dfa12 | 2016-08-11 17:42:57 -0700 | [diff] [blame] | 156 | MenuItem delete = menu.findItem(R.id.menu_delete); |
Ben Lin | b2dfa12 | 2016-08-11 17:42:57 -0700 | [diff] [blame] | 157 | |
Garfield Tan | 06c4b11 | 2016-09-14 11:05:58 -0700 | [diff] [blame] | 158 | final boolean canCopy = |
| 159 | selectionDetails.size() > 0 && !selectionDetails.containsPartialFiles(); |
| 160 | final boolean canDelete = selectionDetails.canDelete(); |
| 161 | cut.setEnabled(canCopy && canDelete); |
| 162 | copy.setEnabled(canCopy); |
| 163 | delete.setEnabled(canDelete); |
Ben Lin | b2dfa12 | 2016-08-11 17:42:57 -0700 | [diff] [blame] | 164 | } |
| 165 | |
Garfield Tan | 06c4b11 | 2016-09-14 11:05:58 -0700 | [diff] [blame] | 166 | /** |
| 167 | * @see DirectoryFragment#onCreateContextMenu |
Ben Lin | b2dfa12 | 2016-08-11 17:42:57 -0700 | [diff] [blame] | 168 | * |
| 169 | * Called when user tries to generate a context menu anchored to an empty pane. |
Garfield Tan | 06c4b11 | 2016-09-14 11:05:58 -0700 | [diff] [blame] | 170 | */ |
Garfield Tan | 239ab97 | 2016-09-16 13:33:48 -0700 | [diff] [blame] | 171 | @VisibleForTesting |
Steve McKay | e5d6ca2 | 2016-09-19 20:27:24 -0700 | [diff] [blame^] | 172 | public void updateContextMenuForContainer(Menu menu) { |
Ben Lin | ebf2a17 | 2016-06-03 13:46:52 -0700 | [diff] [blame] | 173 | MenuItem paste = menu.findItem(R.id.menu_paste_from_clipboard); |
Garfield Tan | 06c4b11 | 2016-09-14 11:05:58 -0700 | [diff] [blame] | 174 | MenuItem selectAll = menu.findItem(R.id.menu_select_all); |
Ben Lin | 7c35b03 | 2016-05-31 13:24:01 -0700 | [diff] [blame] | 175 | |
Steve McKay | e5d6ca2 | 2016-09-19 20:27:24 -0700 | [diff] [blame^] | 176 | paste.setEnabled(mDirDetails.hasItemsToPaste() && mDirDetails.canCreateDoc()); |
Garfield Tan | 06c4b11 | 2016-09-14 11:05:58 -0700 | [diff] [blame] | 177 | updateSelectAll(selectAll); |
Ben Lin | ebf2a17 | 2016-06-03 13:46:52 -0700 | [diff] [blame] | 178 | } |
Ben Lin | 7c35b03 | 2016-05-31 13:24:01 -0700 | [diff] [blame] | 179 | |
Garfield Tan | 06c4b11 | 2016-09-14 11:05:58 -0700 | [diff] [blame] | 180 | /** |
| 181 | * @see RootsFragment#onCreateContextMenu |
| 182 | */ |
Ben Lin | 5668b86 | 2016-06-28 17:12:52 -0700 | [diff] [blame] | 183 | public void updateRootContextMenu(Menu menu, RootInfo root) { |
| 184 | MenuItem settings = menu.findItem(R.id.menu_settings); |
| 185 | MenuItem eject = menu.findItem(R.id.menu_eject_root); |
| 186 | |
| 187 | updateSettings(settings, root); |
| 188 | updateEject(eject, root); |
| 189 | } |
| 190 | |
Steve McKay | e5d6ca2 | 2016-09-19 20:27:24 -0700 | [diff] [blame^] | 191 | protected void updateModePicker(MenuItem grid, MenuItem list) { |
Ben Lin | 2567991 | 2016-06-17 11:48:57 -0700 | [diff] [blame] | 192 | grid.setVisible(mState.derivedMode != State.MODE_GRID); |
| 193 | list.setVisible(mState.derivedMode != State.MODE_LIST); |
| 194 | } |
| 195 | |
Steve McKay | e5d6ca2 | 2016-09-19 20:27:24 -0700 | [diff] [blame^] | 196 | protected void updateAdvanced(MenuItem advanced) { |
Ben Lin | 2567991 | 2016-06-17 11:48:57 -0700 | [diff] [blame] | 197 | advanced.setVisible(mState.showAdvancedOption); |
| 198 | advanced.setTitle(mState.showAdvancedOption && mState.showAdvanced |
| 199 | ? R.string.menu_advanced_hide : R.string.menu_advanced_show); |
| 200 | } |
| 201 | |
Steve McKay | e5d6ca2 | 2016-09-19 20:27:24 -0700 | [diff] [blame^] | 202 | protected void updateSettings(MenuItem settings) { |
Ben Lin | 2567991 | 2016-06-17 11:48:57 -0700 | [diff] [blame] | 203 | settings.setVisible(false); |
| 204 | } |
| 205 | |
Garfield Tan | 2567603 | 2016-09-19 13:52:35 -0700 | [diff] [blame] | 206 | protected void updateSettings(MenuItem settings, RootInfo root) { |
Ben Lin | 5668b86 | 2016-06-28 17:12:52 -0700 | [diff] [blame] | 207 | settings.setVisible(false); |
| 208 | } |
| 209 | |
Garfield Tan | 2567603 | 2016-09-19 13:52:35 -0700 | [diff] [blame] | 210 | protected void updateEject(MenuItem eject, RootInfo root) { |
Ben Lin | 5668b86 | 2016-06-28 17:12:52 -0700 | [diff] [blame] | 211 | eject.setVisible(false); |
| 212 | } |
| 213 | |
Steve McKay | e5d6ca2 | 2016-09-19 20:27:24 -0700 | [diff] [blame^] | 214 | protected void updateNewWindow(MenuItem newWindow) { |
Ben Lin | 2567991 | 2016-06-17 11:48:57 -0700 | [diff] [blame] | 215 | newWindow.setVisible(false); |
| 216 | } |
| 217 | |
Garfield Tan | 2567603 | 2016-09-19 13:52:35 -0700 | [diff] [blame] | 218 | protected void updateOpenInActionMode(MenuItem open, SelectionDetails selectionDetails) { |
Ben Lin | 2567991 | 2016-06-17 11:48:57 -0700 | [diff] [blame] | 219 | open.setVisible(false); |
| 220 | } |
| 221 | |
Garfield Tan | 2567603 | 2016-09-19 13:52:35 -0700 | [diff] [blame] | 222 | protected void updateOpenWith(MenuItem openWith, SelectionDetails selectionDetails) { |
Garfield Tan | 06c4b11 | 2016-09-14 11:05:58 -0700 | [diff] [blame] | 223 | openWith.setVisible(false); |
| 224 | } |
| 225 | |
Garfield Tan | 2567603 | 2016-09-19 13:52:35 -0700 | [diff] [blame] | 226 | protected void updateOpenInNewWindow( |
| 227 | MenuItem openInNewWindow, SelectionDetails selectionDetails) { |
Garfield Tan | 06c4b11 | 2016-09-14 11:05:58 -0700 | [diff] [blame] | 228 | openInNewWindow.setVisible(false); |
| 229 | } |
| 230 | |
Garfield Tan | 2567603 | 2016-09-19 13:52:35 -0700 | [diff] [blame] | 231 | protected void updateShare(MenuItem share, SelectionDetails selectionDetails) { |
Ben Lin | 2567991 | 2016-06-17 11:48:57 -0700 | [diff] [blame] | 232 | share.setVisible(false); |
| 233 | } |
| 234 | |
Garfield Tan | 2567603 | 2016-09-19 13:52:35 -0700 | [diff] [blame] | 235 | protected void updateDelete(MenuItem delete, SelectionDetails selectionDetails) { |
Ben Lin | 2567991 | 2016-06-17 11:48:57 -0700 | [diff] [blame] | 236 | delete.setVisible(false); |
| 237 | } |
| 238 | |
Garfield Tan | 2567603 | 2016-09-19 13:52:35 -0700 | [diff] [blame] | 239 | protected void updateRename(MenuItem rename, SelectionDetails selectionDetails) { |
Ben Lin | 2567991 | 2016-06-17 11:48:57 -0700 | [diff] [blame] | 240 | rename.setVisible(false); |
| 241 | } |
| 242 | |
Garfield Tan | 2567603 | 2016-09-19 13:52:35 -0700 | [diff] [blame] | 243 | protected void updateMoveTo(MenuItem moveTo, SelectionDetails selectionDetails) { |
Ben Lin | 2567991 | 2016-06-17 11:48:57 -0700 | [diff] [blame] | 244 | moveTo.setVisible(false); |
| 245 | } |
| 246 | |
Garfield Tan | 2567603 | 2016-09-19 13:52:35 -0700 | [diff] [blame] | 247 | protected void updateCopyTo(MenuItem copyTo, SelectionDetails selectionDetails) { |
Ben Lin | 2567991 | 2016-06-17 11:48:57 -0700 | [diff] [blame] | 248 | copyTo.setVisible(false); |
| 249 | } |
| 250 | |
Garfield Tan | 2567603 | 2016-09-19 13:52:35 -0700 | [diff] [blame] | 251 | protected void updatePasteInto(MenuItem pasteInto, SelectionDetails selectionDetails) { |
Garfield Tan | 06c4b11 | 2016-09-14 11:05:58 -0700 | [diff] [blame] | 252 | pasteInto.setVisible(false); |
Ben Lin | b2dfa12 | 2016-08-11 17:42:57 -0700 | [diff] [blame] | 253 | } |
| 254 | |
Garfield Tan | 2567603 | 2016-09-19 13:52:35 -0700 | [diff] [blame] | 255 | protected abstract void updateOpenInContextMenu( |
| 256 | MenuItem open, SelectionDetails selectionDetails); |
| 257 | protected abstract void updateSelectAll(MenuItem selectAll); |
Steve McKay | e5d6ca2 | 2016-09-19 20:27:24 -0700 | [diff] [blame^] | 258 | protected abstract void updateCreateDir(MenuItem createDir); |
Ben Lin | 7c35b03 | 2016-05-31 13:24:01 -0700 | [diff] [blame] | 259 | |
Ben Lin | ebf2a17 | 2016-06-03 13:46:52 -0700 | [diff] [blame] | 260 | /** |
| 261 | * Access to meta data about the selection. |
| 262 | */ |
| 263 | public interface SelectionDetails { |
| 264 | boolean containsDirectories(); |
| 265 | |
Garfield Tan | 06c4b11 | 2016-09-14 11:05:58 -0700 | [diff] [blame] | 266 | boolean containsFiles(); |
| 267 | |
| 268 | int size(); |
| 269 | |
Ben Lin | ebf2a17 | 2016-06-03 13:46:52 -0700 | [diff] [blame] | 270 | boolean containsPartialFiles(); |
| 271 | |
| 272 | // TODO: Update these to express characteristics instead of answering concrete questions, |
| 273 | // since the answer to those questions is (or can be) activity specific. |
| 274 | boolean canDelete(); |
| 275 | |
| 276 | boolean canRename(); |
Ben Lin | b2dfa12 | 2016-08-11 17:42:57 -0700 | [diff] [blame] | 277 | |
| 278 | boolean canPasteInto(); |
Ben Lin | ebf2a17 | 2016-06-03 13:46:52 -0700 | [diff] [blame] | 279 | } |
| 280 | |
| 281 | public static class DirectoryDetails { |
| 282 | private final BaseActivity mActivity; |
| 283 | |
| 284 | public DirectoryDetails(BaseActivity activity) { |
| 285 | mActivity = activity; |
| 286 | } |
| 287 | |
| 288 | public boolean shouldShowFancyFeatures() { |
| 289 | return Shared.shouldShowFancyFeatures(mActivity); |
| 290 | } |
| 291 | |
| 292 | public boolean hasRootSettings() { |
| 293 | return mActivity.getCurrentRoot().hasSettings(); |
| 294 | } |
| 295 | |
| 296 | public boolean hasItemsToPaste() { |
| 297 | return false; |
| 298 | } |
| 299 | |
Garfield Tan | 06c4b11 | 2016-09-14 11:05:58 -0700 | [diff] [blame] | 300 | public boolean canCreateDoc() { |
| 301 | return isInRecents() ? false : mActivity.getCurrentDirectory().isCreateSupported(); |
| 302 | } |
| 303 | |
Ben Lin | ebf2a17 | 2016-06-03 13:46:52 -0700 | [diff] [blame] | 304 | public boolean isInRecents() { |
| 305 | return mActivity.getCurrentDirectory() == null; |
| 306 | } |
| 307 | |
| 308 | public boolean canCreateDirectory() { |
| 309 | return mActivity.canCreateDirectory(); |
| 310 | } |
| 311 | } |
| 312 | } |