Example usage for android.content Intent ACTION_EDIT

List of usage examples for android.content Intent ACTION_EDIT

Introduction

In this page you can find the example usage for android.content Intent ACTION_EDIT.

Prototype

String ACTION_EDIT

To view the source code for android.content Intent ACTION_EDIT.

Click Source Link

Document

Activity Action: Provide explicit editable access to the given data.

Usage

From source file:net.gsantner.opoc.util.ShareUtil.java

/**
 * Request edit of image (by image editor/viewer - for example to crop image)
 *
 * @param file File that should be edited
 *//*from  www  .j  a v a2s . c  o m*/
public void requestPictureEdit(File file) {
    Uri uri = getUriByFileProviderAuthority(file);
    int flags = Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION;

    Intent intent = new Intent(Intent.ACTION_EDIT);
    intent.setDataAndType(uri, "image/*");
    intent.addFlags(flags);
    intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
    intent.putExtra(EXTRA_FILEPATH, file.getAbsolutePath());

    for (ResolveInfo resolveInfo : _context.getPackageManager().queryIntentActivities(intent,
            PackageManager.MATCH_DEFAULT_ONLY)) {
        String packageName = resolveInfo.activityInfo.packageName;
        _context.grantUriPermission(packageName, uri, flags);
    }
    _context.startActivity(Intent.createChooser(intent, null));
}

From source file:com.nononsenseapps.notepad.ActivityMain.java

/**
 * Returns a note id from an intent if it contains one, either as part of
 * its URI or as an extra// w ww .java 2s  .c om
 * <p/>
 * Returns -1 if no id was contained, this includes insert actions
 */
long getNoteId(final Intent intent) {
    long retval = -1;
    if (intent != null && intent.getData() != null && (Intent.ACTION_EDIT.equals(intent.getAction())
            || Intent.ACTION_VIEW.equals(intent.getAction()))) {
        if (intent.getData().getPath().startsWith(TaskList.URI.getPath())) {
            // Find it in the extras. See DashClock extension for an example
            retval = intent.getLongExtra(Task.TABLE_NAME, -1);
        } else if ((intent.getData().getPath().startsWith(LegacyDBHelper.NotePad.Notes.PATH_VISIBLE_NOTES)
                || intent.getData().getPath().startsWith(LegacyDBHelper.NotePad.Notes.PATH_NOTES)
                || intent.getData().getPath().startsWith(Task.URI.getPath()))) {
            retval = Long.parseLong(intent.getData().getLastPathSegment());
        }
        // else if (null != intent
        // .getStringExtra(TaskDetailFragment.ARG_ITEM_ID)) {
        // retval = Long.parseLong(intent
        // .getStringExtra(TaskDetailFragment.ARG_ITEM_ID));
        // }
    }
    return retval;
}

From source file:com.silentcircle.contacts.editor.ContactEditorFragment.java

@Override
public void onPrepareOptionsMenu(Menu menu) {
    // This supports the keyboard shortcut to save changes to a contact but shouldn't be visible
    // because the custom action bar contains the "save" button now (not the overflow menu).
    // TODO: Find a better way to handle shortcuts, i.e. onKeyDown()?
    final MenuItem doneMenu = menu.findItem(R.id.menu_done);
    //        final MenuItem splitMenu = menu.findItem(R.id.menu_split);
    //        final MenuItem joinMenu = menu.findItem(R.id.menu_join);
    final MenuItem helpMenu = menu.findItem(R.id.menu_help);

    // Set visibility of menus
    doneMenu.setVisible(false);//from  www . j  av a2  s .  c o  m

    //        // Split only if more than one raw profile and not a user profile
    //        splitMenu.setVisible(mState != null && mState.size() > 1 && !isEditingUserProfile());
    //
    //        // Cannot join a user profile
    //        joinMenu.setVisible(!isEditingUserProfile());

    // help menu depending on whether this is inserting or editing
    if (Intent.ACTION_INSERT.equals(mAction)) {
        // inserting
        HelpUtils.prepareHelpMenuItem(mContext, helpMenu, R.string.help_url_people_add);
    } else if (Intent.ACTION_EDIT.equals(mAction)) {
        // editing
        HelpUtils.prepareHelpMenuItem(mContext, helpMenu, R.string.help_url_people_edit);
    } else {
        // something else, so don't show the help menu
        helpMenu.setVisible(false);
    }

    int size = menu.size();
    for (int i = 0; i < size; i++) {
        menu.getItem(i).setEnabled(mEnabled);
    }
}

