mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-20 03:59:35 +01:00
Merge pull request #1246 from nextcloud/feature/noid/reply-privately
↖️ Reply privately
This commit is contained in:
commit
e40e3d6c07
@ -112,6 +112,7 @@ import com.nextcloud.talk.presenters.MentionAutocompletePresenter
|
||||
import com.nextcloud.talk.ui.dialog.AttachmentDialog
|
||||
import com.nextcloud.talk.utils.ApiUtils
|
||||
import com.nextcloud.talk.utils.ConductorRemapping
|
||||
import com.nextcloud.talk.utils.ConductorRemapping.remapChatController
|
||||
import com.nextcloud.talk.utils.DateUtils
|
||||
import com.nextcloud.talk.utils.DisplayUtils
|
||||
import com.nextcloud.talk.utils.KeyboardUtils
|
||||
@ -119,6 +120,10 @@ import com.nextcloud.talk.utils.MagicCharPolicy
|
||||
import com.nextcloud.talk.utils.NotificationUtils
|
||||
import com.nextcloud.talk.utils.UriUtils
|
||||
import com.nextcloud.talk.utils.bundle.BundleKeys
|
||||
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ACTIVE_CONVERSATION
|
||||
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM_ID
|
||||
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM_TOKEN
|
||||
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_USER_ENTITY
|
||||
import com.nextcloud.talk.utils.database.user.UserUtils
|
||||
import com.nextcloud.talk.utils.preferences.AppPreferences
|
||||
import com.nextcloud.talk.utils.singletons.ApplicationWideCurrentRoomHolder
|
||||
@ -542,8 +547,7 @@ class ChatController(args: Bundle) :
|
||||
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
|
||||
if (s.length >= lengthFilter) {
|
||||
messageInput?.error = String.format(
|
||||
Objects.requireNonNull<Resources>
|
||||
(resources).getString(R.string.nc_limit_hit),
|
||||
Objects.requireNonNull<Resources> (resources).getString(R.string.nc_limit_hit),
|
||||
Integer.toString(lengthFilter)
|
||||
)
|
||||
} else {
|
||||
@ -619,8 +623,7 @@ class ChatController(args: Bundle) :
|
||||
conversationVideoMenuItem?.icon?.alpha = 255
|
||||
}
|
||||
|
||||
if (currentConversation != null && currentConversation!!.shouldShowLobby
|
||||
(conversationUser)
|
||||
if (currentConversation != null && currentConversation!!.shouldShowLobby(conversationUser)
|
||||
) {
|
||||
messageInputView?.visibility = View.GONE
|
||||
} else {
|
||||
@ -1557,7 +1560,7 @@ class ChatController(args: Bundle) :
|
||||
PopupMenu(
|
||||
ContextThemeWrapper(view?.context, R.style.appActionBarPopupMenu),
|
||||
view,
|
||||
if (message?.user?.id == conversationUser?.userId) Gravity.END else Gravity.START
|
||||
if (message?.user?.id == currentConversation?.actorType + "/" + currentConversation?.actorId) Gravity.END else Gravity.START
|
||||
).apply {
|
||||
setOnMenuItemClickListener { item ->
|
||||
when (item?.itemId) {
|
||||
@ -1616,6 +1619,66 @@ class ChatController(args: Bundle) :
|
||||
}
|
||||
true
|
||||
}
|
||||
R.id.action_reply_privately -> {
|
||||
val apiVersion = ApiUtils.getConversationApiVersion(conversationUser, intArrayOf(ApiUtils.APIv4, 1))
|
||||
val retrofitBucket = ApiUtils.getRetrofitBucketForCreateRoom(
|
||||
apiVersion,
|
||||
conversationUser?.baseUrl,
|
||||
"1",
|
||||
message?.user?.id?.substring(6),
|
||||
null
|
||||
)
|
||||
ncApi!!.createRoom(
|
||||
credentials,
|
||||
retrofitBucket.getUrl(), retrofitBucket.getQueryMap()
|
||||
)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : Observer<RoomOverall> {
|
||||
override fun onSubscribe(d: Disposable) {}
|
||||
override fun onNext(roomOverall: RoomOverall) {
|
||||
val bundle = Bundle()
|
||||
bundle.putParcelable(KEY_USER_ENTITY, conversationUser)
|
||||
bundle.putString(KEY_ROOM_TOKEN, roomOverall.getOcs().getData().getToken())
|
||||
bundle.putString(KEY_ROOM_ID, roomOverall.getOcs().getData().getRoomId())
|
||||
|
||||
// FIXME once APIv2 or later is used only, the createRoom already returns all the data
|
||||
ncApi!!.getRoom(
|
||||
credentials,
|
||||
ApiUtils.getUrlForRoom(
|
||||
apiVersion, conversationUser?.baseUrl,
|
||||
roomOverall.getOcs().getData().getToken()
|
||||
)
|
||||
)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : Observer<RoomOverall> {
|
||||
override fun onSubscribe(d: Disposable) {}
|
||||
override fun onNext(roomOverall: RoomOverall) {
|
||||
bundle.putParcelable(
|
||||
KEY_ACTIVE_CONVERSATION,
|
||||
Parcels.wrap(roomOverall.getOcs().getData())
|
||||
)
|
||||
remapChatController(
|
||||
router, conversationUser!!.id,
|
||||
roomOverall.getOcs().getData().getToken(), bundle, true
|
||||
)
|
||||
}
|
||||
|
||||
override fun onError(e: Throwable) {
|
||||
Log.e(TAG, e.message, e)
|
||||
}
|
||||
override fun onComplete() {}
|
||||
})
|
||||
}
|
||||
|
||||
override fun onError(e: Throwable) {
|
||||
Log.e(TAG, e.message, e)
|
||||
}
|
||||
override fun onComplete() {}
|
||||
})
|
||||
true
|
||||
}
|
||||
R.id.action_delete_message -> {
|
||||
var apiVersion = 1
|
||||
// FIXME Fix API checking with guests?
|
||||
@ -1667,8 +1730,16 @@ class ChatController(args: Bundle) :
|
||||
inflate(R.menu.chat_message_menu)
|
||||
menu.findItem(R.id.action_copy_message).isVisible = !(message as ChatMessage).isDeleted
|
||||
menu.findItem(R.id.action_reply_to_message).isVisible = (message as ChatMessage).replyable
|
||||
menu.findItem(R.id.action_reply_privately).isVisible = (message as ChatMessage).replyable &&
|
||||
conversationUser?.userId?.isNotEmpty() == true && conversationUser.userId != "?" &&
|
||||
(message as ChatMessage).user.id.startsWith("users/") &&
|
||||
(message as ChatMessage).user.id.substring(6) != currentConversation?.actorId &&
|
||||
currentConversation?.type != Conversation.ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL
|
||||
menu.findItem(R.id.action_delete_message).isVisible = isShowMessageDeletionButton(message)
|
||||
if (menu.hasVisibleItems()) {
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q) {
|
||||
setForceShowIcon(true)
|
||||
}
|
||||
show()
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
<vector android:autoMirrored="true" android:height="24dp"
|
||||
android:tint="#FFFFFF" android:viewportHeight="24.0"
|
||||
android:tint="@color/medium_emphasis_text" android:viewportHeight="24.0"
|
||||
android:viewportWidth="24.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#FF000000" android:pathData="M16,1L4,1c-1.1,0 -2,0.9 -2,2v14h2L4,3h12L16,1zM19,5L8,5c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h11c1.1,0 2,-0.9 2,-2L21,7c0,-1.1 -0.9,-2 -2,-2zM19,21L8,21L8,7h11v14z"/>
|
||||
</vector>
|
@ -21,5 +21,5 @@
|
||||
<vector android:autoMirrored="true" android:height="24dp"
|
||||
android:viewportHeight="24.0" android:viewportWidth="24.0"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#FFFFFF" android:pathData="M6,19c0,1.1 0.9,2 2,2h8c1.1,0 2,-0.9 2,-2V7H6v12zM19,4h-3.5l-1,-1h-5l-1,1H5v2h14V4z"/>
|
||||
<path android:fillColor="@color/medium_emphasis_text" android:pathData="M6,19c0,1.1 0.9,2 2,2h8c1.1,0 2,-0.9 2,-2V7H6v12zM19,4h-3.5l-1,-1h-5l-1,1H5v2h14V4z"/>
|
||||
</vector>
|
@ -1,5 +1,5 @@
|
||||
<vector android:autoMirrored="true" android:height="24dp"
|
||||
android:tint="#FFFFFF" android:viewportHeight="24.0"
|
||||
android:tint="@color/medium_emphasis_text" android:viewportHeight="24.0"
|
||||
android:viewportWidth="24.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#FF000000" android:pathData="M10,9V5l-7,7 7,7v-4.1c5,0 8.5,1.6 11,5.1 -1,-5 -4,-10 -11,-11z"/>
|
||||
</vector>
|
@ -4,19 +4,25 @@
|
||||
|
||||
<item
|
||||
android:id="@+id/action_copy_message"
|
||||
android:icon="@drawable/ic_content_copy_white_24dp"
|
||||
android:icon="@drawable/ic_content_copy"
|
||||
android:title="@string/nc_copy_message"
|
||||
app:showAsAction="always" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_reply_to_message"
|
||||
android:icon="@drawable/ic_reply_white_24dp"
|
||||
android:icon="@drawable/ic_reply"
|
||||
android:title="@string/nc_reply"
|
||||
app:showAsAction="always" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_reply_privately"
|
||||
android:icon="@drawable/ic_reply"
|
||||
android:title="@string/nc_reply_privately"
|
||||
app:showAsAction="always" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_delete_message"
|
||||
android:icon="@drawable/ic_delete_white_24dp"
|
||||
android:icon="@drawable/ic_delete"
|
||||
android:title="@string/nc_delete_message"
|
||||
app:showAsAction="always" />
|
||||
</menu>
|
@ -355,6 +355,7 @@
|
||||
<string name="nc_99_plus">99+</string>
|
||||
<string name="nc_copy_message">Copy</string>
|
||||
<string name="nc_reply">Reply</string>
|
||||
<string name="nc_reply_privately">Reply privately</string>
|
||||
<string name="nc_delete_message">Delete</string>
|
||||
<string name="nc_delete_message_leaked_to_matterbridge">Message deleted successfully, but it might have been leaked to other services</string>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user