导航菜单

页面标题

页面副标题

Crafto v9.3.3 - CropImageActivity.java 源代码

正在查看: Crafto v9.3.3 应用的 CropImageActivity.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.canhub.cropper;

import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.util.Pair;
import android.view.Menu;
import android.view.MenuItem;
import androidx.appcompat.app.AppCompatActivity;
import com.canhub.cropper.CropImageView;
import com.paytmpayments.customuisdk.paymethods.datasource.f;
import dl.J;
import dl.Z;
import dl.g;
import f.u;
import ga.i;
import i.AbstractC1981c;
import j.C2012b;
import j.C2019i;
import java.io.File;
import java.lang.ref.WeakReference;
import java.util.concurrent.CancellationException;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.CallableReference;
import kotlin.jvm.internal.FunctionReferenceImpl;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.Lambda;
import org.jetbrains.annotations.NotNull;
import s6.C2479a;
import t6.C2521a;
import u6.C2600a;

@Metadata
public class CropImageActivity extends AppCompatActivity implements CropImageView.i, CropImageView.e {

    public static final int f20587h = 0;

    public Uri f20588a;

    public CropImageOptions f20589b;

    public CropImageView f20590c;
    public C2521a d;

    public Uri f20591e;

    @NotNull
    public final AbstractC1981c<String> f20592f;

    @NotNull
    public final AbstractC1981c<Uri> f20593g;

    public enum a {
        CAMERA,
        GALLERY
    }

    public class b {

        public static final int[] f20594a;

