示例#1
0
  @Override
  protected boolean isUserDataChanged() {
    if (currentMessageObject == null) {
      return false;
    }

    int uid = currentMessageObject.messageOwner.media.user_id;
    boolean newDrawAdd =
        contactUser != null
            && uid != UserConfig.getClientUserId()
            && ContactsController.getInstance().contactsDict.get(uid) == null;
    if (newDrawAdd != drawAddButton) {
      return true;
    }

    contactUser =
        MessagesController.getInstance().getUser(currentMessageObject.messageOwner.media.user_id);

    TLRPC.FileLocation newPhoto = null;
    if (contactUser != null && contactUser.photo != null) {
      newPhoto = contactUser.photo.photo_small;
    }

    return currentPhoto == null && newPhoto != null
        || currentPhoto != null && newPhoto == null
        || currentPhoto != null
            && newPhoto != null
            && (currentPhoto.local_id != newPhoto.local_id
                || currentPhoto.volume_id != newPhoto.volume_id)
        || super.isUserDataChanged();
  }
  @Override
  public View getView(int i, View view, ViewGroup viewGroup) {
    int type = getItemViewType(i);
    if (type == 0) {
      if (view == null) {
        view = new DrawerProfileCell(mContext);
      }
      ((DrawerProfileCell) view)
          .setUser(MessagesController.getInstance().getUser(UserConfig.getClientUserId()));
    } else if (type == 1) {
      if (view == null) {
        view = new EmptyCell(mContext, AndroidUtilities.dp(8));
      }
    } else if (type == 2) {
      if (view == null) {
        view = new DividerCell(mContext);
      }
    } else if (type == 3) {
      if (view == null) {
        view = new DrawerActionCell(mContext);
      }
      DrawerActionCell actionCell = (DrawerActionCell) view;
      if (i == 2) {
        actionCell.setTextAndIcon(
            LocaleController.getString("NewGroup", R.string.NewGroup), R.drawable.menu_newgroup);
      } else if (i == 3) {
        actionCell.setTextAndIcon(
            LocaleController.getString("NewSecretChat", R.string.NewSecretChat),
            R.drawable.menu_secret);
      } else if (i == 4) {
        actionCell.setTextAndIcon(
            LocaleController.getString("NewChannel", R.string.NewChannel),
            R.drawable.menu_broadcast);
      } else if (i == 6) {
        actionCell.setTextAndIcon(
            LocaleController.getString("Contacts", R.string.Contacts), R.drawable.menu_contacts);
      } else if (i == 7) {
        actionCell.setTextAndIcon(
            LocaleController.getString("InviteFriends", R.string.InviteFriends),
            R.drawable.menu_invite);
      } else if (i == 8) {
        actionCell.setTextAndIcon(
            LocaleController.getString("Settings", R.string.Settings), R.drawable.menu_settings);
      } else if (i == 9) {
        actionCell.setTextAndIcon(
            LocaleController.getString("Finger2ViewFaq", R.string.Finger2ViewFaq),
            R.drawable.menu_help);
      }
    }

    return view;
  }
 private void saveName() {
   TLRPC.User currentUser = UserConfig.getCurrentUser();
   if (currentUser == null
       || lastNameField.getText() == null
       || firstNameField.getText() == null) {
     return;
   }
   String newFirst = firstNameField.getText().toString();
   String newLast = lastNameField.getText().toString();
   if (currentUser.first_name != null
       && currentUser.first_name.equals(newFirst)
       && currentUser.last_name != null
       && currentUser.last_name.equals(newLast)) {
     return;
   }
   TLRPC.TL_account_updateProfile req = new TLRPC.TL_account_updateProfile();
   currentUser.first_name = req.first_name = newFirst;
   currentUser.last_name = req.last_name = newLast;
   TLRPC.User user = MessagesController.getInstance().getUser(UserConfig.getClientUserId());
   if (user != null) {
     user.first_name = req.first_name;
     user.last_name = req.last_name;
   }
   UserConfig.saveConfig(true);
   NotificationCenter.getInstance().postNotificationName(NotificationCenter.mainUserInfoChanged);
   NotificationCenter.getInstance()
       .postNotificationName(
           NotificationCenter.updateInterfaces, MessagesController.UPDATE_MASK_NAME);
   ConnectionsManager.getInstance()
       .performRpc(
           req,
           new RPCRequest.RPCRequestDelegate() {
             @Override
             public void run(TLObject response, TLRPC.TL_error error) {}
           });
 }
