package com.mexico.inloancash.fragment;

import ai.advance.liveness.sdk.activity.LivenessActivity;
import android.annotation.SuppressLint;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.text.TextUtils;
import android.util.Base64;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;
import butterknife.ButterKnife;
import butterknife.Unbinder;
import com.facebook.AccessToken;
import com.facebook.share.internal.MessengerShareContentUtility;
import com.google.gson.Gson;
import com.indiaholacash.holacash.R;
import com.mexico.inloancash.MyApplication;
import com.mexico.inloancash.activity.IndiaCerActivity;
import com.mexico.inloancash.activity.IndiaLoginActivity;
import com.mexico.inloancash.bean.BaseBean;
import com.mexico.inloancash.bean.PcDataBean;
import com.zhihu.matisse.MimeType;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.EnumSet;
import java.util.LinkedHashMap;
import java.util.List;
import org.json.JSONObject;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import ඓ.ඓ.K.ⁱ.C0648;
import ඓ.ඓ.K.ⁱ.C0654;
import ඓ.ඓ.K.ⁱ.C0656;
import ඓ.ඓ.K.ⁱ.C0661;
import ඓ.ඓ.K.ⁱ.C0662;
import ඓ.ඓ.K.ⁱ.C0664;
import ඓ.ඓ.K.ⁱ.RunnableC0665;
import ඓ.ඓ.K.㳳.AbstractC0671;
import ඓ.ඓ.K.㿎.AbstractC0700;
import ඓ.ඓ.K.㿎.C0701;
import ඓ.ඓ.K.䁗.C0727;
import ඓ.ඓ.K.䁗.ᓆ.C0715;
import ඓ.ඓ.K.䁗.ᓆ.C0717;
import ඓ.ᨨ.K.C0804;
import ඓ.ᨨ.K.C0805;
import ඓ.ᨨ.K.ʬ.K.C0765;
import ඓ.ᨨ.K.ඓ.K.C0778;
import ඓ.ᨨ.K.ඓ.K.C0782;
import ඓ.ῲ.K.C1218;
import ඓ.ῲ.K.ComponentCallbacks2C1161;
import ඓ.ⁱ.K.ʬ.C1248;
import ඓ.ⁱ.K.ῲ.C1253;
import ඓ.ⁱ.K.㸾.AbstractC1268;
import ඓ.ⁱ.K.㸾.C1272;
import ඓ.ⁱ.K.㸾.C1288;
import ඓ.K.K.K.C1293;
import ඓ.㳳.K.K.ʬ.AbstractC1294;
import ඓ.㳳.K.K.ῲ.C1300;
import ᕣ.K.K.C1468;
import ῲ.ᨨ.㳳.C1841;
import K.K.㸾.K.C2383;
import 㴹.K.AbstractC2511;
import 㴹.K.ؿ.C2491;
import 㴹.K.ᕣ.K.C2505;
import 㴹.K.䁗.AbstractC2521;
import 㿎.AbstractC2537;

public class IndiaStepOneAuthFragment extends C0648 implements AbstractC0671 {
    public Button btCommit;
    public ImageView idTakeSelf;
    public ImageView mImageViewPanCard;

    /* renamed from: ʬ  reason: contains not printable characters */
    public View f2723;

    /* renamed from: Ԕ  reason: contains not printable characters */
    public String f2724 = "";

    /* renamed from: Ԛ  reason: contains not printable characters */
    public File f2725;

    /* renamed from: ؿ  reason: contains not printable characters */
    public String f2726 = "";

    /* renamed from: ݜ  reason: contains not printable characters */
    public String f2727 = "";

    /* renamed from: ඓ  reason: contains not printable characters */
    public IndiaCerActivity f2728;

    /* renamed from: ᑓ  reason: contains not printable characters */
    public String f2729 = "";

    /* renamed from: ᓆ  reason: contains not printable characters */
    public String f2730 = "";

    /* renamed from: ᓣ  reason: contains not printable characters */
    public String f2731 = "";

