diff --git a/android/src/app/organicmaps/widget/placepage/PlacePageView.java b/android/src/app/organicmaps/widget/placepage/PlacePageView.java index d4b4bf8437..072d181baf 100644 --- a/android/src/app/organicmaps/widget/placepage/PlacePageView.java +++ b/android/src/app/organicmaps/widget/placepage/PlacePageView.java @@ -476,9 +476,16 @@ public class PlacePageView extends Fragment implements View.OnClickListener, updateViewFragment(PlacePageBookmarkFragment.class, BOOKMARK_FRAGMENT_TAG, R.id.place_page_bookmark_fragment, mMapObject.getMapObjectType() == MapObject.BOOKMARK); } + private boolean hasWikipediaEntry() + { + final String wikipediaLink = mMapObject.getMetadata(Metadata.MetadataType.FMD_WIKIPEDIA); + final String description = mMapObject.getDescription(); + return !TextUtils.isEmpty(wikipediaLink) || !TextUtils.isEmpty(description); + } + private void updateWikipediaView() { - updateViewFragment(PlacePageWikipediaFragment.class, WIKIPEDIA_FRAGMENT_TAG, R.id.place_page_wikipedia_fragment, !TextUtils.isEmpty(mMapObject.getDescription())); + updateViewFragment(PlacePageWikipediaFragment.class, WIKIPEDIA_FRAGMENT_TAG, R.id.place_page_wikipedia_fragment, hasWikipediaEntry()); } private void setTextAndColorizeSubtitle() diff --git a/android/src/app/organicmaps/widget/placepage/PlacePageWikipediaFragment.java b/android/src/app/organicmaps/widget/placepage/PlacePageWikipediaFragment.java index 45694ed7a7..f1d7a1edba 100644 --- a/android/src/app/organicmaps/widget/placepage/PlacePageWikipediaFragment.java +++ b/android/src/app/organicmaps/widget/placepage/PlacePageWikipediaFragment.java @@ -3,6 +3,7 @@ package app.organicmaps.widget.placepage; import android.os.Bundle; import android.text.SpannableStringBuilder; import android.text.Spanned; +import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -17,11 +18,13 @@ import app.organicmaps.R; import app.organicmaps.bookmarks.data.MapObject; import app.organicmaps.bookmarks.data.Metadata; import app.organicmaps.util.Utils; +import app.organicmaps.util.UiUtils; public class PlacePageWikipediaFragment extends Fragment implements Observer { private View mFrame; private View mWiki; + private View mPlaceDescriptionViewContainer; private TextView mPlaceDescriptionView; @@ -49,6 +52,7 @@ public class PlacePageWikipediaFragment extends Fragment implements Observer showDescriptionScreen()); mPlaceDescriptionView.setOnClickListener(v -> showDescriptionScreen()); mWiki = view.findViewById(R.id.ll__place_wiki); @@ -80,12 +84,22 @@ public class PlacePageWikipediaFragment extends Fragment implements Observer { - PlacePageUtils.copyToClipboard(requireContext(), mFrame, mPlaceDescriptionView.getText() - .toString()); - return true; - }); + + // There are two sources of wiki info in OrganicMaps: + // wiki links from OpenStreetMaps, and wiki pages explicitly parsed into OrganicMaps. + // This part hides the DescriptionView if the wiki page has not been parsed. + if (TextUtils.isEmpty(mMapObject.getDescription())) + UiUtils.hide(mPlaceDescriptionViewContainer); + else + { + mPlaceDescriptionView.setText(getShortDescription()); + final String descriptionString = mPlaceDescriptionView.getText().toString(); + mPlaceDescriptionView.setOnLongClickListener((v) -> { + PlacePageUtils.copyToClipboard(requireContext(), mFrame, descriptionString); + return true; + }); + } + final String wikipediaLink = mMapObject.getMetadata(Metadata.MetadataType.FMD_WIKIPEDIA); mWiki.setOnClickListener((v) -> Utils.openUrl(requireContext(), wikipediaLink)); mWiki.setOnLongClickListener((v) -> {