Search in sources :

Example 1 with TabFragment

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

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

the class MainActivity method goToMain.

public void goToMain(String path) {
    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    // title.setText(R.string.app_name);
    TabFragment tabFragment = new TabFragment();
    if (intent != null && intent.getAction() != null) {
        if (INTENT_ACTION_OPEN_QUICK_ACCESS.equals(intent.getAction())) {
            path = "5";
        } else if (INTENT_ACTION_OPEN_RECENT.equals(intent.getAction())) {
            path = "6";
        }
    }
    if (path != null && path.length() > 0) {
        Bundle b = new Bundle();
        b.putString("path", path);
        tabFragment.setArguments(b);
    }
    transaction.replace(R.id.content_frame, tabFragment);
    // Commit the transaction
    transaction.addToBackStack("tabt" + 1);
    transaction.commitAllowingStateLoss();
    appbar.setTitle(null);
    floatingActionButton.show();
    if (openzip && zippath != null) {
        openCompressed(zippath);
        zippath = null;
    }
}
Also used : FragmentTransaction(androidx.fragment.app.FragmentTransaction) Bundle(android.os.Bundle) TabFragment(com.amaze.filemanager.ui.fragments.TabFragment)

Example 3 with TabFragment

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

the class MainActivity method onPermissionGranted.

@Override
public void onPermissionGranted() {
    drawer.refreshDrawer();
    TabFragment tabFragment = getTabFragment();
    boolean b = getBoolean(PREFERENCE_NEED_TO_SET_HOME);
    // reset home and current paths according to new storages
    if (b) {
        TabHandler tabHandler = TabHandler.getInstance();
        tabHandler.clear().subscribe(() -> {
            if (tabFragment != null) {
                tabFragment.refactorDrawerStorages(false);
                Fragment main = tabFragment.getFragmentAtIndex(0);
                if (main != null)
                    ((MainFragment) main).updateTabWithDb(tabHandler.findTab(1));
                Fragment main1 = tabFragment.getFragmentAtIndex(1);
                if (main1 != null)
                    ((MainFragment) main1).updateTabWithDb(tabHandler.findTab(2));
            }
            getPrefs().edit().putBoolean(PREFERENCE_NEED_TO_SET_HOME, false).commit();
        });
    } else {
        // just refresh list
        if (tabFragment != null) {
            Fragment main = tabFragment.getFragmentAtIndex(0);
            if (main != null)
                ((MainFragment) main).updateList();
            Fragment main1 = tabFragment.getFragmentAtIndex(1);
            if (main1 != null)
                ((MainFragment) main1).updateList();
        }
    }
}
Also used : TabFragment(com.amaze.filemanager.ui.fragments.TabFragment) TabHandler(com.amaze.filemanager.database.TabHandler) 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 4 with TabFragment

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

the class MainActivity method initLeftRightAndTopDragListeners.

private void initLeftRightAndTopDragListeners(boolean destroy, boolean shouldInvokeLeftAndRight) {
    TabFragment tabFragment = getTabFragment();
    tabFragment.initLeftRightAndTopDragListeners(destroy, shouldInvokeLeftAndRight);
}
Also used : TabFragment(com.amaze.filemanager.ui.fragments.TabFragment)

Example 5 with TabFragment

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

the class MainActivityHelper method search.

/**
 * Creates a fragment which will handle the search AsyncTask {@link SearchWorkerFragment}
 *
 * @param query the text query entered the by user
 */
public void search(SharedPreferences sharedPrefs, String query) {
    TabFragment tabFragment = mainActivity.getTabFragment();
    if (tabFragment == null) {
        Log.w(getClass().getSimpleName(), "Failed to search: tab fragment not available");
        return;
    }
    final MainFragment ma = (MainFragment) tabFragment.getCurrentTabFragment();
    if (ma == null || ma.getMainFragmentViewModel() == null) {
        Log.w(getClass().getSimpleName(), "Failed to search: main fragment not available");
        return;
    }
    final String fpath = ma.getCurrentPath();
    /*SearchTask task = new SearchTask(ma.searchHelper, ma, query);
    task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, fpath);*/
    // ma.searchTask = task;
    SEARCH_TEXT = query;
    FragmentManager fm = mainActivity.getSupportFragmentManager();
    SearchWorkerFragment fragment = (SearchWorkerFragment) fm.findFragmentByTag(MainActivity.TAG_ASYNC_HELPER);
    if (fragment != null) {
        if (fragment.searchAsyncTask.getStatus() == AsyncTask.Status.RUNNING) {
            fragment.searchAsyncTask.cancel(true);
        }
        fm.beginTransaction().remove(fragment).commit();
    }
    addSearchFragment(fm, new SearchWorkerFragment(), fpath, query, ma.getMainFragmentViewModel().getOpenMode(), mainActivity.isRootExplorer(), sharedPrefs.getBoolean(SearchWorkerFragment.KEY_REGEX, false), sharedPrefs.getBoolean(SearchWorkerFragment.KEY_REGEX_MATCHES, false));
}
Also used : FragmentManager(androidx.fragment.app.FragmentManager) MainFragment(com.amaze.filemanager.ui.fragments.MainFragment) TabFragment(com.amaze.filemanager.ui.fragments.TabFragment) SearchWorkerFragment(com.amaze.filemanager.ui.fragments.SearchWorkerFragment)

Aggregations

TabFragment (com.amaze.filemanager.ui.fragments.TabFragment)5 MainFragment (com.amaze.filemanager.ui.fragments.MainFragment)3 SearchWorkerFragment (com.amaze.filemanager.ui.fragments.SearchWorkerFragment)3 Fragment (androidx.fragment.app.Fragment)2 AppsListFragment (com.amaze.filemanager.ui.fragments.AppsListFragment)2 CloudSheetFragment (com.amaze.filemanager.ui.fragments.CloudSheetFragment)2 CompressedExplorerFragment (com.amaze.filemanager.ui.fragments.CompressedExplorerFragment)2 FtpServerFragment (com.amaze.filemanager.ui.fragments.FtpServerFragment)2 ProcessViewerFragment (com.amaze.filemanager.ui.fragments.ProcessViewerFragment)2 BottomSheetDialogFragment (com.google.android.material.bottomsheet.BottomSheetDialogFragment)2 Bundle (android.os.Bundle)1 MenuItem (android.view.MenuItem)1 FragmentManager (androidx.fragment.app.FragmentManager)1 FragmentTransaction (androidx.fragment.app.FragmentTransaction)1 TabHandler (com.amaze.filemanager.database.TabHandler)1 CloudPluginException (com.amaze.filemanager.file_operations.exceptions.CloudPluginException)1