예제 #1
0
  /**
   * Shows the 'Reply to ...' editor.
   *
   * @param post
   */
  private void showPostEditor(final Post post) {
    final EditText view = new EditText(this);
    view.setSingleLine(false);
    view.setLines(4);
    view.setMinLines(4);
    view.setMaxLines(4);

    new AlertDialog.Builder(this)
        .setTitle(post == null ? "New Post" : "Reply to @" + post.getAuthor())
        .setView(view)
        .setMessage(post == null ? null : post.getText())
        .setPositiveButton(
            "Post",
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();

                final String id = (post != null) ? post.getId() : null;
                new AddPostTask(id, myStreamPostsAdapter, accessToken)
                    .execute(view.getText().toString());
              }
            })
        .setNegativeButton(
            "Cancel",
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
              }
            })
        .show();
  }
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.activity_registration);
   uM = new UserManager();
   EditText bio = (EditText) findViewById(R.id.bio);
   bio.setHorizontallyScrolling(false);
   bio.setMaxLines(6);
 }
예제 #3
0
  @Override
  public void onStateChange(View view, HideablePartBehavior.State state) {
    switch (state) {
      case COLLAPSED:
        if (collapsed) return;
        if (getView() == null) return;
        collapsed = true;
        ((RelativeLayout.LayoutParams) send.getLayoutParams())
                .getRules()[RelativeLayout.ALIGN_BOTTOM] =
            R.id.text;
        ((RelativeLayout.LayoutParams) target.getLayoutParams())
                .getRules()[RelativeLayout.ALIGN_BOTTOM] =
            0;
        ((RelativeLayout.LayoutParams) text.getLayoutParams()).getRules()[RelativeLayout.LEFT_OF] =
            R.id.send;

        ((CoordinatorLayout.LayoutParams) commentFrame.getLayoutParams()).rightMargin =
            (int) (getView().getResources().getDisplayMetrics().density * 59);

        root.invalidate();
        text.clearFocus();
        text.setSingleLine(true);
        text.setVerticalScrollBarEnabled(false);

      case HIDDEN:
        hideKeyboard();
        break;

      case EXPANDED:
        if (!collapsed) return;
        if (getView() == null) return;
        collapsed = false;
        ((RelativeLayout.LayoutParams) send.getLayoutParams())
                .getRules()[RelativeLayout.ALIGN_BOTTOM] =
            0;
        ((RelativeLayout.LayoutParams) target.getLayoutParams())
                .getRules()[RelativeLayout.ALIGN_BOTTOM] =
            R.id.send;
        ((RelativeLayout.LayoutParams) text.getLayoutParams()).getRules()[RelativeLayout.LEFT_OF] =
            0;

        ((CoordinatorLayout.LayoutParams) commentFrame.getLayoutParams()).rightMargin = 0;
        root.invalidate();
        text.setVerticalScrollBarEnabled(true);
        text.setSingleLine(false);
        text.setMaxLines(9);

        showKeyboard();
        break;
    }
  }
예제 #4
0
    public android.app.Dialog onCreateDialog(android.os.Bundle savedInstanceState) {
      final String defaultValue = getArguments().getString("defaultValue");
      final int messageResourceId = getArguments().getInt("messageResourceId");
      final int promptId = getArguments().getInt("promptId");
      input = new EditText(getActivity());
      input.setMaxLines(1);
      input.setHint(defaultValue);

      if (savedInstanceState != null) {
        input.onRestoreInstanceState(savedInstanceState.getParcelable("value"));
      }

      AlertDialog dialog =
          new AlertDialog.Builder(getActivity())
              .setTitle(messageResourceId)
              .setView(input)
              .setPositiveButton(
                  getActivity().getResources().getString(android.R.string.ok),
                  new OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                      if (input.getText().length() == 0) {
                        ((PromptListener) getActivity())
                            .handlePromptResponse(defaultValue, promptId);
                      } else {
                        ((PromptListener) getActivity())
                            .handlePromptResponse(input.getText().toString(), promptId);
                      }
                    }
                  })
              .setNegativeButton(
                  getActivity().getResources().getString(android.R.string.cancel),
                  new OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                      ((PromptListener) getActivity()).handlePromptResponse(null, promptId);
                    }
                  })
              .create();
      return dialog;
    }
예제 #5
0
 public TiUIText(TiViewProxy proxy, boolean field) {
   super(proxy);
   if (DBG) {
     Log.d(LCAT, "Creating a text field");
   }
   this.field = field;
   tv = new EditText(getProxy().getContext());
   if (field) {
     tv.setSingleLine();
     tv.setMaxLines(1);
   }
   tv.addTextChangedListener(this);
   tv.setOnEditorActionListener(this);
   tv.setOnFocusChangeListener(this); // TODO refactor to TiUIView?
   // tv.setPadding(5, 0, 5, 0);
   if (field) {
     tv.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
   } else {
     tv.setGravity(Gravity.TOP | Gravity.LEFT);
   }
   setNativeView(tv);
 }
