Example usage for android.support.v4.app DialogFragment setArguments

List of usage examples for android.support.v4.app DialogFragment setArguments

Introduction

In this page you can find the example usage for android.support.v4.app DialogFragment setArguments.

Prototype

public void setArguments(Bundle args) 

Source Link

Document

Supply the construction arguments for this fragment.

Usage

From source file:org.alfresco.mobile.android.application.fragments.node.details.NodeDetailsFragment.java

public void openin(boolean withAlfresco) {
    if (isRestrictable) {
        return;/*  ww  w . j a  v  a2 s . com*/
    }

    Bundle b = new Bundle();

    // 3 cases
    SyncContentManager syncManager = SyncContentManager.getInstance(getActivity());
    AlfrescoAccount acc = getAccount();

    if (syncManager.isSynced(SessionUtils.getAccount(getActivity()), node)) {
        final File syncFile = syncManager.getSyncFile(acc, node);
        if (syncFile == null || !syncFile.exists()) {
            AlfrescoNotificationManager.getInstance(getActivity()).showAlertCrouton(getActivity(),
                    getString(R.string.sync_document_not_available));
            return;
        }

        long datetime = syncFile.lastModified();
        setDownloadDateTime(new Date(datetime));

        if (DataProtectionManager.getInstance(getActivity()).isEncryptionEnable()) {
            // IF sync file + sync activate + data protection
            ActionUtils.actionView(this, syncFile, new ActionManagerListener() {
                @Override
                public void onActivityNotFoundException(ActivityNotFoundException e) {
                    OpenAsDialogFragment.newInstance(syncFile).show(getActivity().getSupportFragmentManager(),
                            OpenAsDialogFragment.TAG);
                }
            });
        } else {
            if (withAlfresco) {
                ActionUtils.openWithAlfrescoTextEditor(this, syncFile,
                        MimeTypeManager.getInstance(getActivity()).getMIMEType(syncFile.getName()),
                        RequestCode.SAVE_BACK);

            } else {
                ActionUtils.openIn(this, syncFile,
                        MimeTypeManager.getInstance(getActivity()).getMIMEType(syncFile.getName()),
                        RequestCode.SAVE_BACK);
            }
        }
    } else {
        // Other case
        b.putParcelable(DownloadDialogFragment.ARGUMENT_DOCUMENT, node);
        b.putInt(DownloadDialogFragment.ARGUMENT_ACTION,
                withAlfresco ? DownloadDialogFragment.ACTION_OPEN_WITH_ALFRESCO
                        : DownloadDialogFragment.ACTION_OPEN);
        DialogFragment frag = new DownloadDialogFragment();
        frag.setArguments(b);
        frag.show(getActivity().getSupportFragmentManager(), DownloadDialogFragment.TAG);
    }

    // Analytics
    if (node instanceof Document) {
        AnalyticsHelper.reportOperationEvent(getActivity(), AnalyticsManager.CATEGORY_DOCUMENT_MANAGEMENT,
                AnalyticsManager.ACTION_OPEN,
                node.isDocument() ? ((Document) node).getContentStreamMimeType() : AnalyticsManager.TYPE_FOLDER,
                1, false, AnalyticsManager.INDEX_FILE_SIZE,
                node.isDocument() ? ((Document) node).getContentStreamLength() : 0);
    } else if (node instanceof NodeSyncPlaceHolder) {
        AnalyticsHelper.reportOperationEvent(getActivity(), AnalyticsManager.CATEGORY_DOCUMENT_MANAGEMENT,
                AnalyticsManager.ACTION_OPEN_OFFLINE,
                node.getPropertyValue(PropertyIds.CONTENT_STREAM_MIME_TYPE) != null
                        ? node.getPropertyValue(PropertyIds.CONTENT_STREAM_MIME_TYPE).toString()
                        : AnalyticsManager.TYPE_FOLDER,
                1, false, AnalyticsManager.INDEX_FILE_SIZE,
                node.getPropertyValue(PropertyIds.CONTENT_STREAM_LENGTH) != null
                        ? Long.parseLong(node.getPropertyValue(PropertyIds.CONTENT_STREAM_LENGTH).toString())
                        : 0);
    }
}

From source file:org.alfresco.mobile.android.application.fragments.node.details.NodeDetailsFragment.java

