package com.mexico.inloancash.activity;

import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.provider.MediaStore;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import butterknife.ButterKnife;
import com.facebook.AccessToken;
import com.google.gson.Gson;
import com.indiaholacash.holacash.R;
import com.mexico.inloancash.MyApplication;
import com.mexico.inloancash.bean.BaseBean;
import com.mexico.inloancash.bean.Mexico_Opinion_Bean;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.json.JSONObject;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import ඓ.ඓ.K.ῲ.C0636;
import ඓ.ඓ.K.ῲ.C0641;
import ඓ.ඓ.K.ῲ.C0644;
import ඓ.ඓ.K.ῲ.C0645;
import ඓ.ඓ.K.ῲ.RunnableC0637;
import ඓ.ඓ.K.㳳.AbstractC0671;
import ඓ.ඓ.K.㴹.DialogC0689;
import ඓ.ඓ.K.㿎.C0701;
import ඓ.ඓ.K.䁗.C0727;
import ඓ.ඓ.K.䁗.ᓆ.C0715;
import ඓ.ඓ.K.䁗.ᓆ.C0717;
import ඓ.ⁱ.K.ʬ.C1248;
import ඓ.ⁱ.K.ῲ.C1253;
import ඓ.ⁱ.K.㸾.AbstractC1268;
import ඓ.ⁱ.K.㸾.C1272;
import ඓ.ⁱ.K.㸾.C1288;
import ඓ.K.K.K.C1293;
import ᕣ.K.K.C1468;
import ῲ.ᨨ.㳳.C1841;
import 㴹.K.AbstractC2511;
import 㴹.K.ؿ.C2491;
import 㴹.K.ᕣ.K.C2505;
import 㴹.K.䁗.AbstractC2521;

public class Mexico_FeedBackActivity extends BaseActivity implements AbstractC0671 {
    public TextView count;
    public ImageView image;
    public ImageView logonBack;
    public EditText opinion;
    public EditText opinionEmail;
    public Button submit;
    public TextView title;

    /* renamed from: Ԕ  reason: contains not printable characters */
    public File f2570;

    /* renamed from: ؿ  reason: contains not printable characters */
    public File f2571 = null;

    /* renamed from: ඓ  reason: contains not printable characters */
    public Mexico_Opinion_Bean f2572;

    /* renamed from: ᓣ  reason: contains not printable characters */
    public File f2573 = null;

    /* renamed from: ᕣ  reason: contains not printable characters */
    public String f2574 = "lb5ntuPzvl6BoSqL5yato8Pqwg5WXoPHGVzTktIt";

    /* renamed from: ᨨ  reason: contains not printable characters */
    public C1272 f2575;

    /* renamed from: ⁱ  reason: contains not printable characters */
    public C1288 f2576;

    /* renamed from: 㑃  reason: contains not printable characters */
    public String f2577 = "7i3g_SDTFCvJ-TYs3FBfCJJtki8Rp2hYfNVIK908";

    /* renamed from: 㗗  reason: contains not printable characters */
    public Uri f2578;

    /* renamed from: 㳳  reason: contains not printable characters */
    public String f2579;

    /* renamed from: 㴹  reason: contains not printable characters */
    public String f2580 = "";

    /* renamed from: 㿎  reason: contains not printable characters */
    public AbstractC1268 f2581;

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

    /* renamed from: com.mexico.inloancash.activity.Mexico_FeedBackActivity$ʬ  reason: contains not printable characters */
    public class C0454 implements Callback<String> {
        public C0454() {
        }

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

