1
0
mirror of https://github.com/KokaKiwi/BarInsta synced 2024-11-25 08:07:29 +00:00

change waterfall layout

location is bugged, does affect visually but should not affect use
This commit is contained in:
Austin Huang 2021-07-10 17:15:25 -04:00
parent e6594e086c
commit e78135f85a
No known key found for this signature in database
GPG Key ID: 84C23AA04587A91F
10 changed files with 241 additions and 377 deletions

View File

@ -1,39 +1,45 @@
package awais.instagrabber.adapters.viewholder.feed; package awais.instagrabber.adapters.viewholder.feed;
import android.text.method.LinkMovementMethod; import android.graphics.drawable.Drawable;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.transition.TransitionManager; import android.transition.TransitionManager;
import android.util.Log;
import android.view.View; import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout; import android.widget.RelativeLayout;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import awais.instagrabber.R;
import awais.instagrabber.adapters.FeedAdapterV2; import awais.instagrabber.adapters.FeedAdapterV2;
import awais.instagrabber.databinding.ItemFeedBottomBinding; import awais.instagrabber.customviews.VerticalImageSpan;
import awais.instagrabber.databinding.ItemFeedTopBinding; import awais.instagrabber.databinding.ItemFeedTopBinding;
import awais.instagrabber.databinding.LayoutPostViewBottomBinding;
import awais.instagrabber.models.enums.MediaItemType; import awais.instagrabber.models.enums.MediaItemType;
import awais.instagrabber.repositories.responses.Caption; import awais.instagrabber.repositories.responses.Caption;
import awais.instagrabber.repositories.responses.Location; import awais.instagrabber.repositories.responses.Location;
import awais.instagrabber.repositories.responses.Media; import awais.instagrabber.repositories.responses.Media;
import awais.instagrabber.repositories.responses.User; import awais.instagrabber.repositories.responses.User;
import awais.instagrabber.utils.TextUtils; import awais.instagrabber.utils.TextUtils;
import awais.instagrabber.utils.Utils;
import static android.text.TextUtils.TruncateAt.END; import static android.text.TextUtils.TruncateAt.END;
public abstract class FeedItemViewHolder extends RecyclerView.ViewHolder { public abstract class FeedItemViewHolder extends RecyclerView.ViewHolder {
public static final int MAX_LINES_COLLAPSED = 5; public static final int MAX_LINES_COLLAPSED = 5;
private final ItemFeedTopBinding topBinding; private final ItemFeedTopBinding topBinding;
private final ItemFeedBottomBinding bottomBinding; private final LayoutPostViewBottomBinding bottomBinding;
private final ViewGroup bottomFrame;
private final FeedAdapterV2.FeedItemCallback feedItemCallback; private final FeedAdapterV2.FeedItemCallback feedItemCallback;
public FeedItemViewHolder(@NonNull final View root, public FeedItemViewHolder(@NonNull final ViewGroup root,
final ItemFeedTopBinding topBinding,
final ItemFeedBottomBinding bottomBinding,
final FeedAdapterV2.FeedItemCallback feedItemCallback) { final FeedAdapterV2.FeedItemCallback feedItemCallback) {
super(root); super(root);
this.topBinding = topBinding; this.bottomFrame = root;
this.bottomBinding = bottomBinding; this.topBinding = ItemFeedTopBinding.bind(root);
topBinding.title.setMovementMethod(new LinkMovementMethod()); this.bottomBinding = LayoutPostViewBottomBinding.bind(root);
this.feedItemCallback = feedItemCallback; this.feedItemCallback = feedItemCallback;
} }
@ -42,33 +48,35 @@ public abstract class FeedItemViewHolder extends RecyclerView.ViewHolder {
return; return;
} }
setupProfilePic(media); setupProfilePic(media);
setupLocation(media); bottomBinding.date.setText(media.getDate());
bottomBinding.tvPostDate.setText(media.getDate());
setupComments(media); setupComments(media);
setupCaption(media); setupCaption(media);
setupActions(media);
if (media.getType() != MediaItemType.MEDIA_TYPE_SLIDER) { if (media.getType() != MediaItemType.MEDIA_TYPE_SLIDER) {
bottomBinding.btnDownload.setOnClickListener(v -> bottomBinding.download.setOnClickListener(v ->
feedItemCallback.onDownloadClick(media, -1, null) feedItemCallback.onDownloadClick(media, -1, null)
); );
} }
bindItem(media); bindItem(media);
bottomFrame.post(() -> setupLocation(media));
} }
private void setupComments(@NonNull final Media feedModel) { private void setupComments(@NonNull final Media feedModel) {
final long commentsCount = feedModel.getCommentCount(); final long commentsCount = feedModel.getCommentCount();
bottomBinding.commentsCount.setText(String.valueOf(commentsCount)); bottomBinding.commentsCount.setText(String.valueOf(commentsCount));
bottomBinding.btnComments.setOnClickListener(v -> feedItemCallback.onCommentsClick(feedModel)); bottomBinding.comment.setOnClickListener(v -> feedItemCallback.onCommentsClick(feedModel));
} }
private void setupProfilePic(@NonNull final Media media) { private void setupProfilePic(@NonNull final Media media) {
final User user = media.getUser(); final User user = media.getUser();
if (user == null) { if (user == null) {
topBinding.ivProfilePic.setVisibility(View.GONE); topBinding.profilePic.setVisibility(View.GONE);
topBinding.title.setVisibility(View.GONE); topBinding.title.setVisibility(View.GONE);
topBinding.subtitle.setVisibility(View.GONE);
return; return;
} }
topBinding.ivProfilePic.setOnClickListener(v -> feedItemCallback.onProfilePicClick(media, topBinding.ivProfilePic)); topBinding.profilePic.setOnClickListener(v -> feedItemCallback.onProfilePicClick(media));
topBinding.ivProfilePic.setImageURI(user.getProfilePicUrl()); topBinding.profilePic.setImageURI(user.getProfilePicUrl());
setupTitle(media); setupTitle(media);
} }
@ -78,68 +86,97 @@ public abstract class FeedItemViewHolder extends RecyclerView.ViewHolder {
// spannableString.setSpan(new CommentMentionClickSpan(), 0, titleLen, 0); // spannableString.setSpan(new CommentMentionClickSpan(), 0, titleLen, 0);
final User user = media.getUser(); final User user = media.getUser();
if (user == null) return; if (user == null) return;
final String title = "@" + user.getUsername(); setUsername(user);
topBinding.title.setText(title); topBinding.title.setOnClickListener(v -> feedItemCallback.onNameClick(media));
topBinding.title.setOnClickListener(v -> feedItemCallback.onNameClick(media, topBinding.ivProfilePic)); final String fullName = user.getFullName();
if (TextUtils.isEmpty(fullName)) {
topBinding.subtitle.setVisibility(View.GONE);
} else {
topBinding.subtitle.setVisibility(View.VISIBLE);
topBinding.subtitle.setText(fullName);
}
topBinding.subtitle.setOnClickListener(v -> feedItemCallback.onNameClick(media));
} }
private void setupCaption(final Media media) { private void setupCaption(final Media media) {
bottomBinding.viewerCaption.clearOnMentionClickListeners(); bottomBinding.caption.clearOnMentionClickListeners();
bottomBinding.viewerCaption.clearOnHashtagClickListeners(); bottomBinding.caption.clearOnHashtagClickListeners();
bottomBinding.viewerCaption.clearOnURLClickListeners(); bottomBinding.caption.clearOnURLClickListeners();
bottomBinding.viewerCaption.clearOnEmailClickListeners(); bottomBinding.caption.clearOnEmailClickListeners();
final Caption caption = media.getCaption(); final Caption caption = media.getCaption();
if (caption == null) { if (caption == null) {
bottomBinding.viewerCaption.setVisibility(View.GONE); bottomBinding.caption.setVisibility(View.GONE);
return; return;
} }
final CharSequence postCaption = caption.getText(); final CharSequence postCaption = caption.getText();
final boolean captionEmpty = TextUtils.isEmpty(postCaption); final boolean captionEmpty = TextUtils.isEmpty(postCaption);
bottomBinding.viewerCaption.setVisibility(captionEmpty ? View.GONE : View.VISIBLE); bottomBinding.caption.setVisibility(captionEmpty ? View.GONE : View.VISIBLE);
if (captionEmpty) return; if (captionEmpty) return;
bottomBinding.viewerCaption.setText(postCaption); bottomBinding.caption.setText(postCaption);
bottomBinding.viewerCaption.setMaxLines(MAX_LINES_COLLAPSED); bottomBinding.caption.setMaxLines(MAX_LINES_COLLAPSED);
bottomBinding.viewerCaption.setEllipsize(END); bottomBinding.caption.setEllipsize(END);
bottomBinding.viewerCaption.setOnClickListener(v -> bottomBinding.getRoot().post(() -> { bottomBinding.caption.setOnClickListener(v -> bottomFrame.post(() -> {
TransitionManager.beginDelayedTransition(bottomBinding.getRoot()); TransitionManager.beginDelayedTransition(bottomFrame);
if (bottomBinding.viewerCaption.getMaxLines() == MAX_LINES_COLLAPSED) { if (bottomBinding.caption.getMaxLines() == MAX_LINES_COLLAPSED) {
bottomBinding.viewerCaption.setMaxLines(Integer.MAX_VALUE); bottomBinding.caption.setMaxLines(Integer.MAX_VALUE);
bottomBinding.viewerCaption.setEllipsize(null); bottomBinding.caption.setEllipsize(null);
return; return;
} }
bottomBinding.viewerCaption.setMaxLines(MAX_LINES_COLLAPSED); bottomBinding.caption.setMaxLines(MAX_LINES_COLLAPSED);
bottomBinding.viewerCaption.setEllipsize(END); bottomBinding.caption.setEllipsize(END);
})); }));
bottomBinding.viewerCaption.addOnMentionClickListener(autoLinkItem -> feedItemCallback.onMentionClick(autoLinkItem.getOriginalText())); bottomBinding.caption.addOnMentionClickListener(autoLinkItem -> feedItemCallback.onMentionClick(autoLinkItem.getOriginalText()));
bottomBinding.viewerCaption.addOnHashtagListener(autoLinkItem -> feedItemCallback.onHashtagClick(autoLinkItem.getOriginalText())); bottomBinding.caption.addOnHashtagListener(autoLinkItem -> feedItemCallback.onHashtagClick(autoLinkItem.getOriginalText()));
bottomBinding.viewerCaption.addOnEmailClickListener(autoLinkItem -> feedItemCallback.onEmailClick(autoLinkItem.getOriginalText())); bottomBinding.caption.addOnEmailClickListener(autoLinkItem -> feedItemCallback.onEmailClick(autoLinkItem.getOriginalText()));
bottomBinding.viewerCaption.addOnURLClickListener(autoLinkItem -> feedItemCallback.onURLClick(autoLinkItem.getOriginalText())); bottomBinding.caption.addOnURLClickListener(autoLinkItem -> feedItemCallback.onURLClick(autoLinkItem.getOriginalText()));
} }
private void setupLocation(@NonNull final Media media) { private void setupLocation(@NonNull final Media media) {
final Location location = media.getLocation(); final Location location = media.getLocation();
if (location == null) { if (location == null) {
topBinding.location.setVisibility(View.GONE); topBinding.location.setVisibility(View.GONE);
topBinding.title.setLayoutParams(new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT
));
} else { } else {
final String locationName = location.getName(); final String locationName = location.getName();
if (TextUtils.isEmpty(locationName)) { if (TextUtils.isEmpty(locationName)) {
topBinding.location.setVisibility(View.GONE); topBinding.location.setVisibility(View.GONE);
topBinding.title.setLayoutParams(new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT
));
} else { } else {
topBinding.location.setVisibility(View.VISIBLE); topBinding.location.setVisibility(View.VISIBLE);
topBinding.location.setText(locationName); topBinding.location.setText(locationName);
topBinding.title.setLayoutParams(new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT
));
topBinding.location.setOnClickListener(v -> feedItemCallback.onLocationClick(media)); topBinding.location.setOnClickListener(v -> feedItemCallback.onLocationClick(media));
} }
} }
} }
private void setupActions(@NonNull final Media media) {
// temporary - to be set up later
bottomBinding.like.setVisibility(View.GONE);
bottomBinding.save.setVisibility(View.GONE);
bottomBinding.translate.setVisibility(View.GONE);
bottomBinding.share.setVisibility(View.GONE);
}
private void setUsername(final User user) {
final SpannableStringBuilder sb = new SpannableStringBuilder(user.getUsername());
final int drawableSize = Utils.convertDpToPx(24);
if (user.isVerified()) {
final Drawable verifiedDrawable = itemView.getResources().getDrawable(R.drawable.verified);
VerticalImageSpan verifiedSpan = null;
if (verifiedDrawable != null) {
final Drawable drawable = verifiedDrawable.mutate();
drawable.setBounds(0, 0, drawableSize, drawableSize);
verifiedSpan = new VerticalImageSpan(drawable);
}
try {
if (verifiedSpan != null) {
sb.append(" ");
sb.setSpan(verifiedSpan, sb.length() - 1, sb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
} catch (Exception e) {
Log.e("FeedItemViewHolder", "setUsername: ", e);
}
}
topBinding.title.setText(sb);
}
public abstract void bindItem(final Media media); public abstract void bindItem(final Media media);
} }

