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:com.visva.voicerecorder.view.fragments.FragmentContact.java

private void editThisContact(int selectedPosition) {
    final Cursor cursor = mAdapter.getCursor();
    if (cursor == null)
        return;/*from  www .  j a va 2s.  c om*/
    cursor.moveToPosition(selectedPosition);

    final Uri uri = Contacts.getLookupUri(cursor.getLong(ContactsQuery.ID),
            cursor.getString(ContactsQuery.LOOKUP_KEY));

    // Standard system edit contact intent
    Intent intent = new Intent(Intent.ACTION_EDIT, uri);

    intent.putExtra("finishActivityOnSaveCompleted", true);

    // Start the edit activity
    startActivity(intent);
}

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

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    validateAction(mAction);/*from  w w w  .  j ava 2s. c  om*/

    // Handle initial actions only when existing state missing
    final boolean hasIncomingState = savedInstanceState != null;

    if (mState == null) {
        // The delta list may not have finished loading before orientation change happens.
        // In this case, there will be a saved state but deltas will be missing.  Reload from
        // database.
        if (Intent.ACTION_EDIT.equals(mAction)) {
            // Either...
            // 1) orientation change but load never finished.
            // or
            // 2) not an orientation change.  data needs to be loaded for first time.
            getLoaderManager().initLoader(LOADER_DATA, null, mDataLoaderListener);
        }
    } else {
        // Orientation change, we already have mState, it was loaded by onCreate
        bindEditors();
    }

    if (!hasIncomingState) {
        if (Intent.ACTION_INSERT.equals(mAction)) {
            selectAccountAndCreateContact();
        }
    }
}

From source file:nl.privacybarometer.privacyvandaag.activity.EditFeedActivity.java

@Override
protected void onDestroy() {
    if (getIntent().getAction().equals(Intent.ACTION_EDIT)) {
        String url = mUrlEditText.getText().toString();
        ContentResolver cr = getContentResolver();

        Cursor cursor = null;//from w w w .  ja v  a  2  s  .  c  o m
        try {
            cursor = getContentResolver().query(FeedColumns.CONTENT_URI, FeedColumns.PROJECTION_ID,
                    FeedColumns.URL + Constants.DB_ARG, new String[] { url }, null);

            if (cursor != null && cursor.moveToFirst()
                    && !getIntent().getData().getLastPathSegment().equals(cursor.getString(0))) {
                Toast.makeText(EditFeedActivity.this, R.string.error_feed_url_exists, Toast.LENGTH_LONG).show();
            } else {
                ContentValues values = new ContentValues();

                if (!url.startsWith(Constants.HTTP_SCHEME) && !url.startsWith(Constants.HTTPS_SCHEME)) {
                    url = Constants.HTTP_SCHEME + url;
                }
                values.put(FeedColumns.URL, url);

                String name = mNameEditText.getText().toString();
                String cookieName = mCookieNameEditText.getText().toString();
                String cookieValue = mCookieValueEditText.getText().toString();

                values.put(FeedColumns.NAME, name.trim().length() > 0 ? name : null);
                values.put(FeedColumns.RETRIEVE_FULLTEXT, mRetrieveFulltextCb.isChecked() ? 1 : null);
                values.put(FeedColumns.COOKIE_NAME, cookieName.trim().length() > 0 ? cookieName : "");
                values.put(FeedColumns.COOKIE_VALUE, cookieValue.trim().length() > 0 ? cookieValue : "");
                final TypedArray selectedValues = getResources()
                        .obtainTypedArray(R.array.settings_keep_time_values);
                values.put(FeedColumns.KEEP_TIME,
                        selectedValues.getInt(mKeepTime.getSelectedItemPosition(), 0));
                values.put(FeedColumns.FETCH_MODE, 0);
                values.putNull(FeedColumns.ERROR);

                cr.update(getIntent().getData(), values, null, null);
            }
        } catch (Exception ignored) {
        } finally {
            if (cursor != null) {
                cursor.close();
            }
        }
    }

    super.onDestroy();
}

From source file:com.money.manager.ex.recurring.transactions.RecurringTransactionListFragment.java

/**
 * start RepeatingTransaction for insert or edit transaction
 *
 * @param billDepositsId Id of the recurring transaction.
 * @param purposeCode       Code that indicates why we are opening the editor.
 *                          example: REQUEST_ADD_REPEATING_TRANSACTION
 *//*  ww w  .ja v  a2s.co m*/
private void startRecurringTransactionEditActivity(Integer billDepositsId, int purposeCode) {
    // create intent, set Bill Deposits ID
    Intent intent = new Intent(getActivity(), RecurringTransactionEditActivity.class);
    // check transId not null
    if (billDepositsId != null) {
        intent.putExtra(RecurringTransactionEditActivity.KEY_BILL_DEPOSITS_ID, billDepositsId);
        intent.setAction(Intent.ACTION_EDIT);
    } else {
        intent.setAction(Intent.ACTION_INSERT);
    }
    // launch activity
    startActivityForResult(intent, purposeCode);
}

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

