mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-21 18:26:57 +00:00
Improve typing experience when changing your profile name.
This commit is contained in:
@@ -23,6 +23,7 @@ import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.profiles.ProfileName;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.util.StringUtil;
|
||||
import org.thoughtcrime.securesms.util.ViewUtil;
|
||||
import org.thoughtcrime.securesms.util.text.AfterTextChanged;
|
||||
|
||||
/**
|
||||
@@ -71,6 +72,8 @@ public class EditProfileNameFragment extends Fragment {
|
||||
saveButton.setOnClickListener(v -> viewModel.onSaveClicked(requireContext(),
|
||||
givenName.getText().toString(),
|
||||
familyName.getText().toString()));
|
||||
|
||||
ViewUtil.focusAndMoveCursorToEndAndOpenKeyboard(this.givenName);
|
||||
}
|
||||
|
||||
private void initializeViewModel() {
|
||||
|
||||
@@ -6,6 +6,7 @@ import android.text.Editable;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.Transformations;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
import org.thoughtcrime.securesms.profiles.ProfileName;
|
||||
@@ -25,7 +26,7 @@ public final class EditProfileNameViewModel extends ViewModel {
|
||||
}
|
||||
|
||||
void onGivenNameChanged(@NonNull String text) {
|
||||
if (StringUtil.isVisuallyEmpty(text.toString())) {
|
||||
if (StringUtil.isVisuallyEmpty(text)) {
|
||||
saveState.setValue(SaveState.DISABLED);
|
||||
} else {
|
||||
saveState.setValue(SaveState.IDLE);
|
||||
@@ -33,7 +34,7 @@ public final class EditProfileNameViewModel extends ViewModel {
|
||||
}
|
||||
|
||||
@NonNull LiveData<SaveState> getSaveState() {
|
||||
return saveState;
|
||||
return Transformations.distinctUntilChanged(saveState);
|
||||
}
|
||||
|
||||
@NonNull LiveData<Event> getEvents() {
|
||||
|
||||
Reference in New Issue
Block a user