mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-20 03:59:35 +01:00
Add editing of conversation name and description
Improvements to be done: MVVM emoji picker horizontal design Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
b43a31a4ca
commit
6152fa50fe
@ -134,6 +134,12 @@ public interface NcApi {
|
|||||||
@Field("roomName") String roomName);
|
@Field("roomName") String roomName);
|
||||||
|
|
||||||
|
|
||||||
|
@FormUrlEncoded
|
||||||
|
@PUT
|
||||||
|
Observable<GenericOverall> setConversationDescription(@Header("Authorization") String authorization,
|
||||||
|
@Url String url,
|
||||||
|
@Field("description") String description);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
QueryMap items are as follows:
|
QueryMap items are as follows:
|
||||||
- "newParticipant" : "user"
|
- "newParticipant" : "user"
|
||||||
|
@ -219,8 +219,6 @@ class ConversationInfoActivity :
|
|||||||
|
|
||||||
override fun onPrepareOptionsMenu(menu: Menu): Boolean {
|
override fun onPrepareOptionsMenu(menu: Menu): Boolean {
|
||||||
super.onPrepareOptionsMenu(menu)
|
super.onPrepareOptionsMenu(menu)
|
||||||
// menu.findItem(R.id.edit).isVisible = editableFields.size > 0
|
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,14 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* Nextcloud Talk application
|
* Nextcloud Talk application
|
||||||
*
|
*
|
||||||
* @author Mario Danic
|
|
||||||
* @author Andy Scherzinger
|
|
||||||
* @author Tim Krüger
|
|
||||||
* @author Marcel Hibbe
|
* @author Marcel Hibbe
|
||||||
* Copyright (C) 2022-2023 Marcel Hibbe (dev@mhibbe.de)
|
* Copyright (C) 2023 Marcel Hibbe (dev@mhibbe.de)
|
||||||
* Copyright (C) 2021-2022 Tim Krüger <t@timkrueger.me>
|
|
||||||
* Copyright (C) 2021 Andy Scherzinger (info@andy-scherzinger.de)
|
|
||||||
* Copyright (C) 2017-2018 Mario Danic <mario@lovelyhq.com>
|
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -33,6 +27,7 @@ import android.os.Bundle
|
|||||||
import android.text.TextUtils
|
import android.text.TextUtils
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
|
import android.view.MenuItem
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.core.net.toFile
|
import androidx.core.net.toFile
|
||||||
import androidx.core.view.ViewCompat
|
import androidx.core.view.ViewCompat
|
||||||
@ -51,11 +46,11 @@ import com.nextcloud.talk.models.json.conversations.Conversation
|
|||||||
import com.nextcloud.talk.models.json.generic.GenericOverall
|
import com.nextcloud.talk.models.json.generic.GenericOverall
|
||||||
import com.nextcloud.talk.repositories.conversations.ConversationsRepository
|
import com.nextcloud.talk.repositories.conversations.ConversationsRepository
|
||||||
import com.nextcloud.talk.utils.ApiUtils
|
import com.nextcloud.talk.utils.ApiUtils
|
||||||
import com.nextcloud.talk.utils.DateUtils
|
|
||||||
import com.nextcloud.talk.utils.DisplayUtils
|
import com.nextcloud.talk.utils.DisplayUtils
|
||||||
import com.nextcloud.talk.utils.Mimetype
|
import com.nextcloud.talk.utils.Mimetype
|
||||||
import com.nextcloud.talk.utils.PickImage
|
import com.nextcloud.talk.utils.PickImage
|
||||||
import com.nextcloud.talk.utils.bundle.BundleKeys
|
import com.nextcloud.talk.utils.bundle.BundleKeys
|
||||||
|
import com.nextcloud.talk.utils.database.user.CapabilitiesUtilNew
|
||||||
import io.reactivex.Observer
|
import io.reactivex.Observer
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||||
import io.reactivex.disposables.Disposable
|
import io.reactivex.disposables.Disposable
|
||||||
@ -79,18 +74,12 @@ class ConversationInfoEditActivity :
|
|||||||
@Inject
|
@Inject
|
||||||
lateinit var conversationsRepository: ConversationsRepository
|
lateinit var conversationsRepository: ConversationsRepository
|
||||||
|
|
||||||
@Inject
|
|
||||||
lateinit var dateUtils: DateUtils
|
|
||||||
|
|
||||||
private lateinit var conversationToken: String
|
private lateinit var conversationToken: String
|
||||||
private lateinit var conversationUser: User
|
private lateinit var conversationUser: User
|
||||||
private lateinit var credentials: String
|
private lateinit var credentials: String
|
||||||
|
|
||||||
private var conversation: Conversation? = null
|
private var conversation: Conversation? = null
|
||||||
|
|
||||||
private lateinit var optionsMenu: Menu
|
|
||||||
private var edit = false
|
|
||||||
|
|
||||||
private lateinit var pickImage: PickImage
|
private lateinit var pickImage: PickImage
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
@ -111,6 +100,9 @@ class ConversationInfoEditActivity :
|
|||||||
conversation = Parcels.unwrap<Conversation>(extras.getParcelable(BundleKeys.KEY_ACTIVE_CONVERSATION))
|
conversation = Parcels.unwrap<Conversation>(extras.getParcelable(BundleKeys.KEY_ACTIVE_CONVERSATION))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
viewThemeUtils.material.colorTextInputLayout(binding.conversationNameInputLayout)
|
||||||
|
viewThemeUtils.material.colorTextInputLayout(binding.conversationDescriptionInputLayout)
|
||||||
|
|
||||||
credentials = ApiUtils.getCredentials(conversationUser.username, conversationUser.token)
|
credentials = ApiUtils.getCredentials(conversationUser.username, conversationUser.token)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,10 +111,14 @@ class ConversationInfoEditActivity :
|
|||||||
|
|
||||||
loadConversationAvatar()
|
loadConversationAvatar()
|
||||||
|
|
||||||
binding.displayNameText.text = conversation!!.displayName
|
binding.conversationName.setText(conversation!!.displayName)
|
||||||
|
|
||||||
if (conversation!!.description != null && conversation!!.description!!.isNotEmpty()) {
|
if (conversation!!.description != null && conversation!!.description!!.isNotEmpty()) {
|
||||||
binding.descriptionText.text = conversation!!.description
|
binding.conversationDescription.setText(conversation!!.description)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!CapabilitiesUtilNew.isConversationDescriptionEndpointAvailable(conversationUser)) {
|
||||||
|
binding.conversationDescription.isEnabled = false
|
||||||
}
|
}
|
||||||
|
|
||||||
setupAvatarOptions()
|
setupAvatarOptions()
|
||||||
@ -157,47 +153,105 @@ class ConversationInfoEditActivity :
|
|||||||
viewThemeUtils.material.themeToolbar(binding.conversationInfoEditToolbar)
|
viewThemeUtils.material.themeToolbar(binding.conversationInfoEditToolbar)
|
||||||
}
|
}
|
||||||
|
|
||||||
// override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||||
// super.onCreateOptionsMenu(menu)
|
super.onCreateOptionsMenu(menu)
|
||||||
//
|
menuInflater.inflate(R.menu.menu_conversation_info_edit, menu)
|
||||||
// menuInflater.inflate(R.menu.menu_conversation_info, menu)
|
return true
|
||||||
// optionsMenu = menu
|
}
|
||||||
// return true
|
|
||||||
// }
|
override fun onPrepareOptionsMenu(menu: Menu): Boolean {
|
||||||
//
|
super.onPrepareOptionsMenu(menu)
|
||||||
// override fun onPrepareOptionsMenu(menu: Menu): Boolean {
|
return true
|
||||||
// super.onPrepareOptionsMenu(menu)
|
}
|
||||||
// // menu.findItem(R.id.edit).isVisible = editableFields.size > 0
|
|
||||||
// setEditMode(true)
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
// return true
|
if (item.itemId == R.id.save) {
|
||||||
// }
|
saveConversationNameAndDescription()
|
||||||
//
|
}
|
||||||
// override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
return true
|
||||||
// if (item.itemId == R.id.edit) {
|
}
|
||||||
// toggleEditMode()
|
|
||||||
// }
|
private fun saveConversationNameAndDescription() {
|
||||||
// return true
|
val apiVersion =
|
||||||
// }
|
ApiUtils.getConversationApiVersion(conversationUser, intArrayOf(ApiUtils.APIv4, ApiUtils.APIv1))
|
||||||
//
|
|
||||||
//
|
ncApi.renameRoom(
|
||||||
// private fun toggleEditMode() {
|
credentials,
|
||||||
// edit = !edit
|
ApiUtils.getUrlForRoom(
|
||||||
// if (edit) {
|
apiVersion,
|
||||||
// setEditMode(true)
|
conversationUser.baseUrl,
|
||||||
// } else {
|
conversation!!.token
|
||||||
// setEditMode(false)
|
),
|
||||||
// }
|
binding.conversationName.text.toString()
|
||||||
// }
|
)
|
||||||
//
|
.subscribeOn(Schedulers.io())
|
||||||
// private fun setEditMode(editing: Boolean) {
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
// if (editing) {
|
.retry(1)
|
||||||
// optionsMenu.findItem(R.id.edit).setTitle(R.string.save)
|
.subscribe(object : Observer<GenericOverall> {
|
||||||
// edit = true
|
override fun onSubscribe(d: Disposable) {
|
||||||
// } else {
|
// unused atm
|
||||||
// optionsMenu.findItem(R.id.edit).setTitle(R.string.edit)
|
}
|
||||||
// edit = false
|
|
||||||
// }
|
override fun onNext(genericOverall: GenericOverall) {
|
||||||
// }
|
if (CapabilitiesUtilNew.isConversationDescriptionEndpointAvailable(conversationUser)) {
|
||||||
|
saveConversationDescription()
|
||||||
|
} else {
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onError(e: Throwable) {
|
||||||
|
Toast.makeText(
|
||||||
|
applicationContext,
|
||||||
|
context.getString(R.string.default_error_msg),
|
||||||
|
Toast.LENGTH_LONG
|
||||||
|
).show()
|
||||||
|
Log.e(TAG, "Error while saving conversation name", e)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onComplete() {
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fun saveConversationDescription() {
|
||||||
|
val apiVersion =
|
||||||
|
ApiUtils.getConversationApiVersion(conversationUser, intArrayOf(ApiUtils.APIv4, ApiUtils.APIv1))
|
||||||
|
|
||||||
|
ncApi.setConversationDescription(
|
||||||
|
credentials,
|
||||||
|
ApiUtils.getUrlForConversationDescription(
|
||||||
|
apiVersion,
|
||||||
|
conversationUser.baseUrl,
|
||||||
|
conversation!!.token
|
||||||
|
),
|
||||||
|
binding.conversationDescription.text.toString()
|
||||||
|
)
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.retry(1)
|
||||||
|
.subscribe(object : Observer<GenericOverall> {
|
||||||
|
override fun onSubscribe(d: Disposable) {
|
||||||
|
// unused atm
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onNext(genericOverall: GenericOverall) {
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onError(e: Throwable) {
|
||||||
|
Toast.makeText(
|
||||||
|
applicationContext,
|
||||||
|
context.getString(R.string.default_error_msg),
|
||||||
|
Toast.LENGTH_LONG
|
||||||
|
).show()
|
||||||
|
Log.e(TAG, "Error while saving conversation description", e)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onComplete() {
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||||
super.onActivityResult(requestCode, resultCode, data)
|
super.onActivityResult(requestCode, resultCode, data)
|
||||||
@ -322,6 +376,6 @@ class ConversationInfoEditActivity :
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val TAG = "ConversationEditInfo"
|
private val TAG = ConversationInfoEditActivity::class.simpleName
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -506,4 +506,8 @@ public class ApiUtils {
|
|||||||
public static String getUrlForRequestAssistance(int version, String baseUrl, String token) {
|
public static String getUrlForRequestAssistance(int version, String baseUrl, String token) {
|
||||||
return getUrlForApi(version, baseUrl) + "/breakout-rooms/" + token + "/request-assistance";
|
return getUrlForApi(version, baseUrl) + "/breakout-rooms/" + token + "/request-assistance";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getUrlForConversationDescription(int version, String baseUrl, String token) {
|
||||||
|
return getUrlForRoom(version, baseUrl, token) + "/description";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -148,6 +148,10 @@ object CapabilitiesUtilNew {
|
|||||||
return user.capabilities?.spreedCapability?.features?.contains("avatar") == true
|
return user.capabilities?.spreedCapability?.features?.contains("avatar") == true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun isConversationDescriptionEndpointAvailable(user: User): Boolean {
|
||||||
|
return user.capabilities?.spreedCapability?.features?.contains("room-description") == true
|
||||||
|
}
|
||||||
|
|
||||||
fun canEditScopes(user: User): Boolean {
|
fun canEditScopes(user: User): Boolean {
|
||||||
return user.capabilities?.provisioningCapability?.accountPropertyScopesVersion != null &&
|
return user.capabilities?.provisioningCapability?.accountPropertyScopesVersion != null &&
|
||||||
user.capabilities!!.provisioningCapability!!.accountPropertyScopesVersion!! > 1
|
user.capabilities!!.provisioningCapability!!.accountPropertyScopesVersion!! > 1
|
||||||
|
@ -1,14 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?><!--
|
<?xml version="1.0" encoding="utf-8"?><!--
|
||||||
~ Nextcloud Talk application
|
~ Nextcloud Talk application
|
||||||
~
|
~
|
||||||
~ @author Mario Danic
|
|
||||||
~ @author Andy Scherzinger
|
|
||||||
~ @author Marcel Hibbe
|
~ @author Marcel Hibbe
|
||||||
~ @author Tim Krüger
|
~ Copyright (C) 2023 Marcel Hibbe <dev@mhibbe.de>
|
||||||
~ Copyright (C) 2022 Tim Krüger <t@timkrueger.me>
|
|
||||||
~ Copyright (C) 2022-2023 Marcel Hibbe <dev@mhibbe.de>
|
|
||||||
~ Copyright (C) 2021 Andy Scherzinger <info@andy-scherzinger.de>
|
|
||||||
~ Copyright (C) 2017-2018 Mario Danic <mario@lovelyhq.com>
|
|
||||||
~
|
~
|
||||||
~ This program is free software: you can redistribute it and/or modify
|
~ This program is free software: you can redistribute it and/or modify
|
||||||
~ it under the terms of the GNU General Public License as published by
|
~ it under the terms of the GNU General Public License as published by
|
||||||
@ -122,23 +116,54 @@
|
|||||||
app:srcCompat="@drawable/trashbin" />
|
app:srcCompat="@drawable/trashbin" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<androidx.emoji2.widget.EmojiTextView
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
android:id="@+id/display_name_text"
|
android:id="@+id/conversation_name_input_layout"
|
||||||
android:layout_width="wrap_content"
|
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
|
||||||
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center"
|
|
||||||
android:layout_marginTop="@dimen/margin_between_elements"
|
|
||||||
tools:text="Jane Doe" />
|
|
||||||
|
|
||||||
<androidx.emoji2.widget.EmojiTextView
|
|
||||||
android:id="@+id/description_text"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:layout_margin="@dimen/standard_margin"
|
android:layout_margin="@dimen/standard_margin"
|
||||||
android:layout_marginTop="@dimen/margin_between_elements"
|
android:minHeight="@dimen/min_size_clickable_area"
|
||||||
android:autoLink="web"
|
app:boxStrokeColor="@color/colorPrimary"
|
||||||
tools:text="Hello world!" />
|
app:errorTextAppearance="@style/ErrorAppearance"
|
||||||
|
app:hintTextColor="@color/colorPrimary"
|
||||||
|
android:hint="@string/nc_call_name">
|
||||||
|
|
||||||
|
<com.nextcloud.talk.utils.EmojiTextInputEditText
|
||||||
|
android:id="@+id/conversation_name"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:imeOptions="actionNext"
|
||||||
|
android:inputType="text"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:maxLength="255"
|
||||||
|
android:textAlignment="viewStart"
|
||||||
|
tools:text="Our conversation name" />
|
||||||
|
|
||||||
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
|
android:id="@+id/conversation_description_input_layout"
|
||||||
|
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="@dimen/standard_margin"
|
||||||
|
android:minHeight="@dimen/min_size_clickable_area"
|
||||||
|
app:boxStrokeColor="@color/colorPrimary"
|
||||||
|
app:errorTextAppearance="@style/ErrorAppearance"
|
||||||
|
app:hintTextColor="@color/colorPrimary"
|
||||||
|
android:hint="@string/nc_conversation_description">
|
||||||
|
|
||||||
|
<com.nextcloud.talk.utils.EmojiTextInputEditText
|
||||||
|
android:id="@+id/conversation_description"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:imeOptions="actionNext"
|
||||||
|
android:inputType="text|textMultiLine"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:textAlignment="viewStart"
|
||||||
|
tools:text="Our conversation description" />
|
||||||
|
|
||||||
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
28
app/src/main/res/menu/menu_conversation_info_edit.xml
Normal file
28
app/src/main/res/menu/menu_conversation_info_edit.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/save"
|
||||||
|
android:title="@string/save"
|
||||||
|
app:showAsAction="ifRoom" />
|
||||||
|
</menu>
|
@ -637,6 +637,7 @@ How to translate with transifex:
|
|||||||
<string name="set_avatar_from_camera">Set avatar from camera</string>
|
<string name="set_avatar_from_camera">Set avatar from camera</string>
|
||||||
|
|
||||||
<string name="nc_conversation_settings">Conversation settings</string>
|
<string name="nc_conversation_settings">Conversation settings</string>
|
||||||
|
<string name="nc_conversation_description">Conversation description</string>
|
||||||
|
|
||||||
<!-- Expiring messages -->
|
<!-- Expiring messages -->
|
||||||
<string name="nc_expire_messages">Expire chat messages</string>
|
<string name="nc_expire_messages">Expire chat messages</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user