导航菜单

页面标题

页面副标题

Chaupal v3.2 - CropImageActivity.java 源代码

正在查看: Chaupal v3.2 应用的 CropImageActivity.java JAVA 源代码文件

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


package com.aemerse.cropper;

import android.content.DialogInterface;
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.view.Menu;
import android.view.MenuItem;
import androidx.appcompat.app.d;
import androidx.core.graphics.BlendModeCompat;
import com.aemerse.cropper.CropImageView;
import com.google.ads.interactivemedia.v3.internal.bpr;
import java.io.File;
import kf.l;
import kotlin.Metadata;
import kotlin.jvm.internal.Intrinsics;
import org.jetbrains.annotations.NotNull;

@Metadata
public class CropImageActivity extends androidx.appcompat.app.e implements CropImageView.g, CropImageView.c {

    private Uri f6303a;

    private CropImageOptions f6304c;

    private CropImageView f6305d;

    private v1.a f6306e;

    private Uri f6307f;

    @NotNull
    private final androidx.activity.result.b<String> f6308g;

    @NotNull
    private final androidx.activity.result.b<Uri> f6309h;

    @Metadata
    public enum Source {
        CAMERA,
        GALLERY
    }

    @Metadata
    public class a {

        public static final int[] f6310a;

        static {
            int[] iArr = new int[Source.values().length];
            iArr[Source.CAMERA.ordinal()] = 1;
            iArr[Source.GALLERY.ordinal()] = 2;
            f6310a = iArr;
        }
    }

    public CropImageActivity() {
        androidx.activity.result.b<String> registerForActivityResult = registerForActivityResult(new c.b(), new androidx.activity.result.a() {
            @Override
            public final void a(Object obj) {
                CropImageActivity.d0(CropImageActivity.this, (Uri) obj);
            }
        });
        Intrinsics.checkNotNullExpressionValue(registerForActivityResult, "registerForActivityResul…mageResult(uri)\n        }");
        this.f6308g = registerForActivityResult;
        androidx.activity.result.b<Uri> registerForActivityResult2 = registerForActivityResult(new c.f(), new androidx.activity.result.a() {
            @Override
            public final void a(Object obj) {
                CropImageActivity.k0(CropImageActivity.this, (Boolean) obj);
            }
        });
        Intrinsics.checkNotNullExpressionValue(registerForActivityResult2, "registerForActivityResul…esult(latestTmpUri)\n    }");
        this.f6309h = registerForActivityResult2;
    }

    private final Uri Z() {
        File createTempFile = File.createTempFile("tmp_image_file", ".png", getCacheDir());
        createTempFile.createNewFile();
        createTempFile.deleteOnExit();
        Intrinsics.checkNotNullExpressionValue(createTempFile, "tmpFile");
        return w1.a.a(this, createTempFile);
    }

    private final void b0() {
        Uri Z = Z();
        this.f6307f = Z;
        this.f6309h.a(Z);
    }

    public final void c0(Source source) {
        int i7 = a.f6310a[source.ordinal()];
        if (i7 == 1) {
            b0();
        } else {
            if (i7 != 2) {
                return;
            }
            this.f6308g.a("image/*");
        }
    }

    public static final void d0(CropImageActivity cropImageActivity, Uri uri) {
        Intrinsics.checkNotNullParameter(cropImageActivity, "this$0");
        cropImageActivity.a0(uri);
    }

    public static final void j0(l lVar, DialogInterface dialogInterface, int i7) {
        Intrinsics.checkNotNullParameter(lVar, "$openSource");
        lVar.invoke(i7 == 0 ? Source.CAMERA : Source.GALLERY);
    }

    public static final void k0(CropImageActivity cropImageActivity, Boolean bool) {
        Intrinsics.checkNotNullParameter(cropImageActivity, "this$0");
        Intrinsics.checkNotNullExpressionValue(bool, "it");
        if (bool.booleanValue()) {
            cropImageActivity.a0(cropImageActivity.f6307f);
        }
    }

