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:co.nerdart.ourss.activity.EditFeedActivity.java

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

    ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);

    setContentView(R.layout.feed_edit);/*  w  w  w  . java  2  s . c  o  m*/
    setResult(RESULT_CANCELED);

    Intent intent = getIntent();

    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 filtersLayout = findViewById(R.id.filters_layout);
    View buttonLayout = findViewById(R.id.button_layout);

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

        filtersLayout.setVisibility(View.GONE);

        if (intent.hasExtra(Intent.EXTRA_TEXT)) {
            mUrlEditText.setText(intent.getStringExtra(Intent.EXTRA_TEXT));
        }

        restoreInstanceState(savedInstanceState);
    } 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 (!restoreInstanceState(savedInstanceState)) {
            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();
                Crouton.makeText(EditFeedActivity.this, R.string.error, Style.INFO);
                finish();
            }
        }
    }
}

From source file:edu.mit.mobile.android.livingpostcards.CardListFragment.java

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    final Uri item = ContentUris.withAppendedId(mCards, id);
    final Cursor c = mAdapter.getCursor();
    c.moveToPosition(position);/* w w w  . j  a v a2s .co  m*/
    if (Card.isDraft(c)) {
        startActivity(new Intent(Intent.ACTION_EDIT, item));
    } else {
        startActivity(new Intent(Intent.ACTION_VIEW, item));
    }
}

From source file:at.jclehner.rxdroid.DrugEditFragment.java

@Override
public void onResume() {
    super.onResume();

    Intent intent = getActivity().getIntent();
    String action = intent.getAction();

    Drug drug = null;//from   w ww .  ja v a 2 s.com

    mWrapper = new DrugWrapper();
    mFocusOnCurrentSupply = false;

    if (Intent.ACTION_EDIT.equals(action)) {
        final int drugId = intent.getIntExtra(DrugEditActivity2.EXTRA_DRUG_ID, -1);
        if (drugId == -1)
            throw new IllegalStateException("ACTION_EDIT requires EXTRA_DRUG_ID");

        drug = Drug.get(drugId);

        if (LOGV)
            Util.dumpObjectMembers(TAG, Log.VERBOSE, drug, "drug");

        mWrapper.set(drug);
        mDrugHash = drug.hashCode();
        mIsEditing = true;

        if (intent.getBooleanExtra(DrugEditActivity2.EXTRA_FOCUS_ON_CURRENT_SUPPLY, false))
            mFocusOnCurrentSupply = true;

        setActivityTitle(drug.getName());
    } else if (Intent.ACTION_INSERT.equals(action)) {
        mIsEditing = false;
        mWrapper.set(new Drug());
        setActivityTitle(R.string._title_new_drug);
    } else
        throw new IllegalArgumentException("Unhandled action " + action);

    if (mWrapper.refillSize == 0)
        mWrapper.currentSupply = Fraction.ZERO;

    OTPM.mapToPreferenceHierarchy(getPreferenceScreen(), mWrapper);
    getPreferenceScreen().setOnPreferenceChangeListener(mListener);

    if (!mIsEditing) {
        final Preference p = findPreference("active");
        if (p != null)
            p.setEnabled(false);
    }

    if (mWrapper.refillSize == 0) {
        final Preference p = findPreference("currentSupply");
        if (p != null)
            p.setEnabled(false);
    }

    if (mFocusOnCurrentSupply) {
        Log.i(TAG, "Will focus on current supply preference");
        performPreferenceClick("currentSupply");
    }

    getActivity().supportInvalidateOptionsMenu();
}

From source file:com.android.music.TrackBrowserFragment.java

/** Called when the activity is first created. */

