Search in sources :

Example 11 with RootInfo

use of dev.dworks.apps.anexplorer.model.RootInfo in project AnExplorer by 1hakr.

the class DocumentsActivity method updateActionBar.

public void updateActionBar() {
    final RootInfo root = getCurrentRoot();
    // final boolean showRootIcon = mShowAsDialog || (mState.action == DocumentsActivity.State.ACTION_MANAGE);
    final boolean showIndicator = !mShowAsDialog && (mState.action != ACTION_MANAGE);
    if (mShowAsDialog) {
        // getSupportActionBar().setDisplayHomeAsUpEnabled(showIndicator);
        // mToolbar.setLogo(R.drawable.logo);
        getSupportActionBar().setDisplayShowHomeEnabled(true);
        if (mDrawerToggle != null) {
            mDrawerToggle.setDrawerIndicatorEnabled(showIndicator);
        }
    }
    mToolbar.setNavigationContentDescription(R.string.drawer_open);
    mToolbar.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            setRootsDrawerOpen(!isRootsDrawerOpen());
        }
    });
    if (isRootsDrawerOpen()) {
        // mToolbar.setNavigationIcon(root != null ? root.loadToolbarIcon(mToolbar.getContext()) : null);
        if (mState.action == ACTION_OPEN || mState.action == ACTION_GET_CONTENT || mState.action == ACTION_BROWSE || mState.action == ACTION_OPEN_TREE) {
            // mToolbar.setTitle(R.string.title_open);
            mToolbar.setTitle(R.string.app_name);
        } else if (mState.action == DocumentsActivity.State.ACTION_CREATE) {
            mToolbar.setTitle(R.string.title_save);
        }
        mToolbarStack.setVisibility(View.GONE);
        mToolbarStack.setAdapter(null);
    } else {
        if (mSearchExpanded) {
            mToolbar.setTitle(null);
            mToolbarStack.setVisibility(View.GONE);
            mToolbarStack.setAdapter(null);
        } else {
            if (mState.stack.size() <= 1) {
                if (null != root) {
                    mToolbar.setTitle(root.title);
                    AnalyticsManager.setCurrentScreen(this, root.derivedTag);
                }
                mToolbarStack.setVisibility(View.GONE);
                mToolbarStack.setAdapter(null);
            } else {
                mToolbar.setTitle(null);
                mToolbarStack.setVisibility(View.VISIBLE);
                mToolbarStack.setAdapter(mStackAdapter);
                mIgnoreNextNavigation = true;
                mToolbarStack.setSelection(mStackAdapter.getCount() - 1);
            }
        }
    }
}
Also used : RootInfo(dev.dworks.apps.anexplorer.model.RootInfo) ImageView(android.widget.ImageView) SearchView(android.support.v7.widget.SearchView) DirectoryContainerView(dev.dworks.apps.anexplorer.ui.DirectoryContainerView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) AbsListView(android.widget.AbsListView)

Example 12 with RootInfo

use of dev.dworks.apps.anexplorer.model.RootInfo in project AnExplorer by 1hakr.

the class DocumentsActivity method setPending.

public void setPending(boolean pending) {
    final SaveFragment save = SaveFragment.get(getFragmentManager());
    if (save != null) {
        save.setPending(pending);
    }
    final RootInfo root = getCurrentRoot();
    if (root != null && (root.isRootedStorage() || root.isUsbStorage())) {
        refreshData();
    }
}
Also used : RootInfo(dev.dworks.apps.anexplorer.model.RootInfo) SaveFragment(dev.dworks.apps.anexplorer.fragment.SaveFragment)

Example 13 with RootInfo

use of dev.dworks.apps.anexplorer.model.RootInfo in project AnExplorer by 1hakr.

the class StandaloneActivity method onCurrentDirectoryChanged.

private void onCurrentDirectoryChanged(int anim) {
    final FragmentManager fm = getFragmentManager();
    final RootInfo root = getCurrentRoot();
    final DocumentInfo cwd = getCurrentDirectory();
    mDirectoryContainer.setDrawDisappearingFirst(anim == ANIM_DOWN);
    if (cwd == null) {
        DirectoryFragment.showRecentsOpen(fm, anim);
        // Start recents in grid when requesting visual things
        final boolean visualMimes = MimePredicate.mimeMatches(MimePredicate.VISUAL_MIMES, mState.acceptMimes);
        mState.userMode = visualMimes ? State.MODE_GRID : State.MODE_LIST;
        mState.derivedMode = mState.userMode;
    } else {
        if (mState.currentSearch != null) {
            // Ongoing search
            DirectoryFragment.showSearch(fm, root, cwd, mState.currentSearch, anim);
        } else {
            // Normal boring directory
            DirectoryFragment.showNormal(fm, root, cwd, anim);
        }
    }
    final RootsFragment roots = RootsFragment.get(fm);
    if (roots != null) {
        roots.onCurrentRootChanged();
    }
    updateActionBar();
    supportInvalidateOptionsMenu();
    dumpStack();
}
Also used : FragmentManager(android.app.FragmentManager) RootInfo(dev.dworks.apps.anexplorer.model.RootInfo) RootsFragment(dev.dworks.apps.anexplorer.fragment.RootsFragment) DocumentInfo(dev.dworks.apps.anexplorer.model.DocumentInfo)