        static {
            int[] iArr = new int[a.values().length];
            try {
                iArr[a.CAMERA.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                iArr[a.GALLERY.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            f20594a = iArr;
        }
    }

    public class c extends FunctionReferenceImpl implements Function1<a, Unit> {
        public final Object invoke(Object obj) {
            a aVar = (a) obj;
            Intrinsics.checkNotNullParameter(aVar, "p0");
            CropImageActivity cropImageActivity = (CropImageActivity) ((CallableReference) this).receiver;
            int i7 = CropImageActivity.f20587h;
            cropImageActivity.getClass();
            int i8 = b.f20594a[aVar.ordinal()];
            if (i8 == 1) {
                File createTempFile = File.createTempFile("tmp_image_file", ".png", cropImageActivity.getCacheDir());
                createTempFile.createNewFile();
                createTempFile.deleteOnExit();
                Intrinsics.checkNotNullExpressionValue(createTempFile, "tmpFile");
                Uri a8 = C2600a.a(cropImageActivity, createTempFile);
                cropImageActivity.f20591e = a8;
                cropImageActivity.f20593g.launch(a8);
            } else if (i8 == 2) {
                cropImageActivity.f20592f.launch("image/*");
            }
            return Unit.a;
        }
    }

    public static final class d extends Lambda implements Function1<u, Unit> {
        public d() {
            super(1);
        }

        public final Object invoke(Object obj) {
            Intrinsics.checkNotNullParameter((u) obj, "$this$addCallback");
            CropImageActivity cropImageActivity = CropImageActivity.this;
            cropImageActivity.setResult(0);
            cropImageActivity.finish();
            return Unit.a;
        }
    }

    public CropImageActivity() {
        AbstractC1981c<String> registerForActivityResult = registerForActivityResult(new C2012b(), new f(this));
        Intrinsics.checkNotNullExpressionValue(registerForActivityResult, "registerForActivityResul…nPickImageResult(uri)\n  }");
        this.f20592f = registerForActivityResult;
        AbstractC1981c<Uri> registerForActivityResult2 = registerForActivityResult(new C2019i(), new i(this));
        Intrinsics.checkNotNullExpressionValue(registerForActivityResult2, "registerForActivityResul…ageResult(null)\n    }\n  }");
        this.f20593g = registerForActivityResult2;
    }

    public static void J(@NotNull Menu menu, int i7, int i8) {
        Drawable icon;
        Intrinsics.checkNotNullParameter(menu, "menu");
        MenuItem findItem = menu.findItem(i7);
        if (findItem == null || (icon = findItem.getIcon()) == null) {
            return;
        }
        try {
            icon.mutate();
            icon.setColorFilter(M1.a.a(i8, M1.b.SRC_ATOP));
            findItem.setIcon(icon);
        } catch (Exception e8) {
            Log.w("AIC", "Failed to update menu item color", e8);
        }
    }

    public final void G() {
        C2479a c2479a;
        CropImageOptions cropImageOptions = this.f20589b;
        if (cropImageOptions == null) {
            Intrinsics.throwUninitializedPropertyAccessException("cropImageOptions");
            cropImageOptions = null;
        }
        if (cropImageOptions.f20635m2) {
            I(null, null, 1);
            return;
        }
        CropImageView cropImageView = this.f20590c;
        if (cropImageView != null) {
            CropImageOptions cropImageOptions2 = this.f20589b;
            if (cropImageOptions2 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("cropImageOptions");
                cropImageOptions2 = null;
            }
            Bitmap.CompressFormat compressFormat = cropImageOptions2.f20625h2;
            CropImageOptions cropImageOptions3 = this.f20589b;
            if (cropImageOptions3 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("cropImageOptions");
                cropImageOptions3 = null;
            }
            int i7 = cropImageOptions3.f20627i2;
            CropImageOptions cropImageOptions4 = this.f20589b;
            if (cropImageOptions4 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("cropImageOptions");
                cropImageOptions4 = null;
            }
            int i8 = cropImageOptions4.f20629j2;
            CropImageOptions cropImageOptions5 = this.f20589b;
            if (cropImageOptions5 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("cropImageOptions");
                cropImageOptions5 = null;
            }
            int i9 = cropImageOptions5.f20631k2;
            CropImageOptions cropImageOptions6 = this.f20589b;
            if (cropImageOptions6 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("cropImageOptions");
                cropImageOptions6 = null;
            }
            CropImageView.j jVar = cropImageOptions6.f20633l2;
            CropImageOptions cropImageOptions7 = this.f20589b;
            if (cropImageOptions7 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("cropImageOptions");
                cropImageOptions7 = null;
            }
            Uri uri = cropImageOptions7.f20623g2;
            Intrinsics.checkNotNullParameter(compressFormat, "saveCompressFormat");
            Intrinsics.checkNotNullParameter(jVar, "options");
            if (cropImageView.f20665I == null) {
                throw new IllegalArgumentException("mOnCropImageCompleteListener is not set".toString());
            }
            Intrinsics.checkNotNullParameter(jVar, "options");
            Intrinsics.checkNotNullParameter(compressFormat, "saveCompressFormat");
            Bitmap bitmap = cropImageView.f20681i;
            if (bitmap != null) {
                WeakReference<C2479a> weakReference = cropImageView.f20678g2;
                if (weakReference != null) {
                    Intrinsics.checkNotNull(weakReference);
                    c2479a = weakReference.get();
                } else {
                    c2479a = null;
                }
                if (c2479a != null) {
                    c2479a.f26315t.k((CancellationException) null);
                }
                Pair pair = (cropImageView.f20667M > 1 || jVar == CropImageView.j.SAMPLING) ? new Pair(Integer.valueOf(bitmap.getWidth() * cropImageView.f20667M), Integer.valueOf(bitmap.getHeight() * cropImageView.f20667M)) : new Pair(0, 0);
                Integer num = (Integer) pair.first;
                Integer num2 = (Integer) pair.second;
                Context context = cropImageView.getContext();
                Intrinsics.checkNotNullExpressionValue(context, "context");
                WeakReference weakReference2 = new WeakReference(cropImageView);
                Uri uri2 = cropImageView.f20666L;
                float[] cropPoints = cropImageView.getCropPoints();
                int i10 = cropImageView.f20683k;
                int i11 = i8;
                Intrinsics.checkNotNullExpressionValue(num, "orgWidth");
                int intValue = num.intValue();
                Intrinsics.checkNotNullExpressionValue(num2, "orgHeight");
                int intValue2 = num2.intValue();
                CropOverlayView cropOverlayView = cropImageView.f20672b;
                Intrinsics.checkNotNull(cropOverlayView);
                boolean z7 = cropOverlayView.f20708B;
                int aspectRatioX = cropOverlayView.getAspectRatioX();
                int aspectRatioY = cropOverlayView.getAspectRatioY();
                CropImageView.j jVar2 = CropImageView.j.NONE;
                if (jVar == jVar2) {
                    i11 = 0;
                }
                int i12 = jVar != jVar2 ? i9 : 0;
                boolean z8 = cropImageView.f20684l;
                boolean z9 = cropImageView.f20685m;
                if (uri == null) {
                    uri = cropImageView.f20680h2;
                }
                WeakReference<C2479a> weakReference3 = new WeakReference<>(new C2479a(context, weakReference2, uri2, bitmap, cropPoints, i10, intValue, intValue2, z7, aspectRatioX, aspectRatioY, i11, i12, z8, z9, jVar, compressFormat, i7, uri));
                cropImageView.f20678g2 = weakReference3;
                Intrinsics.checkNotNull(weakReference3);
                C2479a c2479a2 = weakReference3.get();
                Intrinsics.checkNotNull(c2479a2);
                C2479a c2479a3 = c2479a2;
                c2479a3.getClass();
                c2479a3.f26315t = g.b(c2479a3, Z.a, (J) null, new s6.c(c2479a3, null), 2);
                cropImageView.i();
            }
        }
    }

    public final void H(Uri uri) {
        if (uri == null) {
            setResult(0);
            finish();
            return;
        }
        this.f20588a = uri;
        CropImageView cropImageView = this.f20590c;
        if (cropImageView != null) {
            cropImageView.setImageUriAsync(uri);
        }
    }

    public final void I(Uri uri, Exception exc, int i7) {
        int i8 = exc != null ? 204 : -1;
        CropImageView cropImageView = this.f20590c;
        Uri imageUri = cropImageView != null ? cropImageView.getImageUri() : null;
        CropImageView cropImageView2 = this.f20590c;
        float[] cropPoints = cropImageView2 != null ? cropImageView2.getCropPoints() : null;
        CropImageView cropImageView3 = this.f20590c;
        Rect cropRect = cropImageView3 != null ? cropImageView3.getCropRect() : null;
        CropImageView cropImageView4 = this.f20590c;
        int rotatedDegrees = cropImageView4 != null ? cropImageView4.getRotatedDegrees() : 0;
        CropImageView cropImageView5 = this.f20590c;
        Rect wholeImageRect = cropImageView5 != null ? cropImageView5.getWholeImageRect() : null;
        Intrinsics.checkNotNull(cropPoints);
        CropImage$ActivityResult cropImage$ActivityResult = new CropImage$ActivityResult(imageUri, uri, exc, cropPoints, cropRect, wholeImageRect, rotatedDegrees, i7);
        Intent intent = new Intent();
        Bundle extras = intent.getExtras();
        if (extras != null) {
            intent.putExtras(extras);
        }
        intent.putExtra("CROP_IMAGE_EXTRA_RESULT", cropImage$ActivityResult);
        setResult(i8, intent);
        finish();
    }

    @Override
    public final void onCreate(android.os.Bundle r55) {
        throw new UnsupportedOperationException("Method not decompiled: com.canhub.cropper.CropImageActivity.onCreate(android.os.Bundle):void");
    }

    @Override
    public final boolean onCreateOptionsMenu(@org.jetbrains.annotations.NotNull android.view.Menu r14) {
        throw new UnsupportedOperationException("Method not decompiled: com.canhub.cropper.CropImageActivity.onCreateOptionsMenu(android.view.Menu):boolean");
    }

    @Override
    public final boolean onOptionsItemSelected(@NotNull MenuItem menuItem) {
        Intrinsics.checkNotNullParameter(menuItem, "item");
        int itemId = menuItem.getItemId();
        if (itemId == s6.u.crop_image_menu_crop) {
            G();
            return true;
        }
        CropImageOptions cropImageOptions = null;
        if (itemId == s6.u.ic_rotate_left_24) {
            CropImageOptions cropImageOptions2 = this.f20589b;
            if (cropImageOptions2 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("cropImageOptions");
            } else {
                cropImageOptions = cropImageOptions2;
            }
            int i7 = -cropImageOptions.s2;
            CropImageView cropImageView = this.f20590c;
            if (cropImageView == null) {
                return true;
            }
            cropImageView.f(i7);
            return true;
        }
        if (itemId == s6.u.ic_rotate_right_24) {
            CropImageOptions cropImageOptions3 = this.f20589b;
            if (cropImageOptions3 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("cropImageOptions");
            } else {
                cropImageOptions = cropImageOptions3;
            }
            int i8 = cropImageOptions.s2;
            CropImageView cropImageView2 = this.f20590c;
            if (cropImageView2 == null) {
                return true;
            }
            cropImageView2.f(i8);
            return true;
        }
        if (itemId == s6.u.ic_flip_24_horizontally) {
            CropImageView cropImageView3 = this.f20590c;
            if (cropImageView3 == null) {
                return true;
            }
            cropImageView3.f20684l = !cropImageView3.f20684l;
            cropImageView3.b(cropImageView3.getWidth(), cropImageView3.getHeight(), true, false);
            return true;
        }
        if (itemId != s6.u.ic_flip_24_vertically) {
            if (itemId != 16908332) {
                return super.onOptionsItemSelected(menuItem);
            }
            setResult(0);
            finish();
            return true;
        }
        CropImageView cropImageView4 = this.f20590c;
        if (cropImageView4 == null) {
            return true;
        }
        cropImageView4.f20685m = !cropImageView4.f20685m;
        cropImageView4.b(cropImageView4.getWidth(), cropImageView4.getHeight(), true, false);
        return true;
    }

    @Override
    public final void onSaveInstanceState(@NotNull Bundle bundle) {
        Intrinsics.checkNotNullParameter(bundle, "outState");
        super.onSaveInstanceState(bundle);
        bundle.putString("bundle_key_tmp_uri", String.valueOf(this.f20591e));
    }

    @Override
    public final void onStart() {
        super.onStart();
        CropImageView cropImageView = this.f20590c;
        if (cropImageView != null) {
            cropImageView.setOnSetImageUriCompleteListener(this);
        }
        CropImageView cropImageView2 = this.f20590c;
        if (cropImageView2 != null) {
            cropImageView2.setOnCropImageCompleteListener(this);
        }
    }

    @Override
    public final void onStop() {
        super.onStop();
        CropImageView cropImageView = this.f20590c;
        if (cropImageView != null) {
            cropImageView.setOnSetImageUriCompleteListener(null);
        }
        CropImageView cropImageView2 = this.f20590c;
        if (cropImageView2 != null) {
            cropImageView2.setOnCropImageCompleteListener(null);
        }
    }

    @Override
    public final void p(@NotNull CropImageView cropImageView, @NotNull CropImageView.b bVar) {
        Intrinsics.checkNotNullParameter(cropImageView, "view");
        Intrinsics.checkNotNullParameter(bVar, "result");
        I(bVar.f20702b, bVar.f20703c, bVar.f20707h);
    }

    @Override
    public final void t(@NotNull CropImageView cropImageView, @NotNull Uri uri, Exception exc) {
        CropImageView cropImageView2;
        CropImageView cropImageView3;
        Intrinsics.checkNotNullParameter(cropImageView, "view");
        Intrinsics.checkNotNullParameter(uri, "uri");
        CropImageOptions cropImageOptions = null;
        if (exc != null) {
            I(null, exc, 1);
            return;
        }
        CropImageOptions cropImageOptions2 = this.f20589b;
        if (cropImageOptions2 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("cropImageOptions");
            cropImageOptions2 = null;
        }
        if (cropImageOptions2.f20637n2 != null && (cropImageView3 = this.f20590c) != null) {
            CropImageOptions cropImageOptions3 = this.f20589b;
            if (cropImageOptions3 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("cropImageOptions");
                cropImageOptions3 = null;
            }
            cropImageView3.setCropRect(cropImageOptions3.f20637n2);
        }
        CropImageOptions cropImageOptions4 = this.f20589b;
        if (cropImageOptions4 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("cropImageOptions");
            cropImageOptions4 = null;
        }
        if (cropImageOptions4.f20639o2 > 0 && (cropImageView2 = this.f20590c) != null) {
            CropImageOptions cropImageOptions5 = this.f20589b;
            if (cropImageOptions5 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("cropImageOptions");
                cropImageOptions5 = null;
            }
            cropImageView2.setRotatedDegrees(cropImageOptions5.f20639o2);
        }
        CropImageOptions cropImageOptions6 = this.f20589b;
        if (cropImageOptions6 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("cropImageOptions");
        } else {
            cropImageOptions = cropImageOptions6;
        }
        if (cropImageOptions.f20658x2) {
            G();
        }
    }
}