Java Code Examples for android.content.Intent#ACTION_EDIT

The following examples show how to use android.content.Intent#ACTION_EDIT . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: OsmGo   File: Camera.java    License: MIT License 7 votes vote down vote up
private void editImage(PluginCall call, Uri uri) {
  try {
    Uri origPhotoUri = uri;
    if (imageFileUri != null) {
      origPhotoUri = imageFileUri;
    }
    Intent editIntent = new Intent(Intent.ACTION_EDIT);
    editIntent.setDataAndType(origPhotoUri, "image/*");
    File editedFile = CameraUtils.createImageFile(getActivity(), false);
    Uri editedUri = Uri.fromFile(editedFile);
    editIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    editIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
    editIntent.putExtra(MediaStore.EXTRA_OUTPUT, editedUri);
    startActivityForResult(call, editIntent, REQUEST_IMAGE_EDIT);
  } catch (Exception ex) {
    call.error(IMAGE_EDIT_ERROR, ex);
  }
}
 
Example 2
Source Project: flutter_contacts   File: ContactsServicePlugin.java    License: MIT License 6 votes vote down vote up
void openExistingContact(Contact contact) {
  String identifier = contact.identifier;
  try {
    HashMap contactMapFromDevice = getContactByIdentifier(identifier);
    // Contact existence check
    if(contactMapFromDevice != null) {
      Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI, identifier);
      Intent intent = new Intent(Intent.ACTION_EDIT);
      intent.setDataAndType(uri, ContactsContract.Contacts.CONTENT_ITEM_TYPE);
      intent.putExtra("finishActivityOnSaveCompleted", true);
      startIntent(intent, REQUEST_OPEN_EXISTING_CONTACT);
    } else {
      finishWithResult(FORM_COULD_NOT_BE_OPEN);
    }
  } catch(Exception e) {
    finishWithResult(FORM_COULD_NOT_BE_OPEN);
  }
}
 
Example 3
Source Project: call_manage   File: ContactUtils.java    License: MIT License 6 votes vote down vote up
/**
 * Open contact edit page in default contacts app by contact's id
 *
 * @param activity
 * @param number
 */
public static void openContactToEditByNumber(Activity activity, String number) {
    try {
        long contactId = ContactUtils.getContactByPhoneNumber(activity, number).getContactId();
        Uri uri = ContentUris.withAppendedId(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
                contactId);
        Intent intent = new Intent(Intent.ACTION_EDIT);
        intent.setDataAndType(uri, ContactsContract.Contacts.CONTENT_ITEM_TYPE);
        intent.putExtra("finishActivityOnSaveCompleted", true);
        //add the below line
        intent.addFlags(FLAG_ACTIVITY_CLEAR_TOP);
        activity.startActivityForResult(intent, 1);
    } catch (Exception e) {
        Toast.makeText(activity, "Oops there was a problem trying to open the contact :(", Toast.LENGTH_SHORT).show();
    }
}
 
Example 4
Source Project: shortyz   File: Scrapers.java    License: GNU General Public License v3.0 6 votes vote down vote up
private void postDownloadedNotification(int i, String name, File puzFile) {
    String contentTitle = "Downloaded Puzzle From " + name;

    Intent notificationIntent = new Intent(Intent.ACTION_EDIT, Uri.fromFile(puzFile), context, PlayActivity.class);
    PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);

    Notification not = new NotificationCompat.Builder(context)
            .setSmallIcon(android.R.drawable.stat_sys_download_done)
            .setContentTitle(contentTitle)
            .setContentText(puzFile.getName())
            .setContentIntent(contentIntent)
            .setWhen(System.currentTimeMillis())
            .build();

    if (this.notificationManager != null) {
        this.notificationManager.notify(i, not);
    }
}
 
