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.os.Handler;
import android.os.Message;
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.India_User_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 ඓ.ඓ.K.ῲ.C0635;
import ඓ.ඓ.K.ῲ.C0640;
import ඓ.ඓ.K.ῲ.C0642;
import ඓ.ඓ.K.ῲ.RunnableC0643;
import ඓ.ඓ.K.㳳.AbstractC0671;
import ඓ.ඓ.K.㴹.DialogC0677;
import ඓ.ඓ.K.㿎.AbstractC0700;
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 IndiaRecommendationActivity extends BaseActivity implements AbstractC0671 {
    public ImageView mGonBack;
    public ImageView mImage;
    public EditText mIndiaEtEmail;
    public Button mIndia_Button_Submit;
    public TextView mTvCount;
    public EditText mTvOpinions;
    public TextView mTvTitle;

    /* renamed from: Ԕ  reason: contains not printable characters */
    public Handler f2488 = new HandlerC0426();

    /* renamed from: ؿ  reason: contains not printable characters */
    public Uri f2489;

    /* renamed from: ඓ  reason: contains not printable characters */
    public India_User_Opinion_Bean f2490;

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

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

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

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

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

    /* renamed from: 㗗  reason: contains not printable characters */
    public File f2496;

    /* renamed from: 㗽  reason: contains not printable characters */
    public File f2497 = null;

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

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

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

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

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

        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) {
            IndiaRecommendationActivity.this.m1448();
        }
    }

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

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

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

        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) {
            IndiaRecommendationActivity.this.m1448();
            TextView textView = IndiaRecommendationActivity.this.mTvCount;
            textView.setText(charSequence.length() + "/200");
        }
    }

    /* renamed from: com.mexico.inloancash.activity.IndiaRecommendationActivity$K  reason: contains not printable characters */
    public class HandlerC0426 extends Handler {
        public HandlerC0426() {
        }

        public void handleMessage(Message message) {
            super.handleMessage(message);
            if (message.arg1 == 0) {
                C1841.m4792((Context) IndiaRecommendationActivity.this, "Image upload failed, please check internet connection");
            }
        }
    }

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

        @Override // retrofit2.Callback
        public void onFailure(Call<String> call, Throwable th) {
            IndiaRecommendationActivity.this.f2296.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) {
                    C1841.m4792((Context) IndiaRecommendationActivity.this, "Submitted successfully");
                    IndiaRecommendationActivity.this.finish();
                } else if (baseBean.getCode() == 401) {
                    IndiaRecommendationActivity.this.startActivity(new Intent(IndiaRecommendationActivity.this, IndiaLoginActivity.class));
                }
            }
        }
    }

    @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.f2496;
                    if (file != null) {
                        this.f2491 = file;
                    } else {
                        return;
                    }
                } else {
                    this.f2491 = new File(C1841.m4786(this.f2489, this));
                    if (this.f2491 == null) {
                        return;
                    }
                }
                this.f2296.m2183();
                m1446();
            }
        } else if (intent != null) {
            this.f2489 = intent.getData();
            this.f2491 = new File(C1841.m4786(this.f2489, this));
            this.f2296.m2183();
            m1446();
        }
    }

    @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.india_activity_view_suggest_layout);
        ButterKnife.m1066(this);
        this.mTvTitle.setText("Feedback");
        this.f2490 = new India_User_Opinion_Bean();
        this.mTvOpinions.requestFocus();
        C1272.C1273 k = new C1272.C1273();
        k.f4985 = 524288;
        k.f4980 = 1048576;
        k.f4984 = 10;
        k.f4979 = true;
        k.f4982 = 60;
        k.f4981 = this.f2500;
        k.f4983 = C1253.f4935;
        this.f2493 = k.m3378();
        this.f2498 = C0727.m2149(this.f2492, this.f2495).m2150(this.f2501);
        this.mTvOpinions.addTextChangedListener(new C0425());
        this.mIndiaEtEmail.addTextChangedListener(new C0423());
    }

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

    public void onViewClicked(View view) {
        int id = view.getId();
        if (id == R.id.image) {
            new DialogC0677(this, this).show();
        } else if (id == R.id.logon_back) {
            finish();
        } else if (id == R.id.submit) {
            m1447();
        }
    }

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

    /* renamed from: ؿ  reason: contains not printable characters */
    public void m1446() {
        File file = this.f2491;
        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 C0424()).m6558(C2505.m6549()).m6560();
        }
    }

    /* renamed from: ݜ  reason: contains not printable characters */
    public void m1447() {
        if (C1293.m3418(this.mTvOpinions)) {
            C1841.m4792((Context) this, "Please enter your feedback");
        } else if (C1293.m3418(this.mIndiaEtEmail)) {
            C1841.m4792((Context) this, "Please enter your contact number");
        } else if (this.f2497 == null) {
            C1841.m4792((Context) this, "Please take and upload a feedback photo");
        } else {
            this.f2296.m2183();
            String str = this.f2498;
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
            StringBuilder r1 = C1293.m3416("icon_3");
            r1.append(simpleDateFormat.format(new Date()));
            String sb = r1.toString();
            this.f2494 = new C1288(this.f2493);
            this.f2494.m3396(this.f2497, sb, str, new C0642(this), null);
        }
    }

    /* renamed from: ᓣ  reason: contains not printable characters */
    public void m1448() {
        if (C1293.m3418(this.mTvOpinions)) {
            this.mIndia_Button_Submit.setSelected(false);
        } else if (C1293.m3418(this.mIndiaEtEmail)) {
            this.mIndia_Button_Submit.setSelected(false);
        } else {
            this.mIndia_Button_Submit.setSelected(true);
        }
    }

    /* renamed from: ῲ  reason: contains not printable characters */
    public /* synthetic */ void m1449(Boolean bool) throws Exception {
        if (bool.booleanValue()) {
            m1454();
        } else {
            C1841.m4792((Context) this, "Please turn on memory card read/write, camera access");
        }
    }

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

    /* renamed from: 㗽  reason: contains not printable characters */
    public void m1453() {
        AbstractC0700 r1 = C0701.f3707.m2131();
        String r2 = C1841.m4788(AccessToken.TOKEN_KEY, "");
        MyApplication.m1353();
        r1.m2113(r2, MyApplication.f2291, this.f2490.getOpinoin(), this.f2490.getImg(), this.f2490.getEmail()).enqueue(new C0427());
    }

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

    /* renamed from: K  reason: contains not printable characters */
    public /* synthetic */ void m1451(Boolean bool) throws Exception {
        if (bool.booleanValue()) {
            startActivityForResult(new Intent("android.intent.action.PICK", MediaStore.Images.Media.EXTERNAL_CONTENT_URI), 1);
        } else {
            C1841.m4792((Context) this, "Please turn on memory card read/write, camera access");
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public /* synthetic */ void m1452(String str, C1248 r2, JSONObject jSONObject) {
        if (r2.m3322()) {
            this.f2499 = str;
            if (!TextUtils.isEmpty(this.f2499)) {
                this.f2490.setEmail(this.mIndiaEtEmail.getText().toString().trim());
                this.f2490.setImg(this.f2499);
                this.f2490.setOpinoin(this.mTvOpinions.getText().toString().trim());
                m1453();
                return;
            }
            return;
        }
        this.f2296.m2185();
        Message message = new Message();
        message.arg1 = 0;
        this.f2488.sendMessage(message);
    }
}
