private void initLettersRows(final View view) {
    int max = getScreenMaxHeight();

    DisplayMetrics displayMetrics = getActivity().getResources().getDisplayMetrics();
    int dpMax = (int) ((max / displayMetrics.density) + 0.5);

    if (dpMax > 480) {
      LinearLayout lastNumbersContainer =
          (LinearLayout) view.findViewById(R.id.housenumber_container);

      LinearLayout.LayoutParams params =
          (LinearLayout.LayoutParams) lastNumbersContainer.getLayoutParams();
      // Changes the height and width to the specified *pixels*
      params.height = params.height * 3 / 2;
      lastNumbersContainer.setLayoutParams(params);
      textlastHouseNumbers3.setVisibility(View.VISIBLE);
      FrameLayout.LayoutParams number2Params =
          (FrameLayout.LayoutParams) textlastHouseNumbers2.getLayoutParams();
      number2Params.gravity = Gravity.CENTER_VERTICAL;

    } else {
      textlastHouseNumbers3.setVisibility(View.GONE);
    }

    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE
        || dpMax >= 580) {
      // do nothing
    } else if (dpMax > 480) {
      // remove one line
      // view.findViewById(R.id.keysRow3).setVisibility(View.GONE);
      ((Button) view.findViewById(R.id.buttonJ)).setText(localizer.getString("buttonSep1"));
      ((Button) view.findViewById(R.id.buttonK)).setText(localizer.getString("buttonSep2"));
      ((Button) view.findViewById(R.id.buttonL)).setText(localizer.getString("buttonSep3"));
    } else {
      // remove two lines
      view.findViewById(R.id.keysRow2).setVisibility(View.GONE);
      view.findViewById(R.id.keysRow3).setVisibility(View.GONE);
      ((Button) view.findViewById(R.id.buttonD)).setText(localizer.getString("buttonSep1"));
      ((Button) view.findViewById(R.id.buttonE)).setText(localizer.getString("buttonSep2"));
      ((Button) view.findViewById(R.id.buttonF)).setText(localizer.getString("buttonSep3"));
      if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
        View lfrRow = view.findViewById(R.id.lfrRow);
        LayoutParams params = (LayoutParams) lfrRow.getLayoutParams();
        if (KeypadMapperApplication.getInstance().getSettings().isLayoutOptimizationEnabled()) {
          params.weight = 1.55f;
        } else {
          params.weight = 1.4f;
        }
        lfrRow.setLayoutParams(params);
      }
    }
  }
  private void updateTextOnLayout(View view) {

    textHousenumber.setBackgroundDrawable(localizer.getDrawable("house_number_background"));

    inputNotes.setHint(localizer.getString("keypad_info_hint"));
    inputNotes.setBackgroundDrawable(
        localizer.get9PatchDrawable("textfield_multiline_activated_holo_dark"));

    view.findViewById(R.id.helpBtn).setBackgroundDrawable(localizer.getDrawable("icon_help"));

    View delimiter1 = view.findViewById(R.id.delimiter1);
    if (delimiter1 != null) {
      delimiter1.setBackgroundDrawable(localizer.getDrawable("icon_line_menu"));
    }
    View delimiter2 = view.findViewById(R.id.delimiter2);
    if (delimiter2 != null) {
      delimiter2.setBackgroundDrawable(localizer.getDrawable("icon_line_menu"));
    }

    ((Button) view.findViewById(R.id.button1)).setText(localizer.getString("button1"));

    ((Button) view.findViewById(R.id.button1)).setText(localizer.getString("button1"));
    ((Button) view.findViewById(R.id.button2)).setText(localizer.getString("button2"));
    ((Button) view.findViewById(R.id.button3)).setText(localizer.getString("button3"));
    ((Button) view.findViewById(R.id.button4)).setText(localizer.getString("button4"));
    ((Button) view.findViewById(R.id.button5)).setText(localizer.getString("button5"));
    ((Button) view.findViewById(R.id.button6)).setText(localizer.getString("button6"));
    ((Button) view.findViewById(R.id.button7)).setText(localizer.getString("button7"));
    ((Button) view.findViewById(R.id.button8)).setText(localizer.getString("button8"));
    ((Button) view.findViewById(R.id.button9)).setText(localizer.getString("button9"));
    ((Button) view.findViewById(R.id.button0)).setText(localizer.getString("button0"));

    ((Button) view.findViewById(R.id.buttonA)).setText(localizer.getString("buttonA"));
    ((Button) view.findViewById(R.id.buttonB)).setText(localizer.getString("buttonB"));
    ((Button) view.findViewById(R.id.buttonC)).setText(localizer.getString("buttonC"));
    ((Button) view.findViewById(R.id.buttonD)).setText(localizer.getString("buttonD"));
    ((Button) view.findViewById(R.id.buttonE)).setText(localizer.getString("buttonE"));
    ((Button) view.findViewById(R.id.buttonF)).setText(localizer.getString("buttonF"));

    ((Button) view.findViewById(R.id.buttonG)).setText(localizer.getString("buttonG"));
    ((Button) view.findViewById(R.id.buttonH)).setText(localizer.getString("buttonH"));
    ((Button) view.findViewById(R.id.buttonI)).setText(localizer.getString("buttonI"));

    ((Button) view.findViewById(R.id.buttonJ)).setText(localizer.getString("buttonJ"));
    ((Button) view.findViewById(R.id.buttonK)).setText(localizer.getString("buttonK"));
    ((Button) view.findViewById(R.id.buttonL)).setText(localizer.getString("buttonL"));

    ((Button) view.findViewById(R.id.buttonSep1)).setText(localizer.getString("buttonSep1"));
    ((Button) view.findViewById(R.id.buttonSep2)).setText(localizer.getString("buttonSep2"));
    ((Button) view.findViewById(R.id.buttonSep3)).setText(localizer.getString("buttonSep3"));

    initLettersRows(view);
  }
  @Override
  public void onClick(View v) {
    enableHousenumberView();
    address = mapper.getCurrentAddress();
    addressCallback.extendedAddressInactive();
    String housenumber = (String) textHousenumber.getText().toString();
    textHousenumber.clearFocus();

    try {
      switch (v.getId()) {
        case R.id.helpBtn:
          Intent help = new Intent(getActivity(), HelpActivity.class);
          startActivity(help);
          break;
        case R.id.button_C:
          // clear
          keyboardVibrate();
          clearInfo();
          break;
        case R.id.button_DEL:
          {
            keyboardVibrate();
            // delete the last char
            if (housenumber.length() > 0) {
              address.setNumber(housenumber.substring(0, housenumber.length() - 1));
              mapper.setCurrentAddress(address);
            }
            break;
          }
        case R.id.button_L:
          if (!KeypadMapperApplication.getInstance().getSettings().isRecording()) {
            Toast.makeText(getActivity(), localizer.getString("notRecording"), Toast.LENGTH_SHORT)
                .show();
            return;
          }

          if (mapper.getCurrentLocation() == null && mapper.getFreezedLocation() == null) {
            throw new LocationNotAvailableException("Location is not available");
          }

          // must update address if user has used soft-keyboard
          if (housenumber.length() != 0) {
            address.setNumber(localizer.getString("buttonLeft") + ": " + housenumber);
          }

          mapper.setCurrentAddress(address);
          // place address to the left
          mapper.saveCurrentAddress(0, distance);

          clearInfo();
          vibrate();
          break;
        case R.id.button_F:
          if (!KeypadMapperApplication.getInstance().getSettings().isRecording()) {
            Toast.makeText(getActivity(), localizer.getString("notRecording"), Toast.LENGTH_SHORT)
                .show();
            return;
          }

          if (mapper.getCurrentLocation() == null && mapper.getFreezedLocation() == null) {
            throw new LocationNotAvailableException("Location is not available");
          }

          // must update address if user has used soft-keyboard
          if (housenumber.length() != 0) {
            address.setNumber(localizer.getString("buttonFront") + ": " + housenumber);
          }
          mapper.setCurrentAddress(address);
          // place address forwards
          mapper.saveCurrentAddress(distance, 0);

          // menu.updateShareIcon();

          clearInfo();
          vibrate();
          break;
        case R.id.button_R:
          if (!KeypadMapperApplication.getInstance().getSettings().isRecording()) {
            Toast.makeText(getActivity(), localizer.getString("notRecording"), Toast.LENGTH_SHORT)
                .show();
            return;
          }

          if (mapper.getCurrentLocation() == null && mapper.getFreezedLocation() == null) {
            throw new LocationNotAvailableException("Location is not available");
          }

          // must update address if user has used soft-keyboard
          if (housenumber.length() != 0) {
            address.setNumber(localizer.getString("buttonRight") + ": " + housenumber);
          }
          mapper.setCurrentAddress(address);

          // place address to the right
          mapper.saveCurrentAddress(0, -distance);
          // menu.updateShareIcon();

          clearInfo();
          vibrate();
          break;
        default:
          // all other buttons are used to add characters
          keyboardVibrate();
          housenumber += ((Button) v).getText();

          address.setNumber(housenumber);
          mapper.setCurrentAddress(address);
      }
    } catch (LocationNotAvailableException exception) {
      Toast.makeText(getActivity(), localizer.getString("locationNotAvailable"), Toast.LENGTH_SHORT)
          .show();
    }
    addressCallback.onHousenumberChanged(address.getNumber());
    updateLastHouseNumbers();
  }