Replace EditText with OutlineContainer
This commit is contained in:
@@ -44,6 +44,7 @@ import org.telegram.ui.Components.CodepointsLengthInputFilter;
|
||||
import org.telegram.ui.Components.EditTextBoldCursor;
|
||||
import org.telegram.ui.Components.LayoutHelper;
|
||||
import org.telegram.ui.Components.NumberTextView;
|
||||
import org.telegram.ui.Components.OutlineTextContainerView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -52,8 +53,9 @@ import com.exteragram.messenger.extras.Vibrate;
|
||||
public class ChangeBioActivity extends BaseFragment {
|
||||
|
||||
private EditTextBoldCursor firstNameField;
|
||||
private OutlineTextContainerView firstNameFieldContainer;
|
||||
|
||||
private View doneButton;
|
||||
private NumberTextView checkTextView;
|
||||
private TextView helpTextView;
|
||||
|
||||
private final static int done_button = 1;
|
||||
@@ -83,21 +85,36 @@ public class ChangeBioActivity extends BaseFragment {
|
||||
linearLayout.setOrientation(LinearLayout.VERTICAL);
|
||||
fragmentView.setOnTouchListener((v, event) -> true);
|
||||
|
||||
FrameLayout fieldContainer = new FrameLayout(context);
|
||||
linearLayout.addView(fieldContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 24, 24, 20, 0));
|
||||
firstNameFieldContainer = new OutlineTextContainerView(context);
|
||||
firstNameFieldContainer.setText(LocaleController.getString(R.string.UserBio));
|
||||
linearLayout.addView(firstNameFieldContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL, 24, 24, 24, 0));
|
||||
|
||||
firstNameField = new EditTextBoldCursor(context);
|
||||
firstNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
|
||||
firstNameField.setHintTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteHintText));
|
||||
firstNameField.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
|
||||
firstNameField.setBackgroundDrawable(null);
|
||||
firstNameField.setLineColors(getThemedColor(Theme.key_windowBackgroundWhiteInputField), getThemedColor(Theme.key_windowBackgroundWhiteInputFieldActivated), getThemedColor(Theme.key_windowBackgroundWhiteRedText3));
|
||||
firstNameField.setHintTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteHintText));
|
||||
firstNameField.setBackground(null);
|
||||
firstNameField.setMaxLines(4);
|
||||
firstNameField.setPadding(AndroidUtilities.dp(LocaleController.isRTL ? 24 : 0), 0, AndroidUtilities.dp(LocaleController.isRTL ? 0 : 24), AndroidUtilities.dp(6));
|
||||
firstNameField.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
|
||||
firstNameField.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
|
||||
firstNameField.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
|
||||
firstNameField.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
|
||||
firstNameField.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||
firstNameField.setCursorColor(Theme.getColor(Theme.key_windowBackgroundWhiteInputFieldActivated));
|
||||
firstNameField.setCursorWidth(1.5f);
|
||||
firstNameField.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
|
||||
firstNameField.setOnFocusChangeListener((v, hasFocus) -> firstNameFieldContainer.animateSelection(hasFocus ? 1 : 0));
|
||||
int padding = AndroidUtilities.dp(16);
|
||||
firstNameField.setPadding(padding, padding, padding, padding);
|
||||
firstNameField.setCursorSize(AndroidUtilities.dp(20));
|
||||
firstNameFieldContainer.addView(firstNameField, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
|
||||
firstNameFieldContainer.attachEditText(firstNameField);
|
||||
firstNameField.setOnEditorActionListener((textView, i, keyEvent) -> {
|
||||
if (i == EditorInfo.IME_ACTION_NEXT || i == EditorInfo.IME_ACTION_DONE) {
|
||||
doneButton.performClick();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
InputFilter[] inputFilters = new InputFilter[1];
|
||||
inputFilters[0] = new CodepointsLengthInputFilter(70) {
|
||||
@Override
|
||||
@@ -109,17 +126,13 @@ public class ChangeBioActivity extends BaseFragment {
|
||||
CharSequence result = super.filter(source, start, end, dest, dstart, dend);
|
||||
if (result != null && source != null && result.length() != source.length()) {
|
||||
Vibrate.vibrate();
|
||||
AndroidUtilities.shakeView(checkTextView, 2, 0);
|
||||
AndroidUtilities.shakeView(firstNameFieldContainer, 2, 0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
||||
firstNameField.setFilters(inputFilters);
|
||||
firstNameField.setMinHeight(AndroidUtilities.dp(36));
|
||||
firstNameField.setHint(LocaleController.getString("UserBio", R.string.UserBio));
|
||||
firstNameField.setCursorColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
|
||||
firstNameField.setCursorSize(AndroidUtilities.dp(20));
|
||||
firstNameField.setCursorWidth(1.5f);
|
||||
firstNameField.setOnEditorActionListener((textView, i, keyEvent) -> {
|
||||
if (i == EditorInfo.IME_ACTION_DONE && doneButton != null) {
|
||||
doneButton.performClick();
|
||||
@@ -140,19 +153,11 @@ public class ChangeBioActivity extends BaseFragment {
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
checkTextView.setNumber(70 - Character.codePointCount(s, 0, s.length()), true);
|
||||
firstNameFieldContainer.setText(LocaleController.getString(R.string.UserBio), 70 - Character.codePointCount(s, 0, s.length()));
|
||||
}
|
||||
});
|
||||
|
||||
fieldContainer.addView(firstNameField, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 0, 0, 4, 0));
|
||||
|
||||
checkTextView = new NumberTextView(context);
|
||||
checkTextView.setCenterAlign(true);
|
||||
checkTextView.setTextSize(15);
|
||||
checkTextView.setNumber(70, false);
|
||||
checkTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText4));
|
||||
checkTextView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
|
||||
fieldContainer.addView(checkTextView, LayoutHelper.createFrame(20, 20, LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT, 0, 4, 4, 0));
|
||||
firstNameFieldContainer.setText(LocaleController.getString(R.string.UserBio), 70);
|
||||
|
||||
helpTextView = new TextView(context);
|
||||
helpTextView.setFocusable(true);
|
||||
@@ -259,8 +264,6 @@ public class ChangeBioActivity extends BaseFragment {
|
||||
|
||||
themeDescriptions.add(new ThemeDescription(helpTextView, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteGrayText8));
|
||||
|
||||
themeDescriptions.add(new ThemeDescription(checkTextView, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteGrayText4));
|
||||
|
||||
return themeDescriptions;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,13 +33,18 @@ import org.telegram.ui.ActionBar.Theme;
|
||||
import org.telegram.ui.ActionBar.ThemeDescription;
|
||||
import org.telegram.ui.Components.EditTextBoldCursor;
|
||||
import org.telegram.ui.Components.LayoutHelper;
|
||||
import org.telegram.ui.Components.OutlineTextContainerView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ChangeNameActivity extends BaseFragment {
|
||||
|
||||
private EditTextBoldCursor firstNameField;
|
||||
private OutlineTextContainerView firstNameFieldContainer;
|
||||
|
||||
private EditTextBoldCursor lastNameField;
|
||||
private OutlineTextContainerView lastNameFieldContainer;
|
||||
|
||||
private View headerLabelView;
|
||||
private View doneButton;
|
||||
|
||||
@@ -78,49 +83,55 @@ public class ChangeNameActivity extends BaseFragment {
|
||||
((LinearLayout) fragmentView).setOrientation(LinearLayout.VERTICAL);
|
||||
fragmentView.setOnTouchListener((v, event) -> true);
|
||||
|
||||
firstNameFieldContainer = new OutlineTextContainerView(context);
|
||||
firstNameFieldContainer.setText(LocaleController.getString(R.string.FirstName));
|
||||
linearLayout.addView(firstNameFieldContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL, 24, 24, 24, 0));
|
||||
|
||||
firstNameField = new EditTextBoldCursor(context);
|
||||
firstNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
|
||||
firstNameField.setHintTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteHintText));
|
||||
firstNameField.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
|
||||
firstNameField.setBackgroundDrawable(null);
|
||||
firstNameField.setLineColors(getThemedColor(Theme.key_windowBackgroundWhiteInputField), getThemedColor(Theme.key_windowBackgroundWhiteInputFieldActivated), getThemedColor(Theme.key_windowBackgroundWhiteRedText3));
|
||||
firstNameField.setMaxLines(1);
|
||||
firstNameField.setLines(1);
|
||||
firstNameField.setHintTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteHintText));
|
||||
firstNameField.setBackground(null);
|
||||
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));
|
||||
firstNameField.setCursorColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
|
||||
firstNameField.setCursorSize(AndroidUtilities.dp(20));
|
||||
firstNameField.setCursorColor(Theme.getColor(Theme.key_windowBackgroundWhiteInputFieldActivated));
|
||||
firstNameField.setCursorWidth(1.5f);
|
||||
linearLayout.addView(firstNameField, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 36, 24, 24, 24, 0));
|
||||
firstNameField.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
|
||||
firstNameField.setOnFocusChangeListener((v, hasFocus) -> firstNameFieldContainer.animateSelection(hasFocus ? 1 : 0));
|
||||
int padding = AndroidUtilities.dp(16);
|
||||
firstNameField.setPadding(padding, padding, padding, padding);
|
||||
firstNameField.setCursorSize(AndroidUtilities.dp(20));
|
||||
firstNameFieldContainer.addView(firstNameField, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
|
||||
firstNameFieldContainer.attachEditText(firstNameField);
|
||||
firstNameField.setOnEditorActionListener((textView, i, keyEvent) -> {
|
||||
if (i == EditorInfo.IME_ACTION_NEXT) {
|
||||
lastNameField.requestFocus();
|
||||
lastNameField.setSelection(lastNameField.length());
|
||||
if (i == EditorInfo.IME_ACTION_NEXT || i == EditorInfo.IME_ACTION_DONE) {
|
||||
doneButton.performClick();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
lastNameFieldContainer = new OutlineTextContainerView(context);
|
||||
lastNameFieldContainer.setText(LocaleController.getString(R.string.LastName));
|
||||
linearLayout.addView(lastNameFieldContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL, 24, 24, 24, 0));
|
||||
|
||||
lastNameField = new EditTextBoldCursor(context);
|
||||
lastNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
|
||||
lastNameField.setHintTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteHintText));
|
||||
lastNameField.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
|
||||
lastNameField.setBackgroundDrawable(null);
|
||||
lastNameField.setLineColors(getThemedColor(Theme.key_windowBackgroundWhiteInputField), getThemedColor(Theme.key_windowBackgroundWhiteInputFieldActivated), getThemedColor(Theme.key_windowBackgroundWhiteRedText3));
|
||||
lastNameField.setMaxLines(1);
|
||||
lastNameField.setLines(1);
|
||||
lastNameField.setHintTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteHintText));
|
||||
lastNameField.setBackground(null);
|
||||
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));
|
||||
lastNameField.setCursorColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
|
||||
lastNameField.setCursorSize(AndroidUtilities.dp(20));
|
||||
lastNameField.setImeOptions(EditorInfo.IME_ACTION_NEXT);
|
||||
lastNameField.setCursorColor(Theme.getColor(Theme.key_windowBackgroundWhiteInputFieldActivated));
|
||||
lastNameField.setCursorWidth(1.5f);
|
||||
linearLayout.addView(lastNameField, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 36, 24, 16, 24, 0));
|
||||
lastNameField.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
|
||||
lastNameField.setOnFocusChangeListener((v, hasFocus) -> lastNameFieldContainer.animateSelection(hasFocus ? 1 : 0));
|
||||
lastNameField.setPadding(padding, padding, padding, padding);
|
||||
lastNameField.setCursorSize(AndroidUtilities.dp(20));
|
||||
lastNameFieldContainer.addView(lastNameField, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
|
||||
lastNameFieldContainer.attachEditText(lastNameField);
|
||||
lastNameField.setOnEditorActionListener((textView, i, keyEvent) -> {
|
||||
if (i == EditorInfo.IME_ACTION_DONE) {
|
||||
doneButton.performClick();
|
||||
|
||||
@@ -50,12 +50,14 @@ import org.telegram.ui.Components.AlertsCreator;
|
||||
import org.telegram.ui.Components.BulletinFactory;
|
||||
import org.telegram.ui.Components.EditTextBoldCursor;
|
||||
import org.telegram.ui.Components.LayoutHelper;
|
||||
import org.telegram.ui.Components.OutlineTextContainerView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ChangeUsernameActivity extends BaseFragment {
|
||||
|
||||
private EditTextBoldCursor firstNameField;
|
||||
private OutlineTextContainerView firstNameFieldContainer;
|
||||
private View doneButton;
|
||||
private TextView checkTextView;
|
||||
private TextView helpTextView;
|
||||
@@ -143,30 +145,35 @@ public class ChangeUsernameActivity extends BaseFragment {
|
||||
linearLayout.setOrientation(LinearLayout.VERTICAL);
|
||||
fragmentView.setOnTouchListener((v, event) -> true);
|
||||
|
||||
firstNameFieldContainer = new OutlineTextContainerView(context);
|
||||
firstNameFieldContainer.setText(LocaleController.getString(R.string.UsernamePlaceholder));
|
||||
linearLayout.addView(firstNameFieldContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL, 24, 24, 24, 0));
|
||||
|
||||
firstNameField = new EditTextBoldCursor(context);
|
||||
firstNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
|
||||
firstNameField.setHintTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteHintText));
|
||||
firstNameField.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
|
||||
firstNameField.setBackgroundDrawable(null);
|
||||
firstNameField.setLineColors(getThemedColor(Theme.key_windowBackgroundWhiteInputField), getThemedColor(Theme.key_windowBackgroundWhiteInputFieldActivated), getThemedColor(Theme.key_windowBackgroundWhiteRedText3));
|
||||
firstNameField.setMaxLines(1);
|
||||
firstNameField.setLines(1);
|
||||
firstNameField.setPadding(0, 0, 0, 0);
|
||||
firstNameField.setHintTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteHintText));
|
||||
firstNameField.setBackground(null);
|
||||
firstNameField.setSingleLine(true);
|
||||
firstNameField.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
|
||||
firstNameField.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
|
||||
firstNameField.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||
firstNameField.setHint(LocaleController.getString("UsernamePlaceholder", R.string.UsernamePlaceholder));
|
||||
firstNameField.setCursorColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
|
||||
firstNameField.setCursorSize(AndroidUtilities.dp(20));
|
||||
firstNameField.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
|
||||
firstNameField.setImeOptions(EditorInfo.IME_ACTION_NEXT);
|
||||
firstNameField.setCursorColor(Theme.getColor(Theme.key_windowBackgroundWhiteInputFieldActivated));
|
||||
firstNameField.setCursorWidth(1.5f);
|
||||
firstNameField.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
|
||||
firstNameField.setOnFocusChangeListener((v, hasFocus) -> firstNameFieldContainer.animateSelection(hasFocus ? 1 : 0));
|
||||
int padding = AndroidUtilities.dp(16);
|
||||
firstNameField.setPadding(padding, padding, padding, padding);
|
||||
firstNameField.setCursorSize(AndroidUtilities.dp(20));
|
||||
firstNameFieldContainer.addView(firstNameField, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
|
||||
firstNameFieldContainer.attachEditText(firstNameField);
|
||||
firstNameField.setOnEditorActionListener((textView, i, keyEvent) -> {
|
||||
if (i == EditorInfo.IME_ACTION_DONE && doneButton != null) {
|
||||
if (i == EditorInfo.IME_ACTION_NEXT || i == EditorInfo.IME_ACTION_DONE) {
|
||||
doneButton.performClick();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
firstNameField.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
|
||||
@@ -202,8 +209,6 @@ public class ChangeUsernameActivity extends BaseFragment {
|
||||
}
|
||||
});
|
||||
|
||||
linearLayout.addView(firstNameField, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 36, 24, 24, 24, 0));
|
||||
|
||||
checkTextView = new TextView(context);
|
||||
checkTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
|
||||
checkTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
|
||||
|
||||
@@ -86,6 +86,12 @@ public class OutlineTextContainerView extends FrameLayout {
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public void setText(@NonNull String text, int number) {
|
||||
this.mText = text;
|
||||
setText(mText + " " + "(" + String.valueOf(number) + ")");
|
||||
invalidate();
|
||||
}
|
||||
|
||||
private void setColor(int color) {
|
||||
outlinePaint.setColor(color);
|
||||
invalidate();
|
||||
|
||||
Reference in New Issue
Block a user