diff --git a/.editorconfig b/.editorconfig index 75fa24ed2e..fbc2f393c5 100644 --- a/.editorconfig +++ b/.editorconfig @@ -38,4 +38,11 @@ indent_size=2 [*.{kt,kts}] # IDE does not follow this Ktlint rule strictly, but the default ordering is pretty good anyway, so let's ditch it -ktlint_disabled_rules=import-ordering +ktlint_code_style = android_studio +insert_final_newline = true +ktlint_function_signature_rule_force_multiline_when_parameter_count_greater_or_equal_than=unset +ktlint_function_signature_body_expression_wrapping=multiline +ktlint_standard_import-ordering = disabled +ktlint_standard_wrapping = enabled +ij_kotlin_allow_trailing_comma = false +ij_kotlin_allow_trailing_comma_on_call_site = false diff --git a/app/build.gradle b/app/build.gradle index ea98bcaa79..562c5bb63d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -129,6 +129,7 @@ android { buildFeatures { viewBinding true + buildConfig = true } lint { diff --git a/app/src/androidTest/java/com/nextcloud/talk/utils/ShareUtilsIT.kt b/app/src/androidTest/java/com/nextcloud/talk/utils/ShareUtilsIT.kt index eeef9ea8da..2011acda64 100644 --- a/app/src/androidTest/java/com/nextcloud/talk/utils/ShareUtilsIT.kt +++ b/app/src/androidTest/java/com/nextcloud/talk/utils/ShareUtilsIT.kt @@ -20,9 +20,12 @@ class ShareUtilsIT { return DateUtils.parseDate( dateStr, Locale.US, HttpUtils.httpDateFormatStr, - "EEE, dd MMM yyyy HH:mm:ss zzz", // RFC 822, updated by RFC 1123 with any TZ - "EEEE, dd-MMM-yy HH:mm:ss zzz", // RFC 850, obsoleted by RFC 1036 with any TZ. - "EEE MMM d HH:mm:ss yyyy", // ANSI C's asctime() format + // RFC 822, updated by RFC 1123 with any TZ + "EEE, dd MMM yyyy HH:mm:ss zzz", + // RFC 850, obsoleted by RFC 1036 with any TZ. + "EEEE, dd-MMM-yy HH:mm:ss zzz", + // ANSI C's asctime() format + "EEE MMM d HH:mm:ss yyyy", // Alternative formats. "EEE, dd-MMM-yyyy HH:mm:ss z", "EEE, dd-MMM-yyyy HH-mm-ss z", @@ -35,7 +38,7 @@ class ShareUtilsIT { "EEE,dd-MMM-yy HH:mm:ss z", "EEE,dd-MMM-yyyy HH:mm:ss z", "EEE, dd-MM-yyyy HH:mm:ss z", - /* RI bug 6641315 claims a cookie of this format was once served by www.yahoo.com */ + // RI bug 6641315 claims a cookie of this format was once served by www.yahoo.com "EEE MMM d yyyy HH:mm:ss z" ) } diff --git a/app/src/main/java/com/nextcloud/talk/activities/BaseActivity.kt b/app/src/main/java/com/nextcloud/talk/activities/BaseActivity.kt index 9d147d8adf..a33027f161 100644 --- a/app/src/main/java/com/nextcloud/talk/activities/BaseActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/activities/BaseActivity.kt @@ -62,7 +62,9 @@ import javax.inject.Inject open class BaseActivity : AppCompatActivity() { enum class AppBarLayoutType { - TOOLBAR, SEARCH_BAR, EMPTY + TOOLBAR, + SEARCH_BAR, + EMPTY } @Inject diff --git a/app/src/main/java/com/nextcloud/talk/activities/CallActivity.kt b/app/src/main/java/com/nextcloud/talk/activities/CallActivity.kt index 8a6c92466d..b850d9fc7b 100644 --- a/app/src/main/java/com/nextcloud/talk/activities/CallActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/activities/CallActivity.kt @@ -1050,10 +1050,7 @@ class CallActivity : CallBaseActivity() { private val isConnectionEstablished: Boolean get() = currentCallStatus === CallStatus.JOINED || currentCallStatus === CallStatus.IN_CONVERSATION - private fun onAudioManagerDevicesChanged( - currentDevice: AudioDevice, - availableDevices: Set - ) { + private fun onAudioManagerDevicesChanged(currentDevice: AudioDevice, availableDevices: Set) { Log.d(TAG, "onAudioManagerDevicesChanged: $availableDevices, currentDevice: $currentDevice") val shouldDisableProximityLock = currentDevice == AudioDevice.WIRED_HEADSET || @@ -1529,10 +1526,7 @@ class CallActivity : CallBaseActivity() { }) } - private fun addIceServers( - signalingSettingsOverall: SignalingSettingsOverall, - apiVersion: Int - ) { + private fun addIceServers(signalingSettingsOverall: SignalingSettingsOverall, apiVersion: Int) { if (signalingSettingsOverall.ocs!!.settings!!.stunServers != null) { val stunServers = signalingSettingsOverall.ocs!!.settings!!.stunServers if (apiVersion == ApiUtils.APIv3) { @@ -3035,11 +3029,7 @@ class CallActivity : CallBaseActivity() { } } - private fun updatePictureInPictureActions( - @DrawableRes iconId: Int, - title: String?, - requestCode: Int - ) { + private fun updatePictureInPictureActions(@DrawableRes iconId: Int, title: String?, requestCode: Int) { if (isGreaterEqualOreo && isPipModePossible) { val actions = ArrayList() val icon = Icon.createWithResource(this, iconId) diff --git a/app/src/main/java/com/nextcloud/talk/activities/CallStatus.kt b/app/src/main/java/com/nextcloud/talk/activities/CallStatus.kt index d717ea02de..268e2ac680 100644 --- a/app/src/main/java/com/nextcloud/talk/activities/CallStatus.kt +++ b/app/src/main/java/com/nextcloud/talk/activities/CallStatus.kt @@ -24,5 +24,12 @@ import kotlinx.parcelize.Parcelize @Parcelize enum class CallStatus : Parcelable { - CONNECTING, CALLING_TIMEOUT, JOINED, IN_CONVERSATION, RECONNECTING, OFFLINE, LEAVING, PUBLISHER_FAILED + CONNECTING, + CALLING_TIMEOUT, + JOINED, + IN_CONVERSATION, + RECONNECTING, + OFFLINE, + LEAVING, + PUBLISHER_FAILED } diff --git a/app/src/main/java/com/nextcloud/talk/adapters/items/ConversationItem.kt b/app/src/main/java/com/nextcloud/talk/adapters/items/ConversationItem.kt index 4906bb7bcf..3dbf39f169 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/items/ConversationItem.kt +++ b/app/src/main/java/com/nextcloud/talk/adapters/items/ConversationItem.kt @@ -203,9 +203,7 @@ class ConversationItem( } } - private fun shouldLoadAvatar( - holder: ConversationItemViewHolder - ): Boolean { + private fun shouldLoadAvatar(holder: ConversationItemViewHolder): Boolean { return when (model.objectType) { Conversation.ObjectType.SHARE_PASSWORD -> { holder.binding.dialogAvatar.setImageDrawable( @@ -237,10 +235,7 @@ class ConversationItem( } } - private fun setLastMessage( - holder: ConversationItemViewHolder, - appContext: Context - ) { + private fun setLastMessage(holder: ConversationItemViewHolder, appContext: Context) { if (model.lastMessage != null) { holder.binding.dialogDate.visibility = View.VISIBLE holder.binding.dialogDate.text = DateUtils.getRelativeTimeSpanString( diff --git a/app/src/main/java/com/nextcloud/talk/adapters/items/MessageResultItem.kt b/app/src/main/java/com/nextcloud/talk/adapters/items/MessageResultItem.kt index c9384ce2aa..ff989d160b 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/items/MessageResultItem.kt +++ b/app/src/main/java/com/nextcloud/talk/adapters/items/MessageResultItem.kt @@ -95,10 +95,11 @@ data class MessageResultItem constructor( const val VIEW_TYPE = FlexibleItemViewType.MESSAGE_RESULT_ITEM } - override fun getHeader(): GenericTextHeaderItem = MessagesTextHeaderItem(context, viewThemeUtils) - .apply { - isHidden = showHeader // FlexibleAdapter needs this hack for some reason - } + override fun getHeader(): GenericTextHeaderItem = + MessagesTextHeaderItem(context, viewThemeUtils) + .apply { + isHidden = showHeader // FlexibleAdapter needs this hack for some reason + } override fun setHeader(header: GenericTextHeaderItem?) { // nothing, header is always the same diff --git a/app/src/main/java/com/nextcloud/talk/adapters/messages/CallStartedViewHolder.kt b/app/src/main/java/com/nextcloud/talk/adapters/messages/CallStartedViewHolder.kt index c6154ddaa1..8aa0665cff 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/messages/CallStartedViewHolder.kt +++ b/app/src/main/java/com/nextcloud/talk/adapters/messages/CallStartedViewHolder.kt @@ -124,6 +124,6 @@ class CallStartedViewHolder(incomingView: View, payload: Any) : } companion object { - var TAG: String? = CallStartedViewHolder::class.simpleName + val TAG: String? = CallStartedViewHolder::class.simpleName } } diff --git a/app/src/main/java/com/nextcloud/talk/adapters/messages/LinkPreview.kt b/app/src/main/java/com/nextcloud/talk/adapters/messages/LinkPreview.kt index cfba665d59..8ddd8a52ed 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/messages/LinkPreview.kt +++ b/app/src/main/java/com/nextcloud/talk/adapters/messages/LinkPreview.kt @@ -38,12 +38,7 @@ import io.reactivex.schedulers.Schedulers class LinkPreview { - fun showLink( - message: ChatMessage, - ncApi: NcApi, - binding: ReferenceInsideMessageBinding, - context: Context - ) { + fun showLink(message: ChatMessage, ncApi: NcApi, binding: ReferenceInsideMessageBinding, context: Context) { binding.referenceName.text = "" binding.referenceDescription.text = "" binding.referenceLink.text = "" diff --git a/app/src/main/java/com/nextcloud/talk/bottomsheet/items/ListIconDialogAdapter.kt b/app/src/main/java/com/nextcloud/talk/bottomsheet/items/ListIconDialogAdapter.kt index ccae4ac4f1..434df1b236 100644 --- a/app/src/main/java/com/nextcloud/talk/bottomsheet/items/ListIconDialogAdapter.kt +++ b/app/src/main/java/com/nextcloud/talk/bottomsheet/items/ListIconDialogAdapter.kt @@ -79,10 +79,7 @@ internal class ListIconDialogAdapter( } } - override fun onCreateViewHolder( - parent: ViewGroup, - viewType: Int - ): ListItemViewHolder { + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ListItemViewHolder { val listItemView: View = parent.inflate(dialog.windowContext, R.layout.menu_item_sheet) val viewHolder = ListItemViewHolder( itemView = listItemView, @@ -94,10 +91,7 @@ internal class ListIconDialogAdapter( override fun getItemCount() = items.size - override fun onBindViewHolder( - holder: ListItemViewHolder, - position: Int - ) { + override fun onBindViewHolder(holder: ListItemViewHolder, position: Int) { holder.itemView.isEnabled = !disabledIndices.contains(position) val currentItem = items[position] @@ -120,10 +114,7 @@ internal class ListIconDialogAdapter( } } - override fun replaceItems( - items: List, - listener: ListItemListener - ) { + override fun replaceItems(items: List, listener: ListItemListener) { this.items = items if (listener != null) { this.selection = listener diff --git a/app/src/main/java/com/nextcloud/talk/call/ReactionAnimator.kt b/app/src/main/java/com/nextcloud/talk/call/ReactionAnimator.kt index 746644b8c6..3354c3ab99 100644 --- a/app/src/main/java/com/nextcloud/talk/call/ReactionAnimator.kt +++ b/app/src/main/java/com/nextcloud/talk/call/ReactionAnimator.kt @@ -46,10 +46,7 @@ class ReactionAnimator( ) { private val reactionsList: MutableList = ArrayList() - fun addReaction( - emoji: String, - displayName: String - ) { + fun addReaction(emoji: String, displayName: String) { val callReaction = CallReaction(emoji, displayName) reactionsList.add(callReaction) @@ -58,9 +55,7 @@ class ReactionAnimator( } } - private fun animateReaction( - callReaction: CallReaction - ) { + private fun animateReaction(callReaction: CallReaction) { val reactionWrapper = getReactionWrapperView(callReaction) val params = RelativeLayout.LayoutParams( diff --git a/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt b/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt index 1db37dc2d5..9d203e9a04 100644 --- a/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt @@ -348,7 +348,13 @@ class ChatActivity : private var recorder: MediaRecorder? = null private enum class MediaRecorderState { - INITIAL, INITIALIZED, CONFIGURED, PREPARED, RECORDING, RELEASED, ERROR + INITIAL, + INITIALIZED, + CONFIGURED, + PREPARED, + RECORDING, + RELEASED, + ERROR } private var mediaRecorderState: MediaRecorderState = MediaRecorderState.INITIAL @@ -1708,14 +1714,17 @@ class ChatActivity : } } - fun isOneToOneConversation() = currentConversation != null && currentConversation?.type != null && - currentConversation?.type == ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL + fun isOneToOneConversation() = + currentConversation != null && currentConversation?.type != null && + currentConversation?.type == ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL - private fun isGroupConversation() = currentConversation != null && currentConversation?.type != null && - currentConversation?.type == ConversationType.ROOM_GROUP_CALL + private fun isGroupConversation() = + currentConversation != null && currentConversation?.type != null && + currentConversation?.type == ConversationType.ROOM_GROUP_CALL - private fun isPublicConversation() = currentConversation != null && currentConversation?.type != null && - currentConversation?.type == ConversationType.ROOM_PUBLIC_CALL + private fun isPublicConversation() = + currentConversation != null && currentConversation?.type != null && + currentConversation?.type == ConversationType.ROOM_PUBLIC_CALL private fun switchToRoom(token: String, startCallAfterRoomSwitch: Boolean, isVoiceOnlyCall: Boolean) { if (conversationUser != null) { @@ -2973,9 +2982,7 @@ class ChatActivity : } } - fun leaveRoom( - funToCallWhenLeaveSuccessful: (() -> Unit)? - ) { + fun leaveRoom(funToCallWhenLeaveSuccessful: (() -> Unit)?) { logConversationInfos("leaveRoom") var apiVersion = 1 @@ -3141,11 +3148,7 @@ class ChatActivity : signalingMessageSender = webSocketInstance?.signalingMessageSender } - fun pullChatMessages( - lookIntoFuture: Boolean, - setReadMarker: Boolean = true, - xChatLastCommonRead: Int? = null - ) { + fun pullChatMessages(lookIntoFuture: Boolean, setReadMarker: Boolean = true, xChatLastCommonRead: Int? = null) { if (!validSessionId()) { return } @@ -3465,10 +3468,7 @@ class ChatActivity : } } - private fun addMessagesToAdapter( - shouldAddNewMessagesNotice: Boolean, - chatMessageList: List - ) { + private fun addMessagesToAdapter(shouldAddNewMessagesNotice: Boolean, chatMessageList: List) { val isThereANewNotice = shouldAddNewMessagesNotice || adapter?.getMessagePositionByIdInReverse("-1") != -1 for (chatMessage in chatMessageList) { @@ -3721,19 +3721,15 @@ class ChatActivity : chatMessageMap[currentMessage.value.parentMessage!!.id]!!.isDeleted = true } chatMessageIterator.remove() - } - - // delete reactions system messages - else if (isReactionsMessage(currentMessage)) { + } else if (isReactionsMessage(currentMessage)) { + // delete reactions system messages if (!chatMessageMap.containsKey(currentMessage.value.parentMessage!!.id)) { updateAdapterForReaction(currentMessage.value.parentMessage) } chatMessageIterator.remove() - } - - // delete poll system messages - else if (isPollVotedMessage(currentMessage)) { + } else if (isPollVotedMessage(currentMessage)) { + // delete poll system messages chatMessageIterator.remove() } } diff --git a/app/src/main/java/com/nextcloud/talk/chat/data/ChatRepositoryImpl.kt b/app/src/main/java/com/nextcloud/talk/chat/data/ChatRepositoryImpl.kt index 81327cf742..488aaece3b 100644 --- a/app/src/main/java/com/nextcloud/talk/chat/data/ChatRepositoryImpl.kt +++ b/app/src/main/java/com/nextcloud/talk/chat/data/ChatRepositoryImpl.kt @@ -29,10 +29,7 @@ import com.nextcloud.talk.utils.ApiUtils import io.reactivex.Observable class ChatRepositoryImpl(private val ncApi: NcApi) : ChatRepository { - override fun getRoom( - user: User, - roomToken: String - ): Observable { + override fun getRoom(user: User, roomToken: String): Observable { val credentials: String = ApiUtils.getCredentials(user.username, user.token) val apiVersion = ApiUtils.getConversationApiVersion(user, intArrayOf(ApiUtils.APIv4, ApiUtils.APIv3, 1)) @@ -42,11 +39,7 @@ class ChatRepositoryImpl(private val ncApi: NcApi) : ChatRepository { ).map { ConversationModel.mapToConversationModel(it.ocs?.data!!) } } - override fun joinRoom( - user: User, - roomToken: String, - roomPassword: String - ): Observable { + override fun joinRoom(user: User, roomToken: String, roomPassword: String): Observable { val credentials: String = ApiUtils.getCredentials(user.username, user.token) val apiVersion = ApiUtils.getConversationApiVersion(user, intArrayOf(ApiUtils.APIv4, 1)) diff --git a/app/src/main/java/com/nextcloud/talk/conversation/repository/ConversationRepository.kt b/app/src/main/java/com/nextcloud/talk/conversation/repository/ConversationRepository.kt index 4e085b5567..fd8760d49e 100644 --- a/app/src/main/java/com/nextcloud/talk/conversation/repository/ConversationRepository.kt +++ b/app/src/main/java/com/nextcloud/talk/conversation/repository/ConversationRepository.kt @@ -27,13 +27,7 @@ import io.reactivex.Observable interface ConversationRepository { - fun renameConversation( - roomToken: String, - roomNameNew: String - ): Observable + fun renameConversation(roomToken: String, roomNameNew: String): Observable - fun createConversation( - roomName: String, - conversationType: Conversation.ConversationType? - ): Observable + fun createConversation(roomName: String, conversationType: Conversation.ConversationType?): Observable } diff --git a/app/src/main/java/com/nextcloud/talk/conversation/repository/ConversationRepositoryImpl.kt b/app/src/main/java/com/nextcloud/talk/conversation/repository/ConversationRepositoryImpl.kt index 6db12b27fc..adc6f88eba 100644 --- a/app/src/main/java/com/nextcloud/talk/conversation/repository/ConversationRepositoryImpl.kt +++ b/app/src/main/java/com/nextcloud/talk/conversation/repository/ConversationRepositoryImpl.kt @@ -38,10 +38,7 @@ class ConversationRepositoryImpl(private val ncApi: NcApi, currentUserProvider: val currentUser: User = currentUserProvider.currentUser.blockingGet() val credentials: String = ApiUtils.getCredentials(currentUser.username, currentUser.token) - override fun renameConversation( - roomToken: String, - roomNameNew: String - ): Observable { + override fun renameConversation(roomToken: String, roomNameNew: String): Observable { val apiVersion = ApiUtils.getConversationApiVersion(currentUser, intArrayOf(ApiUtils.APIv4, ApiUtils.APIv1)) return ncApi.renameRoom( diff --git a/app/src/main/java/com/nextcloud/talk/conversation/viewmodel/ConversationViewModel.kt b/app/src/main/java/com/nextcloud/talk/conversation/viewmodel/ConversationViewModel.kt index c35f31ced8..69e2303103 100644 --- a/app/src/main/java/com/nextcloud/talk/conversation/viewmodel/ConversationViewModel.kt +++ b/app/src/main/java/com/nextcloud/talk/conversation/viewmodel/ConversationViewModel.kt @@ -54,10 +54,7 @@ class ConversationViewModel @Inject constructor(private val repository: Conversa disposable?.dispose() } - fun createConversation( - roomName: String, - conversationType: Conversation.ConversationType? - ) { + fun createConversation(roomName: String, conversationType: Conversation.ConversationType?) { _viewState.value = CreatingState repository.createConversation( diff --git a/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt b/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt index 9ee0e5c41e..c473ecc6d4 100644 --- a/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt @@ -352,9 +352,7 @@ class ConversationsListActivity : viewThemeUtils.material.themeToolbar(binding.conversationListToolbar) } - private fun loadUserAvatar( - target: Target - ) { + private fun loadUserAvatar(target: Target) { if (currentUser != null) { val url = ApiUtils.getUrlForAvatar( currentUser!!.baseUrl, diff --git a/app/src/main/java/com/nextcloud/talk/dagger/modules/RepositoryModule.kt b/app/src/main/java/com/nextcloud/talk/dagger/modules/RepositoryModule.kt index 9d93b2a551..19694599ac 100644 --- a/app/src/main/java/com/nextcloud/talk/dagger/modules/RepositoryModule.kt +++ b/app/src/main/java/com/nextcloud/talk/dagger/modules/RepositoryModule.kt @@ -87,8 +87,10 @@ class RepositoryModule { } @Provides - fun provideRemoteFileBrowserItemsRepository(okHttpClient: OkHttpClient, userProvider: CurrentUserProviderNew): - RemoteFileBrowserItemsRepository { + fun provideRemoteFileBrowserItemsRepository( + okHttpClient: OkHttpClient, + userProvider: CurrentUserProviderNew + ): RemoteFileBrowserItemsRepository { return RemoteFileBrowserItemsRepositoryImpl(okHttpClient, userProvider) } @@ -113,38 +115,41 @@ class RepositoryModule { } @Provides - fun provideRequestAssistanceRepository(ncApi: NcApi, userProvider: CurrentUserProviderNew): - RequestAssistanceRepository { + fun provideRequestAssistanceRepository( + ncApi: NcApi, + userProvider: CurrentUserProviderNew + ): RequestAssistanceRepository { return RequestAssistanceRepositoryImpl(ncApi, userProvider) } @Provides - fun provideOpenConversationsRepository(ncApi: NcApi, userProvider: CurrentUserProviderNew): - OpenConversationsRepository { + fun provideOpenConversationsRepository( + ncApi: NcApi, + userProvider: CurrentUserProviderNew + ): OpenConversationsRepository { return OpenConversationsRepositoryImpl(ncApi, userProvider) } @Provides - fun translateRepository(ncApi: NcApi): - TranslateRepository { + fun translateRepository(ncApi: NcApi): TranslateRepository { return TranslateRepositoryImpl(ncApi) } @Provides - fun provideChatRepository(ncApi: NcApi): - ChatRepository { + fun provideChatRepository(ncApi: NcApi): ChatRepository { return ChatRepositoryImpl(ncApi) } @Provides - fun provideConversationInfoEditRepository(ncApi: NcApi, userProvider: CurrentUserProviderNew): - ConversationInfoEditRepository { + fun provideConversationInfoEditRepository( + ncApi: NcApi, + userProvider: CurrentUserProviderNew + ): ConversationInfoEditRepository { return ConversationInfoEditRepositoryImpl(ncApi, userProvider) } @Provides - fun provideConversationRepository(ncApi: NcApi, userProvider: CurrentUserProviderNew): - ConversationRepository { + fun provideConversationRepository(ncApi: NcApi, userProvider: CurrentUserProviderNew): ConversationRepository { return ConversationRepositoryImpl(ncApi, userProvider) } } diff --git a/app/src/main/java/com/nextcloud/talk/data/source/local/TalkDatabase.kt b/app/src/main/java/com/nextcloud/talk/data/source/local/TalkDatabase.kt index 4db51a3e73..65eb7ee5fe 100644 --- a/app/src/main/java/com/nextcloud/talk/data/source/local/TalkDatabase.kt +++ b/app/src/main/java/com/nextcloud/talk/data/source/local/TalkDatabase.kt @@ -64,12 +64,12 @@ abstract class TalkDatabase : RoomDatabase() { const val TAG = "TalkDatabase" @Volatile - private var INSTANCE: TalkDatabase? = null + private var instance: TalkDatabase? = null @JvmStatic fun getInstance(context: Context, appPreferences: AppPreferences): TalkDatabase = - INSTANCE ?: synchronized(this) { - INSTANCE ?: build(context, appPreferences).also { INSTANCE = it } + instance ?: synchronized(this) { + instance ?: build(context, appPreferences).also { instance = it } } private fun build(context: Context, appPreferences: AppPreferences): TalkDatabase { diff --git a/app/src/main/java/com/nextcloud/talk/jobs/ShareOperationWorker.kt b/app/src/main/java/com/nextcloud/talk/jobs/ShareOperationWorker.kt index 95f09fdcb8..45b3cae47a 100644 --- a/app/src/main/java/com/nextcloud/talk/jobs/ShareOperationWorker.kt +++ b/app/src/main/java/com/nextcloud/talk/jobs/ShareOperationWorker.kt @@ -93,12 +93,7 @@ class ShareOperationWorker(context: Context, workerParams: WorkerParameters) : W companion object { private val TAG = ShareOperationWorker::class.simpleName - fun shareFile( - roomToken: String?, - currentUser: User, - remotePath: String, - metaData: String? - ) { + fun shareFile(roomToken: String?, currentUser: User, remotePath: String, metaData: String?) { val paths: MutableList = ArrayList() paths.add(remotePath) diff --git a/app/src/main/java/com/nextcloud/talk/jobs/UploadAndShareFilesWorker.kt b/app/src/main/java/com/nextcloud/talk/jobs/UploadAndShareFilesWorker.kt index e6bc5370dd..6ace531288 100644 --- a/app/src/main/java/com/nextcloud/talk/jobs/UploadAndShareFilesWorker.kt +++ b/app/src/main/java/com/nextcloud/talk/jobs/UploadAndShareFilesWorker.kt @@ -186,9 +186,7 @@ class UploadAndShareFilesWorker(val context: Context, workerParameters: WorkerPa return remotePath } - override fun onTransferProgress( - percentage: Int - ) { + override fun onTransferProgress(percentage: Int) { notification = mBuilder!! .setProgress(HUNDRED_PERCENT, percentage, false) .setContentText(getNotificationContentText(percentage)) @@ -322,12 +320,7 @@ class UploadAndShareFilesWorker(val context: Context, workerParameters: WorkerPa } } - fun upload( - fileUri: String, - roomToken: String, - conversationName: String, - metaData: String? - ) { + fun upload(fileUri: String, roomToken: String, conversationName: String, metaData: String?) { val data: Data = Data.Builder() .putString(DEVICE_SOURCE_FILE, fileUri) .putString(ROOM_TOKEN, roomToken) diff --git a/app/src/main/java/com/nextcloud/talk/location/LocationPickerActivity.kt b/app/src/main/java/com/nextcloud/talk/location/LocationPickerActivity.kt index be2bba0666..c93de415aa 100644 --- a/app/src/main/java/com/nextcloud/talk/location/LocationPickerActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/location/LocationPickerActivity.kt @@ -335,41 +335,42 @@ class LocationPickerActivity : ) } - private fun delayedMapListener() = DelayedMapListener( - object : MapListener { - @Suppress("Detekt.TooGenericExceptionCaught") - override fun onScroll(paramScrollEvent: ScrollEvent): Boolean { - try { - when { - moveToCurrentLocation -> { - setLocationDescription(isGpsLocation = true, isGeocodedResult = false) - moveToCurrentLocation = false - } - - geocodingResult != null -> { - binding.shareLocation.isClickable = true - setLocationDescription(isGpsLocation = false, isGeocodedResult = true) - geocodingResult = null - } - - else -> { - binding.shareLocation.isClickable = true - setLocationDescription(isGpsLocation = false, isGeocodedResult = false) + private fun delayedMapListener() = + DelayedMapListener( + object : MapListener { + @Suppress("Detekt.TooGenericExceptionCaught") + override fun onScroll(paramScrollEvent: ScrollEvent): Boolean { + try { + when { + moveToCurrentLocation -> { + setLocationDescription(isGpsLocation = true, isGeocodedResult = false) + moveToCurrentLocation = false + } + + geocodingResult != null -> { + binding.shareLocation.isClickable = true + setLocationDescription(isGpsLocation = false, isGeocodedResult = true) + geocodingResult = null + } + + else -> { + binding.shareLocation.isClickable = true + setLocationDescription(isGpsLocation = false, isGeocodedResult = false) + } } + } catch (e: NullPointerException) { + Log.d(TAG, "UI already closed") } - } catch (e: NullPointerException) { - Log.d(TAG, "UI already closed") - } - readyToShareLocation = true - return true - } + readyToShareLocation = true + return true + } - override fun onZoom(event: ZoomEvent): Boolean { - return false + override fun onZoom(event: ZoomEvent): Boolean { + return false + } } - } - ) + ) @Suppress("Detekt.TooGenericExceptionCaught") private fun requestLocationUpdates() { @@ -524,11 +525,7 @@ class LocationPickerActivity : ) } - override fun onRequestPermissionsResult( - requestCode: Int, - permissions: Array, - grantResults: IntArray - ) { + override fun onRequestPermissionsResult(requestCode: Int, permissions: Array, grantResults: IntArray) { super.onRequestPermissionsResult(requestCode, permissions, grantResults) fun areAllGranted(grantResults: IntArray): Boolean { diff --git a/app/src/main/java/com/nextcloud/talk/models/domain/ConversationModel.kt b/app/src/main/java/com/nextcloud/talk/models/domain/ConversationModel.kt index 9859d3b8d4..e9e2a164af 100644 --- a/app/src/main/java/com/nextcloud/talk/models/domain/ConversationModel.kt +++ b/app/src/main/java/com/nextcloud/talk/models/domain/ConversationModel.kt @@ -46,9 +46,7 @@ class ConversationModel( ) { companion object { - fun mapToConversationModel( - conversation: Conversation - ): ConversationModel { + fun mapToConversationModel(conversation: Conversation): ConversationModel { return ConversationModel( roomId = conversation.roomId, token = conversation.token, @@ -113,7 +111,13 @@ enum class ConversationType { } enum class ParticipantType { - DUMMY, OWNER, MODERATOR, USER, GUEST, USER_FOLLOWING_LINK, GUEST_MODERATOR + DUMMY, + OWNER, + MODERATOR, + USER, + GUEST, + USER_FOLLOWING_LINK, + GUEST_MODERATOR } enum class ObjectType { @@ -124,13 +128,18 @@ enum class ObjectType { } enum class NotificationLevel { - DEFAULT, ALWAYS, MENTION, NEVER + DEFAULT, + ALWAYS, + MENTION, + NEVER } enum class ConversationReadOnlyState { - CONVERSATION_READ_WRITE, CONVERSATION_READ_ONLY + CONVERSATION_READ_WRITE, + CONVERSATION_READ_ONLY } enum class LobbyState { - LOBBY_STATE_ALL_PARTICIPANTS, LOBBY_STATE_MODERATORS_ONLY + LOBBY_STATE_ALL_PARTICIPANTS, + LOBBY_STATE_MODERATORS_ONLY } diff --git a/app/src/main/java/com/nextcloud/talk/models/json/chat/ChatMessage.kt b/app/src/main/java/com/nextcloud/talk/models/json/chat/ChatMessage.kt index bb68e697d5..c9d70038ad 100644 --- a/app/src/main/java/com/nextcloud/talk/models/json/chat/ChatMessage.kt +++ b/app/src/main/java/com/nextcloud/talk/models/json/chat/ChatMessage.kt @@ -374,11 +374,12 @@ data class ChatMessage( return "" } - private fun getNullsafeActorDisplayName() = if (!TextUtils.isEmpty(actorDisplayName)) { - actorDisplayName - } else { - sharedApplication!!.getString(R.string.nc_guest) - } + private fun getNullsafeActorDisplayName() = + if (!TextUtils.isEmpty(actorDisplayName)) { + actorDisplayName + } else { + sharedApplication!!.getString(R.string.nc_guest) + } override fun getUser(): IUser { return object : IUser { @@ -471,7 +472,8 @@ data class ChatMessage( * see https://nextcloud-talk.readthedocs.io/en/latest/chat/#system-messages */ enum class SystemMessageType { - DUMMY, CONVERSATION_CREATED, + DUMMY, + CONVERSATION_CREATED, CONVERSATION_RENAMED, DESCRIPTION_REMOVED, DESCRIPTION_SET, @@ -505,7 +507,8 @@ data class ChatMessage( GUEST_MODERATOR_PROMOTED, GUEST_MODERATOR_DEMOTED, MESSAGE_DELETED, - FILE_SHARED, OBJECT_SHARED, + FILE_SHARED, + OBJECT_SHARED, MATTERBRIDGE_CONFIG_ADDED, MATTERBRIDGE_CONFIG_EDITED, MATTERBRIDGE_CONFIG_REMOVED, diff --git a/app/src/main/java/com/nextcloud/talk/models/json/chat/ChatUtils.kt b/app/src/main/java/com/nextcloud/talk/models/json/chat/ChatUtils.kt index d6d1d6869d..d09ccd680d 100644 --- a/app/src/main/java/com/nextcloud/talk/models/json/chat/ChatUtils.kt +++ b/app/src/main/java/com/nextcloud/talk/models/json/chat/ChatUtils.kt @@ -26,8 +26,10 @@ package com.nextcloud.talk.models.json.chat class ChatUtils { companion object { - fun getParsedMessage(message: String?, messageParameters: HashMap>?): - String? { + fun getParsedMessage( + message: String?, + messageParameters: HashMap>? + ): String? { if (messageParameters != null && messageParameters.size > 0) { return parse(messageParameters, message) } @@ -35,10 +37,7 @@ class ChatUtils { } @Suppress("Detekt.ComplexMethod") - private fun parse( - messageParameters: HashMap>, - message: String? - ): String? { + private fun parse(messageParameters: HashMap>, message: String?): String? { var resultMessage = message for (key in messageParameters.keys) { val individualHashMap = messageParameters[key] diff --git a/app/src/main/java/com/nextcloud/talk/models/json/chat/ReadStatus.kt b/app/src/main/java/com/nextcloud/talk/models/json/chat/ReadStatus.kt index d913689950..07259466da 100644 --- a/app/src/main/java/com/nextcloud/talk/models/json/chat/ReadStatus.kt +++ b/app/src/main/java/com/nextcloud/talk/models/json/chat/ReadStatus.kt @@ -20,5 +20,7 @@ package com.nextcloud.talk.models.json.chat enum class ReadStatus { - NONE, SENT, READ + NONE, + SENT, + READ } diff --git a/app/src/main/java/com/nextcloud/talk/models/json/conversations/Conversation.kt b/app/src/main/java/com/nextcloud/talk/models/json/conversations/Conversation.kt index e3dd2ea920..57dc17779e 100644 --- a/app/src/main/java/com/nextcloud/talk/models/json/conversations/Conversation.kt +++ b/app/src/main/java/com/nextcloud/talk/models/json/conversations/Conversation.kt @@ -229,15 +229,20 @@ data class Conversation( } enum class NotificationLevel { - DEFAULT, ALWAYS, MENTION, NEVER + DEFAULT, + ALWAYS, + MENTION, + NEVER } enum class LobbyState { - LOBBY_STATE_ALL_PARTICIPANTS, LOBBY_STATE_MODERATORS_ONLY + LOBBY_STATE_ALL_PARTICIPANTS, + LOBBY_STATE_MODERATORS_ONLY } enum class ConversationReadOnlyState { - CONVERSATION_READ_WRITE, CONVERSATION_READ_ONLY + CONVERSATION_READ_WRITE, + CONVERSATION_READ_ONLY } @Parcelize diff --git a/app/src/main/java/com/nextcloud/talk/models/json/participants/Participant.kt b/app/src/main/java/com/nextcloud/talk/models/json/participants/Participant.kt index 3b085025b1..68f0c7bf94 100644 --- a/app/src/main/java/com/nextcloud/talk/models/json/participants/Participant.kt +++ b/app/src/main/java/com/nextcloud/talk/models/json/participants/Participant.kt @@ -124,11 +124,22 @@ data class Participant( } enum class ActorType { - DUMMY, EMAILS, GROUPS, GUESTS, USERS, CIRCLES + DUMMY, + EMAILS, + GROUPS, + GUESTS, + USERS, + CIRCLES } enum class ParticipantType { - DUMMY, OWNER, MODERATOR, USER, GUEST, USER_FOLLOWING_LINK, GUEST_MODERATOR + DUMMY, + OWNER, + MODERATOR, + USER, + GUEST, + USER_FOLLOWING_LINK, + GUEST_MODERATOR } object InCallFlags { diff --git a/app/src/main/java/com/nextcloud/talk/models/json/reactions/ReactionVoter.kt b/app/src/main/java/com/nextcloud/talk/models/json/reactions/ReactionVoter.kt index c500155874..74eeec9a39 100644 --- a/app/src/main/java/com/nextcloud/talk/models/json/reactions/ReactionVoter.kt +++ b/app/src/main/java/com/nextcloud/talk/models/json/reactions/ReactionVoter.kt @@ -41,6 +41,8 @@ data class ReactionVoter( constructor() : this(null, null, null, 0) enum class ReactionActorType { - DUMMY, GUESTS, USERS + DUMMY, + GUESTS, + USERS } } diff --git a/app/src/main/java/com/nextcloud/talk/openconversations/data/OpenConversationsRepositoryImpl.kt b/app/src/main/java/com/nextcloud/talk/openconversations/data/OpenConversationsRepositoryImpl.kt index 1924b85c18..cde5347572 100644 --- a/app/src/main/java/com/nextcloud/talk/openconversations/data/OpenConversationsRepositoryImpl.kt +++ b/app/src/main/java/com/nextcloud/talk/openconversations/data/OpenConversationsRepositoryImpl.kt @@ -42,9 +42,7 @@ class OpenConversationsRepositoryImpl(private val ncApi: NcApi, currentUserProvi ).map { mapToOpenConversationsModel(it.ocs?.data!!) } } - private fun mapToOpenConversationsModel( - conversations: List - ): OpenConversationsModel { + private fun mapToOpenConversationsModel(conversations: List): OpenConversationsModel { return OpenConversationsModel( conversations.map { conversation -> OpenConversation( diff --git a/app/src/main/java/com/nextcloud/talk/polls/adapters/PollCreateOptionViewHolder.kt b/app/src/main/java/com/nextcloud/talk/polls/adapters/PollCreateOptionViewHolder.kt index 26a97801e2..6280b6a1e8 100644 --- a/app/src/main/java/com/nextcloud/talk/polls/adapters/PollCreateOptionViewHolder.kt +++ b/app/src/main/java/com/nextcloud/talk/polls/adapters/PollCreateOptionViewHolder.kt @@ -75,20 +75,19 @@ class PollCreateOptionViewHolder( private fun getTextWatcher( pollCreateOptionItem: PollCreateOptionItem, itemsListener: PollCreateOptionsItemListener - ) = - object : TextWatcher { - override fun afterTextChanged(s: Editable) { - // unused atm - } + ) = object : TextWatcher { + override fun afterTextChanged(s: Editable) { + // unused atm + } - override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) { - // unused atm - } + override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) { + // unused atm + } - override fun onTextChanged(option: CharSequence, start: Int, before: Int, count: Int) { - pollCreateOptionItem.pollOption = option.toString() + override fun onTextChanged(option: CharSequence, start: Int, before: Int, count: Int) { + pollCreateOptionItem.pollOption = option.toString() - itemsListener.onOptionsItemTextChanged(pollCreateOptionItem) - } + itemsListener.onOptionsItemTextChanged(pollCreateOptionItem) } + } } diff --git a/app/src/main/java/com/nextcloud/talk/polls/ui/PollLoadingFragment.kt b/app/src/main/java/com/nextcloud/talk/polls/ui/PollLoadingFragment.kt index 80b8a62c69..803e1136c7 100644 --- a/app/src/main/java/com/nextcloud/talk/polls/ui/PollLoadingFragment.kt +++ b/app/src/main/java/com/nextcloud/talk/polls/ui/PollLoadingFragment.kt @@ -49,11 +49,7 @@ class PollLoadingFragment : Fragment() { fragmentHeight = arguments?.getInt(KEY_FRAGMENT_HEIGHT)!! } - override fun onCreateView( - inflater: LayoutInflater, - container: ViewGroup?, - savedInstanceState: Bundle? - ): View { + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { binding = DialogPollLoadingBinding.inflate(inflater, container, false) binding.root.layoutParams.height = fragmentHeight viewThemeUtils.platform.colorCircularProgressBar(binding.pollLoadingProgressbar, ColorRole.PRIMARY) @@ -65,9 +61,7 @@ class PollLoadingFragment : Fragment() { private const val KEY_FRAGMENT_HEIGHT = "keyFragmentHeight" @JvmStatic - fun newInstance( - fragmentHeight: Int - ): PollLoadingFragment { + fun newInstance(fragmentHeight: Int): PollLoadingFragment { val args = bundleOf( KEY_FRAGMENT_HEIGHT to fragmentHeight ) diff --git a/app/src/main/java/com/nextcloud/talk/polls/ui/PollMainDialogFragment.kt b/app/src/main/java/com/nextcloud/talk/polls/ui/PollMainDialogFragment.kt index 27c28dd808..4ee667ad77 100644 --- a/app/src/main/java/com/nextcloud/talk/polls/ui/PollMainDialogFragment.kt +++ b/app/src/main/java/com/nextcloud/talk/polls/ui/PollMainDialogFragment.kt @@ -121,7 +121,7 @@ class PollMainDialogFragment : DialogFragment() { private fun showLoadingScreen() { binding.root.post { - run() { + run { val fragmentHeight = binding.messagePollContentFragment.measuredHeight val contentFragment = PollLoadingFragment.newInstance(fragmentHeight) diff --git a/app/src/main/java/com/nextcloud/talk/polls/ui/PollResultsFragment.kt b/app/src/main/java/com/nextcloud/talk/polls/ui/PollResultsFragment.kt index 17c0408861..2d6b338bd4 100644 --- a/app/src/main/java/com/nextcloud/talk/polls/ui/PollResultsFragment.kt +++ b/app/src/main/java/com/nextcloud/talk/polls/ui/PollResultsFragment.kt @@ -65,11 +65,7 @@ class PollResultsFragment : Fragment(), PollResultItemClickListener { parentViewModel = ViewModelProvider(requireParentFragment(), viewModelFactory)[PollMainViewModel::class.java] } - override fun onCreateView( - inflater: LayoutInflater, - container: ViewGroup?, - savedInstanceState: Bundle? - ): View { + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { binding = DialogPollResultsBinding.inflate(inflater, container, false) return binding.root } diff --git a/app/src/main/java/com/nextcloud/talk/polls/ui/PollVoteFragment.kt b/app/src/main/java/com/nextcloud/talk/polls/ui/PollVoteFragment.kt index 2443abacab..9ce1540191 100644 --- a/app/src/main/java/com/nextcloud/talk/polls/ui/PollVoteFragment.kt +++ b/app/src/main/java/com/nextcloud/talk/polls/ui/PollVoteFragment.kt @@ -69,11 +69,7 @@ class PollVoteFragment : Fragment() { parentViewModel = ViewModelProvider(requireParentFragment(), viewModelFactory)[PollMainViewModel::class.java] } - override fun onCreateView( - inflater: LayoutInflater, - container: ViewGroup?, - savedInstanceState: Bundle? - ): View { + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { binding = DialogPollVoteBinding.inflate(inflater, container, false) return binding.root } diff --git a/app/src/main/java/com/nextcloud/talk/polls/viewmodels/PollResultsViewModel.kt b/app/src/main/java/com/nextcloud/talk/polls/viewmodels/PollResultsViewModel.kt index 430b0d37c7..8ce1737c5a 100644 --- a/app/src/main/java/com/nextcloud/talk/polls/viewmodels/PollResultsViewModel.kt +++ b/app/src/main/java/com/nextcloud/talk/polls/viewmodels/PollResultsViewModel.kt @@ -41,8 +41,8 @@ class PollResultsViewModel @Inject constructor() : ViewModel() { val poll: Poll? get() = _poll - private var _itemsOverviewList: ArrayList = ArrayList() - private var _itemsDetailsList: ArrayList = ArrayList() + private var itemsOverviewList: ArrayList = ArrayList() + private var itemsDetailsList: ArrayList = ArrayList() private var _items: MutableLiveData?> = MutableLiveData?>() val items: MutableLiveData?> @@ -77,23 +77,23 @@ class PollResultsViewModel @Inject constructor() : ViewModel() { optionsPercent, isOptionSelfVoted(poll, index) ) - _itemsOverviewList.add(pollResultHeaderItem) - _itemsDetailsList.add(pollResultHeaderItem) + itemsOverviewList.add(pollResultHeaderItem) + itemsDetailsList.add(pollResultHeaderItem) val voters = poll.details?.filter { it.optionId == index } if (!voters.isNullOrEmpty()) { - _itemsOverviewList.add(PollResultVotersOverviewItem(voters)) + itemsOverviewList.add(PollResultVotersOverviewItem(voters)) } if (!voters.isNullOrEmpty()) { voters.forEach { - _itemsDetailsList.add(PollResultVoterItem(it)) + itemsDetailsList.add(PollResultVoterItem(it)) } } } - _items.value = _itemsOverviewList + _items.value = itemsOverviewList } private fun getVotersAmountForOption(poll: Poll, index: Int): Int { @@ -114,10 +114,10 @@ class PollResultsViewModel @Inject constructor() : ViewModel() { } fun toggleDetails() { - if (_items.value?.containsAll(_itemsDetailsList) == true) { - _items.value = _itemsOverviewList + if (_items.value?.containsAll(itemsDetailsList) == true) { + _items.value = itemsOverviewList } else { - _items.value = _itemsDetailsList + _items.value = itemsDetailsList } } diff --git a/app/src/main/java/com/nextcloud/talk/profile/ProfileActivity.kt b/app/src/main/java/com/nextcloud/talk/profile/ProfileActivity.kt index 8b7f16478e..48020e8c96 100644 --- a/app/src/main/java/com/nextcloud/talk/profile/ProfileActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/profile/ProfileActivity.kt @@ -688,10 +688,7 @@ class ProfileActivity : BaseActivity() { } } - private fun initUserInfoEditText( - holder: ViewHolder, - item: UserInfoDetailsItem - ) { + private fun initUserInfoEditText(holder: ViewHolder, item: UserInfoDetailsItem) { holder.binding.userInfoEditTextEdit.setText(item.text) holder.binding.userInfoInputLayout.hint = item.hint holder.binding.userInfoEditTextEdit.addTextChangedListener(object : TextWatcher { @@ -714,10 +711,7 @@ class ProfileActivity : BaseActivity() { }) } - private fun initScopeElements( - item: UserInfoDetailsItem, - holder: ViewHolder - ) { + private fun initScopeElements(item: UserInfoDetailsItem, holder: ViewHolder) { if (item.scope == null) { holder.binding.scope.visibility = View.GONE } else { diff --git a/app/src/main/java/com/nextcloud/talk/raisehand/RequestAssistanceRepository.kt b/app/src/main/java/com/nextcloud/talk/raisehand/RequestAssistanceRepository.kt index 826dc72e18..2c5d2b958a 100644 --- a/app/src/main/java/com/nextcloud/talk/raisehand/RequestAssistanceRepository.kt +++ b/app/src/main/java/com/nextcloud/talk/raisehand/RequestAssistanceRepository.kt @@ -24,11 +24,7 @@ import io.reactivex.Observable interface RequestAssistanceRepository { - fun requestAssistance( - roomToken: String - ): Observable + fun requestAssistance(roomToken: String): Observable - fun withdrawRequestAssistance( - roomToken: String - ): Observable + fun withdrawRequestAssistance(roomToken: String): Observable } diff --git a/app/src/main/java/com/nextcloud/talk/raisehand/RequestAssistanceRepositoryImpl.kt b/app/src/main/java/com/nextcloud/talk/raisehand/RequestAssistanceRepositoryImpl.kt index aa42daa7dd..7576027626 100644 --- a/app/src/main/java/com/nextcloud/talk/raisehand/RequestAssistanceRepositoryImpl.kt +++ b/app/src/main/java/com/nextcloud/talk/raisehand/RequestAssistanceRepositoryImpl.kt @@ -57,18 +57,14 @@ class RequestAssistanceRepositoryImpl(private val ncApi: NcApi, currentUserProvi ).map { mapToWithdrawRequestAssistanceModel(it.ocs?.meta!!) } } - private fun mapToRequestAssistanceModel( - response: GenericMeta - ): RequestAssistanceModel { + private fun mapToRequestAssistanceModel(response: GenericMeta): RequestAssistanceModel { val success = response.statusCode == HTTP_OK return RequestAssistanceModel( success ) } - private fun mapToWithdrawRequestAssistanceModel( - response: GenericMeta - ): WithdrawRequestAssistanceModel { + private fun mapToWithdrawRequestAssistanceModel(response: GenericMeta): WithdrawRequestAssistanceModel { val success = response.statusCode == HTTP_OK return WithdrawRequestAssistanceModel( success diff --git a/app/src/main/java/com/nextcloud/talk/remotefilebrowser/activities/RemoteFileBrowserActivity.kt b/app/src/main/java/com/nextcloud/talk/remotefilebrowser/activities/RemoteFileBrowserActivity.kt index dde05d6482..12c21bb61b 100644 --- a/app/src/main/java/com/nextcloud/talk/remotefilebrowser/activities/RemoteFileBrowserActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/remotefilebrowser/activities/RemoteFileBrowserActivity.kt @@ -160,10 +160,7 @@ class RemoteFileBrowserActivity : AppCompatActivity(), SelectionInterface, Swipe } } - private fun loadList( - state: RemoteFileBrowserItemsViewModel.LoadedState, - mimeTypeSelectionFilter: String? - ) { + private fun loadList(state: RemoteFileBrowserItemsViewModel.LoadedState, mimeTypeSelectionFilter: String?) { val remoteFileBrowserItems = state.items Log.d(TAG, "Items received: $remoteFileBrowserItems") diff --git a/app/src/main/java/com/nextcloud/talk/remotefilebrowser/repositories/RemoteFileBrowserItemsRepositoryImpl.kt b/app/src/main/java/com/nextcloud/talk/remotefilebrowser/repositories/RemoteFileBrowserItemsRepositoryImpl.kt index 45f104d3f8..b238744d53 100644 --- a/app/src/main/java/com/nextcloud/talk/remotefilebrowser/repositories/RemoteFileBrowserItemsRepositoryImpl.kt +++ b/app/src/main/java/com/nextcloud/talk/remotefilebrowser/repositories/RemoteFileBrowserItemsRepositoryImpl.kt @@ -36,8 +36,7 @@ class RemoteFileBrowserItemsRepositoryImpl @Inject constructor( private val user: User get() = userProvider.currentUser.blockingGet() - override fun listFolder(path: String): - Observable> { + override fun listFolder(path: String): Observable> { return Observable.fromCallable { val operation = ReadFolderListingOperation( diff --git a/app/src/main/java/com/nextcloud/talk/repositories/callrecording/CallRecordingRepository.kt b/app/src/main/java/com/nextcloud/talk/repositories/callrecording/CallRecordingRepository.kt index a206442eb3..8422a8315b 100644 --- a/app/src/main/java/com/nextcloud/talk/repositories/callrecording/CallRecordingRepository.kt +++ b/app/src/main/java/com/nextcloud/talk/repositories/callrecording/CallRecordingRepository.kt @@ -26,11 +26,7 @@ import io.reactivex.Observable interface CallRecordingRepository { - fun startRecording( - roomToken: String - ): Observable + fun startRecording(roomToken: String): Observable - fun stopRecording( - roomToken: String - ): Observable + fun stopRecording(roomToken: String): Observable } diff --git a/app/src/main/java/com/nextcloud/talk/repositories/callrecording/CallRecordingRepositoryImpl.kt b/app/src/main/java/com/nextcloud/talk/repositories/callrecording/CallRecordingRepositoryImpl.kt index 601b431b83..71c6d64d21 100644 --- a/app/src/main/java/com/nextcloud/talk/repositories/callrecording/CallRecordingRepositoryImpl.kt +++ b/app/src/main/java/com/nextcloud/talk/repositories/callrecording/CallRecordingRepositoryImpl.kt @@ -37,9 +37,7 @@ class CallRecordingRepositoryImpl(private val ncApi: NcApi, currentUserProvider: var apiVersion = 1 - override fun startRecording( - roomToken: String - ): Observable { + override fun startRecording(roomToken: String): Observable { return ncApi.startRecording( credentials, ApiUtils.getUrlForRecording( @@ -51,9 +49,7 @@ class CallRecordingRepositoryImpl(private val ncApi: NcApi, currentUserProvider: ).map { mapToStartCallRecordingModel(it.ocs?.meta!!) } } - override fun stopRecording( - roomToken: String - ): Observable { + override fun stopRecording(roomToken: String): Observable { return ncApi.stopRecording( credentials, ApiUtils.getUrlForRecording( @@ -64,18 +60,14 @@ class CallRecordingRepositoryImpl(private val ncApi: NcApi, currentUserProvider: ).map { mapToStopCallRecordingModel(it.ocs?.meta!!) } } - private fun mapToStartCallRecordingModel( - response: GenericMeta - ): StartCallRecordingModel { + private fun mapToStartCallRecordingModel(response: GenericMeta): StartCallRecordingModel { val success = response.statusCode == HTTP_OK return StartCallRecordingModel( success ) } - private fun mapToStopCallRecordingModel( - response: GenericMeta - ): StopCallRecordingModel { + private fun mapToStopCallRecordingModel(response: GenericMeta): StopCallRecordingModel { val success = response.statusCode == HTTP_OK return StopCallRecordingModel( success diff --git a/app/src/main/java/com/nextcloud/talk/repositories/reactions/ReactionsRepository.kt b/app/src/main/java/com/nextcloud/talk/repositories/reactions/ReactionsRepository.kt index 71a999bd5b..e99340c392 100644 --- a/app/src/main/java/com/nextcloud/talk/repositories/reactions/ReactionsRepository.kt +++ b/app/src/main/java/com/nextcloud/talk/repositories/reactions/ReactionsRepository.kt @@ -27,15 +27,7 @@ import io.reactivex.Observable interface ReactionsRepository { - fun addReaction( - roomToken: String, - message: ChatMessage, - emoji: String - ): Observable + fun addReaction(roomToken: String, message: ChatMessage, emoji: String): Observable - fun deleteReaction( - roomToken: String, - message: ChatMessage, - emoji: String - ): Observable + fun deleteReaction(roomToken: String, message: ChatMessage, emoji: String): Observable } diff --git a/app/src/main/java/com/nextcloud/talk/repositories/reactions/ReactionsRepositoryImpl.kt b/app/src/main/java/com/nextcloud/talk/repositories/reactions/ReactionsRepositoryImpl.kt index 2a99c3c429..55de85b818 100644 --- a/app/src/main/java/com/nextcloud/talk/repositories/reactions/ReactionsRepositoryImpl.kt +++ b/app/src/main/java/com/nextcloud/talk/repositories/reactions/ReactionsRepositoryImpl.kt @@ -36,11 +36,7 @@ class ReactionsRepositoryImpl(private val ncApi: NcApi, currentUserProvider: Cur val currentUser: User = currentUserProvider.currentUser.blockingGet() val credentials: String = ApiUtils.getCredentials(currentUser.username, currentUser.token) - override fun addReaction( - roomToken: String, - message: ChatMessage, - emoji: String - ): Observable { + override fun addReaction(roomToken: String, message: ChatMessage, emoji: String): Observable { return ncApi.sendReaction( credentials, ApiUtils.getUrlForMessageReaction( diff --git a/app/src/main/java/com/nextcloud/talk/repositories/unifiedsearch/UnifiedSearchRepositoryImpl.kt b/app/src/main/java/com/nextcloud/talk/repositories/unifiedsearch/UnifiedSearchRepositoryImpl.kt index 2083418ec9..df475b4554 100644 --- a/app/src/main/java/com/nextcloud/talk/repositories/unifiedsearch/UnifiedSearchRepositoryImpl.kt +++ b/app/src/main/java/com/nextcloud/talk/repositories/unifiedsearch/UnifiedSearchRepositoryImpl.kt @@ -81,8 +81,11 @@ class UnifiedSearchRepositoryImpl(private val api: NcApi, private val userProvid private const val ATTRIBUTE_CONVERSATION = "conversation" private const val ATTRIBUTE_MESSAGE_ID = "messageId" - private fun mapToMessageResults(data: UnifiedSearchResponseData, searchTerm: String, limit: Int): - UnifiedSearchRepository.UnifiedSearchResults { + private fun mapToMessageResults( + data: UnifiedSearchResponseData, + searchTerm: String, + limit: Int + ): UnifiedSearchRepository.UnifiedSearchResults { val entries = data.entries?.map { it -> mapToMessage(it, searchTerm) } val cursor = data.cursor ?: 0 val hasMore = entries?.size == limit diff --git a/app/src/main/java/com/nextcloud/talk/shareditems/repositories/SharedItemsRepository.kt b/app/src/main/java/com/nextcloud/talk/shareditems/repositories/SharedItemsRepository.kt index 89353f6110..0860d159b1 100644 --- a/app/src/main/java/com/nextcloud/talk/shareditems/repositories/SharedItemsRepository.kt +++ b/app/src/main/java/com/nextcloud/talk/shareditems/repositories/SharedItemsRepository.kt @@ -28,16 +28,9 @@ import io.reactivex.Observable interface SharedItemsRepository { - fun media( - parameters: Parameters, - type: SharedItemType - ): Observable? + fun media(parameters: Parameters, type: SharedItemType): Observable? - fun media( - parameters: Parameters, - type: SharedItemType, - lastKnownMessageId: Int? - ): Observable? + fun media(parameters: Parameters, type: SharedItemType, lastKnownMessageId: Int?): Observable? fun availableTypes(parameters: Parameters): Observable> diff --git a/app/src/main/java/com/nextcloud/talk/shareditems/repositories/SharedItemsRepositoryImpl.kt b/app/src/main/java/com/nextcloud/talk/shareditems/repositories/SharedItemsRepositoryImpl.kt index ba422c1ab0..21d7419ca0 100644 --- a/app/src/main/java/com/nextcloud/talk/shareditems/repositories/SharedItemsRepositoryImpl.kt +++ b/app/src/main/java/com/nextcloud/talk/shareditems/repositories/SharedItemsRepositoryImpl.kt @@ -48,10 +48,7 @@ import javax.inject.Inject class SharedItemsRepositoryImpl @Inject constructor(private val ncApi: NcApi, private val dateUtils: DateUtils) : SharedItemsRepository { - override fun media( - parameters: SharedItemsRepository.Parameters, - type: SharedItemType - ): Observable? { + override fun media(parameters: SharedItemsRepository.Parameters, type: SharedItemType): Observable? { return media(parameters, type, null) } diff --git a/app/src/main/java/com/nextcloud/talk/shareditems/viewmodels/SharedItemsViewModel.kt b/app/src/main/java/com/nextcloud/talk/shareditems/viewmodels/SharedItemsViewModel.kt index d5d7b81f03..96dbf5b003 100644 --- a/app/src/main/java/com/nextcloud/talk/shareditems/viewmodels/SharedItemsViewModel.kt +++ b/app/src/main/java/com/nextcloud/talk/shareditems/viewmodels/SharedItemsViewModel.kt @@ -98,10 +98,11 @@ class SharedItemsViewModel @Inject constructor( }) } - private fun chooseInitialType(newTypes: Set): SharedItemType = when { - newTypes.contains(SharedItemType.MEDIA) -> SharedItemType.MEDIA - else -> newTypes.toList().first() - } + private fun chooseInitialType(newTypes: Set): SharedItemType = + when { + newTypes.contains(SharedItemType.MEDIA) -> SharedItemType.MEDIA + else -> newTypes.toList().first() + } fun initialLoadItems(type: SharedItemType) { val state = _viewState.value diff --git a/app/src/main/java/com/nextcloud/talk/translate/repositories/TranslateRepository.kt b/app/src/main/java/com/nextcloud/talk/translate/repositories/TranslateRepository.kt index 7692cae58a..d464e89848 100644 --- a/app/src/main/java/com/nextcloud/talk/translate/repositories/TranslateRepository.kt +++ b/app/src/main/java/com/nextcloud/talk/translate/repositories/TranslateRepository.kt @@ -13,8 +13,5 @@ interface TranslateRepository { fromLanguage: String? ): Observable - fun getLanguages( - authorization: String, - url: String - ): Observable> + fun getLanguages(authorization: String, url: String): Observable> } diff --git a/app/src/main/java/com/nextcloud/talk/translate/viewmodels/TranslateViewModel.kt b/app/src/main/java/com/nextcloud/talk/translate/viewmodels/TranslateViewModel.kt index dc5a439fb8..99a40e3bcf 100644 --- a/app/src/main/java/com/nextcloud/talk/translate/viewmodels/TranslateViewModel.kt +++ b/app/src/main/java/com/nextcloud/talk/translate/viewmodels/TranslateViewModel.kt @@ -39,7 +39,12 @@ class TranslateViewModel @Inject constructor( val currentUser: User = userManager.currentUser.blockingGet() val authorization: String = ApiUtils.getCredentials(currentUser.username, currentUser.token) val url: String = ApiUtils.getUrlForTranslation(currentUser.baseUrl) - val calculatedFromLanguage = if (fromLanguage == null || fromLanguage == "") { null } else { fromLanguage } + val calculatedFromLanguage = + if (fromLanguage == null || fromLanguage == "") { + null + } else { + fromLanguage + } Log.i(TAG, "translateMessage Called") repository.translateMessage( authorization, diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/DateTimePickerFragment.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/DateTimePickerFragment.kt index 886ef57f99..93a8d42dbf 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/DateTimePickerFragment.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/DateTimePickerFragment.kt @@ -299,14 +299,11 @@ class DateTimePickerFragment( private const val HOUR_SIX_PM = 18 @JvmStatic - fun newInstance( - token: String, - id: String, - chatViewModel: ChatViewModel - ) = DateTimePickerFragment( - token, - id, - chatViewModel - ) + fun newInstance(token: String, id: String, chatViewModel: ChatViewModel) = + DateTimePickerFragment( + token, + id, + chatViewModel + ) } } diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/FileAttachmentPreviewFragment.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/FileAttachmentPreviewFragment.kt index e4f004b95b..01ce6dd79c 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/FileAttachmentPreviewFragment.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/FileAttachmentPreviewFragment.kt @@ -93,8 +93,7 @@ class FileAttachmentPreviewFragment( filenames: String, filesToUpload: MutableList, functionToCall: (files: MutableList, caption: String) -> Unit - ) = - FileAttachmentPreviewFragment(filenames, filesToUpload, functionToCall) + ) = FileAttachmentPreviewFragment(filenames, filesToUpload, functionToCall) val TAG: String = FilterConversationFragment::class.java.simpleName } } diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/FilterConversationFragment.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/FilterConversationFragment.kt index aa8061e42c..a990a0c813 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/FilterConversationFragment.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/FilterConversationFragment.kt @@ -62,11 +62,7 @@ class FilterConversationFragment( return MaterialAlertDialogBuilder(requireContext()).setView(dialogView).create() } - override fun onCreateView( - inflater: LayoutInflater, - container: ViewGroup?, - savedInstanceState: Bundle? - ): View? { + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { NextcloudTalkApplication.sharedApplication!!.componentApplication.inject(this) setUpColors() setUpListeners() diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/SaveToStorageDialogFragment.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/SaveToStorageDialogFragment.kt index 70c270ae6b..e5d8def95c 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/SaveToStorageDialogFragment.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/SaveToStorageDialogFragment.kt @@ -83,9 +83,7 @@ class SaveToStorageDialogFragment : DialogFragment() { } @SuppressLint("LongLogTag") - private fun saveImageToStorage( - fileName: String - ) { + private fun saveImageToStorage(fileName: String) { val sourceFilePath = requireContext().cacheDir.path val workerTag = SAVE_TO_STORAGE_WORKER_PREFIX + fileName diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/SetStatusDialogFragment.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/SetStatusDialogFragment.kt index e92ae94b10..eab617bc54 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/SetStatusDialogFragment.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/SetStatusDialogFragment.kt @@ -350,9 +350,7 @@ class SetStatusDialogFragment : return returnValue } - private fun clearAtToUnixTimeTypeEndOf( - clearAt: ClearAt - ): Long { + private fun clearAtToUnixTimeTypeEndOf(clearAt: ClearAt): Long { var returnValue = -1L if (clearAt.time == "day") { val date = Calendar.getInstance().apply { diff --git a/app/src/main/java/com/nextcloud/talk/ui/theme/TalkSpecificViewThemeUtils.kt b/app/src/main/java/com/nextcloud/talk/ui/theme/TalkSpecificViewThemeUtils.kt index 5a06acef8c..98794590b8 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/theme/TalkSpecificViewThemeUtils.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/theme/TalkSpecificViewThemeUtils.kt @@ -295,11 +295,7 @@ class TalkSpecificViewThemeUtils @Inject constructor( } } - fun themeAndHighlightText( - textView: TextView, - originalText: String?, - c: String? - ) { + fun themeAndHighlightText(textView: TextView, originalText: String?, c: String?) { withScheme(textView) { scheme -> var constraint = c constraint = FlexibleUtils.toLowerCase(constraint) @@ -374,11 +370,7 @@ class TalkSpecificViewThemeUtils @Inject constructor( } } - fun getTextColor( - isOutgoingMessage: Boolean, - isSelfReaction: Boolean, - binding: ReactionsInsideMessageBinding - ): Int { + fun getTextColor(isOutgoingMessage: Boolean, isSelfReaction: Boolean, binding: ReactionsInsideMessageBinding): Int { return withScheme(binding.root) { scheme -> return@withScheme if (!isOutgoingMessage || isSelfReaction) { ContextCompat.getColor(binding.root.context, R.color.high_emphasis_text) diff --git a/app/src/main/java/com/nextcloud/talk/upload/chunked/ChunkedFileUploader.kt b/app/src/main/java/com/nextcloud/talk/upload/chunked/ChunkedFileUploader.kt index 0183059513..6c7021371d 100644 --- a/app/src/main/java/com/nextcloud/talk/upload/chunked/ChunkedFileUploader.kt +++ b/app/src/main/java/com/nextcloud/talk/upload/chunked/ChunkedFileUploader.kt @@ -83,11 +83,7 @@ class ChunkedFileUploader( } @Suppress("Detekt.TooGenericExceptionCaught") - fun upload( - localFile: File, - mimeType: MediaType?, - targetPath: String - ): Boolean { + fun upload(localFile: File, mimeType: MediaType?, targetPath: String): Boolean { try { val uploadFolderUri: String = remoteChunkUrl + "/" + FileUtils.md5Sum(localFile) val davResource = DavResource( @@ -137,10 +133,7 @@ class ChunkedFileUploader( } @Suppress("Detekt.ComplexMethod") - private fun getUploadedChunks( - davResource: DavResource, - uploadFolderUri: String - ): MutableList { + private fun getUploadedChunks(davResource: DavResource, uploadFolderUri: String): MutableList { val davResponse = DavResponse() val memberElements: MutableList = ArrayList() val rootElement = arrayOfNulls(1) diff --git a/app/src/main/java/com/nextcloud/talk/upload/chunked/OnDataTransferProgressListener.kt b/app/src/main/java/com/nextcloud/talk/upload/chunked/OnDataTransferProgressListener.kt index 049fee4fb1..6ba4633427 100644 --- a/app/src/main/java/com/nextcloud/talk/upload/chunked/OnDataTransferProgressListener.kt +++ b/app/src/main/java/com/nextcloud/talk/upload/chunked/OnDataTransferProgressListener.kt @@ -25,7 +25,5 @@ package com.nextcloud.talk.upload.chunked interface OnDataTransferProgressListener { - fun onTransferProgress( - percentage: Int - ) + fun onTransferProgress(percentage: Int) } diff --git a/app/src/main/java/com/nextcloud/talk/upload/normal/FileUploader.kt b/app/src/main/java/com/nextcloud/talk/upload/normal/FileUploader.kt index 514aae0da9..d21f906058 100644 --- a/app/src/main/java/com/nextcloud/talk/upload/normal/FileUploader.kt +++ b/app/src/main/java/com/nextcloud/talk/upload/normal/FileUploader.kt @@ -21,12 +21,7 @@ class FileUploader( val roomToken: String, val ncApi: NcApi ) { - fun upload( - sourceFileUri: Uri, - fileName: String, - remotePath: String, - metaData: String? - ): Observable { + fun upload(sourceFileUri: Uri, fileName: String, remotePath: String, metaData: String?): Observable { return ncApi.uploadFile( ApiUtils.getCredentials(currentUser.username, currentUser.token), ApiUtils.getUrlForFileUpload(currentUser.baseUrl, currentUser.userId, remotePath), diff --git a/app/src/main/java/com/nextcloud/talk/utils/BitmapShrinker.kt b/app/src/main/java/com/nextcloud/talk/utils/BitmapShrinker.kt index 9f9635f8dc..008b2355d9 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/BitmapShrinker.kt +++ b/app/src/main/java/com/nextcloud/talk/utils/BitmapShrinker.kt @@ -35,21 +35,13 @@ object BitmapShrinker { private const val DEGREES_270 = 270f @JvmStatic - fun shrinkBitmap( - path: String, - reqWidth: Int, - reqHeight: Int - ): Bitmap { + fun shrinkBitmap(path: String, reqWidth: Int, reqHeight: Int): Bitmap { val bitmap = decodeBitmap(path, reqWidth, reqHeight) return rotateBitmap(path, bitmap) } // solution inspired by https://developer.android.com/topic/performance/graphics/load-bitmap - private fun decodeBitmap( - path: String, - requestedWidth: Int, - requestedHeight: Int - ): Bitmap { + private fun decodeBitmap(path: String, requestedWidth: Int, requestedHeight: Int): Bitmap { return BitmapFactory.Options().run { inJustDecodeBounds = true BitmapFactory.decodeFile(path, this) @@ -60,11 +52,7 @@ object BitmapShrinker { } // solution inspired by https://developer.android.com/topic/performance/graphics/load-bitmap - private fun getInSampleSize( - options: BitmapFactory.Options, - requestedWidth: Int, - requestedHeight: Int - ): Int { + private fun getInSampleSize(options: BitmapFactory.Options, requestedWidth: Int, requestedHeight: Int): Int { val (height: Int, width: Int) = options.run { outHeight to outWidth } var inSampleSize = 1 if (height > requestedHeight || width > requestedWidth) { diff --git a/app/src/main/java/com/nextcloud/talk/utils/DateUtils.kt b/app/src/main/java/com/nextcloud/talk/utils/DateUtils.kt index 6f94209e2e..af5c3f600e 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/DateUtils.kt +++ b/app/src/main/java/com/nextcloud/talk/utils/DateUtils.kt @@ -37,14 +37,17 @@ class DateUtils(val context: Context) { /* date formatter in local timezone and locale */ private var format: DateFormat = DateFormat.getDateTimeInstance( - DateFormat.DEFAULT, // dateStyle - DateFormat.SHORT, // timeStyle + // dateStyle + DateFormat.DEFAULT, + // timeStyle + DateFormat.SHORT, context.resources.configuration.locales[0] ) /* date formatter in local timezone and locale */ private var formatTime: DateFormat = DateFormat.getTimeInstance( - DateFormat.SHORT, // timeStyle + // timeStyle + DateFormat.SHORT, context.resources.configuration.locales[0] ) diff --git a/app/src/main/java/com/nextcloud/talk/utils/DisplayUtils.java b/app/src/main/java/com/nextcloud/talk/utils/DisplayUtils.java index 4682f50fcf..c964645e82 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/DisplayUtils.java +++ b/app/src/main/java/com/nextcloud/talk/utils/DisplayUtils.java @@ -89,12 +89,12 @@ import coil.transform.CircleCropTransformation; import third.parties.fresco.BetterImageSpan; -import static com.nextcloud.talk.utils.FileSortOrder.sort_a_to_z_id; -import static com.nextcloud.talk.utils.FileSortOrder.sort_big_to_small_id; -import static com.nextcloud.talk.utils.FileSortOrder.sort_new_to_old_id; -import static com.nextcloud.talk.utils.FileSortOrder.sort_old_to_new_id; -import static com.nextcloud.talk.utils.FileSortOrder.sort_small_to_big_id; -import static com.nextcloud.talk.utils.FileSortOrder.sort_z_to_a_id; +import static com.nextcloud.talk.utils.FileSortOrder.SORT_A_TO_Z_ID; +import static com.nextcloud.talk.utils.FileSortOrder.SORT_BIG_TO_SMALL_ID; +import static com.nextcloud.talk.utils.FileSortOrder.SORT_NEW_TO_OLD_ID; +import static com.nextcloud.talk.utils.FileSortOrder.SORT_OLD_TO_NEW_ID; +import static com.nextcloud.talk.utils.FileSortOrder.SORT_SMALL_TO_BIG_ID; +import static com.nextcloud.talk.utils.FileSortOrder.SORT_Z_TO_A_ID; public class DisplayUtils { private static final String TAG = DisplayUtils.class.getSimpleName(); @@ -476,17 +476,17 @@ public static void loadAvatarImage(User user, ImageView avatarImageView, boolean public static @StringRes int getSortOrderStringId(FileSortOrder sortOrder) { switch (sortOrder.getName()) { - case sort_z_to_a_id: + case SORT_Z_TO_A_ID: return R.string.menu_item_sort_by_name_z_a; - case sort_new_to_old_id: + case SORT_NEW_TO_OLD_ID: return R.string.menu_item_sort_by_date_newest_first; - case sort_old_to_new_id: + case SORT_OLD_TO_NEW_ID: return R.string.menu_item_sort_by_date_oldest_first; - case sort_big_to_small_id: + case SORT_BIG_TO_SMALL_ID: return R.string.menu_item_sort_by_size_biggest_first; - case sort_small_to_big_id: + case SORT_SMALL_TO_BIG_ID: return R.string.menu_item_sort_by_size_smallest_first; - case sort_a_to_z_id: + case SORT_A_TO_Z_ID: default: return R.string.menu_item_sort_by_name_a_z; } diff --git a/app/src/main/java/com/nextcloud/talk/utils/FileSortOrder.kt b/app/src/main/java/com/nextcloud/talk/utils/FileSortOrder.kt index f3bfffb150..405e766355 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/FileSortOrder.kt +++ b/app/src/main/java/com/nextcloud/talk/utils/FileSortOrder.kt @@ -27,19 +27,19 @@ import java.util.Collections open class FileSortOrder(var name: String, var isAscending: Boolean) { companion object { - const val sort_a_to_z_id = "sort_a_to_z" - const val sort_z_to_a_id = "sort_z_to_a" - const val sort_old_to_new_id = "sort_old_to_new" - const val sort_new_to_old_id = "sort_new_to_old" - const val sort_small_to_big_id = "sort_small_to_big" - const val sort_big_to_small_id = "sort_big_to_small" + const val SORT_A_TO_Z_ID = "sort_a_to_z" + const val SORT_Z_TO_A_ID = "sort_z_to_a" + const val SORT_OLD_TO_NEW_ID = "sort_old_to_new" + const val SORT_NEW_TO_OLD_ID = "sort_new_to_old" + const val SORT_SMALL_TO_BIG_ID = "sort_small_to_big" + const val SORT_BIG_TO_SMALL_ID = "sort_big_to_small" - val sort_a_to_z: FileSortOrder = FileSortOrderByName(sort_a_to_z_id, true) - val sort_z_to_a: FileSortOrder = FileSortOrderByName(sort_z_to_a_id, false) - val sort_old_to_new: FileSortOrder = FileSortOrderByDate(sort_old_to_new_id, true) - val sort_new_to_old: FileSortOrder = FileSortOrderByDate(sort_new_to_old_id, false) - val sort_small_to_big: FileSortOrder = FileSortOrderBySize(sort_small_to_big_id, true) - val sort_big_to_small: FileSortOrder = FileSortOrderBySize(sort_big_to_small_id, false) + val sort_a_to_z: FileSortOrder = FileSortOrderByName(SORT_A_TO_Z_ID, true) + val sort_z_to_a: FileSortOrder = FileSortOrderByName(SORT_Z_TO_A_ID, false) + val sort_old_to_new: FileSortOrder = FileSortOrderByDate(SORT_OLD_TO_NEW_ID, true) + val sort_new_to_old: FileSortOrder = FileSortOrderByDate(SORT_NEW_TO_OLD_ID, false) + val sort_small_to_big: FileSortOrder = FileSortOrderBySize(SORT_SMALL_TO_BIG_ID, true) + val sort_big_to_small: FileSortOrder = FileSortOrderBySize(SORT_BIG_TO_SMALL_ID, false) val sortOrders: Map = mapOf( sort_a_to_z.name to sort_a_to_z, diff --git a/app/src/main/java/com/nextcloud/talk/utils/FileViewerUtils.kt b/app/src/main/java/com/nextcloud/talk/utils/FileViewerUtils.kt index caa66d9972..92cc4183f5 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/FileViewerUtils.kt +++ b/app/src/main/java/com/nextcloud/talk/utils/FileViewerUtils.kt @@ -73,10 +73,7 @@ import java.util.concurrent.ExecutionException */ class FileViewerUtils(private val context: Context, private val user: User) { - fun openFile( - message: ChatMessage, - progressUi: ProgressUi - ) { + fun openFile(message: ChatMessage, progressUi: ProgressUi) { val fileName = message.selectedIndividualHashMap!![PreviewMessageViewHolder.KEY_NAME]!! val mimetype = message.selectedIndividualHashMap!![PreviewMessageViewHolder.KEY_MIMETYPE]!! val link = message.selectedIndividualHashMap!!["link"]!! diff --git a/app/src/main/java/com/nextcloud/talk/utils/NotificationUtils.kt b/app/src/main/java/com/nextcloud/talk/utils/NotificationUtils.kt index a5682d9597..68ff86ca43 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/NotificationUtils.kt +++ b/app/src/main/java/com/nextcloud/talk/utils/NotificationUtils.kt @@ -102,10 +102,7 @@ object NotificationUtils { } } - private fun createCallsNotificationChannel( - context: Context, - appPreferences: AppPreferences - ) { + private fun createCallsNotificationChannel(context: Context, appPreferences: AppPreferences) { val audioAttributes = AudioAttributes.Builder() .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION) @@ -126,10 +123,7 @@ object NotificationUtils { ) } - private fun createMessagesNotificationChannel( - context: Context, - appPreferences: AppPreferences - ) { + private fun createMessagesNotificationChannel(context: Context, appPreferences: AppPreferences) { val audioAttributes = AudioAttributes.Builder() .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION) @@ -150,9 +144,7 @@ object NotificationUtils { ) } - private fun createUploadsNotificationChannel( - context: Context - ) { + private fun createUploadsNotificationChannel(context: Context) { createNotificationChannel( context, Channel( @@ -166,10 +158,7 @@ object NotificationUtils { ) } - fun registerNotificationChannels( - context: Context, - appPreferences: AppPreferences - ) { + fun registerNotificationChannels(context: Context, appPreferences: AppPreferences) { createCallsNotificationChannel(context, appPreferences) createMessagesNotificationChannel(context, appPreferences) createUploadsNotificationChannel(context) @@ -197,10 +186,7 @@ object NotificationUtils { } @TargetApi(Build.VERSION_CODES.O) - private fun getNotificationChannel( - context: Context, - channelId: String - ): NotificationChannel? { + private fun getNotificationChannel(context: Context, channelId: String): NotificationChannel? { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager return notificationManager.getNotificationChannel(channelId) @@ -275,10 +261,7 @@ object NotificationUtils { } } - fun isNotificationVisible( - context: Context?, - notificationId: Int - ): Boolean { + fun isNotificationVisible(context: Context?, notificationId: Int): Boolean { var isVisible = false val notificationManager = context!!.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager @@ -319,10 +302,7 @@ object NotificationUtils { } } - fun getCallRingtoneUri( - context: Context, - appPreferences: AppPreferences - ): Uri? { + fun getCallRingtoneUri(context: Context, appPreferences: AppPreferences): Uri? { return getRingtoneUri( context, appPreferences.callRingtoneUri, @@ -331,10 +311,7 @@ object NotificationUtils { ) } - fun getMessageRingtoneUri( - context: Context, - appPreferences: AppPreferences - ): Uri? { + fun getMessageRingtoneUri(context: Context, appPreferences: AppPreferences): Uri? { return getRingtoneUri( context, appPreferences.messageRingtoneUri, diff --git a/app/src/main/java/com/nextcloud/talk/utils/RemoteFileUtils.kt b/app/src/main/java/com/nextcloud/talk/utils/RemoteFileUtils.kt index 4786997e44..2e3681f889 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/RemoteFileUtils.kt +++ b/app/src/main/java/com/nextcloud/talk/utils/RemoteFileUtils.kt @@ -31,11 +31,7 @@ import io.reactivex.schedulers.Schedulers object RemoteFileUtils { private val TAG = RemoteFileUtils::class.java.simpleName - fun getNewPathIfFileExists( - ncApi: NcApi, - currentUser: User, - remotePath: String - ): String { + fun getNewPathIfFileExists(ncApi: NcApi, currentUser: User, remotePath: String): String { var finalPath = remotePath val fileExists = doesFileExist( ncApi, @@ -53,11 +49,7 @@ object RemoteFileUtils { return finalPath } - private fun doesFileExist( - ncApi: NcApi, - currentUser: User, - remotePath: String - ): Observable { + private fun doesFileExist(ncApi: NcApi, currentUser: User, remotePath: String): Observable { return ncApi.checkIfFileExists( ApiUtils.getCredentials(currentUser.username, currentUser.token), ApiUtils.getUrlForFileUpload( @@ -72,11 +64,7 @@ object RemoteFileUtils { } } - private fun getFileNameWithoutCollision( - ncApi: NcApi, - currentUser: User, - remotePath: String - ): String { + private fun getFileNameWithoutCollision(ncApi: NcApi, currentUser: User, remotePath: String): String { val extPos = remotePath.lastIndexOf('.') var suffix: String var extension = "" diff --git a/app/src/main/java/com/nextcloud/talk/utils/ShareUtils.kt b/app/src/main/java/com/nextcloud/talk/utils/ShareUtils.kt index 3aea937722..41c6448783 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/ShareUtils.kt +++ b/app/src/main/java/com/nextcloud/talk/utils/ShareUtils.kt @@ -25,11 +25,7 @@ import com.nextcloud.talk.data.user.model.User import com.nextcloud.talk.models.json.conversations.Conversation object ShareUtils { - fun getStringForIntent( - context: Context, - user: User, - conversation: Conversation? - ): String { + fun getStringForIntent(context: Context, user: User, conversation: Conversation?): String { return String.format( context.resources.getString(R.string.nc_share_text), user.baseUrl, diff --git a/app/src/main/java/com/nextcloud/talk/utils/preferences/AppPreferencesImpl.kt b/app/src/main/java/com/nextcloud/talk/utils/preferences/AppPreferencesImpl.kt index 4e6f4fcd61..c096044ebd 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/preferences/AppPreferencesImpl.kt +++ b/app/src/main/java/com/nextcloud/talk/utils/preferences/AppPreferencesImpl.kt @@ -46,13 +46,14 @@ class AppPreferencesImpl(val context: Context) : AppPreferences { }.getCompleted() } - override fun setProxyType(proxyType: String?) = runBlocking { - async { - if (proxyType != null) { - writeString(PROXY_TYPE, proxyType) + override fun setProxyType(proxyType: String?) = + runBlocking { + async { + if (proxyType != null) { + writeString(PROXY_TYPE, proxyType) + } } } - } override fun removeProxyType() { proxyType = "" @@ -62,13 +63,14 @@ class AppPreferencesImpl(val context: Context) : AppPreferences { return runBlocking { async { readString(PROXY_HOST).first() } }.getCompleted() } - override fun setProxyHost(proxyHost: String?) = runBlocking { - async { - if (proxyHost != null) { - writeString(PROXY_HOST, proxyHost) + override fun setProxyHost(proxyHost: String?) = + runBlocking { + async { + if (proxyHost != null) { + writeString(PROXY_HOST, proxyHost) + } } } - } override fun removeProxyHost() { proxyHost = "" @@ -78,13 +80,14 @@ class AppPreferencesImpl(val context: Context) : AppPreferences { return runBlocking { async { readString(PROXY_PORT).first() } }.getCompleted() } - override fun setProxyPort(proxyPort: String?) = runBlocking { - async { - if (proxyPort != null) { - writeString(PROXY_PORT, proxyPort) + override fun setProxyPort(proxyPort: String?) = + runBlocking { + async { + if (proxyPort != null) { + writeString(PROXY_PORT, proxyPort) + } } } - } override fun removeProxyPort() { proxyPort = "" @@ -94,11 +97,12 @@ class AppPreferencesImpl(val context: Context) : AppPreferences { return runBlocking { async { readBoolean(PROXY_CRED).first() } }.getCompleted() } - override fun setProxyNeedsCredentials(proxyNeedsCredentials: Boolean) = runBlocking { - async { - writeBoolean(PROXY_CRED, proxyNeedsCredentials) + override fun setProxyNeedsCredentials(proxyNeedsCredentials: Boolean) = + runBlocking { + async { + writeBoolean(PROXY_CRED, proxyNeedsCredentials) + } } - } override fun removeProxyCredentials() { setProxyNeedsCredentials(false) @@ -108,13 +112,14 @@ class AppPreferencesImpl(val context: Context) : AppPreferences { return runBlocking { async { readString(PROXY_USERNAME).first() } }.getCompleted() } - override fun setProxyUsername(proxyUsername: String?) = runBlocking { - async { - if (proxyUsername != null) { - writeString(PROXY_USERNAME, proxyUsername) + override fun setProxyUsername(proxyUsername: String?) = + runBlocking { + async { + if (proxyUsername != null) { + writeString(PROXY_USERNAME, proxyUsername) + } } } - } override fun removeProxyUsername() { proxyUsername = "" @@ -124,13 +129,14 @@ class AppPreferencesImpl(val context: Context) : AppPreferences { return runBlocking { async { readString(PROXY_PASSWORD).first() } }.getCompleted() } - override fun setProxyPassword(proxyPassword: String?) = runBlocking { - async { - if (proxyPassword != null) { - writeString(PROXY_PASSWORD, proxyPassword) + override fun setProxyPassword(proxyPassword: String?) = + runBlocking { + async { + if (proxyPassword != null) { + writeString(PROXY_PASSWORD, proxyPassword) + } } } - } override fun removeProxyPassword() { proxyPassword = "" @@ -140,13 +146,14 @@ class AppPreferencesImpl(val context: Context) : AppPreferences { return runBlocking { async { readString(PUSH_TOKEN).first() } }.getCompleted() } - override fun setPushToken(pushToken: String?) = runBlocking { - async { - if (pushToken != null) { - writeString(PUSH_TOKEN, pushToken) + override fun setPushToken(pushToken: String?) = + runBlocking { + async { + if (pushToken != null) { + writeString(PUSH_TOKEN, pushToken) + } } } - } override fun removePushToken() { pushToken = "" @@ -156,13 +163,14 @@ class AppPreferencesImpl(val context: Context) : AppPreferences { return runBlocking { async { readString(TEMP_CLIENT_CERT_ALIAS).first() } }.getCompleted() } - override fun setTemporaryClientCertAlias(alias: String?) = runBlocking { - async { - if (alias != null) { - writeString(TEMP_CLIENT_CERT_ALIAS, alias) + override fun setTemporaryClientCertAlias(alias: String?) = + runBlocking { + async { + if (alias != null) { + writeString(TEMP_CLIENT_CERT_ALIAS, alias) + } } } - } override fun removeTemporaryClientCertAlias() { temporaryClientCertAlias = "" @@ -172,11 +180,12 @@ class AppPreferencesImpl(val context: Context) : AppPreferences { return runBlocking { async { readBoolean(PUSH_TO_TALK_INTRO_SHOWN).first() } }.getCompleted() } - override fun setPushToTalkIntroShown(shown: Boolean) = runBlocking { - async { - writeBoolean(PUSH_TO_TALK_INTRO_SHOWN, shown) + override fun setPushToTalkIntroShown(shown: Boolean) = + runBlocking { + async { + writeBoolean(PUSH_TO_TALK_INTRO_SHOWN, shown) + } } - } override fun removePushToTalkIntroShown() { pushToTalkIntroShown = false @@ -186,13 +195,14 @@ class AppPreferencesImpl(val context: Context) : AppPreferences { return runBlocking { async { readString(CALL_RINGTONE).first() } }.getCompleted() } - override fun setCallRingtoneUri(value: String?) = runBlocking { - async { - if (value != null) { - writeString(CALL_RINGTONE, value) + override fun setCallRingtoneUri(value: String?) = + runBlocking { + async { + if (value != null) { + writeString(CALL_RINGTONE, value) + } } } - } override fun removeCallRingtoneUri() { callRingtoneUri = "" @@ -202,13 +212,14 @@ class AppPreferencesImpl(val context: Context) : AppPreferences { return runBlocking { async { readString(MESSAGE_RINGTONE).first() } }.getCompleted() } - override fun setMessageRingtoneUri(value: String?) = runBlocking { - async { - if (value != null) { - writeString(MESSAGE_RINGTONE, value) + override fun setMessageRingtoneUri(value: String?) = + runBlocking { + async { + if (value != null) { + writeString(MESSAGE_RINGTONE, value) + } } } - } override fun removeMessageRingtoneUri() { messageRingtoneUri = "" @@ -218,11 +229,12 @@ class AppPreferencesImpl(val context: Context) : AppPreferences { return runBlocking { async { readBoolean(NOTIFY_UPGRADE_V2).first() } }.getCompleted() } - override fun setNotificationChannelIsUpgradedToV2(value: Boolean) = runBlocking { - async { - writeBoolean(NOTIFY_UPGRADE_V2, value) + override fun setNotificationChannelIsUpgradedToV2(value: Boolean) = + runBlocking { + async { + writeBoolean(NOTIFY_UPGRADE_V2, value) + } } - } override fun removeNotificationChannelUpgradeToV2() { setNotificationChannelIsUpgradedToV2(false) @@ -232,11 +244,12 @@ class AppPreferencesImpl(val context: Context) : AppPreferences { return runBlocking { async { readBoolean(NOTIFY_UPGRADE_V3).first() } }.getCompleted() } - override fun setNotificationChannelIsUpgradedToV3(value: Boolean) = runBlocking { - async { - writeBoolean(NOTIFY_UPGRADE_V3, value) + override fun setNotificationChannelIsUpgradedToV3(value: Boolean) = + runBlocking { + async { + writeBoolean(NOTIFY_UPGRADE_V3, value) + } } - } override fun removeNotificationChannelUpgradeToV3() { setNotificationChannelIsUpgradedToV3(false) @@ -246,11 +259,12 @@ class AppPreferencesImpl(val context: Context) : AppPreferences { return runBlocking { async { readBoolean(SCREEN_SECURITY).first() } }.getCompleted() } - override fun setScreenSecurity(value: Boolean) = runBlocking { - async { - writeBoolean(SCREEN_SECURITY, value) + override fun setScreenSecurity(value: Boolean) = + runBlocking { + async { + writeBoolean(SCREEN_SECURITY, value) + } } - } override fun removeScreenSecurity() { setScreenSecurity(false) @@ -260,11 +274,12 @@ class AppPreferencesImpl(val context: Context) : AppPreferences { return runBlocking { async { readBoolean(SCREEN_LOCK).first() } }.getCompleted() } - override fun setScreenLock(value: Boolean) = runBlocking { - async { - writeBoolean(SCREEN_LOCK, value) + override fun setScreenLock(value: Boolean) = + runBlocking { + async { + writeBoolean(SCREEN_LOCK, value) + } } - } override fun removeScreenLock() { setScreenLock(false) @@ -275,11 +290,12 @@ class AppPreferencesImpl(val context: Context) : AppPreferences { return read } - override fun setIncognitoKeyboard(value: Boolean) = runBlocking { - async { - writeBoolean(INCOGNITO_KEYBOARD, value) + override fun setIncognitoKeyboard(value: Boolean) = + runBlocking { + async { + writeBoolean(INCOGNITO_KEYBOARD, value) + } } - } override fun removeIncognitoKeyboard() { setIncognitoKeyboard(false) @@ -289,17 +305,19 @@ class AppPreferencesImpl(val context: Context) : AppPreferences { return runBlocking { async { readBoolean(PHONE_BOOK_INTEGRATION).first() } }.getCompleted() } - override fun setPhoneBookIntegration(value: Boolean) = runBlocking { - async { - writeBoolean(PHONE_BOOK_INTEGRATION, value) + override fun setPhoneBookIntegration(value: Boolean) = + runBlocking { + async { + writeBoolean(PHONE_BOOK_INTEGRATION, value) + } } - } - override fun removeLinkPreviews() = runBlocking { - async { - writeBoolean(LINK_PREVIEWS, false) + override fun removeLinkPreviews() = + runBlocking { + async { + writeBoolean(LINK_PREVIEWS, false) + } } - } override fun getScreenLockTimeout(): String { val default = context.resources.getString(R.string.nc_screen_lock_timeout_sixty) @@ -307,13 +325,14 @@ class AppPreferencesImpl(val context: Context) : AppPreferences { return read.ifEmpty { default } } - override fun setScreenLockTimeout(value: String?) = runBlocking { - async { - if (value != null) { - writeString(SCREEN_LOCK_TIMEOUT, value) + override fun setScreenLockTimeout(value: String?) = + runBlocking { + async { + if (value != null) { + writeString(SCREEN_LOCK_TIMEOUT, value) + } } } - } override fun removeScreenLockTimeout() { screenLockTimeout = "" @@ -326,14 +345,15 @@ class AppPreferencesImpl(val context: Context) : AppPreferences { return read.ifEmpty { default } } - override fun setTheme(value: String?) = runBlocking { - async { - if (value != null) { - val key = context.resources.getString(R.string.nc_settings_theme_key) - writeString(key, value) + override fun setTheme(value: String?) = + runBlocking { + async { + if (value != null) { + val key = context.resources.getString(R.string.nc_settings_theme_key) + writeString(key, value) + } } } - } override fun removeTheme() { theme = "" @@ -344,27 +364,30 @@ class AppPreferencesImpl(val context: Context) : AppPreferences { return read } - override fun setDbCypherToUpgrade(value: Boolean) = runBlocking { - async { - writeBoolean(DB_CYPHER_V4_UPGRADE, value) + override fun setDbCypherToUpgrade(value: Boolean) = + runBlocking { + async { + writeBoolean(DB_CYPHER_V4_UPGRADE, value) + } } - } override fun getIsDbRoomMigrated(): Boolean { return runBlocking { async { readBoolean(DB_ROOM_MIGRATED).first() } }.getCompleted() } - override fun setIsDbRoomMigrated(value: Boolean) = runBlocking { - async { - writeBoolean(DB_ROOM_MIGRATED, value) + override fun setIsDbRoomMigrated(value: Boolean) = + runBlocking { + async { + writeBoolean(DB_ROOM_MIGRATED, value) + } } - } - override fun setPhoneBookIntegrationLastRun(currentTimeMillis: Long) = runBlocking { - async { - writeLong(PHONE_BOOK_INTEGRATION_LAST_RUN, currentTimeMillis) + override fun setPhoneBookIntegrationLastRun(currentTimeMillis: Long) = + runBlocking { + async { + writeLong(PHONE_BOOK_INTEGRATION_LAST_RUN, currentTimeMillis) + } } - } override fun getPhoneBookIntegrationLastRun(defaultValue: Long?): Long { val result = if (defaultValue != null) { @@ -376,36 +399,39 @@ class AppPreferencesImpl(val context: Context) : AppPreferences { return result } - override fun setReadPrivacy(value: Boolean) = runBlocking { - val key = context.resources.getString(R.string.nc_settings_read_privacy_key) - async { - writeBoolean(key, value) + override fun setReadPrivacy(value: Boolean) = + runBlocking { + val key = context.resources.getString(R.string.nc_settings_read_privacy_key) + async { + writeBoolean(key, value) + } } - } override fun getReadPrivacy(): Boolean { val key = context.resources.getString(R.string.nc_settings_read_privacy_key) return runBlocking { async { readBoolean(key).first() } }.getCompleted() } - override fun setTypingStatus(value: Boolean) = runBlocking { - async { - writeBoolean(TYPING_STATUS, value) + override fun setTypingStatus(value: Boolean) = + runBlocking { + async { + writeBoolean(TYPING_STATUS, value) + } } - } override fun getTypingStatus(): Boolean { return runBlocking { async { readBoolean(TYPING_STATUS).first() } }.getCompleted() } - override fun setSorting(value: String?) = runBlocking { - val key = context.resources.getString(R.string.nc_file_browser_sort_by_key) - async { - if (value != null) { - writeString(key, value) + override fun setSorting(value: String?) = + runBlocking { + val key = context.resources.getString(R.string.nc_file_browser_sort_by_key) + async { + if (value != null) { + writeString(key, value) + } } } - } override fun getSorting(): String { val key = context.resources.getString(R.string.nc_file_browser_sort_by_key) @@ -414,11 +440,12 @@ class AppPreferencesImpl(val context: Context) : AppPreferences { return read.ifEmpty { default } } - override fun saveWaveFormForFile(filename: String, array: Array) = runBlocking { - async { - writeString(filename, array.contentToString()) + override fun saveWaveFormForFile(filename: String, array: Array) = + runBlocking { + async { + writeString(filename, array.contentToString()) + } } - } override fun getWaveFormFromFile(filename: String): Array { val string = runBlocking { async { readString(filename).first() } }.getCompleted() @@ -427,29 +454,32 @@ class AppPreferencesImpl(val context: Context) : AppPreferences { override fun clear() {} - private suspend fun writeString(key: String, value: String) = context.dataStore.edit { settings -> - settings[ - stringPreferencesKey( - key - ) - ] = value - } + private suspend fun writeString(key: String, value: String) = + context.dataStore.edit { settings -> + settings[ + stringPreferencesKey( + key + ) + ] = value + } /** * Returns a Flow of type String * @param key the key of the persisted data to be observed */ - fun readString(key: String, defaultValue: String = ""): Flow = context.dataStore.data.map { preferences -> - preferences[stringPreferencesKey(key)] ?: defaultValue - } + fun readString(key: String, defaultValue: String = ""): Flow = + context.dataStore.data.map { preferences -> + preferences[stringPreferencesKey(key)] ?: defaultValue + } - private suspend fun writeBoolean(key: String, value: Boolean) = context.dataStore.edit { settings -> - settings[ - booleanPreferencesKey( - key - ) - ] = value - } + private suspend fun writeBoolean(key: String, value: Boolean) = + context.dataStore.edit { settings -> + settings[ + booleanPreferencesKey( + key + ) + ] = value + } /** * Returns a Flow of type Boolean @@ -460,17 +490,15 @@ class AppPreferencesImpl(val context: Context) : AppPreferences { preferences[booleanPreferencesKey(key)] ?: defaultValue } - private suspend fun writeLong(key: String, value: Long) = context.dataStore.edit { settings -> - settings[ - longPreferencesKey( - key - ) - ] = value - } + private suspend fun writeLong(key: String, value: Long) = + context.dataStore.edit { settings -> + settings[longPreferencesKey(key)] = value + } - private fun readLong(key: String, defaultValue: Long = 0): Flow = context.dataStore.data.map { preferences -> - preferences[longPreferencesKey(key)] ?: defaultValue - } + private fun readLong(key: String, defaultValue: Long = 0): Flow = + context.dataStore.data.map { preferences -> + preferences[longPreferencesKey(key)] ?: defaultValue + } companion object { @Suppress("UnusedPrivateProperty") diff --git a/app/src/main/java/com/nextcloud/talk/utils/ssl/SSLSocketFactoryCompat.kt b/app/src/main/java/com/nextcloud/talk/utils/ssl/SSLSocketFactoryCompat.kt index 56e6ec8118..48f37449ff 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/ssl/SSLSocketFactoryCompat.kt +++ b/app/src/main/java/com/nextcloud/talk/utils/ssl/SSLSocketFactoryCompat.kt @@ -55,11 +55,9 @@ class SSLSocketFactoryCompat( } } - override fun getDefaultCipherSuites(): Array? = cipherSuites - ?: delegate.defaultCipherSuites + override fun getDefaultCipherSuites(): Array? = cipherSuites ?: delegate.defaultCipherSuites - override fun getSupportedCipherSuites(): Array? = cipherSuites - ?: delegate.supportedCipherSuites + override fun getSupportedCipherSuites(): Array? = cipherSuites ?: delegate.supportedCipherSuites override fun createSocket(s: Socket, host: String, port: Int, autoClose: Boolean): Socket { val ssl = delegate.createSocket(s, host, port, autoClose) diff --git a/app/src/main/java/third/parties/fresco/BetterImageSpan.kt b/app/src/main/java/third/parties/fresco/BetterImageSpan.kt index fbd003ed0e..c4b7241d60 100644 --- a/app/src/main/java/third/parties/fresco/BetterImageSpan.kt +++ b/app/src/main/java/third/parties/fresco/BetterImageSpan.kt @@ -65,13 +65,7 @@ open class BetterImageSpan @JvmOverloads constructor( /** * Returns the width of the image span and increases the height if font metrics are available. */ - override fun getSize( - paint: Paint, - text: CharSequence, - start: Int, - end: Int, - fontMetrics: FontMetricsInt? - ): Int { + override fun getSize(paint: Paint, text: CharSequence, start: Int, end: Int, fontMetrics: FontMetricsInt?): Int { updateBounds() if (fontMetrics == null) { return mWidth diff --git a/app/src/test/java/com/nextcloud/talk/test/fakes/FakeCallRecordingRepository.kt b/app/src/test/java/com/nextcloud/talk/test/fakes/FakeCallRecordingRepository.kt index 1b91df4e8e..d88690de21 100644 --- a/app/src/test/java/com/nextcloud/talk/test/fakes/FakeCallRecordingRepository.kt +++ b/app/src/test/java/com/nextcloud/talk/test/fakes/FakeCallRecordingRepository.kt @@ -28,15 +28,11 @@ import io.reactivex.Observable class FakeCallRecordingRepository : CallRecordingRepository { - override fun startRecording( - roomToken: String - ): Observable { + override fun startRecording(roomToken: String): Observable { return Observable.just(StartCallRecordingModel(true)) } - override fun stopRecording( - roomToken: String - ): Observable { + override fun stopRecording(roomToken: String): Observable { return Observable.just(StopCallRecordingModel(true)) } } diff --git a/build.gradle b/build.gradle index 78a435a71a..6319e8d022 100644 --- a/build.gradle +++ b/build.gradle @@ -39,7 +39,7 @@ buildscript { classpath "org.jetbrains.kotlin:kotlin-serialization:${kotlinVersion}" classpath 'com.github.spotbugs.snom:spotbugs-gradle-plugin:6.0.2' classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.23.4" - classpath "org.jlleitschuh.gradle:ktlint-gradle:11.6.1" + classpath "org.jlleitschuh.gradle:ktlint-gradle:12.0.2" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/gradle.properties b/gradle.properties index 8c1fae9487..f560fcfbf9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -35,7 +35,6 @@ org.gradle.jvmargs=-XX:MaxHeapSize\=2048m -Xmx2048m android.useAndroidX=true android.enableJetifier=true -android.defaults.buildfeatures.buildconfig=true android.nonTransitiveRClass=false android.nonFinalResIds=false