导航菜单

页面标题

页面副标题

MedEd v5.3.6 - ConversationDetailActivity.java 源代码

正在查看: MedEd v5.3.6 应用的 ConversationDetailActivity.java JAVA 源代码文件

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


package com.freshchat.consumer.sdk.activity;

import android.app.ProgressDialog;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.net.ConnectivityManager;
import android.net.NetworkRequest;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.text.Html;
import android.text.TextWatcher;
import android.util.SparseBooleanArray;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.OrientationEventListener;
import android.view.View;
import android.view.ViewGroup;
import android.view.autofill.AutofillManager;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.RatingBar;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.TimePicker;
import androidx.appcompat.app.c;
import androidx.compose.ui.input.key.mmtm.EZkPENtU;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager$SavedState;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView$p;
import com.freshchat.consumer.sdk.R;
import com.freshchat.consumer.sdk.a.ab;
import com.freshchat.consumer.sdk.a.ad;
import com.freshchat.consumer.sdk.a.b;
import com.freshchat.consumer.sdk.a.k;
import com.freshchat.consumer.sdk.a.p;
import com.freshchat.consumer.sdk.beans.CalendarDay;
import com.freshchat.consumer.sdk.beans.CalendarMessageMeta;
import com.freshchat.consumer.sdk.beans.Channel;
import com.freshchat.consumer.sdk.beans.Conversation;
import com.freshchat.consumer.sdk.beans.CountryCode;
import com.freshchat.consumer.sdk.beans.Csat;
import com.freshchat.consumer.sdk.beans.CsatResponse;
import com.freshchat.consumer.sdk.beans.Message;
import com.freshchat.consumer.sdk.beans.Participant;
import com.freshchat.consumer.sdk.beans.QuickActions;
import com.freshchat.consumer.sdk.beans.QuickReplyOptions;
import com.freshchat.consumer.sdk.beans.config.RemoteConfig;
import com.freshchat.consumer.sdk.beans.feedback.OpinionOption;
import com.freshchat.consumer.sdk.beans.feedback.RatingOption;
import com.freshchat.consumer.sdk.beans.fragment.AudioFragment;
import com.freshchat.consumer.sdk.beans.fragment.CarouselCardDefaultFragment;
import com.freshchat.consumer.sdk.beans.fragment.DateFragment;
import com.freshchat.consumer.sdk.beans.fragment.FileFragment;
import com.freshchat.consumer.sdk.beans.fragment.ImageFragment;
import com.freshchat.consumer.sdk.beans.fragment.MessageFragment;
import com.freshchat.consumer.sdk.beans.fragment.MultiSelectCheckedButtonFragment;
import com.freshchat.consumer.sdk.beans.fragment.QuickReplyButtonFragment;
import com.freshchat.consumer.sdk.beans.fragment.QuickReplyDropDownFragment;
import com.freshchat.consumer.sdk.beans.fragment.TextFragment;
import com.freshchat.consumer.sdk.beans.reqres.CsatResponseRequest;
import com.freshchat.consumer.sdk.d.f;
import com.freshchat.consumer.sdk.j.c;
import com.freshchat.consumer.sdk.l.m;
import com.freshchat.consumer.sdk.l.y;
import com.freshchat.consumer.sdk.service.Status;
import com.freshchat.consumer.sdk.service.d.g;
import com.freshchat.consumer.sdk.service.e.k$a;
import com.freshchat.consumer.sdk.ui.FlowLayout;
import com.freshchat.consumer.sdk.ui.QuickActionsAutoCompleteView;
import com.freshchat.consumer.sdk.ui.an;
import com.freshchat.consumer.sdk.ui.b;
import com.freshchat.consumer.sdk.ui.o;
import com.freshchat.consumer.sdk.ui.p;
import com.freshchat.consumer.sdk.util.Cdo;
import com.freshchat.consumer.sdk.util.FreshchatRecyclerView;
import com.freshchat.consumer.sdk.util.cy;
import com.freshchat.consumer.sdk.util.da;
import com.freshchat.consumer.sdk.util.k;
import com.freshchat.consumer.sdk.util.q;
import com.penpencil.network.response.MZlY.JixXvsprIVCroZ;
import com.penpencil.player_engagement.live_chat.feature.blockscreens.data.model.hqLo.pdCqGbSVuq;
import defpackage.C2516sf;
import defpackage.C2615tf;
import defpackage.Ml1$a;
import in.juspay.hypersdk.mystique.bG.FrpdF;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class ConversationDetailActivity extends cr implements com.freshchat.consumer.sdk.util.ea, f.a, ad.a, ad.c, ad.b, p.a, k.a, o.a, an.a {
    private static String BM = null;
    private static long cK = 0;
    public static final String i = "com.freshchat.consumer.sdk.activity.ConversationDetailActivity";
    private String[] B;
    private long a;
    private com.freshchat.consumer.sdk.b.f aR;
    private com.freshchat.consumer.sdk.c.k aZ;
    private String b;
    private View bA;
    private TextView bC;
    private View bD;
    private View bE;
    private FreshchatRecyclerView bF;
    private LinearLayoutManager bG;
    private LinearLayoutManager bH;
    private QuickActionsAutoCompleteView bI;
    private View bJ;
    private View bK;
    private View bL;
    private View bM;
    private ProgressBar bN;
    private TextView bO;
    private androidx.appcompat.app.c bP;
    private View bQ;
    private View bR;
    private TextView bS;
    private View bT;
    private RecyclerView bU;
    private RelativeLayout bV;
    private TextView bW;
    private RecyclerView bX;
    private View bY;
    private TextView bZ;
    private ClipboardManager bc;
    private com.freshchat.consumer.sdk.util.k bk;
    private View bp;
    private View bu;
    private View bx;
    private String c;
    private String cA;
    private com.freshchat.consumer.sdk.a.z cB;
    private Button cC;
    private boolean cF;
    private RemoteConfig cG;
    private com.freshchat.consumer.sdk.a.p cH;
    private Uri cJ;
    private ConnectivityManager.NetworkCallback cL;
    private com.freshchat.consumer.sdk.l.m cM;
    private com.freshchat.consumer.sdk.l.ab cN;
    private com.freshchat.consumer.sdk.d.f cO;
    private boolean cQ;
    private boolean cR;
    private com.freshchat.consumer.sdk.util.dk cT;
    private ScrollView cU;
    private View cW;
    private View cX;
    private OrientationEventListener cY;
    private Button cb;
    private View ce;
    private TextView cj;
    private Button cp;
    private MenuItem cq;
    private com.freshchat.consumer.sdk.ui.ak cs;
    private com.freshchat.consumer.sdk.util.dl ct;
    private QuickActions d;
    private Button dA;
    private List<MessageFragment> dD;
    private SparseBooleanArray dE;
    private View da;
    private ImageView db;
    private TextView dc;
    private View dd;
    private TextView df;
    private boolean dg;
    private CountDownTimer dh;
    private ProgressDialog di;
    private View dn;

    private View f2do;
    private boolean dp;
    private com.freshchat.consumer.sdk.a.w dr;
    private List<OpinionOption> ds;
    private TextView dt;
    private RatingBar du;
    private Button dv;
    private View dw;
    private TextView dx;
    private View dy;
    private int e;
    private String h;
    private com.freshchat.consumer.sdk.l.w cD = com.freshchat.consumer.sdk.l.w.UNDEFINED;
    private Map<String, Participant> cE = new HashMap();
    private long cP = -1;
    List<String> f = new ArrayList();
    List<String> g = new ArrayList();
    List<MessageFragment> cS = new ArrayList();
    private boolean cZ = false;
    private long dl = -1;
    private final com.freshchat.consumer.sdk.g.d dq = new aa(this);
    private final List<MessageFragment> dB = new ArrayList();
    private final List<CarouselCardDefaultFragment> dC = new ArrayList();
    private com.freshchat.consumer.sdk.g.b dF = new cj(this);
    private final p.g dG = new cp(this);
    private final p.k dH = new cq(this);
    private final p.a dI = new ac(this);
    private b.a dJ = new ad(this);
    private final b.c dK = new ae(this);
    private final b.InterfaceC0087b dL = new ag(this);
    private p.i dM = new ah(this);
    final p.l dN = new al(this);
    private ab.a dO = new at(this);
    private TextWatcher dP = new ay(this);
    private View.OnClickListener dQ = new ba(this);
    private View.OnClickListener dR = new bb(this);
    private View.OnLongClickListener dS = new bc(this);
    private final View.OnClickListener dT = new bd(this);
    private Ml1$a<List<Message>> dU = new be(this);
    private c.b dV = new bq(this);
    private Ml1$a<Channel> dW = new bs(this);
    private View.OnClickListener dX = new bt(this);
    View.OnClickListener dY = new cb(this);
    private final q.a dZ = new cm(this);

    private boolean a0() {
        return this.cM.lD() && this.cM.hr().hasPendingCsat();
    }

    private boolean aA() {
        com.freshchat.consumer.sdk.util.k kVar = this.bk;
        return (kVar == null || kVar.ja() == null || !this.bk.ja().aA()) ? false : true;
    }

    private void aB() {
        if (this.cM.hH().i(this.cM.b(), this.cM.mA()) <= 0 || !this.cM.lD()) {
            return;
        }
        com.freshchat.consumer.sdk.util.b.a(a(), this.cM.b(), this.cM.mA());
    }

    private void aC() {
        try {
            Set<Long> p = this.cM.hH().p(this.cM.b());
            com.freshchat.consumer.sdk.util.co.a(i, "Unread marketing Ids for channel " + this.cM.b() + " are " + p);
            Iterator<Long> it = p.iterator();
            while (it.hasNext()) {
                long longValue = it.next().longValue();
                com.freshchat.consumer.sdk.util.cc.r(getApplicationContext(), longValue);
                com.freshchat.consumer.sdk.i.b.a(a(), 0L, longValue, this.b);
            }
        } catch (Exception e) {
            com.freshchat.consumer.sdk.util.aj.a(e);
        }
    }

    private void aD() {
        try {
            if (isTaskRoot()) {
                String hG = this.cM.hG();
                if (com.freshchat.consumer.sdk.util.ds.a(hG)) {
                    com.freshchat.consumer.sdk.util.cc.Q(a(), hG);
                } else {
                    startActivity(getPackageManager().getLaunchIntentForPackage(getPackageName()));
                }
            }
        } catch (Exception e) {
            com.freshchat.consumer.sdk.util.aj.a(e);
        }
    }

    private boolean aE() {
        return com.freshchat.consumer.sdk.util.dd.c(this, com.freshchat.consumer.sdk.util.dd.yC);
    }

    private void aF() {
        if (aE()) {
            aG();
        } else {
            this.bJ.setOnClickListener(this.dR);
            this.bJ.setOnLongClickListener(this.dS);
        }
    }

    private void aG() {
        this.bk = new com.freshchat.consumer.sdk.util.k(getApplicationContext(), this, this.cM.b());
        setVolumeControlStream(3);
        com.freshchat.consumer.sdk.g.c cVar = new com.freshchat.consumer.sdk.g.c(this, this.bk);
        this.bN = (ProgressBar) findViewById(R.id.freshchat_conv_detail_voice_reply_progressbar);
        this.bO = (TextView) findViewById(R.id.freshchat_conv_detail_voice_reply_time_elapsed_text);
        this.bJ.setOnClickListener(null);
        this.bJ.setOnLongClickListener(null);
        this.bJ.setOnTouchListener(cVar);
    }

    public void aH() {
        String str;
        int i2;
        if (com.freshchat.consumer.sdk.util.dz.kq()) {
            com.freshchat.consumer.sdk.util.co.c(i, "Permissions required for voice messaging has NOT been granted. Requesting permission.");
            boolean shouldShowRequestPermissionRationale = shouldShowRequestPermissionRationale("android.permission.RECORD_AUDIO");
            boolean shouldShowRequestPermissionRationale2 = shouldShowRequestPermissionRationale("android.permission.WRITE_EXTERNAL_STORAGE");
            if (shouldShowRequestPermissionRationale && shouldShowRequestPermissionRationale2) {
                i2 = R.string.freshchat_chat_voice_messaging_permissions_rationale;
            } else if (shouldShowRequestPermissionRationale2) {
                i2 = R.string.freshchat_chat_voice_messaging_write_storage_permission_rationale;
            } else {
                if (!shouldShowRequestPermissionRationale) {
                    str = "";
                    com.freshchat.consumer.sdk.b.o.g(a(), str);
                    requestPermissions(com.freshchat.consumer.sdk.util.dd.d(a(), com.freshchat.consumer.sdk.util.dd.yC), 100);
                }
                i2 = R.string.freshchat_chat_voice_messaging_audio_recording_permission_rationale;
            }
            str = getString(i2);
            com.freshchat.consumer.sdk.b.o.g(a(), str);
            requestPermissions(com.freshchat.consumer.sdk.util.dd.d(a(), com.freshchat.consumer.sdk.util.dd.yC), 100);
        }
    }

    private void aI() {
        this.cs.setOnItemClickListener(new an(this));
    }

    private void aM() {
        if (this.cY == null) {
            as asVar = new as(this, a());
            this.cY = asVar;
            asVar.enable();
        }
    }

    private void aN() {
        this.bI.setOnItemClickListener(new au(this));
    }

    private void aQ() {
        if (this.cM.ef()) {
            try {
                com.freshchat.consumer.sdk.k.d.iw();
            } catch (Exception e) {
                com.freshchat.consumer.sdk.util.aj.a(e);
            }
        }
    }

    public void aR() {
        if (this.bG == null || !com.freshchat.consumer.sdk.util.w.a(this.cM.lB())) {
            return;
        }
        LinearLayoutManager linearLayoutManager = this.bG;
        linearLayoutManager.x = com.freshchat.consumer.sdk.util.w.b(this.cM.lB()) - 1;
        linearLayoutManager.y = 0;
        LinearLayoutManager$SavedState linearLayoutManager$SavedState = linearLayoutManager.z;
        if (linearLayoutManager$SavedState != null) {
            linearLayoutManager$SavedState.b();
        }
        linearLayoutManager.s0();
    }

    private void aS() {
        this.cD = com.freshchat.consumer.sdk.l.w.UNDEFINED;
        List<OpinionOption> list = this.ds;
        if (list != null) {
            list.clear();
            com.freshchat.consumer.sdk.b.o.i(this.cC);
        }
        this.du.setRating(0.0f);
        if (com.freshchat.consumer.sdk.b.o.l(this.bx)) {
            com.freshchat.consumer.sdk.b.o.d(this.bx);
        }
        if (com.freshchat.consumer.sdk.b.o.l(this.bA)) {
            com.freshchat.consumer.sdk.b.o.d(this.bA);
        }
    }

    private void aT() {
        CountDownTimer countDownTimer = this.dh;
        if (countDownTimer == null || !this.dg) {
            return;
        }
        this.dg = false;
        countDownTimer.cancel();
    }

    public void aU() {
        if (com.freshchat.consumer.sdk.b.o.l(this.bT)) {
            com.freshchat.consumer.sdk.b.o.d(this.bT);
            com.freshchat.consumer.sdk.b.o.c(this.cW);
        }
    }

    private void aV() {
        com.freshchat.consumer.sdk.ui.ak akVar;
        com.freshchat.consumer.sdk.util.dl dlVar = this.ct;
        if (dlVar == null || (akVar = this.cs) == null) {
            return;
        }
        int aa = dlVar.aa(akVar.getHeight());
        if (com.freshchat.consumer.sdk.b.o.l(this.cU) && aa > ((int) (this.cU.getHeight() * 1.5d))) {
            aa -= (int) (this.cU.getHeight() * 1.5d);
        }
        this.cs.setHeight(aa);
    }

    private void aW() {
        if (aX() || !(Z().D() || Z().C() || Z().ee())) {
            com.freshchat.consumer.sdk.b.o.d(this.bL);
        } else {
            com.freshchat.consumer.sdk.b.o.c(this.bL);
        }
    }

    public boolean aX() {
        return this.cD == com.freshchat.consumer.sdk.l.w.COMMENT;
    }

    public void aY() {
        boolean C = Z().C();
        boolean D = Z().D();
        boolean ee = Z().ee();
        com.freshchat.consumer.sdk.a.b bVar = new com.freshchat.consumer.sdk.a.b();
        if (C && D && ee) {
            bVar.a(b.a.CAMERA_CAPTURE, b.a.IMAGE_FROM_GALLERY, b.a.FILE);
        } else if (C && D) {
            bVar.a(b.a.CAMERA_CAPTURE, b.a.IMAGE_FROM_GALLERY);
            this.bC.setText(getString(R.string.freshchat_bot_only_image_attachment));
        } else if (D && ee) {
            bVar.a(b.a.IMAGE_FROM_GALLERY, b.a.FILE);
        } else {
            if (!C || !ee) {
                if (C) {
                    bb();
                    return;
                } else if (D) {
                    aZ();
                    return;
                } else {
                    if (ee) {
                        ba();
                        return;
                    }
                    return;
                }
            }
            bVar.a(b.a.CAMERA_CAPTURE, b.a.FILE);
        }
        a(bVar);
    }

    public void aZ() {
        Intent intent = new Intent();
        intent.setType(da.b.TYPE_IMAGE.b());
        intent.setAction((com.freshchat.consumer.sdk.util.dz.ko() && getResources().getBoolean(R.bool.freshchat_document_provider_enabled)) ? "android.intent.action.OPEN_DOCUMENT" : "android.intent.action.GET_CONTENT");
        intent.addCategory("android.intent.category.OPENABLE");
        startActivityForResult(intent, 125);
    }

    private void aa() {
        z();
    }

    public static long ae() {
        return cK;
    }

    private void ah() {
        this.bI.setOnEditorActionListener(new by(this));
    }

    private void ai() {
        View a = com.freshchat.consumer.sdk.b.o.a(getWindow());
        if (a != null) {
            a.getViewTreeObserver().addOnGlobalLayoutListener(new co(this, a));
        }
    }

    public com.freshchat.consumer.sdk.a.p aj() {
        if (this.cH == null) {
            com.freshchat.consumer.sdk.a.p pVar = new com.freshchat.consumer.sdk.a.p(this, this.cM.lB(), this.cM.lC(), this.dN, this.dZ, this.dq, this.cM);
            this.cH = pVar;
            pVar.a(this.dJ);
            this.cH.a(this.dG);
            this.cH.a(this.dH);
            this.cH.a(this.dI);
            this.cH.a(this.dK);
            this.cH.a(this.dM);
            this.cH.a(this.dL);
        }
        return this.cH;
    }

    public com.freshchat.consumer.sdk.a.e ak() {
        return this.cH.df();
    }

    private void ap() {
        String e = Z().e("CONFIG_CONVERSATION_BANNER_MESSAGE");
        if (!com.freshchat.consumer.sdk.util.ds.a(e)) {
            com.freshchat.consumer.sdk.b.o.d(this.bM);
            return;
        }
        com.freshchat.consumer.sdk.b.o.c(this.bM);
        View view = this.bM;
        if (view instanceof TextView) {
            ((TextView) view).setText(e);
        }
    }

    private void ar() {
        this.bI.setHint(R.string.freshchat_chat_message_composer_hint);
        aW();
        if (this.bI.getInputType() != 16384) {
            this.bI.setInputType(16384);
        }
    }

    private void as() {
        bv();
        if (this.cq == null || !com.freshchat.consumer.sdk.util.w.a(this.f) || a0()) {
            return;
        }
        if (at()) {
            com.freshchat.consumer.sdk.b.o.a(this.cq);
        } else {
            com.freshchat.consumer.sdk.b.o.b(this.cq);
        }
    }

    private boolean at() {
        com.freshchat.consumer.sdk.l.m mVar = this.cM;
        if (mVar.O(mVar.lB()).equals(m.c.Bd)) {
            return false;
        }
        long j = this.cP;
        return j == -1 || this.cM.Q(j) || this.cP == 2;
    }

    public void au() {
        if (this.cB != null && !this.f.isEmpty() && !a0()) {
            this.cB.jI = at();
        }
        this.bI.setAdapter(this.cB);
    }

    private void av() {
        com.freshchat.consumer.sdk.l.m mVar = this.cM;
        Message aa = mVar.aa(mVar.lB());
        if ((!at() && !aw()) || aa == null || aa.getIsFeedBackSent()) {
            com.freshchat.consumer.sdk.b.o.d(this.cU);
        } else {
            if (!com.freshchat.consumer.sdk.util.w.a(this.cS) || a0()) {
                return;
            }
            aL();
            com.freshchat.consumer.sdk.b.o.c(this.cU);
        }
    }

    private boolean aw() {
        return this.cD != com.freshchat.consumer.sdk.l.w.UNDEFINED;
    }

    public ClipboardManager ax() {
        if (this.bc == null && com.freshchat.consumer.sdk.util.dz.kj()) {
            this.bc = (ClipboardManager) a().getSystemService("clipboard");
        }
        return this.bc;
    }

    public void ay() {
        aC();
        aB();
        b(getIntent());
    }

    private void az() {
        if (this.bk != null) {
            if (aA()) {
                this.bk.iX();
            }
            this.bk.jb();
        }
    }

    public void bA() {
        bH();
        bD();
        bO();
        bE();
        bF();
        aS();
        bK();
        bL();
        LinearLayoutManager linearLayoutManager = this.bG;
        if (linearLayoutManager != null) {
            linearLayoutManager.j1(false);
        }
        int b = com.freshchat.consumer.sdk.util.w.b(this.cM.lB());
        if (b > 0) {
            this.bF.scrollToPosition(b - 1);
        }
    }

    private RemoteConfig bB() {
        if (this.cG == null) {
            this.cG = com.freshchat.consumer.sdk.util.dn.cs(a());
        }
        return this.cG;
    }

    private void bM() {
        com.freshchat.consumer.sdk.b.o.a(a(), (View) this.bI);
        c(this.bE);
    }

    private void bN() {
        FlowLayout flowLayout = (FlowLayout) findViewById(R.id.freshchat_chips_flowlayout);
        if (flowLayout == null) {
            return;
        }
        com.freshchat.consumer.sdk.l.m mVar = this.cM;
        Message aa = mVar.aa(mVar.lB());
        if (aa != null) {
            View findViewWithTag = flowLayout.getRootView().findViewWithTag("CHIPS_CONTAINER" + aa.getId());
            if (findViewWithTag != null) {
                com.freshchat.consumer.sdk.b.o.d(findViewWithTag);
            } else {
                com.freshchat.consumer.sdk.b.o.d(flowLayout);
            }
        }
    }

    private void bO() {
        d(this.bE);
    }

    private void bP() {
        bR();
        this.cN = null;
    }

    private void bQ() {
        TextView textView;
        int i2;
        com.freshchat.consumer.sdk.b.o.d(this.bT);
        com.freshchat.consumer.sdk.b.o.d(this.cW);
        com.freshchat.consumer.sdk.b.o.c(this.bV);
        com.freshchat.consumer.sdk.l.m mVar = this.cM;
        QuickReplyDropDownFragment Y = mVar.Y(mVar.lB());
        if (Y == null) {
            com.freshchat.consumer.sdk.util.co.a(i, "quickReplyDropDownFragment is null");
            return;
        }
        com.freshchat.consumer.sdk.l.ab abVar = new com.freshchat.consumer.sdk.l.ab(a());
        this.cN = abVar;
        abVar.a(Y);
        if (this.cN.mu() == QuickReplyOptions.DropdownType.MULTI_SELECT) {
            textView = this.bW;
            i2 = R.string.freshchat_multi_select_drop_down_hint_text;
        } else {
            textView = this.bW;
            i2 = R.string.freshchat_drop_down_hint_text;
        }
        textView.setText(getString(i2));
        this.bV.setOnClickListener(new ca(this));
    }

    private void bU() {
        View view = this.bE;
        if (view != null) {
            View findViewById = view.findViewById(R.id.freshchat_chat_resolution_positive_btn);
            if (findViewById != null) {
                findViewById.setOnClickListener(this.dY);
            }
            View findViewById2 = this.bE.findViewById(R.id.freshchat_chat_resolution_negative_btn);
            if (findViewById2 != null) {
                findViewById2.setOnClickListener(this.dY);
            }
        }
    }

    private boolean bV() {
        return this.cM.lD() && this.cM.hr().getCsat() != null && this.cM.hr().getCsat().getCsatId() > 0;
    }

    private boolean bW() {
        Csat csat = (bV() && this.cM.hr().hasPendingCsat()) ? this.cM.hr().getCsat() : null;
        if (csat == null) {
            return false;
        }
        boolean lJ = this.cM.lJ();
        if (!com.freshchat.consumer.sdk.util.ab.a(bB()) || !com.freshchat.consumer.sdk.util.ab.a(bB(), csat)) {
            return (!lJ || bX() || aA()) ? false : true;
        }
        long mB = this.cM.mB();
        bc().k(mB);
        com.freshchat.consumer.sdk.util.ba.c(a(), mB, this.a);
        return false;
    }

    private boolean bX() {
        QuickActionsAutoCompleteView quickActionsAutoCompleteView = this.bI;
        return quickActionsAutoCompleteView != null && com.freshchat.consumer.sdk.util.ds.a(quickActionsAutoCompleteView.getText());
    }

    public void bY() {
        aj().h(false);
        if (this.cM.hr() != null && this.dl == this.cM.hr().getStatus()) {
            this.cM.lR();
        }
        bm();
        com.freshchat.consumer.sdk.l.m mVar = this.cM;
        if (mVar.Z(mVar.lB()) == com.freshchat.consumer.sdk.b.k.CAROUSEL) {
            this.bF.post(new ck(this));
        }
    }

    private boolean bZ() {
        androidx.appcompat.app.c cVar = this.bP;
        return cVar != null && cVar.isShowing();
    }

    public void ba() {
        Intent intent = new Intent();
        intent.setType(da.b.TYPE_ANY.b());
        intent.setAction((com.freshchat.consumer.sdk.util.dz.ko() && getResources().getBoolean(R.bool.freshchat_document_provider_enabled)) ? "android.intent.action.OPEN_DOCUMENT" : "android.intent.action.GET_CONTENT");
        intent.addCategory("android.intent.category.OPENABLE");
        startActivityForResult(intent, 124);
    }

    public void bb() {
        throw new UnsupportedOperationException("Method not decompiled: com.freshchat.consumer.sdk.activity.ConversationDetailActivity.bb():void");
    }

    private com.freshchat.consumer.sdk.c.k bc() {
        if (this.aZ == null) {
            this.aZ = new com.freshchat.consumer.sdk.c.k(getApplicationContext());
        }
        return this.aZ;
    }

    public void bd() {
        this.cM.lM();
        boolean bW = bW();
        aj().h(bW);
        if (!bW) {
            bm();
            bl();
            be();
            bf();
            bg();
            return;
        }
        bH();
        bD();
        bM();
        bU();
        bP();
        com.freshchat.consumer.sdk.util.ba.l(a(), this.a);
    }

    private void be() {
        com.freshchat.consumer.sdk.l.m mVar = this.cM;
        com.freshchat.consumer.sdk.l.w P = mVar.P(mVar.lB());
        this.cD = P;
        int i2 = cn.eL[P.ordinal()];
        if (i2 == 1) {
            aW();
            this.bI.setHint(R.string.freshchat_comment_feedback_hint);
            return;
        }
        if (i2 == 2) {
            bh();
            return;
        }
        if (i2 != 3) {
            if (i2 != 4) {
                return;
            }
            ar();
        } else {
            com.freshchat.consumer.sdk.b.o.c(this.bA);
            com.freshchat.consumer.sdk.b.o.d(this.bp);
            com.freshchat.consumer.sdk.l.m mVar2 = this.cM;
            b(mVar2.R(mVar2.aa(mVar2.lB()).getReplyFragments()));
        }
    }

    private void bf() {
        com.freshchat.consumer.sdk.l.m mVar = this.cM;
        DateFragment A = com.freshchat.consumer.sdk.util.ac.A(mVar.aa(mVar.lB()));
        if (A == null) {
            return;
        }
        bH();
        com.freshchat.consumer.sdk.b.o.c(this.dn);
        this.dn.setOnClickListener(new bj(this, A));
    }

    private void bg() {
        com.freshchat.consumer.sdk.l.m mVar = this.cM;
        if (com.freshchat.consumer.sdk.util.ac.B(mVar.aa(mVar.lB())) == null) {
            return;
        }
        bH();
        com.freshchat.consumer.sdk.b.o.c(this.f2do);
        this.f2do.setOnClickListener(new bl(this));
    }

    private void bh() {
        if (!com.freshchat.consumer.sdk.util.w.a(this.ds)) {
            com.freshchat.consumer.sdk.l.m mVar = this.cM;
            Message aa = mVar.aa(mVar.lB());
            if (aa != null) {
                this.ds = this.cM.Q(aa.getReplyFragments());
            }
        }
        this.bX.setAdapter(this.dr);
        this.dr.g(this.ds);
        bi();
        this.cC.setOnClickListener(new bm(this));
        bk();
    }

    private void bi() {
        com.freshchat.consumer.sdk.b.o.a(a(), getCurrentFocus());
        com.freshchat.consumer.sdk.b.o.d(this.bp);
        com.freshchat.consumer.sdk.b.o.c(this.bx);
        com.freshchat.consumer.sdk.b.o.d(this.cW);
        av();
    }

    public void bj() {
        com.freshchat.consumer.sdk.b.o.c(this.cW);
        com.freshchat.consumer.sdk.b.o.d(this.bx);
        by();
    }

    private void bk() {
        this.dr.a(new bp(this));
    }

    private void bl() {
        com.freshchat.consumer.sdk.l.m mVar = this.cM;
        this.cS = mVar.T(mVar.lB());
        aL();
        av();
    }

    private void bm() {
        throw new UnsupportedOperationException("Method not decompiled: com.freshchat.consumer.sdk.activity.ConversationDetailActivity.bm():void");
    }

    private void bn() {
        c(this.bY);
    }

    private void bo() {
        d(this.bY);
    }

    private void bp() {
        com.freshchat.consumer.sdk.b.o.a(false, (View) this.bI);
        com.freshchat.consumer.sdk.b.o.a(false, this.bL);
        com.freshchat.consumer.sdk.b.o.a(false, this.bK);
    }

    public void bq() {
        com.freshchat.consumer.sdk.b.o.a(true, (View) this.bI);
        com.freshchat.consumer.sdk.b.o.a(true, this.bL);
        com.freshchat.consumer.sdk.b.o.a(true, this.bK);
    }

    private void br() {
        bH();
        bQ();
    }

    private void bs() {
        if (aA()) {
            return;
        }
        if (this.cM.lA()) {
            bA();
            return;
        }
        ao();
        bD();
        bO();
        bE();
        bF();
        aS();
        bJ();
        bK();
        bL();
        bT();
    }

    public void bt() {
        String ly = this.cM.ly();
        if (getSupportActionBar() == null || !com.freshchat.consumer.sdk.util.ds.a(ly)) {
            return;
        }
        getSupportActionBar().p(ly);
    }

    public static String bu() {
        return BM;
    }

    public void bv() {
        if (this.cM.lD()) {
            this.cP = this.cM.hr().getStatus();
        }
    }

    public boolean bw() {
        return this.cM.lD() && this.cQ && this.cM.hr().getStatus() == 2;
    }

    public void bx() {
        this.bI.setText("");
        com.freshchat.consumer.sdk.b.o.d(this.bp);
        this.cD = com.freshchat.consumer.sdk.l.w.UNDEFINED;
        aW();
        ar();
        by();
    }

    public void by() {
        av();
        com.freshchat.consumer.sdk.b.o.c(this.cX);
        this.cX.postDelayed(new bw(this), 3000L);
    }

    public void bz() {
        com.freshchat.consumer.sdk.l.m mVar = this.cM;
        Message aa = mVar.aa(mVar.lB());
        if (aa != null) {
            aa.setIsFeedBackSent(true);
            this.cM.hH().i(aa);
        }
    }

    private void c0() {
        if (Build.VERSION.SDK_INT >= 26) {
            AutofillManager e = C2615tf.e(getSystemService(C2516sf.d()));
            if (e != null) {
                e.cancel();
            }
            this.bI.setAutofillHints(new String[]{""});
            this.bI.setImportantForAutofill(0);
        }
    }

    private ConnectivityManager ca() {
        try {
            return (ConnectivityManager) a().getApplicationContext().getSystemService("connectivity");
        } catch (Exception e) {
            com.freshchat.consumer.sdk.util.aj.a(e);
            return null;
        }
    }

    private boolean cb() {
        return com.freshchat.consumer.sdk.util.dz.kr() && com.freshchat.consumer.sdk.util.j.aI(a()) >= 24;
    }

    private void cd() {
        ConnectivityManager ca;
        ConnectivityManager.NetworkCallback networkCallback;
        try {
            if (!cb() || (ca = ca()) == null || (networkCallback = this.cL) == null) {
                return;
            }
            ca.unregisterNetworkCallback(networkCallback);
        } catch (Exception e) {
            com.freshchat.consumer.sdk.util.aj.a(e);
        }
    }

    private void ce() {
        com.freshchat.consumer.sdk.ui.ak akVar = this.cs;
        if (akVar == null || !akVar.isShowing()) {
            return;
        }
        this.cs.dismiss();
        aJ();
        this.cs.setAnchorView(findViewById(R.id.freshchat_quick_action_menu));
        aV();
        this.cs.show();
    }

    private void cf() {
        this.bI.dismissDropDown();
        com.freshchat.consumer.sdk.util.dk dkVar = this.cT;
        if (dkVar != null) {
            int kc = dkVar.kc();
            this.bI.setDropDownWidth(kc);
            this.bI.setDropDownHeight(this.cT.kb());
            this.bI.setDropDownHorizontalOffset(this.cT.Z(kc));
        }
        if (this.bI.isPopupShowing()) {
            this.bI.showDropDown();
        }
    }

    private void cg() {
        com.freshchat.consumer.sdk.d.f fVar = this.cO;
        if (fVar != null) {
            fVar.dismiss();
            this.cO = null;
        }
    }

    public com.freshchat.consumer.sdk.ui.m ch() {
        return (com.freshchat.consumer.sdk.ui.m) getSupportFragmentManager().c.g("COUNTRY_CODE_BOTTOM_SHEET");
    }

    public void ci() {
        a(this.cM.kO());
    }

    private void cj() {
        int b = com.freshchat.consumer.sdk.util.w.b(this.cM.lB());
        Status lH = this.cM.lH();
        if (lH == Status.COMPLETE) {
            aj().g(false);
            aj().notifyDataSetChanged();
        }
        int b2 = com.freshchat.consumer.sdk.util.w.b(this.cM.lB()) - b;
        if (b2 > 0) {
            a(lH, b2);
        }
    }

    public void ck() {
        String lP = this.cM.lP();
        if (com.freshchat.consumer.sdk.util.ds.a(lP)) {
            aj().m(lP);
        }
    }

    private com.freshchat.consumer.sdk.ui.p cl() {
        return (com.freshchat.consumer.sdk.ui.p) getSupportFragmentManager().c.g("TAG_DROPDOWN_BOTTOMSHEET");
    }

    private void e(int i2) {
        String string = getResources().getString(R.string.freshchat_count_tracker_count_text);
        this.bZ.setText(String.format(string, Integer.valueOf(i2)));
        this.dx.setText(String.format(string, Integer.valueOf(i2)));
        com.freshchat.consumer.sdk.b.o.a(i2 > 0, this.cb);
        com.freshchat.consumer.sdk.b.o.a(i2 > 0, this.dy);
    }

    private String f(String str) {
        return com.freshchat.consumer.sdk.util.ds.b(str) ? Html.escapeHtml(str) : str;
    }

    private void z() {
        int i2 = cn.aY[this.cM.mj().ordinal()];
        if (i2 == 1) {
            com.freshchat.consumer.sdk.b.o.c(this.bQ);
            com.freshchat.consumer.sdk.b.o.d(this.bR);
            return;
        }
        if (i2 != 2) {
            if (i2 != 3) {
                return;
            }
            H();
            return;
        }
        com.freshchat.consumer.sdk.util.aw.jD().c(a(), true);
        com.freshchat.consumer.sdk.b.o.d(this.bQ);
        com.freshchat.consumer.sdk.b.o.c(this.bR);
        if (this.bV.getVisibility() == 0) {
            com.freshchat.consumer.sdk.l.m mVar = this.cM;
            mVar.N(mVar.lB());
        }
    }

    public void aJ() {
        com.freshchat.consumer.sdk.ui.ak akVar = new com.freshchat.consumer.sdk.ui.ak(a(), null, R.attr.freshchatQuickActionMenuStyle);
        this.cs = akVar;
        int i2 = R.drawable.freshchat_quick_actions_menu_popup;
        Object obj = dT.a;
        akVar.setBackgroundDrawable(a.b(this, i2));
        ArrayAdapter arrayAdapter = new ArrayAdapter(a(), R.layout.freshchat_quick_action_menu_options, this.f);
        this.cs.setAdapter(arrayAdapter);
        this.ct = new com.freshchat.consumer.sdk.util.dl(a(), arrayAdapter);
        this.cs.setContentWidth(-2);
        this.cs.setInputMethodMode(2);
        this.cs.setVerticalOffset(-getResources().getDimensionPixelSize(R.dimen.freshchat_quick_action_menu_vertical_offset));
        this.cs.setHeight(this.ct.aa(this.cs.getHeight()));
        int kd = this.ct.kd();
        this.cs.setWidth(kd);
        this.cs.setHorizontalOffset(this.ct.ab(kd));
        aI();
    }

    public void aK() {
        if (this.cT != null) {
            this.bI.setAdapter(this.cB);
            this.bI.setThreshold(1);
            this.bI.setDropDownVerticalOffset(0);
            int kc = this.cT.kc();
            this.bI.setDropDownWidth(kc);
            this.bI.setDropDownHorizontalOffset(this.cT.Z(kc));
            this.cB.registerDataSetObserver(new ao(this));
            aN();
        }
    }

    public void aL() {
        com.freshchat.consumer.sdk.a.ab abVar = new com.freshchat.consumer.sdk.a.ab(a(), this.cS, this.dO);
        this.bU.setLayoutManager(this.bH);
        this.bU.setAdapter(abVar);
        a(this.bU, this.bH);
    }

    public void aO() {
        Bundle bundle = new Bundle();
        bundle.putLong("CHANNEL_ID", this.cM.b());
        bundle.putString("EXTRA_CONVERSATION_REFERENCE_ID", this.b);
        getSupportLoaderManager().c(0, bundle, this.dU);
    }

    public void aP() {
        Bundle bundle = new Bundle();
        bundle.putLong("CHANNEL_ID", this.cM.b());
        bundle.putString("EXTRA_CONVERSATION_REFERENCE_ID", this.b);
        bundle.putBoolean("EXTRA_FORCE_CLEAN_UP_EXPIRED_CSAT", true);
        getSupportLoaderManager().c(0, bundle, this.dW);
    }

    public void ag() {
        Collections.sort(this.dC, new bk(this));
        bG();
        Message f = this.cM.f("");
        Iterator<CarouselCardDefaultFragment> it = this.dC.iterator();
        while (it.hasNext()) {
            f.addMessageFragment(it.next());
        }
        a(f);
        com.freshchat.consumer.sdk.util.ba.b(a(), this.dC, true);
    }

    @Override
    public void bC() {
        c(this.bD);
    }

    @Override
    public void bD() {
        d(this.bD);
    }

    public void bE() {
        if (com.freshchat.consumer.sdk.b.o.l(this.da)) {
            com.freshchat.consumer.sdk.b.o.d(this.da);
        }
    }

    public void bF() {
        if (com.freshchat.consumer.sdk.b.o.l(this.dd)) {
            com.freshchat.consumer.sdk.b.o.d(this.dd);
            com.freshchat.consumer.sdk.b.o.c(this.cW);
        }
    }

    @Override
    public void bG() {
        bP();
        bo();
        c(this.bp);
        c(this.cW);
    }

    @Override
    public void bH() {
        d(this.bp);
        d(this.cW);
        com.freshchat.consumer.sdk.b.o.a(a(), this.bp);
    }

    public void bI() {
        c(this.bu);
        this.cR = true;
    }

    public void bJ() {
        d(this.bu);
        this.cR = false;
    }

    public void bK() {
        if (com.freshchat.consumer.sdk.b.o.l(this.dn)) {
            d(this.dn);
        }
    }

    public void bL() {
        if (com.freshchat.consumer.sdk.b.o.l(this.f2do)) {
            d(this.f2do);
        }
    }

    public void bR() {
        com.freshchat.consumer.sdk.b.o.d(this.bV);
        com.freshchat.consumer.sdk.b.o.c(this.cW);
    }

    public void bS() {
        c(this.dw);
    }

    public void bT() {
        d(this.dw);
    }

    @Override
    public void cm() {
        bN();
        aj().notifyDataSetChanged();
        al();
    }

    @Override
    public void g(int i2) {
        runOnUiThread(new cd(this, i2));
    }

    public void onActivityResult(int i2, int i3, Intent intent) {
        if (i3 != -1) {
            com.freshchat.consumer.sdk.util.co.a(i, "onActivityResult::Request Code " + i2 + ", Result: " + i3);
            return;
        }
        try {
            switch (i2) {
                case 124:
                    com.freshchat.consumer.sdk.util.co.a(i, "onActivityResult::REQUEST_CODE_FILE");
                    Uri data = intent.getData();
                    a(data, da.b.TYPE_ANY, i2, this.cR);
                    com.freshchat.consumer.sdk.util.co.a("File test", data.toString());
                    break;
                case 125:
                    com.freshchat.consumer.sdk.util.co.a(i, "onActivityResult::REQUEST_CODE_GALLERY");
                    Uri data2 = intent.getData();
                    if (!com.freshchat.consumer.sdk.util.cj.xV.contains(com.freshchat.consumer.sdk.util.as.f(a(), data2))) {
                        a(data2, i2);
                        break;
                    } else {
                        a(data2, da.b.TYPE_ANY, i2, this.cR);
                        break;
                    }
                case 126:
                    String str = i;
                    com.freshchat.consumer.sdk.util.co.a(str, "onActivityResult::REQUEST_CODE_CAMERA");
                    if (this.cJ != null) {
                        com.freshchat.consumer.sdk.util.co.a(str, "Found Pic From Camera : " + this.cJ);
                        a(this.cJ, da.b.TYPE_IMAGE, i2, this.cR);
                        this.cJ = null;
                        break;
                    }
                    break;
                case 127:
                    if (!da.b.TYPE_ANY.b().equals(intent.getStringExtra("MIME_TYPE"))) {
                        this.bI.setText("");
                        y.b bVar = new y.b();
                        bVar.j(intent);
                        a(bVar.mp(), bVar.c(), bVar.b(), bVar.mm(), bVar.a());
                        break;
                    } else {
                        y.a aVar = new y.a();
                        aVar.i(intent);
                        a(aVar.a(), aVar.mn(), aVar.b(), aVar.mm());
                        break;
                    }
                default:
                    return;
            }
        } catch (Exception e) {
            com.freshchat.consumer.sdk.util.aj.a(e);
        }
    }

    @Override
    public void onBackPressed() {
        com.freshchat.consumer.sdk.b.o.a(getApplicationContext(), getCurrentFocus());
        aQ();
        aD();
        com.freshchat.consumer.sdk.b.j.fA().fD();
        super.onBackPressed();
    }

    public void onConfigurationChanged(Configuration configuration) {
        super.onConfigurationChanged(configuration);
        this.e = configuration.orientation;
        ce();
        cf();
        h(this.e);
    }

    @Override
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        X();
        this.cM.lv();
        com.freshchat.consumer.sdk.util.b.ap(a());
        setContentView(R.layout.freshchat_activity_conversation_detail);
        c(this.cM.lx());
        E();
        this.e = getResources().getConfiguration().orientation;
        d();
        af();
        this.cM.lz();
        cc();
        this.dr = new com.freshchat.consumer.sdk.a.w(a());
        this.ds = new ArrayList();
        h(getResources().getConfiguration().orientation);
        this.dE = new SparseBooleanArray();
    }

    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.freshchat_conversation_detail, menu);
        MenuItem findItem = menu.findItem(R.id.freshchat_menu_item_toggle_speakerphone);
        if (this.cM.ef()) {
            a(findItem, false);
        } else {
            findItem.setVisible(false);
        }
        this.cq = menu.findItem(R.id.freshchat_quick_action_menu);
        as();
        aJ();
        return true;
    }

    public void onDestroy() {
        aT();
        super.onDestroy();
        com.freshchat.consumer.sdk.util.co.a(i, "Feedback activity is being destroyed");
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem menuItem) {
        if (menuItem.getItemId() == R.id.freshchat_menu_item_toggle_speakerphone) {
            if (this.cM.eg()) {
                this.cM.p(false);
            } else {
                this.cM.p(true);
            }
            a(menuItem, true);
            return true;
        }
        int itemId = menuItem.getItemId();
        int i2 = R.id.freshchat_quick_action_menu;
        if (itemId != i2) {
            return super.onOptionsItemSelected(menuItem);
        }
        this.cs.setAnchorView(findViewById(i2));
        aV();
        this.cs.show();
        return true;
    }

    @Override
    public void onPause() {
        super.onPause();
        cK = 0L;
        BM = null;
        this.cM.lO();
        cd();
        try {
            if (bZ()) {
                this.bP.cancel();
            }
            cg();
            az();
        } catch (Exception e) {
            com.freshchat.consumer.sdk.util.aj.a(e);
        }
    }

    public void onRequestPermissionsResult(int i2, String[] strArr, int[] iArr) {
        String str;
        int i3;
        if (i2 == 100) {
            str = i;
            com.freshchat.consumer.sdk.util.co.c(str, "Received response for audio recording permission request.");
            if (com.freshchat.consumer.sdk.util.dd.a(iArr)) {
                com.freshchat.consumer.sdk.util.co.c(str, getString(R.string.freshchat_chat_voice_messaging_permissions_granted));
                aG();
                return;
            }
            i3 = R.string.freshchat_chat_voice_messaging_permissions_not_granted;
        } else if (i2 != 101) {
            super/*androidx.fragment.app.e*/.onRequestPermissionsResult(i2, strArr, iArr);
            return;
        } else if (com.freshchat.consumer.sdk.util.dd.a(iArr)) {
            com.freshchat.consumer.sdk.util.co.c(i, getString(R.string.freshchat_chat_camera_permissions_granted));
            bb();
            return;
        } else {
            str = i;
            i3 = R.string.freshchat_chat_camera_permissions_not_granted;
        }
        com.freshchat.consumer.sdk.util.co.l(this, str, getString(i3));
    }

    @Override
    public void onResume() {
        super.onResume();
        com.freshchat.consumer.sdk.util.c.c.a(getApplicationContext(), true);
        cK = this.cM.b();
        BM = this.cM.mA();
        cc();
        try {
            com.freshchat.consumer.sdk.util.b.a(getApplicationContext(), k$a.NORMAL);
            this.cZ = true;
            com.freshchat.consumer.sdk.util.b.av(getApplicationContext());
            com.freshchat.consumer.sdk.util.b.ao(a());
            as();
            au();
            bl();
            com.freshchat.consumer.sdk.i.b.a(a(), this.a, 0L, this.b);
        } catch (Exception e) {
            com.freshchat.consumer.sdk.util.aj.a(e);
        }
        aa();
        aP();
    }

    public void onStop() {
        super.onStop();
        com.freshchat.consumer.sdk.util.co.a(i, "Conversation Detail activity is being stopped");
    }

    private void X() {
        Intent intent = getIntent();
        if (!intent.hasExtra("CHANNEL_ID")) {
            finish();
            com.freshchat.consumer.sdk.b.o.a((Context) this, com.freshchat.consumer.sdk.b.c.CHANNEL_ID_MISSING);
            return;
        }
        long longExtra = intent.getLongExtra("CHANNEL_ID", 0L);
        if (intent.hasExtra("EXTRA_CONVERSATION_REFERENCE_ID")) {
            this.b = intent.getStringExtra("EXTRA_CONVERSATION_REFERENCE_ID");
        }
        if (intent.hasExtra("UNFETCHED_CHANNEL")) {
            finish();
            startActivity(new Intent(a(), (Class<?>) ChannelListActivity.class));
        }
        String stringExtra = (!intent.hasExtra("CHANNEL_NAME") || com.freshchat.consumer.sdk.util.ds.c(intent.getStringExtra("CHANNEL_NAME"))) ? "" : intent.getStringExtra("CHANNEL_NAME");
        String stringExtra2 = (!intent.hasExtra("CHANNEL_TYPE") || com.freshchat.consumer.sdk.util.ds.c(intent.getStringExtra("CHANNEL_TYPE"))) ? null : intent.getStringExtra("CHANNEL_TYPE");
        this.B = intent.getStringArrayExtra("INPUT_TAGS");
        com.freshchat.consumer.sdk.l.m a = com.freshchat.consumer.sdk.l.a.a.a(a().getApplicationContext(), this.B, longExtra);
        this.cM = a;
        a.a(longExtra, stringExtra, stringExtra2, this.b);
    }

    public com.freshchat.consumer.sdk.b.f Z() {
        if (this.aR == null) {
            this.aR = com.freshchat.consumer.sdk.b.f.t(getApplicationContext());
        }
        return this.aR;
    }

    private void af() {
        LinearLayoutManager layoutManager = this.bF.getLayoutManager();
        this.bG = layoutManager;
        layoutManager.k1(true);
        bs();
        this.bF.setAdapter(aj());
        this.bF.addOnScrollListener(this.dF);
        this.bK.setOnClickListener(this.dX);
        e(0);
        aW();
        this.bL.setOnClickListener(this.dQ);
        this.bu.setOnClickListener(this.dQ);
        this.dy.setOnClickListener(new am(this));
        this.dA.setOnClickListener(new ax(this));
        this.bI.addTextChangedListener(this.dP);
        b(true);
        aF();
        ah();
        ai();
        this.cp.setOnClickListener(this.dT);
        String fr = this.cM.fr();
        if (!com.freshchat.consumer.sdk.util.ds.a(fr)) {
            com.freshchat.consumer.sdk.b.o.d(this.bM);
            return;
        }
        com.freshchat.consumer.sdk.b.o.c(this.bM);
        View view = this.bM;
        if (view instanceof TextView) {
            ((TextView) view).setText(fr);
        }
    }

    public void al() {
        List<MultiSelectCheckedButtonFragment> fC = com.freshchat.consumer.sdk.b.j.fA().fC();
        if (com.freshchat.consumer.sdk.util.w.e(fC)) {
            e(0);
        } else {
            e(fC.size());
            this.cb.setOnClickListener(new ab(this, fC));
        }
    }

    private void am() {
        e(0);
        com.freshchat.consumer.sdk.b.o.d(this.bY);
        bN();
    }

    public void ao() {
        throw new UnsupportedOperationException("Method not decompiled: com.freshchat.consumer.sdk.activity.ConversationDetailActivity.ao():void");
    }

    public void aq() {
        int inputType = this.bI.getInputType();
        com.freshchat.consumer.sdk.l.m mVar = this.cM;
        m.c O = mVar.O(mVar.lB());
        c0();
        if (!m.c.f(O)) {
            if (aX()) {
                return;
            }
            ar();
        } else {
            com.freshchat.consumer.sdk.b.o.d(this.bL);
            a(O);
            int e = m.c.e(O);
            if (inputType != e) {
                this.bI.setInputType(e);
            }
        }
    }

    private void cc() {
        try {
            if (cb()) {
                this.cL = new cl(this);
                NetworkRequest.Builder builder = new NetworkRequest.Builder();
                ConnectivityManager ca = ca();
                if (ca != null) {
                    ca.registerNetworkCallback(builder.build(), this.cL);
                }
            }
        } catch (Exception e) {
            com.freshchat.consumer.sdk.util.aj.a(e);
        }
    }

    private void h(int i2) {
        ViewGroup.LayoutParams layoutParams = this.cb.getLayoutParams();
        layoutParams.width = i2 == 2 ? com.freshchat.consumer.sdk.util.cj.a(a(), 540.0f) : -1;
        this.cb.setLayoutParams(layoutParams);
    }

    public void an() {
        if (this.dC.size() != 0) {
            this.dC.size();
            this.dD.size();
            this.dK.a(this.dD, null, false, false, 1);
            this.dC.clear();
            this.dB.clear();
            return;
        }
        this.dB.clear();
        Iterator<MessageFragment> it = this.dD.iterator();
        while (it.hasNext()) {
            this.dC.add((MessageFragment) it.next());
        }
        this.dB.addAll(this.dD);
        this.dK.a(this.dD, null, true, false, 1);
    }

    @Override
    public void f(int i2) {
        runOnUiThread(new cc(this, i2));
    }

    private void d() {
        this.bx = findViewById(R.id.opinion_feedback);
        this.bA = findViewById(R.id.rating_feedback);
        this.bp = findViewById(R.id.freshchat_conv_detail_text_reply_layout);
        this.bu = findViewById(R.id.freshchat_conv_detail_upload_attachment_layout);
        this.bC = (TextView) findViewById(R.id.freshchat_upload_attachment_tv);
        this.bD = findViewById(R.id.freshchat_conv_detail_voice_reply_layout);
        this.bE = findViewById(R.id.freshchat_chat_resolution_confirmation_layout);
        this.bF = (FreshchatRecyclerView) findViewById(R.id.freshchat_conv_detail_list);
        this.bI = (QuickActionsAutoCompleteView) findViewById(R.id.freshchat_conv_detail_reply_text);
        this.bJ = findViewById(R.id.freshchat_conv_detail_record_voice_reply_button);
        this.bK = findViewById(R.id.freshchat_conv_detail_send_reply_button);
        this.bL = findViewById(R.id.freshchat_conv_detail_attach_image);
        this.bM = findViewById(R.id.freshchat_conversation_banner_message_text);
        this.bQ = findViewById(R.id.freshchat_activity_conversation_detail_progressbar);
        this.bR = findViewById(R.id.freshchat_activity_conversation_detail_content);
        this.bV = (RelativeLayout) findViewById(R.id.freshchat_drop_down_input_frame);
        this.bW = (TextView) findViewById(R.id.freshchat_drop_down_input_frame_text);
        this.ce = findViewById(R.id.freshchat_conversation_meeting_banner);
        this.cj = (TextView) findViewById(R.id.freshchat_meeting_banner_date_text);
        this.cp = (Button) findViewById(R.id.freshchat_new_messages_count_btn);
        this.bU = findViewById(R.id.freshchat_quick_actions_button_recycler_view);
        this.bX = findViewById(R.id.fresh_chat_opinion_feedback_recycler_view);
        this.bH = new LinearLayoutManager(0);
        this.cU = (ScrollView) findViewById(R.id.freshchat_quick_actions_button_layout);
        findViewById(R.id.freshchat_quick_action_divider);
        this.bS = (TextView) findViewById(R.id.bot_invalid_input_alert_text);
        this.bT = findViewById(R.id.freshchat_invalid_input_message);
        this.cW = findViewById(R.id.freshchat_conv_detail_divider);
        this.dn = findViewById(R.id.freshchat_bot_calendar_layout);
        this.f2do = findViewById(R.id.freshchat_bot_time_picker_layout);
        int i2 = R.id.freshchat_phone_country_code_layout;
        this.da = findViewById(i2);
        int i3 = R.id.freshchat_phone_country_code;
        this.dc = (TextView) findViewById(i3);
        int i4 = R.id.freshchat_resend_otp_button;
        this.dd = findViewById(i4);
        int i5 = R.id.freshchat_resend_otp_text;
        this.df = (TextView) findViewById(i5);
        int i6 = R.id.freshchat_phone_country_flag;
        this.db = (ImageView) findViewById(i6);
        this.cX = findViewById(R.id.botFeedBackThanksMessage);
        this.cC = (Button) findViewById(R.id.opinion_feedback_select);
        this.bY = findViewById(R.id.freshchat_count_tracker_container);
        this.bZ = (TextView) findViewById(R.id.count_textView);
        this.cb = (Button) findViewById(R.id.submit_button);
        this.da = findViewById(i2);
        this.dc = (TextView) findViewById(i3);
        this.dd = findViewById(i4);
        this.df = (TextView) findViewById(i5);
        this.db = (ImageView) findViewById(i6);
        this.du = (RatingBar) findViewById(R.id.rating_bar);
        this.dt = (TextView) findViewById(R.id.rating_bar_label);
        this.dv = (Button) findViewById(R.id.rating_bar_button);
        this.dw = findViewById(R.id.freshchat_multiselect_carousel_frame);
        this.dx = (TextView) findViewById(R.id.freshchat_carousel_counter_text);
        this.dy = findViewById(R.id.freshchat_carousel_submit_button);
        this.dA = (Button) findViewById(R.id.freshchat_select_all_button);
    }

    public void c(int i2) {
        Button button;
        int i3;
        Button button2 = this.cb;
        if (i2 > 0) {
            button2.setEnabled(true);
            button = this.dA;
            i3 = R.string.freshchat_deselect_all;
        } else {
            button2.setEnabled(false);
            button = this.dA;
            i3 = R.string.freshchat_select_all;
        }
        button.setText(getString(i3));
        e(i2);
    }

    @Override
    public void g(String str) {
        runOnUiThread(new ce(this, str));
    }

    private void b(long j) {
        if (this.dg) {
            return;
        }
        ai aiVar = new ai(this, j, 1000L);
        this.dh = aiVar;
        aiVar.start();
    }

    private void c(View view) {
        runOnUiThread(new bx(this, view));
    }

    public void d(int i2) {
        String ag = this.cM.ag(i2);
        if (com.freshchat.consumer.sdk.util.ds.c(ag)) {
            com.freshchat.consumer.sdk.b.o.d(this.cp);
        } else {
            this.cp.setText(ag);
            com.freshchat.consumer.sdk.b.o.c(this.cp);
        }
    }

    public void e(String str) {
        if (com.freshchat.consumer.sdk.util.ds.c(str)) {
            return;
        }
        if (this.cM.bQ(str)) {
            com.freshchat.consumer.sdk.b.o.c(this.bT);
            com.freshchat.consumer.sdk.b.o.c(this.bS);
            this.bS.setText(getString(R.string.freshchat_character_limit_message, String.valueOf(str.length()), String.valueOf(500)));
        } else {
            ProgressDialog i2 = com.freshchat.consumer.sdk.b.o.i(a(), a().getString(R.string.freshchat_spinner_text));
            this.di = i2;
            i2.show();
            com.freshchat.consumer.sdk.l.m mVar = this.cM;
            mVar.a(mVar.a(str, true), new bu(this));
        }
    }

    private void b(Intent intent) {
        if (intent != null) {
            try {
                long longExtra = intent.getLongExtra("MARKETING_ID", -1L);
                if (intent.getBooleanExtra("NOTIFICATION_CLICKED", false)) {
                    com.freshchat.consumer.sdk.util.cc.s(getApplicationContext(), longExtra);
                }
            } catch (Exception e) {
                com.freshchat.consumer.sdk.util.aj.a(e);
            }
        }
    }

    private void d(View view) {
        runOnUiThread(new bz(this, view));
    }

    public void b(View view) {
        if (com.freshchat.consumer.sdk.util.w.a(this.cS)) {
            if (com.freshchat.consumer.sdk.b.o.m(view)) {
                if (this.cU == null) {
                    return;
                }
                View findViewById = findViewById(R.id.freshchat_message_container);
                int height = this.cU.getHeight();
                int height2 = findViewById != null ? findViewById.getHeight() : 0;
                int dimensionPixelSize = getResources().getDimensionPixelSize(R.dimen.freshchat_min_space_for_quick_action_buttons);
                if (height2 >= dimensionPixelSize) {
                    if (height2 - height <= dimensionPixelSize || com.freshchat.consumer.sdk.b.o.l(this.cU)) {
                        return;
                    }
                }
            } else if (com.freshchat.consumer.sdk.b.o.l(this.cU)) {
                return;
            }
            bl();
            return;
        }
        if (!com.freshchat.consumer.sdk.b.o.l(this.cU)) {
            return;
        }
        com.freshchat.consumer.sdk.b.o.d(this.cU);
    }

    public void c(boolean z) {
        com.freshchat.consumer.sdk.l.m mVar = this.cM;
        mVar.a(mVar.b(), this.cM.mA(), this.dV, z);
    }

    public void d(String str) {
        try {
            if (com.freshchat.consumer.sdk.util.ds.c(str)) {
                return;
            }
            String f = f(str);
            Message f2 = this.cM.f(f);
            com.freshchat.consumer.sdk.l.m mVar = this.cM;
            m.c O = mVar.O(mVar.lB());
            if (O == m.c.Bc) {
                String charSequence = this.dc.getText().toString();
                if (com.freshchat.consumer.sdk.util.w.a(f2.getMessageFragments())) {
                    Iterator<MessageFragment> it = f2.getMessageFragments().iterator();
                    while (true) {
                        if (!it.hasNext()) {
                            break;
                        }
                        MessageFragment next = it.next();
                        if (next.getContent().equals(f)) {
                            f = charSequence + f;
                            next.setContent(f);
                            break;
                        }
                    }
                }
            }
            if (!O.bS(f)) {
                b(O);
                return;
            }
            this.bI.setText("");
            this.bI.requestFocus();
            aU();
            a(f2);
        } catch (Exception e) {
            com.freshchat.consumer.sdk.util.aj.a(e);
        }
    }

    private static void a(Context context, long j, long j2, boolean z, int i2, String str) {
        if (j == 0 || j2 == 0) {
            return;
        }
        new com.freshchat.consumer.sdk.c.k(context).ae(Long.toString(j));
        com.freshchat.consumer.sdk.service.e.af afVar = new com.freshchat.consumer.sdk.service.e.af();
        CsatResponseRequest csatResponseRequest = new CsatResponseRequest();
        CsatResponse conversationId = new CsatResponse().setCsatId(j2).setIssueResolved(z).setConversationId(j);
        if (i2 > 0) {
            conversationId.setStars(i2);
        }
        if (!com.freshchat.consumer.sdk.util.ds.c(str)) {
            conversationId.setResponse(str);
        }
        csatResponseRequest.setCsatResponse(conversationId);
        afVar.b(csatResponseRequest);
        com.freshchat.consumer.sdk.service.d.h.b(context, afVar);
    }

    public void d(boolean z) {
        Csat csat;
        boolean z2;
        Conversation hr = this.cM.hr();
        if (hr == null || (csat = hr.getCsat()) == null || bZ()) {
            return;
        }
        c.a b = com.freshchat.consumer.sdk.b.o.b((Context) this, R.attr.freshchatCustomerSurveyDialog);
        View inflate = LayoutInflater.from(this).inflate(R.layout.freshchat_dialog_customer_survey, (ViewGroup) null);
        TextView textView = (TextView) inflate.findViewById(R.id.freshchat_custsurvey_question_text);
        RatingBar ratingBar = (RatingBar) inflate.findViewById(R.id.freshchat_custsurvey_rating_bar);
        EditText editText = (EditText) inflate.findViewById(R.id.freshchat_custsurvey_user_comment);
        if (z) {
            String string = getString(R.string.freshchat_chat_resolution_survey_question);
            if (com.freshchat.consumer.sdk.util.ds.c(string)) {
                string = csat.getQuestion();
            }
            textView.setText(com.freshchat.consumer.sdk.util.ds.a(string));
            z2 = csat.isMobileUserCommentsAllowed();
        } else {
            textView.setText(getString(R.string.freshchat_chat_resolution_suggestions_prompt));
            z2 = true;
        }
        if (z) {
            c(ratingBar);
        } else {
            d(ratingBar);
        }
        if (z2) {
            c(editText);
        } else {
            d(editText);
        }
        b.setPositiveButton(R.string.freshchat_chat_rating_submit, new cf(this, z, ratingBar, editText, csat, z));
        b.f(new cg(this, csat, z));
        b.setView(inflate);
        this.bP = b.create();
        ratingBar.setOnRatingBarChangeListener(new ch(this, z));
        this.bP.setOnShowListener(new ci(this, z));
        this.bP.show();
    }

    @Override
    public void b(CalendarMessageMeta calendarMessageMeta) {
        a(calendarMessageMeta);
    }

    public boolean c(Message message) {
        LinearLayoutManager linearLayoutManager = this.bG;
        if (linearLayoutManager != null && message != null) {
            View V0 = linearLayoutManager.V0(linearLayoutManager.x() - 1, -1, true, false);
            int a = V0 != null ? ((RecyclerView$p) V0.getLayoutParams()).a() : -1;
            if (com.freshchat.consumer.sdk.util.w.a(this.cM.lB()) && a > 0 && a < com.freshchat.consumer.sdk.util.w.b(this.cM.lB())) {
                if (aj().getItemCount() > com.freshchat.consumer.sdk.util.w.b(this.cM.lB())) {
                    a--;
                }
                return com.freshchat.consumer.sdk.util.ds.A(this.cM.lB().get(a).getAlias(), message.getAlias());
            }
        }
        return false;
    }

    @Override
    public void a(Context context, Intent intent) {
        String action = intent.getAction();
        com.freshchat.consumer.sdk.util.ck.a("FRESHCHAT", intent);
        if ("com.freshchat.consumer.sdk.actions.ExpectedConversationResponseTimeUpdated".equals(action)) {
            bt();
            return;
        }
        boolean equals = "com.freshchat.consumer.sdk.actions.ChannelsUpdated".equals(action);
        String str = EZkPENtU.SWcCQXdoJoJ;
        if (!equals && !str.equals(action) && !"com.freshchat.consumer.sdk.actions.MessageStatusChanged".equals(action) && !"com.freshchat.consumer.sdk.actions.OldMessagesFetched".equals(action)) {
            if ("com.freshchat.consumer.sdk.actions.JwtIdTokenStateChanged".equalsIgnoreCase(action) || "com.freshchat.consumer.sdk.actions.RemoteConfigUpdated".equalsIgnoreCase(action) || ("com.freshchat.consumer.sdk.actions.JwtModeEnabledForAccount".equalsIgnoreCase(action) && com.freshchat.consumer.sdk.util.dn.ct(a()) && com.freshchat.consumer.sdk.util.cl.cb(a()))) {
                aa();
                return;
            } else if ("android.net.conn.CONNECTIVITY_CHANGE".equals(intent.getAction())) {
                a(this.cM.kP());
                return;
            } else {
                if (JixXvsprIVCroZ.QVxczQvC.equalsIgnoreCase(action)) {
                    ap();
                    return;
                }
                return;
            }
        }
        if ("com.freshchat.consumer.sdk.actions.MessageStatusChanged".equals(action) && com.freshchat.consumer.sdk.util.ck.d(intent, "CHANNEL_ID") == this.cM.b() && !intent.getBooleanExtra("STATUS_SUCCESS", true)) {
            com.freshchat.consumer.sdk.b.o.a(a(), R.string.freshchat_message_sending_failed);
            return;
        }
        if ("com.freshchat.consumer.sdk.actions.OldMessagesFetched".equals(intent.getAction())) {
            cj();
        }
        if (str.equals(action) || "com.freshchat.consumer.sdk.actions.MessageStatusChanged".equals(action)) {
            if (this.cM.hr() != null && this.dl == this.cM.hr().getStatus()) {
                aO();
            }
            bv();
            if (this.cP != -1) {
                as();
                au();
            }
        }
        aP();
        (this.bI.hasFocus() ? this.bI : this.bF).requestFocus();
    }

    @Override
    public void b(CalendarMessageMeta calendarMessageMeta, CalendarDay.TimeSlot timeSlot, int i2) {
        a(calendarMessageMeta, timeSlot, i2);
    }

    private void a(Uri uri, int i2) {
        com.freshchat.consumer.sdk.util.da.a(a(), uri, da.b.TYPE_IMAGE, new av(this, uri, i2));
    }

    public void b(Message message) {
        CalendarMessageMeta y = this.cM.y(message);
        com.freshchat.consumer.sdk.l.m mVar = this.cM;
        com.freshchat.consumer.sdk.d.f a = com.freshchat.consumer.sdk.d.f.a(this.e, y, mVar.a(y, mVar.lC()));
        this.cO = a;
        a.show(getSupportFragmentManager(), "CalendarBottomSheet");
    }

    public void a(Uri uri, da.b bVar, int i2, boolean z) {
        Context a;
        int i3;
        long e = com.freshchat.consumer.sdk.util.as.e(a(), uri);
        String d = com.freshchat.consumer.sdk.util.as.d(a(), uri);
        if (com.freshchat.consumer.sdk.util.as.L(e)) {
            a = a();
            i3 = R.string.freshchat_file_size_exceeded_message;
        } else if (!com.freshchat.consumer.sdk.util.ds.c(com.freshchat.consumer.sdk.util.as.aV(d)) || bVar.equals(da.b.TYPE_IMAGE)) {
            startActivityForResult(PictureAttachmentActivity.a(a(), uri, i2, this.bI.getText().toString(), bVar, z), 127);
            return;
        } else {
            a = a();
            i3 = R.string.freshchat_file_not_supported_message;
        }
        com.freshchat.consumer.sdk.b.o.h(a, getString(i3));
    }

    private void b(m.c cVar) {
        com.freshchat.consumer.sdk.b.o.c(this.bT);
        com.freshchat.consumer.sdk.b.o.d(this.cW);
        int c = m.c.c(cVar);
        if (c != 0) {
            this.bS.setText(c);
        } else {
            com.freshchat.consumer.sdk.b.o.c(this.cW);
        }
    }

    private void a(MenuItem menuItem, boolean z) {
        Context a;
        int i2;
        if (this.cM.eg()) {
            int a2 = Cdo.a(a(), R.attr.freshchatSpeakerIcon, false);
            if (a2 <= 0) {
                return;
            }
            menuItem.setVisible(true);
            menuItem.setIcon(a2);
            if (!z) {
                return;
            }
            a = a();
            i2 = R.string.freshchat_speaker_phone_on;
        } else {
            int a3 = Cdo.a(a(), R.attr.freshchatEarpieceIcon, false);
            if (a3 <= 0) {
                return;
            }
            menuItem.setVisible(true);
            menuItem.setIcon(a3);
            if (!z) {
                return;
            }
            a = a();
            i2 = R.string.freshchat_speaker_phone_off;
        }
        com.freshchat.consumer.sdk.b.o.a(a, i2);
    }

    private void b(List<RatingOption> list) {
        this.du.setNumStars(list.size());
        this.du.setStepSize(1.0f);
        this.dv.setOnClickListener(new bf(this));
        this.du.setOnRatingBarChangeListener(new bi(this, list));
    }

    @Override
    public void a(DatePicker datePicker, int i2, int i3, int i4) {
        d(com.freshchat.consumer.sdk.util.ac.a(a(), i2, i3, i4));
    }

    @Override
    public void b(List<MultiSelectCheckedButtonFragment> list, long j) {
        bG();
        Message f = this.cM.f("");
        Iterator<MultiSelectCheckedButtonFragment> it = list.iterator();
        while (it.hasNext()) {
            f.addMessageFragment(it.next());
        }
        a(f);
        com.freshchat.consumer.sdk.util.ba.a(a(), list);
        com.freshchat.consumer.sdk.ui.p cl = cl();
        if (cl != null) {
            cl.dismiss();
            this.cH.notifyDataSetChanged();
        }
    }

    public void b(boolean z) {
        View view;
        if (z && Z().ef()) {
            com.freshchat.consumer.sdk.b.o.c(this.bJ);
            view = this.bK;
        } else {
            com.freshchat.consumer.sdk.b.o.c(this.bK);
            view = this.bJ;
        }
        com.freshchat.consumer.sdk.b.o.d(view);
    }

    @Override
    public void a(TimePicker timePicker, int i2, int i3) {
        d(com.freshchat.consumer.sdk.util.ac.b(i2, i3));
    }

    public void a(LinearLayoutManager linearLayoutManager) {
        if (linearLayoutManager != null) {
            ImageButton imageButton = (ImageButton) findViewById(R.id.freshchat_quick_action_button_scroll);
            int T0 = linearLayoutManager.T0();
            int P0 = linearLayoutManager.P0();
            if (this.cS != null && T0 == r2.size() - 1) {
                com.freshchat.consumer.sdk.b.o.d(imageButton);
            } else if (P0 >= 0) {
                com.freshchat.consumer.sdk.b.o.c(imageButton);
            }
        }
    }

    public void a(RecyclerView recyclerView, LinearLayoutManager linearLayoutManager) {
        ImageButton imageButton = (ImageButton) findViewById(R.id.freshchat_quick_action_button_scroll);
        recyclerView.addOnScrollListener(new ap(this, linearLayoutManager));
        recyclerView.getViewTreeObserver().addOnGlobalLayoutListener(new aq(this, linearLayoutManager));
        aM();
        imageButton.setOnClickListener(new ar(this, recyclerView));
    }

    @Override
    public String[] b() {
        return new String[]{"com.freshchat.consumer.sdk.actions.JwtModeEnabledForAccount", "com.freshchat.consumer.sdk.actions.MessagesUpdated", "com.freshchat.consumer.sdk.actions.ChannelsUpdated", "com.freshchat.consumer.sdk.actions.MessageStatusChanged", "com.freshchat.consumer.sdk.actions.ExpectedConversationResponseTimeUpdated", "com.freshchat.consumer.sdk.actions.JwtIdTokenStateChanged", "com.freshchat.consumer.sdk.actions.TokenWaitTimeout", "com.freshchat.consumer.sdk.actions.RemoteConfigUpdated", "com.freshchat.consumer.sdk.actions.OldMessagesFetched", "com.freshchat.consumer.sdk.actions.BannerMessageChanged"};
    }

    private void a(com.freshchat.consumer.sdk.a.b bVar) {
        if (bVar != null) {
            com.freshchat.consumer.sdk.b.o.x(this).a(bVar, new az(this, bVar)).h();
        }
    }

    public void a(CalendarMessageMeta calendarMessageMeta) {
        com.freshchat.consumer.sdk.l.m mVar = this.cM;
        Message a = mVar.a(calendarMessageMeta, mVar.mB(), this.a, this.b);
        if (a != null) {
            a(a);
            this.cM.N(a);
        }
    }

    private void a(CalendarMessageMeta calendarMessageMeta, CalendarDay.TimeSlot timeSlot, int i2) {
        com.freshchat.consumer.sdk.l.m mVar = this.cM;
        Message a = mVar.a(calendarMessageMeta, timeSlot, i2, mVar.mB(), this.a, this.b);
        if (a != null) {
            a(a);
        }
    }

    @Override
    public void a(CountryCode countryCode, int i2, String str) {
        com.freshchat.consumer.sdk.b.o.a(a().getApplicationContext(), getCurrentFocus());
        this.bI.requestFocus();
        this.db.setImageResource(i2);
        this.dc.setText(str);
        com.freshchat.consumer.sdk.ui.m ch = ch();
        if (ch != null) {
            ch.dismiss();
        }
    }

    public void a(Csat csat, boolean z) {
        a(csat, z, 0, (String) null);
    }

    public void a(Csat csat, boolean z, int i2, String str) {
        Conversation hr = this.cM.hr();
        if (hr == null) {
            return;
        }
        a(getApplicationContext(), hr.getConversationId(), csat.getCsatId(), z, i2, str);
        bs();
        com.freshchat.consumer.sdk.b.o.k(this.bI);
    }

    public void a(Message message) {
        if (message == null) {
            return;
        }
        am();
        if (com.freshchat.consumer.sdk.b.o.l(this.cU)) {
            com.freshchat.consumer.sdk.b.o.d(this.cU);
        }
        bE();
        bF();
        aT();
        if (this.cM.Q(this.cP) || this.cM.R(this.cP) || this.cM.S(this.cP)) {
            this.cM.a(message, this.h);
        }
        bE();
        bF();
        aS();
        aW();
        ar();
        aU();
        bK();
        bL();
        this.cQ = true;
        this.dB.clear();
        this.dC.clear();
        this.dE.clear();
        c(0);
        com.freshchat.consumer.sdk.util.ba.b(a(), this.cM.b(), this.cM.mA());
        if (!com.freshchat.consumer.sdk.util.db.cm(a())) {
            com.freshchat.consumer.sdk.b.o.a(a(), R.string.freshchat_error_send_message_when_no_internet);
        }
        com.freshchat.consumer.sdk.b.o.k(this.bI);
        List<Message> H = com.freshchat.consumer.sdk.util.at.H(this.cM.lB());
        if (com.freshchat.consumer.sdk.util.w.a(H)) {
            this.cM.hH().a(H, this.a, this.b);
            message.setAlias(com.freshchat.consumer.sdk.util.at.b(H.get(0).getCreatedMillis(), com.freshchat.consumer.sdk.util.w.b(H)));
        }
        if (!this.cM.hH().i(message)) {
            com.freshchat.consumer.sdk.b.o.a(a(), com.freshchat.consumer.sdk.b.c.MESSAGE_SENDING_FAILED);
            return;
        }
        this.cM.i(a(), message);
        aP();
        if (!com.freshchat.consumer.sdk.service.a.c.U(a())) {
            com.freshchat.consumer.sdk.util.b.a(a(), message, new aw(this));
        } else {
            com.freshchat.consumer.sdk.service.a.c.a(a(), message);
            com.freshchat.consumer.sdk.util.b.ap(a());
        }
    }

    @Override
    public void a(QuickReplyButtonFragment quickReplyButtonFragment, long j) {
        bG();
        Message a = this.cM.a(Z().dS(), (MessageFragment) quickReplyButtonFragment, this.cM.mB(), this.a, this.b, j);
        if (a != null) {
            a.setReferenceId(this.b);
            a(a);
            com.freshchat.consumer.sdk.util.ba.a(a(), (List<QuickReplyButtonFragment>) Collections.singletonList(quickReplyButtonFragment), false);
        }
        com.freshchat.consumer.sdk.ui.p cl = cl();
        if (cl != null) {
            cl.dismiss();
        }
    }

    public void a(com.freshchat.consumer.sdk.l.ab abVar) {
        List<MessageFragment> mt = abVar.mt();
        if (com.freshchat.consumer.sdk.util.w.e(mt)) {
            com.freshchat.consumer.sdk.util.co.a(i, pdCqGbSVuq.orAUpjrKZHJsFX);
            return;
        }
        com.freshchat.consumer.sdk.l.m mVar = this.cM;
        long ad = mVar.ad(mVar.lB());
        this.cM.N(ad);
        if (cl() == null) {
            com.freshchat.consumer.sdk.ui.p.a(mt, abVar.mu(), ad, QuickReplyOptions.QuickReplyMessageType.DROPDOWN).show(getSupportFragmentManager(), FrpdF.kOyrkBJmna);
        }
    }

    public void a(m.c cVar) {
        ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) this.bI.getLayoutParams();
        int dimensionPixelSize = getResources().getDimensionPixelSize(R.dimen.freshchat_text_view_placeholder_margin_left);
        int i2 = cn.eI[cVar.ordinal()];
        if (i2 != 1 && i2 != 2 && i2 != 3) {
            if (i2 == 4) {
                com.freshchat.consumer.sdk.util.z.jo();
                int dimensionPixelSize2 = getResources().getDimensionPixelSize(R.dimen.freshchat_text_view_default_margin_left);
                marginLayoutParams.leftMargin = dimensionPixelSize2;
                marginLayoutParams.setMarginStart(dimensionPixelSize2);
                this.bI.setLayoutParams(marginLayoutParams);
                com.freshchat.consumer.sdk.b.o.c(this.da);
                CountryCode aT = com.freshchat.consumer.sdk.util.z.aT(a());
                this.db.setImageResource(aT.getFlagResId());
                this.dc.setText(aT.getCountryDialCode());
                this.da.setOnClickListener(new aj(this));
            } else if (i2 != 5) {
                dimensionPixelSize = getResources().getDimensionPixelSize(R.dimen.freshchat_text_view_default_margin_left);
            } else {
                com.freshchat.consumer.sdk.util.z.jo();
                marginLayoutParams.leftMargin = dimensionPixelSize;
                marginLayoutParams.setMarginStart(dimensionPixelSize);
                av();
                this.bI.setLayoutParams(marginLayoutParams);
                com.freshchat.consumer.sdk.l.m mVar = this.cM;
                String U = mVar.U(mVar.lB());
                com.freshchat.consumer.sdk.l.m mVar2 = this.cM;
                long V = mVar2.V(mVar2.lB());
                if (V > 0) {
                    b(V);
                } else {
                    this.df.setText(U);
                    a(true);
                }
                this.dd.setOnClickListener(new ak(this, U));
                com.freshchat.consumer.sdk.b.o.d(this.cW);
                com.freshchat.consumer.sdk.b.o.c(this.dd);
                if (Build.VERSION.SDK_INT >= 26) {
                    this.bI.setAutofillHints(new String[]{"smsOTPCode"});
                    this.bI.setImportantForAutofill(1);
                    AutofillManager e = C2615tf.e(getSystemService(C2516sf.d()));
                    if (e != null) {
                        e.requestAutofill(this.bI);
                    }
                }
            }
            this.bI.setHint(m.c.d(cVar));
        }
        marginLayoutParams.leftMargin = dimensionPixelSize;
        marginLayoutParams.setMarginStart(dimensionPixelSize);
        this.bI.setLayoutParams(marginLayoutParams);
        this.bI.setHint(m.c.d(cVar));
    }

    public void a(Status status) {
        if (status == null) {
            return;
        }
        this.cM.f(status);
        aj().a(status);
        aj().notifyDataSetChanged();
    }

    private void a(Status status, int i2) {
        if (status == null) {
            return;
        }
        this.cM.f(status);
        aj().a(status);
        aj().notifyItemRangeInserted(0, i2 - 1);
        c(true);
    }

    public void a(g.a aVar, String str) {
        MessageFragment quickReplyButtonFragment = new QuickReplyButtonFragment();
        quickReplyButtonFragment.setLabel(str);
        com.freshchat.consumer.sdk.l.m mVar = this.cM;
        String dS = Z().dS();
        long mB = this.cM.mB();
        long j = this.a;
        String str2 = this.b;
        com.freshchat.consumer.sdk.l.m mVar2 = this.cM;
        Message a = mVar.a(dS, quickReplyButtonFragment, mB, j, str2, mVar2.ad(mVar2.lB()));
        String b = aVar.b();
        if (a != null) {
            a.setReferenceId(this.b);
            a(a);
            com.freshchat.consumer.sdk.util.ba.j(a(), b, str);
        }
    }

    public void a(cy.a aVar) {
        this.cN = new com.freshchat.consumer.sdk.l.ab(a());
        QuickReplyOptions.DropdownType dropdownType = QuickReplyOptions.DropdownType.SINGLE_SELECT;
        List<MessageFragment> arrayList = new ArrayList<>();
        if (aVar == cy.a.MULTI_SELECT_CHECKED_BUTTON || aVar == cy.a.MULTI_SELECT_BUTTONS) {
            arrayList = com.freshchat.consumer.sdk.b.j.fA().fB();
            dropdownType = QuickReplyOptions.DropdownType.MULTI_SELECT;
        } else if (aVar == cy.a.SINGLE_SELECT_BUTTON) {
            com.freshchat.consumer.sdk.l.m mVar = this.cM;
            Message aa = mVar.aa(mVar.lB());
            if (aa != null) {
                arrayList = this.cM.O(aa);
            }
        }
        if (com.freshchat.consumer.sdk.util.w.e(arrayList)) {
            com.freshchat.consumer.sdk.util.co.a(i, "MessageFragmentList is null");
            return;
        }
        com.freshchat.consumer.sdk.l.m mVar2 = this.cM;
        long ad = mVar2.ad(mVar2.lB());
        if (cl() == null) {
            com.freshchat.consumer.sdk.ui.p.a(arrayList, dropdownType, ad, QuickReplyOptions.QuickReplyMessageType.MULTI_SELECT_BUTTONS).show(getSupportFragmentManager(), "TAG_DROPDOWN_BOTTOMSHEET");
        }
    }

    @Override
    public void a(k.a aVar) {
        if (aVar != null) {
            try {
                if (aVar.jh() != null && !com.freshchat.consumer.sdk.util.ds.c(aVar.jh().getAbsolutePath())) {
                    Message f = this.cM.f("");
                    AudioFragment audioFragment = new AudioFragment();
                    audioFragment.setContent(aVar.jh().getAbsolutePath());
                    audioFragment.setContentType("audio/mpeg3");
                    audioFragment.setDuration(aVar.ji());
                    f.addMessageFragment(audioFragment);
                    com.freshchat.consumer.sdk.b.o.a(a(), (View) this.bI);
                    a(f);
                }
            } catch (Exception e) {
                com.freshchat.consumer.sdk.util.aj.a(e);
            }
        }
    }

    private void a(String str, int i2, int i3, String str2, String str3) {
        try {
            Message f = this.cM.f("");
            ImageFragment imageFragment = new ImageFragment();
            imageFragment.setContent(str);
            imageFragment.setContentType(com.freshchat.consumer.sdk.util.as.aX(str3));
            imageFragment.setHeight(i3);
            imageFragment.setWidth(i2);
            f.addMessageFragment(imageFragment);
            if (com.freshchat.consumer.sdk.util.ds.a(str2)) {
                TextFragment textFragment = new TextFragment();
                textFragment.setContent(str2);
                f.addMessageFragment(textFragment);
            }
            a(f);
        } catch (Exception e) {
            com.freshchat.consumer.sdk.util.aj.a(e);
        }
    }

    private void a(String str, String str2, long j, String str3) {
        try {
            Message f = this.cM.f("");
            FileFragment fileFragment = new FileFragment();
            fileFragment.setContent(str2);
            fileFragment.setContentType("*/*");
            fileFragment.setFileName(str);
            fileFragment.setFileSize(j);
            fileFragment.setFileExtension(com.freshchat.consumer.sdk.util.as.aV(str));
            f.addMessageFragment(fileFragment);
            if (com.freshchat.consumer.sdk.util.ds.a(str3)) {
                TextFragment textFragment = new TextFragment();
                textFragment.setContent(str3);
                f.addMessageFragment(textFragment);
            }
            a(f);
        } catch (Exception e) {
            com.freshchat.consumer.sdk.util.aj.a(e);
        }
    }

    @Override
    public void a(List<QuickReplyButtonFragment> list, long j) {
        bG();
        Message f = this.cM.f("");
        Iterator<QuickReplyButtonFragment> it = list.iterator();
        while (it.hasNext()) {
            f.addMessageFragment(it.next());
        }
        a(f);
        com.freshchat.consumer.sdk.util.ba.a(a(), list, true);
        com.freshchat.consumer.sdk.ui.p cl = cl();
        if (cl != null) {
            cl.dismiss();
        }
    }

    public void a(boolean z) {
        com.freshchat.consumer.sdk.b.o.a(a(), this.df, z ? R.attr.freshchatResendOtpEnabledTextStyle : R.attr.freshchatResendOtpDisabledTextStyle);
        this.dd.setSelected(z);
        this.dd.setEnabled(z);
    }
}