Search in sources :

Example 1 with TabFragment

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

the class MainActivity method onRequestPermissionsResult.

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
    if (requestCode == 77) {
        if (grantResults.length == 1 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
            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.clear();
                if (drawer.getStorageCount() > 1) {
                    tabHandler.addTab(new Tab(1, drawer.getSecondPath(), "/"));
                } else {
                    tabHandler.addTab(new Tab(1, "/", "/"));
                }
                if (drawer.getFirstPath() != null) {
                    String pa = drawer.getFirstPath();
                    tabHandler.addTab(new Tab(2, pa, pa));
                } else {
                    tabHandler.addTab(new Tab(2, drawer.getSecondPath(), "/"));
                }
                if (tabFragment != null) {
                    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();
                }
            }
        } else {
            Toast.makeText(this, R.string.grantfailed, Toast.LENGTH_SHORT).show();
            requestStoragePermission();
        }
    }
}
Also used : Tab(com.amaze.filemanager.database.models.Tab) TabFragment(com.amaze.filemanager.fragments.TabFragment) Fragment(android.support.v4.app.Fragment) FTPServerFragment(com.amaze.filemanager.fragments.FTPServerFragment) CompressedExplorerFragment(com.amaze.filemanager.fragments.CompressedExplorerFragment) AppsListFragment(com.amaze.filemanager.fragments.AppsListFragment) ProcessViewerFragment(com.amaze.filemanager.fragments.ProcessViewerFragment) TabFragment(com.amaze.filemanager.fragments.TabFragment) MainFragment(com.amaze.filemanager.fragments.MainFragment) SearchWorkerFragment(com.amaze.filemanager.fragments.SearchWorkerFragment) CloudSheetFragment(com.amaze.filemanager.fragments.CloudSheetFragment)

Example 2 with TabFragment

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

the class MainActivity method goToMain.

public void goToMain(String path) {
    android.support.v4.app.FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    // title.setText(R.string.app_name);
    TabFragment tabFragment = new TabFragment();
    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
    drawer.setSomethingSelected(true);
    transaction.addToBackStack("tabt" + 1);
    transaction.commitAllowingStateLoss();
    appbar.setTitle(null);
    floatingActionButton.setVisibility(View.VISIBLE);
    floatingActionButton.getMenuButton().show();
    if (openzip && zippath != null) {
        if (zippath.endsWith(".zip") || zippath.endsWith(".apk"))
            openZip(zippath);
        else {
            openRar(zippath);
        }
        zippath = null;
    }
}
Also used : Bundle(android.os.Bundle) TabFragment(com.amaze.filemanager.fragments.TabFragment) FragmentTransaction(android.support.v4.app.FragmentTransaction)

Example 3 with TabFragment

