mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-11 18:54:21 +00:00
Edit closed group activity layout refactoring.
This commit is contained in:
parent
f7923cd8a4
commit
3e05a616ce
@ -2,7 +2,9 @@
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/default_session_background">
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:background="@drawable/default_session_background"
|
||||
tools:context="org.thoughtcrime.securesms.loki.activities.EditClosedGroupActivity">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/mainContentContainer"
|
||||
@ -18,66 +20,152 @@
|
||||
android:layout_marginTop="@dimen/small_spacing"
|
||||
android:layout_marginRight="@dimen/large_spacing">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/cntGroupNameEdit"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:orientation="horizontal"
|
||||
android:visibility="invisible"
|
||||
tools:visibility="visible">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/btnCancelGroupNameEdit"
|
||||
android:layout_width="36dp"
|
||||
android:layout_height="36dp"
|
||||
android:layout_toLeftOf="@+id/edtGroupName"
|
||||
android:layout_centerVertical="true"
|
||||
android:src="@drawable/ic_close_white_24dp"
|
||||
android:visibility="gone" />
|
||||
android:layout_gravity="center"
|
||||
android:src="@drawable/ic_close_white_24dp"/>
|
||||
|
||||
<EditText
|
||||
style="@style/SessionEditText"
|
||||
android:id="@+id/edtGroupName"
|
||||
android:layout_width="@dimen/album_total_width"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_weight="1"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:textAlignment="center"
|
||||
android:paddingTop="12dp"
|
||||
android:paddingBottom="@dimen/large_spacing"
|
||||
android:paddingHorizontal="@dimen/large_spacing"
|
||||
android:visibility="invisible"
|
||||
android:inputType="text"
|
||||
android:singleLine="true"
|
||||
android:imeOptions="actionDone"
|
||||
android:hint="@string/activity_edit_closed_group_edit_text_hint" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/btnSaveGroupNameEdit"
|
||||
android:layout_width="36dp"
|
||||
android:layout_height="36dp"
|
||||
android:layout_gravity="center"
|
||||
android:src="@drawable/ic_check_white_24dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/cntGroupNameDisplay"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:paddingVertical="@dimen/medium_spacing"
|
||||
android:gravity="center"
|
||||
android:visibility="visible"
|
||||
tools:visibility="invisible">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txvGroupNameDisplay"
|
||||
android:id="@+id/lblGroupNameDisplay"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_gravity="center"
|
||||
android:textColor="@color/text"
|
||||
android:textSize="@dimen/very_large_font_size"
|
||||
android:textStyle="bold"
|
||||
android:drawableRight="@drawable/ic_edit_white_24dp"
|
||||
android:drawablePadding="@dimen/small_spacing"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/btnSaveGroupName"
|
||||
android:layout_width="36dp"
|
||||
android:layout_height="36dp"
|
||||
android:src="@drawable/ic_check_white_24dp"
|
||||
android:layout_toRightOf="@+id/edtGroupName"
|
||||
android:layout_centerVertical="true"
|
||||
android:visibility="gone" />
|
||||
android:textAlignment="center"
|
||||
android:paddingStart="24dp"
|
||||
android:paddingEnd="0dp"
|
||||
android:drawableEnd="@drawable/ic_edit_white_24dp"
|
||||
android:drawablePadding="@dimen/small_spacing"
|
||||
tools:text="SomeGroupName"/>
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<View
|
||||
android:layout_weight="2"
|
||||
android:layout_height="0px"
|
||||
android:layout_width="@dimen/large_spacing"/>
|
||||
<!-- <RelativeLayout-->
|
||||
<!-- android:id="@+id/ctnGroupNameSection"-->
|
||||
<!-- android:layout_width="match_parent"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:layout_marginLeft="@dimen/large_spacing"-->
|
||||
<!-- android:layout_marginTop="@dimen/small_spacing"-->
|
||||
<!-- android:layout_marginRight="@dimen/large_spacing"-->
|
||||
<!-- tools:visibility="gone">-->
|
||||
|
||||
<View
|
||||
android:layout_weight="2"
|
||||
android:layout_height="0px"
|
||||
android:layout_width="@dimen/large_spacing"
|
||||
/>
|
||||
<!-- <ImageView-->
|
||||
<!-- android:id="@+id/btnCancelGroupNameEdit"-->
|
||||
<!-- android:layout_width="36dp"-->
|
||||
<!-- android:layout_height="36dp"-->
|
||||
<!-- android:layout_toLeftOf="@+id/edtGroupName"-->
|
||||
<!-- android:layout_centerVertical="true"-->
|
||||
<!-- android:src="@drawable/ic_close_white_24dp"-->
|
||||
<!-- android:visibility="gone" />-->
|
||||
|
||||
<!-- <EditText-->
|
||||
<!-- style="@style/SessionEditText"-->
|
||||
<!-- android:id="@+id/edtGroupName"-->
|
||||
<!-- android:layout_width="@dimen/album_total_width"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:layout_centerInParent="true"-->
|
||||
<!-- android:textAlignment="center"-->
|
||||
<!-- android:visibility="invisible"-->
|
||||
<!-- android:hint="@string/activity_edit_closed_group_edit_text_hint" />-->
|
||||
<!--<!– android:layout_width="@dimen/album_total_width"–>-->
|
||||
<!--<!– android:paddingTop="12dp"–>-->
|
||||
<!--<!– android:paddingBottom="@dimen/large_spacing"–>-->
|
||||
<!--<!– android:paddingHorizontal="@dimen/large_spacing"–>-->
|
||||
|
||||
</LinearLayout>
|
||||
<!--<!– <EditText–>-->
|
||||
<!--<!– style="@style/SessionEditText"–>-->
|
||||
<!--<!– android:id="@+id/nameEditText"–>-->
|
||||
<!--<!– android:layout_width="match_parent"–>-->
|
||||
<!--<!– android:layout_height="wrap_content"–>-->
|
||||
<!--<!– android:layout_marginLeft="@dimen/large_spacing"–>-->
|
||||
<!--<!– android:layout_marginTop="@dimen/medium_spacing"–>-->
|
||||
<!--<!– android:layout_marginRight="@dimen/large_spacing"–>-->
|
||||
<!--<!– android:layout_marginBottom="@dimen/medium_spacing"–>-->
|
||||
<!--<!– android:hint="@string/activity_create_closed_group_edit_text_hint" />–>-->
|
||||
|
||||
<!-- <TextView-->
|
||||
<!-- android:id="@+id/btnGroupNameDisplay"-->
|
||||
<!-- android:layout_width="wrap_content"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:layout_centerInParent="true"-->
|
||||
<!-- android:textColor="@color/text"-->
|
||||
<!-- android:textSize="@dimen/very_large_font_size"-->
|
||||
<!-- android:textStyle="bold"-->
|
||||
<!-- android:drawableRight="@drawable/ic_edit_white_24dp"-->
|
||||
<!-- android:drawablePadding="@dimen/small_spacing"/>-->
|
||||
|
||||
<!-- <ImageView-->
|
||||
<!-- android:id="@+id/imgSaveGroupName"-->
|
||||
<!-- android:layout_width="36dp"-->
|
||||
<!-- android:layout_height="36dp"-->
|
||||
<!-- android:src="@drawable/ic_check_white_24dp"-->
|
||||
<!-- android:layout_toRightOf="@+id/edtGroupName"-->
|
||||
<!-- android:layout_centerVertical="true"-->
|
||||
<!-- android:visibility="gone" />-->
|
||||
|
||||
<!-- </RelativeLayout>-->
|
||||
|
||||
<!-- <!– TODO: WTF? –>-->
|
||||
<!-- <LinearLayout-->
|
||||
<!-- android:layout_width="match_parent"-->
|
||||
<!-- android:layout_height="wrap_content">-->
|
||||
<!-- <View-->
|
||||
<!-- android:layout_weight="2"-->
|
||||
<!-- android:layout_height="0px"-->
|
||||
<!-- android:layout_width="@dimen/large_spacing"/>-->
|
||||
<!-- <View-->
|
||||
<!-- android:layout_weight="2"-->
|
||||
<!-- android:layout_height="0px"-->
|
||||
<!-- android:layout_width="@dimen/large_spacing"/>-->
|
||||
<!-- </LinearLayout>-->
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
@ -92,8 +180,6 @@
|
||||
android:textAlignment="center"
|
||||
android:text="@string/activity_edit_closed_group_explanation" />
|
||||
|
||||
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1px"
|
||||
@ -106,9 +192,9 @@
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/large_spacing"
|
||||
android:layout_marginStart="@dimen/large_spacing"
|
||||
android:layout_marginTop="@dimen/small_spacing"
|
||||
android:layout_marginRight="@dimen/massive_spacing"
|
||||
android:layout_marginEnd="@dimen/massive_spacing"
|
||||
android:layout_marginBottom="@dimen/small_spacing"
|
||||
android:layout_weight="1"
|
||||
android:alpha="0.8"
|
||||
|
@ -97,7 +97,7 @@
|
||||
android:hint="@string/activity_settings_display_name_edit_text_hint" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txvGroupNameDisplay"
|
||||
android:id="@+id/btnGroupNameDisplay"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
|
@ -35,7 +35,7 @@
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txvGroupNameDisplay"
|
||||
android:id="@+id/btnGroupNameDisplay"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="1"
|
||||
|
@ -30,7 +30,7 @@
|
||||
</RelativeLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txvGroupNameDisplay"
|
||||
android:id="@+id/btnGroupNameDisplay"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/medium_spacing"
|
||||
|
@ -9,13 +9,12 @@ import android.support.v7.widget.LinearLayoutManager
|
||||
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 kotlinx.android.synthetic.main.activity_create_closed_group.emptyStateContainer
|
||||
import kotlinx.android.synthetic.main.activity_create_closed_group.mainContentContainer
|
||||
import kotlinx.android.synthetic.main.activity_edit_closed_group.*
|
||||
import kotlinx.android.synthetic.main.activity_edit_closed_group.ctnGroupNameSection
|
||||
import kotlinx.android.synthetic.main.activity_edit_closed_group.txvGroupNameDisplay
|
||||
import kotlinx.android.synthetic.main.activity_linked_devices.recyclerView
|
||||
import network.loki.messenger.R
|
||||
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity
|
||||
@ -45,7 +44,11 @@ class EditClosedGroupActivity : PassphraseRequiredActionBarActivity() {
|
||||
private var nameHasChanged = false
|
||||
|
||||
private var isEditingGroupName = false
|
||||
set(value) { field = value; handleIsEditingDisplayNameChanged() }
|
||||
set(value) {
|
||||
if (field == value) return
|
||||
field = value
|
||||
handleIsEditingDisplayNameChanged()
|
||||
}
|
||||
|
||||
// region Lifecycle
|
||||
override fun onCreate(savedInstanceState: Bundle?, isReady: Boolean) {
|
||||
@ -54,14 +57,10 @@ class EditClosedGroupActivity : PassphraseRequiredActionBarActivity() {
|
||||
|
||||
this.groupID = intent.getStringExtra(EXTRA_GROUP_ID)
|
||||
this.originalName = DatabaseFactory.getGroupDatabase(this).getGroup(groupID).get().title
|
||||
this.newGroupDisplayName = this.originalName
|
||||
|
||||
supportActionBar!!.title = resources.getString(R.string.activity_edit_closed_group_title)
|
||||
|
||||
txvGroupNameDisplay.text = originalName
|
||||
ctnGroupNameSection.setOnClickListener { showEditDisplayNameUI() }
|
||||
btnCancelGroupNameEdit.setOnClickListener { cancelEditingDisplayName() }
|
||||
btnSaveGroupName.setOnClickListener { saveDisplayName() }
|
||||
|
||||
addMembersClosedGroupButton.setOnClickListener { onAddMembersClick() }
|
||||
|
||||
this.memberListAdapter = EditClosedGroupMembersAdapter(
|
||||
@ -72,6 +71,21 @@ class EditClosedGroupActivity : PassphraseRequiredActionBarActivity() {
|
||||
recyclerView.adapter = this.memberListAdapter
|
||||
recyclerView.layoutManager = LinearLayoutManager(this)
|
||||
|
||||
lblGroupNameDisplay.text = this.originalName
|
||||
cntGroupNameDisplay.setOnClickListener { isEditingGroupName = true }
|
||||
btnCancelGroupNameEdit.setOnClickListener { isEditingGroupName = false }
|
||||
btnSaveGroupNameEdit.setOnClickListener { saveDisplayName() }
|
||||
edtGroupName.setImeActionLabel(getString(R.string.save), EditorInfo.IME_ACTION_DONE)
|
||||
edtGroupName.setOnEditorActionListener { _, actionId, _ ->
|
||||
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<List<String>> {
|
||||
override fun onCreateLoader(id: Int, bundle: Bundle?): Loader<List<String>> {
|
||||
@ -101,8 +115,6 @@ class EditClosedGroupActivity : PassphraseRequiredActionBarActivity() {
|
||||
// endregion
|
||||
|
||||
// region Updating
|
||||
|
||||
|
||||
private fun updateMembers(members: Set<String>) {
|
||||
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
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user