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:edu.cens.loci.ui.PlaceListActivity.java

@Override
protected void onListItemClick(ListView l, View v, int position, long id) {

    Intent intent;//from   w  w  w  . j av  a  2  s .  c o m
    Bundle extras;

    switch (mMode) {
    case MODE_VIEW:
        //Log.i(TAG, "onListItemClick : position=" + position + ", id=" + id);
        if ((mFilterState & FILTER_STATE_SUGGESTED) != 0) {
            if (position == 0) {
                intent = new Intent(Constants.Intents.UI.ACTION_VIEW_SUGGESTED_GPS_PLACES);
                Toast.makeText(this, "Not supported yet", Toast.LENGTH_SHORT).show();
                return;
            } else {
                intent = new Intent(Intent.ACTION_VIEW, getSelectedUri(position - 1));
            }
        } else {
            intent = new Intent(Intent.ACTION_VIEW, getSelectedUri(position));
        }
        startActivity(intent);
        break;
    case MODE_INSERT:
        extras = getIntent().getExtras();
        if (position == 0) {
            intent = new Intent(Intent.ACTION_INSERT, Places.CONTENT_URI);
            if (extras.containsKey(UI.LIST_ORDER_EXTRA_WIFI_KEY)
                    && extras.containsKey(UI.LIST_ORDER_EXTRA_WIFI_TIME_KEY)) {
                String wifiJson = getIntent().getExtras().getString(UI.LIST_ORDER_EXTRA_WIFI_KEY);
                String timestamp = getIntent().getExtras().getString(UI.LIST_ORDER_EXTRA_WIFI_TIME_KEY);
                intent.putExtra(Insert.WIFI_FINTERPRINT, wifiJson);
                intent.putExtra(Insert.TIME, timestamp);
            }
            //intent = new Intent(Intent.ACTION_EDIT, getSelectedUri(position));
        } else {
            intent = new Intent(Intent.ACTION_EDIT, getSelectedUri(position - 1));
            if (extras.containsKey(UI.LIST_ORDER_EXTRA_WIFI_KEY)
                    && extras.containsKey(UI.LIST_ORDER_EXTRA_WIFI_TIME_KEY)) {
                String wifiJson = getIntent().getExtras().getString(UI.LIST_ORDER_EXTRA_WIFI_KEY);
                String timestamp = getIntent().getExtras().getString(UI.LIST_ORDER_EXTRA_WIFI_TIME_KEY);
                intent.putExtra(Insert.WIFI_FINTERPRINT, wifiJson);
                intent.putExtra(Insert.TIME, timestamp);
            }
        }
        //extras = getIntent().getExtras();
        //if (extras != null) 
        //   intent.putExtras(extras);

        startActivityForResult(intent, SUBACTIVITY_NEW_PLACE);
        break;
    case MODE_REGISTER_SUGGESTED:
        extras = getIntent().getExtras();
        if (position == 0) {
            intent = new Intent(Intents.UI.ACTION_CREATE_FROM_SUGGESTED_PLACE, getIntent().getData());
        } else {
            //intent = new Intent(Intents.UI.ACTION_ADDTO_FROM_SUGESTED_PLACE, getIntent().getData());
            //extras.putLong(Intents.UI.SELECTED_PLACE_ID_EXTRA_KEY, getSelectedPlaceId(position-1));
            intent = new Intent(Intents.UI.ACTION_ADDTO_FROM_SUGESTED_PLACE, getSelectedUri(position - 1));
            extras.putLong(Intents.UI.SELECTED_PLACE_ID_EXTRA_KEY, ContentUris.parseId(getIntent().getData()));
        }
        if (extras != null)
            intent.putExtras(extras);

        startActivityForResult(intent, SUBACTIVITY_NEW_PLACE);
        break;
    case MODE_PICK:
        final Uri uri = getSelectedUri(position);
        intent = new Intent();
        setResult(RESULT_OK, intent.setData(uri));
        finish();
        break;
    }

}

From source file:com.money.manager.ex.currency.list.CurrencyListFragment.java