示例#4
0
 public void setMessageObject(MessageObject messageObject) {
   if (currentMessageObject == messageObject) {
     return;
   }
   currentMessageObject = messageObject;
   previousWidth = 0;
   if (currentMessageObject.type == MessageObject.Type.MSG_ACTION) {
     int id = 0;
     if (messageObject.messageOwner.to_id != null) {
       if (messageObject.messageOwner.to_id.chat_id != 0) {
         id = messageObject.messageOwner.to_id.chat_id;
       } else {
         id = messageObject.messageOwner.to_id.user_id;
         if (id == UserConfig.getClientUserId()) {
           id = messageObject.messageOwner.from_id;
         }
       }
     }
     avatarDrawable.setInfo(id, null, null, false);
     if (currentMessageObject.messageOwner.action
         instanceof TLRPC.TL_messageActionUserUpdatedPhoto) {
       imageReceiver.setImage(
           currentMessageObject.messageOwner.action.newUserPhoto.photo_small,
           "50_50",
           avatarDrawable,
           null,
           false);
     } else {
       TLRPC.PhotoSize photo =
           FileLoader.getClosestPhotoSizeWithSize(
               currentMessageObject.photoThumbs, AndroidUtilities.dp(64));
       if (photo != null) {
         imageReceiver.setImage(photo.location, "50_50", avatarDrawable, null, false);
       } else {
         imageReceiver.setImageBitmap(avatarDrawable);
       }
     }
     imageReceiver.setVisible(
         !PhotoViewer.getInstance().isShowingImage(currentMessageObject), false);
   } else {
     imageReceiver.setImageBitmap((Bitmap) null);
   }
   requestLayout();
 }
