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:org.apache.cordova.plugin.Bazaar.java

@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
    if (action.equals("update")) {
        try {//from  www.  ja v a2 s .c  o  m
            activity = this.cordova.getActivity();
            callback = callbackContext;
            packageName = args.getString(0);
            connection = new UpdateServiceConnection();
            Intent intent = new Intent("com.farsitel.bazaar.service.UpdateCheckService.BIND");
            intent.setPackage("com.farsitel.bazaar");
            boolean ret = activity.bindService(intent, connection, Context.BIND_AUTO_CREATE);
            if (ret == false) {
                callbackContext.error("Intent not bind");
                return false;
            }
            return true;
        } catch (JSONException e) {
            callbackContext.error(e.getMessage());
            return false;
        }
    }

    if (action.equals("show")) {
        try {
            packageName = args.getString(0);
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse("bazaar://details?id=" + packageName));
            intent.setPackage("com.farsitel.bazaar");
            this.cordova.getActivity().startActivity(intent);
            callbackContext.success("View Intent Sent");
            return true;
        } catch (JSONException e) {
            callbackContext.error(e.getMessage());
            return false;
        }
    }

    if (action.equals("rate")) {
        try {
            packageName = args.getString(0);
            Intent intent = new Intent(Intent.ACTION_EDIT);
            intent.setData(Uri.parse("bazaar://details?id=" + packageName));
            intent.setPackage("com.farsitel.bazaar");
            this.cordova.getActivity().startActivity(intent);
            callbackContext.success("Rate Intent Sent");
            return true;
        } catch (JSONException e) {
            callbackContext.error(e.getMessage());
            return false;
        }
    }

    if (action.equals("developer")) {
        try {
            packageName = args.getString(0);
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse("bazaar://collection?slug=by_author&aid=" + packageName));
            intent.setPackage("com.farsitel.bazaar");
            this.cordova.getActivity().startActivity(intent);
            callbackContext.success("Rate Intent Sent");
            return true;
        } catch (JSONException e) {
            callbackContext.error(e.getMessage());
            return false;
        }
    }

    return false;
}

From source file:com.silentcircle.contacts.interactions.GroupCreationDialogFragment.java

@Override
protected void onCompleted(String groupLabel) {

    // Indicate to the listener that a new group will be created.
    // If the device is rotated, mListener will become null, so that the
    // popup from GroupMembershipView will not be shown.
    if (mListener != null) {
        mListener.onGroupCreated();//from   w  w w .j  ava2 s. c o  m
    }

    Activity activity = getActivity();
    activity.startService(ScContactSaveService.createNewGroupIntent(activity, groupLabel,
            null /* no new members to add */, activity.getClass(), Intent.ACTION_EDIT));
}

From source file:org.svij.taskwarriorapp.MenuListFragment.java

public void onTaskButtonClick(View view) {
    switch (view.getId()) {
    case R.id.btnTaskDelete:
        deleteTask(getTaskWithId(selectedItemId));
        break;/*from  ww w.ja va2  s.co  m*/
    case R.id.btnTaskModify:
        showAddTaskActivity(getTaskWithId(selectedItemId));
        break;
    case R.id.btnTaskAddReminder:
        Task task = datasource.getTask(getTaskWithId(selectedItemId));
        Intent intent = new Intent(Intent.ACTION_EDIT);
        intent.setType("vnd.android.cursor.item/event");
        if (task.getDue() != null) {
            intent.putExtra("beginTime", task.getDue().getTime());
        }
        intent.putExtra("title", task.getDescription());
        startActivity(intent);
        break;
    case R.id.btnTaskDone:
        doneTask(getTaskWithId(selectedItemId));
        break;
    default:
        break;
    }
}

From source file:com.github.baoti.pioneer.ui.news.NewsActivity.java