From source file:com.nononsenseapps.notepad.ActivityMain.java

/**
 * Returns true the intent URI targets a note. Either an edit/view or
 * insert./*from w w w .j  ava  2 s. c  o  m*/
 */
boolean isNoteIntent(final Intent intent) {
    if (intent == null) {
        return false;
    }
    if (Intent.ACTION_SEND.equals(intent.getAction())
            || "com.google.android.gm.action.AUTO_SEND".equals(intent.getAction())) {
        return true;
    }

    if (intent.getData() != null
            && (Intent.ACTION_EDIT.equals(intent.getAction()) || Intent.ACTION_VIEW.equals(intent.getAction())
                    || Intent.ACTION_INSERT.equals(intent.getAction()))
            && (intent.getData().getPath().startsWith(LegacyDBHelper.NotePad.Notes.PATH_VISIBLE_NOTES)
                    || intent.getData().getPath().startsWith(LegacyDBHelper.NotePad.Notes.PATH_NOTES)
                    || intent.getData().getPath().startsWith(Task.URI.getPath()))
            && !intent.getData().getPath().startsWith(TaskList.URI.getPath())) {
        return true;
    }

    return false;
}

From source file:com.chen.mail.ui.AbstractActivityController.java

@Override
public void changeAccount(Account account) {
    LogUtils.d(LOG_TAG, "AAC.changeAccount(%s)", account);
    // Is the account or account settings different from the existing account?
    final boolean firstLoad = mAccount == null;
    final boolean accountChanged = firstLoad || !account.uri.equals(mAccount.uri);

    // If nothing has changed, return early without wasting any more time.
    if (!accountChanged && !account.settingsDiffer(mAccount)) {
        return;/* w w w. jav  a2 s .com*/
    }
    // We also don't want to do anything if the new account is null
    if (account == null) {
        LogUtils.e(LOG_TAG, "AAC.changeAccount(null) called.");
        return;
    }
    final String emailAddress = account.getEmailAddress();
    mHandler.post(new Runnable() {
        @Override
        public void run() {
            MailActivity.setNfcMessage(emailAddress);
        }
    });
    if (accountChanged) {
        commitDestructiveActions(false);
    }
    Analytics.getInstance().setCustomDimension(Analytics.CD_INDEX_ACCOUNT_TYPE,
            AnalyticsUtils.getAccountTypeForAccount(emailAddress));
    // Change the account here
    setAccount(account);
    // And carry out associated actions.
    cancelRefreshTask();
    if (accountChanged) {
        loadAccountInbox();
    }
    // Check if we need to force setting up an account before proceeding.
    if (mAccount != null && !Uri.EMPTY.equals(mAccount.settings.setupIntentUri)) {
        // Launch the intent!
        final Intent intent = new Intent(Intent.ACTION_EDIT);
        intent.setData(mAccount.settings.setupIntentUri);
        mActivity.startActivity(intent);
    }
}

From source file:org.opendatakit.survey.activities.MainMenuActivity.java

@Override
public void chooseForm(Uri formUri) {
    Intent i = new Intent(Intent.ACTION_EDIT, formUri, this, MainMenuActivity.class);
    i.putExtra("_sync_state", submenuPage);
    startActivityForResult(i, INTERNAL_ACTIVITY_CODE);
}