示例#5
0
  private void searchBingImages(String query, int offset, int count) {
    if (searching) {
      searching = false;
      requestQueue.cancelAll("search");
    }
    try {
      searching = true;
      String url;
      if (nextSearchBingString != null) {
        url = nextSearchBingString;
      } else {
        boolean adult;
        String phone = UserConfig.getCurrentUser().phone;
        adult =
            phone.startsWith("44")
                || phone.startsWith("49")
                || phone.startsWith("43")
                || phone.startsWith("31")
                || phone.startsWith("1");
        url =
            String.format(
                Locale.US,
                "https://api.datamarket.azure.com/Bing/Search/v1/Image?Query='%s'&$skip=%d&$top=%d&$format=json%s",
                URLEncoder.encode(query, "UTF-8"),
                offset,
                count,
                adult ? "" : "&Adult='Off'");
      }
      JsonObjectRequest jsonObjReq =
          new JsonObjectRequest(
              Request.Method.GET,
              url,
              null,
              new Response.Listener<JSONObject>() {
                @Override
                public void onResponse(JSONObject response) {
                  nextSearchBingString = null;
                  try {
                    JSONObject d = response.getJSONObject("d");
                    JSONArray result = d.getJSONArray("results");
                    try {
                      nextSearchBingString = d.getString("__next");
                    } catch (Exception e) {
                      nextSearchBingString = null;
                      FileLog.e("tmessages", e);
                    }
                    for (int a = 0; a < result.length(); a++) {
                      try {
                        JSONObject object = result.getJSONObject(a);
                        String id = Utilities.MD5(object.getString("MediaUrl"));
                        if (searchResultKeys.containsKey(id)) {
                          continue;
                        }
                        MediaController.SearchImage bingImage = new MediaController.SearchImage();
                        bingImage.id = id;
                        bingImage.width = object.getInt("Width");
                        bingImage.height = object.getInt("Height");
                        bingImage.size = object.getInt("FileSize");
                        bingImage.imageUrl = object.getString("MediaUrl");
                        JSONObject thumbnail = object.getJSONObject("Thumbnail");
                        bingImage.thumbUrl = thumbnail.getString("MediaUrl");
                        searchResult.add(bingImage);
                        searchResultKeys.put(id, bingImage);
                      } catch (Exception e) {
                        FileLog.e("tmessages", e);
                      }
                    }
                  } catch (Exception e) {
                    FileLog.e("tmessages", e);
                  }
                  searching = false;
                  if (nextSearchBingString != null && !nextSearchBingString.contains("json")) {
                    nextSearchBingString += "&$format=json";
                  }
                  updateSearchInterface();
                }
              },
              new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                  FileLog.e("tmessages", "Error: " + error.getMessage());
                  nextSearchBingString = null;
                  searching = false;
                  updateSearchInterface();
                }
              }) {

            @Override
            public Map<String, String> getHeaders() throws AuthFailureError {
              Map<String, String> headers = new HashMap<>();
              String auth =
                  "Basic "
                      + Base64.encodeToString(
                          (BuildVars.BING_SEARCH_KEY + ":" + BuildVars.BING_SEARCH_KEY).getBytes(),
                          Base64.NO_WRAP);
              headers.put("Authorization", auth);
              return headers;
            }
          };
      jsonObjReq.setTag("search");
      requestQueue.add(jsonObjReq);
    } catch (Exception e) {
      FileLog.e("tmessages", e);
      nextSearchBingString = null;
      searching = false;
      updateSearchInterface();
    }
  }
