diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 2d8473b849..f573045a8f 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -172,9 +172,6 @@ - - - - - - - - - - - - - + when (actionId) { + EditorInfo.IME_ACTION_DONE -> { + saveNickName(recipient) + return@setOnEditorActionListener true + } + else -> return@setOnEditorActionListener false } - SSKEnvironment.shared.profileManager.setDisplayName(requireContext(), recipient, newNickName) - nameTextView.text = SSKEnvironment.shared.profileManager.getDisplayName(requireContext(), recipient) ?: "Anonymous" } nameTextView.text = SSKEnvironment.shared.profileManager.getDisplayName(requireContext(), recipient) ?: "Anonymous" publicKeyTextView.text = publicKey @@ -68,6 +69,19 @@ public class UserDetailsBottomSheet : BottomSheetDialogFragment() { } } + fun saveNickName(recipient: Recipient) { + nameEditText.clearFocus() + hideSoftKeyboard() + nameTextViewContainer.visibility = View.VISIBLE + nameEditContainer.visibility = View.INVISIBLE + var newNickName: String? = null + if (!nameEditText.text.isEmpty()) { + newNickName = nameEditText.text.toString() + } + SSKEnvironment.shared.profileManager.setDisplayName(requireContext(), recipient, newNickName) + nameTextView.text = SSKEnvironment.shared.profileManager.getDisplayName(requireContext(), recipient) ?: "Anonymous" + } + @SuppressLint("ServiceCast") fun showSoftKeyboard() { val imm = context?.getSystemService(Context.INPUT_METHOD_SERVICE) as? InputMethodManager