Example usage for android.content Intent ACTION_INSERT_OR_EDIT

List of usage examples for android.content Intent ACTION_INSERT_OR_EDIT

Introduction

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

Prototype

String ACTION_INSERT_OR_EDIT

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

Click Source Link

Document

Activity Action: Pick an existing item, or insert a new item, and then edit it.

Usage

From source file:org.gnucash.android.ui.transaction.ScheduledActionsListFragment.java

/**
 * Opens the transaction editor to enable editing of the transaction
 * @param accountUID GUID of account to which transaction belongs
 * @param transactionUID GUID of transaction to be edited
 *///from   w w w.  j av a  2 s .c o  m
public void openTransactionForEdit(String accountUID, String transactionUID, String scheduledActionUid) {
    Intent createTransactionIntent = new Intent(getActivity(), FormActivity.class);
    createTransactionIntent.setAction(Intent.ACTION_INSERT_OR_EDIT);
    createTransactionIntent.putExtra(UxArgument.FORM_TYPE, FormActivity.FormType.TRANSACTION.name());
    createTransactionIntent.putExtra(UxArgument.SELECTED_ACCOUNT_UID, accountUID);
    createTransactionIntent.putExtra(UxArgument.SELECTED_TRANSACTION_UID, transactionUID);
    createTransactionIntent.putExtra(UxArgument.SCHEDULED_ACTION_UID, scheduledActionUid);
    startActivity(createTransactionIntent);
}

From source file:net.potterpcs.recipebook.RecipeBookActivity.java

public void onNewItemSelected(MenuItem item) {
    Uri uri = new Uri.Builder().scheme("content").authority("net.potterpcs.recipebook").build();
    uri = ContentUris.withAppendedId(uri, -1);
    Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT, uri);
    startActivity(intent);/*  w  ww  . ja  v a2 s  . c  o  m*/
}

From source file:com.android.mms.ui.MailBoxMessageContent.java

public void saveToContact() {
    String address = mMsgFrom;/*from w  w w .  j  a v a 2  s . co m*/
    if (TextUtils.isEmpty(address)) {
        if (LogTag.VERBOSE || Log.isLoggable(LogTag.APP, Log.VERBOSE)) {
            Log.v(TAG, "  saveToContact fail for null address! ");
        }
        return;
    }

    // address must be a single recipient
    Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT);
    intent.setType(Contacts.CONTENT_ITEM_TYPE);
    if (Mms.isEmailAddress(address)) {
        intent.putExtra(ContactsContract.Intents.Insert.EMAIL, address);
    } else {
        intent.putExtra(ContactsContract.Intents.Insert.PHONE, address);
        intent.putExtra(ContactsContract.Intents.Insert.PHONE_TYPE,
                ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE);
    }
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    this.startActivity(intent);
}

From source file:org.gnucash.android.ui.homescreen.WidgetConfigurationActivity.java

/**
 * Updates the widget with id <code>appWidgetId</code> with information from the 
 * account with record ID <code>accountId</code>
  * If the account has been deleted, then a notice is posted in the widget
 * @param appWidgetId ID of the widget to be updated
 *//*from   ww w .j a  v a  2 s . c o m*/