예제 #6
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    instance = this;
    View view = inflater.inflate(R.layout.chat, container, false);

    // Retain the fragment across configuration changes
    setRetainInstance(true);

    // Retrieve parameter from intent
    sipUri = getArguments().getString("SipUri");
    displayName = getArguments().getString("DisplayName");
    pictureUri = getArguments().getString("PictureUri");

    // Initialize UI
    contactName = (TextView) view.findViewById(R.id.contactName);
    contactPicture = (AvatarWithShadow) view.findViewById(R.id.contactPicture);
    messagesList = (ListView) view.findViewById(R.id.chatMessageList);
    textLayout = (RelativeLayout) view.findViewById(R.id.messageLayout);
    progressBar = (ProgressBar) view.findViewById(R.id.progressbar);
    topBar = (LinearLayout) view.findViewById(R.id.topbar);

    sendMessage = (TextView) view.findViewById(R.id.sendMessage);
    sendMessage.setOnClickListener(this);

    remoteComposing = (TextView) view.findViewById(R.id.remoteComposing);
    remoteComposing.setVisibility(View.GONE);

    uploadLayout = (RelativeLayout) view.findViewById(R.id.uploadLayout);
    uploadLayout.setVisibility(View.GONE);

    displayChatHeader(displayName, pictureUri);

    // Manage multiline
    message = (EditText) view.findViewById(R.id.message);
    if (!getResources().getBoolean(R.bool.allow_chat_multiline)) {
      message.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE);
      message.setMaxLines(1);
    }

    sendImage = (TextView) view.findViewById(R.id.sendPicture);
    if (!getResources().getBoolean(R.bool.disable_chat_send_file)) {
      sendImage.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              pickImage();
            }
          });
    } else {
      sendImage.setEnabled(false);
    }

    back = (TextView) view.findViewById(R.id.back);
    if (back != null) {
      back.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              getActivity().finish();
            }
          });
    }

    cancelUpload = (ImageView) view.findViewById(R.id.cancelUpload);
    cancelUpload.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (currentMessageInFileTransferUploadState != null) {
              uploadLayout.setVisibility(View.GONE);
              textLayout.setVisibility(View.VISIBLE);
              progressBar.setProgress(0);
              currentMessageInFileTransferUploadState.cancelFileTransfer();
              currentMessageInFileTransferUploadState = null;
            }
          }
        });

    LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
    if (lc != null) {
      chatRoom = lc.getOrCreateChatRoom(sipUri);
      // Only works if using liblinphone storage
      chatRoom.markAsRead();
    }

    mListener =
        new LinphoneCoreListenerBase() {
          @Override
          public void messageReceived(
              LinphoneCore lc, LinphoneChatRoom cr, LinphoneChatMessage message) {
            LinphoneAddress from = cr.getPeerAddress();
            if (from.asStringUriOnly().equals(sipUri)) {
              invalidate();
            }
          }

          @Override
          public void isComposingReceived(LinphoneCore lc, LinphoneChatRoom room) {
            if (chatRoom != null
                && room != null
                && chatRoom
                    .getPeerAddress()
                    .asStringUriOnly()
                    .equals(room.getPeerAddress().asStringUriOnly())) {
              remoteComposing.setVisibility(
                  chatRoom.isRemoteComposing() ? View.VISIBLE : View.GONE);
            }
          }
        };

    textWatcher =
        new TextWatcher() {
          public void afterTextChanged(Editable arg0) {}

          public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {}

          public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
            if (message.getText().toString().equals("")) {
              sendMessage.setEnabled(false);
            } else {
              if (chatRoom != null) chatRoom.compose();
              sendMessage.setEnabled(true);
            }
          }
        };

    // Force hide keyboard
    getActivity()
        .getWindow()
        .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

    return view;
  }
예제 #7
0
  private void editEntry(final long row_id_input) {
    AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
    final EditText titleInputField = new EditText(this);
    final EditText descriptionInputField = new EditText(this);
    LinearLayout layout = new LinearLayout(this);

    layout.setOrientation(LinearLayout.VERTICAL);

    String[] columns =
        new String[] {
          DiaryDatabaseHelper.KEY_TITLE,
          DiaryDatabaseHelper.KEY_DATE,
          DiaryDatabaseHelper.KEY_DESCRIPTION
        };
    final String row_id = DiaryDatabaseHelper.KEY_ID + "=" + row_id_input;

    Cursor cursor =
        db.query(DiaryDatabaseHelper.DATABASE_TABLE, columns, row_id, null, null, null, null);
    cursor.moveToFirst();

    // save the timestamp, we won't touch it
    final String date = cursor.getString(cursor.getColumnIndex(DiaryDatabaseHelper.KEY_DATE));

    // set title edittext to single line mode (just in case)
    titleInputField.setSingleLine();

    // vertical scrolling
    descriptionInputField.setVerticalScrollBarEnabled(true);
    // make edittext multiline and display scrollbar after five lines of text
    descriptionInputField.setSingleLine(false);
    descriptionInputField.setMaxLines(5);
    descriptionInputField.setMovementMethod(new ScrollingMovementMethod());
    // no horizontal scrolling -> word wrap
    descriptionInputField.setHorizontallyScrolling(false);

    // fill EditText-fields with existing entry data
    titleInputField.setText(cursor.getString(cursor.getColumnIndex(DiaryDatabaseHelper.KEY_TITLE)));
    descriptionInputField.setText(
        cursor.getString(cursor.getColumnIndex(DiaryDatabaseHelper.KEY_DESCRIPTION)));

    // set EditText-fields to capitalize first letters
    titleInputField.setInputType(
        InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
    descriptionInputField.setInputType(
        InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);

    // add fields to layout
    layout.addView(titleInputField);
    layout.addView(descriptionInputField);

    // assign layout to dialog + set title
    dialogBuilder.setView(layout);
    dialogBuilder.setTitle("Edit entry");

    // confirm button + behaviour
    dialogBuilder.setPositiveButton(
        "Update entry",
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
            // get strings from the user input fields
            String titleText = titleInputField.getText().toString();
            String descriptionText = descriptionInputField.getText().toString();

            // open database
            databaseHelper = new DiaryDatabaseHelper(MainActivity.this);
            db = databaseHelper.getWritableDatabase();

            // store the input data
            ContentValues values = new ContentValues();
            values.put(DiaryDatabaseHelper.KEY_TITLE, titleText);
            values.put(DiaryDatabaseHelper.KEY_DESCRIPTION, descriptionText);
            values.put(DiaryDatabaseHelper.KEY_DATE, date);

            // update row with new data
            databaseHelper.updateRow(db, row_id_input, values);

            // refresh UI so we can see the changes made
            refreshUI();

            // display toast notification
            Toast.makeText(getApplicationContext(), "Entry updated", Toast.LENGTH_SHORT).show();
          }
        });

    // set cancel button
    dialogBuilder.setNegativeButton("Cancel", null);

    // finally show the dialog
    dialogBuilder.create().show();
  }
