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

    if (!Intent.ACTION_VIEW.equals(getIntent().getAction())
        && !Intent.ACTION_PICK.equals(getIntent().getAction())) {
      LOG.error(
          "Unsupported action.  Expected [{}] or [{}] but received [{}].",
          new Object[] {Intent.ACTION_VIEW, Intent.ACTION_PICK, getIntent().getAction()});

      onTerminalError();
    } else {

      Cursor splitMarkerSetCursor =
          managedQuery(TrackLoggerData.SplitMarkerSet.CONTENT_URI, null, null, null, null);

      SimpleCursorAdapter adapter =
          new SimpleCursorAdapter(
              this,
              R.layout.split_marker_set_list_item,
              splitMarkerSetCursor,
              new String[] {
                TrackLoggerData.SplitMarkerSet._ID, TrackLoggerData.SplitMarkerSet.COLUMN_NAME_NAME
              },
              new int[] {R.id.splitMarkerSetId, R.id.splitMarkerSetName});

      setContentView(R.layout.split_marker_set_list);
      setListAdapter(adapter);

      getListView().setOnCreateContextMenuListener(this);
    }
  }
Ejemplo n.º 2
0
  /** Stores the path of selected form and finishes. */
  @Override
  protected void onListItemClick(ListView listView, View view, int position, long id) {
    // get uri to form
    long idFormsTable = ((SimpleCursorAdapter) getListAdapter()).getItemId(position);
    Uri formUri = ContentUris.withAppendedId(FormsColumns.CONTENT_URI, idFormsTable);

    Collect.getInstance()
        .getActivityLogger()
        .logAction(this, "onListItemClick", formUri.toString());

    String action = getIntent().getAction();
    if (Intent.ACTION_PICK.equals(action)) {
      // caller is waiting on a picked form
      setResult(RESULT_OK, new Intent().setData(formUri));
    } else {
      // caller wants to view/edit a form, so launch formentryactivity.
      // Use explicit intent to avoid being picked up by ODK
      startActivity(
          new Intent(getApplicationContext(), FormEntryActivity.class)
              .setData(formUri)
              .setAction(Intent.ACTION_EDIT));
    }

    finish();
  }
Ejemplo n.º 3
0
 @Override
 protected Uri resolveIntent() {
   Intent intent = getIntent();
   intent.setData(Uri.parse("content://icc/adn"));
   if (Intent.ACTION_PICK.equals(intent.getAction())) {
     // "index" is 1-based
     mInitialSelection = intent.getIntExtra("index", 0) - 1;
   }
   return intent.getData();
 }
  @Override
  protected void onResume() {
    super.onResume();

    if (Intent.ACTION_PICK.equals(getIntent().getAction())) {
      Toast.makeText(
              getApplicationContext(),
              getString(R.string.split_marker_set_list_pick_instructions),
              Toast.LENGTH_LONG)
          .show();
    }
  }
Ejemplo n.º 5
0
  @Override
  protected void onListItemClick(ListView l, View v, int position, long id) {
    Uri uri = ContentUris.withAppendedId(getIntent().getData(), id);

    String action = getIntent().getAction();
    if (Intent.ACTION_PICK.equals(action) || Intent.ACTION_GET_CONTENT.equals(action)) {
      // The caller is waiting for us to return a record selected by
      // the user.  The have clicked on one, so return it now.
      setResult(RESULT_OK, new Intent().setData(uri));
    } else {
      // Launch activity to view/edit the currently selected item
      startActivity(new Intent(Intent.ACTION_EDIT, uri));
    }
  }
