From 1d5f7957ab2c514eb7289aaedcde4dcbf9077ea7 Mon Sep 17 00:00:00 2001 From: Ryan ZHAO Date: Thu, 13 May 2021 16:20:55 +1000 Subject: [PATCH] clean --- app/src/main/AndroidManifest.xml | 33 ------------------ .../loki/dialogs/UserDetailsBottomSheet.kt | 34 +++++++++++++------ 2 files changed, 24 insertions(+), 43 deletions(-) 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