From 85fe560fc1f45088e143dc12ae903dbee49fee9b Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Wed, 26 May 2021 18:32:44 +0200 Subject: [PATCH] reformat code for 120 line length Signed-off-by: Andy Scherzinger --- .../talk/controllers/ChatController.kt | 71 ++++++++++++------- 1 file changed, 45 insertions(+), 26 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt b/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt index 19d8b1444..27ba78bbf 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt +++ b/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt @@ -3,8 +3,10 @@ * * @author Mario Danic * @author Marcel Hibbe - * Copyright (C) 2017-2019 Mario Danic + * @author Andy Scherzinger + * Copyright (C) 2021 Andy Scherzinger * Copyright (C) 2021 Marcel Hibbe + * Copyright (C) 2017-2019 Mario Danic * * 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 @@ -708,7 +710,10 @@ class ChatController(args: Bundle) : require(files.isNotEmpty()) val data: Data = Data.Builder() .putStringArray(UploadAndShareFilesWorker.DEVICE_SOURCEFILES, files.toTypedArray()) - .putString(UploadAndShareFilesWorker.NC_TARGETPATH, CapabilitiesUtil.getAttachmentFolder(conversationUser)) + .putString( + UploadAndShareFilesWorker.NC_TARGETPATH, + CapabilitiesUtil.getAttachmentFolder(conversationUser) + ) .putString(UploadAndShareFilesWorker.ROOM_TOKEN, roomToken) .build() val uploadWorker: OneTimeWorkRequest = OneTimeWorkRequest.Builder(UploadAndShareFilesWorker::class.java) @@ -1073,7 +1078,11 @@ class ChatController(args: Bundle) : val replyMessageId: Int? = view?.findViewById(R.id.quotedChatMessageView)?.tag as Int? sendMessage( editable, - if (view?.findViewById(R.id.quotedChatMessageView)?.visibility == View.VISIBLE) replyMessageId else null + if ( + view + ?.findViewById(R.id.quotedChatMessageView) + ?.visibility == View.VISIBLE + ) replyMessageId else null ) cancelReply() } @@ -1546,7 +1555,9 @@ class ChatController(args: Bundle) : PopupMenu( ContextThemeWrapper(view?.context, R.style.appActionBarPopupMenu), view, - if (message?.user?.id == currentConversation?.actorType + "/" + currentConversation?.actorId) Gravity.END else Gravity.START + if ( + message?.user?.id == currentConversation?.actorType + "/" + currentConversation?.actorId + ) Gravity.END else Gravity.START ).apply { setOnMenuItemClickListener { item -> when (item?.itemId) { @@ -1561,42 +1572,48 @@ class ChatController(args: Bundle) : R.id.action_reply_to_message -> { val chatMessage = message as ChatMessage? chatMessage?.let { - binding?.messageInputView?.findViewById(R.id.attachmentButton)?.visibility = View.GONE - binding?.messageInputView?.findViewById(R.id.attachmentButtonSpace)?.visibility = View.GONE + binding?.messageInputView?.findViewById(R.id.attachmentButton)?.visibility = + View.GONE + binding?.messageInputView?.findViewById(R.id.attachmentButtonSpace)?.visibility = + View.GONE binding?.messageInputView?.findViewById(R.id.cancelReplyButton)?.visibility = View.VISIBLE - binding?.messageInputView?.findViewById(R.id.quotedMessage)?.maxLines = 2 - binding?.messageInputView?.findViewById(R.id.quotedMessage)?.ellipsize = - TextUtils.TruncateAt.END - binding?.messageInputView?.findViewById(R.id.quotedMessage)?.text = it.text + + val quotedMessage = binding + ?.messageInputView + ?.findViewById(R.id.quotedMessage) + + quotedMessage?.maxLines = 2 + quotedMessage?.ellipsize = TextUtils.TruncateAt.END + quotedMessage?.text = it.text binding?.messageInputView?.findViewById(R.id.quotedMessageAuthor)?.text = it.actorDisplayName ?: context!!.getText(R.string.nc_nick_guest) conversationUser?.let { currentUser -> - + val quotedMessageImage = binding + ?.messageInputView + ?.findViewById(R.id.quotedMessageImage) chatMessage.imageUrl?.let { previewImageUrl -> - binding?.messageInputView?.findViewById(R.id.quotedMessageImage)?.visibility = - View.VISIBLE + quotedMessageImage?.visibility = View.VISIBLE val px = TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, 96f, resources?.displayMetrics ) - binding?.messageInputView?.findViewById(R.id.quotedMessageImage)?.maxHeight = - px.toInt() - val layoutParams = - binding?.messageInputView?.findViewById(R.id.quotedMessageImage)?.layoutParams as FlexboxLayout.LayoutParams + + quotedMessageImage?.maxHeight = px.toInt() + val layoutParams = quotedMessageImage?.layoutParams as FlexboxLayout.LayoutParams layoutParams.flexGrow = 0f - binding?.messageInputView?.findViewById(R.id.quotedMessageImage)?.layoutParams = - layoutParams - binding?.messageInputView?.findViewById(R.id.quotedMessageImage) - ?.load(previewImageUrl) { - addHeader("Authorization", credentials!!) - } + quotedMessageImage?.layoutParams = layoutParams + quotedMessageImage?.load(previewImageUrl) { + addHeader("Authorization", credentials!!) + } } ?: run { - binding?.messageInputView?.findViewById(R.id.quotedMessageImage)?.visibility = - View.GONE + binding + ?.messageInputView + ?.findViewById(R.id.quotedMessageImage) + ?.visibility = View.GONE } } @@ -1760,7 +1777,9 @@ class ChatController(args: Bundle) : if (message.hasFileAttachment()) return false val sixHoursInMillis = 6 * 3600 * 1000 - val isOlderThanSixHours = message.createdAt?.before(Date(System.currentTimeMillis() - sixHoursInMillis)) == true + val isOlderThanSixHours = message + .createdAt + ?.before(Date(System.currentTimeMillis() - sixHoursInMillis)) == true if (isOlderThanSixHours) return false val isUserAllowedByPrivileges = if (message.actorId == conversationUser.userId) {