mirror of
https://github.com/fcitx5-android/fcitx5-android.git
synced 2026-08-02 20:16:06 +08:00
Update dependencies
AGP 8.13.1 KSP 2.3.2, turn on ksp.useKSP2 android-image-cropper 4.7.0, migrate off customOutputUri
This commit is contained in:
parent
3322470470
commit
92e38dcf33
@ -23,6 +23,7 @@ import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.appcompat.graphics.drawable.DrawerArrowDrawable
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.core.view.updateLayoutParams
|
||||
@ -52,7 +53,7 @@ import splitties.views.topPadding
|
||||
import timber.log.Timber
|
||||
import java.io.File
|
||||
|
||||
class CropImageActivity : AppCompatActivity(), CropImageView.OnCropImageCompleteListener {
|
||||
class CropImageActivity : AppCompatActivity() {
|
||||
|
||||
companion object {
|
||||
const val CROP_OPTIONS = "crop_options"
|
||||
@ -143,8 +144,6 @@ class CropImageActivity : AppCompatActivity(), CropImageView.OnCropImageComplete
|
||||
}
|
||||
}
|
||||
|
||||
private lateinit var tempOutFile: File
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
cropOption = intent.parcelable<CropOption>(CROP_OPTIONS) ?: CropOption.New(1, 1)
|
||||
@ -169,7 +168,6 @@ class CropImageActivity : AppCompatActivity(), CropImageView.OnCropImageComplete
|
||||
setupToolbarMenu(menu)
|
||||
}
|
||||
cropView = CropImageView(this).apply {
|
||||
setOnCropImageCompleteListener(this@CropImageActivity)
|
||||
setImageCropOptions(getDefaultCropImageOptions())
|
||||
}
|
||||
root = constraintLayout {
|
||||
@ -221,9 +219,10 @@ class CropImageActivity : AppCompatActivity(), CropImageView.OnCropImageComplete
|
||||
launcher.launch("image/*")
|
||||
}
|
||||
is CropOption.Edit -> {
|
||||
cropView.setOnSetImageUriCompleteListener { view, uri, e ->
|
||||
cropView.setOnSetImageUriCompleteListener { view, _, _ ->
|
||||
view.cropRect = option.initialRect
|
||||
view.rotatedDegrees = option.initialRotation
|
||||
cropView.setOnSetImageUriCompleteListener(null)
|
||||
}
|
||||
cropView.setImageUriAsync(option.sourceUri)
|
||||
}
|
||||
@ -231,28 +230,24 @@ class CropImageActivity : AppCompatActivity(), CropImageView.OnCropImageComplete
|
||||
}
|
||||
|
||||
private fun onCropImage() {
|
||||
tempOutFile = File.createTempFile("cropped", ".png", cacheDir)
|
||||
cropView.croppedImageAsync(
|
||||
saveCompressFormat = Bitmap.CompressFormat.PNG,
|
||||
reqWidth = cropOption.width,
|
||||
reqHeight = cropOption.height,
|
||||
options = CropImageView.RequestSizeOptions.RESIZE_INSIDE,
|
||||
customOutputUri = Uri.fromFile(tempOutFile)
|
||||
)
|
||||
}
|
||||
|
||||
override fun onCropImageComplete(view: CropImageView, result: CropImageView.CropResult) {
|
||||
val tempOutFile = File.createTempFile("cropped", ".png", cacheDir)
|
||||
try {
|
||||
result
|
||||
val success = CropResult.Success(
|
||||
result.cropRect!!,
|
||||
result.rotation,
|
||||
tempOutFile,
|
||||
(cropOption as? CropOption.Edit)?.sourceUri ?: selectedImageUri!!
|
||||
val bitmap = cropView.getCroppedImage(
|
||||
reqWidth = cropOption.width,
|
||||
reqHeight = cropOption.height,
|
||||
options = CropImageView.RequestSizeOptions.RESIZE_INSIDE,
|
||||
)
|
||||
setResult(RESULT_OK, Intent().putExtra(CROP_RESULT, success))
|
||||
tempOutFile.outputStream().use { bitmap!!.compress(Bitmap.CompressFormat.PNG, 100, it) }
|
||||
val success = CropResult.Success(
|
||||
rect = cropView.cropRect!!,
|
||||
rotation = cropView.rotatedDegrees,
|
||||
file = tempOutFile,
|
||||
srcUri = (cropOption as? CropOption.Edit)?.sourceUri ?: selectedImageUri!!
|
||||
)
|
||||
setResult(RESULT_OK, Intent().putExtras(bundleOf(CROP_RESULT to success)))
|
||||
} catch (e: Exception) {
|
||||
Timber.e("Exception when cropping image: $e")
|
||||
tempOutFile.delete()
|
||||
Timber.e("Exception when cropping image: ${e.stackTraceToString()}")
|
||||
toast(e)
|
||||
setResult(RESULT_CANCELED)
|
||||
}
|
||||
|
||||
@ -20,6 +20,8 @@ android.nonTransitiveRClass=true
|
||||
android.enableJetifier=false
|
||||
# Kotlin code style for this project: "official" or "obsolete":
|
||||
kotlin.code.style=official
|
||||
# KSP2 https://github.com/google/ksp/blob/main/docs/ksp2.md
|
||||
ksp.useKSP2=true
|
||||
# Build property overrides
|
||||
#buildABI=arm64-v8a
|
||||
#buildVersionName=
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
[versions]
|
||||
androidGradlePlugin = "8.13.0"
|
||||
androidGradlePlugin = "8.13.1"
|
||||
kotlin = "2.2.21"
|
||||
ksp = "2.2.21-2.0.4"
|
||||
ksp = "2.3.2"
|
||||
lifecycle = "2.9.4"
|
||||
navigation = "2.9.5"
|
||||
room = "2.8.3"
|
||||
navigation = "2.9.6"
|
||||
room = "2.8.4"
|
||||
test = "1.7.0"
|
||||
splitties = "3.0.0"
|
||||
aboutlibraries = "13.1.0"
|
||||
@ -41,7 +41,7 @@ androidx-viewpager2 = { module = "androidx.viewpager2:viewpager2", version = "1.
|
||||
material = { module = "com.google.android.material:material", version = "1.13.0" }
|
||||
arrow-core = { module = "io.arrow-kt:arrow-core", version.ref = "arrow" }
|
||||
arrow-functions = { module = "io.arrow-kt:arrow-functions", version.ref = "arrow" }
|
||||
imagecropper = { module = "com.vanniktech:android-image-cropper", version = "4.6.0" }
|
||||
imagecropper = { module = "com.vanniktech:android-image-cropper", version = "4.7.0" }
|
||||
flexbox = { module = "com.google.android.flexbox:flexbox", version = "3.0.0" }
|
||||
dependency = { module = "org.mechdancer:dependency", version = "0.1.2" }
|
||||
timber = { module = "com.jakewharton.timber:timber", version = "5.0.1" }
|
||||
@ -72,4 +72,4 @@ ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
|
||||
aboutlibraries = { id = "com.mikepenz.aboutlibraries.plugin.android", version.ref = "aboutlibraries" }
|
||||
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
|
||||
kotlin-parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", version.ref = "kotlin" }
|
||||
gitVersion = { id = "com.palantir.git-version", version = "4.1.0" }
|
||||
gitVersion = { id = "com.palantir.git-version", version = "4.2.0" }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user