View File

@ -16,6 +16,7 @@ import com.facebook.imagepipeline.request.ImageRequestBuilder;
import awais.instagrabber.adapters.FeedAdapterV2; import awais.instagrabber.adapters.FeedAdapterV2;
import awais.instagrabber.databinding.ItemFeedPhotoBinding; import awais.instagrabber.databinding.ItemFeedPhotoBinding;
import awais.instagrabber.databinding.LayoutPostViewBottomBinding;
import awais.instagrabber.repositories.responses.Media; import awais.instagrabber.repositories.responses.Media;
import awais.instagrabber.utils.ResponseBodyUtils; import awais.instagrabber.utils.ResponseBodyUtils;
import awais.instagrabber.utils.TextUtils; import awais.instagrabber.utils.TextUtils;
@ -28,10 +29,11 @@ public class FeedPhotoViewHolder extends FeedItemViewHolder {
public FeedPhotoViewHolder(@NonNull final ItemFeedPhotoBinding binding, public FeedPhotoViewHolder(@NonNull final ItemFeedPhotoBinding binding,
final FeedAdapterV2.FeedItemCallback feedItemCallback) { final FeedAdapterV2.FeedItemCallback feedItemCallback) {
super(binding.getRoot(), binding.itemFeedTop, binding.itemFeedBottom, feedItemCallback); super(binding.getRoot(), feedItemCallback);
this.binding = binding; this.binding = binding;
this.feedItemCallback = feedItemCallback; this.feedItemCallback = feedItemCallback;
binding.itemFeedBottom.btnViews.setVisibility(View.GONE); final LayoutPostViewBottomBinding bottom = LayoutPostViewBottomBinding.bind(binding.getRoot());
bottom.viewsCount.setVisibility(View.GONE);
// binding.itemFeedBottom.btnMute.setVisibility(View.GONE); // binding.itemFeedBottom.btnMute.setVisibility(View.GONE);
binding.imageViewer.setAllowTouchInterceptionWhileZoomed(false); binding.imageViewer.setAllowTouchInterceptionWhileZoomed(false);
final GenericDraweeHierarchy hierarchy = new GenericDraweeHierarchyBuilder(itemView.getContext().getResources()) final GenericDraweeHierarchy hierarchy = new GenericDraweeHierarchyBuilder(itemView.getContext().getResources())

View File

@ -13,6 +13,7 @@ import awais.instagrabber.adapters.FeedAdapterV2;
import awais.instagrabber.adapters.SliderCallbackAdapter; import awais.instagrabber.adapters.SliderCallbackAdapter;
import awais.instagrabber.adapters.SliderItemsAdapter; import awais.instagrabber.adapters.SliderItemsAdapter;
import awais.instagrabber.databinding.ItemFeedSliderBinding; import awais.instagrabber.databinding.ItemFeedSliderBinding;
import awais.instagrabber.databinding.LayoutPostViewBottomBinding;
import awais.instagrabber.repositories.responses.Media; import awais.instagrabber.repositories.responses.Media;
import awais.instagrabber.utils.NumberUtils; import awais.instagrabber.utils.NumberUtils;
import awais.instagrabber.utils.Utils; import awais.instagrabber.utils.Utils;
@ -23,14 +24,16 @@ public class FeedSliderViewHolder extends FeedItemViewHolder {
private final ItemFeedSliderBinding binding; private final ItemFeedSliderBinding binding;
private final FeedAdapterV2.FeedItemCallback feedItemCallback; private final FeedAdapterV2.FeedItemCallback feedItemCallback;
private final LayoutPostViewBottomBinding bottom;
public FeedSliderViewHolder(@NonNull final ItemFeedSliderBinding binding, public FeedSliderViewHolder(@NonNull final ItemFeedSliderBinding binding,
final FeedAdapterV2.FeedItemCallback feedItemCallback) { final FeedAdapterV2.FeedItemCallback feedItemCallback) {
super(binding.getRoot(), binding.itemFeedTop, binding.itemFeedBottom, feedItemCallback); super(binding.getRoot(), feedItemCallback);
this.binding = binding; this.binding = binding;
this.feedItemCallback = feedItemCallback; this.feedItemCallback = feedItemCallback;
binding.itemFeedBottom.btnViews.setVisibility(View.GONE); bottom = LayoutPostViewBottomBinding.bind(binding.getRoot());
// binding.itemFeedBottom.btnMute.setVisibility(View.GONE); bottom.viewsCount.setVisibility(View.GONE);
// bottom.btnMute.setVisibility(View.GONE);
final ViewGroup.LayoutParams layoutParams = binding.mediaList.getLayoutParams(); final ViewGroup.LayoutParams layoutParams = binding.mediaList.getLayoutParams();
layoutParams.height = Utils.displayMetrics.widthPixels + 1; layoutParams.height = Utils.displayMetrics.widthPixels + 1;
binding.mediaList.setLayoutParams(layoutParams); binding.mediaList.setLayoutParams(layoutParams);
@ -59,14 +62,14 @@ public class FeedSliderViewHolder extends FeedItemViewHolder {
final String text = (position + 1) + "/" + sliderItemLen; final String text = (position + 1) + "/" + sliderItemLen;
binding.mediaCounter.setText(text); binding.mediaCounter.setText(text);
setDimensions(binding.mediaList, sliderItems.get(position)); setDimensions(binding.mediaList, sliderItems.get(position));
binding.itemFeedBottom.btnDownload.setOnClickListener(v -> bottom.download.setOnClickListener(v ->
feedItemCallback.onDownloadClick(feedModel, position, binding.itemFeedBottom.btnDownload) feedItemCallback.onDownloadClick(feedModel, position, bottom.download)
); );
} }
}); });
setDimensions(binding.mediaList, sliderItems.get(0)); setDimensions(binding.mediaList, sliderItems.get(0));
binding.itemFeedBottom.btnDownload.setOnClickListener(v -> bottom.download.setOnClickListener(v ->
feedItemCallback.onDownloadClick(feedModel, 0, binding.itemFeedBottom.btnDownload) feedItemCallback.onDownloadClick(feedModel, 0, bottom.download)
); );
adapter.submitList(sliderItems); adapter.submitList(sliderItems);
} }