public void share() {
    if (node.isFolder()) {
        return;//from  w  w w . j  a  v  a 2  s. com
    }

    if (node instanceof NodeSyncPlaceHolder) {
        SyncContentManager syncManager = SyncContentManager.getInstance(getActivity());
        AlfrescoAccount acc = SessionUtils.getAccount(getActivity());
        final File syncFile = syncManager.getSyncFile(acc, node);
        if (syncFile == null || !syncFile.exists()) {
            AlfrescoNotificationManager.getInstance(getActivity())
                    .showLongToast(getString(R.string.sync_document_not_available));
            return;
        }
        long datetime = syncFile.lastModified();
        setDownloadDateTime(new Date(datetime));

        if (DataProtectionManager.getInstance(getActivity()).isEncryptionEnable()) {
            // IF sync file + sync activate + data protection
            ActionUtils.actionSend(getActivity(), syncFile, new ActionManagerListener() {
                @Override
                public void onActivityNotFoundException(ActivityNotFoundException e) {
                }
            });
        } else {
            // If sync file + sync activate
            ActionUtils.actionSend(getActivity(), syncFile, (String) null);
        }
        return;
    }

    ConfigService configService = ConfigManager.getInstance(getActivity()).getConfig(getAccount().getId(),
            ConfigTypeIds.REPOSITORY);
    if (configService != null && configService.getRepositoryConfig() != null) {
        shareUrl = configService.getRepositoryConfig().getShareURL();
        if (!TextUtils.isEmpty(shareUrl) && !shareUrl.endsWith("/")) {
            shareUrl.concat("/");
        }
    }

    if (MDMManager.getInstance(getActivity()).hasConfig()) {
        String tmpShareURL = (String) MDMManager.getInstance(getActivity()).getShareURL();
        if (!TextUtils.isEmpty(tmpShareURL)) {
            shareUrl = tmpShareURL;
        }
    }

    if (getSession() instanceof RepositorySession && shareUrl == null) {
        // Only sharing as attachment is allowed when we're not on a cloud
        // account
        Bundle b = new Bundle();
        b.putParcelable(DownloadDialogFragment.ARGUMENT_DOCUMENT, node);
        b.putInt(DownloadDialogFragment.ARGUMENT_ACTION, DownloadDialogFragment.ACTION_EMAIL);
        DialogFragment frag = new DownloadDialogFragment();
        frag.setArguments(b);
        frag.show(getActivity().getSupportFragmentManager(), DownloadDialogFragment.TAG);

        // Analytics
        AnalyticsHelper.reportOperationEvent(getActivity(), AnalyticsManager.CATEGORY_DOCUMENT_MANAGEMENT,
                AnalyticsManager.ACTION_SHARE,
                node.isDocument() ? ((Document) node).getContentStreamMimeType() : AnalyticsManager.TYPE_FOLDER,
                1, false);
    } else {
        new MaterialDialog.Builder(getActivity()).iconRes(R.drawable.ic_application_logo)
                .title(R.string.app_name).content(R.string.link_or_attach)
                .positiveText(R.string.full_attachment).negativeText(R.string.link_to_repo)
                .callback(new MaterialDialog.ButtonCallback() {
                    @Override
                    public void onPositive(MaterialDialog dialog) {
                        Bundle b = new Bundle();
                        b.putParcelable(DownloadDialogFragment.ARGUMENT_DOCUMENT, node);
                        b.putInt(DownloadDialogFragment.ARGUMENT_ACTION, DownloadDialogFragment.ACTION_EMAIL);
                        DialogFragment frag = new DownloadDialogFragment();
                        frag.setArguments(b);
                        frag.show(getActivity().getSupportFragmentManager(), DownloadDialogFragment.TAG);
                        dialog.dismiss();

                        // Analytics
                        AnalyticsHelper.reportOperationEvent(getActivity(),
                                AnalyticsManager.CATEGORY_DOCUMENT_MANAGEMENT, AnalyticsManager.ACTION_SHARE,
                                node.isDocument() ? ((Document) node).getContentStreamMimeType()
                                        : AnalyticsManager.TYPE_FOLDER,
                                1, false);
                    }

                    @Override
                    public void onNegative(MaterialDialog dialog) {
                        if (parentNode != null) {
                            String path = parentNode.getPropertyValue(PropertyIds.PATH);
                            if (path.length() > 0) {
                                String fullPath = null;
                                if (getSession() instanceof RepositorySession) {
                                    fullPath = shareUrl.concat(String.format(
                                            getString(R.string.onpremise_share_url),
                                            NodeRefUtils.getCleanIdentifier(
                                                    NodeRefUtils.getNodeIdentifier(node.getIdentifier()))));
                                    ActionUtils.actionShareLink(NodeDetailsFragment.this, fullPath);
                                } else if (path.startsWith("/Sites/")) {
                                    // Get past the '/Sites/'
                                    String sub1 = path.substring(7);
                                    // Find end of site name
                                    int idx = sub1.indexOf('/');
                                    if (idx == -1) {
                                        idx = sub1.length();
                                    }
                                    String siteName = sub1.substring(0, idx);
                                    String nodeID = NodeRefUtils.getCleanIdentifier(node.getIdentifier());
                                    fullPath = String.format(getString(R.string.cloud_share_url),
                                            ((CloudSession) getSession()).getNetwork().getIdentifier(),
                                            siteName, nodeID);

                                    ActionUtils.actionShareLink(NodeDetailsFragment.this, fullPath);
                                } else {
                                    Log.i(getString(R.string.app_name),
                                            "Site path not as expected: no /sites/");
                                }

                                // Analytics
                                AnalyticsHelper.reportOperationEvent(getActivity(),
                                        AnalyticsManager.CATEGORY_DOCUMENT_MANAGEMENT,
                                        AnalyticsManager.ACTION_SHARE_AS_LINK,
                                        node.isDocument() ? ((Document) node).getContentStreamMimeType()
                                                : AnalyticsManager.TYPE_FOLDER,
                                        1, false);
                            } else {
                                Log.i(getString(R.string.app_name),
                                        "Site path not as expected: no parent path");
                            }
                        } else {
                            Log.i(getString(R.string.app_name), "Site path not as expected: No parent folder");
                        }

                        dialog.dismiss();
                    }
                }).show();
    }
}

