use of com.amaze.filemanager.filesystem.PasteHelper in project AmazeFileManager by TeamAmaze.
the class MainActivity method onCreate.
/**
* Called when the activity is first created.
*/
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
initialisePreferences();
initializeInteractiveShell();
dataUtils.registerOnDataChangedListener(this);
CustomSshJConfig.init();
AppConfig.setActivityContext(con);
setContentView(R.layout.main_toolbar);
appbar = new AppBar(this, getPrefs(), queue -> {
if (!queue.isEmpty()) {
mainActivityHelper.search(getPrefs(), queue);
}
});
initialiseViews();
tabHandler = new TabHandler(this);
utilsHandler = AppConfig.getInstance().getUtilsHandler();
cloudHandler = new CloudHandler(this);
mainActivityHelper = new MainActivityHelper(this);
// TODO: 7/12/2017 not init when actionIntent != null
initialiseFab();
if (CloudSheetFragment.isCloudProviderAvailable(this)) {
getSupportLoaderManager().initLoader(REQUEST_CODE_CLOUD_LIST_KEYS, null, this);
}
path = getIntent().getStringExtra("path");
openProcesses = getIntent().getBooleanExtra(KEY_INTENT_PROCESS_VIEWER, false);
intent = getIntent();
if (intent.getStringArrayListExtra(TAG_INTENT_FILTER_FAILED_OPS) != null) {
ArrayList<HybridFileParcelable> failedOps = intent.getParcelableArrayListExtra(TAG_INTENT_FILTER_FAILED_OPS);
if (failedOps != null) {
mainActivityHelper.showFailedOperationDialog(failedOps, this);
}
}
checkForExternalIntent(intent);
if (savedInstanceState != null) {
drawer.setSomethingSelected(savedInstanceState.getBoolean(KEY_DRAWER_SELECTED));
}
// setting window background color instead of each item, in order to reduce pixel overdraw
if (getAppTheme().equals(AppTheme.LIGHT)) {
/*if(Main.IS_LIST)
getWindow().setBackgroundDrawableResource(android.R.color.white);
else
getWindow().setBackgroundDrawableResource(R.color.grid_background_light);
*/
getWindow().setBackgroundDrawableResource(android.R.color.white);
} else if (getAppTheme().equals(AppTheme.BLACK)) {
getWindow().setBackgroundDrawableResource(android.R.color.black);
} else {
getWindow().setBackgroundDrawableResource(R.color.holo_dark_background);
}
/*findViewById(R.id.drawer_buttton).setOnClickListener(new ImageView.OnClickListener() {
@Override
public void onClick(View view) {
if (mDrawerLayout.isOpen(mDrawerLinear)) {
mDrawerLayout.close(mDrawerLinear);
} else mDrawerLayout.openDrawer(mDrawerLinear);
}
});*/
drawer.setDrawerIndicatorEnabled();
// recents header color implementation
if (SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription("Amaze", ((BitmapDrawable) getResources().getDrawable(R.mipmap.ic_launcher)).getBitmap(), getColorPreference().getColor(ColorUsage.getPrimary(MainActivity.currentTab)));
setTaskDescription(taskDescription);
}
if (!getBoolean(PREFERENCE_BOOKMARKS_ADDED)) {
utilsHandler.addCommonBookmarks();
getPrefs().edit().putBoolean(PREFERENCE_BOOKMARKS_ADDED, true).commit();
}
AppConfig.runInBackground(new AppConfig.CustomAsyncCallbacks() {
@Override
public <E> E doInBackground() {
dataUtils.setHiddenFiles(utilsHandler.getHiddenFilesConcurrentRadixTree());
dataUtils.setHistory(utilsHandler.getHistoryLinkedList());
dataUtils.setGridfiles(utilsHandler.getGridViewList());
dataUtils.setListfiles(utilsHandler.getListViewList());
dataUtils.setBooks(utilsHandler.getBookmarksList());
ArrayList<String[]> servers = new ArrayList<String[]>();
servers.addAll(utilsHandler.getSmbList());
servers.addAll(utilsHandler.getSftpList());
dataUtils.setServers(servers);
return null;
}
@Override
public Void onPostExecute(Object result) {
drawer.refreshDrawer();
if (savedInstanceState == null) {
if (openProcesses) {
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.content_frame, new ProcessViewerFragment(), KEY_INTENT_PROCESS_VIEWER);
// transaction.addToBackStack(null);
drawer.setSomethingSelected(true);
openProcesses = false;
// title.setText(utils.getString(con, R.string.process_viewer));
// Commit the transaction
transaction.commit();
supportInvalidateOptionsMenu();
} else if (intent.getAction() != null && intent.getAction().equals(TileService.ACTION_QS_TILE_PREFERENCES)) {
// tile preferences, open ftp fragment
FragmentTransaction transaction2 = getSupportFragmentManager().beginTransaction();
transaction2.replace(R.id.content_frame, new FTPServerFragment());
appBarLayout.animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)).start();
drawer.setSomethingSelected(true);
drawer.deselectEverything();
transaction2.commit();
} else {
if (path != null && path.length() > 0) {
HybridFile file = new HybridFile(OpenMode.UNKNOWN, path);
file.generateMode(MainActivity.this);
if (file.isDirectory(MainActivity.this))
goToMain(path);
else {
goToMain(null);
FileUtils.openFile(new File(path), MainActivity.this, getPrefs());
}
} else {
goToMain(null);
}
}
} else {
pasteHelper = savedInstanceState.getParcelable(PASTEHELPER_BUNDLE);
oppathe = savedInstanceState.getString(KEY_OPERATION_PATH);
oppathe1 = savedInstanceState.getString(KEY_OPERATED_ON_PATH);
oparrayList = savedInstanceState.getParcelableArrayList(KEY_OPERATIONS_PATH_LIST);
operation = savedInstanceState.getInt(KEY_OPERATION);
// mainFragment = (Main) savedInstanceState.getParcelable("main_fragment");
}
return null;
}
@Override
public Void onPreExecute() {
return null;
}
@Override
public Void publishResult(Object... result) {
return null;
}
@Override
public <T> T[] params() {
return null;
}
});
}
use of com.amaze.filemanager.filesystem.PasteHelper 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;
}
Aggregations