@Override/*  w  w w.j  a  v  a  2 s.c o m*/
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    View view = inflater.inflate(R.layout.media_picker_activity, null);

    Intent intent = getActivity().getIntent();
    /*if (intent != null) {
     if (intent.getBooleanExtra("withtabs", false)) {
        getActivity().requestWindowFeature(Window.FEATURE_NO_TITLE);
     }
    }*/
    getActivity().setVolumeControlStream(AudioManager.STREAM_MUSIC);
    if (savedInstanceState != null) {
        mSelectedId = savedInstanceState.getLong("selectedtrack");
        mAlbumId = savedInstanceState.getString("album");
        mArtistId = savedInstanceState.getString("artist");
        mPlaylist = savedInstanceState.getString("playlist");
        mGenre = savedInstanceState.getString("genre");
        mEditMode = savedInstanceState.getBoolean("editmode", false);
    } else {
        mAlbumId = intent.getStringExtra("album");
        // If we have an album, show everything on the album, not just stuff
        // by a particular artist.
        mArtistId = intent.getStringExtra("artist");
        mPlaylist = intent.getStringExtra("playlist");
        mGenre = intent.getStringExtra("genre");
        mEditMode = intent.getAction().equals(Intent.ACTION_EDIT);
    }

    mCursorCols = new String[] { MediaStore.Audio.Media._ID, MediaStore.Audio.Media.TITLE,
            MediaStore.Audio.Media.DATA, MediaStore.Audio.Media.ALBUM, MediaStore.Audio.Media.ARTIST,
            MediaStore.Audio.Media.ARTIST_ID, MediaStore.Audio.Media.DURATION };
    mPlaylistMemberCols = new String[] { MediaStore.Audio.Playlists.Members._ID, MediaStore.Audio.Media.TITLE,
            MediaStore.Audio.Media.DATA, MediaStore.Audio.Media.ALBUM, MediaStore.Audio.Media.ARTIST,
            MediaStore.Audio.Media.ARTIST_ID, MediaStore.Audio.Media.DURATION,
            MediaStore.Audio.Playlists.Members.PLAY_ORDER, MediaStore.Audio.Playlists.Members.AUDIO_ID,
            MediaStore.Audio.Media.IS_MUSIC };

    //mUseLastListPos = MusicUtils.updateButtonBar(getActivity(), R.id.songtab);
    mTrackList = (ListView) view.findViewById(android.R.id.list);
    mTrackList.setOnCreateContextMenuListener(this);
    mTrackList.setCacheColorHint(0);
    if (mEditMode) {
        ((TouchInterceptor) mTrackList).setDropListener(mDropListener);
        ((TouchInterceptor) mTrackList).setRemoveListener(mRemoveListener);
        mTrackList.setDivider(null);
        mTrackList.setSelector(R.drawable.list_selector_background);
    } else {
        mTrackList.setTextFilterEnabled(true);
    }
    mAdapter = (TrackListAdapter) getActivity().getLastNonConfigurationInstance();

    if (mAdapter != null) {
        mAdapter.setActivity(this);
        mTrackList.setAdapter(mAdapter);
    }
    mToken = MusicUtils.bindToService(getActivity(), this);

    // don't set the album art until after the view has been layed out
    mTrackList.post(new Runnable() {

        public void run() {
            setAlbumArtBackground();
        }
    });

    // mTrackList.dispatchKeyEvent();

    mTrackList.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            // TODO Auto-generated method stub
            if (mTrackCursor.getCount() == 0) {
                return;
            }
            // When selecting a track from the queue, just jump there instead of
            // reloading the queue. This is both faster, and prevents accidentally
            // dropping out of party shuffle.
            if (mTrackCursor instanceof NowPlayingCursor) {
                if (MusicUtils.sService != null) {
                    try {
                        MusicUtils.sService.setQueuePosition(position);
                        return;
                    } catch (RemoteException ex) {
                    }
                }
            }
            MusicUtils.playAll(getActivity(), mTrackCursor, position);

        }
    });

    return view;
}

From source file:edu.mit.mobile.android.livingpostcards.CardViewActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.share:
        send();/*ww w .  j a v  a 2s .c  om*/
        return true;

    case android.R.id.home: {
        NavUtils.navigateUpFromSameTask(this);
    }
        return true;

    case R.id.edit:
        startActivity(new Intent(Intent.ACTION_EDIT, mCard));
        return true;

    case R.id.delete:
        startActivityForResult(new Intent(Intent.ACTION_DELETE, mCard), REQUEST_DELETE);
        return true;

    default:
        return false;
    }
}

