add edit name UI

This commit is contained in:
Haafingar 2020-06-09 15:03:43 +10:00
parent cd7fd5d51a
commit e0c8ae54b6
2 changed files with 28 additions and 9 deletions

View File

@ -22,7 +22,7 @@
<EditText
style="@style/SessionEditText"
android:id="@+id/displayNameEditText"
android:id="@+id/groupNameEditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
@ -39,13 +39,9 @@
android:layout_centerInParent="true"
android:textColor="@color/text"
android:textSize="@dimen/very_large_font_size"
android:textStyle="bold"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableStart="@drawable/ic_edit_white_24dp"
android:gravity="right"/>
android:textStyle="bold"
android:drawableRight="@drawable/ic_edit_white_24dp"
android:drawablePadding="@dimen/small_spacing"/>
</RelativeLayout>

View File

@ -1,5 +1,6 @@
package org.thoughtcrime.securesms.loki.activities
import android.content.Context
import android.content.Intent
import android.graphics.Bitmap
import android.os.AsyncTask
@ -10,6 +11,8 @@ import android.support.v7.widget.LinearLayoutManager
import android.view.Menu
import android.view.MenuItem
import android.view.View
import android.view.inputmethod.InputMethodManager
import android.widget.LinearLayout
import android.widget.Toast
import kotlinx.android.synthetic.main.activity_create_closed_group.*
import kotlinx.android.synthetic.main.activity_create_closed_group.emptyStateContainer
@ -28,6 +31,7 @@ import org.thoughtcrime.securesms.database.DatabaseFactory
import org.thoughtcrime.securesms.database.ThreadDatabase
import org.thoughtcrime.securesms.groups.GroupManager
import org.thoughtcrime.securesms.loki.dialogs.GroupEditingOptionsBottomSheet
import org.thoughtcrime.securesms.loki.utilities.toPx
import org.thoughtcrime.securesms.mms.GlideApp
import org.thoughtcrime.securesms.recipients.Recipient
import org.thoughtcrime.securesms.util.TextSecurePreferences
@ -45,6 +49,7 @@ class EditClosedGroupActivity : PassphraseRequiredActionBarActivity(), MemberCli
result
}
private var isEditingDisplayName = false
set(value) { field = value; handleIsEditingDisplayNameChanged() }
private val selectedMembers: Set<String>
get() { return editClosedGroupAdapter.selectedMembers }
@ -58,7 +63,7 @@ class EditClosedGroupActivity : PassphraseRequiredActionBarActivity(), MemberCli
setContentView(R.layout.activity_edit_closed_group)
supportActionBar!!.title = resources.getString(R.string.activity_edit_closed_group_title)
displayNameContainer.setOnClickListener { showEditDisplayNameUI() }
displayNameTextView.text = "Get Group Name"
displayNameTextView.text = "Get Group Name" // DatabaseFactory.getLokiUserDatabase(this).getDisplayName(hexEncodedPublicKey)
recyclerView.adapter = editClosedGroupAdapter
recyclerView.layoutManager = LinearLayoutManager(this)
addMembersClosedGroupButton.setOnClickListener { createNewPrivateChat() }
@ -152,6 +157,24 @@ class EditClosedGroupActivity : PassphraseRequiredActionBarActivity(), MemberCli
startActivity(intent)
finish()
}
private fun handleIsEditingDisplayNameChanged() {
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
displayNameTextView.visibility = if (isEditingDisplayName) View.INVISIBLE else View.VISIBLE
groupNameEditText.visibility = if (isEditingDisplayName) View.VISIBLE else View.INVISIBLE
val titleTextViewLayoutParams = titleTextView.layoutParams as LinearLayout.LayoutParams
titleTextViewLayoutParams.leftMargin = if (isEditingDisplayName) toPx(16, resources) else 0
titleTextView.layoutParams = titleTextViewLayoutParams
val inputMethodManager = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
if (isEditingDisplayName) {
groupNameEditText.requestFocus()
inputMethodManager.showSoftInput(groupNameEditText, 0)
} else {
inputMethodManager.hideSoftInputFromWindow(groupNameEditText.windowToken, 0)
}
}
// endregion
// region Tasks