Ejemplo n.º 6
0
  /**
   * This method is called when the user clicks a note in the displayed list.
   *
   * <p>This method handles incoming actions of either PICK (get data from the provider) or
   * GET_CONTENT (get or create data). If the incoming action is EDIT, this method sends a new
   * Intent to start NoteEditor.
   *
   * @param l The ListView that contains the clicked item
   * @param v The View of the individual item
   * @param position The position of v in the displayed list
   * @param id The row ID of the clicked item
   */
  @Override
  protected void OnListItemClick(ListView l, View v, int position, long id) {

    // Constructs a new URI from the incoming URI and the row ID
    Uri uri = ContentUris.withAppendedId(getIntent().getData(), id);

    // Gets the action from the incoming Intent
    String action = getIntent().getAction();

    // Handles requests for note data
    if (Intent.ACTION_PICK.equals(action) || Intent.ACTION_GET_CONTENT.equals(action)) {

      // Sets the result to return to the component that called this Activity. The
      // result contains the new URI
      setResult(RESULT_OK, new Intent().setData(uri));
    } else {

      // Sends out an Intent to start an Activity that can handle ACTION_EDIT. The
      // Intent's data is the note ID URI. The effect is to call NoteEdit.
      StartActivity(new Intent(Intent.ACTION_EDIT, uri));
    }
  }
 @Override
 void executeOnUiThread(MessageContextMenu menu, MessageEditorData editorData) {
   Uri uri =
       MatchedUri.getTimelineItemUri(
           editorData.ma.getUserId(),
           menu.messageList.getTimelineType(),
           menu.messageList.isTimelineCombined(),
           menu.messageList.getSelectedUserId(),
           menu.getMsgId());
   String action = menu.messageList.getActivity().getIntent().getAction();
   if (Intent.ACTION_PICK.equals(action) || Intent.ACTION_GET_CONTENT.equals(action)) {
     if (MyLog.isLoggable(this, MyLog.DEBUG)) {
       MyLog.d(this, "onItemClick, setData=" + uri);
     }
     menu.messageList.getActivity().setResult(Activity.RESULT_OK, new Intent().setData(uri));
   } else {
     if (MyLog.isLoggable(this, MyLog.DEBUG)) {
       MyLog.d(this, "onItemClick, startActivity=" + uri);
     }
     menu.messageList.getActivity().startActivity(MyAction.VIEW_CONVERSATION.getIntent(uri));
   }
 }
 boolean isPickIntent() {
   String action = getIntent().getAction();
   return (Intent.ACTION_PICK.equals(action) || Intent.ACTION_GET_CONTENT.equals(action));
 }