示例#6
0
  public void buildLayout() {
    CharSequence nameString;
    TextPaint currentNamePaint;

    drawNameBroadcast = false;
    drawNameLock = false;
    drawNameGroup = false;
    drawCheck = false;
    drawNameBot = false;

    if (encryptedChat != null) {
      drawNameLock = true;
      dialog_id = ((long) encryptedChat.id) << 32;
      if (!LocaleController.isRTL) {
        nameLockLeft = AndroidUtilities.dp(AndroidUtilities.leftBaseline);
        nameLeft =
            AndroidUtilities.dp(AndroidUtilities.leftBaseline + 4)
                + lockDrawable.getIntrinsicWidth();
      } else {
        nameLockLeft =
            getMeasuredWidth()
                - AndroidUtilities.dp(AndroidUtilities.leftBaseline + 2)
                - lockDrawable.getIntrinsicWidth();
        nameLeft = AndroidUtilities.dp(11);
      }
      nameLockTop = AndroidUtilities.dp(16.5f);
    } else {
      if (chat != null) {
        if (chat.id < 0) {
          dialog_id = AndroidUtilities.makeBroadcastId(chat.id);
          drawNameBroadcast = true;
          nameLockTop = AndroidUtilities.dp(28.5f);
        } else {
          dialog_id = -chat.id;
          if (ChatObject.isChannel(chat) && !chat.megagroup) {
            drawNameBroadcast = true;
            nameLockTop = AndroidUtilities.dp(28.5f);
          } else {
            drawNameGroup = true;
            nameLockTop = AndroidUtilities.dp(30);
          }
        }
        drawCheck = chat.verified;
        if (!LocaleController.isRTL) {
          nameLockLeft = AndroidUtilities.dp(AndroidUtilities.leftBaseline);
          nameLeft =
              AndroidUtilities.dp(AndroidUtilities.leftBaseline + 4)
                  + (drawNameGroup
                      ? groupDrawable.getIntrinsicWidth()
                      : broadcastDrawable.getIntrinsicWidth());
        } else {
          nameLockLeft =
              getMeasuredWidth()
                  - AndroidUtilities.dp(AndroidUtilities.leftBaseline + 2)
                  - (drawNameGroup
                      ? groupDrawable.getIntrinsicWidth()
                      : broadcastDrawable.getIntrinsicWidth());
          nameLeft = AndroidUtilities.dp(11);
        }
      } else {
        dialog_id = user.id;
        if (!LocaleController.isRTL) {
          nameLeft = AndroidUtilities.dp(AndroidUtilities.leftBaseline);
        } else {
          nameLeft = AndroidUtilities.dp(11);
        }
        if (user.bot) {
          drawNameBot = true;
          if (!LocaleController.isRTL) {
            nameLockLeft = AndroidUtilities.dp(AndroidUtilities.leftBaseline);
            nameLeft =
                AndroidUtilities.dp(AndroidUtilities.leftBaseline + 4)
                    + botDrawable.getIntrinsicWidth();
          } else {
            nameLockLeft =
                getMeasuredWidth()
                    - AndroidUtilities.dp(AndroidUtilities.leftBaseline + 2)
                    - botDrawable.getIntrinsicWidth();
            nameLeft = AndroidUtilities.dp(11);
          }
          nameLockTop = AndroidUtilities.dp(16.5f);
        } else {
          nameLockTop = AndroidUtilities.dp(17);
        }
        drawCheck = user.verified;
      }
    }

    if (currentName != null) {
      nameString = currentName;
    } else {
      String nameString2 = "";
      if (chat != null) {
        nameString2 = chat.title;
      } else if (user != null) {
        nameString2 = UserObject.getUserName(user);
      }
      nameString = nameString2.replace('\n', ' ');
    }
    if (nameString.length() == 0) {
      if (user != null && user.phone != null && user.phone.length() != 0) {
        nameString = PhoneFormat.getInstance().format("+" + user.phone);
      } else {
        nameString = LocaleController.getString("HiddenName", R.string.HiddenName);
      }
    }
    if (encryptedChat != null) {
      currentNamePaint = nameEncryptedPaint;
    } else {
      currentNamePaint = namePaint;
    }

    int onlineWidth;
    int nameWidth;
    if (!LocaleController.isRTL) {
      onlineWidth = nameWidth = getMeasuredWidth() - nameLeft - AndroidUtilities.dp(14);
    } else {
      onlineWidth =
          nameWidth =
              getMeasuredWidth() - nameLeft - AndroidUtilities.dp(AndroidUtilities.leftBaseline);
    }
    if (drawNameLock) {
      nameWidth -= AndroidUtilities.dp(6) + lockDrawable.getIntrinsicWidth();
    } else if (drawNameBroadcast) {
      nameWidth -= AndroidUtilities.dp(6) + broadcastDrawable.getIntrinsicWidth();
    } else if (drawNameGroup) {
      nameWidth -= AndroidUtilities.dp(6) + groupDrawable.getIntrinsicWidth();
    } else if (drawNameBot) {
      nameWidth -= AndroidUtilities.dp(6) + botDrawable.getIntrinsicWidth();
    }

    if (drawCount) {
      TLRPC.TL_dialog dialog = MessagesController.getInstance().dialogs_dict.get(dialog_id);
      if (dialog != null && dialog.unread_count != 0) {
        lastUnreadCount = dialog.unread_count;
        String countString = String.format("%d", dialog.unread_count);
        countWidth =
            Math.max(AndroidUtilities.dp(12), (int) Math.ceil(countPaint.measureText(countString)));
        countLayout =
            new StaticLayout(
                countString,
                countPaint,
                countWidth,
                Layout.Alignment.ALIGN_CENTER,
                1.0f,
                0.0f,
                false);
        int w = countWidth + AndroidUtilities.dp(18);
        nameWidth -= w;
        if (!LocaleController.isRTL) {
          countLeft = getMeasuredWidth() - countWidth - AndroidUtilities.dp(19);
        } else {
          countLeft = AndroidUtilities.dp(19);
          nameLeft += w;
        }
      } else {
        lastUnreadCount = 0;
        countLayout = null;
      }
    } else {
      lastUnreadCount = 0;
      countLayout = null;
    }

    CharSequence nameStringFinal =
        TextUtils.ellipsize(
            nameString,
            currentNamePaint,
            nameWidth - AndroidUtilities.dp(12),
            TextUtils.TruncateAt.END);
    nameLayout =
        new StaticLayout(
            nameStringFinal,
            currentNamePaint,
            nameWidth,
            Layout.Alignment.ALIGN_NORMAL,
            1.0f,
            0.0f,
            false);

    if (chat == null || subLabel != null) {
      if (!LocaleController.isRTL) {
        onlineLeft = AndroidUtilities.dp(AndroidUtilities.leftBaseline);
      } else {
        onlineLeft = AndroidUtilities.dp(11);
      }

      CharSequence onlineString = "";
      TextPaint currentOnlinePaint = offlinePaint;

      if (subLabel != null) {
        onlineString = subLabel;
      } else if (user != null) {
        if (user.bot) {
          onlineString = LocaleController.getString("Bot", R.string.Bot);
        } else {
          onlineString = LocaleController.formatUserStatus(user);
          if (user != null
              && (user.id == UserConfig.getClientUserId()
                  || user.status != null
                      && user.status.expires > ConnectionsManager.getInstance().getCurrentTime())) {
            currentOnlinePaint = onlinePaint;
            onlineString = LocaleController.getString("Online", R.string.Online);
          }
        }
      }

      CharSequence onlineStringFinal =
          TextUtils.ellipsize(
              onlineString,
              currentOnlinePaint,
              onlineWidth - AndroidUtilities.dp(12),
              TextUtils.TruncateAt.END);
      onlineLayout =
          new StaticLayout(
              onlineStringFinal,
              currentOnlinePaint,
              onlineWidth,
              Layout.Alignment.ALIGN_NORMAL,
              1.0f,
              0.0f,
              false);
      nameTop = AndroidUtilities.dp(13);
      if (subLabel != null && chat != null) {
        nameLockTop -= AndroidUtilities.dp(12);
      }
    } else {
      onlineLayout = null;
      nameTop = AndroidUtilities.dp(25);
    }

    int avatarLeft;
    if (!LocaleController.isRTL) {
      avatarLeft = AndroidUtilities.dp(AndroidUtilities.isTablet() ? 13 : 9);
    } else {
      avatarLeft = getMeasuredWidth() - AndroidUtilities.dp(AndroidUtilities.isTablet() ? 65 : 61);
    }

    avatarImage.setImageCoords(
        avatarLeft, AndroidUtilities.dp(10), AndroidUtilities.dp(52), AndroidUtilities.dp(52));

    double widthpx;
    float left;
    if (LocaleController.isRTL) {
      if (nameLayout.getLineCount() > 0) {
        left = nameLayout.getLineLeft(0);
        if (left == 0) {
          widthpx = Math.ceil(nameLayout.getLineWidth(0));
          if (widthpx < nameWidth) {
            nameLeft += (nameWidth - widthpx);
          }
        }
      }
      if (onlineLayout != null && onlineLayout.getLineCount() > 0) {
        left = onlineLayout.getLineLeft(0);
        if (left == 0) {
          widthpx = Math.ceil(onlineLayout.getLineWidth(0));
          if (widthpx < onlineWidth) {
            onlineLeft += (onlineWidth - widthpx);
          }
        }
      }
    } else {
      if (nameLayout.getLineCount() > 0) {
        left = nameLayout.getLineRight(0);
        if (left == nameWidth) {
          widthpx = Math.ceil(nameLayout.getLineWidth(0));
          if (widthpx < nameWidth) {
            nameLeft -= (nameWidth - widthpx);
          }
        }
      }
      if (onlineLayout != null && onlineLayout.getLineCount() > 0) {
        left = onlineLayout.getLineRight(0);
        if (left == onlineWidth) {
          widthpx = Math.ceil(onlineLayout.getLineWidth(0));
          if (widthpx < onlineWidth) {
            onlineLeft -= (onlineWidth - widthpx);
          }
        }
      }
    }
  }