From source file:com.android.mail.ui.AbstractActivityController.java

public void changeAccount(Account account) {
    LogUtils.d(LOG_TAG, "AAC.changeAccount(%s)", account);
    // Is the account or account settings different from the existing account?
    final boolean firstLoad = mAccount == null;
    final boolean accountChanged = firstLoad || !account.uri.equals(mAccount.uri);

    // If nothing has changed, return early without wasting any more time.
    if (!accountChanged && !account.settingsDiffer(mAccount)) {
        return;/*from w  w w.ja  v  a 2 s.c o m*/
    }
    // We also don't want to do anything if the new account is null
    if (account == null) {
        LogUtils.e(LOG_TAG, "AAC.changeAccount(null) called.");
        return;
    }
    final String emailAddress = account.getEmailAddress();
    mHandler.post(new Runnable() {
        @Override
        public void run() {
            MailActivity.setNfcMessage(emailAddress);
        }
    });
    if (accountChanged) {
        commitDestructiveActions(false);
    }

    // Change the account here
    setAccount(account);
    // And carry out associated actions.
    cancelRefreshTask();
    if (accountChanged) {
        loadAccountInbox();
    }
    // Check if we need to force setting up an account before proceeding.
    if (mAccount != null && !Uri.EMPTY.equals(mAccount.settings.setupIntentUri)) {
        // Launch the intent!
        final Intent intent = new Intent(Intent.ACTION_EDIT);

        intent.setPackage(mContext.getPackageName());
        intent.setData(mAccount.settings.setupIntentUri);

        mActivity.startActivity(intent);
    }
}

From source file:edu.cens.loci.ui.PlaceViewActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {
    case R.id.menu_edit:
        Intent intent = new Intent(Intent.ACTION_EDIT,
                ContentUris.withAppendedId(Places.CONTENT_URI, mPlace.placeId));
        startActivity(intent);//  w  w w  .jav  a 2 s. c  o  m
        return true;
    case R.id.menu_delete:
        showDialog(DIALOG_CONFIRM_DELETE, null);
        return true;
    case R.id.menu_block:
        showDialog(DIALOG_CONFIRM_BLOCK, null);
        return true;
    case R.id.menu_unblock:
        showDialog(DIALOG_CONFIRM_UNBLOCK, null);
        return true;
    }
    return false;
}

From source file:org.brandroid.openmanager.fragments.ContentFragment.java

