mirror of
https://github.com/nextcloud/talk-android
synced 2025-03-06 22:29:09 +00:00
add editing mode for conversation avatar
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
dc09f21870
commit
84008a40dc
@ -34,6 +34,8 @@ import android.os.Bundle
|
||||
import android.os.Parcelable
|
||||
import android.text.TextUtils
|
||||
import android.util.Log
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.View.GONE
|
||||
import android.view.View.VISIBLE
|
||||
@ -135,6 +137,9 @@ class ConversationInfoActivity :
|
||||
private var adapter: FlexibleAdapter<ParticipantItem>? = null
|
||||
private var userItems: MutableList<ParticipantItem> = ArrayList()
|
||||
|
||||
private lateinit var optionsMenu: Menu
|
||||
private var edit = false
|
||||
|
||||
private lateinit var pickImage: PickImage
|
||||
|
||||
private val workerData: Data?
|
||||
@ -199,7 +204,6 @@ class ConversationInfoActivity :
|
||||
}
|
||||
|
||||
private fun setupAvatarOptions() {
|
||||
if (CapabilitiesUtilNew.isConversationAvatarEndpointAvailable(conversationUser)) {
|
||||
pickImage = PickImage(this, conversationUser)
|
||||
binding.avatarUpload.setOnClickListener { pickImage.selectLocal() }
|
||||
binding.avatarChoose.setOnClickListener { pickImage.selectRemote() }
|
||||
@ -213,9 +217,6 @@ class ConversationInfoActivity :
|
||||
viewThemeUtils.material.themeFAB(it.avatarCamera)
|
||||
viewThemeUtils.material.themeFAB(it.avatarDelete)
|
||||
}
|
||||
} else {
|
||||
binding.avatarButtons.visibility = GONE
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupActionBar() {
|
||||
@ -234,6 +235,30 @@ class ConversationInfoActivity :
|
||||
viewThemeUtils.material.themeToolbar(binding.conversationInfoToolbar)
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
super.onCreateOptionsMenu(menu)
|
||||
if (CapabilitiesUtilNew.isConversationAvatarEndpointAvailable(conversationUser)) {
|
||||
menuInflater.inflate(R.menu.menu_conversation_info, menu)
|
||||
optionsMenu = menu
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
override fun onPrepareOptionsMenu(menu: Menu): Boolean {
|
||||
super.onPrepareOptionsMenu(menu)
|
||||
// menu.findItem(R.id.edit).isVisible = editableFields.size > 0
|
||||
setEditMode(false)
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
if (item.itemId == R.id.edit) {
|
||||
toggleEditMode()
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
private fun themeSwitchPreferences() {
|
||||
binding.run {
|
||||
listOf(
|
||||
@ -263,6 +288,33 @@ class ConversationInfoActivity :
|
||||
}
|
||||
}
|
||||
|
||||
private fun toggleEditMode() {
|
||||
edit = !edit
|
||||
if (edit) {
|
||||
setEditMode(true)
|
||||
} else {
|
||||
setEditMode(false)
|
||||
}
|
||||
}
|
||||
|
||||
private fun setEditMode(editing: Boolean) {
|
||||
if (editing) {
|
||||
optionsMenu.findItem(R.id.edit).setTitle(R.string.save)
|
||||
binding.avatarUpload.visibility = VISIBLE
|
||||
binding.avatarChoose.visibility = VISIBLE
|
||||
binding.avatarCamera.visibility = VISIBLE
|
||||
binding.avatarDelete.visibility = VISIBLE
|
||||
edit = true
|
||||
} else {
|
||||
optionsMenu.findItem(R.id.edit).setTitle(R.string.edit)
|
||||
binding.avatarUpload.visibility = GONE
|
||||
binding.avatarChoose.visibility = GONE
|
||||
binding.avatarCamera.visibility = GONE
|
||||
binding.avatarDelete.visibility = GONE
|
||||
edit = false
|
||||
}
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
when (resultCode) {
|
||||
@ -325,7 +377,7 @@ class ConversationInfoActivity :
|
||||
}
|
||||
|
||||
override fun onComplete() {
|
||||
// unused atm
|
||||
setEditMode(false)
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -360,7 +412,7 @@ class ConversationInfoActivity :
|
||||
}
|
||||
|
||||
override fun onComplete() {
|
||||
// unused atm
|
||||
setEditMode(false)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -87,6 +87,14 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/avatar_image"
|
||||
android:layout_width="@dimen/avatar_size_big"
|
||||
android:layout_height="@dimen/avatar_size_big"
|
||||
android:layout_centerHorizontal="true"
|
||||
tools:src="@drawable/account_circle_48dp"
|
||||
android:contentDescription="@string/avatar" />
|
||||
|
||||
<androidx.emoji2.widget.EmojiTextView
|
||||
android:id="@+id/display_name_text"
|
||||
android:layout_width="wrap_content"
|
||||
@ -96,14 +104,6 @@
|
||||
android:layout_marginTop="@dimen/margin_between_elements"
|
||||
tools:text="Jane Doe" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/avatar_image"
|
||||
android:layout_width="@dimen/avatar_size_big"
|
||||
android:layout_height="@dimen/avatar_size_big"
|
||||
android:layout_centerHorizontal="true"
|
||||
tools:src="@drawable/account_circle_48dp"
|
||||
android:contentDescription="@string/avatar" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
|
28
app/src/main/res/menu/menu_conversation_info.xml
Normal file
28
app/src/main/res/menu/menu_conversation_info.xml
Normal file
@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Nextcloud Android Talk application
|
||||
|
||||
@author Tobias Kaminsky
|
||||
Copyright (C) 2021 Tobias Kaminsky
|
||||
Copyright (C) 2021 Nextcloud GmbH
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
-->
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<item
|
||||
android:id="@+id/edit"
|
||||
android:title="@string/edit"
|
||||
app:showAsAction="ifRoom" />
|
||||
</menu>
|
Loading…
Reference in New Issue
Block a user