From ea274c4df60dadf4dadb7f4e748e1df59f01806c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 10 Aug 2022 23:11:34 +0000 Subject: [PATCH 01/19] Bump appcompat from 1.4.2 to 1.5.0 Bumps appcompat from 1.4.2 to 1.5.0. --- updated-dependencies: - dependency-name: androidx.appcompat:appcompat dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- dependencies.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dependencies.gradle b/dependencies.gradle index 9641a63f26..6b827e834e 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -51,7 +51,7 @@ ext.libs = [ ], androidx : [ 'activity' : "androidx.activity:activity:1.5.1", - 'appCompat' : "androidx.appcompat:appcompat:1.4.2", + 'appCompat' : "androidx.appcompat:appcompat:1.5.0", 'biometric' : "androidx.biometric:biometric:1.1.0", 'core' : "androidx.core:core-ktx:1.8.0", 'recyclerview' : "androidx.recyclerview:recyclerview:1.2.1", From d9ee51a2122aaed30b1a2b85fc7befdd495909ed Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 17 Aug 2022 13:16:52 +0000 Subject: [PATCH 02/19] Bump emoji2 from 1.1.0 to 1.2.0 Bumps emoji2 from 1.1.0 to 1.2.0. --- updated-dependencies: - dependency-name: androidx.emoji2:emoji2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- vector/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vector/build.gradle b/vector/build.gradle index ac3699454c..740f2710c0 100644 --- a/vector/build.gradle +++ b/vector/build.gradle @@ -232,7 +232,7 @@ dependencies { // UnifiedPush implementation 'com.github.UnifiedPush:android-connector:2.0.1' - implementation "androidx.emoji2:emoji2:1.1.0" + implementation "androidx.emoji2:emoji2:1.2.0" // WebRTC // org.webrtc:google-webrtc is for development purposes only From 8b64bd38b72b72beb49b7849058fde796e1f9a0c Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 24 Aug 2022 16:32:05 +0200 Subject: [PATCH 03/19] 'compileSdk': 32, 'targetSdk': 32 --- dependencies.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dependencies.gradle b/dependencies.gradle index 6b827e834e..8a93950c15 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -1,8 +1,8 @@ ext.versions = [ 'minSdk' : 21, - 'compileSdk' : 31, - 'targetSdk' : 31, + 'compileSdk' : 32, + 'targetSdk' : 32, 'sourceCompat' : JavaVersion.VERSION_11, 'targetCompat' : JavaVersion.VERSION_11, ] From 3f3c83a43d8f380f93c3f315e9381633414b1a20 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 24 Aug 2022 17:03:38 +0200 Subject: [PATCH 04/19] Remove deprecated internal class. --- .../send/queue/EventSenderProcessorThread.kt | 235 ------------------ 1 file changed, 235 deletions(-) delete mode 100644 matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/EventSenderProcessorThread.kt diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/EventSenderProcessorThread.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/EventSenderProcessorThread.kt deleted file mode 100644 index 55363a7251..0000000000 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/EventSenderProcessorThread.kt +++ /dev/null @@ -1,235 +0,0 @@ -/* - * Copyright 2020 The Matrix.org Foundation C.I.C. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.matrix.android.sdk.internal.session.room.send.queue - -import kotlinx.coroutines.CancellationException -import kotlinx.coroutines.launch -import kotlinx.coroutines.runBlocking -import org.matrix.android.sdk.api.auth.data.SessionParams -import org.matrix.android.sdk.api.auth.data.sessionId -import org.matrix.android.sdk.api.extensions.tryOrNull -import org.matrix.android.sdk.api.failure.Failure -import org.matrix.android.sdk.api.failure.isLimitExceededError -import org.matrix.android.sdk.api.failure.isTokenError -import org.matrix.android.sdk.api.session.Session -import org.matrix.android.sdk.api.session.crypto.CryptoService -import org.matrix.android.sdk.api.session.events.model.Event -import org.matrix.android.sdk.api.session.sync.SyncState -import org.matrix.android.sdk.api.util.Cancelable -import org.matrix.android.sdk.internal.session.SessionScope -import org.matrix.android.sdk.internal.task.TaskExecutor -import timber.log.Timber -import java.io.IOException -import java.util.Timer -import java.util.TimerTask -import java.util.concurrent.LinkedBlockingQueue -import javax.inject.Inject -import kotlin.concurrent.schedule - -/** - * A simple ever running thread unique for that session responsible of sending events in order. - * Each send is retried 3 times, if there is no network (e.g if cannot ping homeserver) it will wait and - * periodically test reachability before resume (does not count as a retry) - * - * If the app is killed before all event were sent, on next wakeup the scheduled events will be re posted - */ -@Deprecated("You should know use EventSenderProcessorCoroutine instead") -@SessionScope -internal class EventSenderProcessorThread @Inject constructor( - private val cryptoService: CryptoService, - private val sessionParams: SessionParams, - private val queuedTaskFactory: QueuedTaskFactory, - private val taskExecutor: TaskExecutor, - private val memento: QueueMemento -) : Thread("Matrix-SENDER_THREAD_SID_${sessionParams.credentials.sessionId()}"), EventSenderProcessor { - - private fun markAsManaged(task: QueuedTask) { - memento.track(task) - } - - private fun markAsFinished(task: QueuedTask) { - memento.unTrack(task) - } - - override fun onSessionStarted(session: Session) { - start() - } - - override fun onSessionStopped(session: Session) { - interrupt() - } - - override fun start() { - super.start() - // We should check for sending events not handled because app was killed - // But we should be careful of only took those that was submitted to us, because if it's - // for example it's a media event it is handled by some worker and he will handle it - // This is a bit fragile :/ - // also some events cannot be retried manually by users, e.g reactions - // they were previously relying on workers to do the work :/ and was expected to always finally succeed - // Also some echos are not to be resent like redaction echos (fake event created for aggregation) - - tryOrNull { - taskExecutor.executorScope.launch { - Timber.d("## Send relaunched pending events on restart") - memento.restoreTasks(this@EventSenderProcessorThread) - } - } - } - - // API - override fun postEvent(event: Event): Cancelable { - return postEvent(event, event.roomId?.let { cryptoService.isRoomEncrypted(it) } ?: false) - } - - override fun postEvent(event: Event, encrypt: Boolean): Cancelable { - val task = queuedTaskFactory.createSendTask(event, encrypt) - return postTask(task) - } - - override fun postRedaction(redactionLocalEcho: Event, reason: String?): Cancelable { - return postRedaction(redactionLocalEcho.eventId!!, redactionLocalEcho.redacts!!, redactionLocalEcho.roomId!!, reason) - } - - override fun postRedaction(redactionLocalEchoId: String, eventToRedactId: String, roomId: String, reason: String?): Cancelable { - val task = queuedTaskFactory.createRedactTask(redactionLocalEchoId, eventToRedactId, roomId, reason) - return postTask(task) - } - - override fun postTask(task: QueuedTask): Cancelable { - // non blocking add to queue - sendingQueue.add(task) - markAsManaged(task) - return task - } - - override fun cancel(eventId: String, roomId: String) { - (currentTask as? SendEventQueuedTask) - ?.takeIf { it.event.eventId == eventId && it.event.roomId == roomId } - ?.cancel() - } - - companion object { - private const val RETRY_WAIT_TIME_MS = 10_000L - } - - private var currentTask: QueuedTask? = null - - private var sendingQueue = LinkedBlockingQueue() - - private var networkAvailableLock = Object() - private var canReachServer = true - private var retryNoNetworkTask: TimerTask? = null - - override fun run() { - Timber.v("## SendThread started") - try { - while (!isInterrupted) { - Timber.v("## SendThread wait for task to process") - val task = sendingQueue.take() - .also { currentTask = it } - Timber.v("## SendThread Found task to process $task") - - if (task.isCancelled()) { - Timber.v("## SendThread send cancelled for $task") - // we do not execute this one - continue - } - // we check for network connectivity - while (!canReachServer) { - Timber.v("## SendThread cannot reach server") - // schedule to retry - waitForNetwork() - // if thread as been killed meanwhile -// if (state == State.KILLING) break - } - Timber.v("## Server is Reachable") - // so network is available - - runBlocking { - retryLoop@ while (task.retryCount.get() < 3) { - try { - // SendPerformanceProfiler.startStage(task.event.eventId!!, SendPerformanceProfiler.Stages.SEND_WORKER) - Timber.v("## SendThread retryLoop for $task retryCount ${task.retryCount}") - task.execute() - // sendEventTask.execute(SendEventTask.Params(task.event, task.encrypt, cryptoService)) - // SendPerformanceProfiler.stopStage(task.event.eventId, SendPerformanceProfiler.Stages.SEND_WORKER) - break@retryLoop - } catch (exception: Throwable) { - when { - exception is IOException || exception is Failure.NetworkConnection -> { - canReachServer = false - if (task.retryCount.getAndIncrement() >= 3) task.onTaskFailed() - while (!canReachServer) { - Timber.v("## SendThread retryLoop cannot reach server") - // schedule to retry - waitForNetwork() - } - } - (exception.isLimitExceededError()) -> { - if (task.retryCount.getAndIncrement() >= 3) task.onTaskFailed() - Timber.v("## SendThread retryLoop retryable error for $task reason: ${exception.localizedMessage}") - // wait a bit - // Todo if its a quota exception can we get timout? - sleep(3_000) - continue@retryLoop - } - exception.isTokenError() -> { - Timber.v("## SendThread retryLoop retryable TOKEN error, interrupt") - // we can exit the loop - task.onTaskFailed() - throw InterruptedException() - } - exception is CancellationException -> { - Timber.v("## SendThread task has been cancelled") - break@retryLoop - } - else -> { - Timber.v("## SendThread retryLoop Un-Retryable error, try next task") - // this task is in error, check next one? - task.onTaskFailed() - break@retryLoop - } - } - } - } - } - markAsFinished(task) - } - } catch (interruptionException: InterruptedException) { - // will be thrown is thread is interrupted while seeping - interrupt() - Timber.v("## InterruptedException!! ${interruptionException.localizedMessage}") - } -// state = State.KILLED - // is this needed? - retryNoNetworkTask?.cancel() - Timber.w("## SendThread finished") - } - - private fun waitForNetwork() { - retryNoNetworkTask = Timer(SyncState.NoNetwork.toString(), false).schedule(RETRY_WAIT_TIME_MS) { - synchronized(networkAvailableLock) { - canReachServer = HomeServerAvailabilityChecker(sessionParams).check().also { - Timber.v("## SendThread checkHostAvailable $it") - } - networkAvailableLock.notify() - } - } - synchronized(networkAvailableLock) { networkAvailableLock.wait() } - } -} From 24e4f94e61a3da054f842450f32f57a17aea0359 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 24 Aug 2022 17:30:36 +0200 Subject: [PATCH 05/19] Stop using deprecated method. --- .../uploads/media/RoomUploadsMediaFragment.kt | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/roomprofile/uploads/media/RoomUploadsMediaFragment.kt b/vector/src/main/java/im/vector/app/features/roomprofile/uploads/media/RoomUploadsMediaFragment.kt index f53f572e38..98a28557ae 100644 --- a/vector/src/main/java/im/vector/app/features/roomprofile/uploads/media/RoomUploadsMediaFragment.kt +++ b/vector/src/main/java/im/vector/app/features/roomprofile/uploads/media/RoomUploadsMediaFragment.kt @@ -82,15 +82,18 @@ class RoomUploadsMediaFragment : controller.listener = this } - @Suppress("DEPRECATION") private fun getNumberOfColumns(): Int { - val displayMetrics = DisplayMetrics() - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { - requireContext().display?.getMetrics(displayMetrics) + val screenWidthInPx = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + val a = requireActivity().windowManager.currentWindowMetrics + a.bounds.width() } else { + val displayMetrics = DisplayMetrics() + @Suppress("DEPRECATION") requireActivity().windowManager.defaultDisplay.getMetrics(displayMetrics) + displayMetrics.widthPixels } - return dimensionConverter.pxToDp(displayMetrics.widthPixels) / IMAGE_SIZE_DP + val screenWidthInDp = dimensionConverter.pxToDp(screenWidthInPx) + return screenWidthInDp / IMAGE_SIZE_DP } override fun onDestroyView() { From 536b9cf926bb9ca285a49a81a93fb91b1c78e322 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 24 Aug 2022 17:38:00 +0200 Subject: [PATCH 06/19] Move `@Suppress("DEPRECATION")` closer to the deprecated usage. Will help to detect other deprecated API usage. --- .../lib/attachmentviewer/AttachmentViewerActivity.kt | 8 +++++--- .../sdk/internal/legacy/DefaultLegacySessionImporter.kt | 1 - .../im/vector/app/espresso/tools/ScreenshotFailureRule.kt | 1 - .../main/java/im/vector/app/core/extensions/Context.kt | 2 +- .../im/vector/app/core/platform/VectorBaseActivity.kt | 2 +- .../im/vector/app/core/utils/ExternalApplicationsUtil.kt | 3 +-- .../attachments/preview/AttachmentsPreviewFragment.kt | 2 +- .../lifecycle/VectorActivityLifecycleCallbacks.kt | 2 +- .../ui/fallbackprompt/FallbackBiometricDialogFragment.kt | 2 +- 9 files changed, 11 insertions(+), 12 deletions(-) diff --git a/library/attachment-viewer/src/main/java/im/vector/lib/attachmentviewer/AttachmentViewerActivity.kt b/library/attachment-viewer/src/main/java/im/vector/lib/attachmentviewer/AttachmentViewerActivity.kt index 764cf8419a..0e8590f386 100644 --- a/library/attachment-viewer/src/main/java/im/vector/lib/attachmentviewer/AttachmentViewerActivity.kt +++ b/library/attachment-viewer/src/main/java/im/vector/lib/attachmentviewer/AttachmentViewerActivity.kt @@ -136,7 +136,6 @@ abstract class AttachmentViewerActivity : AppCompatActivity(), AttachmentEventLi } } - @Suppress("DEPRECATION") private fun setDecorViewFullScreen() { // This is important for the dispatchTouchEvent, if not we must correct // the touch coordinates @@ -155,11 +154,14 @@ abstract class AttachmentViewerActivity : AppCompatActivity(), AttachmentEventLi // new API instead of FLAG_TRANSLUCENT_NAVIGATION window.navigationBarColor = ContextCompat.getColor(this, R.color.half_transparent_status_bar) } else { + @Suppress("DEPRECATION") window.decorView.systemUiVisibility = ( View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_IMMERSIVE) + @Suppress("DEPRECATION") window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS) + @Suppress("DEPRECATION") window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION) } } @@ -344,7 +346,6 @@ abstract class AttachmentViewerActivity : AppCompatActivity(), AttachmentEventLi ?.handleCommand(commands) } - @Suppress("DEPRECATION") private fun hideSystemUI() { systemUiVisibility = false // Enables regular immersive mode. @@ -367,6 +368,7 @@ abstract class AttachmentViewerActivity : AppCompatActivity(), AttachmentEventLi // New API instead of FLAG_TRANSLUCENT_NAVIGATION window.navigationBarColor = ContextCompat.getColor(this, R.color.half_transparent_status_bar) } else { + @Suppress("DEPRECATION") window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_IMMERSIVE // Set the content to appear under the system bars so that the // content doesn't resize when the system bars hide and show. @@ -381,13 +383,13 @@ abstract class AttachmentViewerActivity : AppCompatActivity(), AttachmentEventLi // Shows the system bars by removing all the flags // except for the ones that make the content appear under the system bars. - @Suppress("DEPRECATION") private fun showSystemUI() { systemUiVisibility = true if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { // New API instead of SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN and SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION window.setDecorFitsSystemWindows(false) } else { + @Suppress("DEPRECATION") window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/legacy/DefaultLegacySessionImporter.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/legacy/DefaultLegacySessionImporter.kt index 7d52d9b2bf..567f605643 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/legacy/DefaultLegacySessionImporter.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/legacy/DefaultLegacySessionImporter.kt @@ -104,7 +104,6 @@ internal class DefaultLegacySessionImporter @Inject constructor( } private suspend fun importCredentials(legacyConfig: LegacyHomeServerConnectionConfig) { - @Suppress("DEPRECATION") val sessionParams = SessionParams( credentials = Credentials( userId = legacyConfig.credentials.userId, diff --git a/vector-app/src/androidTest/java/im/vector/app/espresso/tools/ScreenshotFailureRule.kt b/vector-app/src/androidTest/java/im/vector/app/espresso/tools/ScreenshotFailureRule.kt index 068c9fb646..5e131479bf 100644 --- a/vector-app/src/androidTest/java/im/vector/app/espresso/tools/ScreenshotFailureRule.kt +++ b/vector-app/src/androidTest/java/im/vector/app/espresso/tools/ScreenshotFailureRule.kt @@ -92,7 +92,6 @@ private fun useMediaStoreScreenshotStorage( } } -@Suppress("DEPRECATION") private fun usePublicExternalScreenshotStorage( contentValues: ContentValues, contentResolver: ContentResolver, diff --git a/vector/src/main/java/im/vector/app/core/extensions/Context.kt b/vector/src/main/java/im/vector/app/core/extensions/Context.kt index 14e639bf32..1ed5aa8ba1 100644 --- a/vector/src/main/java/im/vector/app/core/extensions/Context.kt +++ b/vector/src/main/java/im/vector/app/core/extensions/Context.kt @@ -91,7 +91,6 @@ fun Context.safeOpenOutputStream(uri: Uri): OutputStream? { * * @return true if no active connection is found */ -@Suppress("deprecation") @SuppressLint("NewApi") // false positive fun Context.inferNoConnectivity(sdkIntProvider: BuildVersionSdkIntProvider): Boolean { val connectivityManager = getSystemService()!! @@ -104,6 +103,7 @@ fun Context.inferNoConnectivity(sdkIntProvider: BuildVersionSdkIntProvider): Boo else -> true } } else { + @Suppress("DEPRECATION") when (connectivityManager.activeNetworkInfo?.type) { ConnectivityManager.TYPE_WIFI -> false ConnectivityManager.TYPE_MOBILE -> false diff --git a/vector/src/main/java/im/vector/app/core/platform/VectorBaseActivity.kt b/vector/src/main/java/im/vector/app/core/platform/VectorBaseActivity.kt index c2c66ae69e..cb8c0ec8d1 100644 --- a/vector/src/main/java/im/vector/app/core/platform/VectorBaseActivity.kt +++ b/vector/src/main/java/im/vector/app/core/platform/VectorBaseActivity.kt @@ -464,7 +464,6 @@ abstract class VectorBaseActivity : AppCompatActivity(), Maver /** * Force to render the activity in fullscreen. */ - @Suppress("DEPRECATION") private fun setFullScreen() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { // New API instead of SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN and SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION @@ -481,6 +480,7 @@ abstract class VectorBaseActivity : AppCompatActivity(), Maver // New API instead of FLAG_TRANSLUCENT_NAVIGATION window.navigationBarColor = ContextCompat.getColor(this, im.vector.lib.attachmentviewer.R.color.half_transparent_status_bar) } else { + @Suppress("DEPRECATION") window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN diff --git a/vector/src/main/java/im/vector/app/core/utils/ExternalApplicationsUtil.kt b/vector/src/main/java/im/vector/app/core/utils/ExternalApplicationsUtil.kt index d52b7088ff..915a8d4d0d 100644 --- a/vector/src/main/java/im/vector/app/core/utils/ExternalApplicationsUtil.kt +++ b/vector/src/main/java/im/vector/app/core/utils/ExternalApplicationsUtil.kt @@ -309,7 +309,6 @@ suspend fun saveMedia( } } -@Suppress("DEPRECATION") private fun saveMediaLegacy( context: Context, mediaMimeType: String?, @@ -340,6 +339,7 @@ private fun saveMediaLegacy( val savedFile = saveFileIntoLegacy(file, downloadDir, outputFilename, currentTimeMillis) if (savedFile != null) { val downloadManager = context.getSystemService() + @Suppress("DEPRECATION") downloadManager?.addCompletedDownload( savedFile.name, title, @@ -430,7 +430,6 @@ fun selectTxtFileToWrite( * @param currentTimeMillis the current time in milliseconds * @return the created file */ -@Suppress("DEPRECATION") fun saveFileIntoLegacy(sourceFile: File, dstDirPath: File, outputFilename: String?, currentTimeMillis: Long): File? { // defines another name for the external media var dstFileName: String diff --git a/vector/src/main/java/im/vector/app/features/attachments/preview/AttachmentsPreviewFragment.kt b/vector/src/main/java/im/vector/app/features/attachments/preview/AttachmentsPreviewFragment.kt index 47b19a435e..20b155d11e 100644 --- a/vector/src/main/java/im/vector/app/features/attachments/preview/AttachmentsPreviewFragment.kt +++ b/vector/src/main/java/im/vector/app/features/attachments/preview/AttachmentsPreviewFragment.kt @@ -169,11 +169,11 @@ class AttachmentsPreviewFragment : ) } - @Suppress("DEPRECATION") private fun applyInsets() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { activity?.window?.setDecorFitsSystemWindows(false) } else { + @Suppress("DEPRECATION") view?.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION } ViewCompat.setOnApplyWindowInsetsListener(views.attachmentPreviewerBottomContainer) { v, insets -> diff --git a/vector/src/main/java/im/vector/app/features/lifecycle/VectorActivityLifecycleCallbacks.kt b/vector/src/main/java/im/vector/app/features/lifecycle/VectorActivityLifecycleCallbacks.kt index 32b4bf3f12..75f02c36d7 100644 --- a/vector/src/main/java/im/vector/app/features/lifecycle/VectorActivityLifecycleCallbacks.kt +++ b/vector/src/main/java/im/vector/app/features/lifecycle/VectorActivityLifecycleCallbacks.kt @@ -92,7 +92,6 @@ class VectorActivityLifecycleCallbacks constructor(private val popupAlertManager * @return true if an app task is corrupted by a potentially malicious activity */ @SuppressLint("NewApi") - @Suppress("DEPRECATION") private suspend fun isTaskCorrupted(activity: Activity): Boolean = withContext(Dispatchers.Default) { val context = activity.applicationContext val packageManager: PackageManager = context.packageManager @@ -120,6 +119,7 @@ class VectorActivityLifecycleCallbacks constructor(private val popupAlertManager // This was present in ActivityManager.RunningTaskInfo class since API level 1! // and it is inherited from TaskInfo since Android Q (API level 29). // API 29 changes : https://developer.android.com/sdk/api_diff/29/changes/android.app.ActivityManager.RunningTaskInfo + @Suppress("DEPRECATION") manager.getRunningTasks(10).any { runningTaskInfo -> runningTaskInfo.topActivity?.let { // Check whether the activity task affinity matches with app task affinity. diff --git a/vector/src/main/java/im/vector/app/features/pin/lockscreen/ui/fallbackprompt/FallbackBiometricDialogFragment.kt b/vector/src/main/java/im/vector/app/features/pin/lockscreen/ui/fallbackprompt/FallbackBiometricDialogFragment.kt index d50ff791ed..c778e880b2 100644 --- a/vector/src/main/java/im/vector/app/features/pin/lockscreen/ui/fallbackprompt/FallbackBiometricDialogFragment.kt +++ b/vector/src/main/java/im/vector/app/features/pin/lockscreen/ui/fallbackprompt/FallbackBiometricDialogFragment.kt @@ -50,10 +50,10 @@ class FallbackBiometricDialogFragment : DialogFragment(R.layout.fragment_biometr private val parsedArgs by args() - @Suppress("DEPRECATION") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) + @Suppress("DEPRECATION") retainInstance = true setStyle(STYLE_NORMAL, android.R.style.Theme_Material_Light_Dialog) From e17f009566efde75dc02c12355a987400d763598 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 24 Aug 2022 17:54:28 +0200 Subject: [PATCH 07/19] Reduce level API check, this seems not necessary. --- .../lib/attachmentviewer/AttachmentViewerActivity.kt | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/library/attachment-viewer/src/main/java/im/vector/lib/attachmentviewer/AttachmentViewerActivity.kt b/library/attachment-viewer/src/main/java/im/vector/lib/attachmentviewer/AttachmentViewerActivity.kt index 0e8590f386..ca91ddb621 100644 --- a/library/attachment-viewer/src/main/java/im/vector/lib/attachmentviewer/AttachmentViewerActivity.kt +++ b/library/attachment-viewer/src/main/java/im/vector/lib/attachmentviewer/AttachmentViewerActivity.kt @@ -143,12 +143,7 @@ abstract class AttachmentViewerActivity : AppCompatActivity(), AttachmentEventLi // New API instead of SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN and SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION window.setDecorFitsSystemWindows(false) // New API instead of SYSTEM_UI_FLAG_IMMERSIVE - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { - window.decorView.windowInsetsController?.systemBarsBehavior = WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE - } else { - @SuppressLint("WrongConstant") - window.decorView.windowInsetsController?.systemBarsBehavior = WindowInsetsController.BEHAVIOR_SHOW_BARS_BY_SWIPE - } + window.decorView.windowInsetsController?.systemBarsBehavior = WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE // New API instead of FLAG_TRANSLUCENT_STATUS window.statusBarColor = ContextCompat.getColor(this, R.color.half_transparent_status_bar) // new API instead of FLAG_TRANSLUCENT_NAVIGATION From 518ec738f30e515777a231e39b51bd56060ad299 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 24 Aug 2022 17:59:46 +0200 Subject: [PATCH 08/19] Reduce level API check, this seems not necessary. --- .../lib/attachmentviewer/AttachmentViewerActivity.kt | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/library/attachment-viewer/src/main/java/im/vector/lib/attachmentviewer/AttachmentViewerActivity.kt b/library/attachment-viewer/src/main/java/im/vector/lib/attachmentviewer/AttachmentViewerActivity.kt index ca91ddb621..98398760d1 100644 --- a/library/attachment-viewer/src/main/java/im/vector/lib/attachmentviewer/AttachmentViewerActivity.kt +++ b/library/attachment-viewer/src/main/java/im/vector/lib/attachmentviewer/AttachmentViewerActivity.kt @@ -17,7 +17,6 @@ package im.vector.lib.attachmentviewer -import android.annotation.SuppressLint import android.graphics.Color import android.os.Build import android.os.Bundle @@ -352,12 +351,7 @@ abstract class AttachmentViewerActivity : AppCompatActivity(), AttachmentEventLi // new API instead of SYSTEM_UI_FLAG_HIDE_NAVIGATION window.decorView.windowInsetsController?.hide(WindowInsets.Type.navigationBars()) // New API instead of SYSTEM_UI_FLAG_IMMERSIVE - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { - window.decorView.windowInsetsController?.systemBarsBehavior = WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE - } else { - @SuppressLint("WrongConstant") - window.decorView.windowInsetsController?.systemBarsBehavior = WindowInsetsController.BEHAVIOR_SHOW_BARS_BY_SWIPE - } + window.decorView.windowInsetsController?.systemBarsBehavior = WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE // New API instead of FLAG_TRANSLUCENT_STATUS window.statusBarColor = ContextCompat.getColor(this, R.color.half_transparent_status_bar) // New API instead of FLAG_TRANSLUCENT_NAVIGATION From cde709692899df5e9c9050869bee9d6ab26a9d56 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 24 Aug 2022 18:02:42 +0200 Subject: [PATCH 09/19] Restore this annotation --- .../android/sdk/internal/legacy/DefaultLegacySessionImporter.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/legacy/DefaultLegacySessionImporter.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/legacy/DefaultLegacySessionImporter.kt index 567f605643..7d52d9b2bf 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/legacy/DefaultLegacySessionImporter.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/legacy/DefaultLegacySessionImporter.kt @@ -104,6 +104,7 @@ internal class DefaultLegacySessionImporter @Inject constructor( } private suspend fun importCredentials(legacyConfig: LegacyHomeServerConnectionConfig) { + @Suppress("DEPRECATION") val sessionParams = SessionParams( credentials = Credentials( userId = legacyConfig.credentials.userId, From 88482c9b2edc7ea50950b24cb697d75babb836ae Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 24 Aug 2022 18:06:38 +0200 Subject: [PATCH 10/19] Reduce level API check, this seems not necessary. --- .../im/vector/app/core/platform/VectorBaseActivity.kt | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/vector/src/main/java/im/vector/app/core/platform/VectorBaseActivity.kt b/vector/src/main/java/im/vector/app/core/platform/VectorBaseActivity.kt index cb8c0ec8d1..b4ba384f8f 100644 --- a/vector/src/main/java/im/vector/app/core/platform/VectorBaseActivity.kt +++ b/vector/src/main/java/im/vector/app/core/platform/VectorBaseActivity.kt @@ -16,7 +16,6 @@ package im.vector.app.core.platform -import android.annotation.SuppressLint import android.app.Activity import android.content.Context import android.os.Build @@ -469,12 +468,7 @@ abstract class VectorBaseActivity : AppCompatActivity(), Maver // New API instead of SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN and SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION window.setDecorFitsSystemWindows(false) // New API instead of SYSTEM_UI_FLAG_IMMERSIVE - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { - window.decorView.windowInsetsController?.systemBarsBehavior = WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE - } else { - @SuppressLint("WrongConstant") - window.decorView.windowInsetsController?.systemBarsBehavior = WindowInsetsController.BEHAVIOR_SHOW_BARS_BY_SWIPE - } + window.decorView.windowInsetsController?.systemBarsBehavior = WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE // New API instead of FLAG_TRANSLUCENT_STATUS window.statusBarColor = ContextCompat.getColor(this, im.vector.lib.attachmentviewer.R.color.half_transparent_status_bar) // New API instead of FLAG_TRANSLUCENT_NAVIGATION From 842a9bbd5595fc4901836f396f4b68047d6d99f4 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 24 Aug 2022 19:03:29 +0200 Subject: [PATCH 11/19] Add dataExtractionRules, applicable to Android 12. Exclude everything from being backed up. Also properly support Android 11. --- tools/lint/lint.xml | 1 + vector/src/main/AndroidManifest.xml | 10 +++++----- vector/src/main/res/xml/backup_rules.xml | 18 ++++++++++++++++++ .../src/main/res/xml/data_extraction_rules.xml | 17 +++++++++++++++++ 4 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 vector/src/main/res/xml/backup_rules.xml create mode 100644 vector/src/main/res/xml/data_extraction_rules.xml diff --git a/tools/lint/lint.xml b/tools/lint/lint.xml index b4b6ebc12f..1776bd341f 100644 --- a/tools/lint/lint.xml +++ b/tools/lint/lint.xml @@ -87,6 +87,7 @@ + diff --git a/vector/src/main/AndroidManifest.xml b/vector/src/main/AndroidManifest.xml index d60620dddf..c7c0d40dd7 100644 --- a/vector/src/main/AndroidManifest.xml +++ b/vector/src/main/AndroidManifest.xml @@ -318,12 +318,12 @@ - + - - - - + + + + diff --git a/vector/src/main/res/xml/backup_rules.xml b/vector/src/main/res/xml/backup_rules.xml new file mode 100644 index 0000000000..fe10b316ed --- /dev/null +++ b/vector/src/main/res/xml/backup_rules.xml @@ -0,0 +1,18 @@ + + + + + + + + diff --git a/vector/src/main/res/xml/data_extraction_rules.xml b/vector/src/main/res/xml/data_extraction_rules.xml new file mode 100644 index 0000000000..fe61eb717c --- /dev/null +++ b/vector/src/main/res/xml/data_extraction_rules.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + From c5571c06edf2145ecc13044efa248694ea77e990 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 25 Aug 2022 09:51:32 +0200 Subject: [PATCH 12/19] Upgrade gradle plugin from 7.1.3 to 7.2.2 --- dependencies.gradle | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/dependencies.gradle b/dependencies.gradle index 8a93950c15..a402ec3135 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -7,10 +7,7 @@ ext.versions = [ 'targetCompat' : JavaVersion.VERSION_11, ] - -// Pinned to 7.1.3 because of https://github.com/vector-im/element-android/issues/6142 -// Please test carefully before upgrading again. -def gradle = "7.1.3" +def gradle = "7.2.2" // Ref: https://kotlinlang.org/releases.html def kotlin = "1.6.21" def kotlinCoroutines = "1.6.4" From 57db43c80a78bf9474abcab8ca6dc58fefc0b22a Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 25 Aug 2022 11:30:06 +0200 Subject: [PATCH 13/19] Fix gradle warning: WARNING:API 'ApkVariantOutput.getVersionCodeOverride()' is obsolete and has been replaced with 'VariantOutput.versionCode()'. --- vector-app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vector-app/build.gradle b/vector-app/build.gradle index 82c433d2df..f0f1bb81b8 100644 --- a/vector-app/build.gradle +++ b/vector-app/build.gradle @@ -191,7 +191,7 @@ android { // Known limitation: it does not modify the value in the BuildConfig.java generated file // See https://issuetracker.google.com/issues/171133218 output.versionCodeOverride = baseVariantVersion + baseAbiVersionCode - print "ABI " + output.getFilter(OutputFile.ABI) + " \t-> VersionCode = " + output.versionCodeOverride + "\n" + print "ABI " + output.getFilter(OutputFile.ABI) + " \t-> VersionCode = " + output.versionCode + "\n" output.outputFileName = output.outputFileName.replace("vector-app", "vector") } } From 892484a1b306c5ff66b442ce85bf142849b37761 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 25 Aug 2022 11:54:29 +0200 Subject: [PATCH 14/19] Upgrade kotlin from 1.6.21 to 1.7.10 and dagger (+hilt) from 2.42 to 2.43.2 --- dependencies.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dependencies.gradle b/dependencies.gradle index a402ec3135..a9fe9b4eb2 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -9,9 +9,9 @@ ext.versions = [ def gradle = "7.2.2" // Ref: https://kotlinlang.org/releases.html -def kotlin = "1.6.21" +def kotlin = "1.7.10" def kotlinCoroutines = "1.6.4" -def dagger = "2.42" +def dagger = "2.43.2" def appDistribution = "16.0.0-beta04" def retrofit = "2.9.0" def arrow = "0.8.2" From 84afa4714a792d62e4506c6b4ad37b4df5b04b21 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 12 Sep 2022 17:32:42 +0200 Subject: [PATCH 15/19] App compat 1.5.1 --- dependencies.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dependencies.gradle b/dependencies.gradle index a9fe9b4eb2..b026e79768 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -48,7 +48,7 @@ ext.libs = [ ], androidx : [ 'activity' : "androidx.activity:activity:1.5.1", - 'appCompat' : "androidx.appcompat:appcompat:1.5.0", + 'appCompat' : "androidx.appcompat:appcompat:1.5.1", 'biometric' : "androidx.biometric:biometric:1.1.0", 'core' : "androidx.core:core-ktx:1.8.0", 'recyclerview' : "androidx.recyclerview:recyclerview:1.2.1", From a1f4ffbf172315a5906c59ab821ab907d5cc2135 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Fri, 16 Sep 2022 23:12:48 +0200 Subject: [PATCH 16/19] Use vanniktechEmoji "0.16.0-SNAPSHOT" --- build.gradle | 8 ++++++++ dependencies.gradle | 4 +++- dependencies_groups.gradle | 9 ++++++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 49dc1e7fb4..d8de6dd55f 100644 --- a/build.gradle +++ b/build.gradle @@ -71,6 +71,14 @@ allprojects { groups.mavenCentral.group.each { includeGroup it } } } + // snapshots repository + maven { + url "https://oss.sonatype.org/content/repositories/snapshots" + content { + groups.snapshot.regex.each { includeGroupByRegex it } + groups.snapshot.group.each { includeGroup it } + } + } maven { url 'https://jitpack.io' content { diff --git a/dependencies.gradle b/dependencies.gradle index b026e79768..fd758dd859 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -25,7 +25,9 @@ def mavericks = "2.7.0" def glide = "4.13.2" def bigImageViewer = "1.8.1" def jjwt = "0.11.5" -def vanniktechEmoji = "0.15.0" +// Temporary version to unblock #6929. Once 0.16.0 is released we should use it, and revert +// the whole commit which set version 0.16.0-SNAPSHOT +def vanniktechEmoji = "0.16.0-SNAPSHOT" def fragment = "1.5.2" diff --git a/dependencies_groups.gradle b/dependencies_groups.gradle index 433bc53568..e44e0bc5c2 100644 --- a/dependencies_groups.gradle +++ b/dependencies_groups.gradle @@ -38,6 +38,13 @@ ext.groups = [ 'com.google.testing.platform', ] ], + snapshot: [ + regex: [ + ], + group: [ + 'com.vanniktech', + ] + ], mavenCentral: [ regex: [ ], @@ -118,7 +125,7 @@ ext.groups = [ 'com.sun.xml.bind.mvn', 'com.sun.xml.fastinfoset', 'com.thoughtworks.qdox', - 'com.vanniktech', + // 'com.vanniktech', 'commons-cli', 'commons-codec', 'commons-io', From d4eb619d4022f7e4be139e164df746693d2de812 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Fri, 16 Sep 2022 23:30:20 +0200 Subject: [PATCH 17/19] Changelog --- changelog.d/6929.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/6929.misc diff --git a/changelog.d/6929.misc b/changelog.d/6929.misc new file mode 100644 index 0000000000..d12167cfea --- /dev/null +++ b/changelog.d/6929.misc @@ -0,0 +1 @@ +Target API 12 and compile with Android SDK 32. From c91ba06285419c2122ce2c7fa539531593e9bb4c Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 19 Sep 2022 10:50:15 +0200 Subject: [PATCH 18/19] Fix lint warnings, some code has vanished dur to the rebasing of the branch... --- vector-app/src/main/AndroidManifest.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vector-app/src/main/AndroidManifest.xml b/vector-app/src/main/AndroidManifest.xml index bff594c0de..2767b20404 100644 --- a/vector-app/src/main/AndroidManifest.xml +++ b/vector-app/src/main/AndroidManifest.xml @@ -6,6 +6,8 @@ Date: Mon, 19 Sep 2022 11:56:40 +0200 Subject: [PATCH 19/19] Move xml resource in the module where they are used to avoid lint false positive `UnusedResources` issues. --- {vector => vector-app}/src/main/res/xml/backup_rules.xml | 0 {vector => vector-app}/src/main/res/xml/data_extraction_rules.xml | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename {vector => vector-app}/src/main/res/xml/backup_rules.xml (100%) rename {vector => vector-app}/src/main/res/xml/data_extraction_rules.xml (100%) diff --git a/vector/src/main/res/xml/backup_rules.xml b/vector-app/src/main/res/xml/backup_rules.xml similarity index 100% rename from vector/src/main/res/xml/backup_rules.xml rename to vector-app/src/main/res/xml/backup_rules.xml diff --git a/vector/src/main/res/xml/data_extraction_rules.xml b/vector-app/src/main/res/xml/data_extraction_rules.xml similarity index 100% rename from vector/src/main/res/xml/data_extraction_rules.xml rename to vector-app/src/main/res/xml/data_extraction_rules.xml