예제 #8
0
  private void newEntry() {
    AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
    final EditText titleInputField = new EditText(this);
    final EditText descriptionInputField = new EditText(this);
    LinearLayout layout = new LinearLayout(this);

    layout.setOrientation(LinearLayout.VERTICAL);

    // set text hints for empty EditText-fields
    titleInputField.setHint("Title");
    descriptionInputField.setHint("What's on your mind?");

    // set EditText-fields to capitalize first letter of every sentence
    titleInputField.setInputType(
        InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
    descriptionInputField.setInputType(
        InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);

    // set title edittext to single line mode (just in case)
    titleInputField.setSingleLine();

    // vertical scrolling
    descriptionInputField.setVerticalScrollBarEnabled(true);
    // make edittext multiline and display scrollbar after five lines of text
    descriptionInputField.setSingleLine(false);
    descriptionInputField.setMaxLines(5);
    descriptionInputField.setMovementMethod(new ScrollingMovementMethod());
    // no horizontal scrolling -> word wrap
    descriptionInputField.setHorizontallyScrolling(false);

    // add fields to layout
    layout.addView(titleInputField);
    layout.addView(descriptionInputField);

    // assign layout to dialog + set title
    dialogBuilder.setView(layout);
    dialogBuilder.setTitle("New entry");

    // confirm button + behaviour
    dialogBuilder.setPositiveButton(
        "Confirm",
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
            // get strings from the user input fields
            String titleText = titleInputField.getText().toString();
            String descriptionText = descriptionInputField.getText().toString();

            // generate timestamp
            String timestamp = (DateFormat.format("yyyy.MM.dd", new java.util.Date()).toString());

            // create database (or re-open if exists)
            databaseHelper = new DiaryDatabaseHelper(MainActivity.this);
            db = databaseHelper.getWritableDatabase();

            // store the input data
            ContentValues values = new ContentValues();
            values.put(DiaryDatabaseHelper.KEY_TITLE, titleText);
            values.put(DiaryDatabaseHelper.KEY_DESCRIPTION, descriptionText);
            values.put(DiaryDatabaseHelper.KEY_DATE, timestamp);

            // insert data into database table
            databaseHelper.insertRow(db, values);

            // display toast notification
            Toast.makeText(getApplicationContext(), "New entry created", Toast.LENGTH_SHORT).show();

            // refresh UI so we can see the changes made
            refreshUI();
          }
        });

    // set cancel button
    dialogBuilder.setNegativeButton("Cancel", null);

    // finally show the dialog
    dialogBuilder.create().show();
  }
