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.money.manager.ex.home.MainActivity.java

/**
 * Handle the drawer item click. Invoked by the actual click handler.
 * @param item selected DrawerMenuItem/*  ww  w  . j  a v  a2  s . c om*/
 * @return boolean indicating whether the action was handled or not.
 */
public boolean onDrawerMenuAndOptionMenuSelected(DrawerMenuItem item) {
    boolean result = true;
    Intent intent;

    // Recent database?
    if (item.getId() == null && item.getTag() != null) {
        String key = item.getTag().toString();
        DatabaseMetadata selectedDatabase = getDatabases().get(key);
        if (selectedDatabase != null) {
            onOpenDatabaseClick(selectedDatabase);
        }
    }
    if (item.getId() == null)
        return false;

    switch (item.getId()) {
    case R.id.menu_home:
        showFragment(HomeFragment.class);
        break;
    case R.id.menu_sync:
        SyncManager sync = new SyncManager(this);
        sync.triggerSynchronization();
        // re-set the sync timer.
        sync.startSyncServiceHeartbeat();
        break;
    case R.id.menu_open_database:
        openDatabasePicker();
        break;
    case R.id.menu_account:
        showFragment(AccountListFragment.class);
        break;
    case R.id.menu_category:
        showFragment(CategoryListFragment.class);
        break;
    case R.id.menu_currency:
        // Show Currency list.
        intent = new Intent(MainActivity.this, CurrencyListActivity.class);
        //                intent = new Intent(MainActivity.this, CurrencyRecyclerListActivity.class);
        intent.setAction(Intent.ACTION_EDIT);
        startActivity(intent);
        break;
    case R.id.menu_payee:
        showFragment(PayeeListFragment.class);
        break;
    case R.id.menu_recurring_transaction:
        showFragment(RecurringTransactionListFragment.class);
        break;
    case R.id.menu_budgets:
        intent = new Intent(this, BudgetsActivity.class);
        startActivity(intent);
        break;
    case R.id.menu_asset_allocation:
        intent = new Intent(this, AssetAllocationOverviewActivity.class);
        startActivity(intent);
        break;
    case R.id.menu_search_transaction:
        startActivity(new Intent(MainActivity.this, SearchActivity.class));
        break;
    case R.id.menu_report_categories:
        startActivity(new Intent(this, CategoriesReportActivity.class));
        break;
    case R.id.menu_settings:
        startActivity(new Intent(MainActivity.this, SettingsActivity.class));
        break;
    case R.id.menu_reports:
        showReportsSelector(item.getText());
        break;
    case R.id.menu_report_payees:
        startActivity(new Intent(this, PayeesReportActivity.class));
        break;
    case R.id.menu_report_where_money_goes:
        intent = new Intent(this, CategoriesReportActivity.class);
        intent.putExtra(CategoriesReportActivity.REPORT_FILTERS, TransactionTypes.Withdrawal.name());
        intent.putExtra(CategoriesReportActivity.REPORT_TITLE,
                getString(R.string.menu_report_where_money_goes));
        startActivity(intent);
        break;
    case R.id.menu_report_where_money_comes_from:
        intent = new Intent(this, CategoriesReportActivity.class);
        intent.putExtra(CategoriesReportActivity.REPORT_FILTERS, TransactionTypes.Deposit.name());
        intent.putExtra(CategoriesReportActivity.REPORT_TITLE,
                getString(R.string.menu_report_where_money_comes_from));
        startActivity(intent);
        break;
    case R.id.menu_report_income_vs_expenses:
        startActivity(new Intent(this, IncomeVsExpensesActivity.class));
        break;
    case R.id.menu_asset_allocation_overview:
        startActivity(new Intent(this, AssetAllocationReportActivity.class));
        break;
    case R.id.menu_help:
        startActivity(new Intent(MainActivity.this, HelpActivity.class));
        break;
    case R.id.menu_about:
        startActivity(new Intent(MainActivity.this, AboutActivity.class));
        break;
    case R.id.menu_donate:
        startActivity(new Intent(this, DonateActivity.class));
        break;
    default:
        // if no match, return false
        result = false;
    }

    return result;
}

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