    /* renamed from: ᕣ  reason: contains not printable characters */
    public String f2732 = "MGYWxZcIKcDcxzxJfDiar42ERXg1Wtimz-ixCl0U";

    /* renamed from: ᨨ  reason: contains not printable characters */
    public String f2733;

    /* renamed from: ⁱ  reason: contains not printable characters */
    public AbstractC1268 f2734;

    /* renamed from: ゎ  reason: contains not printable characters */
    public File f2735;

    /* renamed from: ト  reason: contains not printable characters */
    public Uri f2736;

    /* renamed from: 㑃  reason: contains not printable characters */
    public String f2737 = "ynimage001";

    /* renamed from: 㗗  reason: contains not printable characters */
    public String f2738 = "";

    /* renamed from: 㗽  reason: contains not printable characters */
    public String f2739 = "";

    /* renamed from: 㳳  reason: contains not printable characters */
    public String f2740 = "kFiJToSdmLlsn2ttg-L8_X51Cu4oFialS-9qIKtB";

    /* renamed from: 㴪  reason: contains not printable characters */
    public String f2741 = "";

    /* renamed from: 㴹  reason: contains not printable characters */
    public C1288 f2742;

    /* renamed from: 㶋  reason: contains not printable characters */
    public File f2743;

    /* renamed from: 㸾  reason: contains not printable characters */
    public Unbinder f2744;

    /* renamed from: 㿎  reason: contains not printable characters */
    public C1272 f2745;

    /* renamed from: 䀟  reason: contains not printable characters */
    public String f2746 = "";

    /* renamed from: 䁗  reason: contains not printable characters */
    public String f2747 = "";

    /* renamed from: com.mexico.inloancash.fragment.IndiaStepOneAuthFragment$ῲ  reason: contains not printable characters */
    public class C0505 implements Callback<String> {
        public C0505() {
        }

        @Override // retrofit2.Callback
        public void onFailure(Call<String> call, Throwable th) {
            IndiaStepOneAuthFragment.this.f3640.m2185();
        }

        @Override // retrofit2.Callback
        public void onResponse(Call<String> call, Response<String> response) {
            if (response.isSuccessful()) {
                BaseBean baseBean = (BaseBean) new Gson().fromJson(response.body(), BaseBean.class);
                if (baseBean.getCode() == 200) {
                    IndiaStepOneAuthFragment.this.f2728.m1390(1);
                } else if (baseBean.getCode() == 401) {
                    IndiaStepOneAuthFragment.this.startActivity(new Intent(IndiaStepOneAuthFragment.this.getContext(), IndiaLoginActivity.class));
                } else {
                    C1841.m4792(IndiaStepOneAuthFragment.this.getContext(), baseBean.getMsg());
                }
            }
            IndiaStepOneAuthFragment.this.f3640.m2185();
        }
    }

    /* renamed from: com.mexico.inloancash.fragment.IndiaStepOneAuthFragment$K  reason: contains not printable characters */
    public class C0506 implements AbstractC2521<List<String>, List<File>> {

        /* renamed from: ῲ  reason: contains not printable characters */
        public final /* synthetic */ int f2751;

        public C0506(int i) {
            this.f2751 = i;
        }

        /* Return type fixed from 'java.lang.Object' to match base method */
        /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
        @Override // 㴹.K.䁗.AbstractC2521
        public List<File> apply(List<String> list) throws Exception {
            List<String> list2 = list;
            if (list2.size() > 0) {
                C1468.C1469 r0 = C1468.m3677(IndiaStepOneAuthFragment.this.getActivity());
                r0.m3682(list2);
                IndiaStepOneAuthFragment.this.m1588(new File(r0.m3681().get(0).getAbsolutePath()), this.f2751);
            } else {
                IndiaStepOneAuthFragment.this.f3640.m2185();
            }
            C1468.C1469 r02 = C1468.m3677(IndiaStepOneAuthFragment.this.getActivity());
            r02.m3682(list2);
            return r02.m3681();
        }
    }

    public IndiaStepOneAuthFragment(IndiaCerActivity indiaCerActivity) {
        this.f2728 = indiaCerActivity;
    }