@Override
public void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);

    // Show context menu only if we are displaying the list of currencies
    // but not in selection mode.
    if (mAction.equals(Intent.ACTION_EDIT)) {
        getActivity().openContextMenu(v);
    } else {//from w  ww . jav  a2  s .  c  o  m
        // we are picking a currency. Select one.
        setResultAndFinish();
    }
}

From source file:net.reichholf.dreamdroid.fragment.ProfileListFragment.java

/**
 * Opens a <code>ProfileEditActivity</code> for creating a new profile
 *//*from   w w w.j a v a 2s  .co m*/
private void createProfile() {
    Bundle args = new Bundle();
    args.putString("action", Intent.ACTION_EDIT);

    Fragment f = new ProfileEditFragment();
    f.setArguments(args);
    f.setTargetFragment(this, Statics.REQUEST_EDIT_PROFILE);
    getMultiPaneHandler().showDetails(f, true);
}

From source file:com.ifeel.mt.ui.ContactDetailFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    // When "edit" menu option selected
    if (item.getItemId() == R.id.menu_edit_contact) {
        // Standard system edit contact intent
        Intent intent = new Intent(Intent.ACTION_EDIT, mContactUri);

        // Because of an issue in Android 4.0 (API level 14), clicking Done or Back in the
        // People app doesn't return the user to your app; instead, it displays the People
        // app's contact list. A workaround, introduced in Android 4.0.3 (API level 15) is
        // to set a special flag in the extended data for the Intent you send to the People
        // app. The issue is does not appear in versions prior to Android 4.0. You can use
        // the flag with any version of the People app; if the workaround isn't needed,
        // the flag is ignored.
        intent.putExtra("finishActivityOnSaveCompleted", true);

        // Start the edit activity
        startActivity(intent);//from w  w  w .  j av a 2s  . co m
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:android.com.example.contactslist.ui.ContactDetailFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    // When "edit" menu option selected
    case R.id.menu_edit_contact:
        // Standard system edit contact intent
        Intent intent = new Intent(Intent.ACTION_EDIT, mContactUri);

        // Because of an issue in Android 4.0 (API level 14), clicking Done or Back in the
        // People app doesn't return the user to your app; instead, it displays the People
        // app's contact list. A workaround, introduced in Android 4.0.3 (API level 15) is
        // to set a special flag in the extended data for the Intent you send to the People
        // app. The issue is does not appear in versions prior to Android 4.0. You can use
        // the flag with any version of the People app; if the workaround isn't needed,
        // the flag is ignored.
        intent.putExtra("finishActivityOnSaveCompleted", true);

        // Start the edit activity
        startActivity(intent);/*w  ww.j ava  2 s .  c  o  m*/
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:net.etuldan.sparss.fragment.EditFeedsListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_edit_feed_list, container, false);

    mListView = (DragNDropExpandableListView) rootView.findViewById(android.R.id.list);
    mListView.setFastScrollEnabled(true);
    mListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    mListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
        @Override//from  www  .j a  v a 2s. c o  m
        public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition,
                long id) {
            startActivity(new Intent(Intent.ACTION_EDIT).setData(FeedColumns.CONTENT_URI(id)));
            return true;
        }
    });
    mListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
        @Override
        public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
            if (v.findViewById(R.id.indicator).getVisibility() != View.VISIBLE) { // This is no a real group
                startActivity(new Intent(Intent.ACTION_EDIT).setData(FeedColumns.CONTENT_URI(id)));
                return true;
            }
            return false;
        }
    });
    mListView.setOnItemLongClickListener(new OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            ActionBarActivity activity = (ActionBarActivity) getActivity();
            if (activity != null) {
                String title = ((TextView) view.findViewById(android.R.id.text1)).getText().toString();
                Matcher m = Pattern.compile("(.*) \\([0-9]+\\)$").matcher(title);
                if (m.matches()) {
                    title = m.group(1);
                }

                long feedId = mListView.getItemIdAtPosition(position);
                ActionMode actionMode;
                if (view.findViewById(R.id.indicator).getVisibility() == View.VISIBLE) { // This is a group
                    actionMode = activity.startSupportActionMode(mGroupActionModeCallback);
                } else { // This is a feed
                    actionMode = activity.startSupportActionMode(mFeedActionModeCallback);
                }
                actionMode.setTag(new Pair<>(feedId, title));

                mListView.setItemChecked(position, true);
            }
            return true;
        }
    });

    mListView.setAdapter(new FeedsCursorAdapter(getActivity(), FeedColumns.GROUPS_CONTENT_URI));

    mListView.setDragNDropListener(new DragNDropListener() {
        boolean fromHasGroupIndicator = false;

        @Override
        public void onStopDrag(View itemView) {
        }

        @Override
        public void onStartDrag(View itemView) {
            fromHasGroupIndicator = itemView.findViewById(R.id.indicator).getVisibility() == View.VISIBLE;
        }

        @Override
        public void onDrop(final int flatPosFrom, final int flatPosTo) {
            final boolean fromIsGroup = ExpandableListView.getPackedPositionType(mListView
                    .getExpandableListPosition(flatPosFrom)) == ExpandableListView.PACKED_POSITION_TYPE_GROUP;
            final boolean toIsGroup = ExpandableListView.getPackedPositionType(mListView
                    .getExpandableListPosition(flatPosTo)) == ExpandableListView.PACKED_POSITION_TYPE_GROUP;

            final boolean fromIsFeedWithoutGroup = fromIsGroup && !fromHasGroupIndicator;

            View toView = mListView.getChildAt(flatPosTo - mListView.getFirstVisiblePosition());
            boolean toIsFeedWithoutGroup = toIsGroup
                    && toView.findViewById(R.id.indicator).getVisibility() != View.VISIBLE;

            final long packedPosTo = mListView.getExpandableListPosition(flatPosTo);
            final int packedGroupPosTo = ExpandableListView.getPackedPositionGroup(packedPosTo);

            if ((fromIsFeedWithoutGroup || !fromIsGroup) && toIsGroup && !toIsFeedWithoutGroup) {
                new AlertDialog.Builder(getActivity()) //
                        .setTitle(R.string.to_group_title) //
                        .setMessage(R.string.to_group_message) //
                        .setPositiveButton(R.string.to_group_into, new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                ContentValues values = new ContentValues();
                                values.put(FeedColumns.PRIORITY, 1);
                                values.put(FeedColumns.GROUP_ID, mListView.getItemIdAtPosition(flatPosTo));

                                ContentResolver cr = getActivity().getContentResolver();
                                cr.update(FeedColumns.CONTENT_URI(mListView.getItemIdAtPosition(flatPosFrom)),
                                        values, null, null);
                                cr.notifyChange(FeedColumns.GROUPS_CONTENT_URI, null);
                            }
                        }).setNegativeButton(R.string.to_group_above, new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                moveItem(fromIsGroup, toIsGroup, fromIsFeedWithoutGroup, packedPosTo,
                                        packedGroupPosTo, flatPosFrom);
                            }
                        }).show();
            } else {
                moveItem(fromIsGroup, toIsGroup, fromIsFeedWithoutGroup, packedPosTo, packedGroupPosTo,
                        flatPosFrom);
            }
        }

        @Override
        public void onDrag(int x, int y, ListView listView) {
        }
    });

    return rootView;
}