From source file:eu.trentorise.smartcampus.jp.PlanNewJourneyFragment.java

protected void setUpTimingControls() {
    Date now = new Date();
    dateEditText = (EditText) getView().findViewById(R.id.plannew_date);

    /* check if date and time are stored */
    if (fromDate == null) {
        dateEditText.setTag(now);//from w w  w.j a  va2s. co  m
        dateEditText.setText(Config.FORMAT_DATE_UI.format(now));
    } else {
        dateEditText.setTag(fromDate);
        dateEditText.setText(Config.FORMAT_DATE_UI.format(fromDate));
    }

    dateEditText.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            DialogFragment f = DatePickerDialogFragment.newInstance((EditText) v);
            // f.setArguments(DatePickerDialogFragment.prepareData(f.toString()));
            f.show(getSherlockActivity().getSupportFragmentManager(), "datePicker");
        }
    });

    timeEditText = (EditText) getView().findViewById(R.id.plannew_time);
    if (fromTime == null) {
        timeEditText.setTag(now);
        timeEditText.setText(Config.FORMAT_TIME_UI.format(now));
    } else {
        timeEditText.setTag(fromTime);
        timeEditText.setText(Config.FORMAT_TIME_UI.format(fromTime));
    }
    timeEditText.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            DialogFragment f = TimePickerDialogFragment.newInstance((EditText) v);
            f.setArguments(TimePickerDialogFragment.prepareData(timeEditText.toString()));
            f.show(getSherlockActivity().getSupportFragmentManager(), "timePicker");

        }
    });
    fromDate = fromTime = now;
}

From source file:de.vanita5.twittnuker.activity.support.ComposeActivity.java

