Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disabled commenter image view on LoadThumbnail set to false #4350

Merged
merged 1 commit into from
Oct 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
package org.schabi.newpipe.info_list.holder;

import android.content.SharedPreferences;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.text.style.URLSpan;
import android.text.util.Linkify;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;
import androidx.preference.PreferenceManager;


import org.schabi.newpipe.R;
import org.schabi.newpipe.extractor.InfoItem;
Expand All @@ -31,7 +36,12 @@ public class CommentsMiniInfoItemHolder extends InfoItemHolder {
private static final int COMMENT_DEFAULT_LINES = 2;
private static final int COMMENT_EXPANDED_LINES = 1000;
private static final Pattern PATTERN = Pattern.compile("(\\d+:)?(\\d+)?:(\\d+)");
private final String downloadThumbnailKey;
private final int commentHorizontalPadding;
private final int commentVerticalPadding;

private SharedPreferences preferences = null;
private final RelativeLayout itemRoot;
public final CircleImageView itemThumbnailView;
private final TextView itemContentView;
private final TextView itemLikesCountView;
Expand Down Expand Up @@ -65,11 +75,20 @@ public String transformUrl(final Matcher match, final String url) {
final ViewGroup parent) {
super(infoItemBuilder, layoutId, parent);

itemRoot = itemView.findViewById(R.id.itemRoot);
itemThumbnailView = itemView.findViewById(R.id.itemThumbnailView);
itemLikesCountView = itemView.findViewById(R.id.detail_thumbs_up_count_view);
itemDislikesCountView = itemView.findViewById(R.id.detail_thumbs_down_count_view);
itemPublishedTime = itemView.findViewById(R.id.itemPublishedTime);
itemContentView = itemView.findViewById(R.id.itemCommentContentView);

downloadThumbnailKey = infoItemBuilder.getContext().
getString(R.string.download_thumbnail_key);

commentHorizontalPadding = (int) infoItemBuilder.getContext()
.getResources().getDimension(R.dimen.comments_horizontal_padding);
commentVerticalPadding = (int) infoItemBuilder.getContext()
.getResources().getDimension(R.dimen.comments_vertical_padding);
}

public CommentsMiniInfoItemHolder(final InfoItemBuilder infoItemBuilder,
Expand All @@ -85,11 +104,24 @@ public void updateFromItem(final InfoItem infoItem,
}
final CommentsInfoItem item = (CommentsInfoItem) infoItem;

preferences = PreferenceManager.getDefaultSharedPreferences(itemBuilder.getContext());

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TobiGr it is directly in mid of the changes

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah didn't get the correct lines, but just check the first changed file.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lines just below this one.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went through the code and did not see it :D
Looks like I need a second pair of glasses...

itemBuilder.getImageLoader()
.displayImage(item.getUploaderAvatarUrl(),
itemThumbnailView,
ImageDisplayConstants.DISPLAY_THUMBNAIL_OPTIONS);

if (preferences.getBoolean(downloadThumbnailKey, true)) {
itemThumbnailView.setVisibility(View.VISIBLE);
itemRoot.setPadding(commentVerticalPadding, commentVerticalPadding,
commentVerticalPadding, commentVerticalPadding);
} else {
itemThumbnailView.setVisibility(View.GONE);
itemRoot.setPadding(commentHorizontalPadding, commentVerticalPadding,
commentHorizontalPadding, commentVerticalPadding);
}


itemThumbnailView.setOnClickListener(view -> openCommentAuthor(item));

streamUrl = item.getUrl();
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/res/layout/list_comments_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:padding="@dimen/video_item_search_padding">
android:padding="@dimen/comments_vertical_padding">

<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/itemThumbnailView"
Expand All @@ -30,7 +30,6 @@
android:layout_alignParentTop="true"
android:layout_marginBottom="@dimen/video_item_search_image_right_margin"
android:layout_toEndOf="@+id/itemThumbnailView"
android:layout_toRightOf="@+id/itemThumbnailView"
android:ellipsize="end"
android:lines="1"
android:textAppearance="?android:attr/textAppearanceSmall"
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
<dimen name="video_item_detail_description_to_details_margin">4dp</dimen>
<dimen name="software_component_item_padding">8dp</dimen>
<dimen name="channel_item_grid_padding">12dp</dimen>
<dimen name="comments_horizontal_padding">16dp</dimen>
<dimen name="comments_vertical_padding">12dp</dimen>

<!-- Players padding & sizes -->
<dimen name="player_main_controls_padding">16dp</dimen>
Expand Down