diff --git a/app/src/main/java/org/thoughtcrime/securesms/groups/CreateGroupFragment.kt b/app/src/main/java/org/thoughtcrime/securesms/groups/CreateGroupFragment.kt
index ecd40938a1..75c7681b1d 100644
--- a/app/src/main/java/org/thoughtcrime/securesms/groups/CreateGroupFragment.kt
+++ b/app/src/main/java/org/thoughtcrime/securesms/groups/CreateGroupFragment.kt
@@ -78,7 +78,7 @@ class CreateGroupFragment : Fragment() {
if (name.isEmpty()) {
return@setOnClickListener Toast.makeText(context, R.string.activity_create_closed_group_group_name_missing_error, Toast.LENGTH_LONG).show()
}
- if (name.length >= 30) {
+ if (name.length > resources.getInteger(R.integer.max_group_and_community_name_length_chars)) {
return@setOnClickListener Toast.makeText(context, R.string.activity_create_closed_group_group_name_too_long_error, Toast.LENGTH_LONG).show()
}
val selectedMembers = adapter.selectedMembers
diff --git a/app/src/main/java/org/thoughtcrime/securesms/home/UserDetailsBottomSheet.kt b/app/src/main/java/org/thoughtcrime/securesms/home/UserDetailsBottomSheet.kt
index ad8f2d0421..acb9caa75f 100644
--- a/app/src/main/java/org/thoughtcrime/securesms/home/UserDetailsBottomSheet.kt
+++ b/app/src/main/java/org/thoughtcrime/securesms/home/UserDetailsBottomSheet.kt
@@ -25,7 +25,6 @@ import org.session.libsession.utilities.recipients.Recipient
import org.session.libsignal.utilities.IdPrefix
import org.thoughtcrime.securesms.conversation.v2.ConversationActivityV2
import org.thoughtcrime.securesms.database.ThreadDatabase
-import org.thoughtcrime.securesms.mms.GlideApp
import javax.inject.Inject
@AndroidEntryPoint
@@ -34,6 +33,9 @@ class UserDetailsBottomSheet: BottomSheetDialogFragment() {
@Inject lateinit var threadDb: ThreadDatabase
private lateinit var binding: FragmentUserDetailsBottomSheetBinding
+
+ private var previousContactNickname: String = ""
+
companion object {
const val ARGUMENT_PUBLIC_KEY = "publicKey"
const val ARGUMENT_THREAD_ID = "threadId"
@@ -130,9 +132,10 @@ class UserDetailsBottomSheet: BottomSheetDialogFragment() {
nameTextViewContainer.visibility = View.VISIBLE
nameEditTextContainer.visibility = View.INVISIBLE
var newNickName: String? = null
- if (nicknameEditText.text.isNotEmpty()) {
+ if (nicknameEditText.text.isNotEmpty() && nicknameEditText.text.trim().length != 0) {
newNickName = nicknameEditText.text.toString()
}
+ else { newNickName = previousContactNickname }
val publicKey = recipient.address.serialize()
val storage = MessagingModuleConfiguration.shared.storage
val contact = storage.getContactWithSessionID(publicKey) ?: Contact(publicKey)
@@ -145,6 +148,9 @@ class UserDetailsBottomSheet: BottomSheetDialogFragment() {
fun showSoftKeyboard() {
val imm = context?.getSystemService(Context.INPUT_METHOD_SERVICE) as? InputMethodManager
imm?.showSoftInput(binding.nicknameEditText, 0)
+
+ // Keep track of the original nickname to re-use if an empty / blank nickname is entered
+ previousContactNickname = binding.nameTextView.text.toString()
}
fun hideSoftKeyboard() {
diff --git a/app/src/main/java/org/thoughtcrime/securesms/preferences/SettingsActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/preferences/SettingsActivity.kt
index 062a8d44dd..2a45d596d6 100644
--- a/app/src/main/java/org/thoughtcrime/securesms/preferences/SettingsActivity.kt
+++ b/app/src/main/java/org/thoughtcrime/securesms/preferences/SettingsActivity.kt
@@ -17,6 +17,7 @@ import android.view.ActionMode
import android.view.Menu
import android.view.MenuItem
import android.view.View
+import android.view.inputmethod.EditorInfo
import android.view.inputmethod.InputMethodManager
import android.widget.Toast
import androidx.core.view.isVisible
@@ -203,6 +204,21 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() {
binding.displayNameEditText.selectAll()
binding.displayNameEditText.requestFocus()
inputMethodManager.showSoftInput(binding.displayNameEditText, 0)
+
+ // Save the updated display name when the user presses enter on the soft keyboard
+ binding.displayNameEditText.setOnEditorActionListener { v, actionId, event ->
+ when (actionId) {
+ // Note: IME_ACTION_DONE is how we've configured the soft keyboard to respond,
+ // while IME_ACTION_UNSPECIFIED is what triggers when we hit enter on a
+ // physical keyboard.
+ EditorInfo.IME_ACTION_DONE, EditorInfo.IME_ACTION_UNSPECIFIED -> {
+ saveDisplayName()
+ displayNameEditActionMode?.finish()
+ true
+ }
+ else -> false
+ }
+ }
} else {
inputMethodManager.hideSoftInputFromWindow(binding.displayNameEditText.windowToken, 0)
}
diff --git a/app/src/main/res/layout-sw400dp/activity_display_name.xml b/app/src/main/res/layout-sw400dp/activity_display_name.xml
index 4d4ff30406..d62faca064 100644
--- a/app/src/main/res/layout-sw400dp/activity_display_name.xml
+++ b/app/src/main/res/layout-sw400dp/activity_display_name.xml
@@ -43,6 +43,8 @@
android:paddingBottom="0dp"
android:gravity="center_vertical"
android:inputType="textCapWords"
+ android:maxLength="@integer/max_user_nickname_length_chars"
+ android:maxLines="1"
android:hint="@string/activity_display_name_edit_text_hint" />
@@ -49,6 +50,7 @@
android:inputType="text"
android:singleLine="true"
android:imeOptions="actionDone"
+ android:maxLength="@integer/max_group_and_community_name_length_chars"
android:contentDescription="@string/AccessibilityId_group_name"
android:hint="@string/activity_edit_closed_group_edit_text_hint" />
@@ -57,6 +59,7 @@
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center"
+ android:layout_marginRight="@dimen/medium_spacing"
android:contentDescription="@string/AccessibilityId_accept_name_change"
android:src="@drawable/ic_baseline_done_24"/>
diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml
index 44df7e82ef..01a124fe11 100644
--- a/app/src/main/res/layout/activity_settings.xml
+++ b/app/src/main/res/layout/activity_settings.xml
@@ -47,7 +47,11 @@
android:paddingTop="12dp"
android:paddingBottom="12dp"
android:visibility="invisible"
- android:hint="@string/activity_settings_display_name_edit_text_hint" />
+ android:hint="@string/activity_settings_display_name_edit_text_hint"
+ android:imeOptions="actionDone"
+ android:inputType="textCapWords"
+ android:maxLength="@integer/max_user_nickname_length_chars"
+ android:maxLines="1" />
diff --git a/app/src/main/res/layout/fragment_create_group.xml b/app/src/main/res/layout/fragment_create_group.xml
index af685fa9f6..1e901c753c 100644
--- a/app/src/main/res/layout/fragment_create_group.xml
+++ b/app/src/main/res/layout/fragment_create_group.xml
@@ -62,10 +62,14 @@
android:layout_marginBottom="@dimen/medium_spacing"
android:contentDescription="@string/AccessibilityId_group_name_input"
android:hint="@string/activity_create_closed_group_edit_text_hint"
- android:maxLength="30"
+ android:imeOptions="actionDone"
+ android:inputType="textCapWords"
+ android:maxLength="@integer/max_group_and_community_name_length_chars"
+ android:maxLines="1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toBottomOf="@id/titleText" />
+ app:layout_constraintTop_toBottomOf="@id/titleText"
+ tools:ignore="ContentDescription" />
@@ -73,6 +77,7 @@
android:id="@+id/cancelNicknameEditingButton"
android:layout_width="24dp"
android:layout_height="24dp"
+ android:layout_marginLeft="@dimen/large_spacing"
android:contentDescription="@string/AccessibilityId_cancel"
android:src="@drawable/ic_baseline_clear_24" />
@@ -82,12 +87,12 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
- android:layout_marginHorizontal="@dimen/small_spacing"
android:contentDescription="@string/AccessibilityId_username"
android:textAlignment="center"
android:paddingVertical="12dp"
android:inputType="text"
- android:singleLine="true"
+ android:maxLength="@integer/max_user_nickname_length_chars"
+ android:maxLines="1"
android:imeOptions="actionDone"
android:textColorHint="?android:textColorSecondary"
android:hint="@string/fragment_user_details_bottom_sheet_edit_text_hint" />
@@ -96,6 +101,7 @@
android:id="@+id/saveNicknameButton"
android:layout_width="24dp"
android:layout_height="24dp"
+ android:layout_marginRight="@dimen/large_spacing"
android:contentDescription="@string/AccessibilityId_apply"
android:src="@drawable/ic_baseline_done_24" />
diff --git a/app/src/main/res/layout/view_contact.xml b/app/src/main/res/layout/view_contact.xml
index 3053046d8c..ceb4304cc7 100644
--- a/app/src/main/res/layout/view_contact.xml
+++ b/app/src/main/res/layout/view_contact.xml
@@ -25,6 +25,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/medium_spacing"
+ android:maxLength="@integer/max_user_nickname_length_chars"
android:maxLines="1"
android:textAlignment="viewStart"
android:ellipsize="end"
diff --git a/app/src/main/res/layout/view_conversation.xml b/app/src/main/res/layout/view_conversation.xml
index 12a7a8ac8c..ed3cc66969 100644
--- a/app/src/main/res/layout/view_conversation.xml
+++ b/app/src/main/res/layout/view_conversation.xml
@@ -165,7 +165,7 @@
android:maxLines="1"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/medium_font_size"
- tools:text="Sorry, gotta go fight crime again" />
+ tools:text="Sorry, gotta go fight crime again - and more text to make it ellipsize" />
100
150
10
+
+ 35
+ 35
\ No newline at end of file