@Override
protected void onNewIntent(Intent intent) {
    // Search// w  ww. jav  a 2s  . co  m
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        String query = intent.getStringExtra(SearchManager.QUERY);
        // list.onQueryTextChange(query);
        NotesListFragment list = getLeftFragment();
        if (list != null && list.mSearchView != null) {
            list.mSearchView.setQuery(query, false);
        } else if (list != null) {
            list.onQueryTextSubmit(query);
        }
        // Edit or View a list or a note.
    } else if (Intent.ACTION_EDIT.equals(intent.getAction()) || Intent.ACTION_VIEW.equals(intent.getAction())) {
        handleEditIntent(intent);
    } else if (Intent.ACTION_INSERT.equals(intent.getAction())) {
        handleInsertIntent(intent);
    } else if (Intent.ACTION_SEND.equals(intent.getAction())) {
        handleInsertIntent(intent);
    } else if (getString(R.string.complete_note_broadcast_intent).equals(intent.getAction())) {
        // Sent from lock-screen widget on 4.2 and above.
        // Send complete broadcast and finish
        long noteId = NotesEditorFragment.getIdFromUri(intent.getData());
        // This will complete the note
        if (noteId > -1) {
            Intent bintent = new Intent(this, NotePadBroadcastReceiver.class);
            bintent.setAction(getString(R.string.complete_note_broadcast_intent));
            bintent.putExtra(NotePad.Notes._ID, noteId);
            Log.d(TAG, "Sending complete broadcast");
            sendBroadcast(bintent);

            openNoteFragment(intent);

            // Toast.makeText(this, getString(R.string.completed),
            // Toast.LENGTH_SHORT).show();
        }
    } else {
        // Open a note
        if (noteIdToSelect > -1 && currentContent == CONTENTVIEW.DUAL) {
            Bundle arguments = new Bundle();
            arguments.putLong(NotesEditorFragment.KEYID, noteIdToSelect);
            NotesEditorFragment fragment = new NotesEditorFragment();
            fragment.setArguments(arguments);
            getFragmentManager().beginTransaction().replace(R.id.rightFragment, fragment).commit();
            noteIdToSelect = -1;
        }
    }
}

From source file:com.silentcircle.contacts.group.GroupEditorFragment.java

/**
 * Saves or creates the group based on the mode, and if successful
 * finishes the activity. This actually only handles saving the group name.
 * @return true when successful//from   w  ww  .j a va 2  s  . c  o m
 */
public boolean save() {
    if (!hasValidGroupName() || mStatus != Status.EDITING) {
        return false;
    }

    // If we are about to close the editor - there is no need to refresh the data
    getLoaderManager().destroyLoader(LOADER_EXISTING_MEMBERS);

    // If there are no changes, then go straight to onSaveCompleted()
    if (!hasNameChange() && !hasMembershipChange()) {
        onSaveCompleted(false, mGroupUri);
        return true;
    }

    mStatus = Status.SAVING;

    Activity activity = getActivity();
    // If the activity is not there anymore, then we can't continue with the save process.
    if (activity == null) {
        return false;
    }
    Intent saveIntent = null;
    if (Intent.ACTION_INSERT.equals(mAction)) {
        // Create array of raw contact IDs for contacts to add to the group
        long[] membersToAddArray = convertToArray(mListMembersToAdd);

        // Create the save intent to create the group and add members at the same time
        saveIntent = ScContactSaveService.createNewGroupIntent(activity, mGroupNameView.getText().toString(),
                membersToAddArray, activity.getClass(), GroupEditorActivity.ACTION_SAVE_COMPLETED);
    } else if (Intent.ACTION_EDIT.equals(mAction)) {
        // Create array of raw contact IDs for contacts to add to the group
        long[] membersToAddArray = convertToArray(mListMembersToAdd);

        // Create array of raw contact IDs for contacts to add to the group
        long[] membersToRemoveArray = convertToArray(mListMembersToRemove);

        // Create the update intent (which includes the updated group name if necessary)
        saveIntent = ScContactSaveService.createGroupUpdateIntent(activity, mGroupId, getUpdatedName(),
                membersToAddArray, membersToRemoveArray, activity.getClass(),
                GroupEditorActivity.ACTION_SAVE_COMPLETED);
    } else {
        throw new IllegalStateException("Invalid intent action type " + mAction);
    }
    activity.startService(saveIntent);
    return true;
}