From source file:com.viktorrudometkin.burramys.fragment.EditFeedsListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_edit_feed_list, container, false);

    mListView = (DragNDropExpandableListView) rootView.findViewById(android.R.id.list);
    mListView.setFastScrollEnabled(true);
    mListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    mListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
        @Override/*ww  w. j a va2 s  .c o m*/
        public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition,
                long id) {
            startActivity(new Intent(Intent.ACTION_EDIT).setData(FeedColumns.CONTENT_URI(id)));
            return true;
        }
    });
    mListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
        @Override
        public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
            if (v.findViewById(R.id.indicator).getVisibility() != View.VISIBLE) { // This is no a real group
                startActivity(new Intent(Intent.ACTION_EDIT).setData(FeedColumns.CONTENT_URI(id)));
                return true;
            }
            return false;
        }
    });
    mListView.setOnItemLongClickListener(new OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            AppCompatActivity activity = (AppCompatActivity) getActivity();
            if (activity != null) {
                String title = ((TextView) view.findViewById(android.R.id.text1)).getText().toString();
                Matcher m = Pattern.compile("(.*) \\([0-9]+\\)$").matcher(title);
                if (m.matches()) {
                    title = m.group(1);
                }

                long feedId = mListView.getItemIdAtPosition(position);
                ActionMode actionMode;
                if (view.findViewById(R.id.indicator).getVisibility() == View.VISIBLE) { // This is a group
                    actionMode = activity.startSupportActionMode(mGroupActionModeCallback);
                } else { // This is a feed
                    actionMode = activity.startSupportActionMode(mFeedActionModeCallback);
                }
                actionMode.setTag(new Pair<>(feedId, title));

                mListView.setItemChecked(position, true);
            }
            return true;
        }
    });

    mListView.setAdapter(new FeedsCursorAdapter(getActivity(), FeedColumns.GROUPS_CONTENT_URI));

    mListView.setDragNDropListener(new DragNDropListener() {
        boolean fromHasGroupIndicator = false;

        @Override
        public void onStopDrag(View itemView) {
        }

        @Override
        public void onStartDrag(View itemView) {
            fromHasGroupIndicator = itemView.findViewById(R.id.indicator).getVisibility() == View.VISIBLE;
        }

        @Override
        public void onDrop(final int flatPosFrom, final int flatPosTo) {
            final boolean fromIsGroup = ExpandableListView.getPackedPositionType(mListView
                    .getExpandableListPosition(flatPosFrom)) == ExpandableListView.PACKED_POSITION_TYPE_GROUP;
            final boolean toIsGroup = ExpandableListView.getPackedPositionType(mListView
                    .getExpandableListPosition(flatPosTo)) == ExpandableListView.PACKED_POSITION_TYPE_GROUP;

            final boolean fromIsFeedWithoutGroup = fromIsGroup && !fromHasGroupIndicator;

            View toView = mListView.getChildAt(flatPosTo - mListView.getFirstVisiblePosition());
            boolean toIsFeedWithoutGroup = toIsGroup
                    && toView.findViewById(R.id.indicator).getVisibility() != View.VISIBLE;

            final long packedPosTo = mListView.getExpandableListPosition(flatPosTo);
            final int packedGroupPosTo = ExpandableListView.getPackedPositionGroup(packedPosTo);

            if ((fromIsFeedWithoutGroup || !fromIsGroup) && toIsGroup && !toIsFeedWithoutGroup) {
                new AlertDialog.Builder(getActivity()) //
                        .setTitle(R.string.to_group_title) //
                        .setMessage(R.string.to_group_message) //
                        .setPositiveButton(R.string.to_group_into, new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                ContentValues values = new ContentValues();
                                values.put(FeedColumns.PRIORITY, 1);
                                values.put(FeedColumns.GROUP_ID, mListView.getItemIdAtPosition(flatPosTo));

                                ContentResolver cr = getActivity().getContentResolver();
                                cr.update(FeedColumns.CONTENT_URI(mListView.getItemIdAtPosition(flatPosFrom)),
                                        values, null, null);
                                cr.notifyChange(FeedColumns.GROUPS_CONTENT_URI, null);
                            }
                        }).setNegativeButton(R.string.to_group_above, new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                moveItem(fromIsGroup, toIsGroup, fromIsFeedWithoutGroup, packedPosTo,
                                        packedGroupPosTo, flatPosFrom);
                            }
                        }).show();
            } else {
                moveItem(fromIsGroup, toIsGroup, fromIsFeedWithoutGroup, packedPosTo, packedGroupPosTo,
                        flatPosFrom);
            }
        }

        @Override
        public void onDrag(int x, int y, ListView listView) {
        }
    });

    return rootView;
}

