Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/src/main/assets/kommunicate-settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -187,5 +187,6 @@
"isVideoCompressionEnabled": false,
"minimumCompressionThresholdForVideosInMB": 10,
"hideAttachmentOptionsWithBots": false,
"showBackButtonOnFaqPage": true
"showBackButtonOnFaqPage": false,
"showStatusBarOnFaqPage": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ public class CustomizationSettings extends JsonMarker {
private boolean javaScriptEnabled = true;
private boolean hideChatInHelpcenter = true;
private boolean showBackButtonOnFaqPage = true;
private boolean showStatusBarOnFaqPage = true;
private boolean checkboxAsMultipleButton = false;
private String staticTopMessage = "";
private String staticTopIcon = "";
Expand Down Expand Up @@ -809,6 +810,10 @@ public boolean isShowBackButtonOnFaqPage() {
return showBackButtonOnFaqPage;
}

public boolean isShowStatusBarOnFaqPage() {
return showStatusBarOnFaqPage;
}

public boolean isToolbarTitleCenterAligned() {
return toolbarTitleCenterAligned;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,13 @@ public void createRichMessage(boolean isMessageProcessed) {
headerText.setVisibility(View.GONE);
}

if (!TextUtils.isEmpty(payload.getHeaderImgSrc())) {
String headerImageUrl = !TextUtils.isEmpty(payload.getHeaderImgSrc())
? payload.getHeaderImgSrc()
: payload.getHeaderImageUrl();

if (!TextUtils.isEmpty(headerImageUrl)) {
headerImage.setVisibility(View.VISIBLE);
Glide.with(context).load(KmAppSettingPreferences.appendSasToken(payload.getHeaderImgSrc())).into(headerImage);
Glide.with(context).load(KmAppSettingPreferences.appendSasToken(headerImageUrl)).into(headerImage);
} else {
headerImage.setVisibility(View.GONE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import android.text.TextUtils;
import android.view.View;
import android.view.WindowManager;
import android.webkit.CookieManager;
import android.webkit.URLUtil;
import android.webkit.WebResourceRequest;
Expand All @@ -27,6 +28,10 @@
import android.widget.ProgressBar;
import android.widget.Toast;

import androidx.core.view.WindowCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.core.view.WindowInsetsControllerCompat;

import io.kommunicate.ui.CustomizationSettings;
import io.kommunicate.ui.R;
import io.kommunicate.ui.activities.KmBaseActivity;
Expand All @@ -53,6 +58,7 @@ public class KmWebViewActivity extends KmBaseActivity {
Toolbar toolbar;
private Map<String, String> txnData;
private boolean isPaymentRequest = false;
private boolean isHelpCenterFaqPage = false;
CustomizationSettings customizationSettings;
private ProgressBar loadingProgressBar;
private static final String JS_INTERFACE_NAME = "AlWebViewScreen";
Expand All @@ -61,10 +67,10 @@ public class KmWebViewActivity extends KmBaseActivity {
public static final String DEFAULT_REQUEST_TYPE = "application/x-www-form-urlencoded";
public static final String REQUEST_TYPE_JSON = "json";
public static final String Al_WEB_VIEW_BUNDLE = "alWebViewBundle";
private static final String BODY_ONLOAD = "<body onload='form1.submit()'>";
private static final String BODY_ONLOAD = "<body onload=\'form1.submit()\'>";
private static final String HTML_HEAD_HEAD = "<html><head></head>";
private static final String FORMID_ACTION = "<form id='form1' action='%s' method='%s'>";
private static final String INPUT_NAME_HIDDEN = "<input name='%s' type='hidden' value='%s' />";
private static final String FORMID_ACTION = "<form id=\'form1\' action='%s\' method=\'%s\'>";
private static final String INPUT_NAME_HIDDEN = "<input name='%s\' type=\'hidden\' value='%s\' />";
private static final String FORM_BODY_HTML = "</form></body></html>";
private static final String text_html = "text/html";

Expand Down Expand Up @@ -106,6 +112,11 @@ protected void onCreate(Bundle savedInstanceState) {
String helpCenterUrl = alWebViewBundle.getString(KmConstants.KM_HELPCENTER_URL);

if (!TextUtils.isEmpty(helpCenterUrl)) {
isHelpCenterFaqPage = true;
boolean showFaqStatusBar = customizationSettings.isShowStatusBarOnFaqPage();
boolean showFaqToolbar = customizationSettings.isShowBackButtonOnFaqPage();
applyFaqHeaderVisibility(showFaqToolbar);
applyFaqStatusBarVisibility(showFaqStatusBar);
loadUrl(helpCenterUrl);
webView.getSettings().setBuiltInZoomControls(false);
webView.getSettings().setDisplayZoomControls(false);
Expand Down Expand Up @@ -143,6 +154,29 @@ protected void onCreate(Bundle savedInstanceState) {
setupInsets();
}

private void applyFaqHeaderVisibility(boolean showFaqToolbar) {
if (showFaqToolbar || getSupportActionBar() == null) {
return;
}
getSupportActionBar().hide();
toolbar.setVisibility(View.GONE);
}

private void applyFaqStatusBarVisibility(boolean showFaqStatusBar) {
WindowInsetsControllerCompat controller = WindowCompat.getInsetsController(getWindow(), getWindow().getDecorView());
if (controller == null) {
return;
}
if (showFaqStatusBar) {
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
controller.show(WindowInsetsCompat.Type.statusBars());
} else {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
controller.setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE);
controller.hide(WindowInsetsCompat.Type.statusBars());
}
}

private void setupDownloadListener(WebView webView) {
webView.setDownloadListener((url, userAgent, contentDisposition, mimetype, contentLength) -> {
try {
Expand Down Expand Up @@ -174,6 +208,9 @@ private void setupDownloadListener(WebView webView) {
}

private void setupInsets() {
if (isHelpCenterFaqPage && !customizationSettings.isShowStatusBarOnFaqPage()) {
return;
}
InsetHelper.configureSystemInsets(
toolbar,
-1,
Expand All @@ -188,7 +225,7 @@ public void webViewClientPost(WebView webView, String url,

sb.append(HTML_HEAD_HEAD);
sb.append(BODY_ONLOAD);
sb.append(String.format(FORMID_ACTION));
sb.append(String.format(FORMID_ACTION, url, "post"));

for (Map.Entry<String, String> item : postData) {
sb.append(String.format(INPUT_NAME_HIDDEN, item.getKey(), item.getValue()));
Expand Down Expand Up @@ -223,6 +260,22 @@ public void onClick(DialogInterface dialog, int which) {
}
}

@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus && isHelpCenterFaqPage && !customizationSettings.isShowStatusBarOnFaqPage()) {
applyFaqStatusBarVisibility(false);
}
}

@Override
protected void onResume() {
super.onResume();
if (isHelpCenterFaqPage && !customizationSettings.isShowStatusBarOnFaqPage()) {
applyFaqStatusBarVisibility(false);
}
}

public void loadUrl(String url) {
if (!TextUtils.isEmpty(url)) {
webView.getSettings().setJavaScriptEnabled(customizationSettings.isJavaScriptEnabled());
Expand Down
Loading