Esempio n. 1
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case R.id.next:
        FragmentTransaction ft = getFragmentManager().beginTransaction();

        Bundle args = new Bundle();
        String host_path = editBaseURI.getText().toString();
        args.putString(
            QueryServerDialogFragment.EXTRA_BASE_URI, URLUtils.sanitize(scheme + host_path));
        args.putString(
            QueryServerDialogFragment.EXTRA_USER_NAME, editUserName.getText().toString());
        args.putString(QueryServerDialogFragment.EXTRA_PASSWORD, editPassword.getText().toString());
        args.putBoolean(
            QueryServerDialogFragment.EXTRA_AUTH_PREEMPTIVE, checkboxPreemptive.isChecked());

        DialogFragment dialog = new QueryServerDialogFragment();
        dialog.setArguments(args);
        dialog.show(ft, QueryServerDialogFragment.class.getName());
        break;
      default:
        return false;
    }
    return true;
  }
Esempio n. 2
0
  @Override
  public void onPrepareOptionsMenu(Menu menu) {
    boolean ok = editUserName.getText().length() > 0 && editPassword.getText().length() > 0;

    if (ok)
      // check host name
      try {
        URI uri = new URI(URLUtils.sanitize(scheme + editBaseURI.getText().toString()));
        if (StringUtils.isBlank(uri.getHost())) ok = false;
      } catch (URISyntaxException e) {
        ok = false;
      }

    MenuItem item = menu.findItem(R.id.next);
    item.setEnabled(ok);
  }