- Added realracing3-community.apk (71.57 MB) - Removed 32-bit support (armeabi-v7a) - Only includes arm64-v8a libraries - Decompiled source code included - Added README-community.md with analysis
298 lines
12 KiB
Java
298 lines
12 KiB
Java
package com.helpshift.faq;
|
|
|
|
import android.content.Intent;
|
|
import android.os.Bundle;
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.webkit.WebView;
|
|
import android.widget.ImageView;
|
|
import android.widget.LinearLayout;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import androidx.fragment.app.Fragment;
|
|
import androidx.fragment.app.FragmentActivity;
|
|
import com.helpshift.R$id;
|
|
import com.helpshift.R$layout;
|
|
import com.helpshift.activities.FragmentTransactionListener;
|
|
import com.helpshift.activities.HSMainActivity;
|
|
import com.helpshift.cache.HelpshiftResourceCacheManager;
|
|
import com.helpshift.core.HSContext;
|
|
import com.helpshift.core.HSJSGenerator;
|
|
import com.helpshift.log.HSLogger;
|
|
import com.helpshift.notification.NotificationReceivedCallback;
|
|
import com.helpshift.user.UserManager;
|
|
import com.helpshift.util.Utils;
|
|
import com.helpshift.util.ValuePair;
|
|
import com.helpshift.util.ViewUtil;
|
|
import com.helpshift.views.HSWebView;
|
|
import com.ironsource.nb;
|
|
|
|
/* loaded from: classes3.dex */
|
|
public class HSHelpcenterFragment extends Fragment implements HelpcenterToUiCallback, NotificationReceivedCallback, View.OnClickListener {
|
|
public static final String TAG = "HelpCenter";
|
|
private HSHelpcenterEventsHandler eventsHandler;
|
|
private HSWebView helpCenterWebview;
|
|
private LinearLayout helpcenterLayout;
|
|
private View loadingView;
|
|
private View retryView;
|
|
private FragmentTransactionListener transactionListener;
|
|
|
|
public void setFragmentTransactionListener(FragmentTransactionListener fragmentTransactionListener) {
|
|
this.transactionListener = fragmentTransactionListener;
|
|
}
|
|
|
|
public static HSHelpcenterFragment newInstance(Bundle bundle) {
|
|
HSHelpcenterFragment hSHelpcenterFragment = new HSHelpcenterFragment();
|
|
hSHelpcenterFragment.setArguments(bundle);
|
|
return hSHelpcenterFragment;
|
|
}
|
|
|
|
@Override // androidx.fragment.app.Fragment
|
|
public void onCreate(Bundle bundle) {
|
|
super.onCreate(bundle);
|
|
}
|
|
|
|
@Override // androidx.fragment.app.Fragment
|
|
public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
|
|
HSLogger.d(TAG, "onCreateView - " + hashCode());
|
|
return layoutInflater.inflate(R$layout.hs__helpcenter_layout, viewGroup, false);
|
|
}
|
|
|
|
@Override // androidx.fragment.app.Fragment
|
|
public void onViewCreated(@NonNull View view, @Nullable Bundle bundle) {
|
|
super.onViewCreated(view, bundle);
|
|
HSLogger.d(TAG, "onViewCreated - " + hashCode());
|
|
Bundle arguments = getArguments();
|
|
initViews(view);
|
|
startHelpcenter(arguments);
|
|
}
|
|
|
|
private void initViews(View view) {
|
|
this.helpCenterWebview = (HSWebView) view.findViewById(R$id.hs__helpcenter_view);
|
|
this.loadingView = view.findViewById(R$id.hs__loading_view);
|
|
((ImageView) view.findViewById(R$id.hs__chat_image)).setVisibility(8);
|
|
this.retryView = view.findViewById(R$id.hs__retry_view);
|
|
this.helpcenterLayout = (LinearLayout) view.findViewById(R$id.hs__helpcenter_layout);
|
|
view.findViewById(R$id.hs__retry_view_close_btn).setOnClickListener(this);
|
|
view.findViewById(R$id.hs__loading_view_close_btn).setOnClickListener(this);
|
|
view.findViewById(R$id.hs__retry_button).setOnClickListener(this);
|
|
}
|
|
|
|
private void startHelpcenter(Bundle bundle) {
|
|
if (bundle == null) {
|
|
HSLogger.e(TAG, "Bundle received in Helpcenter fragment is null.");
|
|
onHelpcenterError();
|
|
return;
|
|
}
|
|
String sourceCode = getSourceCode(bundle);
|
|
if (Utils.isEmpty(sourceCode)) {
|
|
HSLogger.e(TAG, "Error in reading the source code from assets folder.");
|
|
onHelpcenterError();
|
|
} else {
|
|
showLoading();
|
|
initWebviewWithHelpcenter(sourceCode);
|
|
}
|
|
}
|
|
|
|
private String getSourceCode(Bundle bundle) {
|
|
ValuePair helpcenterModes = getHelpcenterModes(bundle);
|
|
return HSContext.getInstance().getJsGenerator().getHelpcenterEmbeddedCodeString(getContext(), (String) helpcenterModes.first, (String) helpcenterModes.second, isWebchatInStackAlready());
|
|
}
|
|
|
|
private ValuePair getHelpcenterModes(Bundle bundle) {
|
|
String string;
|
|
String string2 = bundle.getString("HELPCENTER_MODE");
|
|
string2.hashCode();
|
|
String str = "";
|
|
if (string2.equals("FAQ_SECTION")) {
|
|
string = bundle.getString("FAQ_SECTION_ID");
|
|
} else if (string2.equals("SINGLE_FAQ")) {
|
|
str = bundle.getString("SINGLE_FAQ_PUBLISH_ID");
|
|
string = "";
|
|
} else {
|
|
string = "";
|
|
}
|
|
return new ValuePair(str, string);
|
|
}
|
|
|
|
private void initWebviewWithHelpcenter(String str) {
|
|
HSLogger.d(TAG, "Webview is launched");
|
|
HSContext hSContext = HSContext.getInstance();
|
|
HelpshiftResourceCacheManager helpcenterResourceCacheManager = hSContext.getHelpcenterResourceCacheManager();
|
|
HSHelpcenterEventsHandler hSHelpcenterEventsHandler = new HSHelpcenterEventsHandler(hSContext.getConfigManager(), hSContext.getHsThreadingService(), helpcenterResourceCacheManager);
|
|
this.eventsHandler = hSHelpcenterEventsHandler;
|
|
hSHelpcenterEventsHandler.setHelpcenterUiCallback(this);
|
|
this.helpCenterWebview.setWebViewClient(new HSHelpcenterWebViewClient(helpcenterResourceCacheManager));
|
|
this.helpCenterWebview.setWebChromeClient(new HSHelpcenterWebChromeClient(this.eventsHandler));
|
|
this.helpCenterWebview.addJavascriptInterface(new HelpcenterToNativeBridge(this.eventsHandler), "HCInterface");
|
|
this.helpCenterWebview.loadDataWithBaseURL("https://localhost", str, "text/html", nb.N, null);
|
|
}
|
|
|
|
public boolean canHelpcenterWebviewGoBack() {
|
|
return this.helpCenterWebview.canGoBack();
|
|
}
|
|
|
|
public void helpcenterWebviewGoBack() {
|
|
callHelpcenterApi(HSJSGenerator.backBtnClickJs);
|
|
this.helpCenterWebview.goBack();
|
|
}
|
|
|
|
@Override // androidx.fragment.app.Fragment
|
|
public void onStart() {
|
|
super.onStart();
|
|
HSLogger.d(TAG, "onStart - " + hashCode());
|
|
HSContext.getInstance().getNotificationManager().setNotificationReceivedCallback(this);
|
|
sendLifecycleEventToHelpCenter(false);
|
|
}
|
|
|
|
@Override // androidx.fragment.app.Fragment
|
|
public void onStop() {
|
|
super.onStop();
|
|
sendLifecycleEventToHelpCenter(true);
|
|
}
|
|
|
|
@Override // androidx.fragment.app.Fragment
|
|
public void onDestroy() {
|
|
super.onDestroy();
|
|
HSLogger.d(TAG, "onDestroy - " + hashCode());
|
|
HSContext.getInstance().getNotificationManager().setNotificationReceivedCallback(null);
|
|
HSHelpcenterEventsHandler hSHelpcenterEventsHandler = this.eventsHandler;
|
|
if (hSHelpcenterEventsHandler != null) {
|
|
hSHelpcenterEventsHandler.setHelpcenterUiCallback(null);
|
|
}
|
|
HSContext.getInstance().setIsWebchatOpenedFromHelpcenter(false);
|
|
this.helpcenterLayout.removeView(this.helpCenterWebview);
|
|
this.helpCenterWebview.destroyCustomWebview();
|
|
this.helpCenterWebview = null;
|
|
}
|
|
|
|
@Override // com.helpshift.faq.HelpcenterToUiCallback
|
|
public void closeHelpcenter() {
|
|
FragmentTransactionListener fragmentTransactionListener = this.transactionListener;
|
|
if (fragmentTransactionListener != null) {
|
|
fragmentTransactionListener.closeHelpcenter();
|
|
}
|
|
}
|
|
|
|
@Override // com.helpshift.faq.HelpcenterToUiCallback
|
|
public void openWebchat() {
|
|
if (this.transactionListener != null) {
|
|
HSContext.getInstance().setIsWebchatOpenedFromHelpcenter(true);
|
|
this.transactionListener.openWebchat();
|
|
}
|
|
}
|
|
|
|
@Override // com.helpshift.faq.HelpcenterToUiCallback
|
|
public void onHelpcenterLoaded() {
|
|
showHelpcenter();
|
|
}
|
|
|
|
@Override // com.helpshift.faq.HelpcenterToUiCallback
|
|
public void setNativeUiColors(String str) {
|
|
FragmentTransactionListener fragmentTransactionListener = this.transactionListener;
|
|
if (fragmentTransactionListener != null) {
|
|
fragmentTransactionListener.changeStatusBarColor(str);
|
|
}
|
|
}
|
|
|
|
@Override // com.helpshift.faq.HelpcenterToUiCallback
|
|
public void addWebviewToUi(WebView webView) {
|
|
this.helpcenterLayout.addView(webView);
|
|
}
|
|
|
|
@Override // com.helpshift.faq.HelpcenterToUiCallback
|
|
public void sendEventToSystemApp(Intent intent) {
|
|
try {
|
|
startActivity(intent);
|
|
} catch (Exception e) {
|
|
HSLogger.e(TAG, "Unable to resolve the activity for this intent", e);
|
|
}
|
|
}
|
|
|
|
@Override // com.helpshift.faq.HelpcenterToUiCallback
|
|
public void showNotificationBadgeOnHCLoad() {
|
|
onNotificationReceived();
|
|
}
|
|
|
|
@Override // com.helpshift.faq.HelpcenterToUiCallback
|
|
public void getWebchatData() {
|
|
setWebChatLocalStorageData();
|
|
}
|
|
|
|
@Override // android.view.View.OnClickListener
|
|
public void onClick(View view) {
|
|
int id = view.getId();
|
|
if (id == R$id.hs__loading_view_close_btn || id == R$id.hs__retry_view_close_btn) {
|
|
closeHelpcenter();
|
|
} else if (id == R$id.hs__retry_button) {
|
|
startHelpcenter(getArguments());
|
|
}
|
|
}
|
|
|
|
public void sendLifecycleEventToHelpCenter(boolean z) {
|
|
if (this.loadingView.getVisibility() != 0) {
|
|
callHelpcenterApi(HSJSGenerator.sendForegroundEvent.replace("%foreground", "" + z));
|
|
}
|
|
}
|
|
|
|
private void showLoading() {
|
|
ViewUtil.setVisibility(this.loadingView, true);
|
|
ViewUtil.setVisibility(this.retryView, false);
|
|
}
|
|
|
|
private void showHelpcenter() {
|
|
ViewUtil.setVisibility(this.loadingView, false);
|
|
ViewUtil.setVisibility(this.retryView, false);
|
|
}
|
|
|
|
private void showError() {
|
|
ViewUtil.setVisibility(this.retryView, true);
|
|
ViewUtil.setVisibility(this.loadingView, false);
|
|
}
|
|
|
|
@Override // com.helpshift.faq.HelpcenterToUiCallback
|
|
public void onHelpcenterError() {
|
|
showError();
|
|
}
|
|
|
|
@Override // com.helpshift.notification.NotificationReceivedCallback
|
|
public void onNotificationReceived() {
|
|
UserManager userManager = HSContext.getInstance().getUserManager();
|
|
int unreadNotificationCount = userManager.getUnreadNotificationCount();
|
|
int pushUnreadNotificationCount = userManager.getPushUnreadNotificationCount();
|
|
if (unreadNotificationCount > 0 || pushUnreadNotificationCount > 0) {
|
|
callHelpcenterApi(HSJSGenerator.showNotificationBadgeJS.replace("%count", String.valueOf(Math.max(unreadNotificationCount, pushUnreadNotificationCount))));
|
|
}
|
|
}
|
|
|
|
public void setWebChatLocalStorageData() {
|
|
callHelpcenterApi(HSJSGenerator.sendWebchatData.replace("%data", HSContext.getInstance().getConfigManager().getLocalStorageData()));
|
|
}
|
|
|
|
public void reloadIframe(Bundle bundle) {
|
|
ValuePair helpcenterModes = getHelpcenterModes(bundle);
|
|
callHelpcenterApi(HSJSGenerator.reloadIframeJS.replace("%helpshiftConfig", HSContext.getInstance().getConfigManager().getHelpcenterConfigJs((String) helpcenterModes.first, (String) helpcenterModes.second, isWebchatInStackAlready())));
|
|
}
|
|
|
|
public void callHelpcenterApi(final String str) {
|
|
HSContext.getInstance().getHsThreadingService().runOnUIThread(new Runnable() { // from class: com.helpshift.faq.HSHelpcenterFragment.1
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
if (HSHelpcenterFragment.this.helpCenterWebview == null) {
|
|
return;
|
|
}
|
|
ViewUtil.callJavascriptCode(HSHelpcenterFragment.this.helpCenterWebview, str, null);
|
|
}
|
|
});
|
|
}
|
|
|
|
private boolean isWebchatInStackAlready() {
|
|
FragmentActivity activity = getActivity();
|
|
if (activity instanceof HSMainActivity) {
|
|
return ((HSMainActivity) activity).isWebchatFragmentInStack();
|
|
}
|
|
return false;
|
|
}
|
|
}
|