Ejemplo n.º 1
0
  private Dialog locationPicker() {
    AlertDialog.Builder locationPickerBuilder = new AlertDialog.Builder(this);
    locationPickerBuilder.setTitle("Set task location");

    View content =
        getLayoutInflater()
            .inflate(R.layout.editlocation, (ViewGroup) findViewById(R.id.editLocation));
    locationPickerBuilder.setView(content);

    EditText longitudeText = (EditText) content.findViewById(R.id.longitudeText);
    EditText latitudeText = (EditText) content.findViewById(R.id.latitudeText);

    latitudeText.setText(String.valueOf(location().latitude()));
    longitudeText.setText(String.valueOf(location().longitude()));

    locationPickerBuilder.setPositiveButton(
        "OK",
        new DialogInterface.OnClickListener() {

          @Override
          public void onClick(DialogInterface dialogInterface, int i) {
            Dialog locationPicker = (Dialog) dialogInterface;
            EditText longitudeText = (EditText) locationPicker.findViewById(R.id.longitudeText);
            EditText latitudeText = (EditText) locationPicker.findViewById(R.id.latitudeText);
            double longitude = Double.valueOf(longitudeText.getText().toString());
            double latitude = Double.valueOf(latitudeText.getText().toString());
            task.add(TaskAdapter.LOCATION, new CMGeoPoint(longitude, latitude));
            setLocation();
          }
        });

    return locationPickerBuilder.create();
  }
Ejemplo n.º 2
0
  private void showUserHashDialog() {
    String userHash = NavigineApp.Settings.getString("user_hash", "");

    LayoutInflater inflater = getLayoutInflater();
    View view = inflater.inflate(R.layout.user_hash_dialog, null);
    _userEdit = (EditText) view.findViewById(R.id.user_hash_edit);
    _userEdit.setText(userHash);
    _userEdit.setTypeface(Typeface.MONOSPACE);
    // _userEdit.addTextChangedListener(new TextWatcher()
    //  {
    //    public void afterTextChanged(Editable s) { }
    //    public void beforeTextChanged(CharSequence s, int start, int count, int after) { }
    //    public void onTextChanged(CharSequence s, int start, int before, int count)
    //    {
    //      String text = _userEdit.getText().toString();
    //      int length  = _userEdit.getText().length();
    //
    //      if (text.endsWith("-"))
    //        return;
    //
    //      if (count <= before)
    //        return;
    //
    //      if (length == 4 || length == 9 || length == 14)
    //      {
    //        _userEdit.setText((text + "-"));
    //        _userEdit.setSelection(length + 1);
    //      }
    //    }
    //  });

    AlertDialog.Builder alertBuilder = new AlertDialog.Builder(mContext);
    alertBuilder.setView(view);
    alertBuilder.setTitle("Enter user ID");
    alertBuilder.setNegativeButton(
        getString(R.string.cancel_button),
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dlg, int id) {}
        });

    alertBuilder.setPositiveButton(
        getString(R.string.ok_button),
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dlg, int id) {
            String userHash = _userEdit.getText().toString();
            SharedPreferences.Editor editor = NavigineApp.Settings.edit();
            editor.putString("user_hash", userHash);
            editor.commit();
            NavigineApp.applySettings();
            refreshMapList();
          }
        });

    AlertDialog dialog = alertBuilder.create();
    dialog.setCanceledOnTouchOutside(false);
    dialog.show();
  }