Search in sources :

Example 1 with FtpServerFragment

use of com.amaze.filemanager.ui.fragments.FtpServerFragment in project AmazeFileManager by TeamAmaze.

the class MainActivity method onPrepareOptionsMenu.

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    MenuItem s = menu.findItem(R.id.view);
    MenuItem search = menu.findItem(R.id.search);
    Fragment fragment = getFragmentAtFrame();
    if (fragment instanceof TabFragment) {
        appbar.setTitle(R.string.appbar_name);
        if (getBoolean(PREFERENCE_VIEW)) {
            s.setTitle(getResources().getString(R.string.gridview));
        } else {
            s.setTitle(getResources().getString(R.string.listview));
        }
        try {
            executeWithMainFragment(mainFragment -> {
                if (mainFragment.getMainFragmentViewModel().isList()) {
                    s.setTitle(R.string.gridview);
                } else {
                    s.setTitle(R.string.listview);
                }
                appbar.getBottomBar().updatePath(mainFragment.getCurrentPath(), mainFragment.getMainFragmentViewModel().getResults(), MainActivityHelper.SEARCH_TEXT, mainFragment.getMainFragmentViewModel().getOpenMode(), mainFragment.getMainFragmentViewModel().getFolderCount(), mainFragment.getMainFragmentViewModel().getFileCount(), mainFragment);
                return null;
            });
        } catch (Exception e) {
            e.printStackTrace();
        }
        appbar.getBottomBar().setClickListener();
        search.setVisible(true);
        if (indicator_layout != null)
            indicator_layout.setVisibility(View.VISIBLE);
        menu.findItem(R.id.search).setVisible(true);
        menu.findItem(R.id.home).setVisible(true);
        menu.findItem(R.id.history).setVisible(true);
        menu.findItem(R.id.sethome).setVisible(true);
        menu.findItem(R.id.sort).setVisible(true);
        menu.findItem(R.id.hiddenitems).setVisible(true);
        menu.findItem(R.id.view).setVisible(true);
        menu.findItem(R.id.extract).setVisible(false);
        invalidatePasteSnackbar(true);
        findViewById(R.id.buttonbarframe).setVisibility(View.VISIBLE);
    } else if (fragment instanceof AppsListFragment || fragment instanceof ProcessViewerFragment || fragment instanceof FtpServerFragment) {
        appBarLayout.setExpanded(true);
        menu.findItem(R.id.sethome).setVisible(false);
        if (indicator_layout != null)
            indicator_layout.setVisibility(View.GONE);
        findViewById(R.id.buttonbarframe).setVisibility(View.GONE);
        menu.findItem(R.id.search).setVisible(false);
        menu.findItem(R.id.home).setVisible(false);
        menu.findItem(R.id.history).setVisible(false);
        menu.findItem(R.id.extract).setVisible(false);
        if (fragment instanceof ProcessViewerFragment) {
            menu.findItem(R.id.sort).setVisible(false);
        } else if (fragment instanceof FtpServerFragment) {
            menu.findItem(R.id.sort).setVisible(false);
        } else {
            menu.findItem(R.id.dsort).setVisible(false);
            menu.findItem(R.id.sortby).setVisible(false);
        }
        menu.findItem(R.id.hiddenitems).setVisible(false);
        menu.findItem(R.id.view).setVisible(false);
        invalidatePasteSnackbar(false);
    } else if (fragment instanceof CompressedExplorerFragment) {
        appbar.setTitle(R.string.appbar_name);
        menu.findItem(R.id.sethome).setVisible(false);
        if (indicator_layout != null)
            indicator_layout.setVisibility(View.GONE);
        getAppbar().getBottomBar().resetClickListener();
        menu.findItem(R.id.search).setVisible(false);
        menu.findItem(R.id.home).setVisible(false);
        menu.findItem(R.id.history).setVisible(false);
        menu.findItem(R.id.sort).setVisible(false);
        menu.findItem(R.id.hiddenitems).setVisible(false);
        menu.findItem(R.id.view).setVisible(false);
        menu.findItem(R.id.extract).setVisible(true);
        invalidatePasteSnackbar(false);
    }
    return super.onPrepareOptionsMenu(menu);
}
Also used : AppsListFragment(com.amaze.filemanager.ui.fragments.AppsListFragment) CompressedExplorerFragment(com.amaze.filemanager.ui.fragments.CompressedExplorerFragment) MenuItem(android.view.MenuItem) TabFragment(com.amaze.filemanager.ui.fragments.TabFragment) ProcessViewerFragment(com.amaze.filemanager.ui.fragments.ProcessViewerFragment) Fragment(androidx.fragment.app.Fragment) CompressedExplorerFragment(com.amaze.filemanager.ui.fragments.CompressedExplorerFragment) CloudSheetFragment(com.amaze.filemanager.ui.fragments.CloudSheetFragment) SearchWorkerFragment(com.amaze.filemanager.ui.fragments.SearchWorkerFragment) TabFragment(com.amaze.filemanager.ui.fragments.TabFragment) FtpServerFragment(com.amaze.filemanager.ui.fragments.FtpServerFragment) MainFragment(com.amaze.filemanager.ui.fragments.MainFragment) ProcessViewerFragment(com.amaze.filemanager.ui.fragments.ProcessViewerFragment) AppsListFragment(com.amaze.filemanager.ui.fragments.AppsListFragment) BottomSheetDialogFragment(com.google.android.material.bottomsheet.BottomSheetDialogFragment) CloudPluginException(com.amaze.filemanager.file_operations.exceptions.CloudPluginException) FtpServerFragment(com.amaze.filemanager.ui.fragments.FtpServerFragment)

