Search in sources :

Example 1 with CompressedExplorerFragment

use of com.amaze.filemanager.ui.fragments.CompressedExplorerFragment 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 CompressedExplorerFragment

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

the class MainActivity method onOptionsItemSelected.

// called when the user exits the action mode
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // ActionBarDrawerToggle will take care of this.
    if (drawer.onOptionsItemSelected(item))
        return true;
    // If they have handled the options, we don't need to.
    if (getFragmentAtFrame().onOptionsItemSelected(item))
        return true;
    // Handle action buttons
    executeWithMainFragment(mainFragment -> {
        switch(item.getItemId()) {
            case R.id.home:
                mainFragment.home();
                break;
            case R.id.history:
                GeneralDialogCreation.showHistoryDialog(dataUtils, getPrefs(), mainFragment, getAppTheme());
                break;
            case R.id.sethome:
                if (mainFragment.getMainFragmentViewModel().getOpenMode() != OpenMode.FILE && mainFragment.getMainFragmentViewModel().getOpenMode() != OpenMode.ROOT) {
                    Toast.makeText(mainActivity, R.string.not_allowed, Toast.LENGTH_SHORT).show();
                    break;
                }
                final MaterialDialog dialog = GeneralDialogCreation.showBasicDialog(mainActivity, R.string.question_set_path_as_home, R.string.set_as_home, R.string.yes, R.string.no);
                dialog.getActionButton(DialogAction.POSITIVE).setOnClickListener((v) -> {
                    mainFragment.getMainFragmentViewModel().setHome(mainFragment.getCurrentPath());
                    updatePaths(mainFragment.getMainFragmentViewModel().getNo());
                    dialog.dismiss();
                });
                dialog.show();
                break;
            case R.id.exit:
                finish();
                break;
            case R.id.sortby:
                GeneralDialogCreation.showSortDialog(mainFragment, getAppTheme(), getPrefs());
                break;
            case R.id.dsort:
                String[] sort = getResources().getStringArray(R.array.directorysortmode);
                MaterialDialog.Builder builder = new MaterialDialog.Builder(mainActivity);
                builder.theme(getAppTheme().getMaterialDialogTheme());
                builder.title(R.string.directorysort);
                int current = Integer.parseInt(getPrefs().getString(PreferencesConstants.PREFERENCE_DIRECTORY_SORT_MODE, "0"));
                builder.items(sort).itemsCallbackSingleChoice(current, (dialog1, view, which, text) -> {
                    getPrefs().edit().putString(PreferencesConstants.PREFERENCE_DIRECTORY_SORT_MODE, "" + which).commit();
                    mainFragment.getMainFragmentViewModel().initSortModes(SortHandler.getSortType(this, mainFragment.getMainFragmentViewModel().getCurrentPath()), getPrefs());
                    mainFragment.updateList();
                    dialog1.dismiss();
                    return true;
                });
                builder.build().show();
                break;
            case R.id.hiddenitems:
                GeneralDialogCreation.showHiddenDialog(dataUtils, getPrefs(), mainFragment, getAppTheme());
                break;
            case R.id.view:
                int pathLayout = dataUtils.getListOrGridForPath(mainFragment.getCurrentPath(), DataUtils.LIST);
                if (mainFragment.getMainFragmentViewModel().isList()) {
                    if (pathLayout == DataUtils.LIST) {
                        AppConfig.getInstance().runInBackground(() -> {
                            utilsHandler.removeFromDatabase(new OperationData(UtilsHandler.Operation.LIST, mainFragment.getCurrentPath()));
                        });
                    }
                    utilsHandler.saveToDatabase(new OperationData(UtilsHandler.Operation.GRID, mainFragment.getCurrentPath()));
                    dataUtils.setPathAsGridOrList(mainFragment.getCurrentPath(), DataUtils.GRID);
                } else {
                    if (pathLayout == DataUtils.GRID) {
                        AppConfig.getInstance().runInBackground(() -> {
                            utilsHandler.removeFromDatabase(new OperationData(UtilsHandler.Operation.GRID, mainFragment.getCurrentPath()));
                        });
                    }
                    utilsHandler.saveToDatabase(new OperationData(UtilsHandler.Operation.LIST, mainFragment.getCurrentPath()));
                    dataUtils.setPathAsGridOrList(mainFragment.getCurrentPath(), DataUtils.LIST);
                }
                mainFragment.switchView();
                break;
            case R.id.extract:
                Fragment fragment1 = getFragmentAtFrame();
                if (fragment1 instanceof CompressedExplorerFragment) {
                    mainActivityHelper.extractFile(((CompressedExplorerFragment) fragment1).compressedFile);
                }
                break;
            case R.id.search:
                getAppbar().getSearchView().revealSearchView();
                break;
        }
        return null;
    }, false);
    return super.onOptionsItemSelected(item);
}
Also used : OperationData(com.amaze.filemanager.database.models.OperationData) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) CompressedExplorerFragment(com.amaze.filemanager.ui.fragments.CompressedExplorerFragment) 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)

Example 3 with CompressedExplorerFragment

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

the class MainActivity method openCompressed.

public void openCompressed(String path) {
    appBarLayout.animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)).start();
    FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
    fragmentTransaction.setCustomAnimations(R.anim.slide_in_top, R.anim.slide_in_bottom);
    Fragment zipFragment = new CompressedExplorerFragment();
    Bundle bundle = new Bundle();
    bundle.putString(CompressedExplorerFragment.KEY_PATH, path);
    zipFragment.setArguments(bundle);
    fragmentTransaction.add(R.id.content_frame, zipFragment);
    fragmentTransaction.commitAllowingStateLoss();
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) FragmentTransaction(androidx.fragment.app.FragmentTransaction) CompressedExplorerFragment(com.amaze.filemanager.ui.fragments.CompressedExplorerFragment) Bundle(android.os.Bundle) 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)

Aggregations

Fragment (androidx.fragment.app.Fragment)3 AppsListFragment (com.amaze.filemanager.ui.fragments.AppsListFragment)3 CloudSheetFragment (com.amaze.filemanager.ui.fragments.CloudSheetFragment)3 CompressedExplorerFragment (com.amaze.filemanager.ui.fragments.CompressedExplorerFragment)3 FtpServerFragment (com.amaze.filemanager.ui.fragments.FtpServerFragment)3 MainFragment (com.amaze.filemanager.ui.fragments.MainFragment)3 ProcessViewerFragment (com.amaze.filemanager.ui.fragments.ProcessViewerFragment)3 SearchWorkerFragment (com.amaze.filemanager.ui.fragments.SearchWorkerFragment)3 TabFragment (com.amaze.filemanager.ui.fragments.TabFragment)3 BottomSheetDialogFragment (com.google.android.material.bottomsheet.BottomSheetDialogFragment)3 Bundle (android.os.Bundle)1 MenuItem (android.view.MenuItem)1 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)1 FragmentTransaction (androidx.fragment.app.FragmentTransaction)1 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)1 OperationData (com.amaze.filemanager.database.models.OperationData)1 CloudPluginException (com.amaze.filemanager.file_operations.exceptions.CloudPluginException)1