예제 #9
0
  private void createNewContactObject(String type, View my_contact_view) {
    if (my_contact_view == null) {
      my_contact_view = fragment_mycontact.getView();
    }

    if (my_contact_view == null) return;

    LinearLayout ll_data;
    List<String> list = new ArrayList<String>();
    int it = android.text.InputType.TYPE_CLASS_TEXT;
    int hint = 0;

    // Typen setzen:
    List<Integer> list_number = new ArrayList<Integer>();

    for (int i = 0; i < array_en_type.length; i++) {
      if (array_en_type[i].equals(type)) {
        list_number.add(i);
      }
    }

    for (int i = 0; i < list_number.size(); i++) {
      list.add((array_en_name[list_number.get(i)]));
    }

    final String[] spinnerArray = list.toArray(new String[list.size()]);

    // -----------

    LinearLayout ll_telephone =
        (LinearLayout) my_contact_view.findViewById(R.id.mycontact_ll_data_telephone);
    LinearLayout ll_email =
        (LinearLayout) my_contact_view.findViewById(R.id.mycontact_ll_data_email);
    LinearLayout ll_other =
        (LinearLayout) my_contact_view.findViewById(R.id.mycontact_ll_data_other);

    // new row
    LinearLayout row = new LinearLayout(this);
    row.setOrientation(LinearLayout.HORIZONTAL);

    DisplayMetrics tmp_metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(tmp_metrics);
    int resolution_width = tmp_metrics.widthPixels;

    final boolean large_screen = (resolution_width >= 720);

    final EditText et = new EditText(this);
    LayoutParams lp_et;
    lp_et = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT, 1);

    if (type.equals("number")) {
      ll_data = ll_telephone;

      it = InputType.TYPE_CLASS_PHONE;

      hint = R.string.telephone;

    } else if (type.equals("email")) {
      ll_data = ll_email;

      it = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS;

      hint = R.string.email;

    } else {
      ll_data = ll_other;

      if (type.equals("address")) {

        et.setMinLines(1);
        et.setMaxLines(3);
        et.setLines(2);

        hint = R.string.address;
        it =
            InputType.TYPE_CLASS_TEXT
                | InputType
                    .TYPE_TEXT_FLAG_MULTI_LINE; // android.text.InputType.TYPE_TEXT_VARIATION_POSTAL_ADDRESS;
        lp_et = new LayoutParams(LayoutParams.WRAP_CONTENT, large_screen ? 130 : 90, 1);

        row.setLayoutParams(
            new LayoutParams(LayoutParams.MATCH_PARENT, (large_screen ? 130 : 90) + 20));

        et.setImeOptions(EditorInfo.IME_FLAG_NO_ENTER_ACTION);
        // et.setGravity(Gravity.LEFT | Gravity.TOP );

      } else if (type.equals("website")) {
        hint = R.string.website;
        it = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI;
      }
    }

    ((LinearLayout) ll_data.getParent()).setVisibility(LinearLayout.VISIBLE);

    et.setTextSize(large_screen ? 16 : 14); // EditText-Textgr��e
    et.setEms(10);
    et.setHint(hint);

    et.setInputType(it);

    lp_et.setMargins(0, 3, 0, 0);
    et.setLayoutParams(lp_et);

    Spinner spinner = new Spinner(this);
    LayoutParams lp_spinner =
        new LayoutParams(
            large_screen ? Functions.dpsToPx(this, 100) : Functions.dpsToPx(this, 80), /*300 : 200*/
            LayoutParams.MATCH_PARENT);

    lp_spinner.setMargins(0, 3, 0, 0);

    MySpinnerArrayAdapter dataAdapter = new MySpinnerArrayAdapter(this, list, large_screen);

    dataAdapter.setDropDownViewResource(
        android.support.v7.appcompat.R.layout.support_simple_spinner_dropdown_item);

    spinner.setAdapter(dataAdapter);
    spinner.setLayoutParams(lp_spinner);

    spinner.setOnItemSelectedListener(
        new OnItemSelectedListener() {

          @Override
          public void onItemSelected(
              final AdapterView<?> adapterView, final View view, int arg2, long arg3) {
            final Spinner spinner = (Spinner) adapterView;
            MySpinnerArrayAdapter adapter = (MySpinnerArrayAdapter) spinner.getAdapter();
            if (adapter
                .getItem(arg2)
                .toLowerCase(new Locale("en"))
                .equals(getString(R.string.en_custom).toLowerCase(new Locale("en")))) {

              LinearLayout ll = new LinearLayout(MainActivity.this);
              final EditText et = new EditText(MainActivity.this);

              LinearLayout.LayoutParams layoutParams =
                  new LinearLayout.LayoutParams(
                      LinearLayout.LayoutParams.MATCH_PARENT,
                      LinearLayout.LayoutParams.WRAP_CONTENT);
              layoutParams.setMargins(0, 20, 0, 0);

              et.setTextColor(Color.BLACK);
              et.requestFocus();

              // et.setHint(R.string.place);

              ll.addView(et, layoutParams);

              AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
              builder
                  .setView(ll)
                  .setTitle(R.string.message_custom_en)
                  .setPositiveButton(
                      android.R.string.ok,
                      new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {

                          String[] newItems = new String[spinnerArray.length + 1];
                          System.arraycopy(spinnerArray, 0, newItems, 0, spinnerArray.length);
                          newItems[newItems.length - 1] = et.getText().toString();

                          MySpinnerArrayAdapter adapter =
                              new MySpinnerArrayAdapter(
                                  getApplicationContext(),
                                  newItems,
                                  ((MySpinnerArrayAdapter) spinner.getAdapter()).getLargeScreen());
                          spinner.setAdapter(adapter);
                          spinner.setSelection(newItems.length - 1);
                        }
                      })
                  .setNegativeButton(
                      android.R.string.cancel,
                      new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {}
                      })
                  .create()
                  .show();
            }
          }

          @Override
          public void onNothingSelected(AdapterView<?> arg0) {
            // TODO Auto-generated method stub

          }
        });

    Button btn = new Button(this);
    btn.setText("x");
    LayoutParams lp_btn = new LayoutParams(Functions.dpsToPx(this, 32), LayoutParams.WRAP_CONTENT);
    lp_btn.setMargins(-10, 0, -10, 0);
    btn.setLayoutParams(lp_btn);
    btn.setBackgroundColor(Color.TRANSPARENT);

    btn.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            if (((LinearLayout) v.getParent().getParent()).getChildCount() == 1) {
              ((LinearLayout) v.getParent().getParent().getParent()).setVisibility(View.GONE);
            }
            ((LinearLayout) v.getParent().getParent()).removeView((LinearLayout) v.getParent());
          }
        });

    row.addView(et);
    row.addView(spinner);
    row.addView(btn);

    row.setTag(type);

    ll_data.addView(row);
  }
예제 #10
0
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == 0) {
      if (resultCode == -1) {
        if (data != null) {
          if (data.hasExtra("data")) {
            imgTmp.setImage(
                Bitmap.createScaledBitmap(
                    (Bitmap) data.getParcelableExtra("data"), 640, 480, true));
          }
        } else {
          imgTmp.setImage(
              Bitmap.createScaledBitmap(BitmapFactory.decodeFile(name), 640, 480, true));
        }

        final EditText desc = new EditText(this);
        desc.setLines(1);
        desc.setMaxLines(1);

        desc.setBackgroundResource(R.drawable.fondo_edittext);
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setView(desc);

        builder.setIcon(R.drawable.ic_camera);
        builder.setTitle("¿Qué fotografió?");
        builder.setPositiveButton("Guardar", null);
        builder.setNegativeButton(
            "Cancelar",
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialogInterface, int i) {
                imgTmp = null;
                dialogInterface.dismiss();
              }
            });
        builder.setCancelable(false);

        final AlertDialog alert = builder.create();
        alert.setCanceledOnTouchOutside(false);
        alert.setCancelable(false);
        alert.show();
        alert
            .getButton(DialogInterface.BUTTON_POSITIVE)
            .setOnClickListener(
                new View.OnClickListener() {
                  @Override
                  public void onClick(View view) {
                    if (desc.getText().toString().length() == 0) {
                      Toast.makeText(
                              getApplicationContext(),
                              "Ingrese una descripción de lo fotografiado",
                              Toast.LENGTH_LONG)
                          .show();
                      return;
                    }
                    imgTmp.setComment(desc.getText().toString());
                    imgTmp.newNameRelevo(imgTmp.getIdSystem(), imgTmp.getComment());
                    imagenes.add(imgTmp);
                    imgTmp = null;
                    alert.dismiss();
                  }
                });
      }
    }

    if (requestCode == idRelevo) {
      if (resultCode == Activity.RESULT_OK) {
        reg.clearPreferences();
        ((Activity) context).finish();
      }
    }
  }
