FolderPickerActivity.java 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599
  1. /*
  2. * ownCloud Android client application
  3. *
  4. * Copyright (C) 2016 ownCloud Inc.
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2,
  8. * as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. *
  18. */
  19. package com.owncloud.android.ui.activity;
  20. import android.accounts.AuthenticatorException;
  21. import android.app.Activity;
  22. import android.content.BroadcastReceiver;
  23. import android.content.Context;
  24. import android.content.Intent;
  25. import android.content.IntentFilter;
  26. import android.content.res.Resources.NotFoundException;
  27. import android.os.Bundle;
  28. import android.os.Parcelable;
  29. import android.util.Log;
  30. import android.view.ActionMode;
  31. import android.view.Menu;
  32. import android.view.MenuInflater;
  33. import android.view.MenuItem;
  34. import android.view.View;
  35. import android.view.View.OnClickListener;
  36. import com.google.android.material.button.MaterialButton;
  37. import com.nextcloud.client.di.Injectable;
  38. import com.owncloud.android.R;
  39. import com.owncloud.android.datamodel.FileDataStorageManager;
  40. import com.owncloud.android.datamodel.OCFile;
  41. import com.owncloud.android.lib.common.operations.RemoteOperation;
  42. import com.owncloud.android.lib.common.operations.RemoteOperationResult;
  43. import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
  44. import com.owncloud.android.lib.common.utils.Log_OC;
  45. import com.owncloud.android.operations.CreateFolderOperation;
  46. import com.owncloud.android.operations.RefreshFolderOperation;
  47. import com.owncloud.android.syncadapter.FileSyncAdapter;
  48. import com.owncloud.android.ui.dialog.CreateFolderDialogFragment;
  49. import com.owncloud.android.ui.dialog.SortingOrderDialogFragment;
  50. import com.owncloud.android.ui.fragment.FileFragment;
  51. import com.owncloud.android.ui.fragment.OCFileListFragment;
  52. import com.owncloud.android.utils.DataHolderUtil;
  53. import com.owncloud.android.utils.DisplayUtils;
  54. import com.owncloud.android.utils.ErrorMessageAdapter;
  55. import com.owncloud.android.utils.FileSortOrder;
  56. import com.owncloud.android.utils.theme.ThemeButtonUtils;
  57. import com.owncloud.android.utils.theme.ThemeColorUtils;
  58. import com.owncloud.android.utils.theme.ThemeToolbarUtils;
  59. import com.owncloud.android.utils.theme.ThemeUtils;
  60. import java.io.File;
  61. import java.util.ArrayList;
  62. import javax.inject.Inject;
  63. import androidx.appcompat.app.ActionBar;
  64. import androidx.fragment.app.Fragment;
  65. import androidx.fragment.app.FragmentTransaction;
  66. import androidx.localbroadcastmanager.content.LocalBroadcastManager;
  67. public class FolderPickerActivity extends FileActivity implements FileFragment.ContainerActivity,
  68. OnClickListener,
  69. OnEnforceableRefreshListener,
  70. Injectable,
  71. SortingOrderDialogFragment.OnSortingOrderListener {
  72. public static final String EXTRA_FOLDER = FolderPickerActivity.class.getCanonicalName() + ".EXTRA_FOLDER";
  73. public static final String EXTRA_FILES = FolderPickerActivity.class.getCanonicalName() + ".EXTRA_FILES";
  74. public static final String EXTRA_ACTION = FolderPickerActivity.class.getCanonicalName() + ".EXTRA_ACTION";
  75. public static final String EXTRA_CURRENT_FOLDER = FolderPickerActivity.class.getCanonicalName() +
  76. ".EXTRA_CURRENT_FOLDER";
  77. public static final String MOVE = "MOVE";
  78. public static final String COPY = "COPY";
  79. private SyncBroadcastReceiver mSyncBroadcastReceiver;
  80. private static final String TAG = FolderPickerActivity.class.getSimpleName();
  81. protected static final String TAG_LIST_OF_FOLDERS = "LIST_OF_FOLDERS";
  82. private boolean mSyncInProgress;
  83. private boolean mSearchOnlyFolders;
  84. private boolean mDoNotEnterEncryptedFolder;
  85. protected MaterialButton mCancelBtn;
  86. protected MaterialButton mChooseBtn;
  87. private String caption;
  88. @Inject LocalBroadcastManager localBroadcastManager;
  89. @Override
  90. protected void onCreate(Bundle savedInstanceState) {
  91. Log_OC.d(TAG, "onCreate() start");
  92. super.onCreate(savedInstanceState);
  93. if (this instanceof FilePickerActivity) {
  94. setContentView(R.layout.files_picker);
  95. } else {
  96. setContentView(R.layout.files_folder_picker);
  97. }
  98. // sets callback listeners for UI elements
  99. initControls();
  100. // Action bar setup
  101. setupToolbar();
  102. findViewById(R.id.sort_list_button_group).setVisibility(View.VISIBLE);
  103. findViewById(R.id.switch_grid_view_button).setVisibility(View.GONE);
  104. if (getIntent().getStringExtra(EXTRA_ACTION) != null) {
  105. switch (getIntent().getStringExtra(EXTRA_ACTION)) {
  106. case MOVE:
  107. caption = getResources().getText(R.string.move_to).toString();
  108. mSearchOnlyFolders = true;
  109. mDoNotEnterEncryptedFolder = true;
  110. break;
  111. case COPY:
  112. caption = getResources().getText(R.string.copy_to).toString();
  113. mSearchOnlyFolders = true;
  114. mDoNotEnterEncryptedFolder = true;
  115. break;
  116. default:
  117. caption = ThemeUtils.getDefaultDisplayNameForRootFolder(this);
  118. break;
  119. }
  120. } else {
  121. caption = ThemeUtils.getDefaultDisplayNameForRootFolder(this);
  122. }
  123. if (getIntent().getParcelableExtra(EXTRA_CURRENT_FOLDER) != null) {
  124. setFile(getIntent().getParcelableExtra(EXTRA_CURRENT_FOLDER));
  125. }
  126. if (savedInstanceState == null) {
  127. createFragments();
  128. }
  129. updateActionBarTitleAndHomeButtonByString(caption);
  130. // always AFTER setContentView(...) ; to work around bug in its implementation
  131. // sets message for empty list of folders
  132. setBackgroundText();
  133. Log_OC.d(TAG, "onCreate() end");
  134. }
  135. @Override
  136. public void onActionModeStarted(ActionMode mode) {
  137. super.onActionModeStarted(mode);
  138. if (getAccount() != null) {
  139. updateFileFromDB();
  140. OCFile folder = getFile();
  141. if (folder == null || !folder.isFolder()) {
  142. // fall back to root folder
  143. setFile(getStorageManager().getFileByPath(OCFile.ROOT_PATH));
  144. folder = getFile();
  145. }
  146. OCFileListFragment listOfFolders = getListOfFilesFragment();
  147. listOfFolders.listDirectory(folder, false, false);
  148. startSyncFolderOperation(folder, false);
  149. updateNavigationElementsInActionBar();
  150. }
  151. }
  152. private Activity getActivity() {
  153. return this;
  154. }
  155. protected void createFragments() {
  156. OCFileListFragment listOfFiles = new OCFileListFragment();
  157. Bundle args = new Bundle();
  158. args.putBoolean(OCFileListFragment.ARG_ONLY_FOLDERS_CLICKABLE, true);
  159. args.putBoolean(OCFileListFragment.ARG_HIDE_FAB, true);
  160. args.putBoolean(OCFileListFragment.ARG_HIDE_ITEM_OPTIONS, true);
  161. args.putBoolean(OCFileListFragment.ARG_SEARCH_ONLY_FOLDER, mSearchOnlyFolders);
  162. listOfFiles.setArguments(args);
  163. FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
  164. transaction.add(R.id.fragment_container, listOfFiles, TAG_LIST_OF_FOLDERS);
  165. transaction.commit();
  166. }
  167. /**
  168. * Show a text message on screen view for notifying user if content is loading or folder is empty
  169. */
  170. private void setBackgroundText() {
  171. OCFileListFragment listFragment = getListOfFilesFragment();
  172. if (listFragment != null) {
  173. if (!mSyncInProgress) {
  174. listFragment.setMessageForEmptyList(
  175. R.string.file_list_empty_headline,
  176. R.string.file_list_empty_moving,
  177. R.drawable.ic_list_empty_create_folder,
  178. true
  179. );
  180. } else {
  181. listFragment.setEmptyListLoadingMessage();
  182. }
  183. } else {
  184. Log.e(TAG, "OCFileListFragment is null");
  185. }
  186. }
  187. protected OCFileListFragment getListOfFilesFragment() {
  188. Fragment listOfFiles = getSupportFragmentManager().findFragmentByTag(FolderPickerActivity.TAG_LIST_OF_FOLDERS);
  189. if (listOfFiles != null) {
  190. return (OCFileListFragment) listOfFiles;
  191. }
  192. Log_OC.e(TAG, "Access to non existing list of files fragment!!");
  193. return null;
  194. }
  195. /**
  196. * {@inheritDoc}
  197. * <p>
  198. * Updates action bar and second fragment, if in dual pane mode.
  199. */
  200. @Override
  201. public void onBrowsedDownTo(OCFile directory) {
  202. setFile(directory);
  203. updateNavigationElementsInActionBar();
  204. // Sync Folder
  205. startSyncFolderOperation(directory, false);
  206. }
  207. @Override
  208. public void onSavedCertificate() {
  209. startSyncFolderOperation(getCurrentDir(), false);
  210. }
  211. public void startSyncFolderOperation(OCFile folder, boolean ignoreETag) {
  212. long currentSyncTime = System.currentTimeMillis();
  213. mSyncInProgress = true;
  214. // perform folder synchronization
  215. RemoteOperation refreshFolderOperation = new RefreshFolderOperation(folder,
  216. currentSyncTime,
  217. false,
  218. ignoreETag,
  219. getStorageManager(),
  220. getAccount(),
  221. getApplicationContext());
  222. refreshFolderOperation.execute(getAccount(), this, null, null);
  223. getListOfFilesFragment().setLoading(true);
  224. setBackgroundText();
  225. }
  226. @Override
  227. protected void onResume() {
  228. super.onResume();
  229. Log_OC.e(TAG, "onResume() start");
  230. getListOfFilesFragment().setLoading(mSyncInProgress);
  231. // refresh list of files
  232. refreshListOfFilesFragment(false);
  233. // Listen for sync messages
  234. IntentFilter syncIntentFilter = new IntentFilter(FileSyncAdapter.EVENT_FULL_SYNC_START);
  235. syncIntentFilter.addAction(FileSyncAdapter.EVENT_FULL_SYNC_END);
  236. syncIntentFilter.addAction(FileSyncAdapter.EVENT_FULL_SYNC_FOLDER_CONTENTS_SYNCED);
  237. syncIntentFilter.addAction(RefreshFolderOperation.EVENT_SINGLE_FOLDER_CONTENTS_SYNCED);
  238. syncIntentFilter.addAction(RefreshFolderOperation.EVENT_SINGLE_FOLDER_SHARES_SYNCED);
  239. mSyncBroadcastReceiver = new SyncBroadcastReceiver();
  240. localBroadcastManager.registerReceiver(mSyncBroadcastReceiver, syncIntentFilter);
  241. Log_OC.d(TAG, "onResume() end");
  242. }
  243. @Override
  244. protected void onPause() {
  245. Log_OC.e(TAG, "onPause() start");
  246. if (mSyncBroadcastReceiver != null) {
  247. localBroadcastManager.unregisterReceiver(mSyncBroadcastReceiver);
  248. mSyncBroadcastReceiver = null;
  249. }
  250. Log_OC.d(TAG, "onPause() end");
  251. super.onPause();
  252. }
  253. @Override
  254. public boolean onCreateOptionsMenu(Menu menu) {
  255. MenuInflater inflater = getMenuInflater();
  256. inflater.inflate(R.menu.activity_folder_picker, menu);
  257. return true;
  258. }
  259. @Override
  260. public boolean onOptionsItemSelected(MenuItem item) {
  261. boolean retval = true;
  262. switch (item.getItemId()) {
  263. case R.id.action_create_dir: {
  264. CreateFolderDialogFragment dialog = CreateFolderDialogFragment.newInstance(getCurrentFolder());
  265. dialog.show(getSupportFragmentManager(), CreateFolderDialogFragment.CREATE_FOLDER_FRAGMENT);
  266. break;
  267. }
  268. case android.R.id.home: {
  269. OCFile currentDir = getCurrentFolder();
  270. if (currentDir != null && currentDir.getParentId() != 0) {
  271. onBackPressed();
  272. }
  273. break;
  274. }
  275. default:
  276. retval = super.onOptionsItemSelected(item);
  277. break;
  278. }
  279. return retval;
  280. }
  281. protected OCFile getCurrentFolder() {
  282. OCFile currentFile = getFile();
  283. OCFile finalFolder = null;
  284. FileDataStorageManager storageManager = getStorageManager();
  285. // If the file is null, take the root folder to avoid any error in functions depending on this one
  286. if (currentFile != null) {
  287. if (currentFile.isFolder()) {
  288. finalFolder = currentFile;
  289. } else if (currentFile.getRemotePath() != null) {
  290. String parentPath = new File(currentFile.getRemotePath()).getParent();
  291. finalFolder = storageManager.getFileByPath(parentPath);
  292. }
  293. } else {
  294. finalFolder = storageManager.getFileByPath(OCFile.ROOT_PATH);
  295. }
  296. return finalFolder;
  297. }
  298. public void refreshListOfFilesFragment(boolean fromSearch) {
  299. OCFileListFragment fileListFragment = getListOfFilesFragment();
  300. if (fileListFragment != null) {
  301. fileListFragment.listDirectory(false, fromSearch);
  302. }
  303. }
  304. public void browseToRoot() {
  305. OCFileListFragment listOfFiles = getListOfFilesFragment();
  306. if (listOfFiles != null) { // should never be null, indeed
  307. OCFile root = getStorageManager().getFileByPath(OCFile.ROOT_PATH);
  308. listOfFiles.listDirectory(root, false, false);
  309. setFile(listOfFiles.getCurrentFile());
  310. updateNavigationElementsInActionBar();
  311. startSyncFolderOperation(root, false);
  312. }
  313. }
  314. @Override
  315. public void onBackPressed() {
  316. OCFileListFragment listOfFiles = getListOfFilesFragment();
  317. if (listOfFiles != null) { // should never be null, indeed
  318. int levelsUp = listOfFiles.onBrowseUp();
  319. if (levelsUp == 0) {
  320. finish();
  321. return;
  322. }
  323. setFile(listOfFiles.getCurrentFile());
  324. updateNavigationElementsInActionBar();
  325. }
  326. }
  327. protected void updateNavigationElementsInActionBar() {
  328. OCFile currentDir = getCurrentFolder();
  329. ActionBar actionBar = getSupportActionBar();
  330. if (actionBar != null) {
  331. boolean atRoot = currentDir == null || currentDir.getParentId() == 0;
  332. actionBar.setDisplayHomeAsUpEnabled(!atRoot);
  333. actionBar.setHomeButtonEnabled(!atRoot);
  334. ThemeToolbarUtils.tintBackButton(actionBar, this);
  335. ThemeToolbarUtils.setColoredTitle(getSupportActionBar(), atRoot ? caption : currentDir.getFileName(), this);
  336. }
  337. }
  338. /**
  339. * Set per-view controllers
  340. */
  341. private void initControls() {
  342. mCancelBtn = findViewById(R.id.folder_picker_btn_cancel);
  343. mChooseBtn = findViewById(R.id.folder_picker_btn_choose);
  344. if (mChooseBtn != null) {
  345. ThemeButtonUtils.colorPrimaryButton(mChooseBtn, this);
  346. mChooseBtn.setOnClickListener(this);
  347. }
  348. if (mCancelBtn != null) {
  349. if (this instanceof FilePickerActivity) {
  350. ThemeButtonUtils.colorPrimaryButton(mCancelBtn, this);
  351. } else {
  352. mCancelBtn.setTextColor(ThemeColorUtils.primaryColor(this, true));
  353. }
  354. mCancelBtn.setOnClickListener(this);
  355. }
  356. }
  357. @Override
  358. public void onClick(View v) {
  359. if (v.equals(mCancelBtn)) {
  360. finish();
  361. } else if (v.equals(mChooseBtn)) {
  362. Intent i = getIntent();
  363. ArrayList<Parcelable> targetFiles = i.getParcelableArrayListExtra(FolderPickerActivity.EXTRA_FILES);
  364. Intent data = new Intent();
  365. data.putExtra(EXTRA_FOLDER, getListOfFilesFragment().getCurrentFile());
  366. data.putParcelableArrayListExtra(EXTRA_FILES, targetFiles);
  367. setResult(RESULT_OK, data);
  368. finish();
  369. }
  370. }
  371. @Override
  372. public void onRemoteOperationFinish(RemoteOperation operation, RemoteOperationResult result) {
  373. super.onRemoteOperationFinish(operation, result);
  374. if (operation instanceof CreateFolderOperation) {
  375. onCreateFolderOperationFinish((CreateFolderOperation) operation, result);
  376. }
  377. }
  378. /**
  379. * Updates the view associated to the activity after the finish of an operation trying to create a new folder.
  380. *
  381. * @param operation Creation operation performed.
  382. * @param result Result of the creation.
  383. */
  384. private void onCreateFolderOperationFinish(
  385. CreateFolderOperation operation, RemoteOperationResult result
  386. ) {
  387. if (result.isSuccess()) {
  388. refreshListOfFilesFragment(false);
  389. } else {
  390. try {
  391. DisplayUtils.showSnackMessage(
  392. this, ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources())
  393. );
  394. } catch (NotFoundException e) {
  395. Log_OC.e(TAG, "Error while trying to show fail message ", e);
  396. }
  397. }
  398. }
  399. private class SyncBroadcastReceiver extends BroadcastReceiver {
  400. /**
  401. * {@link BroadcastReceiver} to enable syncing feedback in UI
  402. */
  403. @Override
  404. public void onReceive(Context context, Intent intent) {
  405. try {
  406. String event = intent.getAction();
  407. Log_OC.d(TAG, "Received broadcast " + event);
  408. String accountName = intent.getStringExtra(FileSyncAdapter.EXTRA_ACCOUNT_NAME);
  409. String syncFolderRemotePath = intent.getStringExtra(FileSyncAdapter.EXTRA_FOLDER_PATH);
  410. RemoteOperationResult syncResult = (RemoteOperationResult)
  411. DataHolderUtil.getInstance().retrieve(intent.getStringExtra(FileSyncAdapter.EXTRA_RESULT));
  412. boolean sameAccount = getAccount() != null && accountName.equals(getAccount().name)
  413. && getStorageManager() != null;
  414. if (sameAccount) {
  415. if (FileSyncAdapter.EVENT_FULL_SYNC_START.equals(event)) {
  416. mSyncInProgress = true;
  417. } else {
  418. OCFile currentFile = (getFile() == null) ? null :
  419. getStorageManager().getFileByPath(getFile().getRemotePath());
  420. OCFile currentDir = (getCurrentFolder() == null) ? null :
  421. getStorageManager().getFileByPath(getCurrentFolder().getRemotePath());
  422. if (currentDir == null) {
  423. // current folder was removed from the server
  424. DisplayUtils.showSnackMessage(getActivity(),
  425. R.string.sync_current_folder_was_removed,
  426. getCurrentFolder().getFileName());
  427. browseToRoot();
  428. } else {
  429. if (currentFile == null && !getFile().isFolder()) {
  430. // currently selected file was removed in the server, and now we know it
  431. currentFile = currentDir;
  432. }
  433. if (currentDir.getRemotePath().equals(syncFolderRemotePath)) {
  434. OCFileListFragment fileListFragment = getListOfFilesFragment();
  435. if (fileListFragment != null) {
  436. fileListFragment.listDirectory(currentDir, false, false);
  437. }
  438. }
  439. setFile(currentFile);
  440. }
  441. mSyncInProgress = (!FileSyncAdapter.EVENT_FULL_SYNC_END.equals(event) &&
  442. !RefreshFolderOperation.EVENT_SINGLE_FOLDER_SHARES_SYNCED.equals(event));
  443. if (RefreshFolderOperation.EVENT_SINGLE_FOLDER_CONTENTS_SYNCED.equals(event) &&
  444. /// TODO refactor and make common
  445. syncResult != null && !syncResult.isSuccess()) {
  446. if (ResultCode.UNAUTHORIZED.equals(syncResult.getCode()) || (syncResult.isException()
  447. && syncResult.getException() instanceof AuthenticatorException)) {
  448. requestCredentialsUpdate(context);
  449. } else if (RemoteOperationResult.ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED
  450. .equals(syncResult.getCode())) {
  451. showUntrustedCertDialog(syncResult);
  452. }
  453. }
  454. }
  455. DataHolderUtil.getInstance().delete(intent.getStringExtra(FileSyncAdapter.EXTRA_RESULT));
  456. Log_OC.d(TAG, "Setting progress visibility to " + mSyncInProgress);
  457. getListOfFilesFragment().setLoading(mSyncInProgress);
  458. setBackgroundText();
  459. }
  460. } catch (RuntimeException e) {
  461. // avoid app crashes after changing the serial id of RemoteOperationResult
  462. // in owncloud library with broadcast notifications pending to process
  463. DataHolderUtil.getInstance().delete(intent.getStringExtra(FileSyncAdapter.EXTRA_RESULT));
  464. }
  465. }
  466. }
  467. @Override
  468. public void showDetails(OCFile file) {
  469. // not used at the moment
  470. }
  471. @Override
  472. public void showDetails(OCFile file, int activeTab) {
  473. // not used at the moment
  474. }
  475. /**
  476. * {@inheritDoc}
  477. */
  478. @Override
  479. public void onTransferStateChanged(OCFile file, boolean downloading, boolean uploading) {
  480. // not used at the moment
  481. }
  482. @Override
  483. public void onRefresh() {
  484. refreshList(true);
  485. }
  486. @Override
  487. public void onRefresh(boolean enforced) {
  488. refreshList(enforced);
  489. }
  490. private void refreshList(boolean ignoreETag) {
  491. OCFileListFragment listOfFiles = getListOfFilesFragment();
  492. if (listOfFiles != null) {
  493. OCFile folder = listOfFiles.getCurrentFile();
  494. if (folder != null) {
  495. startSyncFolderOperation(folder, ignoreETag);
  496. }
  497. }
  498. }
  499. public boolean isDoNotEnterEncryptedFolder() {
  500. return mDoNotEnterEncryptedFolder;
  501. }
  502. @Override
  503. public void onSortingOrderChosen(FileSortOrder selection) {
  504. getListOfFilesFragment().sortFiles(selection);
  505. }
  506. }