public boolean executeMenu(final int id, final Object mode, final OpenPath file) {
    Logger.LogInfo("ContentFragment.executeMenu(0x" + Integer.toHexString(id) + ") on " + file);
    final String path = file != null ? file.getPath() : null;
    OpenPath parent = file != null ? file.getParent() : mPath;
    if (parent == null || parent instanceof OpenCursor)
        parent = OpenFile.getExternalMemoryDrive(true);
    final OpenPath folder = parent;
    String name = file != null ? file.getName() : null;

    final boolean fromPasteMenu = file.equals(mPath);

    switch (id) {
    case R.id.menu_refresh:
        if (DEBUG)
            Logger.LogDebug("Refreshing " + getPath().getPath());
        getPath().clearChildren();//from   ww  w.j a va2s.  c o  m
        FileManager.removeOpenCache(getPath().getPath());
        getPath().deleteFolderFromDb();
        runUpdateTask(true);
        refreshData(new Bundle(), false);
        return true;

    case R.id.menu_context_download:
        OpenPath dl = OpenExplorer.getDownloadParent().getFirstDir();
        if (dl == null)
            dl = OpenFile.getExternalMemoryDrive(true);
        if (dl != null) {
            List<OpenPath> files = new ArrayList<OpenPath>();
            files.add(file);
            getEventHandler().copyFile(files, dl, getActivity());
        } else
            getExplorer().showToast(R.string.s_error_ftp);
        return true;

    case R.id.menu_context_selectall:
        if (getContentAdapter() == null)
            return false;
        boolean hasAll = true;
        for (OpenPath p : getContentAdapter().getAll())
            if (!getClipboard().contains(p)) {
                hasAll = false;
                break;
            }
        if (!hasAll)
            getClipboard().addAll(getContentAdapter().getAll());
        else
            getClipboard().removeAll(getContentAdapter().getAll());
        return true;

    case R.id.menu_context_view:
        Intent vintent = IntentManager.getIntent(file, getExplorer(), Intent.ACTION_VIEW);
        if (vintent != null)
            getActivity().startActivity(vintent);
        else {
            if (getExplorer() != null)
                getExplorer().showToast(R.string.s_error_no_intents);
            if (file.length() < getResources().getInteger(R.integer.max_text_editor_size))
                getExplorer().editFile(file);
        }
        break;

    case R.id.menu_context_edit:
        Intent intent = IntentManager.getIntent(file, getExplorer(), Intent.ACTION_EDIT);
        if (intent != null) {
            if (intent.getPackage() != null && intent.getPackage().equals(getActivity().getPackageName()))
                getExplorer().editFile(file);
            else
                try {
                    intent.setAction(Intent.ACTION_EDIT);
                    Logger.LogVerbose("Starting Intent: " + intent.toString());
                    getExplorer().startActivity(intent);
                } catch (ActivityNotFoundException e) {
                    getExplorer().showToast(R.string.s_error_no_intents);
                    getExplorer().editFile(file);
                }
        } else if (file.length() < getResources().getInteger(R.integer.max_text_editor_size)) {
            getExplorer().editFile(file);
        } else {
            getExplorer().showToast(R.string.s_error_no_intents);
        }
        break;

    case R.id.menu_multi:
        changeMultiSelectState(!getClipboard().isMultiselect());
        if (!fromPasteMenu)
            getClipboard().add(file);
        return true;
    case R.id.menu_context_bookmark:
        getExplorer().addBookmark(file);
        finishMode(mode);
        return true;

    case R.id.menu_context_delete:
        //fileList.add(file);
        getHandler().deleteFile(file, getActivity(), true);
        finishMode(mode);
        if (getContentAdapter() != null)
            getContentAdapter().notifyDataSetChanged();
        return true;

    case R.id.menu_context_rename:
        getHandler().renameFile(file, true, getActivity());
        finishMode(mode);
        return true;

    case R.id.menu_context_copy:
    case R.id.menu_context_cut:
        getClipboard().DeleteSource = id == R.id.menu_context_cut;
        file.setTag(id);
        getClipboard().add(file);
        return true;

    case R.id.menu_context_paste:
    case R.id.content_paste:
        OpenPath into = file;
        if (fromPasteMenu)
            into = mPath;
        if (!file.isDirectory()) {
            Logger.LogWarning("Can't paste into file (" + file.getPath() + "). Using parent directory ("
                    + folder.getPath() + ")");
            into = folder;
        }
        OpenClipboard cb = getClipboard();
        cb.setCurrentPath(into);
        if (cb.size() > 0) {
            if (cb.DeleteSource)
                getHandler().cutFile(cb, into, getActivity());
            else
                getHandler().copyFile(cb, into, getActivity());
            refreshOperations();
        }

        cb.DeleteSource = false;
        if (cb.ClearAfter)
            getClipboard().clear();
        getExplorer().updateTitle(path);
        finishMode(mode);
        return true;

    case R.id.menu_context_zip:
        if (!fromPasteMenu)
            getClipboard().add(file);
        else
            getClipboard().setCurrentPath(mPath);

        getClipboard().ClearAfter = true;
        String zname = getClipboard().get(0).getName().replace("." + file.getExtension(), "") + ".zip";
        if (getClipboard().size() > 1) {
            OpenPath last = getClipboard().get(getClipboard().getCount() - 1);
            if (last != null && last.getParent() != null) {
                if (last.getParent() instanceof OpenCursor)
                    zname = folder.getPath();
                zname = last.getParent().getName() + ".zip";
            }
        }
        final String def = zname;

        final InputDialog dZip = new InputDialog(getExplorer()).setIcon(R.drawable.sm_zip)
                .setTitle(R.string.s_menu_zip).setMessageTop(R.string.s_prompt_path)
                .setDefaultTop(mPath.getPath()).setMessage(R.string.s_prompt_zip).setCancelable(true)
                .setNegativeButton(android.R.string.no, new OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        if (!fromPasteMenu && getClipboard().size() <= 1)
                            getClipboard().clear();
                    }
                });
        dZip.setOnCancelListener(new OnCancelListener() {
            public void onCancel(DialogInterface dialog) {
                if (fromPasteMenu && getClipboard().size() <= 1)
                    getClipboard().clear();
            }
        }).setPositiveButton(android.R.string.ok, new OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                OpenPath zFolder = new OpenFile(dZip.getInputTopText());
                if (zFolder == null || !zFolder.exists())
                    zFolder = folder;
                OpenPath zipFile = zFolder.getChild(dZip.getInputText());
                Logger.LogVerbose("Zipping " + getClipboard().size() + " items to " + zipFile.getPath());
                getHandler().zipFile(zipFile, getClipboard(), getExplorer());
                refreshOperations();
                finishMode(mode);
            }
        }).setDefaultText(def);
        dZip.create().show();
        return true;

    //case R.id.menu_context_unzip:
    //   getHandler().unzipFile(file, getExplorer());
    //   return true;

    case R.id.menu_context_info:
        DialogHandler.showFileInfo(getExplorer(), file);
        finishMode(mode);
        return true;

    case R.id.menu_multi_all_clear:
        getClipboard().clear();
        return true;

    case R.id.menu_context_share:

        // TODO: WTF is this?
        Intent mail = new Intent();
        mail.setType("application/mail");

        mail.setAction(android.content.Intent.ACTION_SEND);
        mail.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(path)));
        startActivity(mail);

        //mode.finish();
        return true;

    //         this is for bluetooth
    //         files.add(path);
    //         getHandler().sendFile(files);
    //         mode.finish();
    //         return true;
    }
    return false;
}