public boolean handleMenuItem(final MenuItem item) {
    switch (item.getItemId()) {
    case MENU_TAKE_PHOTO: {
        takePhoto();/* ww w.  j  av a  2 s . c  o  m*/
        break;
    }
    case MENU_ADD_IMAGE: {
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT || !openDocument()) {
            pickImage();
        }
        break;
    }
    case MENU_ADD_LOCATION: {
        final boolean attachLocation = mPreferences.getBoolean(KEY_ATTACH_LOCATION, false);
        if (!attachLocation) {
            getLocation();
        } else {
            mLocationManager.removeUpdates(this);
        }
        mPreferences.edit().putBoolean(KEY_ATTACH_LOCATION, !attachLocation).apply();
        setMenu();
        updateTextCount();
        break;
    }
    case MENU_DRAFTS: {
        startActivity(new Intent(INTENT_ACTION_DRAFTS));
        break;
    }
    case MENU_DELETE: {
        new DeleteImageTask(this).execute();
        break;
    }
    case MENU_TOGGLE_SENSITIVE: {
        if (!hasMedia())
            return false;
        mIsPossiblySensitive = !mIsPossiblySensitive;
        setMenu();
        updateTextCount();
        break;
    }
    case MENU_VIEW: {
        if (mInReplyToStatus == null)
            return false;
        final DialogFragment fragment = new ViewStatusDialogFragment();
        final Bundle args = new Bundle();
        args.putParcelable(EXTRA_STATUS, mInReplyToStatus);
        fragment.setArguments(args);
        fragment.show(getSupportFragmentManager(), "view_status");
        break;
    }
    default: {
        break;
    }
    }
    return true;
}

From source file:com.veniosg.dir.android.fragment.SimpleFileListFragment.java

private boolean handleSingleSelectionAction(ActionMode mode, MenuItem item) {
    FileHolder fItem = (FileHolder) getListAdapter().getItem(getCheckedItemPosition());
    if (fItem == null)
        return false;
    DialogFragment dialog;
    Bundle args;//from   w ww .  j  a va2  s.co  m

    switch (item.getItemId()) {
    case R.id.menu_create_shortcut:
        mode.finish();
        Utils.createShortcut(fItem, getActivity());
        return true;

    case R.id.menu_move:
        mode.finish();
        ((FileManagerApplication) getActivity().getApplication()).getCopyHelper().cut(fItem);
        getActivity().supportInvalidateOptionsMenu();
        return true;

    case R.id.menu_copy:
        mode.finish();
        ((FileManagerApplication) getActivity().getApplication()).getCopyHelper().copy(fItem);
        getActivity().supportInvalidateOptionsMenu();
        return true;

    case R.id.menu_delete:
        mode.finish();
        dialog = new SingleDeleteDialog();
        dialog.setTargetFragment(SimpleFileListFragment.this, 0);
        args = new Bundle();
        args.putParcelable(IntentConstants.EXTRA_DIALOG_FILE_HOLDER, fItem);
        dialog.setArguments(args);
        dialog.show(getFragmentManager(), SingleDeleteDialog.class.getName());
        return true;

    case R.id.menu_rename:
        mode.finish();
        dialog = new RenameDialog();
        dialog.setTargetFragment(SimpleFileListFragment.this, 0);
        args = new Bundle();
        args.putParcelable(IntentConstants.EXTRA_DIALOG_FILE_HOLDER, fItem);
        dialog.setArguments(args);
        dialog.show(getFragmentManager(), RenameDialog.class.getName());
        return true;

    case R.id.menu_send:
        mode.finish();
        Utils.sendFile(fItem, getActivity());
        return true;

    case R.id.menu_details:
        mode.finish();
        dialog = new DetailsDialog();
        dialog.setTargetFragment(this, 0);
        args = new Bundle();
        args.putParcelable(IntentConstants.EXTRA_DIALOG_FILE_HOLDER, fItem);
        dialog.setArguments(args);
        dialog.show(getFragmentManager(), DetailsDialog.class.getName());
        return true;

    case R.id.menu_compress:
        mode.finish();
        dialog = new SingleCompressDialog();
        dialog.setTargetFragment(this, 0);
        args = new Bundle();
        args.putParcelable(IntentConstants.EXTRA_DIALOG_FILE_HOLDER, fItem);
        dialog.setArguments(args);
        dialog.show(getFragmentManager(), SingleCompressDialog.class.getName());
        return true;

    case R.id.menu_extract:
        mode.finish();
        File extractTo = new File(fItem.getFile().getParentFile(),
                FileUtils.getNameWithoutExtension(fItem.getFile()));
        extractTo.mkdirs();

        // We just extract on the current directory. If the user needs to put it in another dir,
        // he/she can copy/cut the file
        ZipService.extractTo(getActivity(), fItem, extractTo);
        return true;

    case R.id.menu_bookmark:
        mode.finish();
        addBookmark(fItem.getFile());
        return true;

    default:
        return false;
    }
}