public static void updateWidget(final Context context, int appWidgetId) {
    Log.i("WidgetConfiguration", "Updating widget: " + appWidgetId);
    AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);

    loadOldPreferences(context, appWidgetId);

    SharedPreferences preferences = context.getSharedPreferences("widget:" + appWidgetId, MODE_PRIVATE);
    String bookUID = preferences.getString(UxArgument.BOOK_UID, null);
    String accountUID = preferences.getString(UxArgument.SELECTED_ACCOUNT_UID, null);
    boolean hideAccountBalance = preferences.getBoolean(UxArgument.HIDE_ACCOUNT_BALANCE_IN_WIDGET, false);

    if (bookUID == null || accountUID == null) {
        return;
    }

    AccountsDbAdapter accountsDbAdapter = new AccountsDbAdapter(BookDbHelper.getDatabase(bookUID));

    final Account account;
    try {
        account = accountsDbAdapter.getRecord(accountUID);
    } catch (IllegalArgumentException e) {
        Log.i("WidgetConfiguration", "Account not found, resetting widget " + appWidgetId);
        //if account has been deleted, let the user know
        RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_4x1);
        views.setTextViewText(R.id.account_name, context.getString(R.string.toast_account_deleted));
        views.setTextViewText(R.id.transactions_summary, "");
        //set it to simply open the app
        PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,
                new Intent(context, AccountsActivity.class), 0);
        views.setOnClickPendingIntent(R.id.widget_layout, pendingIntent);
        views.setOnClickPendingIntent(R.id.btn_new_transaction, pendingIntent);
        appWidgetManager.updateAppWidget(appWidgetId, views);
        Editor editor = PreferenceActivity.getActiveBookSharedPreferences().edit(); //PreferenceManager.getDefaultSharedPreferences(context).edit();
        editor.remove(UxArgument.SELECTED_ACCOUNT_UID + appWidgetId);
        editor.apply();
        return;
    }

    final RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_4x1);
    views.setTextViewText(R.id.account_name, account.getName());

    Money accountBalance = accountsDbAdapter.getAccountBalance(accountUID, -1, System.currentTimeMillis());

    if (hideAccountBalance) {
        views.setViewVisibility(R.id.transactions_summary, View.GONE);
    } else {
        views.setTextViewText(R.id.transactions_summary, accountBalance.formattedString(Locale.getDefault()));
        int color = accountBalance.isNegative() ? R.color.debit_red : R.color.credit_green;
        views.setTextColor(R.id.transactions_summary, context.getResources().getColor(color));
    }

    Intent accountViewIntent = new Intent(context, TransactionsActivity.class);
    accountViewIntent.setAction(Intent.ACTION_VIEW);
    accountViewIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
    accountViewIntent.putExtra(UxArgument.SELECTED_ACCOUNT_UID, accountUID);
    accountViewIntent.putExtra(UxArgument.BOOK_UID, bookUID);
    PendingIntent accountPendingIntent = PendingIntent.getActivity(context, appWidgetId, accountViewIntent, 0);
    views.setOnClickPendingIntent(R.id.widget_layout, accountPendingIntent);

    if (accountsDbAdapter.isPlaceholderAccount(accountUID)) {
        views.setOnClickPendingIntent(R.id.btn_view_account, accountPendingIntent);
        views.setViewVisibility(R.id.btn_new_transaction, View.GONE);
    } else {
        Intent newTransactionIntent = new Intent(context, FormActivity.class);
        newTransactionIntent.setAction(Intent.ACTION_INSERT_OR_EDIT);
        newTransactionIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        newTransactionIntent.putExtra(UxArgument.FORM_TYPE, FormActivity.FormType.TRANSACTION.name());
        newTransactionIntent.putExtra(UxArgument.BOOK_UID, bookUID);
        newTransactionIntent.putExtra(UxArgument.SELECTED_ACCOUNT_UID, accountUID);
        PendingIntent pendingIntent = PendingIntent.getActivity(context, appWidgetId, newTransactionIntent, 0);
        views.setOnClickPendingIntent(R.id.btn_new_transaction, pendingIntent);
        views.setViewVisibility(R.id.btn_view_account, View.GONE);
    }

    appWidgetManager.updateAppWidget(appWidgetId, views);
}

From source file:org.gnucash.android.ui.account.AccountsListFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {

    case R.id.menu_add_account:
        Intent addAccountIntent = new Intent(getActivity(), AccountsActivity.class);
        addAccountIntent.setAction(Intent.ACTION_INSERT_OR_EDIT);
        addAccountIntent.putExtra(UxArgument.PARENT_ACCOUNT_ID, mParentAccountId);
        startActivityForResult(addAccountIntent, AccountsActivity.REQUEST_EDIT_ACCOUNT);
        return true;

    case R.id.menu_export:
        showExportDialog();/*ww w  .  j a  v  a2 s. c o  m*/
        return true;

    default:
        return false;
    }
}

From source file:org.gnucash.android.ui.account.AccountsActivity.java

/**
 * Creates an intent which can be used start activity for creating new account
 * @return Intent which can be used to start activity for creating new account
 *///from w w  w  . ja v  a2s.  c  o  m