        @Override // retrofit2.Callback
        public void onResponse(Call<String> call, Response<String> response) {
            Mexico_FeedBackActivity.this.f2296.m2185();
            if (response.isSuccessful()) {
                BaseBean baseBean = (BaseBean) new Gson().fromJson(response.body(), BaseBean.class);
                if (baseBean.getCode() == 200) {
                    C1841.m4792((Context) Mexico_FeedBackActivity.this, "Submit Successful");
                    Mexico_FeedBackActivity.this.finish();
                } else if (baseBean.getCode() == 401) {
                    Mexico_FeedBackActivity.this.finish();
                } else {
                    C1841.m4792((Context) Mexico_FeedBackActivity.this, baseBean.getMsg());
                    Mexico_FeedBackActivity.this.finish();
                }
            }
        }
    }

    /* renamed from: com.mexico.inloancash.activity.Mexico_FeedBackActivity$ῲ  reason: contains not printable characters */
    public class C0455 implements TextWatcher {
        public C0455() {
        }

        public void afterTextChanged(Editable editable) {
        }

        public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
        }

        public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
            Mexico_FeedBackActivity.this.m1504();
        }
    }

    /* renamed from: com.mexico.inloancash.activity.Mexico_FeedBackActivity$K  reason: contains not printable characters */
    public class C0456 implements TextWatcher {
        public C0456() {
        }

        public void afterTextChanged(Editable editable) {
        }

        public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
        }

        public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
            Mexico_FeedBackActivity.this.m1504();
            TextView textView = Mexico_FeedBackActivity.this.count;
            textView.setText(charSequence.length() + "/200");
        }
    }

    /* renamed from: com.mexico.inloancash.activity.Mexico_FeedBackActivity$㸾  reason: contains not printable characters */
    public class C0457 implements AbstractC2521<List<String>, List<File>> {
        public C0457() {
        }

        /* 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(Mexico_FeedBackActivity.this);
                r0.m3682(list2);
                File file = new File(r0.m3681().get(0).getAbsolutePath());
                Mexico_FeedBackActivity mexico_FeedBackActivity = Mexico_FeedBackActivity.this;
                mexico_FeedBackActivity.f2573 = file;
                mexico_FeedBackActivity.runOnUiThread(new RunnableC0637(this));
            } else {
                Mexico_FeedBackActivity.this.f2296.m2185();
            }
            C1468.C1469 r02 = C1468.m3677(Mexico_FeedBackActivity.this);
            r02.m3682(list2);
            return r02.m3681();
        }
    }

    @Override // androidx.fragment.app.FragmentActivity
    public void onActivityResult(int i, int i2, Intent intent) {
        super.onActivityResult(i, i2, intent);
        if (i != 1) {
            if (i == 2) {
                if (Build.VERSION.SDK_INT < 24) {
                    File file = this.f2570;
                    if (file != null) {
                        this.f2571 = file;
                    } else {
                        return;
                    }
                } else {
                    this.f2571 = new File(C1841.m4786(this.f2578, this));
                    if (this.f2571 == null) {
                        return;
                    }
                }
                this.f2296.m2183();
                m1497();
            }
        } else if (intent != null) {
            this.f2578 = intent.getData();
            this.f2571 = new File(C1841.m4786(this.f2578, this));
            this.f2296.m2183();
            m1497();
        }
    }

    @Override // androidx.activity.ComponentActivity, androidx.core.app.ComponentActivity, com.mexico.inloancash.activity.BaseActivity, androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(R.layout.activity_feed_back);
        ButterKnife.m1066(this);
        this.title.setText(getString(R.string.feed));
        this.f2572 = new Mexico_Opinion_Bean();
        MyApplication.m1353().m1355(this);
        C1272.C1273 k = new C1272.C1273();
        k.f4985 = 524288;
        k.f4980 = 1048576;
        k.f4984 = 10;
        k.f4979 = true;
        k.f4982 = 60;
        k.f4981 = this.f2581;
        k.f4983 = C1253.f4935;
        this.f2575 = k.m3378();
        this.f2579 = C0727.m2149(this.f2574, this.f2577).m2150(this.f2582);
        this.opinion.addTextChangedListener(new C0456());
        this.opinionEmail.addTextChangedListener(new C0455());
    }

    @Override // androidx.appcompat.app.AppCompatActivity
    public boolean onKeyDown(int i, KeyEvent keyEvent) {
        if (i == 4) {
            MyApplication.m1353().m1354(this);
        }
        return super.onKeyDown(i, keyEvent);
    }

    public void onViewClicked(View view) {
        int id = view.getId();
        if (id == R.id.image) {
            new C0715(this).m2142("android.permission.WRITE_EXTERNAL_STORAGE", "android.permission.READ_EXTERNAL_STORAGE", "android.permission.CAMERA").m6542(new C0717()).m6544(new C0641(this));
        } else if (id == R.id.logon_back) {
            MyApplication.m1353().m1354(this);
            finish();
        } else if (id == R.id.submit) {
            m1498();
        }
    }

    /* renamed from: ʬ  reason: contains not printable characters */
    public /* synthetic */ void m1496(Boolean bool) throws Exception {
        if (bool.booleanValue()) {
            new DialogC0689(this, this).show();
        } else {
            C1841.m4792((Context) this, "Por favor, active la lectura/escritura de la tarjeta de memoria, el acceso a la cámara");
        }
    }

    /* renamed from: ؿ  reason: contains not printable characters */
    public void m1497() {
        File file = this.f2571;
        if (file != null) {
            String absolutePath = file.getAbsolutePath();
            if (TextUtils.isEmpty(absolutePath)) {
                this.f2296.m2185();
                Toast.makeText(this, "path error", 0).show();
                return;
            }
            ArrayList arrayList = new ArrayList();
            arrayList.add(absolutePath);
            AbstractC2511.m6557(arrayList).m6558(C2491.m6534()).m6559((AbstractC2521) new C0457()).m6558(C2505.m6549()).m6560();
        }
    }

    /* renamed from: ݜ  reason: contains not printable characters */
    public void m1498() {
        if (C1293.m3418(this.opinion)) {
            C1841.m4792((Context) this, getString(R.string.please_fill_in_the_information));
        } else if (C1293.m3418(this.opinionEmail)) {
            C1841.m4792((Context) this, getString(R.string.please_fill_in_the_information));
        } else {
            this.f2296.m2183();
            String str = this.f2579;
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
            StringBuilder r1 = C1293.m3416("icon_3");
            r1.append(simpleDateFormat.format(new Date()));
            String sb = r1.toString();
            this.f2576 = new C1288(this.f2575);
            this.f2576.m3396(this.f2573, sb, str, new C0645(this), null);
        }
    }

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

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

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

    /* renamed from: 㗽  reason: contains not printable characters */
    public void m1504() {
        if (C1293.m3418(this.opinion)) {
            this.submit.setSelected(false);
        } else if (C1293.m3418(this.opinionEmail)) {
            this.submit.setSelected(false);
        } else {
            this.submit.setSelected(true);
        }
    }

    /* renamed from: 䀟  reason: contains not printable characters */
    public void m1505() {
        C0701.f3707.m2131().m2113(C1841.m4788(AccessToken.TOKEN_KEY, ""), MyApplication.f2291, this.opinion.getText().toString().trim(), this.f2580, this.opinionEmail.getText().toString().trim()).enqueue(new C0454());
    }

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

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

    /* renamed from: K  reason: contains not printable characters */
    public /* synthetic */ void m1503(String str, C1248 r2, JSONObject jSONObject) {
        if (r2.m3322()) {
            this.f2580 = str;
            if (!TextUtils.isEmpty(this.f2580)) {
                this.f2572.setEmail(this.opinionEmail.getText().toString().trim());
                this.f2572.setImg(this.f2580);
                this.f2572.setOpinoin(this.opinion.getText().toString().trim());
                m1505();
                return;
            }
            return;
        }
        this.f2296.m2185();
        C1841.m4792((Context) this, "Image upload failed, please check network connection");
    }
}
