Improve typing experience when changing your profile name.

fork-5.53.8
Greyson Parrelli 2022-02-09 17:44:27 -05:00
rodzic 855bada9b8
commit cff5df4353
4 zmienionych plików z 12 dodań i 6 usunięć

Wyświetl plik

@ -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() {

Wyświetl plik

@ -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() {

Wyświetl plik

@ -33,8 +33,9 @@
android:id="@+id/edit_profile_name_given_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autofillHints="personGivenName"
android:inputType="textPersonName"
android:maxLines="1" />
android:singleLine="true" />
</com.google.android.material.textfield.TextInputLayout>
@ -55,8 +56,9 @@
android:id="@+id/edit_profile_name_family_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autofillHints="personFamilyName"
android:inputType="textPersonName"
android:maxLines="1" />
android:singleLine="true" />
</com.google.android.material.textfield.TextInputLayout>

Wyświetl plik

@ -131,7 +131,7 @@
android:layout_marginTop="13dp"
android:layout_marginEnd="16dp"
android:layout_weight="1"
android:autofillHints="given-name"
android:autofillHints="personGivenName"
android:hint="@string/CreateProfileActivity_first_name_required"
android:inputType="textPersonName"
android:singleLine="true" />
@ -158,7 +158,7 @@
android:layout_marginTop="13dp"
android:layout_marginEnd="16dp"
android:layout_weight="1"
android:autofillHints="family-name"
android:autofillHints="personFamilyName"
android:hint="@string/CreateProfileActivity_last_name_optional"
android:inputType="textPersonName"
android:singleLine="true" />