use of dev.dworks.apps.anexplorer.model.RootInfo in project AnExplorer by 1hakr.
the class DocumentsActivity method onCurrentDirectoryChanged.
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public void onCurrentDirectoryChanged(int anim) {
// FIX for java.lang.IllegalStateException ("Activity has been destroyed")
if (!Utils.isActivityAlive(DocumentsActivity.this)) {
return;
}
final FragmentManager fm = getFragmentManager();
final RootInfo root = getCurrentRoot();
DocumentInfo cwd = getCurrentDirectory();
// TODO : this has to be done nicely
if (cwd == null && (null != root && !root.isServerStorage())) {
final Uri uri = DocumentsContract.buildDocumentUri(root.authority, root.documentId);
DocumentInfo result;
try {
result = DocumentInfo.fromUri(getContentResolver(), uri);
if (result != null) {
mState.stack.push(result);
mState.stackTouched = true;
cwd = result;
}
} catch (FileNotFoundException e) {
CrashReportingManager.logException(e);
}
}
if (!SettingsActivity.getFolderAnimation(this)) {
anim = 0;
}
mDirectoryContainer.setDrawDisappearingFirst(anim == ANIM_DOWN);
if (cwd == null) {
// No directory means recents
if (mState.action == ACTION_CREATE || mState.action == ACTION_OPEN_TREE) {
RecentsCreateFragment.show(fm);
} else {
if (root.isHome()) {
HomeFragment.show(fm);
} else if (root.isConnections()) {
ConnectionsFragment.show(fm);
} else if (root.isServerStorage()) {
ServerFragment.show(fm, root);
} else {
DirectoryFragment.showRecentsOpen(fm, anim);
// Start recents in grid when requesting visual things
// MimePredicate.mimeMatches(MimePredicate.VISUAL_MIMES, mState.acceptMimes);
final boolean visualMimes = true;
mState.userMode = visualMimes ? MODE_GRID : MODE_LIST;
mState.derivedMode = mState.userMode;
}
}
} else {
if (mState.currentSearch != null && mSearchResultShown) {
// Ongoing search
DirectoryFragment.showSearch(fm, root, cwd, mState.currentSearch, anim);
mSearchResultShown = false;
} else {
// Normal boring directory
DirectoryFragment.showNormal(fm, root, cwd, anim);
}
}
// Forget any replacement target
if (mState.action == ACTION_CREATE) {
final SaveFragment save = SaveFragment.get(fm);
if (save != null) {
save.setReplaceTarget(null);
}
}
if (mState.action == ACTION_OPEN_TREE) {
final PickFragment pick = PickFragment.get(fm);
if (pick != null) {
final CharSequence displayName = (mState.stack.size() <= 1) && null != root ? root.title : cwd.displayName;
pick.setPickTarget(cwd, displayName);
}
}
final MoveFragment move = MoveFragment.get(fm);
if (move != null) {
move.setReplaceTarget(cwd);
}
final RootsFragment roots = RootsFragment.get(fm);
if (roots != null) {
roots.onCurrentRootChanged();
}
updateActionBar();
invalidateMenu();
dumpStack();
if (!Utils.isOtherBuild() && !isTelevision()) {
AppRate.with(this, mRateContainer).listener(mOnShowListener).checkAndShow();
}
}
use of dev.dworks.apps.anexplorer.model.RootInfo in project AnExplorer by 1hakr.
the class DirectoryFragment method updateUserState.
private void updateUserState(String column) {
final ContentResolver resolver = getActivity().getContentResolver();
final State state = getDisplayState(this);
final RootInfo root = getArguments().getParcelable(EXTRA_ROOT);
final DocumentInfo doc = getArguments().getParcelable(EXTRA_DOC);
if (root != null && doc != null) {
final Uri stateUri = RecentsProvider.buildState(root.authority, root.rootId, doc.documentId);
final ContentValues values = new ContentValues();
if (column.startsWith(StateColumns.MODE)) {
values.put(StateColumns.MODE, state.userMode);
} else {
values.put(StateColumns.SORT_ORDER, state.userSortOrder);
}
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
resolver.insert(stateUri, values);
return null;
}
}.execute();
}
if (column.startsWith(StateColumns.MODE)) {
state.derivedMode = state.userMode;
} else {
state.derivedSortOrder = state.userSortOrder;
}
}
use of dev.dworks.apps.anexplorer.model.RootInfo in project AnExplorer by 1hakr.
the class RootsFragment method onCurrentRootChanged.
public void onCurrentRootChanged() {
if (mAdapter == null || mList == null)
return;
final RootInfo root = ((BaseActivity) getActivity()).getCurrentRoot();
for (int i = 0; i < mAdapter.getGroupCount(); i++) {
for (int j = 0; j < mAdapter.getChildrenCount(i); j++) {
final Object item = mAdapter.getChild(i, j);
if (item instanceof RootItem) {
final RootInfo testRoot = ((RootItem) item).root;
if (Objects.equal(testRoot, root)) {
try {
long id = ExpandableListView.getPackedPositionForChild(i, j);
int index = mList.getFlatListPosition(id);
// mList.setSelection(index);
mList.setItemChecked(index, true);
} catch (Exception e) {
CrashReportingManager.logException(e);
}
return;
}
}
}
}
}
use of dev.dworks.apps.anexplorer.model.RootInfo in project AnExplorer by 1hakr.
the class StandaloneActivity method updateActionBar.
public void updateActionBar() {
final RootInfo root = getCurrentRoot();
mToolbar.setNavigationIcon(root != null ? root.loadToolbarIcon(mToolbar.getContext()) : null);
mToolbar.setNavigationContentDescription(R.string.drawer_open);
mToolbar.setNavigationOnClickListener(null);
if (mSearchExpanded) {
mToolbar.setTitle(null);
mToolbarStack.setVisibility(View.GONE);
mToolbarStack.setAdapter(null);
} else {
if (mState.stack.size() <= 1) {
mToolbar.setTitle(root.title);
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 RootsExpandableAdapter method processRoots.
private void processRoots(Collection<RootInfo> roots) {
List<GroupInfo> groupRoots = new ArrayList<>();
final List<Item> home = new ArrayList<>();
final List<Item> phone = new ArrayList<>();
final List<Item> recent = new ArrayList<>();
final List<Item> connection = new ArrayList<>();
final List<Item> rooted = new ArrayList<>();
final List<Item> appbackup = new ArrayList<>();
final List<Item> usb = new ArrayList<>();
final List<Item> storage = new ArrayList<>();
final List<Item> secondaryStorage = new ArrayList<>();
final List<Item> network = new ArrayList<>();
final List<Item> apps = new ArrayList<>();
final List<Item> libraryMedia = new ArrayList<>();
final List<Item> libraryNonMedia = new ArrayList<>();
final List<Item> folders = new ArrayList<>();
final List<Item> bookmarks = new ArrayList<>();
for (RootInfo root : roots) {
if (root.isHome()) {
home.add(new RootItem(root));
} else if (root.isRecents()) {
if (recent.size() == 0) {
recent.add(new RootItem(root));
}
} else if (root.isConnections()) {
connection.add(new RootItem(root));
} else if (root.isRootedStorage()) {
rooted.add(new RootItem(root));
} else if (root.isPhoneStorage()) {
phone.add(new RootItem(root));
} else if (root.isAppBackupFolder()) {
appbackup.add(new RootItem(root));
} else if (root.isUsbStorage()) {
usb.add(new RootItem(root));
} else if (RootInfo.isLibraryMedia(root)) {
libraryMedia.add(new RootItem(root));
} else if (RootInfo.isLibraryNonMedia(root)) {
libraryNonMedia.add(new RootItem(root));
} else if (RootInfo.isFolder(root)) {
folders.add(new RootItem(root));
} else if (RootInfo.isBookmark(root)) {
bookmarks.add(new BookmarkItem(root));
} else if (RootInfo.isStorage(root)) {
if (root.isSecondaryStorage()) {
secondaryStorage.add(new RootItem(root));
} else {
storage.add(new RootItem(root));
}
} else if (RootInfo.isApps(root)) {
apps.add(new RootItem(root));
} else if (RootInfo.isNetwork(root)) {
network.add(new RootItem(root));
}
}
if (!home.isEmpty() || !storage.isEmpty() || !phone.isEmpty() || !rooted.isEmpty()) {
home.addAll(storage);
home.addAll(secondaryStorage);
home.addAll(usb);
home.addAll(phone);
home.addAll(rooted);
groupRoots.add(new GroupInfo("Storage", home));
}
if (!network.isEmpty()) {
network.addAll(connection);
groupRoots.add(new GroupInfo("Network", network));
} else if (!connection.isEmpty()) {
groupRoots.add(new GroupInfo("Network", connection));
}
if (!apps.isEmpty()) {
if (!appbackup.isEmpty()) {
apps.addAll(appbackup);
}
groupRoots.add(new GroupInfo("Apps", apps));
}
if (!libraryMedia.isEmpty() || !libraryNonMedia.isEmpty()) {
recent.addAll(libraryMedia);
recent.addAll(libraryNonMedia);
groupRoots.add(new GroupInfo("Library", recent));
} else if (!recent.isEmpty()) {
groupRoots.add(new GroupInfo("Library", recent));
}
if (!folders.isEmpty()) {
folders.addAll(bookmarks);
groupRoots.add(new GroupInfo("Folders", folders));
}
group.clear();
group.addAll(groupRoots);
}
Aggregations