Skip to content

Commit

Permalink
[android] Bugfix: Fixed missing wikipedia links:
Browse files Browse the repository at this point in the history
Fixes organicmaps#4912

Signed-off-by: ddpasa <[email protected]>
  • Loading branch information
ddpasa authored and biodranik committed Apr 11, 2023
1 parent 0c3da17 commit 32f02d8
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -476,9 +476,16 @@ private void updateBookmarkView()
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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
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;
Expand All @@ -17,11 +18,13 @@
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;

Expand Down Expand Up @@ -49,6 +52,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat

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);
Expand Down Expand Up @@ -80,12 +84,22 @@ private Spanned getShortDescription()

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) -> {
Expand Down

0 comments on commit 32f02d8

Please sign in to comment.