diff --git a/app/src/main/java/org/schabi/newpipe/fragments/detail/DescriptionFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/detail/DescriptionFragment.java
index 034738d37..bbff26cc4 100644
--- a/app/src/main/java/org/schabi/newpipe/fragments/detail/DescriptionFragment.java
+++ b/app/src/main/java/org/schabi/newpipe/fragments/detail/DescriptionFragment.java
@@ -12,13 +12,17 @@ import androidx.annotation.StringRes;
import androidx.appcompat.widget.TooltipCompat;
import androidx.core.text.HtmlCompat;
+import com.google.android.material.chip.Chip;
+
import org.schabi.newpipe.BaseFragment;
import org.schabi.newpipe.R;
import org.schabi.newpipe.databinding.FragmentDescriptionBinding;
import org.schabi.newpipe.databinding.ItemMetadataBinding;
+import org.schabi.newpipe.databinding.ItemMetadataTagsBinding;
import org.schabi.newpipe.extractor.stream.Description;
import org.schabi.newpipe.extractor.stream.StreamInfo;
import org.schabi.newpipe.util.Localization;
+import org.schabi.newpipe.util.NavigationHelper;
import org.schabi.newpipe.util.ShareUtils;
import org.schabi.newpipe.util.TextLinkifier;
@@ -201,18 +205,34 @@ public class DescriptionFragment extends BaseFragment {
private void addTagsMetadataItem(final LayoutInflater inflater, final LinearLayout layout) {
if (streamInfo.getTags() != null && !streamInfo.getTags().isEmpty()) {
- final StringBuilder tags = new StringBuilder();
- for (int i = 0; i < streamInfo.getTags().size(); ++i) {
- if (i != 0) {
- tags.append(", ");
- }
- tags.append(streamInfo.getTags().get(i));
+ final ItemMetadataTagsBinding itemBinding
+ = ItemMetadataTagsBinding.inflate(inflater, layout, false);
+
+ for (final String tag : streamInfo.getTags()) {
+ final Chip chip = (Chip) inflater.inflate(R.layout.chip,
+ itemBinding.metadataTagsChips, false);
+ chip.setText(tag);
+ chip.setOnClickListener(this::onTagClick);
+ chip.setOnLongClickListener(this::onTagLongClick);
+ itemBinding.metadataTagsChips.addView(chip);
}
- addMetadataItem(inflater, layout, false, R.string.metadata_tags, tags.toString());
+ layout.addView(itemBinding.getRoot());
}
}
+ private void onTagClick(final View chip) {
+ if (getParentFragment() != null) {
+ NavigationHelper.openSearchFragment(getParentFragment().getParentFragmentManager(),
+ streamInfo.getServiceId(), ((Chip) chip).getText().toString());
+ }
+ }
+
+ private boolean onTagLongClick(final View chip) {
+ ShareUtils.copyToClipboard(requireContext(), ((Chip) chip).getText().toString());
+ return true;
+ }
+
private void addPrivacyMetadataItem(final LayoutInflater inflater, final LinearLayout layout) {
if (streamInfo.getPrivacy() != null) {
@StringRes final int contentRes;
diff --git a/app/src/main/res/layout/chip.xml b/app/src/main/res/layout/chip.xml
new file mode 100644
index 000000000..f7a55fdf3
--- /dev/null
+++ b/app/src/main/res/layout/chip.xml
@@ -0,0 +1,9 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_description.xml b/app/src/main/res/layout/fragment_description.xml
index e4622a85f..c44b88cb6 100644
--- a/app/src/main/res/layout/fragment_description.xml
+++ b/app/src/main/res/layout/fragment_description.xml
@@ -88,9 +88,9 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
- android:layout_marginTop="8dp"
+ android:layout_marginTop="10dp"
android:layout_marginEnd="16dp"
- android:layout_marginBottom="16dp"
+ android:layout_marginBottom="10dp"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
diff --git a/app/src/main/res/layout/item_metadata.xml b/app/src/main/res/layout/item_metadata.xml
index 4da962d5c..b9015e603 100644
--- a/app/src/main/res/layout/item_metadata.xml
+++ b/app/src/main/res/layout/item_metadata.xml
@@ -1,23 +1,23 @@
+ android:paddingTop="6dp"
+ android:paddingBottom="6dp">
+ app:layout_constraintGuide_percent="0.23" />
-
\ No newline at end of file
diff --git a/app/src/main/res/layout/item_metadata_tags.xml b/app/src/main/res/layout/item_metadata_tags.xml
new file mode 100644
index 000000000..cd0b8c42d
--- /dev/null
+++ b/app/src/main/res/layout/item_metadata_tags.xml
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file