正在查看: Oolka v2.4.42 应用的 ArticleDetailActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Oolka v2.4.42 应用的 ArticleDetailActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.freshchat.consumer.sdk.activity;
import android.R;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.util.TypedValue;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.webkit.WebViewClient;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.core.view.m1;
import androidx.core.view.z0;
import androidx.loader.app.LoaderManager;
import com.freshchat.consumer.sdk.FaqOptions;
import com.freshchat.consumer.sdk.Freshchat;
import com.freshchat.consumer.sdk.FreshchatWebViewListener;
import com.freshchat.consumer.sdk.activity.ds;
import com.freshchat.consumer.sdk.beans.Article;
import com.freshchat.consumer.sdk.beans.Category;
import com.freshchat.consumer.sdk.service.d.e;
import com.freshchat.consumer.sdk.service.e.o;
import com.freshchat.consumer.sdk.service.e.y;
import com.freshchat.consumer.sdk.util.cn;
import java.lang.ref.WeakReference;
import java.util.Locale;
import java.util.regex.Pattern;
public class ArticleDetailActivity extends cr implements LoaderManager.a<Article>, ds.b {
private static String l = "isArticleVoted";
private static String s = "HL_ARTICLE_TITLE";
private static final String t;
private static final String u;
private static String z;
private String[] B;
private String a;
private String b;
private String c;
private View i;
private View j;
private ds k;
private RelativeLayout m;
private View n;
private View o;
private View p;
private View q;
private com.freshchat.consumer.sdk.b.t r;
private String v;
private boolean w;
private boolean y;
FaqOptions g = new FaqOptions();
private Bundle h = null;
private boolean x = false;
private String d = "article_list";
private boolean A = false;
WebViewClient C = new c(this);
View.OnClickListener D = new f(this);
View.OnClickListener E = new g(this);
public class a implements Runnable {
public a() {
}
@Override
public void run() {
ArticleDetailActivity.this.k.scrollBy(0, 1);
}
}
static {
String str = "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"file:///android_res/raw/normalize.css\"/><script src='file:///freshchat_assets/freshchat_hacks.js'></script><title>" + s + "</title></head>";
t = str;
u = "<!DOCTYPE html>\t<html>" + str + "<body onload='correctIframe()'> <bdi>";
}
private void f0() {
if (this.m == null) {
return;
}
m1.b(getWindow(), false);
z0.G0(this.m, new com.freshchat.consumer.sdk.activity.a(this));
z0.n0(this.m);
}
public int g0() {
TypedValue typedValue = new TypedValue();
if (getTheme().resolveAttribute(R.attr.actionBarSize, typedValue, true)) {
return TypedValue.complexToDimensionPixelSize(typedValue.data, getResources().getDisplayMetrics());
}
return 0;
}
private void n() {
if (this.w) {
return;
}
String str = z;
if (str == null || !str.equals(this.v)) {
Animation loadAnimation = AnimationUtils.loadAnimation(this, com.freshchat.consumer.sdk.R.anim.freshchat_slide_up);
this.n.bringToFront();
this.n.startAnimation(loadAnimation);
this.n.setVisibility(0);
}
}
public void o() {
if (this.w) {
return;
}
this.n.startAnimation(AnimationUtils.loadAnimation(this, com.freshchat.consumer.sdk.R.anim.freshchat_slide_down));
this.n.setVisibility(8);
}
private void p() {
if (getSupportActionBar() != null) {
getSupportActionBar().l();
}
}
private void q() {
if (getSupportActionBar() != null) {
getSupportActionBar().z();
}
}
private void r() {
this.k.postDelayed(new a(), 500L);
}
public com.freshchat.consumer.sdk.util.ao s() {
return com.freshchat.consumer.sdk.util.cc.a(a(), this.g);
}
@Override
public void a(Context context, Intent intent) {
}
@Override
public void m() {
q();
r();
this.x = false;
}
public void onConfigurationChanged(Configuration configuration) {
super.onConfigurationChanged(configuration);
if (this.x) {
return;
}
r();
}
@Override
public void onCreate(Bundle bundle) {
FreshchatWebViewListener webviewListener;
super.onCreate(bundle);
Locale cd = cn.cd(this);
a(bundle);
Intent intent = getIntent();
a(intent);
Bundle extras = intent.getExtras();
this.h = extras;
this.g = com.freshchat.consumer.sdk.util.an.e(extras);
e();
setContentView(com.freshchat.consumer.sdk.R.layout.freshchat_activity_article_detail);
E();
c(!com.freshchat.consumer.sdk.util.ds.c(this.g.getFilteredViewTitle()) ? this.g.getFilteredViewTitle() : com.freshchat.consumer.sdk.util.ds.c(this.c) ? getString(com.freshchat.consumer.sdk.R.string.freshchat_activity_title_article_detail) : this.c);
d();
if (Build.VERSION.SDK_INT >= 35) {
f0();
}
com.freshchat.consumer.sdk.util.b.a(getApplicationContext(), o.a.NORMAL);
f();
this.w = h().Z(this.v);
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(-2, -2);
layoutParams.addRule(13, -1);
RelativeLayout.LayoutParams layoutParams2 = new RelativeLayout.LayoutParams(-1, -1);
layoutParams2.addRule(10, -1);
this.j = LayoutInflater.from(this).inflate(com.freshchat.consumer.sdk.R.layout.freshchat_partial_article_progress, (ViewGroup) null);
ds dsVar = new ds(this);
this.k = dsVar;
dsVar.setWebViewClient(this.C);
this.k.a(this, 85);
this.m.addView(this.k.getLayout(), layoutParams2);
this.m.addView(this.j, layoutParams);
if (bundle != null) {
this.k.restoreState(bundle);
}
this.i = this.k;
Locale cd2 = cn.cd(this);
if (cd == null || cd2 == null || !com.freshchat.consumer.sdk.util.ds.B(cd.getLanguage(), cd2.getLanguage()) || (webviewListener = Freshchat.getInstance(this).getWebviewListener()) == null) {
return;
}
webviewListener.onLocaleChangedByWebView(new WeakReference<>(this));
}
public androidx.loader.content.c<Article> onCreateLoader(int i, Bundle bundle) {
return new com.freshchat.consumer.sdk.h.m(getApplicationContext(), bundle.getString("article_id"), bundle.containsKey("EXTRA_FETCH_CATEGORY_INFO"));
}
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(com.freshchat.consumer.sdk.R.menu.freshchat_article_detail_list, menu);
return true;
}
public void onDestroy() {
super.onDestroy();
ds dsVar = this.k;
if (dsVar != null) {
dsVar.destroy();
}
}
public boolean onKeyDown(int i, KeyEvent keyEvent) {
if (i != 4 || !this.k.cz()) {
return super.onKeyDown(i, keyEvent);
}
this.k.cA();
return true;
}
public void onLoadFinished(androidx.loader.content.c cVar, Object obj) {
a((androidx.loader.content.c<Article>) cVar, (Article) obj);
}
public void onLoaderReset(androidx.loader.content.c<Article> cVar) {
}
@Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
return super.onOptionsItemSelected(menuItem);
}
@Override
@TargetApi(11)
public void onPause() {
super.onPause();
if (com.freshchat.consumer.sdk.util.dz.kw() && com.freshchat.consumer.sdk.util.dz.kj()) {
this.k.onPause();
} else if (com.freshchat.consumer.sdk.util.dz.kh()) {
this.k.cB();
}
}
@Override
@TargetApi(11)
public void onResume() {
super.onResume();
this.w = h().Z(this.v);
g();
if (com.freshchat.consumer.sdk.util.dz.kw() && com.freshchat.consumer.sdk.util.dz.kj()) {
this.k.onResume();
}
}
@Override
public void onSaveInstanceState(Bundle bundle) {
bundle.putBoolean(l, this.w);
super.onSaveInstanceState(bundle);
}
public void onStart() {
super.onStart();
if (com.freshchat.consumer.sdk.util.dz.kr()) {
this.k.onResume();
}
}
public void onStop() {
super.onStop();
if (com.freshchat.consumer.sdk.util.dz.kr()) {
this.k.onPause();
}
this.k.stopLoading();
}
private void c() {
com.freshchat.consumer.sdk.util.ba.a(a(), this.b, this.c, this.v, this.a, this.B);
if (this.A) {
return;
}
new com.freshchat.consumer.sdk.service.d.e(getApplicationContext(), e.a.faq_open_article).r("category_id", this.b).r("category_name", this.c).r("article_id", this.v).r("article_name", this.a).r("source", this.d).hV();
this.A = true;
}
private void d() {
this.p = findViewById(com.freshchat.consumer.sdk.R.id.freshchat_upvote);
this.q = findViewById(com.freshchat.consumer.sdk.R.id.freshchat_downvote);
this.n = findViewById(com.freshchat.consumer.sdk.R.id.freshchat_voting_view);
this.o = findViewById(com.freshchat.consumer.sdk.R.id.freshchat_contact_us_group);
this.m = (RelativeLayout) findViewById(com.freshchat.consumer.sdk.R.id.freshchat_solution_article_root_layout);
((TextView) findViewById(com.freshchat.consumer.sdk.R.id.freshchat_contact_us_btn)).setText(com.freshchat.consumer.sdk.R.string.freshchat_faq_not_helpful_contact_us);
}
private void e() {
Bundle bundle = new Bundle();
bundle.putString("article_id", this.v);
if (com.freshchat.consumer.sdk.util.ds.c(this.c)) {
bundle.putBoolean("EXTRA_FETCH_CATEGORY_INFO", true);
}
getSupportLoaderManager().c(0, bundle, this);
}
private void f() {
this.p.setOnClickListener(this.D);
this.q.setOnClickListener(this.D);
this.o.setOnClickListener(this.E);
}
private void g() {
if (!this.g.shouldShowContactUsOnFaqNotHelpful() || !this.w || !h().Y(this.v)) {
this.o.setVisibility(8);
} else {
this.o.bringToFront();
this.o.setVisibility(0);
}
}
public void i() {
new com.freshchat.consumer.sdk.service.d.e(getApplicationContext(), e.a.channels_launch).r("source", "article_not_helpful").r("article_id", this.v).r("category_id", this.b).hV();
}
@Override
public String[] b() {
return new String[]{"com.freshchat.consumer.sdk.actions.TokenWaitTimeout", "com.freshchat.consumer.sdk.actions.FAQApiVersionChanged"};
}
public com.freshchat.consumer.sdk.b.t h() {
if (this.r == null) {
this.r = new com.freshchat.consumer.sdk.b.t(this);
}
return this.r;
}
@Override
public void j() {
n();
}
@Override
public void k() {
o();
}
@Override
public void l() {
p();
this.x = true;
this.n.setVisibility(8);
}
private void a(Intent intent) {
if (!intent.hasExtra("article_id")) {
Toast.makeText((Context) this, com.freshchat.consumer.sdk.R.string.freshchat_faq_failed_to_load, 0).show();
finish();
}
long longExtra = intent.getLongExtra("article_id", -1L);
if (longExtra > 0) {
this.v = Long.toString(longExtra);
} else {
Toast.makeText((Context) this, com.freshchat.consumer.sdk.R.string.freshchat_faq_failed_to_load, 0).show();
finish();
}
if (intent.hasExtra("category_id")) {
this.b = intent.getStringExtra("category_id");
}
if (intent.hasExtra("category_name")) {
this.c = intent.getStringExtra("category_name");
}
if (intent.hasExtra("EVENT_LAUNCH_SOURCE")) {
this.d = intent.getStringExtra("EVENT_LAUNCH_SOURCE");
}
if (intent.hasExtra("LAUNCHED_FROM_CONVERSATION")) {
this.y = intent.getBooleanExtra("LAUNCHED_FROM_CONVERSATION", false);
}
this.B = intent.getStringArrayExtra("INPUT_TAGS");
}
public void a(y.a aVar) {
y.a aVar2 = y.a.Upvote;
com.freshchat.consumer.sdk.util.ba.a(a(), this.b, this.c, this.v, this.a, aVar == aVar2);
new com.freshchat.consumer.sdk.service.d.e(getApplicationContext(), aVar == aVar2 ? e.a.faq_upvote_article : e.a.faq_downvote_article).r("article_id", this.v).r("category_id", this.b).r("article_name", this.a).hV();
}
public void a(androidx.loader.content.c<Article> cVar, Article article) {
Category hw;
String a2 = a(article);
if (com.freshchat.consumer.sdk.util.ds.a((CharSequence) a2)) {
if ((cVar instanceof com.freshchat.consumer.sdk.h.m) && (hw = ((com.freshchat.consumer.sdk.h.m) cVar).hw()) != null) {
String title = hw.getTitle();
this.c = title;
a2 = a2.replace(s, title);
}
this.k.loadDataWithBaseURL(null, a2, "text/html", "utf-8", null);
}
c();
}
private String a(Article article) {
String str;
if (article == null) {
return null;
}
this.b = article.getCategoryId();
StringBuilder sb = new StringBuilder();
String replaceAll = article.getDescription().replaceAll("src=\"//", "src=\"http://").replaceAll("value=\"//", "value=\"http://");
Pattern compile = Pattern.compile("<\\s*(img|iframe).*?src\\s*=[ '\"]+http[s]?:\\/\\/.*?>");
if (com.freshchat.consumer.sdk.util.db.cm(this) || !compile.matcher(replaceAll).find()) {
str = "";
} else {
str = "<div class='offline-article-message'>" + getString(com.freshchat.consumer.sdk.R.string.freshchat_faq_rich_media_content_cannot_be_displayed) + "</div>";
}
this.a = article.getTitle();
sb.append(u);
sb.append("<div class=\"article-title\";><h3 >");
sb.append(this.a);
sb.append("</h3></div>");
sb.append(str);
sb.append("<div class=\"article-body\">");
sb.append(replaceAll);
sb.append("</div>");
sb.append("</bdi></body></html>");
String sb2 = sb.toString();
return !com.freshchat.consumer.sdk.util.ds.c(this.c) ? sb2.replace(s, this.c) : sb2;
}
private void a(Bundle bundle) {
if (bundle != null) {
this.w = bundle.getBoolean(l);
} else {
this.w = false;
}
}
}