Example 5
private void postDownloadedNotification(int i, String name, File puzFile) {
    try {
        String contentTitle = "Downloaded " + name;

        Intent notificationIntent = new Intent(Intent.ACTION_EDIT,
                Uri.fromFile(puzFile), context, PlayActivity.class);
        PendingIntent contentIntent = PendingIntent.getActivity(context, 0,
                notificationIntent, 0);

        Notification not = new NotificationCompat.Builder(context, ShortyzApplication.PUZZLE_DOWNLOAD_CHANNEL_ID)
                .setSmallIcon(android.R.drawable.stat_sys_download_done)
                .setContentTitle(contentTitle)
                .setContentText(puzFile.getName())
                .setContentIntent(contentIntent)
                .setWhen(System.currentTimeMillis())
                .build();

        if (this.notificationManager != null) {
            this.notificationManager.notify(i, not);
        }
    } catch(Exception e){
        e.printStackTrace();
    }
}
 
Example 6
Source Project: openlauncher   File: ShareUtil.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Request edit of image (by image editor/viewer - for example to crop image)
 *
 * @param file File that should be edited
 */
public void requestPictureEdit(final 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));
}
 
Example 7
Source Project: react-native-contacts   File: ContactsManager.java    License: MIT License 6 votes vote down vote up
@ReactMethod
public void openExistingContact(ReadableMap contact, Callback callback) {

    String recordID = contact.hasKey("recordID") ? contact.getString("recordID") : null;

    try {
        Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI, recordID);
        Intent intent = new Intent(Intent.ACTION_EDIT);
        intent.setDataAndType(uri, ContactsContract.Contacts.CONTENT_ITEM_TYPE);
        intent.putExtra("finishActivityOnSaveCompleted", true);

        updateContactCallback = callback;
        getReactApplicationContext().startActivityForResult(intent, REQUEST_OPEN_EXISTING_CONTACT, Bundle.EMPTY);

    } catch (Exception e) {
        callback.invoke(e.toString());
    }
}
 
Example 8
Intent getEditAccountIntent() {
    Intent intent = new Intent(Intent.ACTION_EDIT, ContentUris.withAppendedId(
            Imps.Account.CONTENT_URI, mProviderCursor.getLong(ACTIVE_ACCOUNT_ID_COLUMN)));
    intent.putExtra("isSignedIn", isSignedIn(mProviderCursor));
    intent.addCategory(getProviderCategory(mProviderCursor));
    return intent;
}
 
Example 9
private void chooseContactForRingtone(Uri uri) {
    try {
        Intent intent = new Intent(Intent.ACTION_EDIT, uri);
        intent.setClassName(
                "com.ringdroid",
                "com.ringdroid.ChooseContactActivity");
        startActivityForResult(intent, REQUEST_CODE_CHOOSE_CONTACT);
    } catch (Exception e) {
        Log.e("Ringdroid", "Couldn't open Choose Contact window");
    }
}
 
Example 10
public static Intent prepareEditContactIntentWithSipAddress(int id, String sipUri) {
	Intent intent = new Intent(Intent.ACTION_EDIT, Contacts.CONTENT_URI);
	Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, id);
	intent.setData(contactUri);
	
	ArrayList<ContentValues> data = new ArrayList<ContentValues>();
	ContentValues sipAddressRow = new ContentValues();
	sipAddressRow.put(Contacts.Data.MIMETYPE, SipAddress.CONTENT_ITEM_TYPE);
	sipAddressRow.put(SipAddress.SIP_ADDRESS, sipUri);
	data.add(sipAddressRow);
	intent.putParcelableArrayListExtra(Insert.DATA, data);
	
	return intent;
}
 
Example 11
Source Project: opentasks   File: ViewTaskActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onTaskEditRequested(@NonNull Uri taskUri, ContentSet data)
{
    Intent editTaskIntent = new Intent(Intent.ACTION_EDIT);
    editTaskIntent.setData(taskUri);
    if (data != null)
    {
        Bundle extraBundle = new Bundle();
        extraBundle.putParcelable(EditTaskActivity.EXTRA_DATA_CONTENT_SET, data);
        editTaskIntent.putExtra(EditTaskActivity.EXTRA_DATA_BUNDLE, extraBundle);
    }
    startActivity(editTaskIntent);
}
 