Example 2 with FtpServerFragment

use of com.amaze.filemanager.ui.fragments.FtpServerFragment in project AmazeFileManager by TeamAmaze.

the class MainActivity method onFolderSelection.

/**
 * Invoke {@link FtpServerFragment#changeFTPServerPath(String)} to change FTP server share path.
 *
 * @see FtpServerFragment#changeFTPServerPath(String)
 * @see FolderChooserDialog
 * @see com.afollestad.materialdialogs.folderselector.FolderChooserDialog.FolderCallback
 * @param dialog
 * @param folder selected folder
 */
@Override
public void onFolderSelection(@NonNull FolderChooserDialog dialog, @NonNull File folder) {
    switch(dialog.getTag()) {
        case FtpServerFragment.TAG:
            FtpServerFragment ftpServerFragment = (FtpServerFragment) getFragmentAtFrame();
            if (folder.exists() && folder.isDirectory()) {
                ftpServerFragment.changeFTPServerPath(folder.getPath());
                Toast.makeText(this, R.string.ftp_path_change_success, Toast.LENGTH_SHORT).show();
            } else {
                // try to get parent
                File pathParentFile = new File(folder.getParent());
                if (pathParentFile.exists() && pathParentFile.isDirectory()) {
                    ftpServerFragment.changeFTPServerPath(pathParentFile.getPath());
                    Toast.makeText(this, R.string.ftp_path_change_success, Toast.LENGTH_SHORT).show();
                } else {
                    // don't have access, print error
                    Toast.makeText(this, R.string.ftp_path_change_error_invalid, Toast.LENGTH_SHORT).show();
                }
            }
            dialog.dismiss();
            break;
        default:
            dialog.dismiss();
            break;
    }
}
Also used : File(java.io.File) HybridFile(com.amaze.filemanager.filesystem.HybridFile) FtpServerFragment(com.amaze.filemanager.ui.fragments.FtpServerFragment)

Example 3 with FtpServerFragment

use of com.amaze.filemanager.ui.fragments.FtpServerFragment in project AmazeFileManager by TeamAmaze.

the class Drawer method refreshDrawer.