use of com.amaze.filemanager.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);
    MenuItem paste = menu.findItem(R.id.paste);
    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 {
            MainFragment ma = getCurrentMainFragment();
            if (ma.IS_LIST)
                s.setTitle(R.string.gridview);
            else
                s.setTitle(R.string.listview);
            appbar.getBottomBar().updatePath(ma.getCurrentPath(), ma.results, MainActivityHelper.SEARCH_TEXT, ma.openMode, ma.folder_count, ma.file_count, ma);
        } catch (Exception e) {
        }
        appbar.getBottomBar().setClickListener();
        invalidatePasteButton(paste);
        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);
        if (getBoolean(PREFERENCE_SHOW_HIDDENFILES))
            menu.findItem(R.id.hiddenitems).setVisible(true);
        menu.findItem(R.id.view).setVisible(true);
        menu.findItem(R.id.extract).setVisible(false);
        invalidatePasteButton(menu.findItem(R.id.paste));
        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 {
            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);
        menu.findItem(R.id.paste).setVisible(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.paste).setVisible(false);
        menu.findItem(R.id.extract).setVisible(true);
    }
    return super.onPrepareOptionsMenu(menu);
}
Also used : MainFragment(com.amaze.filemanager.fragments.MainFragment) AppsListFragment(com.amaze.filemanager.fragments.AppsListFragment) CompressedExplorerFragment(com.amaze.filemanager.fragments.CompressedExplorerFragment) FTPServerFragment(com.amaze.filemanager.fragments.FTPServerFragment) MenuItem(android.view.MenuItem) TabFragment(com.amaze.filemanager.fragments.TabFragment) ProcessViewerFragment(com.amaze.filemanager.fragments.ProcessViewerFragment) Fragment(android.support.v4.app.Fragment) FTPServerFragment(com.amaze.filemanager.fragments.FTPServerFragment) CompressedExplorerFragment(com.amaze.filemanager.fragments.CompressedExplorerFragment) AppsListFragment(com.amaze.filemanager.fragments.AppsListFragment) ProcessViewerFragment(com.amaze.filemanager.fragments.ProcessViewerFragment) TabFragment(com.amaze.filemanager.fragments.TabFragment) MainFragment(com.amaze.filemanager.fragments.MainFragment) SearchWorkerFragment(com.amaze.filemanager.fragments.SearchWorkerFragment) CloudSheetFragment(com.amaze.filemanager.fragments.CloudSheetFragment) ParseException(com.cloudrail.si.exceptions.ParseException) CloudPluginException(com.amaze.filemanager.exceptions.CloudPluginException) AuthenticationException(com.cloudrail.si.exceptions.AuthenticationException)

Example 4 with TabFragment

use of com.amaze.filemanager.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)
        return;
    final MainFragment ma = (MainFragment) tabFragment.getCurrentTabFragment();
    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;
    mainActivity.mainFragment = (MainFragment) mainActivity.getTabFragment().getCurrentTabFragment();
    FragmentManager fm = mainActivity.getSupportFragmentManager();
    SearchWorkerFragment fragment = (SearchWorkerFragment) fm.findFragmentByTag(MainActivity.TAG_ASYNC_HELPER);
    if (fragment != null) {
        if (fragment.mSearchAsyncTask.getStatus() == AsyncTask.Status.RUNNING) {
            fragment.mSearchAsyncTask.cancel(true);
        }
        fm.beginTransaction().remove(fragment).commit();
    }
    addSearchFragment(fm, new SearchWorkerFragment(), fpath, query, ma.openMode, mainActivity.isRootExplorer(), sharedPrefs.getBoolean(SearchWorkerFragment.KEY_REGEX, false), sharedPrefs.getBoolean(SearchWorkerFragment.KEY_REGEX_MATCHES, false));
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) MainFragment(com.amaze.filemanager.fragments.MainFragment) TabFragment(com.amaze.filemanager.fragments.TabFragment) SearchWorkerFragment(com.amaze.filemanager.fragments.SearchWorkerFragment)

Aggregations

TabFragment (com.amaze.filemanager.fragments.TabFragment)4 MainFragment (com.amaze.filemanager.fragments.MainFragment)3 SearchWorkerFragment (com.amaze.filemanager.fragments.SearchWorkerFragment)3 Fragment (android.support.v4.app.Fragment)2 AppsListFragment (com.amaze.filemanager.fragments.AppsListFragment)2 CloudSheetFragment (com.amaze.filemanager.fragments.CloudSheetFragment)2 CompressedExplorerFragment (com.amaze.filemanager.fragments.CompressedExplorerFragment)2 FTPServerFragment (com.amaze.filemanager.fragments.FTPServerFragment)2 ProcessViewerFragment (com.amaze.filemanager.fragments.ProcessViewerFragment)2 Bundle (android.os.Bundle)1 FragmentManager (android.support.v4.app.FragmentManager)1 FragmentTransaction (android.support.v4.app.FragmentTransaction)1 MenuItem (android.view.MenuItem)1 Tab (com.amaze.filemanager.database.models.Tab)1 CloudPluginException (com.amaze.filemanager.exceptions.CloudPluginException)1 AuthenticationException (com.cloudrail.si.exceptions.AuthenticationException)1 ParseException (com.cloudrail.si.exceptions.ParseException)1