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