Update deprecated API usage

Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
alperozturk 2023-11-09 12:30:16 +01:00
parent 618745fa42
commit c76803fe62
No known key found for this signature in database
GPG key ID: 4E577DC593B59BDF

View file

@ -32,6 +32,7 @@ import androidx.core.content.ContextCompat
import androidx.core.graphics.drawable.DrawableCompat
import com.canhub.cropper.CropImageView
import com.nextcloud.client.di.Injectable
import com.nextcloud.utils.extensions.getParcelableArgument
import com.owncloud.android.R
import com.owncloud.android.databinding.ActivityEditImageBinding
import com.owncloud.android.datamodel.OCFile
@ -80,7 +81,7 @@ class EditImageActivity :
binding = ActivityEditImageBinding.inflate(layoutInflater)
setContentView(binding.root)
file = intent.extras?.getParcelable(EXTRA_FILE) ?: throw IllegalArgumentException("Missing file argument")
file = intent.extras?.getParcelableArgument(EXTRA_FILE, OCFile::class.java) ?: throw IllegalArgumentException("Missing file argument")
setSupportActionBar(binding.toolbar)
supportActionBar?.apply {
@ -90,7 +91,12 @@ class EditImageActivity :
window.statusBarColor = ContextCompat.getColor(this, R.color.black)
window.navigationBarColor = getColor(R.color.black)
window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_FULLSCREEN
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
window.setDecorFitsSystemWindows(false)
} else {
@Suppress("DEPRECATION")
window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_FULLSCREEN
}
setupCropper()
}
@ -184,7 +190,14 @@ class EditImageActivity :
// determine output file format
format = when (file.mimeType) {
MimeType.PNG -> Bitmap.CompressFormat.PNG
MimeType.WEBP -> Bitmap.CompressFormat.WEBP
MimeType.WEBP -> {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
Bitmap.CompressFormat.WEBP_LOSSLESS
} else {
@Suppress("DEPRECATION")
Bitmap.CompressFormat.WEBP
}
}
else -> Bitmap.CompressFormat.JPEG
}
}