/**
 * Checks if the requested action is valid.
 *
 * @param action The action to test./*w  w w. j ava2  s . com*/
 * @throws IllegalArgumentException when the action is invalid.
 */
private void validateAction(String action) {
    if (Intent.ACTION_EDIT.equals(action) || Intent.ACTION_INSERT.equals(action)
            || ScContactEditorActivity.ACTION_SAVE_COMPLETED.equals(action)) {
        return;
    }
    throw new IllegalArgumentException(
            "Unknown Action String " + mAction + ". Only support " + Intent.ACTION_EDIT + " or "
                    + Intent.ACTION_INSERT + " or " + ScContactEditorActivity.ACTION_SAVE_COMPLETED);
}

From source file:net.fred.feedex.activity.EditFeedActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    if (mTabHost.getCurrentTab() == 0) {
        menu.findItem(R.id.menu_add_filter).setVisible(false);
    } else {//ww  w. j av  a  2  s.  com
        menu.findItem(R.id.menu_add_filter).setVisible(true);
    }

    if (getIntent() != null && getIntent().getAction().equals(Intent.ACTION_EDIT)) {
        menu.findItem(R.id.menu_validate).setVisible(false); // only in insert mode
    }

    return super.onPrepareOptionsMenu(menu);
}

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

private void resolveAnyConflicts() {
    if (mConflictTables == null || mConflictTables.isEmpty()) {
        scanForConflictAllTables();//  w ww  . ja v a  2  s .  co  m
    }

    if ((mConflictTables != null) && !mConflictTables.isEmpty()) {
        Iterator<String> iterator = mConflictTables.keySet().iterator();
        String tableId = iterator.next();
        mConflictTables.remove(tableId);

        Intent i;
        i = new Intent();
        i.setComponent(new ComponentName(IntentConsts.ResolveConflict.APPLICATION_NAME,
                IntentConsts.ResolveConflict.ACTIVITY_NAME));
        i.setAction(Intent.ACTION_EDIT);
        i.putExtra(IntentConsts.INTENT_KEY_APP_NAME, getAppName());
        i.putExtra(IntentConsts.INTENT_KEY_TABLE_ID, tableId);
        try {
            this.startActivityForResult(i, CONFLICT_ACTIVITY_CODE);
        } catch (ActivityNotFoundException e) {
            Toast.makeText(this,
                    getString(R.string.activity_not_found, IntentConsts.ResolveConflict.ACTIVITY_NAME),
                    Toast.LENGTH_LONG).show();
        }
    }
}

From source file:info.guardianproject.otr.app.im.app.AccountListActivity.java

Intent getEditAccountIntent() {
    Cursor cursor = mAdapter.getCursor();
    Intent intent = new Intent(Intent.ACTION_EDIT,
            ContentUris.withAppendedId(Imps.Account.CONTENT_URI, cursor.getLong(ACTIVE_ACCOUNT_ID_COLUMN)));
    intent.addCategory(ImApp.IMPS_CATEGORY);
    return intent;
}

From source file:com.money.manager.ex.home.HomeFragment.java

@Override
public boolean onContextItemSelected(android.view.MenuItem item) {
    boolean result = false;

    // get account id
    QueryAccountBills account = getSelectedAccount(item);
    if (account == null)
        return false;

    int accountId = account.getAccountId();

    // get the action
    String menuItemTitle = item.getTitle().toString();

    if (menuItemTitle.equalsIgnoreCase(getString(R.string.edit))) {
        Intent intent = new Intent(getActivity(), AccountEditActivity.class);
        intent.putExtra(AccountEditActivity.KEY_ACCOUNT_ID, accountId);
        intent.setAction(Intent.ACTION_EDIT);
        startActivity(intent);//w  w w  .  j  av a 2 s . co  m

        result = true;
    }
    if (menuItemTitle.equalsIgnoreCase(getString(R.string.balance_account))) {
        startBalanceAccount(account);
    }
    if (menuItemTitle.equalsIgnoreCase(getString(R.string.portfolio))) {
        EventBus.getDefault().post(new RequestPortfolioFragmentEvent(accountId));
    }

    return result;
}

From source file:com.money.manager.ex.fragment.AllDataFragment.java

/**
 * start the activity of transaction management
 *
 * @param transId null set if you want to do a new transaction, or transaction id
 *//*ww w. j  a v  a  2s  .c o m*/
private void startCheckingAccountActivity(Integer transId) {
    // create intent, set Account ID
    Intent intent = new Intent(getActivity(), CheckingAccountActivity.class);
    // check transId not null
    if (transId != null) {
        intent.putExtra(CheckingAccountActivity.KEY_TRANS_ID, transId);
        intent.setAction(Intent.ACTION_EDIT);
    } else {
        intent.setAction(Intent.ACTION_INSERT);
    }
    // launch activity
    startActivity(intent);
}