Ejemplo n.º 9
0
  @Override
  public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.act_hostlist);

    this.setTitle(
        String.format(
            "%s: %s",
            getResources().getText(R.string.app_name),
            getResources().getText(R.string.title_hosts_list)));

    // check for eula agreement
    this.prefs = PreferenceManager.getDefaultSharedPreferences(this);

    boolean agreed = prefs.getBoolean(PreferenceConstants.EULA, false);
    if (!agreed) {
      this.startActivityForResult(new Intent(this, WizardActivity.class), REQUEST_EULA);
    }

    this.makingShortcut =
        Intent.ACTION_CREATE_SHORTCUT.equals(getIntent().getAction())
            || Intent.ACTION_PICK.equals(getIntent().getAction());

    // connect with hosts database and populate list
    this.hostdb = new HostDatabase(this);
    ListView list = this.getListView();

    this.sortedByColor = prefs.getBoolean(PreferenceConstants.SORT_BY_COLOR, false);

    // this.list.setSelector(R.drawable.highlight_disabled_pressed);

    list.setOnItemClickListener(
        new OnItemClickListener() {

          public synchronized void onItemClick(
              AdapterView<?> parent, View view, int position, long id) {

            // launch off to console details
            HostBean host = (HostBean) parent.getAdapter().getItem(position);
            Uri uri = host.getUri();

            Intent contents = new Intent(Intent.ACTION_VIEW, uri);
            contents.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

            if (makingShortcut) {
              // create shortcut if requested
              ShortcutIconResource icon =
                  Intent.ShortcutIconResource.fromContext(HostListActivity.this, R.drawable.icon);

              Intent intent = new Intent();
              intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, contents);
              intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, host.getNickname());
              intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);

              setResult(RESULT_OK, intent);
              finish();

            } else {
              // otherwise just launch activity to show this host
              HostListActivity.this.startActivity(contents);
            }
          }
        });

    this.registerForContextMenu(list);

    quickconnect = (TextView) this.findViewById(R.id.front_quickconnect);
    quickconnect.setVisibility(makingShortcut ? View.GONE : View.VISIBLE);
    quickconnect.setOnKeyListener(
        new OnKeyListener() {

          public boolean onKey(View v, int keyCode, KeyEvent event) {

            if (event.getAction() == KeyEvent.ACTION_UP) return false;
            if (keyCode != KeyEvent.KEYCODE_ENTER) return false;

            return startConsoleActivity();
          }
        });

    transportSpinner = (Spinner) findViewById(R.id.transport_selection);
    transportSpinner.setVisibility(makingShortcut ? View.GONE : View.VISIBLE);
    ArrayAdapter<String> transportSelection =
        new ArrayAdapter<String>(
            this, android.R.layout.simple_spinner_item, TransportFactory.getTransportNames());
    transportSelection.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    transportSpinner.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {
          public void onItemSelected(AdapterView<?> arg0, View view, int position, long id) {
            String formatHint =
                TransportFactory.getFormatHint(
                    (String) transportSpinner.getSelectedItem(), HostListActivity.this);

            quickconnect.setHint(formatHint);
            quickconnect.setError(null);
            quickconnect.requestFocus();
          }

          public void onNothingSelected(AdapterView<?> arg0) {}
        });
    transportSpinner.setAdapter(transportSelection);

    this.inflater = LayoutInflater.from(this);
  }
  public ContactsRequest resolveIntent(Intent intent) {
    ContactsRequest request = new ContactsRequest();

    String action = intent.getAction();

    Log.i(TAG, "Called with action: " + action);

    if (UI.LIST_DEFAULT.equals(action)) {
      request.setActionCode(ContactsRequest.ACTION_DEFAULT);
    } else if (UI.LIST_ALL_CONTACTS_ACTION.equals(action)) {
      request.setActionCode(ContactsRequest.ACTION_ALL_CONTACTS);
    } else if (UI.LIST_CONTACTS_WITH_PHONES_ACTION.equals(action)) {
      request.setActionCode(ContactsRequest.ACTION_CONTACTS_WITH_PHONES);
    } else if (UI.LIST_STARRED_ACTION.equals(action)) {
      request.setActionCode(ContactsRequest.ACTION_STARRED);
    } else if (UI.LIST_FREQUENT_ACTION.equals(action)) {
      request.setActionCode(ContactsRequest.ACTION_FREQUENT);
    } else if (UI.LIST_STREQUENT_ACTION.equals(action)) {
      request.setActionCode(ContactsRequest.ACTION_STREQUENT);
    } else if (UI.LIST_GROUP_ACTION.equals(action)) {
      request.setActionCode(ContactsRequest.ACTION_GROUP);
      // We no longer support UI.GROUP_NAME_EXTRA_KEY
    } else if (Intent.ACTION_PICK.equals(action)) {
      final String resolvedType = intent.resolveType(mContext);
      if (Contacts.CONTENT_TYPE.equals(resolvedType)) {
        request.setActionCode(ContactsRequest.ACTION_PICK_CONTACT);
      } else if (People.CONTENT_TYPE.equals(resolvedType)) {
        request.setActionCode(ContactsRequest.ACTION_PICK_CONTACT);
        request.setLegacyCompatibilityMode(true);
      } else if (Phone.CONTENT_TYPE.equals(resolvedType)) {
        request.setActionCode(ContactsRequest.ACTION_PICK_PHONE);
      } else if (Phones.CONTENT_TYPE.equals(resolvedType)) {
        request.setActionCode(ContactsRequest.ACTION_PICK_PHONE);
        request.setLegacyCompatibilityMode(true);
      } else if (StructuredPostal.CONTENT_TYPE.equals(resolvedType)) {
        request.setActionCode(ContactsRequest.ACTION_PICK_POSTAL);
      } else if (ContactMethods.CONTENT_POSTAL_TYPE.equals(resolvedType)) {
        request.setActionCode(ContactsRequest.ACTION_PICK_POSTAL);
        request.setLegacyCompatibilityMode(true);
      } else if (Email.CONTENT_TYPE.equals(resolvedType)) {
        request.setActionCode(ContactsRequest.ACTION_PICK_EMAIL);
      }
    } else if (Intent.ACTION_CREATE_SHORTCUT.equals(action)) {
      String component = intent.getComponent().getClassName();
      if (component.equals("alias.DialShortcut")) {
        request.setActionCode(ContactsRequest.ACTION_CREATE_SHORTCUT_CALL);
      } else if (component.equals("alias.MessageShortcut")) {
        request.setActionCode(ContactsRequest.ACTION_CREATE_SHORTCUT_SMS);
      } else {
        request.setActionCode(ContactsRequest.ACTION_CREATE_SHORTCUT_CONTACT);
      }
    } else if (Intent.ACTION_GET_CONTENT.equals(action)) {
      String type = intent.getType();
      if (Contacts.CONTENT_ITEM_TYPE.equals(type)) {
        request.setActionCode(ContactsRequest.ACTION_PICK_OR_CREATE_CONTACT);
      } else if (Phone.CONTENT_ITEM_TYPE.equals(type)) {
        request.setActionCode(ContactsRequest.ACTION_PICK_PHONE);
      } else if (Phones.CONTENT_ITEM_TYPE.equals(type)) {
        request.setActionCode(ContactsRequest.ACTION_PICK_PHONE);
        request.setLegacyCompatibilityMode(true);
      } else if (StructuredPostal.CONTENT_ITEM_TYPE.equals(type)) {
        request.setActionCode(ContactsRequest.ACTION_PICK_POSTAL);
      } else if (ContactMethods.CONTENT_POSTAL_ITEM_TYPE.equals(type)) {
        request.setActionCode(ContactsRequest.ACTION_PICK_POSTAL);
        request.setLegacyCompatibilityMode(true);
      } else if (People.CONTENT_ITEM_TYPE.equals(type)) {
        request.setActionCode(ContactsRequest.ACTION_PICK_OR_CREATE_CONTACT);
        request.setLegacyCompatibilityMode(true);
      }
    } else if (Intent.ACTION_INSERT_OR_EDIT.equals(action)) {
      request.setActionCode(ContactsRequest.ACTION_INSERT_OR_EDIT_CONTACT);
    } else if (Intent.ACTION_SEARCH.equals(action)) {
      // See if the suggestion was clicked with a search action key (call button)
      if ("call".equals(intent.getStringExtra(SearchManager.ACTION_MSG))) {
        String query = intent.getStringExtra(SearchManager.QUERY);
        if (!TextUtils.isEmpty(query)) {
          Intent newIntent =
              new Intent(Intent.ACTION_CALL_PRIVILEGED, Uri.fromParts("tel", query, null));
          request.setRedirectIntent(newIntent);
        }
      } else {
        request.setQueryString(intent.getStringExtra(SearchManager.QUERY));
        request.setSearchMode(true);
      }
    } else if (Intent.ACTION_VIEW.equals(action)) {
      final String resolvedType = intent.resolveType(mContext);
      if (ContactsContract.Contacts.CONTENT_TYPE.equals(resolvedType)
          || android.provider.Contacts.People.CONTENT_TYPE.equals(resolvedType)) {
        request.setActionCode(ContactsRequest.ACTION_ALL_CONTACTS);
      } else {
        request.setActionCode(ContactsRequest.ACTION_VIEW_CONTACT);
        request.setContactUri(intent.getData());
        intent.setAction(Intent.ACTION_DEFAULT);
        intent.setData(null);
      }
    } else if (UI.FILTER_CONTACTS_ACTION.equals(action)) {
      // When we get a FILTER_CONTACTS_ACTION, it represents search in the context
      // of some other action. Let's retrieve the original action to provide proper
      // context for the search queries.
      request.setActionCode(ContactsRequest.ACTION_DEFAULT);
      Bundle extras = intent.getExtras();
      if (extras != null) {
        request.setQueryString(extras.getString(UI.FILTER_TEXT_EXTRA_KEY));

        ContactsRequest originalRequest =
            (ContactsRequest) extras.get(ContactsSearchManager.ORIGINAL_REQUEST_KEY);
        if (originalRequest != null) {
          request.copyFrom(originalRequest);
        }
      }

      request.setSearchMode(true);

      // Since this is the filter activity it receives all intents
      // dispatched from the SearchManager for security reasons
      // so we need to re-dispatch from here to the intended target.
    } else if (Intents.SEARCH_SUGGESTION_CLICKED.equals(action)) {
      Uri data = intent.getData();
      // See if the suggestion was clicked with a search action key (call button)
      if ("call".equals(intent.getStringExtra(SearchManager.ACTION_MSG))) {
        Intent newIntent = new Intent(mContext, CallContactActivity.class);
        newIntent.setData(data);
        request.setRedirectIntent(newIntent);
      } else {
        request.setActionCode(ContactsRequest.ACTION_VIEW_CONTACT);
        request.setContactUri(data);
        intent.setAction(Intent.ACTION_DEFAULT);
        intent.setData(null);
      }
    } else if (Intents.SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED.equals(action)) {
      request.setRedirectIntent(new Intent(Intent.ACTION_CALL_PRIVILEGED, intent.getData()));
    } else if (Intents.SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED.equals(action)) {
      // TODO actually support this in EditContactActivity.
      String number = intent.getData().getSchemeSpecificPart();
      Intent newIntent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI);
      newIntent.putExtra(Intents.Insert.PHONE, number);
      request.setRedirectIntent(newIntent);
    }
    // Allow the title to be set to a custom String using an extra on the intent
    String title = intent.getStringExtra(UI.TITLE_EXTRA_KEY);
    if (title != null) {
      request.setActivityTitle(title);
    }
    return request;
  }