use of com.amaze.filemanager.file_operations.filesystem.OperationTypeKt.EXTRACT in project AmazeFileManager by TeamAmaze.
the class MainActivity method onActivityResult.
protected void onActivityResult(int requestCode, int responseCode, Intent intent) {
super.onActivityResult(requestCode, responseCode, intent);
if (requestCode == Drawer.image_selector_request_code) {
drawer.onActivityResult(requestCode, responseCode, intent);
} else if (requestCode == 3) {
Uri treeUri;
if (responseCode == Activity.RESULT_OK) {
// Get Uri from Storage Access Framework.
treeUri = intent.getData();
// Persist URI - this is required for verification of writability.
if (treeUri != null)
getPrefs().edit().putString(PreferencesConstants.PREFERENCE_URI, treeUri.toString()).apply();
} else {
/* DialogUtil.displayError(getActivity(), R.string.message_dialog_cannot_write_to_folder_saf, false, currentFolder);
||!FileUtil.isWritableNormalOrSaf(currentFolder)*/
return;
}
if (SDK_INT >= KITKAT) {
getContentResolver().takePersistableUriPermission(treeUri, Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
}
executeWithMainFragment(mainFragment -> {
switch(operation) {
case // deletion
DELETE:
new DeleteTask(mainActivity).execute((oparrayList));
break;
case // copying
COPY:
// legacy compatibility
if (oparrayList != null && oparrayList.size() != 0) {
oparrayListList = new ArrayList<>();
oparrayListList.add(oparrayList);
oparrayList = null;
oppatheList = new ArrayList<>();
oppatheList.add(oppathe);
oppathe = "";
}
for (int i = 0; i < oparrayListList.size(); i++) {
ArrayList<HybridFileParcelable> sourceList = oparrayListList.get(i);
Intent intent1 = new Intent(this, CopyService.class);
intent1.putExtra(CopyService.TAG_COPY_SOURCES, sourceList);
intent1.putExtra(CopyService.TAG_COPY_TARGET, oppatheList.get(i));
ServiceWatcherUtil.runService(this, intent1);
}
break;
case // moving
MOVE:
// legacy compatibility
if (oparrayList != null && oparrayList.size() != 0) {
oparrayListList = new ArrayList<>();
oparrayListList.add(oparrayList);
oparrayList = null;
oppatheList = new ArrayList<>();
oppatheList.add(oppathe);
oppathe = "";
}
new MoveFiles(oparrayListList, isRootExplorer(), mainFragment.getCurrentPath(), mainFragment.getActivity(), OpenMode.FILE).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, oppatheList);
break;
case // mkdir
NEW_FOLDER:
mainActivityHelper.mkDir(new HybridFile(OpenMode.FILE, oppathe), RootHelper.generateBaseFile(new File(oppathe), true), mainFragment);
break;
case RENAME:
mainActivityHelper.rename(mainFragment.getMainFragmentViewModel().getOpenMode(), (oppathe), (oppathe1), null, false, mainActivity, isRootExplorer());
mainFragment.updateList();
break;
case NEW_FILE:
mainActivityHelper.mkFile(new HybridFile(OpenMode.FILE, oppathe), new HybridFile(OpenMode.FILE, oppathe), mainFragment);
break;
case EXTRACT:
mainActivityHelper.extractFile(new File(oppathe));
break;
case COMPRESS:
mainActivityHelper.compressFiles(new File(oppathe), oparrayList);
break;
case SAVE_FILE:
FileUtil.writeUriToStorage(this, urisToBeSaved, getContentResolver(), mainFragment.getCurrentPath());
urisToBeSaved = null;
finish();
break;
default:
LogHelper.logOnProductionOrCrash(TAG, "Incorrect value for switch");
}
return null;
}, true);
operation = UNDEFINED;
} else if (requestCode == REQUEST_CODE_SAF) {
executeWithMainFragment(mainFragment -> {
if (responseCode == Activity.RESULT_OK && intent.getData() != null) {
// otg access
Uri usbOtgRoot = intent.getData();
SingletonUsbOtg.getInstance().setUsbOtgRoot(usbOtgRoot);
mainFragment.loadlist(OTGUtil.PREFIX_OTG, false, OpenMode.OTG);
drawer.closeIfNotLocked();
if (drawer.isLocked())
drawer.onDrawerClosed();
} else if (requestCode == REQUEST_CODE_SAF_FTP) {
FtpServerFragment ftpServerFragment = (FtpServerFragment) getFragmentAtFrame();
ftpServerFragment.changeFTPServerPath(intent.getData().toString());
Toast.makeText(this, R.string.ftp_path_change_success, Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(this, R.string.error, Toast.LENGTH_SHORT).show();
// otg access not provided
drawer.resetPendingPath();
}
return null;
}, true);
}
}
Aggregations