use of dev.dworks.apps.anexplorer.model.DocumentInfo 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.DocumentInfo in project AnExplorer by 1hakr.
the class DirectoryFragment method onUninstall.
private void onUninstall() {
if (!docsAppUninstall.isEmpty()) {
DocumentInfo doc = docsAppUninstall.get(docsAppUninstall.size() - 1);
onUninstallApp(doc);
docsAppUninstall.remove(docsAppUninstall.size() - 1);
} else {
if (null != root && root.isAppPackage()) {
AppsProvider.notifyDocumentsChanged(getActivity(), root.rootId);
}
}
}
use of dev.dworks.apps.anexplorer.model.DocumentInfo in project AnExplorer by 1hakr.
the class DirectoryFragment method bookmarkDocument.
private void bookmarkDocument(DocumentInfo doc) {
DocumentInfo document = doc;
ContentValues contentValues = new ContentValues();
contentValues.put(ExplorerProvider.BookmarkColumns.PATH, document.path);
contentValues.put(ExplorerProvider.BookmarkColumns.TITLE, document.displayName);
contentValues.put(ExplorerProvider.BookmarkColumns.ROOT_ID, document.displayName);
Uri uri = getActivity().getContentResolver().insert(ExplorerProvider.buildBookmark(), contentValues);
if (null != uri) {
((BaseActivity) getActivity()).showInfo("Bookmark added");
RootsCache.updateRoots(getActivity(), ExternalStorageProvider.AUTHORITY);
}
Bundle params = new Bundle();
AnalyticsManager.logEvent("bookmarked", root, params);
}
use of dev.dworks.apps.anexplorer.model.DocumentInfo 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.DocumentInfo in project AnExplorer by 1hakr.
the class DirectoryFragment method onPopupMenuItemClick.
public boolean onPopupMenuItemClick(MenuItem item, int position) {
final ArrayList<DocumentInfo> docs = new ArrayList<>();
final Cursor cursor = mAdapter.getItem(position);
final DocumentInfo doc = DocumentInfo.fromDirectoryCursor(cursor);
docs.add(doc);
final int id = item.getItemId();
switch(id) {
case R.id.menu_share:
onShareDocuments(docs);
return true;
case R.id.menu_copy:
moveDocument(docs, false);
return true;
case R.id.menu_cut:
moveDocument(docs, true);
return true;
case R.id.menu_delete:
deleteDocument(docs, id);
return true;
case R.id.menu_stop:
stopDocument(docs, id);
return true;
case R.id.menu_save:
case R.id.menu_uncompress:
case R.id.menu_compress:
new OperationTask(docs, id).execute();
return true;
case R.id.menu_open:
openDocument(docs.get(0));
return true;
case R.id.menu_details:
Intent intent2 = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, Uri.parse("package:" + AppsProvider.getPackageForDocId(docs.get(0).documentId)));
if (Utils.isIntentAvailable(getActivity(), intent2)) {
getActivity().startActivity(intent2);
}
Bundle params = new Bundle();
String type = IconUtils.getTypeNameFromMimeType(docs.get(0).mimeType);
params.putString(FILE_TYPE, type);
AnalyticsManager.logEvent("details", params);
return true;
case R.id.menu_info:
infoDocument(docs.get(0));
return true;
case R.id.menu_rename:
renameDocument(docs.get(0));
return true;
case R.id.menu_bookmark:
bookmarkDocument(docs.get(0));
return true;
default:
return false;
}
}
Aggregations