display publisher title and thumbnail on file page

This commit is contained in:
Akinwale Ariwodola 2020-06-02 09:34:59 +01:00
parent 37cf85a5f6
commit d4af28d1c5
5 changed files with 92 additions and 21 deletions

View file

@ -97,7 +97,7 @@ public class ChannelFilterListAdapter extends RecyclerView.Adapter<ChannelFilter
vh.titleView.setText(Helper.isNullOrEmpty(claim.getTitle()) ? claim.getName() : claim.getTitle()); vh.titleView.setText(Helper.isNullOrEmpty(claim.getTitle()) ? claim.getName() : claim.getTitle());
String thumbnailUrl = claim.getThumbnailUrl(); String thumbnailUrl = claim.getThumbnailUrl();
if (!Helper.isNullOrEmpty(thumbnailUrl) && context != null) { if (!Helper.isNullOrEmpty(thumbnailUrl) && context != null) {
Glide.with(context.getApplicationContext()).asBitmap().load(thumbnailUrl).apply(RequestOptions.circleCropTransform()).into(vh.thumbnailView); Glide.with(context.getApplicationContext()).load(thumbnailUrl).apply(RequestOptions.circleCropTransform()).into(vh.thumbnailView);
} }
vh.alphaContainer.setVisibility(claim.isPlaceholder() || Helper.isNullOrEmpty(thumbnailUrl) ? View.VISIBLE : View.GONE); vh.alphaContainer.setVisibility(claim.isPlaceholder() || Helper.isNullOrEmpty(thumbnailUrl) ? View.VISIBLE : View.GONE);
vh.thumbnailView.setVisibility(claim.isPlaceholder() || Helper.isNullOrEmpty(thumbnailUrl) ? View.GONE : View.VISIBLE); vh.thumbnailView.setVisibility(claim.isPlaceholder() || Helper.isNullOrEmpty(thumbnailUrl) ? View.GONE : View.VISIBLE);

View file

@ -97,7 +97,7 @@ public class SuggestedChannelGridAdapter extends RecyclerView.Adapter<SuggestedC
vh.alphaView.setText(claim.getName().substring(1, 2)); vh.alphaView.setText(claim.getName().substring(1, 2));
if (!Helper.isNullOrEmpty(thumbnailUrl)) { if (!Helper.isNullOrEmpty(thumbnailUrl)) {
vh.thumbnailView.setVisibility(View.VISIBLE); vh.thumbnailView.setVisibility(View.VISIBLE);
Glide.with(context.getApplicationContext()).asBitmap().load(thumbnailUrl).apply(RequestOptions.circleCropTransform()).into(vh.thumbnailView); Glide.with(context.getApplicationContext()).load(thumbnailUrl).apply(RequestOptions.circleCropTransform()).into(vh.thumbnailView);
} else { } else {
vh.thumbnailView.setVisibility(View.GONE); vh.thumbnailView.setVisibility(View.GONE);
} }

View file