public void refreshDrawer() {
    Menu menu = navView.getMenu();
    menu.clear();
    actionViewStateManager.deselectCurrentActionView();
    int order = 0;
    ArrayList<StorageDirectoryParcelable> storageDirectories = mainActivity.getStorageDirectories();
    ArrayList<String> storageDirectoryPaths = new ArrayList<>();
    phoneStorageCount = 0;
    for (StorageDirectoryParcelable storageDirectory : storageDirectories) {
        String file = storageDirectory.path;
        File f = new File(file);
        String name = storageDirectory.name;
        int icon = storageDirectory.iconRes;
        storageDirectoryPaths.add(file);
        if (file.contains(OTGUtil.PREFIX_OTG) || file.startsWith(OTGUtil.PREFIX_MEDIA_REMOVABLE)) {
            addNewItem(menu, STORAGES_GROUP, order++, "OTG", new MenuMetadata(file), R.drawable.ic_usb_white_24dp, R.drawable.ic_show_chart_black_24dp);
            continue;
        }
        if (f.isDirectory() || f.canExecute()) {
            addNewItem(menu, STORAGES_GROUP, order++, name, new MenuMetadata(file), icon, R.drawable.ic_show_chart_black_24dp);
            if (phoneStorageCount == 0)
                firstPath = file;
            else if (phoneStorageCount == 1)
                secondPath = file;
            phoneStorageCount++;
        }
    }
    dataUtils.setStorages(storageDirectoryPaths);
    if (dataUtils.getServers().size() > 0) {
        Collections.sort(dataUtils.getServers(), new BookSorter());
        synchronized (dataUtils.getServers()) {
            for (String[] file : dataUtils.getServers()) {
                addNewItem(menu, SERVERS_GROUP, order++, file[0], new MenuMetadata(file[1]), R.drawable.ic_settings_remote_white_24dp, R.drawable.ic_edit_24dp);
            }
        }
    }
    ArrayList<String[]> accountAuthenticationList = new ArrayList<>();
    if (CloudSheetFragment.isCloudProviderAvailable(mainActivity)) {
        for (CloudStorage cloudStorage : dataUtils.getAccounts()) {
            @DrawableRes int deleteIcon = R.drawable.ic_delete_grey_24dp;
            if (cloudStorage instanceof Dropbox) {
                addNewItem(menu, CLOUDS_GROUP, order++, CloudHandler.CLOUD_NAME_DROPBOX, new MenuMetadata(CloudHandler.CLOUD_PREFIX_DROPBOX + "/"), R.drawable.ic_dropbox_white_24dp, deleteIcon);
                accountAuthenticationList.add(new String[] { CloudHandler.CLOUD_NAME_DROPBOX, CloudHandler.CLOUD_PREFIX_DROPBOX + "/" });
            } else if (cloudStorage instanceof Box) {
                addNewItem(menu, CLOUDS_GROUP, order++, CloudHandler.CLOUD_NAME_BOX, new MenuMetadata(CloudHandler.CLOUD_PREFIX_BOX + "/"), R.drawable.ic_box_white_24dp, deleteIcon);
                accountAuthenticationList.add(new String[] { CloudHandler.CLOUD_NAME_BOX, CloudHandler.CLOUD_PREFIX_BOX + "/" });
            } else if (cloudStorage instanceof OneDrive) {
                addNewItem(menu, CLOUDS_GROUP, order++, CloudHandler.CLOUD_NAME_ONE_DRIVE, new MenuMetadata(CloudHandler.CLOUD_PREFIX_ONE_DRIVE + "/"), R.drawable.ic_onedrive_white_24dp, deleteIcon);
                accountAuthenticationList.add(new String[] { CloudHandler.CLOUD_NAME_ONE_DRIVE, CloudHandler.CLOUD_PREFIX_ONE_DRIVE + "/" });
            } else if (cloudStorage instanceof GoogleDrive) {
                addNewItem(menu, CLOUDS_GROUP, order++, CloudHandler.CLOUD_NAME_GOOGLE_DRIVE, new MenuMetadata(CloudHandler.CLOUD_PREFIX_GOOGLE_DRIVE + "/"), R.drawable.ic_google_drive_white_24dp, deleteIcon);
                accountAuthenticationList.add(new String[] { CloudHandler.CLOUD_NAME_GOOGLE_DRIVE, CloudHandler.CLOUD_PREFIX_GOOGLE_DRIVE + "/" });
            }
        }
        Collections.sort(accountAuthenticationList, new BookSorter());
    }
    if (mainActivity.getBoolean(PREFERENCE_SHOW_SIDEBAR_FOLDERS)) {
        if (dataUtils.getBooks().size() > 0) {
            Collections.sort(dataUtils.getBooks(), new BookSorter());
            synchronized (dataUtils.getBooks()) {
                for (String[] file : dataUtils.getBooks()) {
                    addNewItem(menu, FOLDERS_GROUP, order++, file[0], new MenuMetadata(file[1]), R.drawable.ic_folder_white_24dp, R.drawable.ic_edit_24dp);
                }
            }
        }
    }
    Boolean[] quickAccessPref = TinyDB.getBooleanArray(mainActivity.getPrefs(), QuickAccessPref.KEY, QuickAccessPref.Companion.getDEFAULT());
    if (mainActivity.getBoolean(PREFERENCE_SHOW_SIDEBAR_QUICKACCESSES)) {
        if (quickAccessPref[0]) {
            addNewItem(menu, QUICKACCESSES_GROUP, order++, R.string.quick, new MenuMetadata("5"), R.drawable.ic_star_white_24dp, null);
        }
        if (quickAccessPref[1]) {
            addNewItem(menu, QUICKACCESSES_GROUP, order++, R.string.recent, new MenuMetadata("6"), R.drawable.ic_history_white_24dp, null);
        }
        if (quickAccessPref[2]) {
            addNewItem(menu, QUICKACCESSES_GROUP, order++, R.string.images, new MenuMetadata("0"), R.drawable.ic_photo_library_white_24dp, null);
        }
        if (quickAccessPref[3]) {
            addNewItem(menu, QUICKACCESSES_GROUP, order++, R.string.videos, new MenuMetadata("1"), R.drawable.ic_video_library_white_24dp, null);
        }
        if (quickAccessPref[4]) {
            addNewItem(menu, QUICKACCESSES_GROUP, order++, R.string.audio, new MenuMetadata("2"), R.drawable.ic_library_music_white_24dp, null);
        }
        if (quickAccessPref[5]) {
            addNewItem(menu, QUICKACCESSES_GROUP, order++, R.string.documents, new MenuMetadata("3"), R.drawable.ic_library_books_white_24dp, null);
        }
        if (quickAccessPref[6]) {
            addNewItem(menu, QUICKACCESSES_GROUP, order++, R.string.apks, new MenuMetadata("4"), R.drawable.ic_apk_library_white_24dp, null);
        }
    }
    addNewItem(menu, LASTGROUP, order++, R.string.ftp, new MenuMetadata(() -> {
        FragmentTransaction transaction2 = mainActivity.getSupportFragmentManager().beginTransaction();
        transaction2.replace(R.id.content_frame, new FtpServerFragment());
        mainActivity.getAppbar().getAppbarLayout().animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)).start();
        pending_fragmentTransaction = transaction2;
        if (!isDrawerLocked)
            close();
        else
            onDrawerClosed();
    }), R.drawable.ic_ftp_white_24dp, null);
    addNewItem(menu, LASTGROUP, order++, R.string.apps, new MenuMetadata(() -> {
        FragmentTransaction transaction2 = mainActivity.getSupportFragmentManager().beginTransaction();
        transaction2.replace(R.id.content_frame, new AppsListFragment());
        mainActivity.getAppbar().getAppbarLayout().animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)).start();
        pending_fragmentTransaction = transaction2;
        if (!isDrawerLocked)
            close();
        else
            onDrawerClosed();
    }), R.drawable.ic_android_white_24dp, null);
    addNewItem(menu, LASTGROUP, order++, R.string.setting, new MenuMetadata(() -> {
        Intent in = new Intent(mainActivity, PreferencesActivity.class);
        mainActivity.startActivity(in);
        mainActivity.finish();
    }), R.drawable.ic_settings_white_24dp, null);
    for (int i = 0; i < navView.getMenu().size(); i++) {
        navView.getMenu().getItem(i).setEnabled(true);
    }
    for (int group : GROUPS) {
        menu.setGroupCheckable(group, true, true);
    }
    MenuItem item = navView.getSelected();
    if (item != null) {
        item.setChecked(true);
        actionViewStateManager.selectActionView(item);
    }
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) PreferencesActivity(com.amaze.filemanager.ui.activities.PreferencesActivity) ArrayList(java.util.ArrayList) GoogleDrive(com.cloudrail.si.services.GoogleDrive) FtpServerFragment(com.amaze.filemanager.ui.fragments.FtpServerFragment) CloudStorage(com.cloudrail.si.interfaces.CloudStorage) OneDrive(com.cloudrail.si.services.OneDrive) FragmentTransaction(androidx.fragment.app.FragmentTransaction) BookSorter(com.amaze.filemanager.utils.BookSorter) Menu(android.view.Menu) Dropbox(com.cloudrail.si.services.Dropbox) DrawableRes(androidx.annotation.DrawableRes) Box(com.cloudrail.si.services.Box) Intent(android.content.Intent) MenuItem(android.view.MenuItem) StorageDirectoryParcelable(com.amaze.filemanager.adapters.data.StorageDirectoryParcelable) AppsListFragment(com.amaze.filemanager.ui.fragments.AppsListFragment) HybridFile(com.amaze.filemanager.filesystem.HybridFile) File(java.io.File)

