mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-20 00:29:11 +01:00
Disallow visually-empty profile names.
This commit is contained in:
committed by
Alex Hart
parent
523e21f3be
commit
a0031298d8
@@ -53,7 +53,7 @@ public class EditProfileNameFragment extends Fragment {
|
||||
this.givenName.setText(Recipient.self().getProfileName().getGivenName());
|
||||
this.familyName.setText(Recipient.self().getProfileName().getFamilyName());
|
||||
|
||||
viewModel.onGivenNameLengthChanged(this.givenName.getText().length());
|
||||
viewModel.onGivenNameChanged(this.givenName.getText().toString());
|
||||
|
||||
view.<Toolbar>findViewById(R.id.toolbar)
|
||||
.setNavigationOnClickListener(v -> Navigation.findNavController(view)
|
||||
@@ -64,7 +64,7 @@ public class EditProfileNameFragment extends Fragment {
|
||||
|
||||
this.givenName.addTextChangedListener(new AfterTextChanged(s -> {
|
||||
trimFieldToMaxByteLength(s);
|
||||
viewModel.onGivenNameLengthChanged(s.length());
|
||||
viewModel.onGivenNameChanged(s.toString());
|
||||
}));
|
||||
this.familyName.addTextChangedListener(new AfterTextChanged(EditProfileNameFragment::trimFieldToMaxByteLength));
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.thoughtcrime.securesms.profiles.manage;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.Editable;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.LiveData;
|
||||
@@ -9,6 +10,7 @@ import androidx.lifecycle.ViewModel;
|
||||
|
||||
import org.thoughtcrime.securesms.profiles.ProfileName;
|
||||
import org.thoughtcrime.securesms.util.SingleLiveEvent;
|
||||
import org.thoughtcrime.securesms.util.StringUtil;
|
||||
|
||||
public final class EditProfileNameViewModel extends ViewModel {
|
||||
|
||||
@@ -22,8 +24,8 @@ public final class EditProfileNameViewModel extends ViewModel {
|
||||
this.events = new SingleLiveEvent<>();
|
||||
}
|
||||
|
||||
void onGivenNameLengthChanged(int length) {
|
||||
if (length <= 0) {
|
||||
void onGivenNameChanged(@NonNull String text) {
|
||||
if (StringUtil.isVisuallyEmpty(text.toString())) {
|
||||
saveState.setValue(SaveState.DISABLED);
|
||||
} else {
|
||||
saveState.setValue(SaveState.IDLE);
|
||||
|
||||
Reference in New Issue
Block a user