Example 14 with RootInfo

use of dev.dworks.apps.anexplorer.model.RootInfo in project AnExplorer by 1hakr.

the class StandaloneActivity method onPrepareOptionsMenu.

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);
    final FragmentManager fm = getFragmentManager();
    final RootInfo root = getCurrentRoot();
    final DocumentInfo cwd = getCurrentDirectory();
    final MenuItem createDir = menu.findItem(R.id.menu_create_dir);
    final MenuItem search = menu.findItem(R.id.menu_search);
    final MenuItem sort = menu.findItem(R.id.menu_sort);
    final MenuItem sortSize = menu.findItem(R.id.menu_sort_size);
    final MenuItem grid = menu.findItem(R.id.menu_grid);
    final MenuItem list = menu.findItem(R.id.menu_list);
    sort.setVisible(cwd != null);
    grid.setVisible(mState.derivedMode != State.MODE_GRID);
    list.setVisible(mState.derivedMode != State.MODE_LIST);
    if (mState.currentSearch != null) {
        // Search uses backend ranking; no sorting
        sort.setVisible(false);
        search.expandActionView();
        mSearchView.setIconified(false);
        mSearchView.clearFocus();
        mSearchView.setQuery(mState.currentSearch, false);
    } else {
        mIgnoreNextClose = true;
        mSearchView.setIconified(true);
        mSearchView.clearFocus();
        mIgnoreNextCollapse = true;
        search.collapseActionView();
    }
    // Only sort by size when visible
    sortSize.setVisible(mState.showSize);
    search.setVisible(true);
    createDir.setVisible(true);
    return true;
}
Also used : FragmentManager(android.app.FragmentManager) RootInfo(dev.dworks.apps.anexplorer.model.RootInfo) MenuItem(android.view.MenuItem) DocumentInfo(dev.dworks.apps.anexplorer.model.DocumentInfo)

Example 15 with RootInfo

use of dev.dworks.apps.anexplorer.model.RootInfo in project AnExplorer by 1hakr.

the class RootsCache method loadRootsForAuthority.

/**
 * Bring up requested provider and query for all active roots.
 */
private Collection<RootInfo> loadRootsForAuthority(ContentResolver resolver, String authority) {
    if (LOGD)
        Log.d(TAG, "Loading roots for " + authority);
    synchronized (mObservedAuthorities) {
        if (mObservedAuthorities.add(authority)) {
            // Watch for any future updates
            final Uri rootsUri = DocumentsContract.buildRootsUri(authority);
            mContext.getContentResolver().registerContentObserver(rootsUri, true, mObserver);
        }
    }
    final List<RootInfo> roots = new ArrayList<>();
    final Uri rootsUri = DocumentsContract.buildRootsUri(authority);
    ContentProviderClient client = null;
    Cursor cursor = null;
    try {
        client = DocumentsApplication.acquireUnstableProviderOrThrow(resolver, authority);
        cursor = client.query(rootsUri, null, null, null, null);
        while (cursor.moveToNext()) {
            final RootInfo root = RootInfo.fromRootsCursor(authority, cursor);
            roots.add(root);
        }
    } catch (Exception e) {
        Log.w(TAG, "Failed to load some roots from " + authority + ": " + e);
    } finally {
        IoUtils.closeQuietly(cursor);
        ContentProviderClientCompat.releaseQuietly(client);
    }
    return roots;
}
Also used : RootInfo(dev.dworks.apps.anexplorer.model.RootInfo) ArrayList(java.util.ArrayList) Cursor(android.database.Cursor) Uri(android.net.Uri) ContentProviderClient(android.content.ContentProviderClient)

Aggregations

RootInfo (dev.dworks.apps.anexplorer.model.RootInfo)26 Bundle (android.os.Bundle)5 View (android.view.View)5 TextView (android.widget.TextView)5 DocumentInfo (dev.dworks.apps.anexplorer.model.DocumentInfo)5 ArrayList (java.util.ArrayList)5 FragmentManager (android.app.FragmentManager)4 Uri (android.net.Uri)4 RecyclerView (android.support.v7.widget.RecyclerView)4 Intent (android.content.Intent)3 BaseActivity (dev.dworks.apps.anexplorer.BaseActivity)3 Timer (java.util.Timer)3 TargetApi (android.annotation.TargetApi)2 Context (android.content.Context)2 Loader (android.content.Loader)2 Cursor (android.database.Cursor)2 MenuItem (android.view.MenuItem)2 State (dev.dworks.apps.anexplorer.BaseActivity.State)2 RootsFragment (dev.dworks.apps.anexplorer.fragment.RootsFragment)2 SaveFragment (dev.dworks.apps.anexplorer.fragment.SaveFragment)2