Example 4 with FtpServerFragment

use of com.amaze.filemanager.ui.fragments.FtpServerFragment 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);
    }
}
Also used : CursorLoader(androidx.loader.content.CursorLoader) AppBar(com.amaze.filemanager.ui.views.appbar.AppBar) MOVE(com.amaze.filemanager.file_operations.filesystem.OperationTypeKt.MOVE) Bundle(android.os.Bundle) SingletonUsbOtg(com.amaze.filemanager.file_operations.filesystem.usb.SingletonUsbOtg) NonNull(androidx.annotation.NonNull) ARG_ADDRESS(com.amaze.filemanager.ui.dialogs.SftpConnectDialog.ARG_ADDRESS) Completable(io.reactivex.Completable) Uri(android.net.Uri) ColorDrawable(android.graphics.drawable.ColorDrawable) CloudEntry(com.amaze.filemanager.database.models.explorer.CloudEntry) SDK_INT(android.os.Build.VERSION.SDK_INT) ARG_KEYPAIR_NAME(com.amaze.filemanager.ui.dialogs.SftpConnectDialog.ARG_KEYPAIR_NAME) StorageDirectoryParcelable(com.amaze.filemanager.adapters.data.StorageDirectoryParcelable) UNDEFINED(com.amaze.filemanager.file_operations.filesystem.OperationTypeKt.UNDEFINED) PREFERENCE_NEED_TO_SET_HOME(com.amaze.filemanager.ui.fragments.preference_fragments.PreferencesConstants.PREFERENCE_NEED_TO_SET_HOME) Handler(android.os.Handler) Shell(eu.chainfire.libsuperuser.Shell) Fragment(androidx.fragment.app.Fragment) Function(androidx.arch.core.util.Function) TargetApi(android.annotation.TargetApi) Log(android.util.Log) M(android.os.Build.VERSION_CODES.M) SAVE_FILE(com.amaze.filemanager.file_operations.filesystem.OperationTypeKt.SAVE_FILE) SshConnectionPool(com.amaze.filemanager.filesystem.ssh.SshConnectionPool) CoordinatorLayout(androidx.coordinatorlayout.widget.CoordinatorLayout) GeneralDialogCreation(com.amaze.filemanager.ui.dialogs.GeneralDialogCreation) N(android.os.Build.VERSION_CODES.N) RENAME(com.amaze.filemanager.file_operations.filesystem.OperationTypeKt.RENAME) CompletableObserver(io.reactivex.CompletableObserver) IntentFilter(android.content.IntentFilter) LogHelper(com.amaze.filemanager.LogHelper) StorageNamingHelper(com.amaze.filemanager.ui.strings.StorageNamingHelper) ARG_USERNAME(com.amaze.filemanager.ui.dialogs.SftpConnectDialog.ARG_USERNAME) FileUtils(com.amaze.filemanager.filesystem.files.FileUtils) NEW_FILE(com.amaze.filemanager.file_operations.filesystem.OperationTypeKt.NEW_FILE) JELLY_BEAN_MR2(android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) IdRes(androidx.annotation.IdRes) StringRes(androidx.annotation.StringRes) JELLY_BEAN_MR1(android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) Nullable(androidx.annotation.Nullable) StorageNaming(com.amaze.filemanager.file_operations.filesystem.StorageNaming) SmbConnectionListener(com.amaze.filemanager.ui.dialogs.SmbConnectDialog.SmbConnectionListener) DELETE(com.amaze.filemanager.file_operations.filesystem.OperationTypeKt.DELETE) R(com.amaze.filemanager.R) AppConfig(com.amaze.filemanager.application.AppConfig) PermissionsActivity(com.amaze.filemanager.ui.activities.superclasses.PermissionsActivity) SftpConnectDialog(com.amaze.filemanager.ui.dialogs.SftpConnectDialog) Environment(android.os.Environment) CompressedExplorerFragment(com.amaze.filemanager.ui.fragments.CompressedExplorerFragment) BaseTransientBottomBar(com.google.android.material.snackbar.BaseTransientBottomBar) CloudLoaderAsyncTask(com.amaze.filemanager.asynchronous.asynctasks.CloudLoaderAsyncTask) CloudSheetFragment(com.amaze.filemanager.ui.fragments.CloudSheetFragment) ArrayList(java.util.ArrayList) TagsHelper(com.amaze.filemanager.TagsHelper) TileService(android.service.quicksettings.TileService) RenameBookmark(com.amaze.filemanager.ui.dialogs.RenameBookmark) StorageVolume(android.os.storage.StorageVolume) MainActivityHelper(com.amaze.filemanager.utils.MainActivityHelper) ARG_PORT(com.amaze.filemanager.ui.dialogs.SftpConnectDialog.ARG_PORT) PreferencesConstants(com.amaze.filemanager.ui.fragments.preference_fragments.PreferencesConstants) MenuInflater(android.view.MenuInflater) SearchWorkerFragment(com.amaze.filemanager.ui.fragments.SearchWorkerFragment) DataUtils(com.amaze.filemanager.utils.DataUtils) PreferenceUtils(com.amaze.filemanager.utils.PreferenceUtils) Toast(android.widget.Toast) Menu(android.view.Menu) TabFragment(com.amaze.filemanager.ui.fragments.TabFragment) Loader(androidx.loader.content.Loader) DeleteTask(com.amaze.filemanager.asynchronous.asynctasks.DeleteTask) StorageManager(android.os.storage.StorageManager) PREFERENCE_COLORED_NAVIGATION(com.amaze.filemanager.ui.fragments.preference_fragments.PreferencesConstants.PREFERENCE_COLORED_NAVIGATION) ARG_NAME(com.amaze.filemanager.ui.dialogs.SftpConnectDialog.ARG_NAME) TextUtils(android.text.TextUtils) File(java.io.File) EXTRACT(com.amaze.filemanager.file_operations.filesystem.OperationTypeKt.EXTRACT) MainActivityActionMode(com.amaze.filemanager.utils.MainActivityActionMode) Utils(com.amaze.filemanager.utils.Utils) FtpServerFragment(com.amaze.filemanager.ui.fragments.FtpServerFragment) ARG_DEFAULT_PATH(com.amaze.filemanager.ui.dialogs.SftpConnectDialog.ARG_DEFAULT_PATH) RingtoneManager(android.media.RingtoneManager) Configuration(android.content.res.Configuration) CloudConnectionCallbacks(com.amaze.filemanager.ui.fragments.CloudSheetFragment.CloudConnectionCallbacks) SaveOnDataUtilsChange(com.amaze.filemanager.asynchronous.SaveOnDataUtilsChange) TabFragmentBottomDragListener(com.amaze.filemanager.ui.drag.TabFragmentBottomDragListener) RequiresApi(androidx.annotation.RequiresApi) KITKAT(android.os.Build.VERSION_CODES.KITKAT) BookSorter(com.amaze.filemanager.utils.BookSorter) SpeedDialView(com.leinardi.android.speeddial.SpeedDialView) DrawableRes(androidx.annotation.DrawableRes) MainFragment(com.amaze.filemanager.ui.fragments.MainFragment) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) AppBarLayout(com.google.android.material.appbar.AppBarLayout) LOLLIPOP(android.os.Build.VERSION_CODES.LOLLIPOP) SortHandler(com.amaze.filemanager.database.SortHandler) RootHelper(com.amaze.filemanager.filesystem.RootHelper) Drawer(com.amaze.filemanager.ui.views.drawer.Drawer) CopyService(com.amaze.filemanager.asynchronous.services.CopyService) SpeedDialOverlayLayout(com.leinardi.android.speeddial.SpeedDialOverlayLayout) ContentResolver(android.content.ContentResolver) CloudContract(com.amaze.filemanager.database.CloudContract) ARG_PASSWORD(com.amaze.filemanager.ui.dialogs.SftpConnectDialog.ARG_PASSWORD) PasteHelper(com.amaze.filemanager.filesystem.PasteHelper) View(android.view.View) Schedulers(io.reactivex.schedulers.Schedulers) CustomZoomFocusChange(com.amaze.filemanager.ui.views.CustomZoomFocusChange) UsbManager(android.hardware.usb.UsbManager) SmbConnectDialog(com.amaze.filemanager.ui.dialogs.SmbConnectDialog) OTGUtil(com.amaze.filemanager.utils.OTGUtil) AsyncTask(android.os.AsyncTask) ProcessViewerFragment(com.amaze.filemanager.ui.fragments.ProcessViewerFragment) MakeFileOperation(com.amaze.filemanager.filesystem.MakeFileOperation) FragmentTransaction(androidx.fragment.app.FragmentTransaction) BroadcastReceiver(android.content.BroadcastReceiver) List(java.util.List) CloudRail(com.cloudrail.si.CloudRail) Disposable(io.reactivex.disposables.Disposable) FabWithLabelView(com.leinardi.android.speeddial.FabWithLabelView) CloudHandler(com.amaze.filemanager.database.CloudHandler) Pattern(java.util.regex.Pattern) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) Snackbar(com.google.android.material.snackbar.Snackbar) KITKAT_WATCH(android.os.Build.VERSION_CODES.KITKAT_WATCH) DecelerateInterpolator(android.view.animation.DecelerateInterpolator) ServiceWatcherUtil(com.amaze.filemanager.asynchronous.management.ServiceWatcherUtil) Context(android.content.Context) KeyEvent(android.view.KeyEvent) HybridFile(com.amaze.filemanager.filesystem.HybridFile) UtilsHandler(com.amaze.filemanager.database.UtilsHandler) COMPRESS(com.amaze.filemanager.file_operations.filesystem.OperationTypeKt.COMPRESS) Intent(android.content.Intent) FolderChooserDialog(com.afollestad.materialdialogs.folderselector.FolderChooserDialog) TabHandler(com.amaze.filemanager.database.TabHandler) LoaderManager(androidx.loader.app.LoaderManager) OpenMode(com.amaze.filemanager.file_operations.filesystem.OpenMode) AppConstants(com.amaze.filemanager.utils.AppConstants) MenuItem(android.view.MenuItem) HybridFileParcelable(com.amaze.filemanager.filesystem.HybridFileParcelable) OperationData(com.amaze.filemanager.database.models.OperationData) UsbOtgRepresentation(com.amaze.filemanager.file_operations.filesystem.usb.UsbOtgRepresentation) COPY(com.amaze.filemanager.file_operations.filesystem.OperationTypeKt.COPY) SystemBarTintManager(com.readystatesoftware.systembartint.SystemBarTintManager) WeakReference(java.lang.ref.WeakReference) Build(android.os.Build) AppsListFragment(com.amaze.filemanager.ui.fragments.AppsListFragment) Cursor(android.database.Cursor) WRITABLE_OR_ON_SDCARD(com.amaze.filemanager.file_operations.filesystem.FolderStateKt.WRITABLE_OR_ON_SDCARD) ExternalSdCardOperation(com.amaze.filemanager.filesystem.ExternalSdCardOperation) PREFERENCE_VIEW(com.amaze.filemanager.ui.fragments.preference_fragments.PreferencesConstants.PREFERENCE_VIEW) ARG_EDIT(com.amaze.filemanager.ui.dialogs.SftpConnectDialog.ARG_EDIT) NEW_FOLDER(com.amaze.filemanager.file_operations.filesystem.OperationTypeKt.NEW_FOLDER) DialogAction(com.afollestad.materialdialogs.DialogAction) REQUEST_CODE_SAF_FTP(com.amaze.filemanager.ui.fragments.FtpServerFragment.REQUEST_CODE_SAF_FTP) BookmarkCallback(com.amaze.filemanager.ui.dialogs.RenameBookmark.BookmarkCallback) ARG_HAS_PASSWORD(com.amaze.filemanager.ui.dialogs.SftpConnectDialog.ARG_HAS_PASSWORD) Color(android.graphics.Color) MoveFiles(com.amaze.filemanager.asynchronous.asynctasks.MoveFiles) SpeedDialActionItem(com.leinardi.android.speeddial.SpeedDialActionItem) BottomSheetDialogFragment(com.google.android.material.bottomsheet.BottomSheetDialogFragment) HandlerThread(android.os.HandlerThread) CloudPluginException(com.amaze.filemanager.file_operations.exceptions.CloudPluginException) Collections(java.util.Collections) Activity(android.app.Activity) PREFERENCE_BOOKMARKS_ADDED(com.amaze.filemanager.ui.fragments.preference_fragments.PreferencesConstants.PREFERENCE_BOOKMARKS_ADDED) FileUtil(com.amaze.filemanager.filesystem.FileUtil) ContentUris(android.content.ContentUris) HybridFile(com.amaze.filemanager.filesystem.HybridFile) ArrayList(java.util.ArrayList) Intent(android.content.Intent) MoveFiles(com.amaze.filemanager.asynchronous.asynctasks.MoveFiles) Uri(android.net.Uri) CopyService(com.amaze.filemanager.asynchronous.services.CopyService) File(java.io.File) HybridFile(com.amaze.filemanager.filesystem.HybridFile) DeleteTask(com.amaze.filemanager.asynchronous.asynctasks.DeleteTask) FtpServerFragment(com.amaze.filemanager.ui.fragments.FtpServerFragment)

