Skip to content

Commit 14e19bb

Browse files
committed
WIP - linter
Signed-off-by: rapterjet2004 <juliuslinus1@gmail.com>
1 parent 02d79e9 commit 14e19bb

3 files changed

Lines changed: 46 additions & 22 deletions

File tree

app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -683,10 +683,10 @@ class ChatActivity :
683683
}
684684
}
685685
}
686-
@Composable
687-
private fun LazyListState.visibleItemsWithThreshold(): List<String> {
688686

689-
return remember(this) {
687+
@Composable
688+
private fun LazyListState.visibleItemsWithThreshold(): List<String> =
689+
remember(this) {
690690
derivedStateOf {
691691
val visibleItemsInfo = layoutInfo.visibleItemsInfo
692692
if (layoutInfo.totalItemsCount == 0) {
@@ -710,8 +710,6 @@ class ChatActivity :
710710

711711
result
712712
}
713-
}
714-
715713

716714
private fun onLoadQuotedMessage(messageId: Int) {
717715
// Loading and displaying surrounding messages for quotes is pending; replace flow from latestChatBlock with
@@ -781,10 +779,18 @@ class ChatActivity :
781779
chatViewModel.setVoiceMessageSpeed(messageId, nextSpeed)
782780
}
783781

784-
fun downloadAndOpenFile(messageId: Int, openWhenDownloadState: MutableState<Boolean>, downloadState: MutableState<List<String>>) {
782+
fun downloadAndOpenFile(
783+
messageId: Int,
784+
openWhenDownloadState: MutableState<Boolean>,
785+
downloadState: MutableState<List<String>>
786+
) {
785787
lifecycleScope.launch {
786788
val chatMessage = chatViewModel.getMessageById(messageId.toLong()).first()
787-
FileViewerUtils(this@ChatActivity, conversationUser).openFile(chatMessage, openWhenDownloadState, downloadState)
789+
FileViewerUtils(this@ChatActivity, conversationUser).openFile(
790+
chatMessage,
791+
openWhenDownloadState,
792+
downloadState
793+
)
788794
}
789795
}
790796

app/src/main/java/com/nextcloud/talk/ui/chat/MediaMessage.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ fun MediaMessage(
4949
chatViewDownloadingFileState: List<String>,
5050
onImageClick: (Int) -> Unit
5151
) {
52-
val fileParameters = remember { FileParameters(message.messageParameters as HashMap<String?, HashMap<String?, String?>>?) }
52+
val fileParameters =
53+
remember { FileParameters(message.messageParameters as HashMap<String?, HashMap<String?, String?>>?) }
5354

5455
val captionText = message.message.takeUnless { it == FILE_PLACEHOLDER_MESSAGE }
5556
val hasCaption = captionText != null

app/src/main/java/com/nextcloud/talk/utils/FileViewerUtils.kt

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,11 @@ import java.util.concurrent.ExecutionException
6262
*/
6363
class FileViewerUtils(private val context: Context, private val user: User) {
6464

65-
fun openFile(message: ChatMessage, openWhenDownloadState: MutableState<Boolean>, downloadState:
66-
MutableState<List<String>>) {
65+
fun openFile(
66+
message: ChatMessage,
67+
openWhenDownloadState: MutableState<Boolean>,
68+
downloadState: MutableState<List<String>>
69+
) {
6770
val fileName = message.fileParameters.name
6871
val mimetype = message.fileParameters.mimetype
6972
val link = message.fileParameters.link
@@ -81,7 +84,11 @@ class FileViewerUtils(private val context: Context, private val user: User) {
8184
)
8285
}
8386

84-
fun openFile(fileInfo: FileInfo, openWhenDownloadState: MutableState<Boolean>, downloadState: MutableState<List<String>>? = null) {
87+
fun openFile(
88+
fileInfo: FileInfo,
89+
openWhenDownloadState: MutableState<Boolean>,
90+
downloadState: MutableState<List<String>>? = null
91+
) {
8592
if (isSupportedForInternalViewer(fileInfo.mimetype) ||
8693
canBeHandledByExternalApp(fileInfo.mimetype, fileInfo.fileName)
8794
) {
@@ -111,7 +118,11 @@ class FileViewerUtils(private val context: Context, private val user: User) {
111118
return intent.resolveActivity(context.packageManager) != null
112119
}
113120

114-
private fun openOrDownloadFile(fileInfo: FileInfo, openWhenDownloadState: MutableState<Boolean>, downloadState: MutableState<List<String>>?) {
121+
private fun openOrDownloadFile(
122+
fileInfo: FileInfo,
123+
openWhenDownloadState: MutableState<Boolean>,
124+
downloadState: MutableState<List<String>>?
125+
) {
115126
val file = File(context.cacheDir, fileInfo.fileName)
116127
if (file.exists()) {
117128
openFileByMimetype(fileInfo.fileName, fileInfo.mimetype, fileInfo.link, fileInfo.fileId)
@@ -133,18 +144,17 @@ class FileViewerUtils(private val context: Context, private val user: User) {
133144
VIDEO_MP4,
134145
VIDEO_QUICKTIME,
135146
VIDEO_OGG,
136-
VIDEO_WEBM
137-
-> openMediaView(filename, mimetype)
147+
VIDEO_WEBM -> openMediaView(filename, mimetype)
148+
138149
IMAGE_PNG,
139150
IMAGE_JPEG,
140151
IMAGE_GIF,
141-
IMAGE_HEIC
142-
-> openImageView(filename, mimetype)
152+
IMAGE_HEIC -> openImageView(filename, mimetype)
153+
143154
TEXT_MARKDOWN,
144-
TEXT_PLAIN
145-
-> openTextView(filename, mimetype, link, fileId)
146-
else
147-
-> openFileByExternalApp(filename, mimetype)
155+
TEXT_PLAIN -> openTextView(filename, mimetype, link, fileId)
156+
157+
else -> openFileByExternalApp(filename, mimetype)
148158
}
149159
} else {
150160
Log.e(TAG, "can't open file with unknown mimetype")
@@ -243,12 +253,16 @@ class FileViewerUtils(private val context: Context, private val user: User) {
243253
VIDEO_WEBM,
244254
TEXT_MARKDOWN,
245255
TEXT_PLAIN -> true
256+
246257
else -> false
247258
}
248259

249260
@SuppressLint("LongLogTag")
250-
private fun downloadFileToCache(fileInfo: FileInfo, openWhenDownloadState: MutableState<Boolean>, downloadState:
251-
MutableState<List<String>>?) {
261+
private fun downloadFileToCache(
262+
fileInfo: FileInfo,
263+
openWhenDownloadState: MutableState<Boolean>,
264+
downloadState: MutableState<List<String>>?
265+
) {
252266
downloadState?.value = downloadState.value + fileInfo.fileId
253267

254268
// check if download worker is already running
@@ -331,6 +345,7 @@ class FileViewerUtils(private val context: Context, private val user: User) {
331345
// )
332346
}
333347
}
348+
334349
WorkInfo.State.SUCCEEDED -> {
335350
if (openWhenDownloadState.value) {
336351
openFileByMimetype(fileName, mimetype, link, fileId)
@@ -345,10 +360,12 @@ class FileViewerUtils(private val context: Context, private val user: User) {
345360
// progressUi.messageText?.text = fileName
346361
// progressUi.progressBar?.visibility = View.GONE
347362
}
363+
348364
WorkInfo.State.FAILED -> {
349365
// progressUi.messageText?.text = fileName
350366
// progressUi.progressBar?.visibility = View.GONE
351367
}
368+
352369
else -> {
353370
}
354371
}

0 commit comments

Comments
 (0)