private void initContentFragment(Bundle savedInstanceState, String action) {
    if (showList) {
        NewsListFragment listFragment;/* w  w  w  .j a  va  2  s.  co  m*/
        if (savedInstanceState == null) {
            listFragment = NewsListFragment.newInstance();
            addContentFragment(listFragment, TAG_FRAG_LIST);
        } else {
            listFragment = (NewsListFragment) getSupportFragmentManager().findFragmentByTag(TAG_FRAG_LIST);
        }
        listFragment.setOnItemClickedListener(this);
        listFragment.enableInitialResources();

        setupSearch(setupToolbar(toolbar), listFragment);
    } else {
        toolbar.setVisibility(View.GONE);
        if (savedInstanceState == null) {
            if (Intent.ACTION_EDIT.equals(action)) {
                NewsEditFragment fragment = NewsEditFragment.newInstance(getIntent().getExtras());
                addContentFragment(fragment, TAG_FRAG_EDIT);
            } else {
                NewsDetailFragment fragment = NewsDetailFragment.newInstance(getIntent().getExtras());
                addContentFragment(fragment, TAG_FRAG_DETAIL);
            }
        }
    }
}

From source file:pl.selvin.android.listsyncsample.ui.ListFragment.java

@Override
public boolean onContextItemSelected(android.view.MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_item_edit:
        AdapterView.AdapterContextMenuInfo menuInfo = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
        Intent intent = new Intent(Intent.ACTION_EDIT,
                ListProvider.getHelper().getItemUri(Database.Item.TABLE_NAME, menuInfo.id), getActivity(),
                EditItemActivity.class);
        startActivity(intent);/*from   w  w  w  .  j  a  v a  2  s .co m*/
        return true;
    case R.id.menu_item_delete:
        menuInfo = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
        ConfirmDeleteDialog
                .newInstance(R.string.ui_alert_delete_item,
                        ListProvider.getHelper().getItemUri(Database.Item.TABLE_NAME, menuInfo.id))
                .show(getFragmentManager(), "dialog");
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:org.dmfs.tasks.model.Model.java

public void startEditIntent(Activity activity, Account account, long listId, String nameHint,
        Integer colorHint) {// ww  w.  j  a va2 s .  c  om
    if (!hasEditActivity()) {
        throw new IllegalStateException("Syncadapter for " + mAccountType + " does not support editing lists.");
    }

    Intent intent = getListIntent(mContext, Intent.ACTION_EDIT, account);
    intent.setData(ContentUris.withAppendedId(TaskLists.getContentUri(mAuthority), listId));
    if (nameHint != null) {
        intent.putExtra(EXTRA_TITLE_HINT, nameHint);
    }
    if (colorHint != null) {
        intent.putExtra(EXTRA_COLOR_HINT, colorHint);
    }
    activity.startActivity(intent);
}

From source file:cz.maresmar.sfm.view.user.UserListActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_user_list);

    if (findViewById(R.id.user_detail_container) != null) {
        // The detail container view will be present only in the
        // large-screen layouts (res/values-w900dp).
        // If this view is present, then the
        // activity should be in two-pane mode.
        mTwoPane = true;/*from ww  w  .ja  va2 s  . co m*/
    }

    // Toolbar
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    // Fab
    FloatingActionButton fab = findViewById(R.id.main_discard_fab);
    if (mTwoPane) {
        AppCompatActivity sourceActivity = this;
        fab.setOnClickListener(view -> {
            UserDetailFragment userDetailFragment = (UserDetailFragment) getSupportFragmentManager()
                    .findFragmentById(R.id.user_detail_container);
            if (userDetailFragment.hasValidData()) {
                userDetailFragment.saveData();
            }
        });
    } else {
        fab.setVisibility(View.GONE);
    }

    // Show the Up button in the action bar.
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }

    View recyclerView = findViewById(R.id.user_list);
    setupRecyclerView((RecyclerView) recyclerView);

    if (Intent.ACTION_EDIT.equals(getIntent().getAction())) {
        Uri userUri = getIntent().getData();
        showUserDetail(userUri);
    }
}

