use of com.amaze.filemanager.adapters.data.LayoutElementParcelable in project AmazeFileManager by TeamAmaze.
the class ItemPopupMenu method onMenuItemClick.
@Override
public boolean onMenuItemClick(MenuItem item) {
switch(item.getItemId()) {
case R.id.about:
GeneralDialogCreation.showPropertiesDialogWithPermissions((rowItem).generateBaseFile(), rowItem.permissions, (ThemedActivity) mainFragment.getActivity(), mainActivity.isRootExplorer(), utilitiesProvider.getAppTheme());
/*
PropertiesSheet propertiesSheet = new PropertiesSheet();
Bundle arguments = new Bundle();
arguments.putParcelable(PropertiesSheet.KEY_FILE, rowItem.generateBaseFile());
arguments.putString(PropertiesSheet.KEY_PERMISSION, rowItem.getPermissions());
arguments.putBoolean(PropertiesSheet.KEY_ROOT, ThemedActivity.rootMode);
propertiesSheet.setArguments(arguments);
propertiesSheet.show(main.getFragmentManager(), PropertiesSheet.TAG_FRAGMENT);
*/
return true;
case R.id.share:
switch(rowItem.getMode()) {
case DROPBOX:
case BOX:
case GDRIVE:
case ONEDRIVE:
FileUtils.shareCloudFile(rowItem.desc, rowItem.getMode(), context);
break;
default:
ArrayList<File> arrayList = new ArrayList<>();
arrayList.add(new File(rowItem.desc));
FileUtils.shareFiles(arrayList, mainFragment.getMainActivity(), utilitiesProvider.getAppTheme(), accentColor);
break;
}
return true;
case R.id.rename:
mainFragment.rename(rowItem.generateBaseFile());
return true;
case R.id.cpy:
case R.id.cut:
{
int op = item.getItemId() == R.id.cpy ? PasteHelper.OPERATION_COPY : PasteHelper.OPERATION_CUT;
PasteHelper pasteHelper = new PasteHelper(op, new HybridFileParcelable[] { rowItem.generateBaseFile() });
mainFragment.getMainActivity().setPaste(pasteHelper);
return true;
}
case R.id.ex:
mainFragment.getMainActivity().mainActivityHelper.extractFile(new File(rowItem.desc));
return true;
case R.id.book:
DataUtils dataUtils = DataUtils.getInstance();
dataUtils.addBook(new String[] { rowItem.title, rowItem.desc }, true);
mainFragment.getMainActivity().getDrawer().refreshDrawer();
Toast.makeText(mainFragment.getActivity(), mainFragment.getResources().getString(R.string.bookmarksadded), Toast.LENGTH_LONG).show();
return true;
case R.id.delete:
ArrayList<LayoutElementParcelable> positions = new ArrayList<>();
positions.add(rowItem);
GeneralDialogCreation.deleteFilesDialog(context, mainFragment.getElementsList(), mainFragment.getMainActivity(), positions, utilitiesProvider.getAppTheme());
return true;
case R.id.open_with:
boolean useNewStack = sharedPrefs.getBoolean(PreferencesConstants.PREFERENCE_TEXTEDITOR_NEWSTACK, false);
FileUtils.openWith(new File(rowItem.desc), mainFragment.getActivity(), useNewStack);
return true;
case R.id.encrypt:
final Intent encryptIntent = new Intent(context, EncryptService.class);
encryptIntent.putExtra(EncryptService.TAG_OPEN_MODE, rowItem.getMode().ordinal());
encryptIntent.putExtra(EncryptService.TAG_SOURCE, rowItem.generateBaseFile());
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
final EncryptDecryptUtils.EncryptButtonCallbackInterface encryptButtonCallbackInterfaceAuthenticate = new EncryptDecryptUtils.EncryptButtonCallbackInterface() {
@Override
public void onButtonPressed(Intent intent) {
}
@Override
public void onButtonPressed(Intent intent, String password) throws Exception {
EncryptDecryptUtils.startEncryption(context, rowItem.generateBaseFile().getPath(), password, intent);
}
};
EncryptDecryptUtils.EncryptButtonCallbackInterface encryptButtonCallbackInterface = new EncryptDecryptUtils.EncryptButtonCallbackInterface() {
@Override
public void onButtonPressed(Intent intent) throws Exception {
// check if a master password or fingerprint is set
if (!preferences.getString(PreferencesConstants.PREFERENCE_CRYPT_MASTER_PASSWORD, PreferencesConstants.PREFERENCE_CRYPT_MASTER_PASSWORD_DEFAULT).equals("")) {
EncryptDecryptUtils.startEncryption(context, rowItem.generateBaseFile().getPath(), PreferencesConstants.ENCRYPT_PASSWORD_MASTER, encryptIntent);
} else if (preferences.getBoolean(PreferencesConstants.PREFERENCE_CRYPT_FINGERPRINT, PreferencesConstants.PREFERENCE_CRYPT_FINGERPRINT_DEFAULT)) {
EncryptDecryptUtils.startEncryption(context, rowItem.generateBaseFile().getPath(), PreferencesConstants.ENCRYPT_PASSWORD_FINGERPRINT, encryptIntent);
} else {
// let's ask a password from user
GeneralDialogCreation.showEncryptAuthenticateDialog(context, encryptIntent, mainFragment.getMainActivity(), utilitiesProvider.getAppTheme(), encryptButtonCallbackInterfaceAuthenticate);
}
}
@Override
public void onButtonPressed(Intent intent, String password) {
}
};
if (preferences.getBoolean(PreferencesConstants.PREFERENCE_CRYPT_WARNING_REMEMBER, PreferencesConstants.PREFERENCE_CRYPT_WARNING_REMEMBER_DEFAULT)) {
// let's skip warning dialog call
try {
encryptButtonCallbackInterface.onButtonPressed(encryptIntent);
} catch (Exception e) {
e.printStackTrace();
Toast.makeText(context, mainFragment.getResources().getString(R.string.crypt_encryption_fail), Toast.LENGTH_LONG).show();
}
} else {
GeneralDialogCreation.showEncryptWarningDialog(encryptIntent, mainFragment, utilitiesProvider.getAppTheme(), encryptButtonCallbackInterface);
}
return true;
case R.id.decrypt:
EncryptDecryptUtils.decryptFile(context, mainActivity, mainFragment, mainFragment.openMode, rowItem.generateBaseFile(), rowItem.generateBaseFile().getParent(context), utilitiesProvider, false);
return true;
case R.id.return_select:
mainFragment.returnIntentResults(rowItem.generateBaseFile());
return true;
}
return false;
}
use of com.amaze.filemanager.adapters.data.LayoutElementParcelable in project AmazeFileManager by TeamAmaze.
the class MainFragment method addSearchResult.
// adds search results based on result boolean. If false, the adapter is initialised with initial
// values, if true, new values are added to the adapter.
public void addSearchResult(HybridFileParcelable a, String query) {
if (listView != null) {
// initially clearing the array for new result set
if (!results) {
LIST_ELEMENTS.clear();
file_count = 0;
folder_count = 0;
}
// adding new value to LIST_ELEMENTS
LayoutElementParcelable layoutElementAdded = addTo(a);
if (!results) {
reloadListElements(false, false, !IS_LIST);
getMainActivity().getAppbar().getBottomBar().setPathText("");
getMainActivity().getAppbar().getBottomBar().setFullPathText(getString(R.string.searching, query));
results = true;
} else {
adapter.addItem(layoutElementAdded);
}
stopAnimation();
}
}
use of com.amaze.filemanager.adapters.data.LayoutElementParcelable in project AmazeFileManager by TeamAmaze.
the class MainFragment method addToSmb.
public ArrayList<LayoutElementParcelable> addToSmb(SmbFile[] mFile, String path) throws SmbException {
ArrayList<LayoutElementParcelable> a = new ArrayList<>();
if (searchHelper.size() > 500)
searchHelper.clear();
for (SmbFile aMFile : mFile) {
if (dataUtils.isFileHidden(aMFile.getPath()))
continue;
String name = aMFile.getName();
name = (aMFile.isDirectory() && name.endsWith("/")) ? name.substring(0, name.length() - 1) : name;
if (path.equals(smbPath)) {
if (name.endsWith("$"))
continue;
}
if (aMFile.isDirectory()) {
folder_count++;
LayoutElementParcelable layoutElement = new LayoutElementParcelable(name, aMFile.getPath(), "", "", "", 0, false, aMFile.lastModified() + "", true, getBoolean(PREFERENCE_SHOW_THUMB));
layoutElement.setMode(OpenMode.SMB);
searchHelper.add(layoutElement.generateBaseFile());
a.add(layoutElement);
} else {
file_count++;
try {
LayoutElementParcelable layoutElement = new LayoutElementParcelable(name, aMFile.getPath(), "", "", Formatter.formatFileSize(getContext(), aMFile.length()), aMFile.length(), false, aMFile.lastModified() + "", false, getBoolean(PREFERENCE_SHOW_THUMB));
layoutElement.setMode(OpenMode.SMB);
searchHelper.add(layoutElement.generateBaseFile());
a.add(layoutElement);
} catch (Exception e) {
e.printStackTrace();
}
}
}
return a;
}
Aggregations