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);
}
}
}
}
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();
}
}
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();
}
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;
}
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;
}
Aggregations