Example 12
Source Project: android-apps   File: ResultHandler.java    License: MIT License 5 votes vote down vote up
/**
 * Sends an intent to create a new calendar event by prepopulating the Add Event UI. Older
 * versions of the system have a bug where the event title will not be filled out.
 *
 * @param summary A description of the event
 * @param start   The start time as yyyyMMdd or yyyyMMdd'T'HHmmss or yyyyMMdd'T'HHmmss'Z'
 * @param end     The end time as yyyyMMdd or yyyyMMdd'T'HHmmss or yyyyMMdd'T'HHmmss'Z'
 * @param location a text description of the event location
 * @param description a text description of the event itself
 */
final void addCalendarEvent(String summary,
                            String start,
                            String end,
                            String location,
                            String description) {
  Intent intent = new Intent(Intent.ACTION_EDIT);
  intent.setType("vnd.android.cursor.item/event");
  long startMilliseconds = calculateMilliseconds(start);
  intent.putExtra("beginTime", startMilliseconds);
  boolean allDay = start.length() == 8;
  if (allDay) {
    intent.putExtra("allDay", true);
  }
  long endMilliseconds;
  if (end == null) {
    if (allDay) {
      // + 1 day
      endMilliseconds = startMilliseconds + 24 * 60 * 60 * 1000;
    } else {
      endMilliseconds = startMilliseconds;
    }
  } else {
    endMilliseconds = calculateMilliseconds(end);
  }
  intent.putExtra("endTime", endMilliseconds);
  intent.putExtra("title", summary);
  intent.putExtra("eventLocation", location);
  intent.putExtra("description", description);
  launchIntent(intent);
}
 
Example 13
/**
 * On edit a user, finish this activity and load edit user activity
 *
 * @param user To edited user
 */
@Override
public void onEditUser(User user) {
    Intent intent = new Intent(Intent.ACTION_EDIT, Uri.EMPTY, getApplicationContext(), CreateUserActivity.class);
    intent.putExtra(CreateUserActivity.KEY_USER_ID, user.getId());
    startActivityForResult(intent, 0);
}
 
Example 14
Source Project: opentasks   File: TaskListFragment.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Opens the task editor for the selected Task.
 *
 * @param taskUri
 *         The {@link Uri} of the task.
 */
private void openTaskEditor(final Uri taskUri, final String accountType)
{
    Intent editTaskIntent = new Intent(Intent.ACTION_EDIT);
    editTaskIntent.setData(taskUri);
    editTaskIntent.putExtra(EditTaskActivity.EXTRA_DATA_ACCOUNT_TYPE, accountType);
    startActivity(editTaskIntent);
}
 
Example 15
/**
 * Open activity for contact modifications
 */
 public static void openAppForContactModifications(Activity activity, Contact contact) {
    Intent editIntent = new Intent(Intent.ACTION_EDIT);
    editIntent.setDataAndType(contact.getUri(), ContactsContract.Contacts.CONTENT_ITEM_TYPE);
    // Response in activity
    activity.startActivityForResult(editIntent, MODIFY_CONTACT_RESULT_CODE);
}
 
Example 16
Intent getEditAccountIntent() {
    Intent intent = new Intent(Intent.ACTION_EDIT, ContentUris.withAppendedId(
            Imps.Account.CONTENT_URI, mProviderCursor.getLong(ACTIVE_ACCOUNT_ID_COLUMN)));
    intent.putExtra("isSignedIn", isSignedIn(mProviderCursor));
    intent.addCategory(getProviderCategory(mProviderCursor));
    return intent;
}
 
