From f501cb1c044b9f224f8414caf231910663d5bedc Mon Sep 17 00:00:00 2001 From: Alexey Osminin Date: Wed, 9 Dec 2020 19:13:38 +0300 Subject: [PATCH] [android] fix for broken content in webview on PP --- .../bookmarks/description/BookmarksDescriptionFragment.java | 5 ++++- .../com/mapswithme/maps/widget/placepage/PlacePageView.java | 4 +++- android/src/com/mapswithme/util/Utils.java | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/android/src/com/mapswithme/maps/bookmarks/description/BookmarksDescriptionFragment.java b/android/src/com/mapswithme/maps/bookmarks/description/BookmarksDescriptionFragment.java index 929cc166a3..8f3939c0e3 100644 --- a/android/src/com/mapswithme/maps/bookmarks/description/BookmarksDescriptionFragment.java +++ b/android/src/com/mapswithme/maps/bookmarks/description/BookmarksDescriptionFragment.java @@ -1,6 +1,7 @@ package com.mapswithme.maps.bookmarks.description; import android.os.Bundle; +import android.util.Base64; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -55,6 +56,8 @@ public class BookmarksDescriptionFragment extends BaseMwmFragment TextView btnDescription = view.findViewById(R.id.btn_description); UiUtils.hide(btnDescription); WebView webView = view.findViewById(R.id.webview); - webView.loadData(mBookmarkCategory.getDescription(), Utils.TEXT_HTML, Utils.UTF_8); + String base64version = Base64.encodeToString(mBookmarkCategory.getDescription().getBytes(), + Base64.DEFAULT); + webView.loadData(base64version, Utils.TEXT_HTML, Utils.BASE_64); } } diff --git a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java index 1d396312b0..2eeb5877d2 100644 --- a/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java +++ b/android/src/com/mapswithme/maps/widget/placepage/PlacePageView.java @@ -16,6 +16,7 @@ import android.text.TextUtils; import android.text.style.ForegroundColorSpan; import android.text.util.Linkify; import android.util.AttributeSet; +import android.util.Base64; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; @@ -1621,7 +1622,8 @@ public class PlacePageView extends NestedScrollViewClickFixed if (StringUtils.nativeIsHtml(notes)) { - mWvBookmarkNote.loadData(notes, "text/html; charset=utf-8", null); + String base64version = Base64.encodeToString(notes.getBytes(), Base64.DEFAULT); + mWvBookmarkNote.loadData(base64version, Utils.TEXT_HTML, Utils.BASE_64); UiUtils.show(mWvBookmarkNote); UiUtils.hide(mTvBookmarkNote); } diff --git a/android/src/com/mapswithme/util/Utils.java b/android/src/com/mapswithme/util/Utils.java index be14d981e1..3ab6b202e5 100644 --- a/android/src/com/mapswithme/util/Utils.java +++ b/android/src/com/mapswithme/util/Utils.java @@ -61,6 +61,7 @@ public class Utils @StringRes public static final int INVALID_ID = 0; public static final String UTF_8 = "utf-8"; + public static final String BASE_64 = "base64"; public static final String TEXT_HTML = "text/html;"; private static final Logger LOGGER = LoggerFactory.INSTANCE.getLogger(LoggerFactory.Type.MISC); private static final String TAG = "Utils";