From source file:org.smap.smapTask.android.activities.MainMapsActivity.java

public void completeTask(String instancePath, String formPath, long taskId) {

    // set the adhoc location
    try {//w  ww  .ja  v  a2  s.  c  o  m
        fda = new FileDbAdapter();
        fda.open();
        if (userPlace != null) {
            WgsPoint userLocation = userPlace.getWgs();
            fda.updateAdhocLocation(taskId, String.valueOf(userLocation.getLon()),
                    String.valueOf(userLocation.getLat()));
        }
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        if (fda != null) {
            fda.close();
        }
    }

    // Get the provider URI of the instance 
    String where = InstanceColumns.INSTANCE_FILE_PATH + "=?";
    String[] whereArgs = { instancePath };
    Cursor cInstanceProvider = managedQuery(InstanceColumns.CONTENT_URI, null, where, whereArgs, null);
    if (cInstanceProvider.getCount() != 1) {

    } else {
        cInstanceProvider.moveToFirst();
        Uri instanceUri = ContentUris.withAppendedId(InstanceColumns.CONTENT_URI,
                cInstanceProvider.getLong(cInstanceProvider.getColumnIndex(InstanceColumns._ID)));
        // Start activity to complete form
        Intent i = new Intent(Intent.ACTION_EDIT, instanceUri);

        i.putExtra(FormEntryActivity.KEY_FORMPATH, formPath); // TODO Don't think this is needed
        i.putExtra(FormEntryActivity.KEY_TASK, taskId);
        if (instancePath != null) { // TODO Don't think this is needed
            i.putExtra(FormEntryActivity.KEY_INSTANCEPATH, instancePath);
        }
        startActivity(i);
    }
    cInstanceProvider.close();
}