예제 #11
0
 public void setMultipleLine(int lines) {
   etTitle.setSingleLine(false);
   etTitle.setMaxLines(lines);
 }
예제 #12
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    sipUri = getArguments().getString("SipUri");
    String displayName = getArguments().getString("DisplayName");
    String pictureUri = getArguments().getString("PictureUri");

    view = inflater.inflate(R.layout.chat, container, false);

    useLinphoneMessageStorage = getResources().getBoolean(R.bool.use_linphone_chat_storage);

    contactName = (TextView) view.findViewById(R.id.contactName);
    contactPicture = (AvatarWithShadow) view.findViewById(R.id.contactPicture);

    sendMessage = (TextView) view.findViewById(R.id.sendMessage);
    sendMessage.setOnClickListener(this);

    remoteComposing = (TextView) view.findViewById(R.id.remoteComposing);
    remoteComposing.setVisibility(View.GONE);

    messagesList = (ListView) view.findViewById(R.id.chatMessageList);

    message = (EditText) view.findViewById(R.id.message);
    if (!getActivity().getResources().getBoolean(R.bool.allow_chat_multiline)) {
      message.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE);
      message.setMaxLines(1);
    }

    uploadLayout = (RelativeLayout) view.findViewById(R.id.uploadLayout);
    uploadLayout.setVisibility(View.GONE);
    textLayout = (RelativeLayout) view.findViewById(R.id.messageLayout);

    progressBar = (ProgressBar) view.findViewById(R.id.progressbar);
    sendImage = (TextView) view.findViewById(R.id.sendPicture);
    if (!getResources().getBoolean(R.bool.disable_chat_send_file)) {
      registerForContextMenu(sendImage);
      sendImage.setOnClickListener(
          new OnClickListener() {
            @Override
            public void onClick(View v) {
              pickImage();
            }
          });
    } else {
      sendImage.setEnabled(false);
    }

    cancelUpload = (ImageView) view.findViewById(R.id.cancelUpload);
    cancelUpload.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            uploadThread.interrupt();
            uploadLayout.setVisibility(View.GONE);
            textLayout.setVisibility(View.VISIBLE);
            progressBar.setProgress(0);
          }
        });

    LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
    if (lc != null) {
      chatRoom = lc.getOrCreateChatRoom(sipUri);
      // Only works if using liblinphone storage
      chatRoom.markAsRead();
    }

    displayChatHeader(displayName, pictureUri);

    uploadServerUri = LinphonePreferences.instance().getSharingPictureServerUrl();

    textWatcher =
        new TextWatcher() {
          public void afterTextChanged(Editable arg0) {}

          public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {}

          public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
            if (message.getText().toString().equals("")) {
              sendMessage.setEnabled(false);
            } else {
              if (chatRoom != null) chatRoom.compose();
              sendMessage.setEnabled(true);
            }
          }
        };

    // Force hide keyboard
    if (LinphoneActivity.isInstanciated()) {
      InputMethodManager imm =
          (InputMethodManager)
              LinphoneActivity.instance().getSystemService(Context.INPUT_METHOD_SERVICE);
      imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
    }

    // Workaround for SGS3 issue
    if (savedInstanceState != null) {
      fileToUploadPath = savedInstanceState.getString("fileToUploadPath");
      imageToUpload = savedInstanceState.getParcelable("imageToUpload");
    }
    if (fileToUploadPath != null || imageToUpload != null) {
      sendImage.post(
          new Runnable() {
            @Override
            public void run() {
              sendImage.showContextMenu();
            }
          });
    }

    return view;
  }
