@Override
  public boolean onMenuItemClick(MenuItem item) {
    if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
      Calendar cal = new GregorianCalendar();
      Date date = cal.getTime();

      SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");
      String dateFormat = df.format(date);

      if (location != null) {
        try {
          JSONObject position = new JSONObject();
          position.put("latitude", location.getLatitude());
          position.put("longitude", location.getLongitude());

          boolean isGroup = false;

          Message message =
              new Message("MAP" + position.toString(), dateFormat, true, toID, toID, isGroup);
          messages.add(message);

          sendMessage(message.getText());
          showMap(message);
        } catch (JSONException e) {
          e.printStackTrace();
        }
      } else {
        Toast.makeText(this, getResources().getString(R.string.gps_disabled), Toast.LENGTH_LONG)
            .show();
      }

    } else {
      AlertDialog.Builder builder = new AlertDialog.Builder(this);
      builder
          .setMessage(getResources().getString(R.string.gps_off))
          .setCancelable(false)
          .setPositiveButton(
              getResources().getString(R.string.yes),
              new DialogInterface.OnClickListener() {
                public void onClick(final DialogInterface dialog, final int id) {
                  startActivity(
                      new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS));
                }
              })
          .setNegativeButton(
              "No",
              new DialogInterface.OnClickListener() {
                public void onClick(final DialogInterface dialog, final int id) {
                  dialog.cancel();
                }
              });
      AlertDialog alert = builder.create();
      alert.show();
    }

    return false;
  }
  @Override
  public void onClick(View v) {
    if (v.getId() == R.id.chat_send && keyboard.getText().toString().length() != 0) {
      Calendar cal = new GregorianCalendar();
      Date date = cal.getTime();

      SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");
      String dateFormat = df.format(date);

      boolean isGroup = false;

      Message message =
          new Message(keyboard.getText().toString(), dateFormat, true, toID, toID, isGroup);

      messages.add(message);

      sendMessage(message.getText());
      showMessage(message);
    } else {
      popupMenu.show();
    }
  }