Example 5 with FtpServerFragment

use of com.amaze.filemanager.ui.fragments.FtpServerFragment in project AmazeFileManager by TeamAmaze.

the class MainActivity method invalidateFragmentAndBundle.

private void invalidateFragmentAndBundle(Bundle savedInstanceState) {
    if (savedInstanceState == null) {
        if (openProcesses) {
            FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
            transaction.replace(R.id.content_frame, new ProcessViewerFragment(), KEY_INTENT_PROCESS_VIEWER);
            // transaction.addToBackStack(null);
            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) || INTENT_ACTION_OPEN_FTP_SERVER.equals(intent.getAction()))) {
            // 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.deselectEverything();
            transaction2.commit();
        } else if (intent.getAction() != null && INTENT_ACTION_OPEN_APP_MANAGER.equals(intent.getAction())) {
            FragmentTransaction transaction3 = getSupportFragmentManager().beginTransaction();
            transaction3.replace(R.id.content_frame, new AppsListFragment());
            appBarLayout.animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)).start();
            drawer.deselectEverything();
            transaction3.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);
        int selectedStorage = savedInstanceState.getInt(KEY_DRAWER_SELECTED, 0);
        getDrawer().selectCorrectDrawerItem(selectedStorage);
    }
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) HybridFile(com.amaze.filemanager.filesystem.HybridFile) FragmentTransaction(androidx.fragment.app.FragmentTransaction) AppsListFragment(com.amaze.filemanager.ui.fragments.AppsListFragment) ProcessViewerFragment(com.amaze.filemanager.ui.fragments.ProcessViewerFragment) File(java.io.File) HybridFile(com.amaze.filemanager.filesystem.HybridFile) FtpServerFragment(com.amaze.filemanager.ui.fragments.FtpServerFragment)

Aggregations

FtpServerFragment (com.amaze.filemanager.ui.fragments.FtpServerFragment)5 HybridFile (com.amaze.filemanager.filesystem.HybridFile)4 AppsListFragment (com.amaze.filemanager.ui.fragments.AppsListFragment)4 File (java.io.File)4 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)3 FragmentTransaction (androidx.fragment.app.FragmentTransaction)3 ProcessViewerFragment (com.amaze.filemanager.ui.fragments.ProcessViewerFragment)3 Intent (android.content.Intent)2 MenuItem (android.view.MenuItem)2 TargetApi (android.annotation.TargetApi)1 Activity (android.app.Activity)1 BroadcastReceiver (android.content.BroadcastReceiver)1 ContentResolver (android.content.ContentResolver)1 ContentUris (android.content.ContentUris)1 Context (android.content.Context)1 IntentFilter (android.content.IntentFilter)1 Configuration (android.content.res.Configuration)1 Cursor (android.database.Cursor)1 Color (android.graphics.Color)1 ColorDrawable (android.graphics.drawable.ColorDrawable)1