From source file:com.todotxt.todotxttouch.TodoTxtTouch.java

@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private void addToCalendar(List<Task> checkedTasks) {
    Intent intent;/*from  w  ww .j  a va2s  .co  m*/
    String calendarTitle = getString(R.string.calendar_title);
    String calendarDescription = "";

    if (checkedTasks.size() == 1) {
        // Set the task as title
        calendarTitle = checkedTasks.get(0).getText();
    } else {
        // Set the tasks as description
        calendarDescription = selectedTasksAsString(checkedTasks);

    }

    intent = new Intent(android.content.Intent.ACTION_EDIT).setType(Constants.ANDROID_EVENT)
            .putExtra(Events.TITLE, calendarTitle).putExtra(Events.DESCRIPTION, calendarDescription);
    startActivity(intent);
}

From source file:it.geosolutions.android.map.MapsActivity.java

/**
 * Add controls to the mapView and to the Buttons
 * @param savedInstanceState /*w  ww.jav  a2s.co m*/
 */
private void addControls(Bundle savedInstanceState) {
    String action = getIntent().getAction();
    Log.v("MapsActivity", "action: " + action);

    //Coordinate Control
    mapView.addControl(new CoordinateControl(mapView, true));
    List<MapControl> group = new ArrayList<MapControl>();

    // Info Control
    MapInfoControl ic = new MapInfoControl(mapView, this);
    ic.setActivationButton((ImageButton) findViewById(R.id.ButtonInfo));

    mapView.addControl(ic);

    if (!Intent.ACTION_VIEW.equals(action)) {
        Log.v("MapsActivity", "Adding MarkerControl");

        //Marker Control 
        MarkerControl mc = new MarkerControl(mapView);
        // activation button
        ImageButton mcbmb = (ImageButton) findViewById(R.id.ButtonMarker);
        mcbmb.setVisibility(View.VISIBLE);
        mc.setActivationButton(mcbmb);
        // info button  // TODO: do we need this button?
        ImageButton mcib = (ImageButton) findViewById(R.id.marker_info_button);
        mcib.setVisibility(View.VISIBLE);
        mc.setInfoButton(mcib);

        mapView.addControl(mc);
        group.add(mc);
        mc.setGroup(group);
        mc.setMode(MarkerControl.MODE_EDIT);
    }

    //My location Control 
    LocationControl lc = new LocationControl(mapView);
    lc.setActivationButton((ImageButton) findViewById(R.id.ButtonLocation));
    mapView.addControl(lc);

    //create and add group 
    group.add(ic);

    ic.setGroup(group);

    //TODO move this in a control

    //Set modes for controls
    if (Intent.ACTION_VIEW.equals(action)) {
        ic.setMode(MapInfoControl.MODE_VIEW);
    } else if (Intent.ACTION_EDIT.equals(action)) {
        ic.setMode(MapInfoControl.MODE_EDIT);
        //Default edit mode
    } else {
        ic.setMode(MapInfoControl.MODE_EDIT);
    }
    if (savedInstanceState != null) {
        for (MapControl c : mapView.getControls()) {
            c.restoreState(savedInstanceState);
        }
    }

}

From source file:com.googlecode.android_scripting.activity.ScriptManager.java

protected void externalEditor(File file) {
    Intent intent = new Intent(Intent.ACTION_EDIT);
    intent.setDataAndType(Uri.fromFile(file), "text/plain");
    try {//from   ww w  .j av a  2  s  .  c  om
        startActivity(intent);
    } catch (Exception e) {
        Crouton.showText(this, getString(R.string.s_UnableOpeneditor) + e.toString(), Style.ALERT);
    }
}

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

