use of dev.dworks.apps.anexplorer.model.DocumentInfo 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.DocumentInfo 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.DocumentInfo in project AnExplorer by 1hakr.
the class CreateDirectoryFragment method onCreateDialog.
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final Context context = getActivity();
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
final LayoutInflater dialogInflater = LayoutInflater.from(builder.getContext());
final View view = dialogInflater.inflate(R.layout.dialog_create_dir, null, false);
final EditText text1 = (EditText) view.findViewById(android.R.id.text1);
Utils.tintWidget(text1);
builder.setTitle(R.string.menu_create_dir);
builder.setView(view);
builder.setPositiveButton(android.R.string.ok, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
final String displayName = text1.getText().toString();
final BaseActivity activity = (BaseActivity) getActivity();
final DocumentInfo cwd = activity.getCurrentDirectory();
if (TextUtils.isEmpty(displayName)) {
activity.showError(R.string.create_error);
return;
}
new CreateDirectoryTask(activity, cwd, displayName).executeOnExecutor(ProviderExecutor.forAuthority(cwd.authority));
}
});
builder.setNegativeButton(android.R.string.cancel, null);
return builder.create();
}
use of dev.dworks.apps.anexplorer.model.DocumentInfo in project AnExplorer by 1hakr.
the class DocumentsActivity method dumpStack.
private void dumpStack() {
Log.d(TAG, "Current stack: ");
Log.d(TAG, " * " + mState.stack.root);
for (DocumentInfo doc : mState.stack) {
Log.d(TAG, " +-- " + doc);
}
}
use of dev.dworks.apps.anexplorer.model.DocumentInfo in project AnExplorer by 1hakr.
the class DocumentsActivity method updateMenuItems.
public void updateMenuItems(Menu menu) {
final FragmentManager fm = getFragmentManager();
final RootInfo root = getCurrentRoot();
final DocumentInfo cwd = getCurrentDirectory();
if (isTelevision()) {
menu.findItem(R.id.menu_create_dir).setVisible(showActionMenu());
menu.findItem(R.id.menu_create_file).setVisible(showActionMenu());
}
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);
final MenuItem settings = menu.findItem(R.id.menu_settings);
// Open drawer means we hide most actions
if (isRootsDrawerOpen()) {
search.setVisible(false);
sort.setVisible(false);
grid.setVisible(false);
list.setVisible(false);
mIgnoreNextCollapse = true;
search.collapseActionView();
return;
}
sort.setVisible(cwd != null);
grid.setVisible(!RootInfo.isOtherRoot(getCurrentRoot()) && mState.derivedMode != MODE_GRID);
list.setVisible(mState.derivedMode != 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);
final boolean searchVisible;
if (mState.action == ACTION_CREATE || mState.action == ACTION_OPEN_TREE) {
searchVisible = false;
// No display options in recent directories
if (cwd == null) {
grid.setVisible(false);
list.setVisible(false);
}
if (mState.action == State.ACTION_CREATE) {
if (null != SaveFragment.get(fm))
SaveFragment.get(fm).setSaveEnabled(cwd != null && cwd.isCreateSupported());
}
} else {
searchVisible = root != null && ((root.flags & Root.FLAG_SUPPORTS_SEARCH) != 0);
// TODO: Is this useful?
if (null != SaveFragment.get(fm))
SaveFragment.get(fm).setSaveEnabled(cwd != null && cwd.isCreateSupported());
if (null != MoveFragment.get(fm))
MoveFragment.get(fm).setSaveEnabled(cwd != null && cwd.isMoveSupported());
}
// TODO: close any search in-progress when hiding
search.setVisible(searchVisible);
settings.setVisible(mState.action != ACTION_MANAGE);
}
Aggregations