/* (non-Javadoc)
   * @see android.app.Activity#onCreate(android.os.Bundle)
   */
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.text_dialog);

    TextView title = (TextView) findViewById(R.id.dialogPromptTitle);
    title.setText(R.string.enterIpAddress);

    InetAddress currentIP = Util.getLocalIpAddress();

    // Send back to main menu if not connected
    if (currentIP == null) {
      setResult(RESULT_CANCELED);
      finish();
    }

    // If not IPv4, set as IPv6
    if ((currentIP != null) && !InetAddressUtils.isIPv4Address(currentIP.getHostAddress())) {
      isIPv4 = false;
    }

    final EditText textView = (EditText) findViewById(R.id.dialogPromptTextbox);

    if (isIPv4) {
      textView.setHint(R.string.ipv4Address);
    } else {
      textView.setHint(R.string.ipv6Address);
      textView.setInputType(InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS);
    }

    textView.setOnEditorActionListener(this);

    // create button for the view
    Button ok = (Button) findViewById(R.id.ok);
    ok.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            addressEntered();
          }
        });
  }