private Intent createNewAccountIntent() {
    Intent addAccountIntent = new Intent(this, AccountsActivity.class);
    addAccountIntent.setAction(Intent.ACTION_INSERT_OR_EDIT);
    return addAccountIntent;
}

From source file:cx.ring.model.CallContact.java

public Intent getAddNumberIntent() {
    final Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT);
    intent.setType(ContactsContract.Contacts.CONTENT_ITEM_TYPE);

    ArrayList<ContentValues> data = new ArrayList<>();
    ContentValues values = new ContentValues();

    SipUri number = getPhones().get(0).getNumber();
    if (number.isRingId()) {
        values.put(ContactsContract.Data.MIMETYPE, ContactsContract.CommonDataKinds.Im.CONTENT_ITEM_TYPE);
        values.put(ContactsContract.CommonDataKinds.Im.DATA, number.getRawUriString());
        values.put(ContactsContract.CommonDataKinds.Im.PROTOCOL,
                ContactsContract.CommonDataKinds.Im.PROTOCOL_CUSTOM);
        values.put(ContactsContract.CommonDataKinds.Im.CUSTOM_PROTOCOL, "Ring");
    } else {//from   w w  w  .  j a  v  a  2 s  .c  o m
        values.put(ContactsContract.Data.MIMETYPE,
                ContactsContract.CommonDataKinds.SipAddress.CONTENT_ITEM_TYPE);
        values.put(ContactsContract.CommonDataKinds.SipAddress.SIP_ADDRESS, number.getRawUriString());
    }
    data.add(values);
    intent.putParcelableArrayListExtra(ContactsContract.Intents.Insert.DATA, data);
    return intent;
}

From source file:com.android.mms.rcs.FavoriteDetailActivity.java

public void saveToContact() {
    String address = mMsgFrom;//from w  w  w  . jav  a2  s. c  om
    if (TextUtils.isEmpty(address)) {
        if (LogTag.VERBOSE || Log.isLoggable(LogTag.APP, Log.VERBOSE)) {
            Log.v(TAG, "  saveToContact fail for null address! ");
        }
        return;
    }

    // address must be a single recipient
    Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT);
    intent.setType(Contacts.CONTENT_ITEM_TYPE);
    intent.putExtra(ContactsContract.Intents.Insert.PHONE, address);
    intent.putExtra(ContactsContract.Intents.Insert.PHONE_TYPE,
            ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    this.startActivity(intent);
}

From source file:org.gnucash.android.ui.accounts.AccountsListFragment.java

/**
 * Opens a new activity for creating or editing an account.
 * If the <code>accountId</code> &lt; 1, then create else edit the account.
 * @param accountId Long record ID of account to be edited. Pass 0 to create a new account.
 */// w  w w. j a va  2 s.  c o m
public void openCreateOrEditActivity(long accountId) {
    Intent editAccountIntent = new Intent(AccountsListFragment.this.getActivity(), AccountsActivity.class);
    editAccountIntent.setAction(Intent.ACTION_INSERT_OR_EDIT);
    editAccountIntent.putExtra(TransactionsListFragment.SELECTED_ACCOUNT_ID, accountId);
    startActivityForResult(editAccountIntent, REQUEST_EDIT_ACCOUNT);
}

From source file:org.gnucash.android.ui.account.AccountsListFragment.java

/**
 * Opens a new activity for creating or editing an account.
 * If the <code>accountId</code> &lt; 1, then create else edit the account.
 * @param accountId Long record ID of account to be edited. Pass 0 to create a new account.
 *//*w w w.ja  va 2 s . c om*/
public void openCreateOrEditActivity(long accountId) {
    Intent editAccountIntent = new Intent(AccountsListFragment.this.getActivity(), AccountsActivity.class);
    editAccountIntent.setAction(Intent.ACTION_INSERT_OR_EDIT);
    editAccountIntent.putExtra(UxArgument.SELECTED_ACCOUNT_ID, accountId);
    startActivityForResult(editAccountIntent, AccountsActivity.REQUEST_EDIT_ACCOUNT);
}