[android] Bugfix: Fixed missing wikipedia links:

Fixes https://github.com/organicmaps/organicmaps/issues/4912

Signed-off-by: ddpasa <emailformygitacc@proton.me>
This commit is contained in:
ddpasa 2023-04-09 17:28:33 +02:00 committed by Alexander Borsuk
parent 0c3da174bf
commit 32f02d8753
2 changed files with 28 additions and 7 deletions

View file

@ -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()

View file

@ -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<MapObject>
{
private View mFrame;
private View mWiki;
private View mPlaceDescriptionViewContainer;
private TextView mPlaceDescriptionView;
@ -49,6 +52,7 @@ public class PlacePageWikipediaFragment extends Fragment implements Observer<Map
mPlaceDescriptionView = view.findViewById(R.id.poi_description);
View placeDescriptionMoreBtn = view.findViewById(R.id.more_btn);
mPlaceDescriptionViewContainer = view.findViewById(R.id.poi_description_container);
placeDescriptionMoreBtn.setOnClickListener(v -> showDescriptionScreen());
mPlaceDescriptionView.setOnClickListener(v -> showDescriptionScreen());
mWiki = view.findViewById(R.id.ll__place_wiki);
@ -80,12 +84,22 @@ public class PlacePageWikipediaFragment extends Fragment implements Observer<Map
private void updateViews()
{
mPlaceDescriptionView.setText(getShortDescription());
mPlaceDescriptionView.setOnLongClickListener((v) -> {
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) -> {