[android] Rework socials networks on the place page

Signed-off-by: Jean-Baptiste <jeanbaptiste.charron@outlook.fr>
This commit is contained in:
Jean-Baptiste
2025-11-14 23:32:48 +01:00
parent 9bfebc2046
commit ffea67a2b3
10 changed files with 127 additions and 224 deletions

View File

@@ -20,6 +20,8 @@ import app.organicmaps.sdk.bookmarks.data.Metadata;
import app.organicmaps.util.Utils;
import app.organicmaps.widget.placepage.PlacePageUtils;
import app.organicmaps.widget.placepage.PlacePageViewModel;
import com.google.android.material.imageview.ShapeableImageView;
import com.google.android.material.textview.MaterialTextView;
import java.util.ArrayList;
import java.util.List;
@@ -29,21 +31,15 @@ public class PlacePageLinksFragment extends Fragment implements Observer<MapObje
private static final String TAG = PlacePageLinksFragment.class.getSimpleName();
private View mFrame;
private View mFacebookPage;
private MaterialTextView mTvFacebookPage;
private View mInstagramPage;
private MaterialTextView mTvInstagramPage;
private View mTwitterPage;
private MaterialTextView mTvTwitterPage;
private View mFediversePage;
private MaterialTextView mTvFediversePage;
private View mBlueskyPage;
private MaterialTextView mTvBlueskyPage;
private View mVkPage;
private MaterialTextView mTvVkPage;
private View mLinePage;
private MaterialTextView mTvLinePage;
private View mSocial;
private ShapeableImageView mFacebookIv;
private ShapeableImageView mInstagramIv;
private ShapeableImageView mTwitterIv;
private ShapeableImageView mFediverseIv;
private ShapeableImageView mBlueskyIv;
private ShapeableImageView mVkIv;
private ShapeableImageView mLineIv;
private View mWebsite;
private MaterialTextView mTvWebsite;
private View mWebsiteMenu;
@@ -71,6 +67,16 @@ public class PlacePageLinksFragment extends Fragment implements Observer<MapObje
metaLayout.setVisibility(GONE);
}
private static void refreshMetadataOrHideSocial(@Nullable String metadata, @NonNull ShapeableImageView metaIv)
{
if (!TextUtils.isEmpty(metadata))
{
metaIv.setVisibility(VISIBLE);
}
else
metaIv.setVisibility(GONE);
}
@NonNull
private String getLink(@NonNull Metadata.MetadataType type)
{
@@ -128,40 +134,35 @@ public class PlacePageLinksFragment extends Fragment implements Observer<MapObje
mWikimedia.setOnClickListener((v) -> openUrl(Metadata.MetadataType.FMD_WIKIMEDIA_COMMONS));
mWikimedia.setOnLongClickListener((v) -> copyUrl(mWikimedia, Metadata.MetadataType.FMD_WIKIMEDIA_COMMONS));
mFacebookPage = mFrame.findViewById(R.id.ll__place_facebook);
mTvFacebookPage = mFrame.findViewById(R.id.tv__place_facebook_page);
mFacebookPage.setOnClickListener((v) -> openUrl(Metadata.MetadataType.FMD_CONTACT_FACEBOOK));
mFacebookPage.setOnLongClickListener((v) -> copyUrl(mFacebookPage, Metadata.MetadataType.FMD_CONTACT_FACEBOOK));
mSocial = mFrame.findViewById(R.id.ll__place_social);
mInstagramPage = mFrame.findViewById(R.id.ll__place_instagram);
mTvInstagramPage = mFrame.findViewById(R.id.tv__place_instagram_page);
mInstagramPage.setOnClickListener((v) -> openUrl(Metadata.MetadataType.FMD_CONTACT_INSTAGRAM));
mInstagramPage.setOnLongClickListener((v) -> copyUrl(mInstagramPage, Metadata.MetadataType.FMD_CONTACT_INSTAGRAM));
mFacebookIv = mSocial.findViewById(R.id.iv__place_facebook);
mFacebookIv.setOnClickListener((v) -> openUrl(Metadata.MetadataType.FMD_CONTACT_FACEBOOK));
mFacebookIv.setOnLongClickListener((v) -> copyUrl(mFacebookIv, Metadata.MetadataType.FMD_CONTACT_FACEBOOK));
mFediversePage = mFrame.findViewById(R.id.ll__place_fediverse);
mTvFediversePage = mFrame.findViewById(R.id.tv__place_fediverse_page);
mFediversePage.setOnClickListener((v) -> openUrl(Metadata.MetadataType.FMD_CONTACT_FEDIVERSE));
mFediversePage.setOnLongClickListener((v) -> copyUrl(mFediversePage, Metadata.MetadataType.FMD_CONTACT_FEDIVERSE));
mInstagramIv = mSocial.findViewById(R.id.iv__place_instagram);
mInstagramIv.setOnClickListener((v) -> openUrl(Metadata.MetadataType.FMD_CONTACT_INSTAGRAM));
mInstagramIv.setOnLongClickListener((v) -> copyUrl(mInstagramIv, Metadata.MetadataType.FMD_CONTACT_INSTAGRAM));
mBlueskyPage = mFrame.findViewById(R.id.ll__place_bluesky);
mTvBlueskyPage = mFrame.findViewById(R.id.tv__place_bluesky_page);
mBlueskyPage.setOnClickListener((v) -> openUrl(Metadata.MetadataType.FMD_CONTACT_BLUESKY));
mBlueskyPage.setOnLongClickListener((v) -> copyUrl(mBlueskyPage, Metadata.MetadataType.FMD_CONTACT_BLUESKY));
mFediverseIv = mSocial.findViewById(R.id.iv__place_fediverse);
mFediverseIv.setOnClickListener((v) -> openUrl(Metadata.MetadataType.FMD_CONTACT_FEDIVERSE));
mFediverseIv.setOnLongClickListener((v) -> copyUrl(mFediverseIv, Metadata.MetadataType.FMD_CONTACT_FEDIVERSE));
mTwitterPage = mFrame.findViewById(R.id.ll__place_twitter);
mTvTwitterPage = mFrame.findViewById(R.id.tv__place_twitter_page);
mTwitterPage.setOnClickListener((v) -> openUrl(Metadata.MetadataType.FMD_CONTACT_TWITTER));
mTwitterPage.setOnLongClickListener((v) -> copyUrl(mTwitterPage, Metadata.MetadataType.FMD_CONTACT_TWITTER));
mBlueskyIv = mSocial.findViewById(R.id.iv__place_bluesky);
mBlueskyIv.setOnClickListener((v) -> openUrl(Metadata.MetadataType.FMD_CONTACT_BLUESKY));
mBlueskyIv.setOnLongClickListener((v) -> copyUrl(mBlueskyIv, Metadata.MetadataType.FMD_CONTACT_BLUESKY));
mVkPage = mFrame.findViewById(R.id.ll__place_vk);
mTvVkPage = mFrame.findViewById(R.id.tv__place_vk_page);
mVkPage.setOnClickListener((v) -> openUrl(Metadata.MetadataType.FMD_CONTACT_VK));
mVkPage.setOnLongClickListener((v) -> copyUrl(mVkPage, Metadata.MetadataType.FMD_CONTACT_VK));
mTwitterIv = mSocial.findViewById(R.id.iv__place_twitter);
mTwitterIv.setOnClickListener((v) -> openUrl(Metadata.MetadataType.FMD_CONTACT_TWITTER));
mTwitterIv.setOnLongClickListener((v) -> copyUrl(mTwitterIv, Metadata.MetadataType.FMD_CONTACT_TWITTER));
mLinePage = mFrame.findViewById(R.id.ll__place_line);
mTvLinePage = mFrame.findViewById(R.id.tv__place_line_page);
mLinePage.setOnClickListener((v) -> openUrl(Metadata.MetadataType.FMD_CONTACT_LINE));
mLinePage.setOnLongClickListener((v) -> copyUrl(mLinePage, Metadata.MetadataType.FMD_CONTACT_LINE));
mVkIv = mSocial.findViewById(R.id.iv__place_vk);
mVkIv.setOnClickListener((v) -> openUrl(Metadata.MetadataType.FMD_CONTACT_VK));
mVkIv.setOnLongClickListener((v) -> copyUrl(mVkIv, Metadata.MetadataType.FMD_CONTACT_VK));
mLineIv = mSocial.findViewById(R.id.iv__place_line);
mLineIv.setOnClickListener((v) -> openUrl(Metadata.MetadataType.FMD_CONTACT_LINE));
mLineIv.setOnLongClickListener((v) -> copyUrl(mLineIv, Metadata.MetadataType.FMD_CONTACT_LINE));
mPanoramax = mFrame.findViewById(R.id.ll__place_panoramax);
mTvPanoramax = mFrame.findViewById(R.id.tv__place_panoramax);
@@ -215,25 +216,25 @@ public class PlacePageLinksFragment extends Fragment implements Observer<MapObje
refreshMetadataOrHide(mMapObject.getMetadata(Metadata.MetadataType.FMD_EMAIL), mEmail, mTvEmail);
final String facebook = mMapObject.getMetadata(Metadata.MetadataType.FMD_CONTACT_FACEBOOK);
refreshMetadataOrHide(facebook, mFacebookPage, mTvFacebookPage);
refreshMetadataOrHideSocial(facebook, mFacebookIv);
final String instagram = mMapObject.getMetadata(Metadata.MetadataType.FMD_CONTACT_INSTAGRAM);
refreshMetadataOrHide(instagram, mInstagramPage, mTvInstagramPage);
refreshMetadataOrHideSocial(instagram, mInstagramIv);
final String fediverse = mMapObject.getMetadata(Metadata.MetadataType.FMD_CONTACT_FEDIVERSE);
refreshMetadataOrHide(fediverse, mFediversePage, mTvFediversePage);
refreshMetadataOrHideSocial(fediverse, mFediverseIv);
final String bluesky = mMapObject.getMetadata(Metadata.MetadataType.FMD_CONTACT_BLUESKY);
refreshMetadataOrHide(bluesky, mBlueskyPage, mTvBlueskyPage);
refreshMetadataOrHideSocial(bluesky, mBlueskyIv);
final String twitter = mMapObject.getMetadata(Metadata.MetadataType.FMD_CONTACT_TWITTER);
refreshMetadataOrHide(twitter, mTwitterPage, mTvTwitterPage);
refreshMetadataOrHideSocial(twitter, mTwitterIv);
final String vk = mMapObject.getMetadata(Metadata.MetadataType.FMD_CONTACT_VK);
refreshMetadataOrHide(vk, mVkPage, mTvVkPage);
refreshMetadataOrHideSocial(vk, mVkIv);
final String line = mMapObject.getMetadata(Metadata.MetadataType.FMD_CONTACT_LINE);
refreshMetadataOrHide(line, mLinePage, mTvLinePage);
refreshMetadataOrHideSocial(line, mLineIv);
final String panoramax = mMapObject.getMetadata(Metadata.MetadataType.FMD_PANORAMAX);
final String panoramaxTitle = TextUtils.isEmpty(panoramax) ? "" : getResources().getString(R.string.panoramax);

View File

@@ -1,25 +0,0 @@
<?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_bluesky"
style="@style/PlacePageItemFrame"
android:tag="website"
tools:background="#20FF0000"
tools:visibility="visible">
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/iv__place_bluesky"
style="@style/PlacePageMetadataIcon"
app:srcCompat="@drawable/ic_bluesky"
app:tint="?colorSecondary"/>
<com.google.android.material.textview.MaterialTextView
android:id="@+id/tv__place_bluesky_page"
android:textAlignment="viewStart"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="@style/MwmTextAppearance.PlacePage.Accent"
tools:text="@string/bluesky"/>
</LinearLayout>

View File

@@ -1,23 +0,0 @@
<?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_facebook"
style="@style/PlacePageItemFrame"
tools:background="#20FF0000"
tools:visibility="visible">
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/iv__place_facebook"
style="@style/PlacePageMetadataIcon"
app:srcCompat="@drawable/ic_facebook_white"
app:tint="?colorSecondary"/>
<com.google.android.material.textview.MaterialTextView
android:id="@+id/tv__place_facebook_page"
android:textAlignment="viewStart"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="@style/MwmTextAppearance.PlacePage.Accent"
tools:text="@string/facebook"/>
</LinearLayout>

View File

@@ -1,25 +0,0 @@
<?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_fediverse"
style="@style/PlacePageItemFrame"
android:tag="website"
tools:background="#20FF0000"
tools:visibility="visible">
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/iv__place_fediverse"
style="@style/PlacePageMetadataIcon"
app:srcCompat="@drawable/ic_mastodon"
app:tint="?colorSecondary"/>
<com.google.android.material.textview.MaterialTextView
android:id="@+id/tv__place_fediverse_page"
android:textAlignment="viewStart"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="@style/MwmTextAppearance.PlacePage.Accent"
tools:text="@string/mastodon"/>
</LinearLayout>

View File

@@ -1,24 +0,0 @@
<?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_instagram"
style="@style/PlacePageItemFrame"
tools:background="#20FF0000"
tools:visibility="visible">
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/iv__place_instagram"
style="@style/PlacePageMetadataIcon"
app:srcCompat="@drawable/ic_instagram_white"
app:tint="?colorSecondary"/>
<com.google.android.material.textview.MaterialTextView
android:id="@+id/tv__place_instagram_page"
android:textAlignment="viewStart"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="@style/MwmTextAppearance.PlacePage.Accent"
tools:text="@string/instagram"/>
</LinearLayout>

View File

@@ -1,23 +0,0 @@
<?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_line"
style="@style/PlacePageItemFrame"
tools:background="#20FF0000"
tools:visibility="visible">
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/iv__place_line"
style="@style/PlacePageMetadataIcon"
app:srcCompat="@drawable/ic_line_white"
app:tint="?colorSecondary"/>
<com.google.android.material.textview.MaterialTextView
android:id="@+id/tv__place_line_page"
android:textAlignment="viewStart"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="@style/MwmTextAppearance.PlacePage.Accent"
tools:text="@string/editor_line_social_network"/>
</LinearLayout>

View File

@@ -13,13 +13,7 @@
android:layout_height="wrap_content"
tools:layout="@layout/place_page_phone_fragment" />
<include layout="@layout/place_page_email" />
<include layout="@layout/place_page_fediverse" />
<include layout="@layout/place_page_facebook" />
<include layout="@layout/place_page_instagram" />
<include layout="@layout/place_page_twitter" />
<include layout="@layout/place_page_vk" />
<include layout="@layout/place_page_line" />
<include layout="@layout/place_page_bluesky" />
<include layout="@layout/place_page_social" />
<include layout="@layout/place_page_wikimedia" />
<include layout="@layout/place_page_panoramax" />
</LinearLayout>

View File

@@ -0,0 +1,76 @@
<?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_social"
style="@style/PlacePageItemFrame"
android:tag="website"
android:gravity="center"
tools:background="#20FF0000"
tools:visibility="visible">
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/iv__place_fediverse"
style="@style/PlacePageMetadataIcon"
android:layout_width="32dp"
android:layout_height="32dp"
android:padding="@dimen/margin_quarter"
app:srcCompat="@drawable/ic_mastodon"
app:tint="?colorSecondary"/>
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/iv__place_facebook"
style="@style/PlacePageMetadataIcon"
android:layout_width="32dp"
android:layout_height="32dp"
android:padding="@dimen/margin_quarter"
app:srcCompat="@drawable/ic_facebook_white"
app:tint="?colorSecondary"/>
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/iv__place_instagram"
style="@style/PlacePageMetadataIcon"
android:layout_width="32dp"
android:layout_height="32dp"
android:padding="@dimen/margin_quarter"
app:srcCompat="@drawable/ic_instagram_white"
app:tint="?colorSecondary"/>
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/iv__place_twitter"
style="@style/PlacePageMetadataIcon"
android:layout_width="32dp"
android:layout_height="32dp"
android:padding="@dimen/margin_quarter"
app:srcCompat="@drawable/ic_twitterx_white"
app:tint="?colorSecondary"/>
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/iv__place_vk"
style="@style/PlacePageMetadataIcon"
android:layout_width="32dp"
android:layout_height="32dp"
android:padding="@dimen/margin_quarter"
app:srcCompat="@drawable/ic_vk_white"
app:tint="?colorSecondary"/>
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/iv__place_line"
style="@style/PlacePageMetadataIcon"
android:layout_width="32dp"
android:layout_height="32dp"
android:padding="@dimen/margin_quarter"
app:srcCompat="@drawable/ic_line_white"
app:tint="?colorSecondary"/>
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/iv__place_bluesky"
style="@style/PlacePageMetadataIcon"
android:layout_width="32dp"
android:layout_height="32dp"
android:padding="@dimen/margin_quarter"
app:srcCompat="@drawable/ic_bluesky"
app:tint="?colorSecondary"/>
</LinearLayout>

View File

@@ -1,24 +0,0 @@
<?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_twitter"
style="@style/PlacePageItemFrame"
tools:background="#20FF0000"
tools:visibility="visible">
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/iv__place_twitter"
style="@style/PlacePageMetadataIcon"
app:srcCompat="@drawable/ic_twitterx_white"
app:tint="?colorSecondary"/>
<com.google.android.material.textview.MaterialTextView
android:id="@+id/tv__place_twitter_page"
android:textAlignment="viewStart"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="@style/MwmTextAppearance.PlacePage.Accent"
tools:text="@string/twitter"/>
</LinearLayout>

View File

@@ -1,24 +0,0 @@
<?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_vk"
style="@style/PlacePageItemFrame"
tools:background="#20FF0000"
tools:visibility="visible">
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/iv__place_vk"
style="@style/PlacePageMetadataIcon"
app:srcCompat="@drawable/ic_vk_white"
app:tint="?colorSecondary"/>
<com.google.android.material.textview.MaterialTextView
android:id="@+id/tv__place_vk_page"
android:textAlignment="viewStart"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="@style/MwmTextAppearance.PlacePage.Accent"
tools:text="@string/vk"/>
</LinearLayout>