Files
rr3-apk/decompiled/sources/com/helpshift/chat/HSChatToNativeBridge.java
Daniel Elliott f9d20bb3fc Add decompiled APK source code (JADX)
- 28,932 files
- Full Java source code
- Smali files
- Resources

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-02-18 14:52:23 -08:00

158 lines
5.1 KiB
Java

package com.helpshift.chat;
import android.webkit.JavascriptInterface;
import com.helpshift.log.HSLogger;
import com.helpshift.util.Utils;
import com.tapjoy.TJAdUnitConstants;
import java.util.Iterator;
import org.json.JSONException;
import org.json.JSONObject;
/* loaded from: classes3.dex */
public class HSChatToNativeBridge {
public final HSEventProxy delegate;
public final HSChatEventsHandler eventsHandler;
public boolean isWebSdkConfigLoaded;
public HSChatToNativeBridge(HSEventProxy hSEventProxy, HSChatEventsHandler hSChatEventsHandler) {
this.delegate = hSEventProxy;
this.eventsHandler = hSChatEventsHandler;
}
@JavascriptInterface
public void sendEvent(String str) {
HSLogger.d("ChatNativeBridge", "Received event from webview.");
if (this.delegate == null || Utils.isEmpty(str)) {
return;
}
try {
JSONObject jSONObject = new JSONObject(str);
Iterator<String> keys = jSONObject.keys();
while (keys.hasNext()) {
String next = keys.next();
this.delegate.sendEvent(next, Utils.jsonStringToMap(jSONObject.optString(next, "")));
}
} catch (JSONException e) {
HSLogger.e("ChatNativeBridge", "Error in sending public event", e);
}
}
@JavascriptInterface
public void widgetToggle(String str) {
HSLogger.d("ChatNativeBridge", "webchat widget toggle: " + str);
if (Utils.isEmpty(str) || !this.isWebSdkConfigLoaded) {
return;
}
try {
if (new JSONObject(str).optBoolean(TJAdUnitConstants.String.VISIBLE, false)) {
this.eventsHandler.onWebchatLoaded();
} else {
this.eventsHandler.onWebchatClosed();
}
} catch (JSONException e) {
HSLogger.e("ChatNativeBridge", "Error in closing the webchat", e);
}
}
@JavascriptInterface
public void onWebSdkConfigLoad() {
HSLogger.d("ChatNativeBridge", "Received event when web sdk config loaded");
if (this.isWebSdkConfigLoaded) {
return;
}
this.isWebSdkConfigLoaded = true;
this.eventsHandler.onWebchatLoaded();
}
@JavascriptInterface
public void setIssueExistsFlag(String str) {
HSLogger.d("ChatNativeBridge", "Received event to set the issue exist as -" + str);
this.eventsHandler.setIssueExistsForUser(str);
}
@JavascriptInterface
public void setLocalStorage(String str) {
HSLogger.d("ChatNativeBridge", "Received event to set data in local store from webview.");
this.eventsHandler.onSetLocalStorage(str);
}
@JavascriptInterface
public void removeLocalStorage(String str) {
HSLogger.d("ChatNativeBridge", "Received event to remove data from local store from webview.");
this.eventsHandler.onRemoveLocalStorage(str);
}
@JavascriptInterface
public void getHelpcenterData() {
HSLogger.d("ChatNativeBridge", "Received event to get Aditional info of HC from WC from webview.");
this.eventsHandler.getHelpcenterData();
}
@JavascriptInterface
public void onWebchatError() {
HSLogger.d("ChatNativeBridge", "Received error from webview.");
this.eventsHandler.onWebchatError();
}
@JavascriptInterface
public void sendPushTokenSyncRequestData(String str) {
this.eventsHandler.onReceivePushTokenSyncRequestData(str);
}
@JavascriptInterface
public void onUIConfigChange(String str) {
this.eventsHandler.onUiConfigChange(str);
}
@JavascriptInterface
public void sendUserAuthFailureEvent(String str) {
if (this.delegate == null || Utils.isEmpty(str)) {
return;
}
String str2 = "Authentication Failure";
try {
JSONObject jSONObject = new JSONObject(str);
if (jSONObject.has("message")) {
String string = jSONObject.getString("message");
if (!Utils.isEmpty(string.trim())) {
str2 = string;
}
}
} catch (Exception unused) {
HSLogger.e("ChatNativeBridge", "Error in reading auth failure event ");
}
this.eventsHandler.onUserAuthenticationFailure();
this.delegate.sendAuthFailureEvent(str2);
}
@JavascriptInterface
public void onRemoveAnonymousUser() {
this.eventsHandler.onRemoveAnonymousUser();
}
@JavascriptInterface
public void setPollingStatus(String str) {
this.eventsHandler.setPollingStatus(str);
}
@JavascriptInterface
public void setGenericSdkData(String str) {
this.eventsHandler.setGenericSdkData(str);
}
@JavascriptInterface
public void sdkxMigrationLogSynced(boolean z) {
this.eventsHandler.sdkxMigrationLogSynced(z);
}
@JavascriptInterface
public void requestConversationMetadata(String str) {
this.eventsHandler.requestConversationMetadata(str);
}
@JavascriptInterface
public void webchatJsFileLoaded() {
this.eventsHandler.webchatJsFileLoaded();
}
}