From 2aeb7698155a71341e7653c39b1c6e2ea1fdcef4 Mon Sep 17 00:00:00 2001 From: ThomasSession Date: Fri, 9 Aug 2024 12:51:29 +1000 Subject: [PATCH] Upgraded to 4.5.0 (we can't use 4.6.0 yet due to kotlin 2.0 usage) --- app/build.gradle | 2 +- .../securesms/avatar/AvatarSelection.kt | 37 ++++++++++++------- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 4da9ed5ebe..f72856553d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -284,7 +284,7 @@ dependencies { implementation 'com.pnikosis:materialish-progress:1.5' implementation 'org.greenrobot:eventbus:3.0.0' implementation 'pl.tajchert:waitingdots:0.1.0' - implementation 'com.vanniktech:android-image-cropper:4.3.3' + implementation 'com.vanniktech:android-image-cropper:4.5.0' implementation 'com.melnykov:floatingactionbutton:1.3.0' implementation 'com.google.zxing:android-integration:3.1.0' implementation 'mobi.upod:time-duration-picker:1.1.3' diff --git a/app/src/main/java/org/thoughtcrime/securesms/avatar/AvatarSelection.kt b/app/src/main/java/org/thoughtcrime/securesms/avatar/AvatarSelection.kt index 961700089a..adf4b0927c 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/avatar/AvatarSelection.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/avatar/AvatarSelection.kt @@ -10,8 +10,8 @@ import android.provider.MediaStore import androidx.activity.result.ActivityResultLauncher import androidx.core.content.ContextCompat import com.canhub.cropper.CropImageContractOptions +import com.canhub.cropper.CropImageOptions import com.canhub.cropper.CropImageView -import com.canhub.cropper.options import network.loki.messenger.R import org.session.libsession.utilities.getColorFromAttr import org.session.libsignal.utilities.ExternalStorageUtil.getImageDir @@ -43,19 +43,28 @@ class AvatarSelection( outputFile: Uri? ) { onAvatarCropped.launch( - options(inputFile) { - setGuidelines(CropImageView.Guidelines.ON) - setAspectRatio(1, 1) - setCropShape(CropImageView.CropShape.OVAL) - setOutputUri(outputFile) - setAllowRotation(true) - setAllowFlipping(true) - setBackgroundColor(imageScrim) - setToolbarColor(bgColor) - setActivityBackgroundColor(bgColor) - setToolbarTintColor(txtColor) - setActivityTitle(activityTitle) - } + CropImageContractOptions( + uri = inputFile, + cropImageOptions = CropImageOptions( + guidelines = CropImageView.Guidelines.ON, + aspectRatioX = 1, + aspectRatioY = 1, + fixAspectRatio = true, + cropShape = CropImageView.CropShape.OVAL, + customOutputUri = outputFile, + allowRotation = true, + allowFlipping = true, + backgroundColor = imageScrim, + toolbarColor = bgColor, + activityBackgroundColor = bgColor, + toolbarTintColor = txtColor, + toolbarBackButtonColor = txtColor, + toolbarTitleColor = txtColor, + activityMenuIconColor = txtColor, + activityMenuTextColor = txtColor, + activityTitle = activityTitle + ) + ) ) }