Ejemplo n.º 1
0
 /**
  * Returns a note id from an intent if it contains one, either as part of its URI or as an extra
  *
  * <p>Returns -1 if no id was contained, this includes insert actions
  */
 long getNoteId(final Intent intent) {
   long retval = -1;
   if (intent != null
       && intent.getData() != null
       && (Intent.ACTION_EDIT.equals(intent.getAction())
           || Intent.ACTION_VIEW.equals(intent.getAction()))) {
     if (intent.getData().getPath().startsWith(TaskList.URI.getPath())) {
       // Find it in the extras. See DashClock extension for an example
       retval = intent.getLongExtra(Task.TABLE_NAME, -1);
     } else if ((intent
             .getData()
             .getPath()
             .startsWith(LegacyDBHelper.NotePad.Notes.PATH_VISIBLE_NOTES)
         || intent.getData().getPath().startsWith(LegacyDBHelper.NotePad.Notes.PATH_NOTES)
         || intent.getData().getPath().startsWith(Task.URI.getPath()))) {
       retval = Long.parseLong(intent.getData().getLastPathSegment());
     }
     // else if (null != intent
     // .getStringExtra(TaskDetailFragment.ARG_ITEM_ID)) {
     // retval = Long.parseLong(intent
     // .getStringExtra(TaskDetailFragment.ARG_ITEM_ID));
     // }
   }
   return retval;
 }
Ejemplo n.º 2
0
  /** Returns true the intent URI targets a note. Either an edit/view or insert. */
  boolean isNoteIntent(final Intent intent) {
    if (intent == null) {
      return false;
    }
    if (Intent.ACTION_SEND.equals(intent.getAction())
        || "com.google.android.gm.action.AUTO_SEND".equals(intent.getAction())) {
      return true;
    }

    if (intent.getData() != null
        && (Intent.ACTION_EDIT.equals(intent.getAction())
            || Intent.ACTION_VIEW.equals(intent.getAction())
            || Intent.ACTION_INSERT.equals(intent.getAction()))
        && (intent.getData().getPath().startsWith(LegacyDBHelper.NotePad.Notes.PATH_VISIBLE_NOTES)
            || intent.getData().getPath().startsWith(LegacyDBHelper.NotePad.Notes.PATH_NOTES)
            || intent.getData().getPath().startsWith(Task.URI.getPath()))
        && !intent.getData().getPath().startsWith(TaskList.URI.getPath())) {
      return true;
    }

    return false;
  }