Added support for showing when a comment has received a heart from the creator of a video.

This commit is contained in:
Kalle Struik 2021-07-23 17:30:47 +02:00
parent 39722a5563
commit 3874e16187
6 changed files with 42 additions and 1 deletions

View File

@ -7,6 +7,7 @@ import android.text.style.URLSpan;
import android.text.util.Linkify;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
@ -45,6 +46,7 @@ public class CommentsMiniInfoItemHolder extends InfoItemHolder {
private final TextView itemContentView;
private final TextView itemLikesCountView;
private final TextView itemDislikesCountView;
private final ImageView itemHeartView;
private final TextView itemPublishedTime;
private String commentText;
@ -80,6 +82,7 @@ public class CommentsMiniInfoItemHolder extends InfoItemHolder {
itemDislikesCountView = itemView.findViewById(R.id.detail_thumbs_down_count_view);
itemPublishedTime = itemView.findViewById(R.id.itemPublishedTime);
itemContentView = itemView.findViewById(R.id.itemCommentContentView);
itemHeartView = itemView.findViewById(R.id.detail_heart_img_view);
downloadThumbnailKey = infoItemBuilder.getContext().
getString(R.string.download_thumbnail_key);
@ -152,6 +155,10 @@ public class CommentsMiniInfoItemHolder extends InfoItemHolder {
itemPublishedTime.setText(item.getTextualUploadDate());
}
if (item.isHeartedByUploader()) {
itemHeartView.setVisibility(View.VISIBLE);
}
itemView.setOnClickListener(view -> {
toggleEllipsize();
if (itemBuilder.getOnCommentsSelectedListener() != null) {

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="#FFFFFF"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M12,21.35l-1.45,-1.32C5.4,15.36 2,12.28 2,8.5 2,5.42 4.42,3 7.5,3c1.74,0 3.41,0.81 4.5,2.09C13.09,3.81 14.76,3 16.5,3 19.58,3 22,5.42 22,8.5c0,3.78 -3.4,6.86 -8.55,11.54L12,21.35z"/>
</vector>

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M12,21.35l-1.45,-1.32C5.4,15.36 2,12.28 2,8.5 2,5.42 4.42,3 7.5,3c1.74,0 3.41,0.81 4.5,2.09C13.09,3.81 14.76,3 16.5,3 19.58,3 22,5.42 22,8.5c0,3.78 -3.4,6.86 -8.55,11.54L12,21.35z"/>
</vector>

View File

@ -71,6 +71,17 @@
tools:ignore="RtlHardcoded"
tools:text="12M" />
<ImageView
android:id="@+id/detail_heart_img_view"
android:layout_width="@dimen/video_item_detail_heart_image_width"
android:layout_height="@dimen/video_item_detail_heart_image_height"
android:layout_below="@id/itemCommentContentView"
android:layout_marginLeft="@dimen/video_item_detail_heart_margin"
android:layout_toRightOf="@+id/detail_thumbs_up_count_view"
android:contentDescription="@string/detail_heart_img_view_description"
android:visibility="gone"
app:srcCompat="@drawable/ic_heart" />
<!--we can uncomment below code if we need dislike button and count in future-->
@ -105,7 +116,7 @@
android:layout_height="wrap_content"
android:layout_below="@id/itemCommentContentView"
android:layout_marginLeft="12dp"
android:layout_toRightOf="@id/detail_thumbs_up_count_view"
android:layout_toRightOf="@id/detail_heart_img_view"
android:lines="1"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textSize="@dimen/video_item_search_upload_date_text_size"

View File

@ -81,11 +81,14 @@
<dimen name="video_item_detail_sub_channel_image_size">16dp</dimen>
<dimen name="video_item_detail_like_image_height">18sp</dimen>
<dimen name="video_item_detail_like_image_width">18sp</dimen>
<dimen name="video_item_detail_heart_image_width">18sp</dimen>
<dimen name="video_item_detail_heart_image_height">18sp</dimen>
<dimen name="channel_avatar_size">70dp</dimen>
<dimen name="sub_channel_avatar_size">35dp</dimen>
<dimen name="mini_player_height">60dp</dimen>
<!-- Paddings & Margins -->
<dimen name="video_item_detail_like_margin">5dp</dimen>
<dimen name="video_item_detail_heart_margin">5dp</dimen>
<dimen name="video_item_detail_error_panel_margin">50dp</dimen>
<!-- Control panel -->
<dimen name="detail_control_text_size">12sp</dimen>

View File

@ -749,6 +749,7 @@
<string name="metadata_privacy_unlisted">Unlisted</string>
<string name="metadata_privacy_private">Private</string>
<string name="metadata_privacy_internal">Internal</string>
<string name="detail_heart_img_view_description">Hearted by creator</string>
<string name="open_website_license">Open website</string>
<string name="tablet_mode_title">Tablet mode</string>
<string name="on">On</string>