    @Override // androidx.fragment.app.Fragment
    public void onActivityResult(int i, int i2, Intent intent) {
        Bitmap bitmap;
        File file;
        Exception e;
        if (!(i == 1 || i == 2)) {
            if (i != 1000) {
                if (i == 1003) {
                    Log.e("data", "onActivityResult:1003");
                    if (i2 == -1) {
                        ArrayList parcelableArrayListExtra = intent.getParcelableArrayListExtra("extra_result_selection");
                        if (parcelableArrayListExtra != null && !parcelableArrayListExtra.isEmpty()) {
                            C1218<Drawable> r3 = ComponentCallbacks2C1161.m3104(getContext()).m3112();
                            r3.f4833 = (Uri) parcelableArrayListExtra.get(0);
                            r3.f4841 = true;
                            r3.m3290(this.mImageViewPanCard);
                            m1587((Uri) parcelableArrayListExtra.get(0), 1003);
                            this.f3640.m2183();
                        }
                    }
                }
            } else if (i2 == -1) {
                Log.d("onActivityResult", "onActivityResult:1000");
                if (C2383.m6384()) {
                    String str = C2383.f8245;
                    if (str != null) {
                        byte[] decode = Base64.decode(str, 2);
                        bitmap = BitmapFactory.decodeByteArray(decode, 0, decode.length);
                    } else {
                        bitmap = null;
                    }
                    if (Build.VERSION.SDK_INT >= 29) {
                        try {
                            Uri r1 = m1583(getContext(), bitmap, Bitmap.CompressFormat.JPEG, "image/jpeg", (System.currentTimeMillis() / 1000) + ".jpeg");
                            if (r1 != null) {
                                String r0 = C1841.m4785(getContext(), r1);
                                Log.d("loan", "saveImage:" + r0);
                                this.f2743 = new File(r0);
                                Log.d("loan", "Liveness file exists:" + this.f2743.exists());
                                ComponentCallbacks2C1161.m3104(getContext()).m3118(bitmap).m3290(this.idTakeSelf);
                                m1591();
                            } else {
                                Log.d("loan", "uri is null");
                                C1841.m4792(getContext(), "uri is null");
                            }
                        } catch (IOException e2) {
                            e2.printStackTrace();
                            C1841.m4792(getContext(), "save failed");
                        }
                    } else {
                        String str2 = (System.currentTimeMillis() / 1000) + ".jpeg";
                        Log.d("loan", "bitmapToFile:" + str2);
                        try {
                            file = new File(Environment.getExternalStorageDirectory() + File.separator + str2);
                            try {
                                file.createNewFile();
                                ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
                                bitmap.compress(Bitmap.CompressFormat.PNG, 0, byteArrayOutputStream);
                                byte[] byteArray = byteArrayOutputStream.toByteArray();
                                FileOutputStream fileOutputStream = new FileOutputStream(file);
                                fileOutputStream.write(byteArray);
                                fileOutputStream.flush();
                                fileOutputStream.close();
                            } catch (Exception e3) {
                                e = e3;
                            }
                        } catch (Exception e4) {
                            e = e4;
                            file = null;
                            e.printStackTrace();
                            this.f2743 = file;
                            ComponentCallbacks2C1161.m3104(getContext()).m3118(bitmap).m3290(this.idTakeSelf);
                            m1591();
                            super.onActivityResult(i, i2, intent);
                        }
                        this.f2743 = file;
                        ComponentCallbacks2C1161.m3104(getContext()).m3118(bitmap).m3290(this.idTakeSelf);
                        m1591();
                    }
                } else {
                    Log.d("loan", getString(R.string.face_failed));
                }
            }
            super.onActivityResult(i, i2, intent);
        }
        super.onActivityResult(i, i2, intent);
    }

