1
0
Fork 1

Video play button

Goes to the video url (usually embed url) instead of the whole webpage.

(cherry picked from commit 2276ee00e042ecade56c279431bdd06bb693d2c0)
This commit is contained in:
Stephen Paul Weber 2024-09-17 23:53:12 -05:00 committed by Arne
parent 1e8d4c86b9
commit f83c2e421c
2 changed files with 52 additions and 25 deletions

View file

@ -1639,6 +1639,13 @@ public class MessageAdapter extends ArrayAdapter<Message> {
binding.title.setText(getItem(position).findChildContent("title", "https://ogp.me/ns#"));
binding.description.setText(getItem(position).findChildContent("description", "https://ogp.me/ns#"));
binding.url.setText(getItem(position).findChildContent("url", "https://ogp.me/ns#"));
final var video = getItem(position).findChildContent("video", "https://ogp.me/ns#");
if (video != null && video.length() > 0) {
binding.playButton.setVisibility(View.VISIBLE);
binding.playButton.setOnClickListener((v) -> {
new FixedURLSpan(video).onClick(v);
});
}
return binding.getRoot();
}
});

View file

@ -2,37 +2,57 @@
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<LinearLayout
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingHorizontal="10dp"
android:paddingHorizontal="4dp"
android:paddingVertical="4dp"
android:background="@drawable/background_link_description"
android:orientation="vertical">
android:descendantFocusability="blocksDescendants"
android:background="@drawable/background_link_description">
<TextView
android:id="@+id/title"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingHorizontal="6dp"
android:orientation="vertical">
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:textColor="?colorPrimary"
android:textAppearance="?textAppearanceTitleSmall" />
<TextView
android:id="@+id/url"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:textColor="?colorOnSurface"
android:textAppearance="?textAppearanceLabelSmall" />
<TextView
android:id="@+id/description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?colorOnSurface"
android:textAppearance="?textAppearanceBodyMedium" />
</LinearLayout>
<ImageButton
android:id="@+id/play_button"
android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:textColor="?colorPrimary"
android:textAppearance="?textAppearanceTitleSmall" />
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:focusable="false"
android:focusableInTouchMode="false"
android:background="?attr/selectableItemBackgroundBorderless"
android:src="@drawable/ic_play_circle_24dp" />
<TextView
android:id="@+id/url"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:textColor="?colorOnSurface"
android:textAppearance="?textAppearanceLabelSmall" />
<TextView
android:id="@+id/description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?colorOnSurface"
android:textAppearance="?textAppearanceBodyMedium" />
</LinearLayout>
</RelativeLayout>
</layout>