예제 #13
0
  @Override
  public View createView(LayoutInflater inflater) {
    if (fragmentView == null) {
      searching = false;
      searchWas = false;

      actionBar.setBackButtonImage(R.drawable.ic_ab_back);
      actionBar.setAllowOverlayTitle(true);
      if (isAlwaysShare) {
        actionBar.setTitle(
            LocaleController.getString("AlwaysShareWithTitle", R.string.AlwaysShareWithTitle));
      } else if (isNeverShare) {
        actionBar.setTitle(
            LocaleController.getString("NeverShareWithTitle", R.string.NeverShareWithTitle));
      } else {
        actionBar.setTitle(
            isBroadcast
                ? LocaleController.getString("NewBroadcastList", R.string.NewBroadcastList)
                : LocaleController.getString("NewGroup", R.string.NewGroup));
        actionBar.setSubtitle(
            LocaleController.formatString(
                "MembersCount", R.string.MembersCount, selectedContacts.size(), maxCount));
      }

      actionBar.setActionBarMenuOnItemClick(
          new ActionBar.ActionBarMenuOnItemClick() {
            @Override
            public void onItemClick(int id) {
              if (id == -1) {
                finishFragment();
              } else if (id == done_button) {
                if (selectedContacts.isEmpty()) {
                  return;
                }
                ArrayList<Integer> result = new ArrayList<>();
                result.addAll(selectedContacts.keySet());
                if (isAlwaysShare || isNeverShare) {
                  if (delegate != null) {
                    delegate.didSelectUsers(result);
                  }
                  finishFragment();
                } else {
                  Bundle args = new Bundle();
                  args.putIntegerArrayList("result", result);
                  args.putBoolean("broadcast", isBroadcast);
                  presentFragment(new GroupCreateFinalActivity(args));
                }
              }
            }
          });
      ActionBarMenu menu = actionBar.createMenu();
      menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));

      searchListViewAdapter = new ContactsSearchAdapter(getParentActivity(), null, false);
      searchListViewAdapter.setCheckedMap(selectedContacts);
      searchListViewAdapter.setUseUserCell(true);
      listViewAdapter = new ContactsAdapter(getParentActivity(), true, false, null);
      listViewAdapter.setCheckedMap(selectedContacts);

      fragmentView = new LinearLayout(getParentActivity());
      LinearLayout linearLayout = (LinearLayout) fragmentView;
      linearLayout.setOrientation(LinearLayout.VERTICAL);

      FrameLayout frameLayout = new FrameLayout(getParentActivity());
      linearLayout.addView(frameLayout);
      LinearLayout.LayoutParams layoutParams =
          (LinearLayout.LayoutParams) frameLayout.getLayoutParams();
      layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
      layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT;
      layoutParams.gravity = Gravity.TOP;
      frameLayout.setLayoutParams(layoutParams);

      userSelectEditText = new EditText(getParentActivity());
      userSelectEditText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
      userSelectEditText.setHintTextColor(0xff979797);
      userSelectEditText.setTextColor(0xff212121);
      userSelectEditText.setInputType(
          InputType.TYPE_TEXT_VARIATION_FILTER
              | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS
              | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
      userSelectEditText.setMinimumHeight(AndroidUtilities.dp(54));
      userSelectEditText.setSingleLine(false);
      userSelectEditText.setLines(2);
      userSelectEditText.setMaxLines(2);
      userSelectEditText.setVerticalScrollBarEnabled(true);
      userSelectEditText.setHorizontalScrollBarEnabled(false);
      userSelectEditText.setPadding(0, 0, 0, 0);
      userSelectEditText.setImeOptions(
          EditorInfo.IME_ACTION_DONE | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
      userSelectEditText.setGravity(
          (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
      AndroidUtilities.clearCursorDrawable(userSelectEditText);
      frameLayout.addView(userSelectEditText);
      FrameLayout.LayoutParams layoutParams1 =
          (FrameLayout.LayoutParams) userSelectEditText.getLayoutParams();
      layoutParams1.width = FrameLayout.LayoutParams.MATCH_PARENT;
      layoutParams1.height = FrameLayout.LayoutParams.WRAP_CONTENT;
      layoutParams1.leftMargin = AndroidUtilities.dp(10);
      layoutParams1.rightMargin = AndroidUtilities.dp(10);
      layoutParams1.gravity = Gravity.TOP;
      userSelectEditText.setLayoutParams(layoutParams1);

      if (isAlwaysShare) {
        userSelectEditText.setHint(
            LocaleController.getString(
                "AlwaysShareWithPlaceholder", R.string.AlwaysShareWithPlaceholder));
      } else if (isNeverShare) {
        userSelectEditText.setHint(
            LocaleController.getString(
                "NeverShareWithPlaceholder", R.string.NeverShareWithPlaceholder));
      } else {
        userSelectEditText.setHint(
            LocaleController.getString("SendMessageTo", R.string.SendMessageTo));
      }
      if (Build.VERSION.SDK_INT >= 11) {
        userSelectEditText.setTextIsSelectable(false);
      }
      userSelectEditText.addTextChangedListener(
          new TextWatcher() {
            @Override
            public void beforeTextChanged(
                CharSequence charSequence, int start, int count, int after) {
              if (!ignoreChange) {
                beforeChangeIndex = userSelectEditText.getSelectionStart();
                changeString = new SpannableString(charSequence);
              }
            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {}

            @Override
            public void afterTextChanged(Editable editable) {
              if (!ignoreChange) {
                boolean search = false;
                int afterChangeIndex = userSelectEditText.getSelectionEnd();
                if (editable.toString().length() < changeString.toString().length()) {
                  String deletedString = "";
                  try {
                    deletedString =
                        changeString.toString().substring(afterChangeIndex, beforeChangeIndex);
                  } catch (Exception e) {
                    FileLog.e("tmessages", e);
                  }
                  if (deletedString.length() > 0) {
                    if (searching && searchWas) {
                      search = true;
                    }
                    Spannable span = userSelectEditText.getText();
                    for (int a = 0; a < allSpans.size(); a++) {
                      XImageSpan sp = allSpans.get(a);
                      if (span.getSpanStart(sp) == -1) {
                        allSpans.remove(sp);
                        selectedContacts.remove(sp.uid);
                      }
                    }
                    if (!isAlwaysShare && !isNeverShare) {
                      actionBar.setSubtitle(
                          LocaleController.formatString(
                              "MembersCount",
                              R.string.MembersCount,
                              selectedContacts.size(),
                              maxCount));
                    }
                    listView.invalidateViews();
                  } else {
                    search = true;
                  }
                } else {
                  search = true;
                }
                if (search) {
                  String text = userSelectEditText.getText().toString().replace("<", "");
                  if (text.length() != 0) {
                    searching = true;
                    searchWas = true;
                    if (listView != null) {
                      listView.setAdapter(searchListViewAdapter);
                      searchListViewAdapter.notifyDataSetChanged();
                      if (android.os.Build.VERSION.SDK_INT >= 11) {
                        listView.setFastScrollAlwaysVisible(false);
                      }
                      listView.setFastScrollEnabled(false);
                      listView.setVerticalScrollBarEnabled(true);
                    }
                    if (emptyTextView != null) {
                      emptyTextView.setText(
                          LocaleController.getString("NoResult", R.string.NoResult));
                    }
                    searchListViewAdapter.searchDialogs(text);
                  } else {
                    searchListViewAdapter.searchDialogs(null);
                    searching = false;
                    searchWas = false;
                    listView.setAdapter(listViewAdapter);
                    listViewAdapter.notifyDataSetChanged();
                    if (android.os.Build.VERSION.SDK_INT >= 11) {
                      listView.setFastScrollAlwaysVisible(true);
                    }
                    listView.setFastScrollEnabled(true);
                    listView.setVerticalScrollBarEnabled(false);
                    emptyTextView.setText(
                        LocaleController.getString("NoContacts", R.string.NoContacts));
                  }
                }
              }
            }
          });

      LinearLayout emptyTextLayout = new LinearLayout(getParentActivity());
      emptyTextLayout.setVisibility(View.INVISIBLE);
      emptyTextLayout.setOrientation(LinearLayout.VERTICAL);
      linearLayout.addView(emptyTextLayout);
      layoutParams = (LinearLayout.LayoutParams) emptyTextLayout.getLayoutParams();
      layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
      layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
      emptyTextLayout.setLayoutParams(layoutParams);
      emptyTextLayout.setOnTouchListener(
          new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
              return true;
            }
          });

      emptyTextView = new TextView(getParentActivity());
      emptyTextView.setTextColor(0xff808080);
      emptyTextView.setTextSize(20);
      emptyTextView.setGravity(Gravity.CENTER);
      emptyTextView.setText(LocaleController.getString("NoContacts", R.string.NoContacts));
      emptyTextLayout.addView(emptyTextView);
      layoutParams = (LinearLayout.LayoutParams) emptyTextView.getLayoutParams();
      layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
      layoutParams.height = LinearLayout.LayoutParams.MATCH_PARENT;
      layoutParams.weight = 0.5f;
      emptyTextView.setLayoutParams(layoutParams);

      FrameLayout frameLayout2 = new FrameLayout(getParentActivity());
      emptyTextLayout.addView(frameLayout2);
      layoutParams = (LinearLayout.LayoutParams) frameLayout2.getLayoutParams();
      layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
      layoutParams.height = LinearLayout.LayoutParams.MATCH_PARENT;
      layoutParams.weight = 0.5f;
      frameLayout2.setLayoutParams(layoutParams);

      listView = new LetterSectionsListView(getParentActivity());
      listView.setEmptyView(emptyTextLayout);
      listView.setVerticalScrollBarEnabled(false);
      listView.setDivider(null);
      listView.setDividerHeight(0);
      listView.setFastScrollEnabled(true);
      listView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY);
      listView.setAdapter(listViewAdapter);
      if (Build.VERSION.SDK_INT >= 11) {
        listView.setFastScrollAlwaysVisible(true);
        listView.setVerticalScrollbarPosition(
            LocaleController.isRTL
                ? ListView.SCROLLBAR_POSITION_LEFT
                : ListView.SCROLLBAR_POSITION_RIGHT);
      }
      linearLayout.addView(listView);
      layoutParams = (LinearLayout.LayoutParams) listView.getLayoutParams();
      layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
      layoutParams.height = LinearLayout.LayoutParams.MATCH_PARENT;
      listView.setLayoutParams(layoutParams);
      listView.setOnItemClickListener(
          new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
              TLRPC.User user = null;
              if (searching && searchWas) {
                user = searchListViewAdapter.getItem(i);
              } else {
                int section = listViewAdapter.getSectionForPosition(i);
                int row = listViewAdapter.getPositionInSectionForPosition(i);
                if (row < 0 || section < 0) {
                  return;
                }
                user = (TLRPC.User) listViewAdapter.getItem(section, row);
              }
              if (user == null) {
                return;
              }

              boolean check = true;
              if (selectedContacts.containsKey(user.id)) {
                check = false;
                try {
                  XImageSpan span = selectedContacts.get(user.id);
                  selectedContacts.remove(user.id);
                  SpannableStringBuilder text =
                      new SpannableStringBuilder(userSelectEditText.getText());
                  text.delete(text.getSpanStart(span), text.getSpanEnd(span));
                  allSpans.remove(span);
                  ignoreChange = true;
                  userSelectEditText.setText(text);
                  userSelectEditText.setSelection(text.length());
                  ignoreChange = false;
                } catch (Exception e) {
                  FileLog.e("tmessages", e);
                }
              } else {
                if (selectedContacts.size() == maxCount) {
                  return;
                }
                ignoreChange = true;
                XImageSpan span = createAndPutChipForUser(user);
                span.uid = user.id;
                ignoreChange = false;
              }
              if (!isAlwaysShare && !isNeverShare) {
                actionBar.setSubtitle(
                    LocaleController.formatString(
                        "MembersCount", R.string.MembersCount, selectedContacts.size(), maxCount));
              }
              if (searching || searchWas) {
                ignoreChange = true;
                SpannableStringBuilder ssb = new SpannableStringBuilder("");
                for (ImageSpan sp : allSpans) {
                  ssb.append("<<");
                  ssb.setSpan(
                      sp,
                      ssb.length() - 2,
                      ssb.length(),
                      SpannableStringBuilder.SPAN_EXCLUSIVE_EXCLUSIVE);
                }
                userSelectEditText.setText(ssb);
                userSelectEditText.setSelection(ssb.length());
                ignoreChange = false;

                searchListViewAdapter.searchDialogs(null);
                searching = false;
                searchWas = false;
                listView.setAdapter(listViewAdapter);
                listViewAdapter.notifyDataSetChanged();
                if (android.os.Build.VERSION.SDK_INT >= 11) {
                  listView.setFastScrollAlwaysVisible(true);
                }
                listView.setFastScrollEnabled(true);
                listView.setVerticalScrollBarEnabled(false);
                emptyTextView.setText(
                    LocaleController.getString("NoContacts", R.string.NoContacts));
              } else {
                if (view instanceof UserCell) {
                  ((UserCell) view).setChecked(check, true);
                }
              }
            }
          });
      listView.setOnScrollListener(
          new AbsListView.OnScrollListener() {
            @Override
            public void onScrollStateChanged(AbsListView absListView, int i) {
              if (i == SCROLL_STATE_TOUCH_SCROLL) {
                AndroidUtilities.hideKeyboard(userSelectEditText);
              }
              if (listViewAdapter != null) {
                listViewAdapter.setIsScrolling(i != SCROLL_STATE_IDLE);
              }
            }

            @Override
            public void onScroll(
                AbsListView absListView,
                int firstVisibleItem,
                int visibleItemCount,
                int totalItemCount) {
              if (absListView.isFastScrollEnabled()) {
                AndroidUtilities.clearDrawableAnimation(absListView);
              }
            }
          });
    } else {
      ViewGroup parent = (ViewGroup) fragmentView.getParent();
      if (parent != null) {
        parent.removeView(fragmentView);
      }
    }
    return fragmentView;
  }