From source file:freed.viewer.screenslide.ScreenSlideFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    view = inflater.inflate(layout.freedviewer_screenslide_fragment, container, false);

    mImageThumbSize = getResources().getDimensionPixelSize(dimen.image_thumbnail_size);
    activityInterface = (ActivityInterface) getActivity();

    // Instantiate a ViewPager and a PagerAdapter.
    mPager = (ViewPager) view.findViewById(id.pager);
    topbar = (LinearLayout) view.findViewById(id.top_bar);
    histogram = (MyHistogram) view.findViewById(id.screenslide_histogram);

    closeButton = (Button) view.findViewById(id.button_closeView);
    closeButton.setOnClickListener(new View.OnClickListener() {
        @Override/*w  w w  . j a  va 2s  .  c  o m*/
        public void onClick(View v) {
            if (thumbclick != null) {
                thumbclick.onThumbClick(mPager.getCurrentItem(), view);
                mPager.setCurrentItem(0);
            } else
                getActivity().finish();
        }
    });

    bottombar = (LinearLayout) view.findViewById(id.bottom_bar);

    exifinfo = (LinearLayout) view.findViewById(id.exif_info);
    exifinfo.setVisibility(View.GONE);
    iso = (TextView) view.findViewById(id.textView_iso);
    iso.setText("");
    shutter = (TextView) view.findViewById(id.textView_shutter);
    shutter.setText("");
    focal = (TextView) view.findViewById(id.textView_focal);
    focal.setText("");
    fnumber = (TextView) view.findViewById(id.textView_fnumber);
    fnumber.setText("");
    filename = (TextView) view.findViewById(id.textView_filename);

    play = (Button) view.findViewById(id.button_play);
    play.setVisibility(View.GONE);
    play.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (folder_to_show == null)
                return;
            if (!folder_to_show.getFile().getName().endsWith(FileEnding.RAW)
                    || !folder_to_show.getFile().getName().endsWith(FileEnding.BAYER)) {
                Uri uri = Uri.fromFile(folder_to_show.getFile());

                Intent i;
                if (folder_to_show.getFile().getName().endsWith(FileEnding.MP4)) {
                    i = new Intent(Intent.ACTION_VIEW);
                    i.setDataAndType(uri, "video/*");
                } else {
                    i = new Intent(Intent.ACTION_EDIT);
                    i.setDataAndType(uri, "image/*");
                }
                Intent chooser = Intent.createChooser(i, "Choose App");
                //startActivity(i);
                if (i.resolveActivity(getActivity().getPackageManager()) != null) {
                    startActivity(chooser);
                }

            }
        }
    });
    deleteButton = (Button) view.findViewById(id.button_delete);
    deleteButton.setVisibility(View.GONE);
    deleteButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (VERSION.SDK_INT <= VERSION_CODES.LOLLIPOP || VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP
                    && !activityInterface.getAppSettings().GetWriteExternal()) {
                Builder builder = new Builder(getContext());
                builder.setMessage("Delete File?").setPositiveButton("Yes", dialogClickListener)
                        .setNegativeButton("No", dialogClickListener).show();
            } else {
                DocumentFile sdDir = activityInterface.getExternalSdDocumentFile();
                if (sdDir == null) {

                    activityInterface.ChooseSDCard(ScreenSlideFragment.this);
                } else {
                    Builder builder = new Builder(getContext());
                    builder.setMessage("Delete File?").setPositiveButton("Yes", dialogClickListener)
                            .setNegativeButton("No", dialogClickListener).show();
                }
            }

        }
    });
    mPagerAdapter = new ScreenSlidePagerAdapter(getChildFragmentManager());
    mPager.setAdapter(mPagerAdapter);
    mPager.setOffscreenPageLimit(2);
    mPager.addOnPageChangeListener(this);
    return view;
}

From source file:org.odk.collect.android.activities.InstanceChooserList.java