From source file:org.getlantern.firetweet.activity.support.ComposeActivity.java

public boolean handleMenuItem(final MenuItem item) {
    switch (item.getItemId()) {
    case MENU_TAKE_PHOTO:
    case R.id.take_photo_sub_item: {
        takePhoto();/* ww  w  .j a v  a 2s  .c om*/
        break;
    }
    case MENU_ADD_IMAGE:
    case R.id.add_image_sub_item: {
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT || !openDocument()) {
            pickImage();
        }
        break;
    }
    case MENU_ADD_LOCATION: {
        toggleLocation();
        break;
    }
    case MENU_DRAFTS: {
        startActivity(new Intent(INTENT_ACTION_DRAFTS));
        break;
    }
    case MENU_DELETE: {
        AsyncTaskUtils.executeTask(new DeleteImageTask(this));
        break;
    }
    case MENU_TOGGLE_SENSITIVE: {
        if (!hasMedia())
            return false;
        mIsPossiblySensitive = !mIsPossiblySensitive;
        setMenu();
        updateTextCount();
        break;
    }
    case MENU_VIEW: {
        if (mInReplyToStatus == null)
            return false;
        final DialogFragment fragment = new ViewStatusDialogFragment();
        final Bundle args = new Bundle();
        args.putParcelable(EXTRA_STATUS, mInReplyToStatus);
        fragment.setArguments(args);
        fragment.show(getSupportFragmentManager(), "view_status");
        break;
    }
    default: {
        final Intent intent = item.getIntent();
        if (intent != null) {
            try {
                final String action = intent.getAction();
                if (INTENT_ACTION_EXTENSION_COMPOSE.equals(action)) {
                    final long[] accountIds = mAccountsAdapter.getSelectedAccountIds();
                    intent.putExtra(EXTRA_TEXT, ParseUtils.parseString(mEditText.getText()));
                    intent.putExtra(EXTRA_ACCOUNT_IDS, accountIds);
                    if (accountIds.length > 0) {
                        final long account_id = accountIds[0];
                        intent.putExtra(EXTRA_NAME, getAccountName(this, account_id));
                        intent.putExtra(EXTRA_SCREEN_NAME, getAccountScreenName(this, account_id));
                    }
                    if (mInReplyToStatusId > 0) {
                        intent.putExtra(EXTRA_IN_REPLY_TO_ID, mInReplyToStatusId);
                    }
                    if (mInReplyToStatus != null) {
                        intent.putExtra(EXTRA_IN_REPLY_TO_NAME, mInReplyToStatus.user_name);
                        intent.putExtra(EXTRA_IN_REPLY_TO_SCREEN_NAME, mInReplyToStatus.user_screen_name);
                    }
                    startActivityForResult(intent, REQUEST_EXTENSION_COMPOSE);
                } else if (INTENT_ACTION_EXTENSION_EDIT_IMAGE.equals(action)) {
                    // final ComponentName cmp = intent.getComponent();
                    // if (cmp == null || !hasMedia()) return false;
                    // final String name = new
                    // File(mMediaUri.getPath()).getName();
                    // final Uri data =
                    // Uri.withAppendedPath(CacheFiles.CONTENT_URI,
                    // Uri.encode(name));
                    // intent.setData(data);
                    // grantUriPermission(cmp.getPackageName(), data,
                    // Intent.FLAG_GRANT_READ_URI_PERMISSION);
                    // startActivityForResult(intent,
                    // REQUEST_EDIT_IMAGE);
                } else {
                    startActivity(intent);
                }
            } catch (final ActivityNotFoundException e) {
                Log.w(LOGTAG, e);
                return false;
            }
        }
        break;
    }
    }
    return true;
}

From source file:com.money.manager.ex.transactions.EditTransactionCommonFunctions.java

/**
 * The user is switching to Transfer transaction type.
 *///w  ww  .jav  a2 s.  c  o  m
