diff --git a/demo-app/build.gradle.kts b/demo-app/build.gradle.kts index 57fc383e..7e11f346 100644 --- a/demo-app/build.gradle.kts +++ b/demo-app/build.gradle.kts @@ -117,6 +117,7 @@ dependencies { implementation(libs.coil.compose) implementation(libs.androidx.activity) implementation(libs.androidx.constraintlayout) + implementation(libs.ucrop) implementation(project(":gravatar")) implementation(project(":gravatar-ui")) implementation(project(":gravatar-quickeditor")) diff --git a/demo-app/src/main/AndroidManifest.xml b/demo-app/src/main/AndroidManifest.xml index 4e1f70ae..bb1141d0 100644 --- a/demo-app/src/main/AndroidManifest.xml +++ b/demo-app/src/main/AndroidManifest.xml @@ -55,6 +55,12 @@ + + + + diff --git a/gravatar-quickeditor/src/main/java/com/gravatar/quickeditor/ui/avatarpicker/AvatarPicker.kt b/gravatar-quickeditor/src/main/java/com/gravatar/quickeditor/ui/avatarpicker/AvatarPicker.kt index e845ea2c..3a798f17 100644 --- a/gravatar-quickeditor/src/main/java/com/gravatar/quickeditor/ui/avatarpicker/AvatarPicker.kt +++ b/gravatar-quickeditor/src/main/java/com/gravatar/quickeditor/ui/avatarpicker/AvatarPicker.kt @@ -50,8 +50,8 @@ import com.gravatar.quickeditor.ui.components.EmailLabel import com.gravatar.quickeditor.ui.components.ErrorSection import com.gravatar.quickeditor.ui.components.FailedAvatarUploadAlertDialog import com.gravatar.quickeditor.ui.components.ProfileCard -import com.gravatar.quickeditor.ui.copperlauncher.CropperLauncher -import com.gravatar.quickeditor.ui.copperlauncher.UCropCropperLauncher +import com.gravatar.quickeditor.ui.cropperlauncher.CropperLauncher +import com.gravatar.quickeditor.ui.cropperlauncher.UCropCropperLauncher import com.gravatar.quickeditor.ui.editor.AvatarPickerContentLayout import com.gravatar.quickeditor.ui.editor.GravatarQuickEditorParams import com.gravatar.quickeditor.ui.editor.bottomsheet.DEFAULT_PAGE_HEIGHT diff --git a/gravatar-quickeditor/src/main/java/com/gravatar/quickeditor/ui/copperlauncher/CropperLauncher.kt b/gravatar-quickeditor/src/main/java/com/gravatar/quickeditor/ui/cropperlauncher/CropperLauncher.kt similarity index 85% rename from gravatar-quickeditor/src/main/java/com/gravatar/quickeditor/ui/copperlauncher/CropperLauncher.kt rename to gravatar-quickeditor/src/main/java/com/gravatar/quickeditor/ui/cropperlauncher/CropperLauncher.kt index cc6daec3..3b51a1c5 100644 --- a/gravatar-quickeditor/src/main/java/com/gravatar/quickeditor/ui/copperlauncher/CropperLauncher.kt +++ b/gravatar-quickeditor/src/main/java/com/gravatar/quickeditor/ui/cropperlauncher/CropperLauncher.kt @@ -1,4 +1,4 @@ -package com.gravatar.quickeditor.ui.copperlauncher +package com.gravatar.quickeditor.ui.cropperlauncher import android.content.Context import android.content.Intent diff --git a/gravatar-quickeditor/src/main/java/com/gravatar/quickeditor/ui/copperlauncher/UCropCropperLauncher.kt b/gravatar-quickeditor/src/main/java/com/gravatar/quickeditor/ui/cropperlauncher/UCropCropperLauncher.kt similarity index 64% rename from gravatar-quickeditor/src/main/java/com/gravatar/quickeditor/ui/copperlauncher/UCropCropperLauncher.kt rename to gravatar-quickeditor/src/main/java/com/gravatar/quickeditor/ui/cropperlauncher/UCropCropperLauncher.kt index bd644048..f17b33d9 100644 --- a/gravatar-quickeditor/src/main/java/com/gravatar/quickeditor/ui/copperlauncher/UCropCropperLauncher.kt +++ b/gravatar-quickeditor/src/main/java/com/gravatar/quickeditor/ui/cropperlauncher/UCropCropperLauncher.kt @@ -1,4 +1,4 @@ -package com.gravatar.quickeditor.ui.copperlauncher +package com.gravatar.quickeditor.ui.cropperlauncher import android.content.Context import android.content.Intent @@ -24,7 +24,21 @@ internal class UCropCropperLauncher : CropperLauncher { setCircleDimmedLayer(true) } launcher.launch( - UCrop.of(image, Uri.fromFile(tempFile)).withAspectRatio(1f, 1f).withOptions(options).getIntent(context), + UCrop.of(image, Uri.fromFile(tempFile)) + .withAspectRatio(1f, 1f) + .withOptions(options) + .getGravatarIntent(context), ) } } + +private fun UCrop.getGravatarIntent(context: Context): Intent { + return getIntent(context).apply { + setClass(context, GravatarUCropActivity::class.java) + } +} + +/** + * Empty Activity to not cause conflicts with UCropActivity when third-party apps depend on it already + */ +internal class GravatarUCropActivity : UCropActivity()