/**
 * Stores the path of selected instance in the parent class and finishes.
 *//*from  w w  w.  j  a v a2 s  . c om*/
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    if (Collect.allowClick(getClass().getName())) {
        if (view.isEnabled()) {
            Cursor c = (Cursor) listView.getAdapter().getItem(position);
            Uri instanceUri = ContentUris.withAppendedId(InstanceColumns.CONTENT_URI,
                    c.getLong(c.getColumnIndex(InstanceColumns._ID)));

            String action = getIntent().getAction();
            if (Intent.ACTION_PICK.equals(action)) {
                // caller is waiting on a picked form
                setResult(RESULT_OK, new Intent().setData(instanceUri));
            } else {
                // the form can be edited if it is incomplete or if, when it was
                // marked as complete, it was determined that it could be edited
                // later.
                String status = c.getString(c.getColumnIndex(InstanceColumns.STATUS));
                String strCanEditWhenComplete = c
                        .getString(c.getColumnIndex(InstanceColumns.CAN_EDIT_WHEN_COMPLETE));

                boolean canEdit = status.equals(InstanceProviderAPI.STATUS_INCOMPLETE)
                        || Boolean.parseBoolean(strCanEditWhenComplete);
                if (!canEdit) {
                    createErrorDialog(getString(R.string.cannot_edit_completed_form), DO_NOT_EXIT);
                    return;
                }
                // caller wants to view/edit a form, so launch formentryactivity
                Intent parentIntent = this.getIntent();
                Intent intent = new Intent(Intent.ACTION_EDIT, instanceUri);
                String formMode = parentIntent.getStringExtra(ApplicationConstants.BundleKeys.FORM_MODE);
                if (formMode == null || ApplicationConstants.FormModes.EDIT_SAVED.equalsIgnoreCase(formMode)) {
                    intent.putExtra(ApplicationConstants.BundleKeys.FORM_MODE,
                            ApplicationConstants.FormModes.EDIT_SAVED);
                } else {
                    intent.putExtra(ApplicationConstants.BundleKeys.FORM_MODE,
                            ApplicationConstants.FormModes.VIEW_SENT);
                }
                startActivity(intent);
            }
            finish();
        } else {
            TextView disabledCause = view.findViewById(R.id.form_subtitle2);
            Toast.makeText(this, disabledCause.getText(), Toast.LENGTH_SHORT).show();
        }
    }
}

From source file:org.awesomeapp.messenger.ui.AccountViewFragment.java