示例#7
0
  @Override
  public void setMessageObject(MessageObject messageObject) {
    if (currentMessageObject != messageObject || isUserDataChanged()) {

      int uid = messageObject.messageOwner.media.user_id;
      contactUser = MessagesController.getInstance().getUser(uid);

      drawAddButton =
          contactUser != null
              && uid != UserConfig.getClientUserId()
              && ContactsController.getInstance().contactsDict.get(uid) == null;

      int maxWidth;
      if (AndroidUtilities.isTablet()) {
        maxWidth = (int) (AndroidUtilities.getMinTabletSide() * 0.7f);
      } else {
        maxWidth =
            (int) (Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) * 0.7f);
      }
      maxWidth -= AndroidUtilities.dp(58 + (drawAddButton ? 42 : 0));

      if (contactUser != null) {
        if (contactUser.photo != null) {
          currentPhoto = contactUser.photo.photo_small;
        } else {
          currentPhoto = null;
        }
        avatarDrawable.setInfo(contactUser);
      } else {
        currentPhoto = null;
        avatarDrawable.setInfo(uid, null, null, false);
      }
      avatarImage.setImage(currentPhoto, "50_50", avatarDrawable, null, false);

      String currentNameString =
          ContactsController.formatName(
              messageObject.messageOwner.media.first_name,
              messageObject.messageOwner.media.last_name);
      int nameWidth = Math.min((int) Math.ceil(namePaint.measureText(currentNameString)), maxWidth);

      CharSequence stringFinal =
          TextUtils.ellipsize(
              currentNameString.replace("\n", " "), namePaint, nameWidth, TextUtils.TruncateAt.END);
      nameLayout =
          new StaticLayout(
              stringFinal, namePaint, nameWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
      if (nameLayout.getLineCount() > 0) {
        nameWidth = (int) Math.ceil(nameLayout.getLineWidth(0));
      } else {
        nameWidth = 0;
      }

      String phone = messageObject.messageOwner.media.phone_number;
      if (phone != null && phone.length() != 0) {
        if (!phone.startsWith("+")) {
          phone = "+" + phone;
        }
        phone = PhoneFormat.getInstance().format(phone);
      } else {
        phone = LocaleController.getString("NumberUnknown", R.string.NumberUnknown);
      }
      int phoneWidth = Math.min((int) Math.ceil(phonePaint.measureText(phone)), maxWidth);
      stringFinal =
          TextUtils.ellipsize(
              phone.replace("\n", " "), phonePaint, phoneWidth, TextUtils.TruncateAt.END);
      phoneLayout =
          new StaticLayout(
              stringFinal,
              phonePaint,
              phoneWidth,
              Layout.Alignment.ALIGN_NORMAL,
              1.0f,
              0.0f,
              false);
      if (phoneLayout.getLineCount() > 0) {
        phoneWidth = (int) Math.ceil(phoneLayout.getLineWidth(0));
      } else {
        phoneWidth = 0;
      }

      namesWidth = Math.max(nameWidth, phoneWidth);
      backgroundWidth = AndroidUtilities.dp(77 + (drawAddButton ? 42 : 0)) + namesWidth;

      super.setMessageObject(messageObject);
    }
  }
 @Override
 public int getCount() {
   return UserConfig.isClientActivated() ? 10 : 0;
 }
 @Override
 public boolean isEmpty() {
   return !UserConfig.isClientActivated();
 }
示例#10
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;
  }