    @Override
    public void A(@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) {
            g0(null, exc, 1);
            return;
        }
        CropImageOptions cropImageOptions2 = this.f6304c;
        if (cropImageOptions2 == null) {
            Intrinsics.w("cropImageOptions");
            cropImageOptions2 = null;
        }
        if (cropImageOptions2.Q != null && (cropImageView3 = this.f6305d) != null) {
            CropImageOptions cropImageOptions3 = this.f6304c;
            if (cropImageOptions3 == null) {
                Intrinsics.w("cropImageOptions");
                cropImageOptions3 = null;
            }
            cropImageView3.setCropRect(cropImageOptions3.Q);
        }
        CropImageOptions cropImageOptions4 = this.f6304c;
        if (cropImageOptions4 == null) {
            Intrinsics.w("cropImageOptions");
            cropImageOptions4 = null;
        }
        if (cropImageOptions4.R <= 0 || (cropImageView2 = this.f6305d) == null) {
            return;
        }
        CropImageOptions cropImageOptions5 = this.f6304c;
        if (cropImageOptions5 == null) {
            Intrinsics.w("cropImageOptions");
        } else {
            cropImageOptions = cropImageOptions5;
        }
        cropImageView2.setRotatedDegrees(cropImageOptions.R);
    }

    public void X() {
        CropImageOptions cropImageOptions = this.f6304c;
        CropImageOptions cropImageOptions2 = null;
        if (cropImageOptions == null) {
            Intrinsics.w("cropImageOptions");
            cropImageOptions = null;
        }
        if (cropImageOptions.P) {
            g0(null, null, 1);
            return;
        }
        CropImageView cropImageView = this.f6305d;
        if (cropImageView == null) {
            return;
        }
        CropImageOptions cropImageOptions3 = this.f6304c;
        if (cropImageOptions3 == null) {
            Intrinsics.w("cropImageOptions");
            cropImageOptions3 = null;
        }
        Bitmap.CompressFormat compressFormat = cropImageOptions3.K;
        CropImageOptions cropImageOptions4 = this.f6304c;
        if (cropImageOptions4 == null) {
            Intrinsics.w("cropImageOptions");
            cropImageOptions4 = null;
        }
        int i7 = cropImageOptions4.L;
        CropImageOptions cropImageOptions5 = this.f6304c;
        if (cropImageOptions5 == null) {
            Intrinsics.w("cropImageOptions");
            cropImageOptions5 = null;
        }
        int i8 = cropImageOptions5.M;
        CropImageOptions cropImageOptions6 = this.f6304c;
        if (cropImageOptions6 == null) {
            Intrinsics.w("cropImageOptions");
            cropImageOptions6 = null;
        }
        int i9 = cropImageOptions6.N;
        CropImageOptions cropImageOptions7 = this.f6304c;
        if (cropImageOptions7 == null) {
            Intrinsics.w("cropImageOptions");
            cropImageOptions7 = null;
        }
        CropImageView.RequestSizeOptions requestSizeOptions = cropImageOptions7.O;
        CropImageOptions cropImageOptions8 = this.f6304c;
        if (cropImageOptions8 == null) {
            Intrinsics.w("cropImageOptions");
        } else {
            cropImageOptions2 = cropImageOptions8;
        }
        cropImageView.d(compressFormat, i7, i8, i9, requestSizeOptions, cropImageOptions2.J);
    }

    @NotNull
    public Intent Y(Uri uri, Exception exc, int i7) {
        CropImageView cropImageView = this.f6305d;
        Uri imageUri = cropImageView == null ? null : cropImageView.getImageUri();
        CropImageView cropImageView2 = this.f6305d;
        float[] cropPoints = cropImageView2 == null ? null : cropImageView2.getCropPoints();
        CropImageView cropImageView3 = this.f6305d;
        Rect cropRect = cropImageView3 == null ? null : cropImageView3.getCropRect();
        CropImageView cropImageView4 = this.f6305d;
        int rotatedDegrees = cropImageView4 == null ? 0 : cropImageView4.getRotatedDegrees();
        CropImageView cropImageView5 = this.f6305d;
        CropImage$ActivityResult cropImage$ActivityResult = new CropImage$ActivityResult(imageUri, uri, exc, cropPoints, cropRect, rotatedDegrees, cropImageView5 == null ? null : cropImageView5.getWholeImageRect(), i7);
        Intent intent = new Intent();
        intent.putExtras(getIntent());
        intent.putExtra("CROP_IMAGE_EXTRA_RESULT", cropImage$ActivityResult);
        return intent;
    }

    protected void a0(Uri uri) {
        if (uri == null) {
            h0();
            return;
        }
        this.f6303a = uri;
        CropImageView cropImageView = this.f6305d;
        if (cropImageView == null) {
            return;
        }
        cropImageView.setImageUriAsync(uri);
    }

    public void e0(int i7) {
        CropImageView cropImageView = this.f6305d;
        if (cropImageView == null) {
            return;
        }
        cropImageView.l(i7);
    }

    public void f0(@NotNull CropImageView cropImageView) {
        Intrinsics.checkNotNullParameter(cropImageView, "cropImageView");
        this.f6305d = cropImageView;
    }

    public void g0(Uri uri, Exception exc, int i7) {
        setResult(exc == null ? -1 : bpr.f12937g, Y(uri, exc, i7));
        finish();
    }

    public void h0() {
        setResult(0);
        finish();
    }

    public void i0(@NotNull final l<? super Source, bf.i> lVar) {
        Intrinsics.checkNotNullParameter(lVar, "openSource");
        new d.a(this).i(j.f6458c).e(new String[]{getString(j.f6457b), getString(j.f6459d)}, new DialogInterface.OnClickListener() {
            @Override
            public final void onClick(DialogInterface dialogInterface, int i7) {
                CropImageActivity.j0(lVar, dialogInterface, i7);
            }
        }).j();
    }

    public void l0(@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(androidx.core.graphics.a.a(i8, BlendModeCompat.SRC_ATOP));
            findItem.setIcon(icon);
        } catch (Exception e7) {
            Log.w("AIC", "Failed to update menu item color", e7);
        }
    }

    @Override
    public void onBackPressed() {
        super.onBackPressed();
        h0();
    }

    @Override
    public void onCreate(Bundle bundle) {
        CharSequence string;
        super.onCreate(bundle);
        v1.a c7 = v1.a.c(getLayoutInflater());
        Intrinsics.checkNotNullExpressionValue(c7, "inflate(layoutInflater)");
        this.f6306e = c7;
        CropImageOptions cropImageOptions = null;
        if (c7 == null) {
            Intrinsics.w("binding");
            c7 = null;
        }
        setContentView(c7.b());
        v1.a aVar = this.f6306e;
        if (aVar == null) {
            Intrinsics.w("binding");
            aVar = null;
        }
        CropImageView cropImageView = aVar.f19283b;
        Intrinsics.checkNotNullExpressionValue(cropImageView, "binding.cropImageView");
        f0(cropImageView);
        Bundle bundleExtra = getIntent().getBundleExtra("CROP_IMAGE_EXTRA_BUNDLE");
        this.f6303a = bundleExtra == null ? null : (Uri) bundleExtra.getParcelable("CROP_IMAGE_EXTRA_SOURCE");
        CropImageOptions cropImageOptions2 = bundleExtra == null ? null : (CropImageOptions) bundleExtra.getParcelable("CROP_IMAGE_EXTRA_OPTIONS");
        if (cropImageOptions2 == null) {
            cropImageOptions2 = new CropImageOptions();
        }
        this.f6304c = cropImageOptions2;
        if (bundle == null) {
            Uri uri = this.f6303a;
            if (uri == null || Intrinsics.c(uri, Uri.EMPTY)) {
                CropImageOptions cropImageOptions3 = this.f6304c;
                if (cropImageOptions3 == null) {
                    Intrinsics.w("cropImageOptions");
                    cropImageOptions3 = null;
                }
                if (cropImageOptions3.f6312a) {
                    CropImageOptions cropImageOptions4 = this.f6304c;
                    if (cropImageOptions4 == null) {
                        Intrinsics.w("cropImageOptions");
                        cropImageOptions4 = null;
                    }
                    if (cropImageOptions4.f6313c) {
                        i0(new CropImageActivity$onCreate$1(this));
                    }
                }
                CropImageOptions cropImageOptions5 = this.f6304c;
                if (cropImageOptions5 == null) {
                    Intrinsics.w("cropImageOptions");
                    cropImageOptions5 = null;
                }
                if (cropImageOptions5.f6312a) {
                    this.f6308g.a("image/*");
                } else {
                    CropImageOptions cropImageOptions6 = this.f6304c;
                    if (cropImageOptions6 == null) {
                        Intrinsics.w("cropImageOptions");
                        cropImageOptions6 = null;
                    }
                    if (cropImageOptions6.f6313c) {
                        b0();
                    } else {
                        finish();
                    }
                }
            } else {
                CropImageView cropImageView2 = this.f6305d;
                if (cropImageView2 != null) {
                    cropImageView2.setImageUriAsync(this.f6303a);
                }
            }
        }
        androidx.appcompat.app.a supportActionBar = getSupportActionBar();
        if (supportActionBar == null) {
            return;
        }
        CropImageOptions cropImageOptions7 = this.f6304c;
        if (cropImageOptions7 == null) {
            Intrinsics.w("cropImageOptions");
            cropImageOptions7 = null;
        }
        if (cropImageOptions7.H.length() > 0) {
            CropImageOptions cropImageOptions8 = this.f6304c;
            if (cropImageOptions8 == null) {
                Intrinsics.w("cropImageOptions");
            } else {
                cropImageOptions = cropImageOptions8;
            }
            string = cropImageOptions.H;
        } else {
            string = getResources().getString(j.f6456a);
        }
        setTitle(string);
        supportActionBar.t(true);
    }

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

    @Override
    public boolean onOptionsItemSelected(@NotNull MenuItem menuItem) {
        Intrinsics.checkNotNullParameter(menuItem, "item");
        int itemId = menuItem.getItemId();
        if (itemId == g.f6447d) {
            X();
            return true;
        }
        CropImageOptions cropImageOptions = null;
        if (itemId == g.f6451h) {
            CropImageOptions cropImageOptions2 = this.f6304c;
            if (cropImageOptions2 == null) {
                Intrinsics.w("cropImageOptions");
            } else {
                cropImageOptions = cropImageOptions2;
            }
            e0(-cropImageOptions.V);
            return true;
        }
        if (itemId == g.f6452i) {
            CropImageOptions cropImageOptions3 = this.f6304c;
            if (cropImageOptions3 == null) {
                Intrinsics.w("cropImageOptions");
            } else {
                cropImageOptions = cropImageOptions3;
            }
            e0(cropImageOptions.V);
            return true;
        }
        if (itemId == g.f6449f) {
            CropImageView cropImageView = this.f6305d;
            if (cropImageView == null) {
                return true;
            }
            cropImageView.e();
            return true;
        }
        if (itemId != g.f6450g) {
            if (itemId != 16908332) {
                return super.onOptionsItemSelected(menuItem);
            }
            h0();
            return true;
        }
        CropImageView cropImageView2 = this.f6305d;
        if (cropImageView2 == null) {
            return true;
        }
        cropImageView2.f();
        return true;
    }

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

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

    @Override
    public void x(@NotNull CropImageView cropImageView, @NotNull CropImageView.b bVar) {
        Intrinsics.checkNotNullParameter(cropImageView, "view");
        Intrinsics.checkNotNullParameter(bVar, "result");
        g0(bVar.j(), bVar.c(), bVar.i());
    }
}