Merge pull request #2887 from fatihergin/feature/update-image-cropper-library

replace outdated image cropper library with an up to date fork
This commit is contained in:
Tibor Kaputa 2023-07-05 10:37:18 +02:00 committed by GitHub
commit 2c3706e86b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 19 deletions

View file

@ -79,7 +79,7 @@ android {
dependencies {
implementation 'com.github.SimpleMobileTools:Simple-Commons:30e6321592'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
implementation 'com.vanniktech:android-image-cropper:4.5.0'
implementation 'it.sephiroth.android.exif:library:1.0.1'
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.25'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'

View file

@ -24,6 +24,7 @@ import com.bumptech.glide.load.engine.GlideException
import com.bumptech.glide.request.RequestListener
import com.bumptech.glide.request.RequestOptions
import com.bumptech.glide.request.target.Target
import com.canhub.cropper.CropImageView
import com.simplemobiletools.commons.dialogs.ColorPickerDialog
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
import com.simplemobiletools.commons.extensions.*
@ -44,7 +45,6 @@ import com.simplemobiletools.gallery.pro.extensions.fixDateTaken
import com.simplemobiletools.gallery.pro.extensions.openEditor
import com.simplemobiletools.gallery.pro.helpers.*
import com.simplemobiletools.gallery.pro.models.FilterItem
import com.theartofdev.edmodo.cropper.CropImageView
import com.zomato.photofilters.FilterPack
import com.zomato.photofilters.imageprocessors.Filter
import kotlinx.android.synthetic.main.activity_edit.*
@ -318,7 +318,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
setOldExif()
if (crop_image_view.isVisible()) {
crop_image_view.getCroppedImageAsync()
crop_image_view.croppedImageAsync()
} else if (editor_draw_canvas.isVisible()) {
val bitmap = editor_draw_canvas.getBitmap()
if (saveUri.scheme == "file") {
@ -387,7 +387,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
crop_image_view.isVisible() -> {
isSharingBitmap = true
runOnUiThread {
crop_image_view.getCroppedImageAsync()
crop_image_view.croppedImageAsync()
}
}
editor_draw_canvas.isVisible() -> shareBitmap(editor_draw_canvas.getBitmap())
@ -752,7 +752,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
ResizeDialog(this, point) {
resizeWidth = it.x
resizeHeight = it.y
crop_image_view.getCroppedImageAsync()
crop_image_view.croppedImageAsync()
}
}
@ -776,10 +776,10 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
}
override fun onCropImageComplete(view: CropImageView, result: CropImageView.CropResult) {
if (result.error == null) {
if (result.error == null && result.bitmap != null) {
setOldExif()
val bitmap = result.bitmap
val bitmap = result.bitmap!!
if (isSharingBitmap) {
isSharingBitmap = false
shareBitmap(bitmap)
@ -826,7 +826,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
toast(R.string.unknown_file_location)
}
} else {
toast("${getString(R.string.image_editing_failed)}: ${result.error.message}")
toast("${getString(R.string.image_editing_failed)}: ${result.error?.message}")
}
}

View file

@ -6,6 +6,7 @@ import android.content.Intent
import android.graphics.Bitmap
import android.net.Uri
import android.os.Bundle
import com.canhub.cropper.CropImageView
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
import com.simplemobiletools.commons.extensions.checkAppSideloading
import com.simplemobiletools.commons.extensions.toast
@ -14,9 +15,10 @@ import com.simplemobiletools.commons.helpers.ensureBackgroundThread
import com.simplemobiletools.commons.helpers.isNougatPlus
import com.simplemobiletools.commons.models.RadioItem
import com.simplemobiletools.gallery.pro.R
import com.theartofdev.edmodo.cropper.CropImageView
import kotlinx.android.synthetic.main.activity_set_wallpaper.*
import kotlinx.android.synthetic.main.bottom_set_wallpaper_actions.*
import kotlinx.android.synthetic.main.activity_set_wallpaper.crop_image_view
import kotlinx.android.synthetic.main.activity_set_wallpaper.set_wallpaper_toolbar
import kotlinx.android.synthetic.main.bottom_set_wallpaper_actions.bottom_set_wallpaper_aspect_ratio
import kotlinx.android.synthetic.main.bottom_set_wallpaper_actions.bottom_set_wallpaper_rotate
class SetWallpaperActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener {
private val RATIO_PORTRAIT = 0
@ -134,21 +136,21 @@ class SetWallpaperActivity : SimpleActivity(), CropImageView.OnCropImageComplete
RadioGroupDialog(this, items) {
wallpaperFlag = it as Int
crop_image_view.getCroppedImageAsync()
crop_image_view.croppedImageAsync()
}
} else {
crop_image_view.getCroppedImageAsync()
crop_image_view.croppedImageAsync()
}
}
override fun onCropImageComplete(view: CropImageView?, result: CropImageView.CropResult) {
override fun onCropImageComplete(view: CropImageView, result: CropImageView.CropResult) {
if (isDestroyed)
return
if (result.error == null) {
if (result.error == null && result.bitmap != null) {
toast(R.string.setting_wallpaper)
ensureBackgroundThread {
val bitmap = result.bitmap
val bitmap = result.bitmap!!
val wantedHeight = wallpaperManager.desiredMinimumHeight
val ratio = wantedHeight / bitmap.height.toFloat()
val wantedWidth = (bitmap.width * ratio).toInt()
@ -167,7 +169,7 @@ class SetWallpaperActivity : SimpleActivity(), CropImageView.OnCropImageComplete
finish()
}
} else {
toast("${getString(R.string.image_editing_failed)}: ${result.error.message}")
toast("${getString(R.string.image_editing_failed)}: ${result.error?.message}")
}
}
}

View file

@ -34,7 +34,7 @@
android:layout_above="@+id/bottom_editor_crop_rotate_actions"
android:layout_marginBottom="@dimen/bottom_filters_height_with_margin" />
<com.theartofdev.edmodo.cropper.CropImageView
<com.canhub.cropper.CropImageView
android:id="@+id/crop_image_view"
android:layout_width="match_parent"
android:layout_height="match_parent"

View file

@ -27,7 +27,7 @@
android:layout_height="match_parent"
android:layout_marginTop="?attr/actionBarSize">
<com.theartofdev.edmodo.cropper.CropImageView
<com.canhub.cropper.CropImageView
android:id="@+id/crop_image_view"
android:layout_width="match_parent"
android:layout_height="match_parent"