private void onTransferSelected() {
    // Check whether to delete split categories, if any.
    if (hasSplitCategories()) {
        // Prompt the user to confirm deleting split categories.
        // Use DialogFragment in order to redraw the binaryDialog when switching device orientation.

        DialogFragment dialog = new YesNoDialog();
        Bundle args = new Bundle();
        args.putString("title", getContext().getString(R.string.warning));
        args.putString("message", getContext().getString(R.string.no_transfer_splits));
        args.putString("purpose", YesNoDialog.PURPOSE_DELETE_SPLITS_WHEN_SWITCHING_TO_TRANSFER);
        dialog.setArguments(args);

        dialog.show(getActivity().getSupportFragmentManager(), "tag");

        // Dialog result is handled in onEvent handlers in the listeners.

        return;
    }

    // un-check split.
    setSplit(false);

    // Set the destination account, if not already.
    if (transactionEntity.getAccountToId() == null
            || transactionEntity.getAccountToId().equals(Constants.NOT_SET)) {
        if (mAccountIdList.size() == 0) {
            // notify the user and exit.
            new MaterialDialog.Builder(getContext()).title(R.string.warning)
                    .content(R.string.no_accounts_available_for_selection).positiveText(android.R.string.ok)
                    .show();
            return;
        } else {
            transactionEntity.setAccountToId(mAccountIdList.get(0));
        }
    }

    // calculate AmountTo only if not set previously.
    if (transactionEntity.getAmountTo().isZero()) {
        Money amountTo = calculateAmountTo();
        transactionEntity.setAmountTo(amountTo);
    }
    displayAmountTo();
}

From source file:org.mariotaku.twidere.activity.support.ComposeActivity.java

@Override
public boolean onMenuItemClick(final MenuItem item) {
    switch (item.getItemId()) {
    case MENU_TAKE_PHOTO:
    case R.id.take_photo_sub_item: {
        takePhoto();/*from ww  w . ja v a 2s .c  o m*/
        break;
    }
    case MENU_ADD_IMAGE:
    case R.id.add_image_sub_item: {
        pickImage();
        break;
    }
    case MENU_ADD_LOCATION: {
        toggleLocation();
        break;
    }
    case MENU_DRAFTS: {
        Utils.openDrafts(this);
        break;
    }
    case MENU_DELETE: {
        AsyncTaskUtils.executeTask(new DeleteImageTask(this));
        break;
    }
    case MENU_TOGGLE_SENSITIVE: {
        if (!hasMedia())
            return false;
        mIsPossiblySensitive = !mIsPossiblySensitive;
        setMenu();
        updateTextCount();
        break;
    }
    case MENU_VIEW: {
        if (mInReplyToStatus == null)
            return false;
        final DialogFragment fragment = new ViewStatusDialogFragment();
        final Bundle args = new Bundle();
        args.putParcelable(EXTRA_STATUS, mInReplyToStatus);
        fragment.setArguments(args);
        fragment.show(getSupportFragmentManager(), "view_status");
        break;
    }
    case R.id.link_to_quoted_status: {
        final boolean newValue = !item.isChecked();
        item.setChecked(newValue);
        mPreferences.edit().putBoolean(KEY_LINK_TO_QUOTED_TWEET, newValue).apply();
        break;
    }
    default: {
        final Intent intent = item.getIntent();
        if (intent != null) {
            try {
                final String action = intent.getAction();
                if (INTENT_ACTION_EXTENSION_COMPOSE.equals(action)) {
                    final long[] accountIds = mAccountsAdapter.getSelectedAccountIds();
                    intent.putExtra(EXTRA_TEXT, ParseUtils.parseString(mEditText.getText()));
                    intent.putExtra(EXTRA_ACCOUNT_IDS, accountIds);
                    if (accountIds.length > 0) {
                        final long account_id = accountIds[0];
                        intent.putExtra(EXTRA_NAME, Utils.getAccountName(this, account_id));
                        intent.putExtra(EXTRA_SCREEN_NAME, Utils.getAccountScreenName(this, account_id));
                    }
                    if (mInReplyToStatusId > 0) {
                        intent.putExtra(EXTRA_IN_REPLY_TO_ID, mInReplyToStatusId);
                    }
                    if (mInReplyToStatus != null) {
                        intent.putExtra(EXTRA_IN_REPLY_TO_NAME, mInReplyToStatus.user_name);
                        intent.putExtra(EXTRA_IN_REPLY_TO_SCREEN_NAME, mInReplyToStatus.user_screen_name);
                    }
                    startActivityForResult(intent, REQUEST_EXTENSION_COMPOSE);
                } else if (INTENT_ACTION_EXTENSION_EDIT_IMAGE.equals(action)) {
                    // final ComponentName cmp = intent.getComponent();
                    // if (cmp == null || !hasMedia()) return false;
                    // final String name = new
                    // File(mMediaUri.getPath()).getName();
                    // final Uri data =
                    // Uri.withAppendedPath(CacheFiles.CONTENT_URI,
                    // Uri.encode(name));
                    // intent.setData(data);
                    // grantUriPermission(cmp.getPackageName(), data,
                    // Intent.FLAG_GRANT_READ_URI_PERMISSION);
                    // startActivityForResult(intent,
                    // REQUEST_EDIT_IMAGE);
                } else {
                    startActivity(intent);
                }
            } catch (final ActivityNotFoundException e) {
                Log.w(LOGTAG, e);
                return false;
            }
        }
        break;
    }
    }
    return true;
}

