kopia lustrzana https://github.com/ryukoposting/Signal-Android
Refresh username in onResume and utilize imeAction.
rodzic
6cffd0a723
commit
7ac14dccda
|
@ -132,6 +132,12 @@ public class EditProfileFragment extends LoggingFragment {
|
|||
initializeUsername();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
viewModel.refreshUsername();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
outState.putByteArray(AVATAR_STATE, viewModel.getAvatarSnapshot());
|
||||
|
|
|
@ -37,8 +37,6 @@ class EditProfileViewModel extends ViewModel {
|
|||
this.repository = repository;
|
||||
this.groupId = groupId;
|
||||
|
||||
repository.getCurrentUsername(internalUsername::postValue);
|
||||
|
||||
if (!hasInstanceState) {
|
||||
if (groupId != null) {
|
||||
repository.getCurrentDisplayName(originalDisplayName::setValue);
|
||||
|
@ -110,6 +108,10 @@ class EditProfileViewModel extends ViewModel {
|
|||
internalAvatar.setValue(avatar);
|
||||
}
|
||||
|
||||
public void refreshUsername() {
|
||||
repository.getCurrentUsername(internalUsername::postValue);
|
||||
}
|
||||
|
||||
public void submitProfile(Consumer<EditProfileRepository.UploadResult> uploadResultConsumer) {
|
||||
ProfileName profileName = isGroup() ? ProfileName.EMPTY : internalProfileName.getValue();
|
||||
String displayName = isGroup() ? givenName.getValue() : "";
|
||||
|
|
|
@ -2,9 +2,11 @@ package org.thoughtcrime.securesms.usernames.username;
|
|||
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
@ -65,6 +67,13 @@ public class UsernameEditFragment extends LoggingFragment {
|
|||
viewModel.onUsernameUpdated(text);
|
||||
}
|
||||
});
|
||||
usernameInput.setOnEditorActionListener((v, actionId, event) -> {
|
||||
if (actionId == EditorInfo.IME_ACTION_DONE) {
|
||||
viewModel.onUsernameSubmitted(usernameInput.getText().toString());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
private void onUiStateChanged(@NonNull UsernameEditViewModel.State state) {
|
||||
|
|
|
@ -16,6 +16,9 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="48dp"
|
||||
android:hint="@string/CreateProfileActivity__create_a_username"
|
||||
android:imeOptions="actionDone"
|
||||
android:inputType="text"
|
||||
android:maxLines="1"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
|
Ładowanie…
Reference in New Issue