private void initFragment() {

    Intent i = getIntent();//  w  w w .  j  a  va 2 s  .  c  om

    mApp = (ImApp) getActivity().getApplication();

    String action = i.getAction();

    if (i.hasExtra("isSignedIn"))
        isSignedIn = i.getBooleanExtra("isSignedIn", false);

    final ProviderDef provider;

    mSignInHelper = new SignInHelper(getActivity(), new SimpleAlertHandler(getActivity()));
    SignInHelper.SignInListener signInListener = new SignInHelper.SignInListener() {
        @Override
        public void connectedToService() {
        }

        @Override
        public void stateChanged(int state, long accountId) {
            if (state == ImConnection.LOGGED_IN) {
                //  mSignInHelper.goToAccount(accountId);
                // finish();
                isSignedIn = true;
            } else {
                isSignedIn = false;
            }

        }
    };

    mSignInHelper.setSignInListener(signInListener);

    ContentResolver cr = getActivity().getContentResolver();

    Uri uri = i.getData();
    // check if there is account information and direct accordingly
    if (Intent.ACTION_INSERT_OR_EDIT.equals(action)) {
        if ((uri == null) || !Imps.Account.CONTENT_ITEM_TYPE.equals(cr.getType(uri))) {
            action = Intent.ACTION_INSERT;
        } else {
            action = Intent.ACTION_EDIT;
        }
    }

    if (Intent.ACTION_INSERT.equals(action) && uri.getScheme().equals("ima")) {
        ImPluginHelper helper = ImPluginHelper.getInstance(getActivity());
        String authority = uri.getAuthority();
        String[] userpass_host = authority.split("@");
        String[] user_pass = userpass_host[0].split(":");
        mUserName = user_pass[0].toLowerCase(Locale.getDefault());
        String pass = user_pass[1];
        mDomain = userpass_host[1].toLowerCase(Locale.getDefault());
        mPort = 0;
        final boolean regWithTor = i.getBooleanExtra("useTor", false);

        Cursor cursor = openAccountByUsernameAndDomain(cr);
        boolean exists = cursor.moveToFirst();
        long accountId;
        if (exists) {
            accountId = cursor.getLong(0);
            mAccountUri = ContentUris.withAppendedId(Imps.Account.CONTENT_URI, accountId);
            pass = cursor.getString(ACCOUNT_PASSWORD_COLUMN);

            setAccountKeepSignedIn(true);
            mSignInHelper.activateAccount(mProviderId, accountId);
            mSignInHelper.signIn(pass, mProviderId, accountId, true);
            //  setResult(RESULT_OK);
            cursor.close();
            // finish();
            return;

        } else {
            mProviderId = helper.createAdditionalProvider(helper.getProviderNames().get(0)); //xmpp FIXME
            accountId = ImApp.insertOrUpdateAccount(cr, mProviderId, -1, mUserName, mUserName, pass);
            mAccountUri = ContentUris.withAppendedId(Imps.Account.CONTENT_URI, accountId);
            mSignInHelper.activateAccount(mProviderId, accountId);
            createNewAccount(mUserName, pass, accountId, regWithTor);
            cursor.close();
            return;
        }

    } else if (Intent.ACTION_INSERT.equals(action)) {

        mOriginalUserAccount = "";
        // TODO once we implement multiple IM protocols
        mProviderId = ContentUris.parseId(uri);
        provider = mApp.getProvider(mProviderId);

    } else if (Intent.ACTION_EDIT.equals(action)) {

        if ((uri == null) || !Imps.Account.CONTENT_ITEM_TYPE.equals(cr.getType(uri))) {
            LogCleaner.warn(ImApp.LOG_TAG, "<AccountActivity>Bad data");
            return;
        }

        isEdit = true;

        Cursor cursor = cr.query(uri, ACCOUNT_PROJECTION, null, null, null);

        if (cursor == null) {

            return;
        }

        if (!cursor.moveToFirst()) {
            cursor.close();

            return;
        }

        mAccountId = cursor.getLong(cursor.getColumnIndexOrThrow(BaseColumns._ID));

        mProviderId = cursor.getLong(ACCOUNT_PROVIDER_COLUMN);
        provider = mApp.getProvider(mProviderId);

        Cursor pCursor = cr.query(Imps.ProviderSettings.CONTENT_URI,
                new String[] { Imps.ProviderSettings.NAME, Imps.ProviderSettings.VALUE },
                Imps.ProviderSettings.PROVIDER + "=?", new String[] { Long.toString(mProviderId) }, null);

        Imps.ProviderSettings.QueryMap settings = new Imps.ProviderSettings.QueryMap(pCursor, cr, mProviderId,
                false /* don't keep updated */, null /* no handler */);

        try {
            mOriginalUserAccount = cursor.getString(ACCOUNT_USERNAME_COLUMN) + "@" + settings.getDomain();
            mEditUserAccount.setText(mOriginalUserAccount);
            mEditPass.setText(cursor.getString(ACCOUNT_PASSWORD_COLUMN));
            //mRememberPass.setChecked(!cursor.isNull(ACCOUNT_PASSWORD_COLUMN));
            //mUseTor.setChecked(settings.getUseTor());
            mBtnQrDisplay.setVisibility(View.VISIBLE);
        } finally {
            settings.close();
            cursor.close();
        }

    } else {
        LogCleaner.warn(ImApp.LOG_TAG, "<AccountActivity> unknown intent action " + action);
        return;
    }

    setupUIPost();

}

From source file:com.todoroo.astrid.gcal.GCalControlSet.java

private void viewCalendarEvent() {
    if (calendarUri == null) {
        return;/*  ww  w .  ja  va2  s  .co m*/
    }

    ContentResolver cr = activity.getContentResolver();
    Intent intent = new Intent(Intent.ACTION_EDIT, calendarUri);
    Cursor cursor = cr.query(calendarUri, new String[] { "dtstart", "dtend" }, null, null, null);
    try {
        if (cursor.getCount() == 0) {
            // event no longer exists, recreate it
            calendarUri = null;
            writeToModel(model);
            return;
        }
        cursor.moveToFirst();
        intent.putExtra("beginTime", cursor.getLong(0));
        intent.putExtra("endTime", cursor.getLong(1));

    } catch (Exception e) {
        log.error(e.getMessage(), e);
        Toast.makeText(activity, R.string.gcal_TEA_error, Toast.LENGTH_LONG).show();
    } finally {
        cursor.close();
    }

    activity.startActivity(intent);
}

From source file:com.granita.tasks.EditTaskActivity.java

private void setActivityTitle(String action) {
    if (Intent.ACTION_EDIT.equals(action)) {
        setTitle(R.string.activity_edit_task_title);
    } else {/*from  w ww .j  av  a 2s .c om*/
        setTitle(R.string.activity_add_task_title);
    }
}