From source file:com.veniosg.dir.android.fragment.SimpleFileListFragment.java

private boolean handleMultipleSelectionAction(ActionMode mode, MenuItem item) {
    DialogFragment dialog;
    Bundle args;/*w w w .  j ava 2  s  .c om*/
    ArrayList<FileHolder> fItems = getCheckedItems();

    switch (item.getItemId()) {
    case R.id.menu_send:
        mode.finish();
        Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
        ArrayList<Uri> uris = new ArrayList<Uri>();
        intent.setType("text/plain");

        for (FileHolder fh : fItems) {
            if (!fh.getFile().isDirectory())
                uris.add(FileUtils.getUri(fh));
        }

        intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);

        try {
            startActivity(Intent.createChooser(intent, getString(R.string.send_chooser_title)));
            return true;
        } catch (ActivityNotFoundException e) {
            Toast.makeText(getActivity(), R.string.send_not_available, Toast.LENGTH_SHORT).show();
            return true;
        }
    case R.id.menu_delete:
        mode.finish();
        dialog = new MultiDeleteDialog();
        dialog.setTargetFragment(this, 0);
        args = new Bundle();
        args.putParcelableArrayList(IntentConstants.EXTRA_DIALOG_FILE_HOLDER,
                new ArrayList<Parcelable>(fItems));
        dialog.setArguments(args);
        dialog.show(getFragmentManager(), MultiDeleteDialog.class.getName());
        return true;
    case R.id.menu_move:
        mode.finish();
        ((FileManagerApplication) getActivity().getApplication()).getCopyHelper().cut(fItems);
        getActivity().supportInvalidateOptionsMenu();
        return true;
    case R.id.menu_copy:
        mode.finish();
        ((FileManagerApplication) getActivity().getApplication()).getCopyHelper().copy(fItems);
        getActivity().supportInvalidateOptionsMenu();
        return true;
    case R.id.menu_compress:
        mode.finish();
        dialog = new MultiCompressDialog();
        dialog.setTargetFragment(this, 0);
        args = new Bundle();
        args.putParcelableArrayList(IntentConstants.EXTRA_DIALOG_FILE_HOLDER,
                new ArrayList<Parcelable>(fItems));
        dialog.setArguments(args);
        dialog.show(getFragmentManager(), MultiCompressDialog.class.getName());
        return true;
    default:
        return false;
    }
}

From source file:org.mariotaku.twidere.util.Utils.java

public static void openImage(final Context context, final Uri uri, final boolean is_possibly_sensitive) {
    if (context == null || uri == null)
        return;/*from  w  w w  . ja va 2  s .c  o  m*/
    final Intent intent = new Intent(INTENT_ACTION_VIEW_IMAGE);
    intent.setDataAndType(uri, "image/*");
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD_MR1) {
        intent.setClass(context, ImageViewerGLActivity.class);
    } else {
        intent.setClass(context, ImageViewerActivity.class);
    }
    final SharedPreferences prefs = context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
    if (context instanceof FragmentActivity && is_possibly_sensitive
            && !prefs.getBoolean(PREFERENCE_KEY_DISPLAY_SENSITIVE_CONTENTS, false)) {
        final FragmentActivity activity = (FragmentActivity) context;
        final FragmentManager fm = activity.getSupportFragmentManager();
        final DialogFragment fragment = new SensitiveContentWaringDialogFragment();
        final Bundle args = new Bundle();
        args.putParcelable(INTENT_KEY_URI, uri);
        fragment.setArguments(args);
        fragment.show(fm, "sensitive_content_warning");
    } else {
        context.startActivity(intent);
    }
}