Skip to content

Commit

Permalink
Add website:menu tag to Place Page
Browse files Browse the repository at this point in the history
Signed-off-by: Arthur-GYT <[email protected]>
  • Loading branch information
Arthur-GYT committed May 5, 2024
1 parent d63c165 commit 1ce3428
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,9 @@ public String getMetadata(Metadata.MetadataType type)
}

@NonNull
public String getWebsiteUrl(boolean strip)
public String getWebsiteUrl(boolean strip, @NonNull Metadata.MetadataType type)
{
final String website = getMetadata(Metadata.MetadataType.FMD_WEBSITE);
final String website = getMetadata(type);
final int len = website.length();
if (strip && len > 1)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ public enum MetadataType
FMD_CAPACITY(42),
FMD_WHEELCHAIR(43),
FMD_LOCAL_REF(44),
FMD_DRIVE_THROUGH(45);
FMD_DRIVE_THROUGH(45),
FMD_WEBSITE_MENU(46);
private final int mMetaType;

MetadataType(int metadataType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public class PlacePageLinksFragment extends Fragment implements Observer<MapObje
private View mKayak;
private View mWebsite;
private TextView mTvWebsite;
private View mWebsiteMenu;
private TextView mTvWebsiteMenu;
private View mEmail;
private TextView mTvEmail;
private View mWikimedia;
Expand Down Expand Up @@ -76,7 +78,9 @@ private String getLink(@NonNull Metadata.MetadataType type)
case FMD_EXTERNAL_URI:
return mMapObject.getKayakUrl();
case FMD_WEBSITE:
return mMapObject.getWebsiteUrl(false /* strip */);
return mMapObject.getWebsiteUrl(false /* strip */, Metadata.MetadataType.FMD_WEBSITE);
case FMD_WEBSITE_MENU:
return mMapObject.getWebsiteUrl(false /* strip */, Metadata.MetadataType.FMD_WEBSITE_MENU);
case FMD_CONTACT_FACEBOOK:
case FMD_CONTACT_INSTAGRAM:
case FMD_CONTACT_TWITTER:
Expand Down Expand Up @@ -123,6 +127,11 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
mWebsite.setOnClickListener((v) -> openUrl(Metadata.MetadataType.FMD_WEBSITE));
mWebsite.setOnLongClickListener((v) -> copyUrl(mWebsite, Metadata.MetadataType.FMD_WEBSITE));

mWebsiteMenu = mFrame.findViewById(R.id.ll__place_website_menu);
mTvWebsiteMenu = mFrame.findViewById(R.id.tv__place_website_menu);
mWebsiteMenu.setOnClickListener((v) -> openUrl(Metadata.MetadataType.FMD_WEBSITE_MENU));
mWebsiteMenu.setOnLongClickListener((v) -> copyUrl(mWebsiteMenu, Metadata.MetadataType.FMD_WEBSITE_MENU));

mEmail = mFrame.findViewById(R.id.ll__place_email);
mTvEmail = mFrame.findViewById(R.id.tv__place_email);
mEmail.setOnClickListener(v -> {
Expand Down Expand Up @@ -178,8 +187,11 @@ private boolean copyUrl(View view, Metadata.MetadataType type)
final List<String> items = new ArrayList<>();
items.add(url);

final String title = type == Metadata.MetadataType.FMD_WEBSITE ?
mMapObject.getWebsiteUrl(false /* strip */) : mMapObject.getMetadata(type);
final String title = switch (type){
case FMD_WEBSITE -> mMapObject.getWebsiteUrl(false /* strip */, Metadata.MetadataType.FMD_WEBSITE);
case FMD_WEBSITE_MENU -> mMapObject.getWebsiteUrl(false /* strip */, Metadata.MetadataType.FMD_WEBSITE_MENU);
default -> mMapObject.getMetadata(type);
};
// Add user names for social media if available
if (!TextUtils.isEmpty(title) && !title.equals(url) && !title.contains("/"))
items.add(title);
Expand All @@ -194,7 +206,8 @@ private boolean copyUrl(View view, Metadata.MetadataType type)
private void refreshLinks()
{
UiUtils.showIf(!TextUtils.isEmpty(mMapObject.getKayakUrl()), mKayak);
refreshMetadataOrHide(mMapObject.getWebsiteUrl(true /* strip */), mWebsite, mTvWebsite);
refreshMetadataOrHide(mMapObject.getWebsiteUrl(true /* strip */, Metadata.MetadataType.FMD_WEBSITE), mWebsite, mTvWebsite);
refreshMetadataOrHide(mMapObject.getWebsiteUrl(true /* strip */, Metadata.MetadataType.FMD_WEBSITE_MENU), mWebsiteMenu, mTvWebsiteMenu);

String wikimedia_commons = mMapObject.getMetadata(Metadata.MetadataType.FMD_WIKIMEDIA_COMMONS);
String wikimedia_commons_text = TextUtils.isEmpty(wikimedia_commons) ? "" : getResources().getString(R.string.wikimedia_commons);
Expand Down
9 changes: 9 additions & 0 deletions android/app/src/main/res/drawable/ic_website_menu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:pathData="m175,840 l-56,-56 410,-410q-18,-42 -5,-95t57,-95q53,-53 118,-62t106,32q41,41 32,106t-62,118q-42,44 -95,57t-95,-5l-50,50 304,304 -56,56 -304,-302 -304,302ZM293,498L173,378q-54,-54 -54,-129t54,-129l248,250 -128,128Z"
android:fillColor="#e8eaed"/>
</vector>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="@layout/place_page_website" />
<include layout="@layout/place_page_website_menu" />
<include layout="@layout/place_page_email" />
<include layout="@layout/place_page_facebook" />
<include layout="@layout/place_page_instagram" />
Expand Down
24 changes: 24 additions & 0 deletions android/app/src/main/res/layout/place_page_website_menu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/ll__place_website_menu"
style="@style/PlacePageItemFrame"
android:tag="website"
tools:background="#20FF0000"
tools:visibility="visible">

<ImageView
android:id="@+id/iv__place_website_menu"
style="@style/PlacePageMetadataIcon"
app:srcCompat="@drawable/ic_website_menu"
app:tint="?colorAccent"/>

<TextView
android:id="@+id/tv__place_website_menu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="@style/MwmTextAppearance.PlacePage.Accent"
tools:text="osm.org"/>
</LinearLayout>

0 comments on commit 1ce3428

Please sign in to comment.