From 8e3234d188275b9477d4694c4fabcec6ff76dbaf Mon Sep 17 00:00:00 2001 From: ganfra Date: Mon, 21 Oct 2019 18:08:42 +0200 Subject: [PATCH] Clean some code --- .gitignore | 2 ++ CHANGES.md | 3 ++- vector/src/main/AndroidManifest.xml | 14 +++++++------- .../riotx/ActiveSessionObservableStore.kt | 17 +++++++++++++++++ .../features/attachments/ContactAttachment.kt | 9 +++++---- .../home/room/detail/RoomDetailFragment.kt | 1 + .../features/share/IncomingShareActivity.kt | 8 ++++---- .../src/main/res/xml/riotx_provider_paths.xml | 5 ----- 8 files changed, 38 insertions(+), 21 deletions(-) diff --git a/.gitignore b/.gitignore index e54a3c380e..76cd170215 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,5 @@ /tmp ktlint +.idea/copyright/New_vector.xml +.idea/copyright/profiles_settings.xml diff --git a/CHANGES.md b/CHANGES.md index 5cac7e8f70..38808bfa28 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -8,7 +8,8 @@ Improvements: - Persist active tab between sessions (#503) - Do not upload file too big for the homeserver (#587) - Handle read markers (#84) - - Attachments: start using system pickers + - Attachments: start using system pickers (#52) + - Attachments: start handling incoming share (#58) Other changes: - Accessibility improvements to read receipts in the room timeline and reactions emoji chooser diff --git a/vector/src/main/AndroidManifest.xml b/vector/src/main/AndroidManifest.xml index 6c0f846997..0c9bac61a1 100644 --- a/vector/src/main/AndroidManifest.xml +++ b/vector/src/main/AndroidManifest.xml @@ -80,18 +80,18 @@ - + - - + + + - - + + + diff --git a/vector/src/main/java/im/vector/riotx/ActiveSessionObservableStore.kt b/vector/src/main/java/im/vector/riotx/ActiveSessionObservableStore.kt index c10a7f700c..fd6a92e820 100644 --- a/vector/src/main/java/im/vector/riotx/ActiveSessionObservableStore.kt +++ b/vector/src/main/java/im/vector/riotx/ActiveSessionObservableStore.kt @@ -1,3 +1,20 @@ +/* + * Copyright 2019 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package im.vector.riotx import arrow.core.Option diff --git a/vector/src/main/java/im/vector/riotx/features/attachments/ContactAttachment.kt b/vector/src/main/java/im/vector/riotx/features/attachments/ContactAttachment.kt index 90340e2ef6..80acefdcf2 100644 --- a/vector/src/main/java/im/vector/riotx/features/attachments/ContactAttachment.kt +++ b/vector/src/main/java/im/vector/riotx/features/attachments/ContactAttachment.kt @@ -28,10 +28,11 @@ data class ContactAttachment( ) { fun toHumanReadable(): String { - val stringBuilder = StringBuilder(displayName) - phones.concatIn(stringBuilder) - emails.concatIn(stringBuilder) - return stringBuilder.toString() + return buildString { + append(displayName) + phones.concatIn(this) + emails.concatIn(this) + } } private fun List.concatIn(stringBuilder: StringBuilder) { diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt index f30ee4d97d..6fa4fdceaf 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt @@ -1126,6 +1126,7 @@ class RoomDetailFragment : } override fun onContactAttachmentReady(contactAttachment: ContactAttachment) { + super.onContactAttachmentReady(contactAttachment) val formattedContact = contactAttachment.toHumanReadable() roomDetailViewModel.process(RoomDetailActions.SendMessage(formattedContact, false)) } diff --git a/vector/src/main/java/im/vector/riotx/features/share/IncomingShareActivity.kt b/vector/src/main/java/im/vector/riotx/features/share/IncomingShareActivity.kt index 3f50ada057..197405aa53 100644 --- a/vector/src/main/java/im/vector/riotx/features/share/IncomingShareActivity.kt +++ b/vector/src/main/java/im/vector/riotx/features/share/IncomingShareActivity.kt @@ -69,10 +69,10 @@ class IncomingShareActivity : isShareManaged = handleTextShare(intent) } if (!isShareManaged) { - cannottManageShare() + cannotManageShare() } } else { - cannottManageShare() + cannotManageShare() } } @@ -83,10 +83,10 @@ class IncomingShareActivity : } override fun onAttachmentsProcessFailed() { - cannottManageShare() + cannotManageShare() } - private fun cannottManageShare() { + private fun cannotManageShare() { Toast.makeText(this, R.string.error_handling_incoming_share, Toast.LENGTH_LONG).show() finish() } diff --git a/vector/src/main/res/xml/riotx_provider_paths.xml b/vector/src/main/res/xml/riotx_provider_paths.xml index a802c0ff97..7d3fcb2203 100644 --- a/vector/src/main/res/xml/riotx_provider_paths.xml +++ b/vector/src/main/res/xml/riotx_provider_paths.xml @@ -3,9 +3,4 @@ - - - \ No newline at end of file