use of com.amaze.filemanager.asynchronous.asynctasks.DeleteTask in project AmazeFileManager by TeamAmaze.
the class CompressedExplorerFragment method onDestroyView.
@Override
public void onDestroyView() {
super.onDestroyView();
mainActivity.supportInvalidateOptionsMenu();
if (files.get(0).exists()) {
new DeleteTask(getActivity().getContentResolver(), getActivity(), this).execute(files);
}
}
use of com.amaze.filemanager.asynchronous.asynctasks.DeleteTask in project AmazeFileManager by TeamAmaze.
the class MainActivityHelper method deleteFiles.
public void deleteFiles(ArrayList<HybridFileParcelable> files) {
if (files == null || files.size() == 0)
return;
if (files.get(0).isSmb()) {
new DeleteTask(null, mainActivity).execute((files));
return;
}
int mode = checkFolder(new File(files.get(0).getPath()).getParentFile(), mainActivity);
if (mode == 2) {
mainActivity.oparrayList = (files);
mainActivity.operation = DataUtils.DELETE;
} else if (mode == 1 || mode == 0)
new DeleteTask(null, mainActivity).execute((files));
else
Toast.makeText(mainActivity, R.string.not_allowed, Toast.LENGTH_SHORT).show();
}
use of com.amaze.filemanager.asynchronous.asynctasks.DeleteTask in project AmazeFileManager by TeamAmaze.
the class MainActivity method onActivityResult.
protected void onActivityResult(int requestCode, int responseCode, Intent 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()).commit();
} else {
/* DialogUtil.displayError(getActivity(), R.string.message_dialog_cannot_write_to_folder_saf, false, currentFolder);
||!FileUtil.isWritableNormalOrSaf(currentFolder)*/
return;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
getContentResolver().takePersistableUriPermission(treeUri, Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
}
switch(operation) {
case // deletion
DataUtils.DELETE:
new DeleteTask(null, mainActivity).execute((oparrayList));
break;
case // copying
DataUtils.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(con, 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
DataUtils.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, getCurrentMainFragment(), getCurrentMainFragment().getActivity(), OpenMode.FILE).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, oppatheList);
break;
case // mkdir
DataUtils.NEW_FOLDER:
mainActivityHelper.mkDir(RootHelper.generateBaseFile(new File(oppathe), true), getCurrentMainFragment());
break;
case DataUtils.RENAME:
MainFragment ma = getCurrentMainFragment();
mainActivityHelper.rename(ma.openMode, (oppathe), (oppathe1), mainActivity, isRootExplorer());
ma.updateList();
break;
case DataUtils.NEW_FILE:
mainActivityHelper.mkFile(new HybridFile(OpenMode.FILE, oppathe), getCurrentMainFragment());
break;
case DataUtils.EXTRACT:
mainActivityHelper.extractFile(new File(oppathe));
break;
case DataUtils.COMPRESS:
mainActivityHelper.compressFiles(new File(oppathe), oparrayList);
}
operation = -1;
} else if (requestCode == REQUEST_CODE_SAF && responseCode == Activity.RESULT_OK) {
// otg access
getPrefs().edit().putString(KEY_PREF_OTG, intent.getData().toString()).apply();
drawer.closeIfNotLocked();
if (drawer.isLocked())
drawer.onDrawerClosed();
} else if (requestCode == REQUEST_CODE_SAF && responseCode != Activity.RESULT_OK) {
// otg access not provided
drawer.resetPendingPath();
}
}
use of com.amaze.filemanager.asynchronous.asynctasks.DeleteTask in project AmazeFileManager by TeamAmaze.
the class AppsAdapter method showPopup.
private void showPopup(View v, final AppDataParcelable rowItem) {
v.setOnClickListener(view -> {
PopupMenu popupMenu = new PopupMenu(app.getActivity(), view);
popupMenu.setOnMenuItemClickListener(item -> {
int colorAccent = themedActivity.getColorPreference().getColor(ColorUsage.ACCENT);
switch(item.getItemId()) {
case R.id.open:
Intent i1 = app.getActivity().getPackageManager().getLaunchIntentForPackage(rowItem.packageName);
if (i1 != null)
app.startActivity(i1);
else
Toast.makeText(app.getActivity(), app.getResources().getString(R.string.not_allowed), Toast.LENGTH_LONG).show();
return true;
case R.id.share:
ArrayList<File> arrayList2 = new ArrayList<File>();
arrayList2.add(new File(rowItem.path));
themedActivity.getColorPreference();
FileUtils.shareFiles(arrayList2, app.getActivity(), utilsProvider.getAppTheme(), colorAccent);
return true;
case R.id.unins:
final HybridFileParcelable f1 = new HybridFileParcelable(rowItem.path);
f1.setMode(OpenMode.ROOT);
if ((Integer.valueOf(rowItem.data.substring(0, rowItem.data.indexOf("_"))) & ApplicationInfo.FLAG_SYSTEM) != 0) {
// system package
if (app.Sp.getBoolean(PreferencesConstants.PREFERENCE_ROOTMODE, false)) {
MaterialDialog.Builder builder1 = new MaterialDialog.Builder(app.getActivity());
builder1.theme(utilsProvider.getAppTheme().getMaterialDialogTheme()).content(app.getResources().getString(R.string.unin_system_apk)).title(app.getResources().getString(R.string.warning)).negativeColor(colorAccent).positiveColor(colorAccent).negativeText(app.getResources().getString(R.string.no)).positiveText(app.getResources().getString(R.string.yes)).callback(new MaterialDialog.ButtonCallback() {
@Override
public void onNegative(MaterialDialog materialDialog) {
materialDialog.cancel();
}
@Override
public void onPositive(MaterialDialog materialDialog) {
ArrayList<HybridFileParcelable> files = new ArrayList<>();
if (Build.VERSION.SDK_INT >= 21) {
String parent = f1.getParent();
if (!parent.equals("app") && !parent.equals("priv-app")) {
HybridFileParcelable baseFile = new HybridFileParcelable(f1.getParent());
baseFile.setMode(OpenMode.ROOT);
files.add(baseFile);
} else
files.add(f1);
} else {
files.add(f1);
}
new DeleteTask(app.getActivity().getContentResolver(), app.getActivity()).execute((files));
}
}).build().show();
} else {
Toast.makeText(app.getActivity(), app.getResources().getString(R.string.enablerootmde), Toast.LENGTH_SHORT).show();
}
} else {
app.unin(rowItem.packageName);
}
return true;
case R.id.play:
Intent intent1 = new Intent(Intent.ACTION_VIEW);
intent1.setData(Uri.parse("market://details?id=" + rowItem.packageName));
app.startActivity(intent1);
return true;
case R.id.properties:
app.startActivity(new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS, Uri.parse("package:" + rowItem.packageName)));
return true;
case R.id.backup:
Toast.makeText(app.getActivity(), app.getResources().getString(R.string.copyingapk) + Environment.getExternalStorageDirectory().getPath() + "/app_backup", Toast.LENGTH_LONG).show();
File f = new File(rowItem.path);
ArrayList<HybridFileParcelable> ab = new ArrayList<>();
File dst = new File(Environment.getExternalStorageDirectory().getPath() + "/app_backup");
if (!dst.exists() || !dst.isDirectory())
dst.mkdirs();
Intent intent = new Intent(app.getActivity(), CopyService.class);
HybridFileParcelable baseFile = RootHelper.generateBaseFile(f, true);
baseFile.setName(rowItem.label + "_" + rowItem.packageName.substring(rowItem.packageName.indexOf("_") + 1) + ".apk");
ab.add(baseFile);
intent.putParcelableArrayListExtra(CopyService.TAG_COPY_SOURCES, ab);
intent.putExtra(CopyService.TAG_COPY_TARGET, dst.getPath());
intent.putExtra(CopyService.TAG_COPY_OPEN_MODE, 0);
ServiceWatcherUtil.runService(app.getActivity(), intent);
return true;
}
return false;
});
popupMenu.inflate(R.menu.app_options);
popupMenu.show();
});
}
use of com.amaze.filemanager.asynchronous.asynctasks.DeleteTask in project AmazeFileManager by TeamAmaze.
the class HiddenAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(HiddenViewHolder holder, int position) {
HybridFile file = items.get(position);
holder.txtTitle.setText(file.getName());
String a = file.getReadablePath(file.getPath());
holder.txtDesc.setText(a);
if (hide) {
holder.image.setVisibility(View.GONE);
}
// TODO: move the listeners to the constructor
holder.image.setOnClickListener(view -> {
if (!file.isSmb() && file.isDirectory()) {
ArrayList<HybridFileParcelable> a1 = new ArrayList<>();
HybridFileParcelable baseFile = new HybridFileParcelable(items.get(position).getPath() + "/.nomedia");
baseFile.setMode(OpenMode.FILE);
a1.add(baseFile);
new DeleteTask(context.getActivity().getContentResolver(), c).execute((a1));
}
dataUtils.removeHiddenFile(items.get(position).getPath());
items.remove(items.get(position));
notifyDataSetChanged();
});
holder.row.setOnClickListener(view -> {
materialDialog.dismiss();
new Thread(() -> {
if (file.isDirectory()) {
context.getActivity().runOnUiThread(() -> {
context.loadlist(file.getPath(), false, OpenMode.UNKNOWN);
});
} else {
if (!file.isSmb()) {
context.getActivity().runOnUiThread(() -> {
FileUtils.openFile(new File(file.getPath()), (MainActivity) context.getActivity(), sharedPrefs);
});
}
}
}).start();
});
}
Aggregations