@Override
protected void onPostResume() {
    super.onPostResume();
    // Hijack the app here, after all screens have been resumed,
    // to ensure that all checkpoints and conflicts have been
    // resolved. If they haven't, we branch to the resolution
    // activity./*  w ww  . j a v  a  2 s  .  c  o m*/

    if (mConflictTables == null || mConflictTables.isEmpty()) {
        scanForConflictAllTables();
    }
    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(SYNC_PACKAGE_NAME, SYNC_CONFLICT_ACTIVITY_COMPONENT_NAME));
        i.setAction(Intent.ACTION_EDIT);
        i.putExtra(APP_NAME, getAppName());
        i.putExtra(SYNC_TABLE_ID_PARAMETER, tableId);
        try {
            this.startActivityForResult(i, CONFLICT_ACTIVITY_CODE);
        } catch (ActivityNotFoundException e) {
            Toast.makeText(this, getString(R.string.activity_not_found, SYNC_CONFLICT_ACTIVITY_COMPONENT_NAME),
                    Toast.LENGTH_LONG).show();
        }
    }
}

From source file:sharedcode.turboeditor.activity.MainActivity.java

/**
 * Parses the intent/*from  www  . j av a 2  s.co  m*/
 */
private void parseIntent(Intent intent) {
    final String action = intent.getAction();
    final String type = intent.getType();

    if (Intent.ACTION_VIEW.equals(action) || Intent.ACTION_EDIT.equals(action)
            || Intent.ACTION_PICK.equals(action) && type != null) {
        // Post event
        onEvent(new EventBusEvents.NewFileToOpen(new File(intent.getData().getPath())));
    } else if (Intent.ACTION_SEND.equals(action) && type != null) {
        if ("text/plain".equals(type)) {
            onEvent(new EventBusEvents.NewFileToOpen(intent.getStringExtra(Intent.EXTRA_TEXT)));
        }
    }
}

From source file:cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.ui.editor.TaskDetailFragment.java

void fixIntent() {
    stateId = mTask._id;/*from w  ww.j a  v a 2  s .co m*/
    stateListId = mTask.dblist;

    if (getActivity() == null)
        return;

    final Intent orgIntent = getActivity().getIntent();
    if (orgIntent == null || orgIntent.getAction() == null
            || !orgIntent.getAction().equals(Intent.ACTION_INSERT))
        return;

    if (mTask == null || mTask._id < 1)
        return;

    final Intent intent = new Intent().setAction(Intent.ACTION_EDIT)
            .setClass(getActivity(), ActivityEditor.class).setData(mTask.getUri())
            .putExtra(TaskDetailFragment.ARG_ITEM_LIST_ID, mTask.dblist);

    getActivity().setIntent(intent);
}

From source file:info.androidhive.slidingmenu.Games.WordSearch.wordsearch.view.WordSearchActivity.java

/** when menu button option selected */
@Override//from  w  w  w.j av  a2  s .c  om
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_scores:
        this.showDialog(DIALOG_ID_HIGH_SCORES_LOCAL_SHOW);
        return true;
    case R.id.menu_options:
        startActivity(new Intent(this, WordSearchPreferences.class));
        return true;
    case R.id.menu_new:
        control.newWordSearch();
        return true;
    case R.id.menu_custom: {
        Intent intent = new Intent(Intent.ACTION_EDIT, WordDictionaryProvider.Word.CONTENT_URI);
        intent.setType(WordDictionaryProvider.Word.CONTENT_TYPE);
        this.startActivity(intent);
        return true;
    }
    case R.id.menu_tutorial: {
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setClass(this, TutorialActivity.class);
        startActivity(intent);
        return true;
    }
    case R.id.menu_donate: {
        this.showDialog(DIALOG_ID_DONATE);
        return true;
    }
    default:
        return super.onOptionsItemSelected(item);
    }
}