    @Override // androidx.fragment.app.Fragment
    public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        this.f2723 = layoutInflater.inflate(R.layout.india_activity_one_view_auth_layout_fragment, viewGroup, false);
        this.f2744 = ButterKnife.m1067(this, this.f2723);
        this.f2728.m1391(getString(R.string.step1_title));
        C1272.C1273 k = new C1272.C1273();
        k.f4985 = 524288;
        k.f4980 = 1048576;
        k.f4984 = 10;
        k.f4979 = true;
        k.f4982 = 60;
        k.f4981 = this.f2734;
        k.f4983 = C1253.f4935;
        this.f2745 = k.m3378();
        this.f2733 = C0727.m2149(this.f2740, this.f2732).m2150(this.f2737);
        return this.f2723;
    }

    @Override // androidx.fragment.app.Fragment
    public void onDestroy() {
        super.onDestroy();
        this.f2744.m1069();
    }

    public void onViewClicked(View view) {
        File file;
        switch (view.getId()) {
            case R.id.bt_commit /*{ENCODED_INT: 2131296407}*/:
                if (TextUtils.isEmpty(this.f2747)) {
                    Toast.makeText(getContext(), getString(R.string.pan_card_error), 1).show();
                    return;
                } else if (TextUtils.isEmpty(this.f2726)) {
                    Toast.makeText(getContext(), getString(R.string.self_id_card_error), 1).show();
                    return;
                } else if (TextUtils.isEmpty(this.f2724)) {
                    Toast.makeText(getContext(), getString(R.string.id_card_error), 1).show();
                    return;
                } else if (TextUtils.isEmpty(this.f2738)) {
                    Toast.makeText(getContext(), getString(R.string.id_card_back_error), 1).show();
                    return;
                } else if (this.f2725 == null) {
                    Toast.makeText(getContext(), getString(R.string.pan_card_error), 1).show();
                    return;
                } else if (this.f2743 == null) {
                    Toast.makeText(getContext(), getString(R.string.take_self_photo), 1).show();
                    return;
                } else if (TextUtils.isEmpty(this.f2730) || TextUtils.isEmpty(this.f2741)) {
                    Toast.makeText(getContext(), getString(R.string.id_card_error), 1).show();
                    return;
                } else if (TextUtils.isEmpty(this.f2729)) {
                    Toast.makeText(getContext(), getString(R.string.pan_card_error), 1).show();
                    return;
                } else {
                    this.f3640.m2183();
                    if (!(this.f2725 == null || this.f2743 == null)) {
                        for (int i = 0; i < 4; i++) {
                            String str = this.f2733;
                            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
                            String str2 = "icon_" + i + simpleDateFormat.format(new Date());
                            this.f2742 = new C1288(this.f2745);
                            if (i == 0) {
                                file = this.f2725;
                            } else {
                                file = this.f2743;
                            }
                            this.f2742.m3396(file, str2, str, new C0664(this, i), null);
                        }
                        return;
                    }
                    return;
                }
            case R.id.iv_pan_card /*{ENCODED_INT: 2131296627}*/:
                Log.d("loan", "chooseIDCard");
                new C0715(getActivity()).m2142("android.permission.WRITE_EXTERNAL_STORAGE", "android.permission.READ_EXTERNAL_STORAGE", "android.permission.CAMERA").m6544(new C0654(this, 1003));
                return;
            case R.id.iv_take_self /*{ENCODED_INT: 2131296628}*/:
                new C0715(this.f2728).m2142("android.permission.WRITE_EXTERNAL_STORAGE", "android.permission.READ_EXTERNAL_STORAGE", "android.permission.CAMERA").m6542(new C0717()).m6544(new C0662(this));
                return;
            default:
                return;
        }
    }

    /* renamed from: ʬ  reason: contains not printable characters */
    public /* synthetic */ void m1580(Boolean bool) throws Exception {
        if (bool.booleanValue()) {
            startActivityForResult(new Intent(getActivity(), LivenessActivity.class), 1000);
        } else {
            C1841.m4792((Context) this.f2728, getString(R.string.permission));
        }
    }

    /* renamed from: ᨨ  reason: contains not printable characters */
    public void m1581() {
        AbstractC0700 r2 = C0701.f3707.m2131();
        String r3 = C1841.m4788(AccessToken.TOKEN_KEY, "");
        String str = MyApplication.f2291;
        String str2 = this.f2741;
        String str3 = this.f2730;
        String str4 = this.f2727;
        String str5 = this.f2746;
        String str6 = this.f2739;
        String str7 = this.f2731;
        String str8 = this.f2726;
        String str9 = this.f2724;
        String str10 = this.f2738;
        String str11 = this.f2747;
        String str12 = this.f2729;
        C1841.f6259 = C1841.m4812();
        r2.m2122(r3, str, str2, str3, str4, str5, str6, str7, str8, str9, str10, str11, str12, C1841.f6259.getString("appsFlyer_trackerName", "")).enqueue(new C0505());
    }

    /* renamed from: ῲ  reason: contains not printable characters */
    public /* synthetic */ void m1582(Boolean bool) throws Exception {
        if (bool.booleanValue()) {
            m1590();
        } else {
            C1841.m4792(getContext(), getString(R.string.permission));
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m1588(File file, int i) {
        String str = i != 1003 ? "" : "PAN_FRONT";
        C1300 r1 = new C1300();
        r1.f5060 = "https://in-api.advance.ai/in/openapi/face-identity/v1/id-card-ocr";
        r1.f5053.add(new C1300.C1301(MessengerShareContentUtility.MEDIA_IMAGE, file.getName(), file));
        if (r1.f5057 == null) {
            r1.f5057 = new LinkedHashMap();
        }
        r1.f5057.put("X-ADVAI-KEY", "aab0194fb8f86e84");
        if (r1.f5061 == null) {
            r1.f5061 = new LinkedHashMap();
        }
        r1.f5061.put("cardType", str);
        r1.m3431().m3438(new C0507(i));
    }

    /* renamed from: 㳳  reason: contains not printable characters */
    public void m1590() {
        File file = new File(Environment.getExternalStorageDirectory(), "myimage");
        if (!file.exists()) {
            file.mkdirs();
        }
        String format = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
        this.f2735 = new File(file, C1293.m3412(format, ".jpg"));
        if (!this.f2735.exists()) {
            try {
                this.f2735.createNewFile();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
        if (Build.VERSION.SDK_INT < 24) {
            this.f2735 = new File(file, C1293.m3412(format, ".jpg"));
            this.f2736 = Uri.fromFile(this.f2735);
            intent.putExtra("output", this.f2736);
        } else {
            this.f2736 = getActivity().getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, new ContentValues());
            intent.putExtra("output", this.f2736);
        }
        startActivityForResult(intent, 2);
    }

    /* renamed from: 㿎  reason: contains not printable characters */
    public void m1591() {
        if (this.f2743 != null) {
            this.f3640.m2183();
            C1300 r0 = new C1300();
            r0.f5060 = "https://in-api.advance.ai/in/openapi/face-identity/v1/face-comparison";
            r0.f5053.add(new C1300.C1301("secondImage", this.f2743.getName(), this.f2743));
            if (r0.f5057 == null) {
                r0.f5057 = new LinkedHashMap();
            }
            r0.f5057.put("X-ADVAI-KEY", "aab0194fb8f86e84");
            r0.m3431().m3438(new C0504());
        }
    }

    /* renamed from: com.mexico.inloancash.fragment.IndiaStepOneAuthFragment$ʬ  reason: contains not printable characters */
    public class C0504 extends AbstractC1294 {
        public C0504() {
        }

        /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object, int] */
        @Override // ඓ.㳳.K.K.ʬ.AbstractC1295
        /* renamed from: K  reason: contains not printable characters */
        public void m1592(String str, int i) {
            IndiaStepOneAuthFragment.this.f3640.m2185();
            IndiaStepOneAuthFragment.this.f2726 = str;
        }

        @Override // ඓ.㳳.K.K.ʬ.AbstractC1295
        /* renamed from: K  reason: contains not printable characters */
        public void m1593(AbstractC2537 r1, Exception exc, int i) {
            C1841.m4792((Context) IndiaStepOneAuthFragment.this.getActivity(), exc.getMessage());
            IndiaStepOneAuthFragment.this.f3640.m2185();
        }
    }

    @Override // ඓ.ඓ.K.㳳.AbstractC0671
    @SuppressLint({"CheckResult"})
    /* renamed from: ʬ  reason: contains not printable characters */
    public void m1579() {
        new C0715(this.f2728).m2142("android.permission.WRITE_EXTERNAL_STORAGE", "android.permission.READ_EXTERNAL_STORAGE", "android.permission.CAMERA").m6542(new C0717()).m6544(new C0661(this));
    }

    /* renamed from: com.mexico.inloancash.fragment.IndiaStepOneAuthFragment$㸾  reason: contains not printable characters */
    public class C0507 extends AbstractC1294 {

        /* renamed from: ῲ  reason: contains not printable characters */
        public final /* synthetic */ int f2753;

        public C0507(int i) {
            this.f2753 = i;
        }

        /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object, int] */
        @Override // ඓ.㳳.K.K.ʬ.AbstractC1295
        /* renamed from: K  reason: contains not printable characters */
        public void m1594(String str, int i) {
            String str2 = str;
            if (this.f2753 == 1003) {
                Log.e("data", "REQUEST_CODE_PAN_CARD" + str2);
                IndiaStepOneAuthFragment.this.f3640.m2185();
                IndiaStepOneAuthFragment.this.f2747 = str2;
                PcDataBean pcDataBean = (PcDataBean) new Gson().fromJson(str2, PcDataBean.class);
                if (pcDataBean.getData() != null) {
                    IndiaStepOneAuthFragment.this.f2729 = pcDataBean.getData().getValues().getIdNumber();
                }
            }
        }

        @Override // ඓ.㳳.K.K.ʬ.AbstractC1295
        /* renamed from: K  reason: contains not printable characters */
        public void m1595(AbstractC2537 r1, Exception exc, int i) {
            IndiaStepOneAuthFragment.this.f3640.m2185();
            C1841.m4792((Context) IndiaStepOneAuthFragment.this.getActivity(), exc.getMessage());
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public /* synthetic */ void m1586(int i, String str, C1248 r3, JSONObject jSONObject) {
        if (r3.m3322()) {
            if (i == 0) {
                this.f2731 = str;
                StringBuilder r1 = C1293.m3416("panCardKey:");
                r1.append(this.f2731);
                Log.e("data", r1.toString());
            } else if (i == 1) {
                this.f2739 = str;
                StringBuilder r12 = C1293.m3416("selfKey:");
                r12.append(this.f2739);
                Log.e("data", r12.toString());
            } else if (i == 2) {
                this.f2727 = str;
                StringBuilder r13 = C1293.m3416("idCardFrontKey:");
                r13.append(this.f2727);
                Log.e("data", r13.toString());
            } else if (i == 3) {
                this.f2746 = str;
                StringBuilder r14 = C1293.m3416("idCardBackKey:");
                r14.append(this.f2746);
                Log.e("data", r14.toString());
            }
            if (!TextUtils.isEmpty(this.f2731) && !TextUtils.isEmpty(this.f2739) && !TextUtils.isEmpty(this.f2727) && !TextUtils.isEmpty(this.f2746)) {
                m1581();
                Log.e("data", "Uploaded backend");
                return;
            }
            return;
        }
        this.f3640.m2185();
        getActivity().runOnUiThread(new RunnableC0665(this));
    }

    /* renamed from: K  reason: contains not printable characters */
    public /* synthetic */ void m1585(int i, Boolean bool) throws Exception {
        if (bool.booleanValue()) {
            C0804 r1 = new C0804(new C0805(this), EnumSet.of(MimeType.JPEG, MimeType.PNG), true);
            r1.f4006.f3944 = true;
            r1.m2392(1);
            C0778 r0 = r1.f4006;
            r0.f3946 = 10;
            r0.f3961 = false;
            r0.f3952 = true;
            r0.f3949 = 1;
            r1.f4006.f3957 = new C0782(true, "com.indiarapido.indiapeso.fileProvider");
            r1.m2393(0.85f);
            C0778 r02 = r1.f4006;
            r02.f3950 = false;
            r02.f3949 = 1;
            C0765 k = new C0765();
            C0778 r03 = r1.f4006;
            r03.f3947 = k;
            r03.f3963 = R.style.MyMatisse;
            r1.m2394(i);
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m1587(Uri uri, int i) {
        Log.d("loan", "compressIDCard");
        String r3 = C1841.m4785(getContext(), uri);
        if (TextUtils.isEmpty(r3)) {
            this.f3640.m2185();
            Toast.makeText(getActivity(), "path error", 0).show();
            return;
        }
        ArrayList arrayList = new ArrayList();
        arrayList.add(r3);
        AbstractC2511.m6557(arrayList).m6558(C2491.m6534()).m6559((AbstractC2521) new C0506(i)).m6558(C2505.m6549()).m6560();
    }

    /* JADX WARNING: Code restructure failed: missing block: B:18:0x0047, code lost:
        r4 = e;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:19:0x0048, code lost:
        r0 = null;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:22:0x0052, code lost:
        r3 = th;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:23:0x0053, code lost:
        r0 = null;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:28:?, code lost:
        r3.delete(r7, null, null);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:30:0x005e, code lost:
        r3 = th;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:31:0x005f, code lost:
        if (r0 != null) goto L_0x0061;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:32:0x0061, code lost:
        r0.close();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:33:0x0064, code lost:
        throw r3;
     */
    /* JADX WARNING: Failed to process nested try/catch */
    /* JADX WARNING: Removed duplicated region for block: B:22:0x0052 A[ExcHandler: all (th java.lang.Throwable), Splitter:B:1:0x001b] */
    /* JADX WARNING: Removed duplicated region for block: B:27:0x005a A[SYNTHETIC, Splitter:B:27:0x005a] */
    /* JADX WARNING: Removed duplicated region for block: B:32:0x0061  */
    /* renamed from: K  reason: contains not printable characters */
    public final Uri m1583(Context context, Bitmap bitmap, Bitmap.CompressFormat compressFormat, String str, String str2) throws IOException {
        OutputStream outputStream;
        Uri uri;
        IOException e;
        ContentValues contentValues = new ContentValues();
        contentValues.put("_display_name", str2);
        contentValues.put("mime_type", str);
        contentValues.put("relative_path", "Pictures/DomepetCash");
        ContentResolver contentResolver = context.getContentResolver();
        try {
            uri = contentResolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, contentValues);
            if (uri != null) {
                outputStream = contentResolver.openOutputStream(uri);
                if (outputStream != null) {
                    try {
                        if (bitmap.compress(compressFormat, 95, outputStream)) {
                            outputStream.close();
                            return uri;
                        }
                        throw new IOException("Failed to save bitmap.");
                    } catch (IOException e2) {
                        e = e2;
                        if (uri != null) {
                        }
                        throw e;
                    }
                } else {
                    throw new IOException("Failed to get output stream.");
                }
            } else {
                throw new IOException("Failed to create new MediaStore record.");
            }
        } catch (IOException e3) {
            e = e3;
            uri = null;
            outputStream = null;
            if (uri != null) {
            }
            throw e;
        } catch (Throwable th) {
        }
    }

    @Override // ඓ.ඓ.K.㳳.AbstractC0671
    @SuppressLint({"CheckResult"})
    /* renamed from: K  reason: contains not printable characters */
    public void m1584() {
        new C0715(this.f2728).m2142("android.permission.WRITE_EXTERNAL_STORAGE", "android.permission.READ_EXTERNAL_STORAGE", "android.permission.CAMERA").m6542(new C0717()).m6544(new C0656(this));
    }

    /* renamed from: K  reason: contains not printable characters */
    public /* synthetic */ void m1589(Boolean bool) throws Exception {
        if (bool.booleanValue()) {
            startActivityForResult(new Intent("android.intent.action.PICK", MediaStore.Images.Media.EXTERNAL_CONTENT_URI), 1);
        } else {
            C1841.m4792(getContext(), getString(R.string.permission));
        }
    }
}