@ -426,7 +426,7 @@ public class ChannelFragment extends BaseFragment implements FetchChannelsListen
Glide.with(context.getApplicationContext()).load(coverUrl).centerCrop().into(imageCover); Glide.with(context.getApplicationContext()).load(coverUrl).centerCrop().into(imageCover);
} }
if (context != null && !Helper.isNullOrEmpty(thumbnailUrl)) { if (context != null && !Helper.isNullOrEmpty(thumbnailUrl)) {
Glide.with(context.getApplicationContext()).asBitmap().load(thumbnailUrl).apply(RequestOptions.circleCropTransform()).into(imageThumbnail); Glide.with(context.getApplicationContext()).load(thumbnailUrl).apply(RequestOptions.circleCropTransform()).into(imageThumbnail);
noThumbnailView.setVisibility(View.GONE); noThumbnailView.setVisibility(View.GONE);
} else { } else {
imageThumbnail.setVisibility(View.GONE); imageThumbnail.setVisibility(View.GONE);

View file

@ -1037,7 +1037,7 @@ public class FileViewFragment extends BaseFragment implements
} }
}); });
root.findViewById(R.id.file_view_publisher_name).setOnClickListener(new View.OnClickListener() { root.findViewById(R.id.file_view_publisher_info_area).setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
if (claim != null && claim.getSigningChannel() != null) { if (claim != null && claim.getSigningChannel() != null) {
@ -1304,6 +1304,8 @@ public class FileViewFragment extends BaseFragment implements
View root = getView(); View root = getView();
if (root != null) { if (root != null) {
Context context = getContext();
root.findViewById(R.id.file_view_scroll_view).scrollTo(0, 0); root.findViewById(R.id.file_view_scroll_view).scrollTo(0, 0);
Helper.setViewVisibility(layoutDisplayArea, View.VISIBLE); Helper.setViewVisibility(layoutDisplayArea, View.VISIBLE);
@ -1325,7 +1327,29 @@ public class FileViewFragment extends BaseFragment implements
((TextView) root.findViewById(R.id.file_view_publisher_name)).setText( ((TextView) root.findViewById(R.id.file_view_publisher_name)).setText(
Helper.isNullOrEmpty(claim.getPublisherName()) ? getString(R.string.anonymous) : claim.getPublisherName()); Helper.isNullOrEmpty(claim.getPublisherName()) ? getString(R.string.anonymous) : claim.getPublisherName());
Context context = getContext(); Claim signingChannel = claim.getSigningChannel();
boolean hasPublisher = signingChannel != null;
boolean hasPublisherThumbnail = hasPublisher && !Helper.isNullOrEmpty(signingChannel.getThumbnailUrl());
root.findViewById(R.id.file_view_publisher_avatar).setVisibility(hasPublisher ? View.VISIBLE : View.GONE);
root.findViewById(R.id.file_view_publisher_thumbnail).setVisibility(hasPublisherThumbnail ? View.VISIBLE : View.INVISIBLE);
root.findViewById(R.id.file_view_publisher_no_thumbnail).setVisibility(!hasPublisherThumbnail ? View.VISIBLE : View.INVISIBLE);
if (hasPublisher) {
int bgColor = Helper.generateRandomColorForValue(signingChannel.getClaimId());
Helper.setIconViewBackgroundColor(root.findViewById(R.id.file_view_publisher_no_thumbnail), bgColor, false, context);
if (hasPublisherThumbnail && context != null) {
Glide.with(context.getApplicationContext()).load(signingChannel.getThumbnailUrl()).
apply(RequestOptions.circleCropTransform()).into((ImageView) root.findViewById(R.id.file_view_publisher_thumbnail));
}
((TextView) root.findViewById(R.id.file_view_publisher_thumbnail_alpha)).
setText(signingChannel.getName() != null ? signingChannel.getName().substring(1, 2).toUpperCase() : null);
}
String publisherTitle = signingChannel != null ? signingChannel.getTitle() : null;
TextView textPublisherTitle = root.findViewById(R.id.file_view_publisher_title);
textPublisherTitle.setVisibility(Helper.isNullOrEmpty(publisherTitle) ? View.GONE : View.VISIBLE);
textPublisherTitle.setText(publisherTitle);
RecyclerView descTagsList = root.findViewById(R.id.file_view_tag_list); RecyclerView descTagsList = root.findViewById(R.id.file_view_tag_list);
FlexboxLayoutManager flm = new FlexboxLayoutManager(context); FlexboxLayoutManager flm = new FlexboxLayoutManager(context);
descTagsList.setLayoutManager(flm); descTagsList.setLayoutManager(flm);

View file

@ -468,41 +468,89 @@
android:background="@color/divider" android:background="@color/divider"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
android:layout_marginBottom="12dp"
android:layout_height="0.5dp" /> android:layout_height="0.5dp" />
<RelativeLayout <RelativeLayout
android:id="@+id/file_view_publisher_area" android:id="@+id/file_view_publisher_area"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content">
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp">
<LinearLayout <LinearLayout
android:id="@+id/file_view_publisher_name_area" android:id="@+id/file_view_publisher_info_area"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:clickable="true" android:paddingTop="12dp"
android:orientation="vertical"> android:paddingLeft="16dp"
android:paddingBottom="12dp"
android:layout_marginRight="16dp"
android:layout_toLeftOf="@id/file_view_icon_follow_unfollow">
<RelativeLayout
android:id="@+id/file_view_publisher_avatar"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center_vertical"
android:layout_marginRight="16dp"
android:visibility="gone">
<RelativeLayout
android:layout_centerHorizontal="true"
android:background="@drawable/bg_channel_icon"
android:id="@+id/file_view_publisher_no_thumbnail"
android:layout_width="50dp"
android:layout_height="50dp">
<TextView
android:id="@+id/file_view_publisher_thumbnail_alpha"
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/inter"
android:textAllCaps="true"
android:textSize="24sp"
android:textColor="@color/white"
android:textFontWeight="300" />
</RelativeLayout>
<ImageView
android:layout_centerHorizontal="true"
android:id="@+id/file_view_publisher_thumbnail"
android:layout_width="50dp"
android:layout_height="50dp" />
</RelativeLayout>
<TextView <LinearLayout
android:id="@+id/file_view_publisher_name" android:id="@+id/file_view_publisher_name_area"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground" android:layout_gravity="center_vertical"
android:clickable="true" android:orientation="vertical">
android:fontFamily="@font/inter" <TextView
android:textColor="@color/lbryGreen" android:id="@+id/file_view_publisher_title"
android:textFontWeight="600" android:layout_width="wrap_content"
android:textSize="14sp" /> android:layout_height="wrap_content"
android:fontFamily="@font/inter"
android:textFontWeight="300"
android:textSize="14sp"
android:visibility="gone" />
<TextView
android:id="@+id/file_view_publisher_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/inter"
android:textColor="@color/lbryGreen"
android:textFontWeight="600"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout> </LinearLayout>
<io.lbry.browser.ui.controls.SolidIconView <io.lbry.browser.ui.controls.SolidIconView
android:id="@+id/file_view_icon_follow_unfollow" android:id="@+id/file_view_icon_follow_unfollow"
android:clickable="true" android:clickable="true"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_width="24dp" android:layout_width="24dp"
android:layout_height="24dp" android:layout_height="24dp"
android:layout_marginRight="16dp"
android:text="@string/fa_heart" android:text="@string/fa_heart"
android:textColor="@color/red" android:textColor="@color/red"
android:textSize="20dp" /> android:textSize="20dp" />
@ -511,7 +559,6 @@
<View <View
android:background="@color/divider" android:background="@color/divider"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_marginTop="12dp"
android:layout_marginBottom="12dp" android:layout_marginBottom="12dp"
android:layout_height="0.5dp" /> android:layout_height="0.5dp" />