diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationActivity.java b/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationActivity.java
index 1582f36227..fa6f9869ba 100644
--- a/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationActivity.java
+++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationActivity.java
@@ -56,7 +56,9 @@ import android.view.View.OnFocusChangeListener;
import android.view.View.OnKeyListener;
import android.view.WindowManager;
import android.view.inputmethod.EditorInfo;
+import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
+import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.ProgressBar;
@@ -91,6 +93,7 @@ import org.session.libsession.messaging.sending_receiving.attachments.Attachment
import org.session.libsession.messaging.threads.DistributionTypes;
import org.session.libsession.utilities.GroupUtil;
import org.session.libsession.utilities.MediaTypes;
+import org.session.libsession.utilities.SSKEnvironment;
import org.session.libsignal.libsignal.InvalidMessageException;
import org.session.libsignal.libsignal.util.guava.Optional;
import org.session.libsignal.service.loki.api.opengroups.PublicChat;
@@ -258,7 +261,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
private ImageButton sendButton;
private ImageButton attachButton;
private ProfilePictureView profilePictureView;
- private TextView titleTextView;
+ private EditText titleTextView;
private ConversationFragment fragment;
private Button unblockButton;
private Button makeDefaultSmsButton;
@@ -374,6 +377,35 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
}
});
+ if (isGroupConversation()) {
+ titleTextView.setEnabled(false);
+ } else {
+ titleTextView.setImeOptions(EditorInfo.IME_ACTION_DONE);
+ titleTextView.setOnEditorActionListener((v, actionId, event) -> {
+ if (actionId == EditorInfo.IME_ACTION_DONE) {
+ String nickname = v.getText().toString().trim();
+ SSKEnvironment.shared.getProfileManager().setDisplayName(this, getRecipient(), nickname);
+ v.clearFocus();
+ return true;
+ }
+ return false;
+ });
+ titleTextView.setOnFocusChangeListener((v, hasFocus) -> {
+ InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
+ if (!hasFocus) {
+ EditText textView = (EditText) v;
+ if (textView.getText().toString().isEmpty()) {
+ textView.setText(getRecipient().getName());
+ }
+ imm.hideSoftInputFromWindow(v.getWindowToken(),0);
+ } else {
+ String nickname = DatabaseFactory.getStorage(this).getDisplayName(getRecipient().getAddress().serialize());
+ titleTextView.setText(nickname);
+ imm.showSoftInput(v, 0);
+ }
+ });
+ }
+
MentionManagerUtilities.INSTANCE.populateUserPublicKeyCacheIfNeeded(threadId, this);
PublicChat publicChat = DatabaseFactory.getLokiThreadDatabase(this).getPublicChat(threadId);
diff --git a/app/src/main/java/org/thoughtcrime/securesms/sskenvironment/ProfileManager.kt b/app/src/main/java/org/thoughtcrime/securesms/sskenvironment/ProfileManager.kt
index f213bb3057..0332f1c474 100644
--- a/app/src/main/java/org/thoughtcrime/securesms/sskenvironment/ProfileManager.kt
+++ b/app/src/main/java/org/thoughtcrime/securesms/sskenvironment/ProfileManager.kt
@@ -11,7 +11,7 @@ class ProfileManager: SSKEnvironment.ProfileManagerProtocol {
override fun setDisplayName(context: Context, recipient: Recipient, displayName: String) {
val database = DatabaseFactory.getLokiUserDatabase(context)
val publicKey = recipient.address.serialize()
- if (recipient.profileName == null) {
+ if (recipient.name == null) {
// Migrate the profile name in LokiUserDatabase to recipient
database.getDisplayName(publicKey)?.let { setProfileName(context, recipient, it) }
}
diff --git a/app/src/main/res/layout/conversation_activity.xml b/app/src/main/res/layout/conversation_activity.xml
index 0b9ff3d077..4b441491ff 100644
--- a/app/src/main/res/layout/conversation_activity.xml
+++ b/app/src/main/res/layout/conversation_activity.xml
@@ -51,15 +51,18 @@
android:layout_marginStart="@dimen/medium_spacing"
android:orientation="vertical">
-
names = new LinkedList<>();