Example 17
Source Project: opentasks   File: TaskListActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onTaskEditRequested(@NonNull Uri taskUri, ContentSet data)
{
    Intent editTaskIntent = new Intent(Intent.ACTION_EDIT);
    editTaskIntent.setData(taskUri);
    if (data != null)
    {
        Bundle extraBundle = new Bundle();
        extraBundle.putParcelable(EditTaskActivity.EXTRA_DATA_CONTENT_SET, data);
        editTaskIntent.putExtra(EditTaskActivity.EXTRA_DATA_BUNDLE, extraBundle);
    }
    startActivity(editTaskIntent);
}
 
Example 18
Source Project: chuck   File: SQLiteUtils.java    License: Apache License 2.0 4 votes vote down vote up
private static Intent getSQLiteDebuggerAppIntent(String path) {
    Intent intent = new Intent(Intent.ACTION_EDIT);
    intent.setData(Uri.parse("sqlite:" + path));
    return intent;
}
 
Example 19
@Override
public boolean onOptionsItemSelected(final MenuItem menuItem) {
    if (MenuDoubleTabUtil.shouldIgnoreTap()) {
        return false;
    }
    final AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setNegativeButton(getString(R.string.cancel), null);
    switch (menuItem.getItemId()) {
        case android.R.id.home:
            finish();
            break;
        case R.id.action_share_http:
            shareLink(true);
            break;
        case R.id.action_share_uri:
            shareLink(false);
            break;
        case R.id.action_delete_contact:
            builder.setTitle(getString(R.string.action_delete_contact))
                    .setMessage(JidDialog.style(this, R.string.remove_contact_text, contact.getJid().toEscapedString()))
                    .setPositiveButton(getString(R.string.delete),
                            removeFromRoster).create().show();
            break;
        case R.id.action_edit_contact:
            Uri systemAccount = contact.getSystemAccount();
            if (systemAccount == null) {
                quickEdit(contact.getServerName(), R.string.contact_name, value -> {
                    contact.setServerName(value);
                    ContactDetailsActivity.this.xmppConnectionService.pushContactToServer(contact);
                    populateView();
                    return null;
                }, true);
            } else {
                Intent intent = new Intent(Intent.ACTION_EDIT);
                intent.setDataAndType(systemAccount, Contacts.CONTENT_ITEM_TYPE);
                intent.putExtra("finishActivityOnSaveCompleted", true);
                try {
                    startActivity(intent);
                } catch (ActivityNotFoundException e) {
                    Toast.makeText(ContactDetailsActivity.this, R.string.no_application_found_to_view_contact, Toast.LENGTH_SHORT).show();
                }

            }
            break;
        case R.id.action_block:
            BlockContactDialog.show(this, contact);
            break;
        case R.id.action_unblock:
            BlockContactDialog.show(this, contact);
            break;
    }
    return super.onOptionsItemSelected(menuItem);
}
 
Example 20
private void initializeDownload() {
    if (!Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
        showSDCardHelp();
        finish();

        return;
    }

    Uri u = this.getIntent()
                .getData();
    String filename = u.toString();
    filename = filename.substring(filename.lastIndexOf('/') + 1);

    final ProgressDialog dialog = new ProgressDialog(this);
    dialog.setMessage("Downloading...\n" + filename);
    dialog.setCancelable(false);

    OkHttpClient client = new OkHttpClient();

    try {
        Request request = new Request.Builder()
                .url(u.toString())
                .build();

        Response response = client.newCall(request).execute();

        if (response.code() != 200) {
            throw new IOException("Non 200 downloading...");
        }

        InputStream is = response.body().byteStream();
        File puzFile = new File(crosswordsFolder, filename);
        FileOutputStream fos = new FileOutputStream(puzFile);
        copyStream(is, fos);
        fos.close();

        Intent i = new Intent(Intent.ACTION_EDIT, Uri.fromFile(puzFile), this, PlayActivity.class);
        this.startActivity(i);
    } catch (Exception e) {
        e.printStackTrace();

        Toast t = Toast.makeText(this, "Unable to download from\n" + u.toString(), Toast.LENGTH_LONG);
        t.show();
    }

    finish();
}