From 3e05a616ced3fbeb1e6ea15378cdeb2da03a942b Mon Sep 17 00:00:00 2001 From: Anton Chekulaev Date: Fri, 14 Aug 2020 19:26:56 +1000 Subject: [PATCH] Edit closed group activity layout refactoring. --- res/layout/activity_edit_closed_group.xml | 196 +++++++++++++----- res/layout/activity_settings.xml | 2 +- res/layout/view_conversation.xml | 2 +- res/layout/view_mention_candidate.xml | 2 +- .../activities/EditClosedGroupActivity.kt | 49 +++-- .../loki/activities/SettingsActivity.kt | 6 +- .../securesms/loki/views/ConversationView.kt | 2 +- .../loki/views/MentionCandidateView.kt | 2 +- 8 files changed, 176 insertions(+), 85 deletions(-) diff --git a/res/layout/activity_edit_closed_group.xml b/res/layout/activity_edit_closed_group.xml index 074b726fb6..d0591d39db 100644 --- a/res/layout/activity_edit_closed_group.xml +++ b/res/layout/activity_edit_closed_group.xml @@ -2,7 +2,9 @@ + xmlns:tools="http://schemas.android.com/tools" + android:background="@drawable/default_session_background" + tools:context="org.thoughtcrime.securesms.loki.activities.EditClosedGroupActivity"> - - - + tools:visibility="visible"> - + + + + + + + + - - + android:paddingVertical="@dimen/medium_spacing" + android:gravity="center" + android:visibility="visible" + tools:visibility="invisible"> + + + - - + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + android:layout_height="match_parent"/> diff --git a/res/layout/activity_settings.xml b/res/layout/activity_settings.xml index df55e40f5e..3f41cde6b9 100644 --- a/res/layout/activity_settings.xml +++ b/res/layout/activity_settings.xml @@ -97,7 +97,7 @@ android:hint="@string/activity_settings_display_name_edit_text_hint" /> + when (actionId) { + EditorInfo.IME_ACTION_DONE -> { + saveDisplayName() + return@setOnEditorActionListener true + } + else -> return@setOnEditorActionListener false + } + } + // Setup member list loader. LoaderManager.getInstance(this).initLoader(LOADER_ID_MEMBERS, null, object : LoaderManager.LoaderCallbacks> { override fun onCreateLoader(id: Int, bundle: Bundle?): Loader> { @@ -101,8 +115,6 @@ class EditClosedGroupActivity : PassphraseRequiredActionBarActivity() { // endregion // region Updating - - private fun updateMembers(members: Set) { this.members.clear() this.members.addAll(members) @@ -121,13 +133,6 @@ class EditClosedGroupActivity : PassphraseRequiredActionBarActivity() { return super.onOptionsItemSelected(item) } - private fun showEditDisplayNameUI() { - isEditingGroupName = true - } - private fun cancelEditingDisplayName() { - isEditingGroupName = false - } - private fun onMemberClick(member: String) { val bottomSheet = GroupEditingOptionsBottomSheet() bottomSheet.onRemoveTapped = { @@ -161,12 +166,12 @@ class EditClosedGroupActivity : PassphraseRequiredActionBarActivity() { } private fun handleIsEditingDisplayNameChanged() { - btnCancelGroupNameEdit.visibility = if (isEditingGroupName) View.VISIBLE else View.GONE - btnSaveGroupName.visibility = if (isEditingGroupName) View.VISIBLE else View.GONE - txvGroupNameDisplay.visibility = if (isEditingGroupName) View.INVISIBLE else View.VISIBLE - edtGroupName.visibility = if (isEditingGroupName) View.VISIBLE else View.INVISIBLE + cntGroupNameEdit.visibility = if (isEditingGroupName) View.VISIBLE else View.INVISIBLE + cntGroupNameDisplay.visibility = if (isEditingGroupName) View.INVISIBLE else View.VISIBLE val inputMethodManager = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager if (isEditingGroupName) { + edtGroupName.setText(newGroupDisplayName) + edtGroupName.selectAll() edtGroupName.requestFocus() inputMethodManager.showSoftInput(edtGroupName, 0) } else { @@ -186,7 +191,7 @@ class EditClosedGroupActivity : PassphraseRequiredActionBarActivity() { return Toast.makeText(this, R.string.activity_settings_display_name_too_long_error, Toast.LENGTH_SHORT).show() } newGroupDisplayName = groupDisplayName - txvGroupNameDisplay.text = groupDisplayName + lblGroupNameDisplay.text = groupDisplayName nameHasChanged = true isEditingGroupName = false } diff --git a/src/org/thoughtcrime/securesms/loki/activities/SettingsActivity.kt b/src/org/thoughtcrime/securesms/loki/activities/SettingsActivity.kt index 20086dc391..c96a7d0a96 100644 --- a/src/org/thoughtcrime/securesms/loki/activities/SettingsActivity.kt +++ b/src/org/thoughtcrime/securesms/loki/activities/SettingsActivity.kt @@ -78,7 +78,7 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() { profilePictureView.update() profilePictureView.setOnClickListener { showEditProfilePictureUI() } ctnGroupNameSection.setOnClickListener { showEditDisplayNameUI() } - txvGroupNameDisplay.text = DatabaseFactory.getLokiUserDatabase(this).getDisplayName(hexEncodedPublicKey) + btnGroupNameDisplay.text = DatabaseFactory.getLokiUserDatabase(this).getDisplayName(hexEncodedPublicKey) publicKeyTextView.text = hexEncodedPublicKey copyButton.setOnClickListener { copyPublicKey() } shareButton.setOnClickListener { sharePublicKey() } @@ -132,7 +132,7 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() { cancelButton.visibility = if (isEditingDisplayName) View.VISIBLE else View.GONE showQRCodeButton.visibility = if (isEditingDisplayName) View.GONE else View.VISIBLE saveButton.visibility = if (isEditingDisplayName) View.VISIBLE else View.GONE - txvGroupNameDisplay.visibility = if (isEditingDisplayName) View.INVISIBLE else View.VISIBLE + btnGroupNameDisplay.visibility = if (isEditingDisplayName) View.INVISIBLE else View.VISIBLE displayNameEditText.visibility = if (isEditingDisplayName) View.VISIBLE else View.INVISIBLE val titleTextViewLayoutParams = titleTextView.layoutParams as LinearLayout.LayoutParams titleTextViewLayoutParams.leftMargin = if (isEditingDisplayName) toPx(16, resources) else 0 @@ -176,7 +176,7 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() { } all(promises).alwaysUi { if (displayName != null) { - txvGroupNameDisplay.text = displayName + btnGroupNameDisplay.text = displayName } displayNameToBeUploaded = null if (isUpdatingProfilePicture && profilePicture != null) { diff --git a/src/org/thoughtcrime/securesms/loki/views/ConversationView.kt b/src/org/thoughtcrime/securesms/loki/views/ConversationView.kt index ce8092d2ff..73463326d7 100644 --- a/src/org/thoughtcrime/securesms/loki/views/ConversationView.kt +++ b/src/org/thoughtcrime/securesms/loki/views/ConversationView.kt @@ -80,7 +80,7 @@ class ConversationView : LinearLayout { profilePictureView.glide = glide profilePictureView.update() val senderDisplayName = if (thread.recipient.isLocalNumber) context.getString(R.string.note_to_self) else if (!thread.recipient.name.isNullOrEmpty()) thread.recipient.name else thread.recipient.address.toString() - txvGroupNameDisplay.text = senderDisplayName + btnGroupNameDisplay.text = senderDisplayName timestampTextView.text = DateUtils.getBriefRelativeTimeSpanString(context, Locale.getDefault(), thread.date) muteIndicatorImageView.visibility = if (thread.recipient.isMuted) VISIBLE else GONE val rawSnippet = thread.getDisplayBody(context) diff --git a/src/org/thoughtcrime/securesms/loki/views/MentionCandidateView.kt b/src/org/thoughtcrime/securesms/loki/views/MentionCandidateView.kt index 392f234d7f..1e6a0d057c 100644 --- a/src/org/thoughtcrime/securesms/loki/views/MentionCandidateView.kt +++ b/src/org/thoughtcrime/securesms/loki/views/MentionCandidateView.kt @@ -30,7 +30,7 @@ class MentionCandidateView(context: Context, attrs: AttributeSet?, defStyleAttr: } private fun update() { - txvGroupNameDisplay.text = mentionCandidate.displayName + btnGroupNameDisplay.text = mentionCandidate.displayName profilePictureView.publicKey = mentionCandidate.publicKey profilePictureView.additionalPublicKey = null profilePictureView.isRSSFeed = false