Search in sources :

Example 11 with DocumentInfo

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();
    }
}
Also used : FragmentManager(android.app.FragmentManager) RootInfo(dev.dworks.apps.anexplorer.model.RootInfo) FileNotFoundException(java.io.FileNotFoundException) SaveFragment(dev.dworks.apps.anexplorer.fragment.SaveFragment) RootsFragment(dev.dworks.apps.anexplorer.fragment.RootsFragment) Uri(android.net.Uri) PickFragment(dev.dworks.apps.anexplorer.fragment.PickFragment) MoveFragment(dev.dworks.apps.anexplorer.fragment.MoveFragment) DocumentInfo(dev.dworks.apps.anexplorer.model.DocumentInfo) TargetApi(android.annotation.TargetApi)

Example 12 with DocumentInfo

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);
        }
    }
}
Also used : DocumentInfo(dev.dworks.apps.anexplorer.model.DocumentInfo)

Example 13 with DocumentInfo

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);
}
Also used : ContentValues(android.content.ContentValues) Bundle(android.os.Bundle) BaseActivity(dev.dworks.apps.anexplorer.BaseActivity) Uri(android.net.Uri) DocumentInfo(dev.dworks.apps.anexplorer.model.DocumentInfo)

Example 14 with DocumentInfo

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;
    }
}
Also used : ContentValues(android.content.ContentValues) RootInfo(dev.dworks.apps.anexplorer.model.RootInfo) State(dev.dworks.apps.anexplorer.BaseActivity.State) Uri(android.net.Uri) ContentResolver(android.content.ContentResolver) DocumentInfo(dev.dworks.apps.anexplorer.model.DocumentInfo)

Example 15 with DocumentInfo

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;
    }
}
Also used : Bundle(android.os.Bundle) ArrayList(java.util.ArrayList) Intent(android.content.Intent) DocumentInfo.getCursorString(dev.dworks.apps.anexplorer.model.DocumentInfo.getCursorString) Cursor(android.database.Cursor) Point(android.graphics.Point) DocumentInfo(dev.dworks.apps.anexplorer.model.DocumentInfo)

Aggregations

DocumentInfo (dev.dworks.apps.anexplorer.model.DocumentInfo)20 Context (android.content.Context)6 ContentResolver (android.content.ContentResolver)5 Uri (android.net.Uri)5 RootInfo (dev.dworks.apps.anexplorer.model.RootInfo)5 ArrayList (java.util.ArrayList)5 FragmentManager (android.app.FragmentManager)4 Intent (android.content.Intent)4 OperationCanceledException (android.os.OperationCanceledException)4 DocumentInfo.getCursorString (dev.dworks.apps.anexplorer.model.DocumentInfo.getCursorString)4 Bundle (android.os.Bundle)3 MenuItem (android.view.MenuItem)3 ContentValues (android.content.ContentValues)2 DialogInterface (android.content.DialogInterface)2 OnClickListener (android.content.DialogInterface.OnClickListener)2 Cursor (android.database.Cursor)2 Point (android.graphics.Point)2 AlertDialog (android.support.v7.app.AlertDialog)2 LayoutInflater (android.view.LayoutInflater)2 View (android.view.View)2