View File

@ -3,10 +3,12 @@ package awais.instagrabber.adapters.viewholder.feed;
import android.content.Context; import android.content.Context;
import android.os.Handler; import android.os.Handler;
import android.os.Looper; import android.os.Looper;
import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.constraintlayout.widget.ConstraintLayout;
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory; import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
import com.google.android.exoplayer2.upstream.cache.CacheDataSourceFactory; import com.google.android.exoplayer2.upstream.cache.CacheDataSourceFactory;
@ -14,13 +16,17 @@ import com.google.android.exoplayer2.upstream.cache.SimpleCache;
import java.util.List; import java.util.List;
import awais.instagrabber.R;
import awais.instagrabber.adapters.FeedAdapterV2; import awais.instagrabber.adapters.FeedAdapterV2;
import awais.instagrabber.customviews.VideoPlayerCallbackAdapter; import awais.instagrabber.customviews.VideoPlayerCallbackAdapter;
import awais.instagrabber.customviews.VideoPlayerViewHelper; import awais.instagrabber.customviews.VideoPlayerViewHelper;
import awais.instagrabber.databinding.ItemFeedVideoBinding; import awais.instagrabber.databinding.ItemFeedVideoBinding;
import awais.instagrabber.databinding.LayoutPostViewBottomBinding;
import awais.instagrabber.databinding.LayoutVideoPlayerWithThumbnailBinding;
import awais.instagrabber.fragments.settings.PreferenceKeys; import awais.instagrabber.fragments.settings.PreferenceKeys;
import awais.instagrabber.repositories.responses.Media; import awais.instagrabber.repositories.responses.Media;
import awais.instagrabber.repositories.responses.MediaCandidate; import awais.instagrabber.repositories.responses.MediaCandidate;
import awais.instagrabber.utils.NullSafePair;
import awais.instagrabber.utils.NumberUtils; import awais.instagrabber.utils.NumberUtils;
import awais.instagrabber.utils.ResponseBodyUtils; import awais.instagrabber.utils.ResponseBodyUtils;
import awais.instagrabber.utils.Utils; import awais.instagrabber.utils.Utils;
@ -35,6 +41,7 @@ public class FeedVideoViewHolder extends FeedItemViewHolder {
private final Handler handler; private final Handler handler;
private final DefaultDataSourceFactory dataSourceFactory; private final DefaultDataSourceFactory dataSourceFactory;
private final LayoutPostViewBottomBinding bottom;
private CacheDataSourceFactory cacheDataSourceFactory; private CacheDataSourceFactory cacheDataSourceFactory;
private Media media; private Media media;
@ -47,10 +54,11 @@ public class FeedVideoViewHolder extends FeedItemViewHolder {
public FeedVideoViewHolder(@NonNull final ItemFeedVideoBinding binding, public FeedVideoViewHolder(@NonNull final ItemFeedVideoBinding binding,
final FeedAdapterV2.FeedItemCallback feedItemCallback) { final FeedAdapterV2.FeedItemCallback feedItemCallback) {
super(binding.getRoot(), binding.itemFeedTop, binding.itemFeedBottom, feedItemCallback); super(binding.getRoot(), feedItemCallback);
bottom = LayoutPostViewBottomBinding.bind(binding.getRoot());
this.binding = binding; this.binding = binding;
this.feedItemCallback = feedItemCallback; this.feedItemCallback = feedItemCallback;
binding.itemFeedBottom.btnViews.setVisibility(View.VISIBLE); bottom.viewsCount.setVisibility(View.VISIBLE);
handler = new Handler(Looper.getMainLooper()); handler = new Handler(Looper.getMainLooper());
final Context context = binding.getRoot().getContext(); final Context context = binding.getRoot().getContext();
dataSourceFactory = new DefaultDataSourceFactory(context, "instagram"); dataSourceFactory = new DefaultDataSourceFactory(context, "instagram");
@ -64,7 +72,19 @@ public class FeedVideoViewHolder extends FeedItemViewHolder {
public void bindItem(final Media media) { public void bindItem(final Media media) {
// Log.d(TAG, "Binding post: " + feedModel.getPostId()); // Log.d(TAG, "Binding post: " + feedModel.getPostId());
this.media = media; this.media = media;
binding.itemFeedBottom.tvVideoViews.setText(String.valueOf(media.getViewCount())); final String viewCount = itemView.getResources().getQuantityString(R.plurals.views_count, (int) media.getViewCount(), media.getViewCount());
bottom.viewsCount.setText(viewCount);
final LayoutVideoPlayerWithThumbnailBinding videoPost =
LayoutVideoPlayerWithThumbnailBinding.inflate(LayoutInflater.from(itemView.getContext()), binding.getRoot(), false);
final ConstraintLayout.LayoutParams layoutParams = (ConstraintLayout.LayoutParams) videoPost.getRoot().getLayoutParams();
final NullSafePair<Integer, Integer> widthHeight = NumberUtils.calculateWidthHeight(media.getOriginalHeight(),
media.getOriginalWidth(),
(int) (Utils.displayMetrics.heightPixels * 0.8),
Utils.displayMetrics.widthPixels);
layoutParams.width = ConstraintLayout.LayoutParams.MATCH_PARENT;
layoutParams.height = widthHeight.second;
final View postView = videoPost.getRoot();
binding.postContainer.addView(postView);
final float vol = settingsHelper.getBoolean(PreferenceKeys.MUTED_VIDEOS) ? 0f : 1f; final float vol = settingsHelper.getBoolean(PreferenceKeys.MUTED_VIDEOS) ? 0f : 1f;
final VideoPlayerViewHelper.VideoPlayerCallback videoPlayerCallback = new VideoPlayerCallbackAdapter() { final VideoPlayerViewHelper.VideoPlayerCallback videoPlayerCallback = new VideoPlayerCallbackAdapter() {
@ -75,12 +95,12 @@ public class FeedVideoViewHolder extends FeedItemViewHolder {
@Override @Override
public void onPlayerViewLoaded() { public void onPlayerViewLoaded() {
final ViewGroup.LayoutParams layoutParams = binding.videoPost.playerView.getLayoutParams(); final ViewGroup.LayoutParams layoutParams = videoPost.playerView.getLayoutParams();
final int requiredWidth = Utils.displayMetrics.widthPixels; final int requiredWidth = Utils.displayMetrics.widthPixels;
final int resultingHeight = NumberUtils.getResultingHeight(requiredWidth, media.getOriginalHeight(), media.getOriginalWidth()); final int resultingHeight = NumberUtils.getResultingHeight(requiredWidth, media.getOriginalHeight(), media.getOriginalWidth());
layoutParams.width = requiredWidth; layoutParams.width = requiredWidth;
layoutParams.height = resultingHeight; layoutParams.height = resultingHeight;
binding.videoPost.playerView.requestLayout(); videoPost.playerView.requestLayout();
} }
}; };
final float aspectRatio = (float) media.getOriginalWidth() / media.getOriginalHeight(); final float aspectRatio = (float) media.getOriginalWidth() / media.getOriginalHeight();
@ -91,7 +111,7 @@ public class FeedVideoViewHolder extends FeedItemViewHolder {
videoUrl = videoVersion.getUrl(); videoUrl = videoVersion.getUrl();
} }
final VideoPlayerViewHelper videoPlayerViewHelper = new VideoPlayerViewHelper(binding.getRoot().getContext(), final VideoPlayerViewHelper videoPlayerViewHelper = new VideoPlayerViewHelper(binding.getRoot().getContext(),
binding.videoPost, videoPost,
videoUrl, videoUrl,
vol, vol,
aspectRatio, aspectRatio,
@ -99,11 +119,11 @@ public class FeedVideoViewHolder extends FeedItemViewHolder {
false, false,
// null, // null,
videoPlayerCallback); videoPlayerCallback);
binding.videoPost.thumbnail.post(() -> { videoPost.thumbnail.post(() -> {
if (media.getOriginalHeight() > 0.8 * Utils.displayMetrics.heightPixels) { if (media.getOriginalHeight() > 0.8 * Utils.displayMetrics.heightPixels) {
final ViewGroup.LayoutParams layoutParams = binding.videoPost.thumbnail.getLayoutParams(); final ViewGroup.LayoutParams tLayoutParams = videoPost.thumbnail.getLayoutParams();
layoutParams.height = (int) (0.8 * Utils.displayMetrics.heightPixels); tLayoutParams.height = (int) (0.8 * Utils.displayMetrics.heightPixels);
binding.videoPost.thumbnail.requestLayout(); videoPost.thumbnail.requestLayout();
} }
}); });
} }
@ -118,8 +138,8 @@ public class FeedVideoViewHolder extends FeedItemViewHolder {
// if (player != null) { // if (player != null) {
// player.release(); // player.release();
// } // }
// if (binding.videoPost.root.getDisplayedChild() == 1) { // if (videoPost.root.getDisplayedChild() == 1) {
// binding.videoPost.root.showPrevious(); // videoPost.root.showPrevious();
// } // }
// } // }
// //

View File

@ -1,113 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="@+id/top_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:id="@+id/btnComments"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="?android:selectableItemBackground"
android:gravity="center"
android:orientation="horizontal"
android:padding="4dp">
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="4dp"
app:srcCompat="@drawable/ic_outline_comments_24"
app:tint="?android:textColorPrimary" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/commentsCount"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:textAppearance="?attr/textAppearanceButton"
tools:text="690000" />
</LinearLayout>
<LinearLayout
android:id="@+id/btnViews"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="horizontal"
android:padding="4dp">
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="4dp"
app:srcCompat="@drawable/ic_outline_views_24"
app:tint="?android:textColorPrimary" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tvVideoViews"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:textAppearance="?attr/textAppearanceButton"
tools:text="690000" />
</LinearLayout>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tvPostDate"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:maxLines="1"
android:padding="8dp"
android:textAppearance="@style/TextAppearance.AppCompat.Caption"
tools:text="2020-01-01 12:00:00" />
<!--<androidx.appcompat.widget.AppCompatImageView-->
<!-- android:id="@+id/btnMute"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="match_parent"-->
<!-- android:background="?selectableItemBackgroundBorderless"-->
<!-- android:padding="4dp"-->
<!-- android:visibility="gone"-->
<!-- app:srcCompat="@drawable/ic_volume_up_24"-->
<!-- app:tint="?android:textColorPrimary"-->
<!-- tools:visibility="visible" />-->
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/btnDownload"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="?selectableItemBackgroundBorderless"
android:padding="4dp"
app:srcCompat="@drawable/ic_download"
app:tint="?android:textColorPrimary" />
</LinearLayout>
<awais.instagrabber.customviews.RamboTextViewV2
android:id="@+id/viewerCaption"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:selectableItemBackground"
android:clickable="true"
android:clipToPadding="false"
android:ellipsize="end"
android:focusable="true"
android:maxLines="5"
android:paddingStart="8dp"
android:paddingLeft="8dp"
android:paddingEnd="8dp"
android:paddingRight="8dp"
android:paddingBottom="8dp"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
tools:text="Bottom text with hashtags etc." />
</LinearLayout>

View File

@ -1,13 +1,11 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content">
android:orientation="vertical">
<include <include layout="@layout/item_feed_top" />
android:id="@+id/item_feed_top"
layout="@layout/item_feed_top" />
<awais.instagrabber.customviews.drawee.ZoomableDraweeView <awais.instagrabber.customviews.drawee.ZoomableDraweeView
android:id="@+id/imageViewer" android:id="@+id/imageViewer"
@ -17,9 +15,9 @@
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
app:actualImageScaleType="fitCenter" app:actualImageScaleType="fitCenter"
app:viewAspectRatio="1" /> app:viewAspectRatio="1"
app:layout_constraintTop_toBottomOf="@id/top_barrier"
app:layout_constraintBottom_toTopOf="@id/buttons_top_barrier"/>
<include <include layout="@layout/layout_post_view_bottom" />
android:id="@+id/item_feed_bottom" </androidx.constraintlayout.widget.ConstraintLayout>
layout="@layout/item_feed_bottom" />
</LinearLayout>

View File

@ -1,18 +1,18 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content">
android:orientation="vertical">
<include <include layout="@layout/item_feed_top" />
android:id="@+id/item_feed_top"
layout="@layout/item_feed_top" />
<FrameLayout <FrameLayout
android:id="@+id/post_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/top_barrier"
app:layout_constraintBottom_toTopOf="@id/buttons_top_barrier">
<androidx.viewpager2.widget.ViewPager2 <androidx.viewpager2.widget.ViewPager2
android:id="@+id/media_list" android:id="@+id/media_list"
@ -39,7 +39,5 @@
android:textColor="@android:color/white" /> android:textColor="@android:color/white" />
</FrameLayout> </FrameLayout>
<include <include layout="@layout/layout_post_view_bottom" />
android:id="@+id/item_feed_bottom" </androidx.constraintlayout.widget.ConstraintLayout>
layout="@layout/item_feed_bottom" />
</LinearLayout>

View File

@ -1,63 +1,86 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container" tools:parentTag="androidx.constraintlayout.widget.ConstraintLayout">
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="8dp">
<com.facebook.drawee.view.SimpleDraweeView <awais.instagrabber.customviews.ProfilePicView
android:id="@+id/ivProfilePic" android:id="@+id/profile_pic"
android:layout_width="@dimen/profile_pic_size_regular" android:layout_width="wrap_content"
android:layout_height="@dimen/profile_pic_size_regular" android:layout_height="wrap_content"
android:background="?selectableItemBackgroundBorderless" android:layout_margin="12dp"
app:roundAsCircle="true" /> android:transitionName="profile_pic"
app:layout_constraintBottom_toTopOf="@id/top_barrier"
app:layout_constraintEnd_toStartOf="@id/title"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:size="regular" />
<RelativeLayout <androidx.appcompat.widget.AppCompatTextView
android:id="@+id/infoContainer" android:id="@+id/title"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:layout_weight="1" android:ellipsize="marquee"
android:animateLayoutChanges="true" android:singleLine="true"
android:background="@null" android:textAppearance="@style/TextAppearance.MaterialComponents.Headline6"
android:gravity="center" app:layout_constrainedWidth="true"
android:orientation="vertical" app:layout_constraintBottom_toTopOf="@id/subtitle"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/profile_pic"
app:layout_constraintTop_toTopOf="@id/profile_pic"
tools:text="Username Username Username" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/subtitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:ellipsize="end"
android:singleLine="true"
android:textAppearance="@style/TextAppearance.MaterialComponents.Subtitle1"
app:layout_constraintBottom_toBottomOf="@id/profile_pic"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@id/title"
app:layout_constraintTop_toBottomOf="@id/title"
tools:text="Full name Full name Full name Full name Full name Full name Full name "
tools:visibility="gone" />
<androidx.constraintlayout.widget.Barrier
android:id="@+id/top_barrier"
android:layout_width="0dp"
android:layout_height="0dp"
app:barrierAllowsGoneWidgets="true"
app:barrierDirection="bottom"/>
<com.google.android.material.button.MaterialButton
android:id="@+id/location"
style="?borderlessButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:elevation="0dp"
android:ellipsize="end"
android:insetTop="0dp"
android:insetBottom="0dp"
android:maxWidth="200dp"
android:maxLines="1"
android:minHeight="32dp"
android:paddingStart="8dp" android:paddingStart="8dp"
android:paddingLeft="8dp"
android:paddingEnd="8dp" android:paddingEnd="8dp"
android:paddingRight="8dp" android:textAlignment="viewStart"
android:weightSum="2"> android:textAllCaps="false"
android:textColor="@android:color/white"
<androidx.appcompat.widget.AppCompatTextView android:visibility="gone"
android:id="@+id/title" app:backgroundTint="@color/black_a50"
android:layout_width="match_parent" app:elevation="0dp"
android:layout_height="wrap_content" app:icon="@drawable/ic_round_location_on_24"
android:gravity="center_vertical" app:iconSize="16dp"
android:textAppearance="@style/TextAppearance.AppCompat.Medium" app:iconTint="@color/white"
tools:text="username" /> app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/top_barrier"
<androidx.appcompat.widget.AppCompatTextView app:rippleColor="@color/grey_600"
android:id="@+id/location" tools:text="Location, Location, Location, Location, "
android:layout_width="match_parent" tools:visibility="visible" />
android:layout_height="wrap_content" </merge>
android:layout_below="@+id/title"
android:ellipsize="end"
android:gravity="center_vertical"
android:maxLines="1"
android:textAppearance="@style/TextAppearance.AppCompat.Subhead"
android:textSize="15sp"
android:visibility="visible"
tools:text="location" />
</RelativeLayout>
<!--<androidx.appcompat.widget.AppCompatImageView-->
<!-- android:id="@+id/viewStoryPost"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="match_parent"-->
<!-- android:layout_gravity="center"-->
<!-- android:background="?selectableItemBackgroundBorderless"-->
<!-- app:srcCompat="@drawable/ic_open_in_new_24"-->
<!-- app:tint="?android:textColorPrimary" />-->
</LinearLayout>

View File

@ -1,19 +1,20 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/videoHolder" android:id="@+id/videoHolder"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content">
android:orientation="vertical">
<include <include layout="@layout/item_feed_top" />
android:id="@+id/item_feed_top"
layout="@layout/item_feed_top" />
<include <FrameLayout
android:id="@+id/video_post" android:id="@+id/post_container"
layout="@layout/layout_video_player_with_thumbnail" /> android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="@id/buttons_top_barrier"
app:layout_constraintTop_toBottomOf="@id/top_barrier"
tools:layout_height="100dp" />
<include <include layout="@layout/layout_post_view_bottom" />
android:id="@+id/item_feed_bottom" </androidx.constraintlayout.widget.ConstraintLayout>
layout="@layout/item_feed_bottom" />
</LinearLayout>

View File

@ -1,105 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?attr/actionBarSize"
android:animateLayoutChanges="true"
android:orientation="vertical"
android:weightSum="3.2">
<include
android:id="@+id/topPanel"
layout="@layout/item_feed_top" />
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1.9">
<awais.instagrabber.customviews.helpers.NestedScrollableHost
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/mediaViewPager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</awais.instagrabber.customviews.helpers.NestedScrollableHost>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/mediaCounter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|bottom"
android:background="@drawable/rounder_corner_semi_black_bg"
android:gravity="center"
android:padding="5dp"
android:textAppearance="@style/TextAppearance.AppCompat.Caption"
android:textColor="@android:color/white"
android:visibility="gone" />
<ProgressBar
android:id="@+id/progressView"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_gravity="center"
android:visibility="gone" />
<!-- Removing for now, will add in later versions -->
<!--<androidx.appcompat.widget.AppCompatImageView-->
<!-- android:id="@+id/ivToggleFullScreen"-->
<!-- android:layout_width="48dp"-->
<!-- android:layout_height="48dp"-->
<!-- android:layout_gravity="end|top"-->
<!-- android:background="?selectableItemBackgroundBorderless"-->
<!-- android:padding="4dp"-->
<!-- app:srcCompat="@drawable/ic_fullscreen"-->
<!-- app:tint="?android:textColorPrimary" />-->
</FrameLayout>
<include
android:id="@+id/bottomPanel"
layout="@layout/item_feed_bottom"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/postActions"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.3"
android:background="#0000"
android:weightSum="2">
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/btnLike"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_weight="1"
android:textColor="@color/btn_lightpink_text_color"
android:textSize="18sp"
app:backgroundTint="@color/btn_lightpink_background"
tools:text="@string/like" />
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/btnBookmark"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginLeft="8dp"
android:layout_marginEnd="6dp"
android:layout_marginRight="8dp"
android:layout_weight="1"
android:text="@string/bookmark"
android:textColor="@color/btn_lightorange_text_color"
android:textSize="18sp"
app:backgroundTint="@color/btn_lightorange_background" />
</androidx.appcompat.widget.LinearLayoutCompat>
</LinearLayout>