예제 #14
0
  @Override
  public View createView(Context context, LayoutInflater inflater) {
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setAllowOverlayTitle(true);
    actionBar.setTitle(LocaleController.getString("EditName", R.string.EditName));
    actionBar.setActionBarMenuOnItemClick(
        new ActionBar.ActionBarMenuOnItemClick() {
          @Override
          public void onItemClick(int id) {
            if (id == -1) {
              finishFragment();
            } else if (id == done_button) {
              if (firstNameField.getText().length() != 0) {
                saveName();
                finishFragment();
              }
            }
          }
        });

    ActionBarMenu menu = actionBar.createMenu();
    doneButton = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));

    TLRPC.User user = MessagesController.getInstance().getUser(UserConfig.getClientUserId());
    if (user == null) {
      user = UserConfig.getCurrentUser();
    }

    fragmentView = new LinearLayout(context);
    fragmentView.setLayoutParams(
        new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    ((LinearLayout) fragmentView).setOrientation(LinearLayout.VERTICAL);
    fragmentView.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            return true;
          }
        });

    firstNameField = new EditText(context);
    firstNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
    firstNameField.setHintTextColor(0xff979797);
    firstNameField.setTextColor(0xff212121);
    firstNameField.setMaxLines(1);
    firstNameField.setLines(1);
    firstNameField.setSingleLine(true);
    firstNameField.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
    firstNameField.setInputType(
        InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
    firstNameField.setImeOptions(EditorInfo.IME_ACTION_NEXT);
    firstNameField.setHint(LocaleController.getString("FirstName", R.string.FirstName));
    AndroidUtilities.clearCursorDrawable(firstNameField);
    ((LinearLayout) fragmentView).addView(firstNameField);
    LinearLayout.LayoutParams layoutParams =
        (LinearLayout.LayoutParams) firstNameField.getLayoutParams();
    layoutParams.topMargin = AndroidUtilities.dp(24);
    layoutParams.height = AndroidUtilities.dp(36);
    layoutParams.leftMargin = AndroidUtilities.dp(24);
    layoutParams.rightMargin = AndroidUtilities.dp(24);
    layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
    firstNameField.setLayoutParams(layoutParams);
    firstNameField.setOnEditorActionListener(
        new TextView.OnEditorActionListener() {
          @Override
          public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
            if (i == EditorInfo.IME_ACTION_NEXT) {
              lastNameField.requestFocus();
              lastNameField.setSelection(lastNameField.length());
              return true;
            }
            return false;
          }
        });

    lastNameField = new EditText(context);
    lastNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
    lastNameField.setHintTextColor(0xff979797);
    lastNameField.setTextColor(0xff212121);
    lastNameField.setMaxLines(1);
    lastNameField.setLines(1);
    lastNameField.setSingleLine(true);
    lastNameField.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
    lastNameField.setInputType(
        InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
    lastNameField.setImeOptions(EditorInfo.IME_ACTION_DONE);
    lastNameField.setHint(LocaleController.getString("LastName", R.string.LastName));
    AndroidUtilities.clearCursorDrawable(lastNameField);
    ((LinearLayout) fragmentView).addView(lastNameField);
    layoutParams = (LinearLayout.LayoutParams) lastNameField.getLayoutParams();
    layoutParams.topMargin = AndroidUtilities.dp(16);
    layoutParams.height = AndroidUtilities.dp(36);
    layoutParams.leftMargin = AndroidUtilities.dp(24);
    layoutParams.rightMargin = AndroidUtilities.dp(24);
    layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
    lastNameField.setLayoutParams(layoutParams);
    lastNameField.setOnEditorActionListener(
        new TextView.OnEditorActionListener() {
          @Override
          public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
            if (i == EditorInfo.IME_ACTION_DONE) {
              doneButton.performClick();
              return true;
            }
            return false;
          }
        });

    if (user != null) {
      firstNameField.setText(user.first_name);
      firstNameField.setSelection(firstNameField.length());
      lastNameField.setText(user.last_name);
    }

    return fragmentView;
  }