From source file:com.farmerbb.notepad.activity.NoteEditActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_note_edit);

    // Apply theme
    SharedPreferences pref = getSharedPreferences(getPackageName() + "_preferences", Context.MODE_PRIVATE);
    String theme = pref.getString("theme", "light-sans");

    LinearLayout noteViewEdit = findViewById(R.id.noteViewEdit);

    if (theme.contains("light"))
        noteViewEdit.setBackgroundColor(ContextCompat.getColor(this, R.color.window_background));

    if (theme.contains("dark"))
        noteViewEdit.setBackgroundColor(ContextCompat.getColor(this, R.color.window_background_dark));

    // Set action bar elevation
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
        getSupportActionBar().setElevation(getResources().getDimensionPixelSize(R.dimen.action_bar_elevation));

    if (!(getSupportFragmentManager().findFragmentById(R.id.noteViewEdit) instanceof NoteEditFragment)) {
        // Handle intents
        Intent intent = getIntent();//from   w w w  .  j  av  a  2 s . c o m
        String action = intent.getAction();
        String type = intent.getType();

        // Intent sent through an external application
        if (Intent.ACTION_SEND.equals(action) && type != null) {
            if ("text/plain".equals(type)) {
                external = getExternalContent();
                if (external != null) {
                    newNote();
                } else {
                    showToast(R.string.loading_external_file);
                    finish();
                }
            } else {
                showToast(R.string.loading_external_file);
                finish();
            }

            // Intent sent through Google Now "note to self"
        } else if ("com.google.android.gm.action.AUTO_SEND".equals(action) && type != null) {
            if ("text/plain".equals(type)) {
                external = getExternalContent();
                if (external != null) {
                    try {
                        // Write note to disk
                        FileOutputStream output = openFileOutput(String.valueOf(System.currentTimeMillis()),
                                Context.MODE_PRIVATE);
                        output.write(external.getBytes());
                        output.close();

                        // Show toast notification and finish
                        showToast(R.string.note_saved);
                        finish();
                    } catch (IOException e) {
                        // Show error message as toast if file fails to save
                        showToast(R.string.failed_to_save);
                        finish();
                    }
                }
            }
        } else if (Intent.ACTION_EDIT.equals(action) && "text/plain".equals(type)) {
            external = intent.getStringExtra(Intent.EXTRA_TEXT);
            if (external != null) {
                newNote();
                return;
            }
            finish();
        } else if (Intent.ACTION_VIEW.equals(action) && "text/plain".equals(type)) {
            try {
                InputStream in = getContentResolver().openInputStream(intent.getData());
                Reader rd = new InputStreamReader(in, "UTF-8");
                char[] buffer = new char[4096];
                int len;
                StringBuilder sb = new StringBuilder();
                while ((len = rd.read(buffer)) != -1) {
                    sb.append(buffer, 0, len);
                }
                rd.close();
                in.close();
                external = sb.toString();
            } catch (Exception e) {
                // show msg error loading data?
            }
            if (external != null) {
                newNote();
                return;
            }
            finish();
        } else
            newNote();
    }
}

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

public void onBackPressed() {
    final Intent intent = getActivity().getIntent();
    final String action = intent.getAction();

    final Drug drug = mWrapper.get();
    final String drugName = drug.getName();

    if (drugName == null || drugName.length() == 0) {
        showDrugDiscardDialog();/*  w w  w  .  j  a v  a2s. c o  m*/
        return;
    }

    if (Intent.ACTION_EDIT.equals(action)) {
        if (mDrugHash != drug.hashCode()) {
            if (LOGV)
                Util.dumpObjectMembers(TAG, Log.VERBOSE, drug, "drug 2");

            showSaveChangesDialog();
            return;
        }
    } else if (Intent.ACTION_INSERT.equals(action)) {
        Database.create(drug, 0);
        Toast.makeText(getActivity(), getString(R.string._toast_saved), Toast.LENGTH_SHORT).show();
    }

    getActivity().finish();
}

From source file:com.money.manager.ex.assetallocation.AssetClassEditActivity.java

private void loadIntent() {
    Intent intent = getIntent();/*from   w w w .java  2 s.c  o  m*/
    if (intent == null)
        return;

    // Insert or Edit?
    mAction = intent.getAction();
    if (mAction == null)
        return;

    AssetClass assetClass = null;

    switch (mAction) {
    case Intent.ACTION_INSERT:
        assetClass = AssetClass.create("");
        int parentId = intent.getIntExtra(KEY_PARENT_ID, Constants.NOT_SET);
        assetClass.setParentId(parentId);
        break;

    case Intent.ACTION_EDIT:
        int id = intent.getIntExtra(Intent.EXTRA_UID, Constants.NOT_SET);
        this.assetClassId = id;

        // load class
        AssetClassRepository repo = new AssetClassRepository(this);
        assetClass = repo.load(id);
        if (assetClass == null) {
            new UIHelper(this).showToast("No asset class found in the database!");
            // todo: show error message and return (close edit activity)
            return;
        }
        break;
    }

    AssetClassEditFragment fragment = getFragment();
    fragment.assetClass = assetClass;
}