Move @Suppress("DEPRECATION") closer to the deprecated usage. Will help to detect other deprecated API usage.

This commit is contained in:
Benoit Marty 2022-08-24 17:38:00 +02:00 committed by Benoit Marty
parent 24e4f94e61
commit 536b9cf926
9 changed files with 11 additions and 12 deletions

View file

@ -136,7 +136,6 @@ abstract class AttachmentViewerActivity : AppCompatActivity(), AttachmentEventLi
} }
} }
@Suppress("DEPRECATION")
private fun setDecorViewFullScreen() { private fun setDecorViewFullScreen() {
// This is important for the dispatchTouchEvent, if not we must correct // This is important for the dispatchTouchEvent, if not we must correct
// the touch coordinates // the touch coordinates
@ -155,11 +154,14 @@ abstract class AttachmentViewerActivity : AppCompatActivity(), AttachmentEventLi
// new API instead of FLAG_TRANSLUCENT_NAVIGATION // new API instead of FLAG_TRANSLUCENT_NAVIGATION
window.navigationBarColor = ContextCompat.getColor(this, R.color.half_transparent_status_bar) window.navigationBarColor = ContextCompat.getColor(this, R.color.half_transparent_status_bar)
} else { } else {
@Suppress("DEPRECATION")
window.decorView.systemUiVisibility = ( window.decorView.systemUiVisibility = (
View.SYSTEM_UI_FLAG_LAYOUT_STABLE View.SYSTEM_UI_FLAG_LAYOUT_STABLE
or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
or View.SYSTEM_UI_FLAG_IMMERSIVE) or View.SYSTEM_UI_FLAG_IMMERSIVE)
@Suppress("DEPRECATION")
window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS) 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) window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION)
} }
} }
@ -344,7 +346,6 @@ abstract class AttachmentViewerActivity : AppCompatActivity(), AttachmentEventLi
?.handleCommand(commands) ?.handleCommand(commands)
} }
@Suppress("DEPRECATION")
private fun hideSystemUI() { private fun hideSystemUI() {
systemUiVisibility = false systemUiVisibility = false
// Enables regular immersive mode. // Enables regular immersive mode.
@ -367,6 +368,7 @@ abstract class AttachmentViewerActivity : AppCompatActivity(), AttachmentEventLi
// New API instead of FLAG_TRANSLUCENT_NAVIGATION // New API instead of FLAG_TRANSLUCENT_NAVIGATION
window.navigationBarColor = ContextCompat.getColor(this, R.color.half_transparent_status_bar) window.navigationBarColor = ContextCompat.getColor(this, R.color.half_transparent_status_bar)
} else { } else {
@Suppress("DEPRECATION")
window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_IMMERSIVE window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_IMMERSIVE
// Set the content to appear under the system bars so that the // Set the content to appear under the system bars so that the
// content doesn't resize when the system bars hide and show. // 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 // Shows the system bars by removing all the flags
// except for the ones that make the content appear under the system bars. // except for the ones that make the content appear under the system bars.
@Suppress("DEPRECATION")
private fun showSystemUI() { private fun showSystemUI() {
systemUiVisibility = true systemUiVisibility = true
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { 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 // New API instead of SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN and SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
window.setDecorFitsSystemWindows(false) window.setDecorFitsSystemWindows(false)
} else { } else {
@Suppress("DEPRECATION")
window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_LAYOUT_STABLE window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_LAYOUT_STABLE
or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN) or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN)

View file

@ -104,7 +104,6 @@ internal class DefaultLegacySessionImporter @Inject constructor(
} }
private suspend fun importCredentials(legacyConfig: LegacyHomeServerConnectionConfig) { private suspend fun importCredentials(legacyConfig: LegacyHomeServerConnectionConfig) {
@Suppress("DEPRECATION")
val sessionParams = SessionParams( val sessionParams = SessionParams(
credentials = Credentials( credentials = Credentials(
userId = legacyConfig.credentials.userId, userId = legacyConfig.credentials.userId,

View file

@ -92,7 +92,6 @@ private fun useMediaStoreScreenshotStorage(
} }
} }
@Suppress("DEPRECATION")
private fun usePublicExternalScreenshotStorage( private fun usePublicExternalScreenshotStorage(
contentValues: ContentValues, contentValues: ContentValues,
contentResolver: ContentResolver, contentResolver: ContentResolver,

View file

@ -91,7 +91,6 @@ fun Context.safeOpenOutputStream(uri: Uri): OutputStream? {
* *
* @return true if no active connection is found * @return true if no active connection is found
*/ */
@Suppress("deprecation")
@SuppressLint("NewApi") // false positive @SuppressLint("NewApi") // false positive
fun Context.inferNoConnectivity(sdkIntProvider: BuildVersionSdkIntProvider): Boolean { fun Context.inferNoConnectivity(sdkIntProvider: BuildVersionSdkIntProvider): Boolean {
val connectivityManager = getSystemService<ConnectivityManager>()!! val connectivityManager = getSystemService<ConnectivityManager>()!!
@ -104,6 +103,7 @@ fun Context.inferNoConnectivity(sdkIntProvider: BuildVersionSdkIntProvider): Boo
else -> true else -> true
} }
} else { } else {
@Suppress("DEPRECATION")
when (connectivityManager.activeNetworkInfo?.type) { when (connectivityManager.activeNetworkInfo?.type) {
ConnectivityManager.TYPE_WIFI -> false ConnectivityManager.TYPE_WIFI -> false
ConnectivityManager.TYPE_MOBILE -> false ConnectivityManager.TYPE_MOBILE -> false

View file

@ -464,7 +464,6 @@ abstract class VectorBaseActivity<VB : ViewBinding> : AppCompatActivity(), Maver
/** /**
* Force to render the activity in fullscreen. * Force to render the activity in fullscreen.
*/ */
@Suppress("DEPRECATION")
private fun setFullScreen() { private fun setFullScreen() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { 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 // New API instead of SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN and SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
@ -481,6 +480,7 @@ abstract class VectorBaseActivity<VB : ViewBinding> : AppCompatActivity(), Maver
// New API instead of FLAG_TRANSLUCENT_NAVIGATION // New API instead of FLAG_TRANSLUCENT_NAVIGATION
window.navigationBarColor = ContextCompat.getColor(this, im.vector.lib.attachmentviewer.R.color.half_transparent_status_bar) window.navigationBarColor = ContextCompat.getColor(this, im.vector.lib.attachmentviewer.R.color.half_transparent_status_bar)
} else { } else {
@Suppress("DEPRECATION")
window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_LAYOUT_STABLE window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_LAYOUT_STABLE
or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN

View file

@ -309,7 +309,6 @@ suspend fun saveMedia(
} }
} }
@Suppress("DEPRECATION")
private fun saveMediaLegacy( private fun saveMediaLegacy(
context: Context, context: Context,
mediaMimeType: String?, mediaMimeType: String?,
@ -340,6 +339,7 @@ private fun saveMediaLegacy(
val savedFile = saveFileIntoLegacy(file, downloadDir, outputFilename, currentTimeMillis) val savedFile = saveFileIntoLegacy(file, downloadDir, outputFilename, currentTimeMillis)
if (savedFile != null) { if (savedFile != null) {
val downloadManager = context.getSystemService<DownloadManager>() val downloadManager = context.getSystemService<DownloadManager>()
@Suppress("DEPRECATION")
downloadManager?.addCompletedDownload( downloadManager?.addCompletedDownload(
savedFile.name, savedFile.name,
title, title,
@ -430,7 +430,6 @@ fun selectTxtFileToWrite(
* @param currentTimeMillis the current time in milliseconds * @param currentTimeMillis the current time in milliseconds
* @return the created file * @return the created file
*/ */
@Suppress("DEPRECATION")
fun saveFileIntoLegacy(sourceFile: File, dstDirPath: File, outputFilename: String?, currentTimeMillis: Long): File? { fun saveFileIntoLegacy(sourceFile: File, dstDirPath: File, outputFilename: String?, currentTimeMillis: Long): File? {
// defines another name for the external media // defines another name for the external media
var dstFileName: String var dstFileName: String

View file

@ -169,11 +169,11 @@ class AttachmentsPreviewFragment :
) )
} }
@Suppress("DEPRECATION")
private fun applyInsets() { private fun applyInsets() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
activity?.window?.setDecorFitsSystemWindows(false) activity?.window?.setDecorFitsSystemWindows(false)
} else { } else {
@Suppress("DEPRECATION")
view?.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION view?.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
} }
ViewCompat.setOnApplyWindowInsetsListener(views.attachmentPreviewerBottomContainer) { v, insets -> ViewCompat.setOnApplyWindowInsetsListener(views.attachmentPreviewerBottomContainer) { v, insets ->

View file

@ -92,7 +92,6 @@ class VectorActivityLifecycleCallbacks constructor(private val popupAlertManager
* @return true if an app task is corrupted by a potentially malicious activity * @return true if an app task is corrupted by a potentially malicious activity
*/ */
@SuppressLint("NewApi") @SuppressLint("NewApi")
@Suppress("DEPRECATION")
private suspend fun isTaskCorrupted(activity: Activity): Boolean = withContext(Dispatchers.Default) { private suspend fun isTaskCorrupted(activity: Activity): Boolean = withContext(Dispatchers.Default) {
val context = activity.applicationContext val context = activity.applicationContext
val packageManager: PackageManager = context.packageManager 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! // This was present in ActivityManager.RunningTaskInfo class since API level 1!
// and it is inherited from TaskInfo since Android Q (API level 29). // 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 // API 29 changes : https://developer.android.com/sdk/api_diff/29/changes/android.app.ActivityManager.RunningTaskInfo
@Suppress("DEPRECATION")
manager.getRunningTasks(10).any { runningTaskInfo -> manager.getRunningTasks(10).any { runningTaskInfo ->
runningTaskInfo.topActivity?.let { runningTaskInfo.topActivity?.let {
// Check whether the activity task affinity matches with app task affinity. // Check whether the activity task affinity matches with app task affinity.

View file

@ -50,10 +50,10 @@ class FallbackBiometricDialogFragment : DialogFragment(R.layout.fragment_biometr
private val parsedArgs by args<Args>() private val parsedArgs by args<Args>()
@Suppress("DEPRECATION")
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
@Suppress("DEPRECATION")
retainInstance = true retainInstance = true
setStyle(STYLE_NORMAL, android.R.style.Theme_Material_Light_Dialog) setStyle(STYLE_NORMAL, android.R.style.Theme_Material_Light_Dialog)