예제 #1
0
  private void handleIntents() {
    Intent i = getIntent();

    if (i.getAction() == null) return;

    if (Constants.ACTION_RESTART_APP.equals(i.getAction())) {
      OmniNotes.restartApp(getApplicationContext());
    }

    if (receivedIntent(i)) {
      Note note = i.getParcelableExtra(Constants.INTENT_NOTE);
      if (note == null) {
        note = DbHelper.getInstance(this).getNote(i.getIntExtra(Constants.INTENT_KEY, 0));
      }
      // Checks if the same note is already opened to avoid to open again
      if (note != null && noteAlreadyOpened(note)) {
        return;
      }
      // Empty note instantiation
      if (note == null) {
        note = new Note();
      }
      switchToDetail(note);
    }

    if (Constants.ACTION_SEND_AND_EXIT.equals(i.getAction())) {
      saveAndExit(i);
    }

    // Tag search
    if (Intent.ACTION_VIEW.equals(i.getAction())) {
      switchToList();
    }
  }
예제 #2
0
 /** Used to perform a quick text-only note saving (eg. Tasker+Pushbullet) */
 private void saveAndExit(Intent i) {
   Note note = new Note();
   note.setTitle(i.getStringExtra(Intent.EXTRA_SUBJECT));
   note.setContent(i.getStringExtra(Intent.EXTRA_TEXT));
   DbHelper.getInstance(this).updateNote(note, true);
   showToast(getString(R.string.note_updated), Toast.LENGTH_SHORT);
   finish();
 }