From source file:com.appsimobile.appsii.module.search.SearchController.java

@Override
public void onEditSelected(BaseContactInfo entry) {
    Uri uri = entry.mContactLookupUri;//ww w . j  av  a 2 s  .c  o  m
    Intent intent = new Intent(Intent.ACTION_EDIT, uri);
    track(AnalyticsManager.ACTION_EDIT_ITEM, AnalyticsManager.CATEGORY_SEARCH);
    getContext().startActivity(intent);
    SearchSuggestionUtils.getInstance(getContext()).saveQuery(mQuery);
}

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

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;
}

From source file:com.app.uafeed.activity.EditFeedActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    UiUtils.setPreferenceTheme(this);
    super.onCreate(savedInstanceState);

    getActionBar().setDisplayHomeAsUpEnabled(true);

    setContentView(R.layout.activity_feed_edit);
    setResult(RESULT_CANCELED);/* w w w .j  a  v  a 2  s  .  c o m*/

    Intent intent = getIntent();

    mTabHost = (TabHost) findViewById(R.id.tabHost);
    mNameEditText = (EditText) findViewById(R.id.feed_title);
    mUrlEditText = (EditText) findViewById(R.id.feed_url);
    mRetrieveFulltextCb = (CheckBox) findViewById(R.id.retrieve_fulltext);
    mFiltersListView = (ListView) findViewById(android.R.id.list);
    View tabWidget = findViewById(android.R.id.tabs);
    View buttonLayout = findViewById(R.id.button_layout);

    mTabHost.setup();
    mTabHost.addTab(mTabHost.newTabSpec("feedTab").setIndicator(getString(R.string.tab_feed_title))
            .setContent(R.id.feed_tab));
    mTabHost.addTab(mTabHost.newTabSpec("filtersTab").setIndicator(getString(R.string.tab_filters_title))
            .setContent(R.id.filters_tab));

    mTabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() {
        @Override
        public void onTabChanged(String s) {
            invalidateOptionsMenu();
        }
    });

    if (savedInstanceState != null) {
        mTabHost.setCurrentTab(savedInstanceState.getInt(STATE_CURRENT_TAB));
    }

    if (intent.getAction().equals(Intent.ACTION_INSERT) || intent.getAction().equals(Intent.ACTION_SEND)) {
        setTitle(R.string.new_feed_title);

        tabWidget.setVisibility(View.GONE);

        if (intent.hasExtra(Intent.EXTRA_TEXT)) {
            mUrlEditText.setText(intent.getStringExtra(Intent.EXTRA_TEXT));
        }
    } else if (intent.getAction().equals(Intent.ACTION_EDIT)) {
        setTitle(R.string.edit_feed_title);

        buttonLayout.setVisibility(View.GONE);

        mFiltersCursorAdapter = new FiltersCursorAdapter(this, null);
        mFiltersListView.setAdapter(mFiltersCursorAdapter);
        mFiltersListView.setOnItemLongClickListener(new OnItemLongClickListener() {
            @Override
            public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
                startActionMode(mFilterActionModeCallback);
                mFiltersCursorAdapter.setSelectedFilter(position);
                mFiltersListView.invalidateViews();
                return true;
            }
        });

        getLoaderManager().initLoader(0, null, this);

        if (savedInstanceState == null) {
            Cursor cursor = getContentResolver().query(intent.getData(), FEED_PROJECTION, null, null, null);

            if (cursor.moveToNext()) {
                mPreviousName = cursor.getString(0);
                mNameEditText.setText(mPreviousName);
                mUrlEditText.setText(cursor.getString(1));
                mRetrieveFulltextCb.setChecked(cursor.getInt(2) == 1);
                cursor.close();
            } else {
                cursor.close();
                Toast.makeText(EditFeedActivity.this, R.string.error, Toast.LENGTH_SHORT).show();
                finish();
            }
        }
    }
}