Beispiel #1
0
 /**
  * Returns a list 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 getListId(final Intent intent) {
   long retval = -1;
   if (intent != null
       && intent.getData() != null
       && (Intent.ACTION_EDIT.equals(intent.getAction())
           || Intent.ACTION_VIEW.equals(intent.getAction())
           || Intent.ACTION_INSERT.equals(intent.getAction()))) {
     if ((intent.getData().getPath().startsWith(NotePad.Lists.PATH_VISIBLE_LISTS)
         || intent.getData().getPath().startsWith(NotePad.Lists.PATH_LISTS)
         || intent.getData().getPath().startsWith(TaskList.URI.getPath()))) {
       try {
         retval = Long.parseLong(intent.getData().getLastPathSegment());
       } catch (NumberFormatException e) {
         retval = -1;
       }
     } else if (-1 != intent.getLongExtra(LegacyDBHelper.NotePad.Notes.COLUMN_NAME_LIST, -1)) {
       retval = intent.getLongExtra(LegacyDBHelper.NotePad.Notes.COLUMN_NAME_LIST, -1);
     } else if (-1 != intent.getLongExtra(TaskDetailFragment.ARG_ITEM_LIST_ID, -1)) {
       retval = intent.getLongExtra(TaskDetailFragment.ARG_ITEM_LIST_ID, -1);
     } else if (-1 != intent.getLongExtra(Task.Columns.DBLIST, -1)) {
       retval = intent.getLongExtra(Task.Columns.DBLIST, -1);
     }
   }
   return retval;
 }
Beispiel #2
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;
 }
Beispiel #3
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;
  }