正在查看: Oolka v2.4.42 应用的 ConversationDetailActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Oolka v2.4.42 应用的 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.annotation.NonNull;
import androidx.appcompat.app.b;
import androidx.loader.app.LoaderManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
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.af;
import com.freshchat.consumer.sdk.service.e.k;
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.ea;
import com.freshchat.consumer.sdk.util.k;
import com.freshchat.consumer.sdk.util.q;
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 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.b 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 f1do;
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 ImageView j;
private String k;
private View l;
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 boolean n = false;
private final com.freshchat.consumer.sdk.g.d dq = new aa(this);
private com.freshchat.consumer.sdk.g.b dF = new by(this);
private final p.g dG = new co(this);
private final p.k dH = new cp(this);
private final p.a dI = new ab(this);
private b.a dJ = new ac(this);
private final b.d m = new ad(this);
private p.i dM = new ae(this);
final p.l dN = new aj(this);
private ab.a dO = new ar(this);
private TextWatcher dP = new av(this);
private View.OnClickListener dQ = new ay(this);
private View.OnClickListener dR = new az(this);
private View.OnLongClickListener dS = new ba(this);
private final View.OnClickListener dT = new bb(this);
private LoaderManager.a<List<Message>> dU = new bc(this);
private final View.OnClickListener o = new com.freshchat.consumer.sdk.util.b0(new bi(this));
private final View.OnClickListener p = new com.freshchat.consumer.sdk.util.b0(new bj(this));
private c.b dV = new bm(this);
private LoaderManager.a<Channel> dW = new bp(this);
private View.OnClickListener dX = new bq(this);
View.OnClickListener dY = new bz(this);
private final q.a dZ = new ck(this);
public class a implements Runnable {
final View a;
public a(View view) {
this.a = view;
}
@Override
public void run() {
View view = this.a;
if (view == null || view.getVisibility() != 0) {
return;
}
this.a.setVisibility(8);
}
}
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((CharSequence) 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() {
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");
com.freshchat.consumer.sdk.b.o.g(a(), (shouldShowRequestPermissionRationale && shouldShowRequestPermissionRationale2) ? getString(R.string.freshchat_chat_voice_messaging_permissions_rationale) : shouldShowRequestPermissionRationale2 ? getString(R.string.freshchat_chat_voice_messaging_write_storage_permission_rationale) : shouldShowRequestPermissionRationale ? getString(R.string.freshchat_chat_voice_messaging_audio_recording_permission_rationale) : "");
requestPermissions(com.freshchat.consumer.sdk.util.dd.d(a(), com.freshchat.consumer.sdk.util.dd.yC), 100);
}
}
private void aI() {
this.cs.setOnItemClickListener(new ak(this));
}
private void aM() {
if (this.cY == null) {
aq aqVar = new aq(this, a());
this.cY = aqVar;
aqVar.enable();
}
}
private void aN() {
this.bI.setOnItemClickListener(new as(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() {
com.freshchat.consumer.sdk.l.m mVar;
int size;
if (this.bG == null || (mVar = this.cM) == null) {
return;
}
List<Message> lB = mVar.lB();
if (!com.freshchat.consumer.sdk.util.w.e(lB) && (size = lB.size()) > 0) {
this.bG.scrollToPositionWithOffset(size - 1, 0);
}
}
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);
a(bVar);
return;
}
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));
a(bVar);
return;
}
if (D && ee) {
bVar.a(b.a.IMAGE_FROM_GALLERY, b.a.FILE);
a(bVar);
return;
}
if (C && ee) {
bVar.a(b.a.CAMERA_CAPTURE, b.a.FILE);
a(bVar);
} else if (C) {
bb();
} else if (D) {
aZ();
} else if (ee) {
ba();
}
}
public void aZ() {
Intent intent = new Intent();
intent.setType(da.b.TYPE_IMAGE.b());
boolean z = getResources().getBoolean(R.bool.freshchat_document_provider_enabled);
if (com.freshchat.consumer.sdk.util.dz.ko() && z) {
intent.setAction("android.intent.action.OPEN_DOCUMENT");
} else {
intent.setAction("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 af() {
LinearLayoutManager layoutManager = this.bF.getLayoutManager();
this.bG = layoutManager;
layoutManager.setStackFromEnd(true);
bs();
this.bF.setAdapter(aj());
this.bF.setItemAnimator((RecyclerView.ItemAnimator) null);
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((CharSequence) 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);
}
}
private void ah() {
this.bI.setOnEditorActionListener(new bk(this));
}
private void ai() {
View a2 = com.freshchat.consumer.sdk.b.o.a(getWindow());
if (a2 != null) {
a2.getViewTreeObserver().addOnGlobalLayoutListener(new cj(this, a2));
}
}
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.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.m);
this.cH.a(this.dM);
}
return this.cH;
}
public com.freshchat.consumer.sdk.a.e ak() {
return this.cH.df();
}
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 cq(this, fC));
}
}
private void am() {
e(0);
com.freshchat.consumer.sdk.b.o.d(this.bY);
bN();
}
public void ao() {
if (this.cM.Q(this.cP)) {
com.freshchat.consumer.sdk.l.m mVar = this.cM;
Message aa = mVar.aa(mVar.lB());
if (aa == null || !aa.isUserMessage()) {
bG();
return;
} else {
bH();
return;
}
}
com.freshchat.consumer.sdk.l.m mVar2 = this.cM;
Message ab = mVar2.ab(mVar2.lB());
com.freshchat.consumer.sdk.l.m mVar3 = this.cM;
Message aa2 = mVar3.aa(mVar3.lB());
if (ab == null || !com.freshchat.consumer.sdk.util.at.ba(ab.getAlias()) || aa2 == null || !aa2.isUserMessage()) {
bG();
} else {
bH();
}
}
private void ap() {
String e = Z().e("CONFIG_CONVERSATION_BANNER_MESSAGE");
if (!com.freshchat.consumer.sdk.util.ds.a((CharSequence) 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);
}
}
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 ar() {
this.bI.setHint(R.string.freshchat_chat_message_composer_hint);
aW();
if (this.bI.getInputType() != 16384) {
this.bI.setInputType(16384);
}
}
public void as() {
bv();
if (this.cq == null || !com.freshchat.consumer.sdk.util.w.a(this.f)) {
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.INPUT_TYPE_OTP)) {
return false;
}
com.freshchat.consumer.sdk.l.m mVar2 = this.cM;
Message aa = mVar2.aa(mVar2.lB());
long j = this.cP;
if (j != -1 && !this.cM.Q(j) && aa != null && !com.freshchat.consumer.sdk.util.at.aZ(aa.getAlias())) {
if (!aa.isUserMessage()) {
return false;
}
long j2 = this.cP;
if (j2 != -1 && !this.cM.Q(j2)) {
return false;
}
}
return true;
}
public void au() {
if (this.cB != null && !this.f.isEmpty()) {
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.setReverseLayout(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() {
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) {
this.bW.setText(getString(R.string.freshchat_multi_select_drop_down_hint_text));
} else {
this.bW.setText(getString(R.string.freshchat_drop_down_hint_text));
}
this.bV.setOnClickListener(new bx(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)) {
long mB = this.cM.mB();
bc().k(mB);
com.freshchat.consumer.sdk.util.ba.c(a(), mB, this.a);
lJ = false;
}
return (!lJ || bX() || aA()) ? false : true;
}
private boolean bX() {
androidx.appcompat.widget.g gVar = this.bI;
return gVar != null && com.freshchat.consumer.sdk.util.ds.a(gVar.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 ch(this));
}
}
private boolean bZ() {
androidx.appcompat.app.b bVar = this.bP;
return bVar != null && bVar.isShowing();
}
public void ba() {
Intent intent = new Intent();
intent.setType(da.b.TYPE_ANY.b());
boolean z = getResources().getBoolean(R.bool.freshchat_document_provider_enabled);
if (com.freshchat.consumer.sdk.util.dz.ko() && z) {
intent.setAction("android.intent.action.OPEN_DOCUMENT");
} else {
intent.setAction("android.intent.action.GET_CONTENT");
}
intent.addCategory("android.intent.category.OPENABLE");
startActivityForResult(intent, 124);
}
@android.annotation.TargetApi(23)
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 = cl.d[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 be(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.f1do);
this.f1do.setOnClickListener(new bf(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(this.o);
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 bl(this));
}
private void bl() {
com.freshchat.consumer.sdk.l.m mVar = this.cM;
this.cS = mVar.T(mVar.lB());
aL();
av();
}
private void bm() {
bs();
com.freshchat.consumer.sdk.l.m mVar = this.cM;
com.freshchat.consumer.sdk.b.k Z = mVar.Z(mVar.lB());
com.freshchat.consumer.sdk.b.k kVar = com.freshchat.consumer.sdk.b.k.NORMAL;
if (Z != kVar) {
bq();
}
com.freshchat.consumer.sdk.b.k kVar2 = com.freshchat.consumer.sdk.b.k.DROP_DOWN;
if (Z != kVar2) {
bP();
}
com.freshchat.consumer.sdk.b.k kVar3 = com.freshchat.consumer.sdk.b.k.MULTI_SELECT_BUTTON_FRAGMENT;
if (Z != kVar3) {
bo();
com.freshchat.consumer.sdk.b.j.fA().fD();
}
if (Z == kVar) {
if (this.cM.lS()) {
bp();
} else {
bq();
}
} else if (Z == kVar2) {
br();
} else if (Z == com.freshchat.consumer.sdk.b.k.CAROUSEL) {
bH();
} else if (Z == com.freshchat.consumer.sdk.b.k.CALLBACK) {
if (this.cM.lS()) {
bH();
}
} else if (Z == com.freshchat.consumer.sdk.b.k.BOT_FILE_ATTACHMENT) {
com.freshchat.consumer.sdk.util.ba.bQ(a());
bH();
bI();
} else if (Z == kVar3) {
bH();
bn();
} else if (Z == com.freshchat.consumer.sdk.b.k.NONE) {
bN();
} else if (Z == com.freshchat.consumer.sdk.b.k.MULTISELECT_CAROUSEL) {
bH();
bS();
}
if (this.cM.lK()) {
bH();
}
}
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((CharSequence) ly)) {
return;
}
getSupportActionBar().w(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 bt(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 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 cc() {
try {
if (cb()) {
cd();
this.cL = new ci(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 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 getSupportFragmentManager().k0("COUNTRY_CODE_BOTTOM_SHEET");
}
public void ci() {
a(this.cM.kO(), (Runnable) null);
}
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().a(this.cM.lB(), lH);
}
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((CharSequence) lP)) {
aj().m(lP);
}
}
private com.freshchat.consumer.sdk.ui.p cl() {
return getSupportFragmentManager().k0("TAG_DROPDOWN_BOTTOMSHEET");
}
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;
akVar.setBackgroundDrawable(androidx.core.content.b.e(this, R.drawable.freshchat_quick_actions_menu_popup));
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 al(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().e(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().e(0, bundle, this.dW);
}
public void ag() {
ArrayList arrayList = new ArrayList();
bG();
Message f = this.cM.f("");
for (MessageFragment messageFragment : this.dD) {
if (messageFragment instanceof CarouselCardDefaultFragment) {
CarouselCardDefaultFragment carouselCardDefaultFragment = (CarouselCardDefaultFragment) messageFragment;
if (carouselCardDefaultFragment.isSelected()) {
f.addMessageFragment(messageFragment);
arrayList.add(carouselCardDefaultFragment);
}
}
}
a(f);
com.freshchat.consumer.sdk.util.ba.b(a(), (List<CarouselCardDefaultFragment>) arrayList, true);
}
public void an() {
this.m.a(this.dD, 1);
}
@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.f1do)) {
d(this.f1do);
}
}
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().a(this.cM.lB(), this.cM.lw());
al();
}
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;
}
switch (i2) {
case 124:
com.freshchat.consumer.sdk.util.co.a(i, "onActivityResult::REQUEST_CODE_FILE");
try {
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;
} catch (Exception e) {
com.freshchat.consumer.sdk.util.aj.a(e);
return;
}
case 125:
com.freshchat.consumer.sdk.util.co.a(i, "onActivityResult::REQUEST_CODE_GALLERY");
try {
Uri data2 = intent.getData();
if (com.freshchat.consumer.sdk.util.cj.xV.contains(com.freshchat.consumer.sdk.util.as.f(a(), data2))) {
a(data2, da.b.TYPE_ANY, i2, this.cR);
} else {
a(data2, i2);
}
break;
} catch (Exception e2) {
com.freshchat.consumer.sdk.util.aj.a(e2);
return;
}
case 126:
String str = i;
com.freshchat.consumer.sdk.util.co.a(str, "onActivityResult::REQUEST_CODE_CAMERA");
try {
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;
}
} catch (Exception e3) {
com.freshchat.consumer.sdk.util.aj.a(e3);
return;
}
break;
case 127:
try {
this.bI.setText("");
this.dP.afterTextChanged(this.bI.getText());
if (da.b.TYPE_ANY.b().equals(intent.getStringExtra("MIME_TYPE"))) {
y.a aVar = new y.a();
aVar.i(intent);
a(aVar.a(), aVar.mn(), aVar.b(), aVar.mm());
} else {
y.b bVar = new y.b();
bVar.j(intent);
a(bVar.mp(), bVar.c(), bVar.b(), bVar.mm(), bVar.a());
}
break;
} catch (Exception e4) {
com.freshchat.consumer.sdk.util.aj.a(e4);
return;
}
}
}
@Override
public void onBackPressed() {
com.freshchat.consumer.sdk.b.o.a(getApplicationContext(), getCurrentFocus());
aQ();
aD();
com.freshchat.consumer.sdk.b.j.fA().fD();
com.freshchat.consumer.sdk.util.z.jo();
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) {
if (i2 == 100) {
String 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.l(this, str, getString(R.string.freshchat_chat_voice_messaging_permissions_not_granted));
return;
} else {
com.freshchat.consumer.sdk.util.co.c(str, getString(R.string.freshchat_chat_voice_messaging_permissions_granted));
aG();
return;
}
}
if (i2 != 101) {
super/*androidx.fragment.app.FragmentActivity*/.onRequestPermissionsResult(i2, strArr, iArr);
} else if (!com.freshchat.consumer.sdk.util.dd.a(iArr)) {
com.freshchat.consumer.sdk.util.co.l(this, i, getString(R.string.freshchat_chat_camera_permissions_not_granted));
} else {
com.freshchat.consumer.sdk.util.co.c(i, getString(R.string.freshchat_chat_camera_permissions_granted));
bb();
}
}
@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 a2 = com.freshchat.consumer.sdk.l.a.a.a(a().getApplicationContext(), this.B, longExtra);
this.cM = a2;
a2.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 boolean a0() {
return this.cM.lD() && this.cM.hr().hasPendingCsat();
}
private void c0() {
if (Build.VERSION.SDK_INT >= 26) {
AutofillManager a2 = androidx.compose.ui.autofill.b.a(getSystemService(androidx.compose.ui.autofill.a.a()));
if (a2 != null) {
a2.cancel();
}
this.bI.setAutofillHints(new String[]{""});
this.bI.setImportantForAutofill(0);
}
}
public void d0() {
com.freshchat.consumer.sdk.b.o.a(this.di);
ProgressDialog i2 = com.freshchat.consumer.sdk.b.o.i(a(), a().getString(R.string.freshchat_spinner_text));
this.di = i2;
i2.show();
}
public boolean e0() {
try {
List currentList = aj().getCurrentList();
if (com.freshchat.consumer.sdk.util.w.e(currentList)) {
return false;
}
int size = currentList.size();
Message a2 = ((com.freshchat.consumer.sdk.m.b.a) currentList.get(size - 1)).a();
Message a3 = size > 1 ? ((com.freshchat.consumer.sdk.m.b.a) currentList.get(size - 2)).a() : null;
if (c(a2)) {
return true;
}
return c(a3);
} catch (Exception e) {
com.freshchat.consumer.sdk.util.aj.a(e);
return true;
}
}
private void z() {
int i2 = cl.e[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 int f(List<MessageFragment> list) {
Iterator<MessageFragment> it = list.iterator();
int i2 = 0;
while (it.hasNext()) {
if (((CarouselCardDefaultFragment) it.next()).isSelected()) {
i2++;
}
}
return i2;
}
@Override
public void g(int i2) {
runOnUiThread(new cb(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.j = (ImageView) findViewById(R.id.freshchat_upload_attachment_icon);
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(this, 0, false);
this.cU = (ScrollView) findViewById(R.id.freshchat_quick_actions_button_layout);
this.l = 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.f1do = findViewById(R.id.freshchat_bot_time_picker_layout);
this.da = findViewById(R.id.freshchat_phone_country_code_layout);
this.dc = (TextView) findViewById(R.id.freshchat_phone_country_code);
this.dd = findViewById(R.id.freshchat_resend_otp_button);
this.df = (TextView) findViewById(R.id.freshchat_resend_otp_text);
this.db = (ImageView) findViewById(R.id.freshchat_phone_country_flag);
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(R.id.freshchat_phone_country_code_layout);
this.dc = (TextView) findViewById(R.id.freshchat_phone_country_code);
this.dd = findViewById(R.id.freshchat_resend_otp_button);
this.df = (TextView) findViewById(R.id.freshchat_resend_otp_text);
this.db = (ImageView) findViewById(R.id.freshchat_phone_country_flag);
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);
}
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 void h(int i2) {
ViewGroup.LayoutParams layoutParams = this.cb.getLayoutParams();
if (i2 == 2) {
layoutParams.width = com.freshchat.consumer.sdk.util.cj.a(a(), 540.0f);
} else {
layoutParams.width = -1;
}
this.cb.setLayoutParams(layoutParams);
}
@Override
public void g(String str) {
runOnUiThread(new cc(this, str));
}
private String f(@NonNull String str) {
return com.freshchat.consumer.sdk.util.ds.b(str) ? Html.escapeHtml(str) : str;
}
public void c(int i2) {
if (i2 > 0) {
this.cb.setEnabled(true);
this.dA.setText(getString(R.string.freshchat_deselect_all));
} else {
this.cb.setEnabled(false);
this.dA.setText(getString(R.string.freshchat_select_all));
}
e(i2);
}
public void b(@NonNull 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) {
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) {
com.freshchat.consumer.sdk.b.o.d(this.cU);
return;
} else {
if (height2 - height <= dimensionPixelSize || com.freshchat.consumer.sdk.b.o.l(this.cU)) {
return;
}
bl();
return;
}
}
return;
}
if (com.freshchat.consumer.sdk.b.o.l(this.cU)) {
return;
}
bl();
return;
}
if (com.freshchat.consumer.sdk.b.o.l(this.cU)) {
com.freshchat.consumer.sdk.b.o.d(this.cU);
}
}
@Override
public void f(int i2) {
runOnUiThread(new ca(this, i2));
}
public void e(@NonNull 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 {
d0();
com.freshchat.consumer.sdk.l.m mVar = this.cM;
mVar.a(mVar.a(str, true), new bs(this));
}
}
public void c(boolean z) {
com.freshchat.consumer.sdk.l.m mVar = this.cM;
mVar.a(mVar.b(), this.cM.mA(), this.dV, z);
}
private void c(View view) {
runOnUiThread(new bw(this, view));
}
private boolean c(Message message) {
LinearLayoutManager linearLayoutManager = this.bG;
if (linearLayoutManager != null && message != null) {
int findLastVisibleItemPosition = linearLayoutManager.findLastVisibleItemPosition();
List<Message> lB = this.cM.lB();
List currentList = aj().getCurrentList();
if (com.freshchat.consumer.sdk.util.w.a(currentList) && findLastVisibleItemPosition > 0 && findLastVisibleItemPosition < com.freshchat.consumer.sdk.util.w.b(currentList)) {
if (aj().getItemCount() > com.freshchat.consumer.sdk.util.w.b(currentList)) {
findLastVisibleItemPosition--;
}
if (findLastVisibleItemPosition < com.freshchat.consumer.sdk.util.w.b(lB)) {
return com.freshchat.consumer.sdk.util.ds.A(lB.get(findLastVisibleItemPosition).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;
}
if (!"com.freshchat.consumer.sdk.actions.ChannelsUpdated".equals(action) && !"com.freshchat.consumer.sdk.actions.MessagesUpdated".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)) {
if ("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(), (Runnable) null);
return;
} else {
if ("com.freshchat.consumer.sdk.actions.BannerMessageChanged".equalsIgnoreCase(action)) {
ap();
return;
}
return;
}
}
aa();
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 ("com.freshchat.consumer.sdk.actions.MessagesUpdated".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();
}
@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 b(long j) {
if (this.dg) {
return;
}
ag agVar = new ag(this, j, 1000L);
this.dh = agVar;
agVar.start();
}
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 b(@NonNull 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);
}
}
public void b(boolean z) {
if (z && Z().ef()) {
com.freshchat.consumer.sdk.b.o.c(this.bJ);
com.freshchat.consumer.sdk.b.o.d(this.bK);
} else {
com.freshchat.consumer.sdk.b.o.c(this.bK);
com.freshchat.consumer.sdk.b.o.d(this.bJ);
}
}
private void b(@NonNull List<RatingOption> list) {
this.du.setNumStars(list.size());
this.du.setStepSize(1.0f);
this.dv.setOnClickListener(this.p);
this.du.setOnRatingBarChangeListener(new bd(this, list));
}
public void b(@NonNull Message message) {
CalendarMessageMeta y = this.cM.y(message);
com.freshchat.consumer.sdk.l.m mVar = this.cM;
com.freshchat.consumer.sdk.d.f a2 = com.freshchat.consumer.sdk.d.f.a(this.e, y, mVar.a(y, mVar.lC()));
this.cO = a2;
a2.show(getSupportFragmentManager(), "CalendarBottomSheet");
}
public void a(@NonNull 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 = cl.a[cVar.ordinal()];
if (i2 == 1 || i2 == 2 || i2 == 3) {
marginLayoutParams.leftMargin = dimensionPixelSize;
marginLayoutParams.setMarginStart(dimensionPixelSize);
this.bI.setLayoutParams(marginLayoutParams);
} else if (i2 == 4) {
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 aU = com.freshchat.consumer.sdk.util.z.aU(a());
this.db.setImageResource(aU.getFlagResId());
this.dc.setText(aU.getCountryDialCode());
this.da.setOnClickListener(new ah(this));
} else if (i2 != 5) {
int dimensionPixelSize3 = getResources().getDimensionPixelSize(R.dimen.freshchat_text_view_default_margin_left);
marginLayoutParams.leftMargin = dimensionPixelSize3;
marginLayoutParams.setMarginStart(dimensionPixelSize3);
this.bI.setLayoutParams(marginLayoutParams);
} else {
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 ai(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 a2 = androidx.compose.ui.autofill.b.a(getSystemService(androidx.compose.ui.autofill.a.a()));
if (a2 != null) {
a2.requestAutofill(this.bI);
}
}
}
this.bI.setHint(m.c.d(cVar));
}
@Override
public void b(CalendarMessageMeta calendarMessageMeta) {
a(calendarMessageMeta);
}
@Override
public void b(CalendarMessageMeta calendarMessageMeta, @NonNull CalendarDay.TimeSlot timeSlot, int i2) {
a(calendarMessageMeta, timeSlot, i2);
}
@Override
public void b(@NonNull 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();
aj().a(this.cM.lB(), this.cM.lw());
}
}
public void d(@NonNull 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.INPUT_TYPE_PHONE_WITH_COUNTRY_CODE) {
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)) {
this.bI.setText("");
this.bI.requestFocus();
aU();
a(f2);
return;
}
b(O);
} catch (Exception e) {
com.freshchat.consumer.sdk.util.aj.a(e);
}
}
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);
}
}
private void d(View view) {
runOnUiThread(new a(view));
}
public void d(boolean z) {
Csat csat;
boolean z2;
Conversation hr = this.cM.hr();
if (hr == null || (csat = hr.getCsat()) == null || bZ()) {
return;
}
b.a b = com.freshchat.consumer.sdk.b.o.b(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 cd(this, z, ratingBar, editText, csat, z));
b.h(new ce(this, csat, z));
b.setView(inflate);
this.bP = b.create();
ratingBar.setOnRatingBarChangeListener(new cf(this, z));
this.bP.setOnShowListener(new cg(this, z));
this.bP.show();
}
public void a(boolean z) {
if (z) {
com.freshchat.consumer.sdk.b.o.a(a(), this.df, R.attr.freshchatResendOtpEnabledTextStyle);
} else {
com.freshchat.consumer.sdk.b.o.a(a(), this.df, R.attr.freshchatResendOtpDisabledTextStyle);
}
this.dd.setSelected(z);
this.dd.setEnabled(z);
}
public void a(@NonNull g.a aVar, @NonNull String str) {
QuickReplyButtonFragment 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 a2 = mVar.a(dS, quickReplyButtonFragment, mB, j, str2, mVar2.ad(mVar2.lB()));
String b = aVar.b();
if (a2 != null) {
a2.setReferenceId(this.b);
a(a2);
com.freshchat.consumer.sdk.util.ba.j(a(), b, str);
}
}
public void a(@NonNull RecyclerView recyclerView, @NonNull LinearLayoutManager linearLayoutManager) {
ImageButton imageButton = (ImageButton) findViewById(R.id.freshchat_quick_action_button_scroll);
recyclerView.addOnScrollListener(new an(this, linearLayoutManager));
recyclerView.getViewTreeObserver().addOnGlobalLayoutListener(new ao(this, linearLayoutManager));
aM();
imageButton.setOnClickListener(new ap(this, recyclerView));
}
public void a(@NonNull LinearLayoutManager linearLayoutManager) {
if (linearLayoutManager != null) {
ImageButton imageButton = (ImageButton) findViewById(R.id.freshchat_quick_action_button_scroll);
int findLastVisibleItemPosition = linearLayoutManager.findLastVisibleItemPosition();
int findFirstCompletelyVisibleItemPosition = linearLayoutManager.findFirstCompletelyVisibleItemPosition();
if (this.cS != null && findLastVisibleItemPosition == r2.size() - 1) {
com.freshchat.consumer.sdk.b.o.d(imageButton);
} else if (findFirstCompletelyVisibleItemPosition >= 0) {
com.freshchat.consumer.sdk.b.o.c(imageButton);
}
}
}
private void a(MenuItem menuItem, boolean z) {
if (this.cM.eg()) {
int a2 = Cdo.a(a(), R.attr.freshchatSpeakerIcon, false);
if (a2 > 0) {
menuItem.setVisible(true);
menuItem.setIcon(a2);
if (z) {
com.freshchat.consumer.sdk.b.o.a(a(), R.string.freshchat_speaker_phone_on);
return;
}
return;
}
return;
}
int a3 = Cdo.a(a(), R.attr.freshchatEarpieceIcon, false);
if (a3 > 0) {
menuItem.setVisible(true);
menuItem.setIcon(a3);
if (z) {
com.freshchat.consumer.sdk.b.o.a(a(), R.string.freshchat_speaker_phone_off);
}
}
}
private void a(Uri uri, int i2) {
com.freshchat.consumer.sdk.util.da.a(a(), uri, da.b.TYPE_IMAGE, new at(this, uri, i2));
}
private void a(@NonNull String str, @NonNull String str2, @NonNull 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((CharSequence) str3)) {
MessageFragment textFragment = new TextFragment();
textFragment.setContent(str3);
f.addMessageFragment(textFragment);
}
a(f);
} catch (Exception e) {
com.freshchat.consumer.sdk.util.aj.a(e);
}
}
private void a(@NonNull String str, @NonNull int i2, @NonNull int i3, String str2, @NonNull 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((CharSequence) str2)) {
MessageFragment textFragment = new TextFragment();
textFragment.setContent(str2);
f.addMessageFragment(textFragment);
}
a(f);
} catch (Exception e) {
com.freshchat.consumer.sdk.util.aj.a(e);
}
}
@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);
}
}
}
public void a(Message message) {
this.n = false;
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.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.service.a.c.a(a(), message);
com.freshchat.consumer.sdk.util.b.ap(a());
} else {
com.freshchat.consumer.sdk.util.b.a(a(), message, new au(this));
}
}
public void a(@NonNull Uri uri, @NonNull da.b bVar, int i2, boolean z) {
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)) {
com.freshchat.consumer.sdk.b.o.h(a(), getString(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)) {
com.freshchat.consumer.sdk.b.o.h(a(), getString(R.string.freshchat_file_not_supported_message));
} else {
startActivityForResult(PictureAttachmentActivity.a(a(), uri, i2, this.bI.getText().toString(), bVar, z), 127);
}
}
private void a(@NonNull com.freshchat.consumer.sdk.a.b bVar) {
if (bVar != null) {
com.freshchat.consumer.sdk.b.o.x(this).a(bVar, new aw(this, bVar)).m();
}
}
public void a(CalendarMessageMeta calendarMessageMeta) {
com.freshchat.consumer.sdk.l.m mVar = this.cM;
Message a2 = mVar.a(calendarMessageMeta, mVar.mB(), this.a, this.b);
if (a2 != null) {
a(a2);
this.cM.N(a2);
}
}
private void a(CalendarMessageMeta calendarMessageMeta, @NonNull CalendarDay.TimeSlot timeSlot, int i2) {
com.freshchat.consumer.sdk.l.m mVar = this.cM;
Message a2 = mVar.a(calendarMessageMeta, timeSlot, i2, mVar.mB(), this.a, this.b);
if (a2 != null) {
a(a2);
}
}
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, "quickReplyDropDownViewModel.getOptions() is null");
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(), "TAG_DROPDOWN_BOTTOMSHEET");
}
}
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) {
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);
}
}
} else {
arrayList = com.freshchat.consumer.sdk.b.j.fA().fB();
dropdownType = QuickReplyOptions.DropdownType.MULTI_SELECT;
}
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");
}
}
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);
}
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));
af afVar = new 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 a(Status status, Runnable runnable) {
if (status == null) {
return;
}
this.cM.f(status);
aj().a(this.cM.lB(), status, runnable);
}
private void a(Status status, int i2) {
if (status == null) {
return;
}
this.cM.f(status);
aj().a(this.cM.lB(), status);
c(true);
}
@Override
public void a(@NonNull QuickReplyButtonFragment quickReplyButtonFragment, long j) {
bG();
Message a2 = this.cM.a(Z().dS(), quickReplyButtonFragment, this.cM.mB(), this.a, this.b, j);
if (a2 != null) {
a2.setReferenceId(this.b);
a(a2);
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();
}
}
@Override
public void a(@NonNull 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();
}
}
@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 a(TimePicker timePicker, int i2, int i3) {
d(com.freshchat.consumer.sdk.util.ac.b(i2, i3));
}
@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();
}
}
}