|
@@ -112,6 +112,7 @@ import com.nextcloud.talk.presenters.MentionAutocompletePresenter
|
|
import com.nextcloud.talk.ui.dialog.AttachmentDialog
|
|
import com.nextcloud.talk.ui.dialog.AttachmentDialog
|
|
import com.nextcloud.talk.utils.ApiUtils
|
|
import com.nextcloud.talk.utils.ApiUtils
|
|
import com.nextcloud.talk.utils.ConductorRemapping
|
|
import com.nextcloud.talk.utils.ConductorRemapping
|
|
|
|
+import com.nextcloud.talk.utils.ConductorRemapping.remapChatController
|
|
import com.nextcloud.talk.utils.DateUtils
|
|
import com.nextcloud.talk.utils.DateUtils
|
|
import com.nextcloud.talk.utils.DisplayUtils
|
|
import com.nextcloud.talk.utils.DisplayUtils
|
|
import com.nextcloud.talk.utils.KeyboardUtils
|
|
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.NotificationUtils
|
|
import com.nextcloud.talk.utils.UriUtils
|
|
import com.nextcloud.talk.utils.UriUtils
|
|
import com.nextcloud.talk.utils.bundle.BundleKeys
|
|
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.database.user.UserUtils
|
|
import com.nextcloud.talk.utils.preferences.AppPreferences
|
|
import com.nextcloud.talk.utils.preferences.AppPreferences
|
|
import com.nextcloud.talk.utils.singletons.ApplicationWideCurrentRoomHolder
|
|
import com.nextcloud.talk.utils.singletons.ApplicationWideCurrentRoomHolder
|
|
@@ -543,7 +548,7 @@ class ChatController(args: Bundle) :
|
|
if (s.length >= lengthFilter) {
|
|
if (s.length >= lengthFilter) {
|
|
messageInput?.error = String.format(
|
|
messageInput?.error = String.format(
|
|
Objects.requireNonNull<Resources>
|
|
Objects.requireNonNull<Resources>
|
|
- (resources).getString(R.string.nc_limit_hit),
|
|
|
|
|
|
+ (resources).getString(R.string.nc_limit_hit),
|
|
Integer.toString(lengthFilter)
|
|
Integer.toString(lengthFilter)
|
|
)
|
|
)
|
|
} else {
|
|
} else {
|
|
@@ -620,7 +625,7 @@ class ChatController(args: Bundle) :
|
|
}
|
|
}
|
|
|
|
|
|
if (currentConversation != null && currentConversation!!.shouldShowLobby
|
|
if (currentConversation != null && currentConversation!!.shouldShowLobby
|
|
- (conversationUser)
|
|
|
|
|
|
+ (conversationUser)
|
|
) {
|
|
) {
|
|
messageInputView?.visibility = View.GONE
|
|
messageInputView?.visibility = View.GONE
|
|
} else {
|
|
} else {
|
|
@@ -1304,9 +1309,9 @@ class ChatController(args: Bundle) :
|
|
TextUtils.isEmpty(chatMessageList[i + 1].systemMessage) &&
|
|
TextUtils.isEmpty(chatMessageList[i + 1].systemMessage) &&
|
|
chatMessageList[i + 1].actorId == chatMessageList[i].actorId &&
|
|
chatMessageList[i + 1].actorId == chatMessageList[i].actorId &&
|
|
countGroupedMessages < 4 && DateFormatter.isSameDay(
|
|
countGroupedMessages < 4 && DateFormatter.isSameDay(
|
|
- chatMessageList[i].createdAt,
|
|
|
|
- chatMessageList[i + 1].createdAt
|
|
|
|
- )
|
|
|
|
|
|
+ chatMessageList[i].createdAt,
|
|
|
|
+ chatMessageList[i + 1].createdAt
|
|
|
|
+ )
|
|
) {
|
|
) {
|
|
chatMessageList[i].isGrouped = true
|
|
chatMessageList[i].isGrouped = true
|
|
countGroupedMessages++
|
|
countGroupedMessages++
|
|
@@ -1616,6 +1621,66 @@ class ChatController(args: Bundle) :
|
|
}
|
|
}
|
|
true
|
|
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 -> {
|
|
R.id.action_delete_message -> {
|
|
var apiVersion = 1
|
|
var apiVersion = 1
|
|
// FIXME Fix API checking with guests?
|
|
// FIXME Fix API checking with guests?
|
|
@@ -1667,6 +1732,11 @@ class ChatController(args: Bundle) :
|
|
inflate(R.menu.chat_message_menu)
|
|
inflate(R.menu.chat_message_menu)
|
|
menu.findItem(R.id.action_copy_message).isVisible = !(message as ChatMessage).isDeleted
|
|
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_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)
|
|
menu.findItem(R.id.action_delete_message).isVisible = isShowMessageDeletionButton(message)
|
|
if (menu.hasVisibleItems()) {
|
|
if (menu.hasVisibleItems()) {
|
|
show()
|
|
show()
|