private void addUniversalButtonLayoutToDialogView(String name, String signal) {
    TextWatcher tw =
        new TextWatcher() {
          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {}

          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

          @Override
          public void afterTextChanged(Editable s) {
            sendChannelDetailsChangedBroadcast(
                getActivity(), null, 0, null, -1, getCurrentUniversalButtons());
          }
        };
    LinearLayout newUniversalButtonLayout = new LinearLayout(getActivity());
    newUniversalButtonLayout.setOrientation(LinearLayout.VERTICAL);

    LinearLayout nameLayout = new LinearLayout(getActivity());
    nameLayout.setOrientation(LinearLayout.HORIZONTAL);

    AppCompatEditText universalButtonNameEditText = new AppCompatEditText(getActivity());
    universalButtonNameEditText.setHint(R.string.name);
    universalButtonNameEditText.setText(name);
    universalButtonNameEditText.addTextChangedListener(tw);

    ImageButton deleteUniversalButton = new ImageButton(getActivity());
    deleteUniversalButton.setBackgroundResource(android.R.color.transparent);
    deleteUniversalButton.setImageResource(android.R.drawable.ic_menu_delete);
    deleteUniversalButton.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            buttonsList.removeView((View) v.getParent().getParent());
            sendChannelDetailsChangedBroadcast(
                getActivity(), null, 0, null, -1, getCurrentUniversalButtons());
          }
        });

    nameLayout.addView(
        universalButtonNameEditText,
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT, 1.0f));
    nameLayout.addView(deleteUniversalButton);

    AppCompatEditText universalButtonSignalEditText = new AppCompatEditText(getActivity());
    universalButtonSignalEditText.setHint(R.string.enter_network_signal);
    universalButtonSignalEditText.setText(signal);
    universalButtonSignalEditText.addTextChangedListener(tw);

    newUniversalButtonLayout.addView(nameLayout);
    newUniversalButtonLayout.addView(universalButtonSignalEditText);

    buttonsList.addView(newUniversalButtonLayout);
  }
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Bundle bundle = getArguments();
    final Alarm alarm = bundle.getParcelable(KEY_ALARM);
    final TimerObj timer = bundle.getParcelable(KEY_TIMER);
    final String tag = bundle.getString(KEY_TAG);
    final String label =
        savedInstanceState != null
            ? savedInstanceState.getString(KEY_LABEL)
            : bundle.getString(KEY_LABEL);

    final Context context = getActivity();
    final int colorAccent = Utils.obtainStyledColor(context, R.attr.colorAccent, Color.RED);
    final int colorControlNormal =
        Utils.obtainStyledColor(context, R.attr.colorControlNormal, Color.WHITE);

    mLabelBox = new AppCompatEditText(context);
    mLabelBox.setOnEditorActionListener(
        new TextView.OnEditorActionListener() {
          @Override
          public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
              set(alarm, timer, tag);
              return true;
            }
            return false;
          }
        });
    mLabelBox.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
            final int color = TextUtils.isEmpty(s) ? colorControlNormal : colorAccent;
            mLabelBox.setSupportBackgroundTintList(ColorStateList.valueOf(color));
          }

          @Override
          public void afterTextChanged(Editable editable) {}
        });
    mLabelBox.setText(label);
    mLabelBox.selectAll();

    final int padding = getResources().getDimensionPixelSize(R.dimen.label_edittext_padding);
    final AlertDialog alertDialog =
        new AlertDialog.Builder(context)
            .setView(mLabelBox, padding, 0, padding, 0)
            .setPositiveButton(
                R.string.time_picker_set,
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                    set(alarm, timer, tag);
                  }
                })
            .setNegativeButton(
                R.string.time_picker_cancel,
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                    dismiss();
                  }
                })
            .setMessage(R.string.label)
            .create();

    alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    return alertDialog;
  }