    private QuickAction prepareFileAction(final SeafDirent dirent, boolean cacheExists) {
        final QuickAction mQuickAction = new QuickAction(mActivity);
        Resources resources = mActivity.getResources();
        ActionItem shareAction, downloadAction, updateAction, exportAction, renameAction, deleteAction;
        if (!repoIsEncrypted) {
            shareAction = new ActionItem(ACTION_ID_SHARE,
                    resources.getString(R.string.file_action_share),
                    resources.getDrawable(R.drawable.action_share));
            mQuickAction.addActionItem(shareAction);
        }
        renameAction = new ActionItem(ACTION_ID_RENAME,
                resources.getString(R.string.file_action_rename),
                resources.getDrawable(R.drawable.action_rename));
        mQuickAction.addActionItem(renameAction);
        exportAction = new ActionItem(ACTION_ID_EXPORT,
                resources.getString(R.string.file_action_export),
                resources.getDrawable(R.drawable.action_export));
        mQuickAction.addActionItem(exportAction);
        if (cacheExists) {
            if (mActivity.hasRepoWritePermission()) {
                updateAction = new ActionItem(ACTION_ID_UPDATE,
                        resources.getString(R.string.file_action_update),
                        resources.getDrawable(R.drawable.action_update));
                mQuickAction.addActionItem(updateAction);
            }
        } else {
            downloadAction = new ActionItem(ACTION_ID_DOWNLOAD,
                    resources.getString(R.string.file_action_download),
                    resources.getDrawable(R.drawable.action_download));
            mQuickAction.addActionItem(downloadAction);
        }
        mQuickAction.setOnActionItemClickListener(new QuickAction.OnActionItemClickListener() {
            @Override
            public void onItemClick(QuickAction quickAction, int pos, int actionId) {
                NavContext nav = mActivity.getNavContext();
                String repoName = nav.getRepoName();
                String repoID = nav.getRepoID();
                String dir = nav.getDirPath();
                String path = Utils.pathJoin(dir, dirent.name);
                DataManager dataManager = mActivity.getDataManager();
                String localPath = dataManager.getLocalRepoFile(repoName, repoID, path).getPath();
                switch (actionId) {
                case ACTION_ID_SHARE:
                    mActivity.shareFile(repoID, path);
                    break;
                case ACTION_ID_EXPORT:
                    mActivity.exportFile(dirent.name);
                    break;
                case ACTION_ID_DOWNLOAD:
                    mActivity.onFileSelected(dirent);
                    break;
                case ACTION_ID_UPDATE:
                    mActivity.addUpdateTask(repoID, repoName, dir, localPath);
                    break;
                case ACTION_ID_RENAME:
                    break;
                }
            }
        });
        mQuickAction.mAnimateTrack(false);
        return mQuickAction;
    }

    private QuickAction prepareFileAction(final SeafDirent dirent, boolean cacheExists) {
        final QuickAction mQuickAction = new QuickAction(mActivity);
        Resources resources = mActivity.getResources();
        ActionItem shareAction, downloadAction, updateAction, exportAction, renameAction, deleteAction;
        if (!repoIsEncrypted) {
            shareAction = new ActionItem(ACTION_ID_SHARE,
                    resources.getString(R.string.file_action_share),
                    resources.getDrawable(R.drawable.action_share));
            mQuickAction.addActionItem(shareAction);
        }
        renameAction = new ActionItem(ACTION_ID_RENAME,
                resources.getString(R.string.file_action_rename),
                resources.getDrawable(R.drawable.action_rename));
        mQuickAction.addActionItem(renameAction);
        exportAction = new ActionItem(ACTION_ID_EXPORT,
                resources.getString(R.string.file_action_export),
                resources.getDrawable(R.drawable.action_export));
        mQuickAction.addActionItem(exportAction);
        if (cacheExists) {
            if (mActivity.hasRepoWritePermission()) {
                updateAction = new ActionItem(ACTION_ID_UPDATE,
                        resources.getString(R.string.file_action_update),
                        resources.getDrawable(R.drawable.action_update));
                mQuickAction.addActionItem(updateAction);
            }
        } else {
            downloadAction = new ActionItem(ACTION_ID_DOWNLOAD,
                    resources.getString(R.string.file_action_download),
                    resources.getDrawable(R.drawable.action_download));
            mQuickAction.addActionItem(downloadAction);
        }
        mQuickAction.setOnActionItemClickListener(new QuickAction.OnActionItemClickListener() {
            @Override
            public void onItemClick(QuickAction quickAction, int pos, int actionId) {
                NavContext nav = mActivity.getNavContext();
                String repoName = nav.getRepoName();
                String repoID = nav.getRepoID();
                String dir = nav.getDirPath();
                String path = Utils.pathJoin(dir, dirent.name);
                DataManager dataManager = mActivity.getDataManager();
                String localPath = dataManager.getLocalRepoFile(repoName, repoID, path).getPath();
                switch (actionId) {
                case ACTION_ID_SHARE:
                    mActivity.shareFile(repoID, path);
                    break;
                case ACTION_ID_EXPORT:
                    mActivity.exportFile(dirent.name);
                    break;
                case ACTION_ID_DOWNLOAD:
                    mActivity.onFileSelected(dirent);
                    break;
                case ACTION_ID_UPDATE:
                    mActivity.addUpdateTask(repoID, repoName, dir, localPath);
                    break;
                case ACTION_ID_RENAME:
                    mActivity.renameFile(repoID, repoName, path);
                    break;
                }
            }
        });
        mQuickAction.mAnimateTrack(false);
        return mQuickAction;
    }
