Browse Source

change waterfall layout

location is bugged, does affect visually but should not affect use
renovate/androidx.fragment-fragment-ktx-1.x
Austin Huang 4 years ago
parent
commit
e78135f85a
No known key found for this signature in database GPG Key ID: 84C23AA04587A91F
  1. 133
      app/src/main/java/awais/instagrabber/adapters/viewholder/feed/FeedItemViewHolder.java
  2. 6
      app/src/main/java/awais/instagrabber/adapters/viewholder/feed/FeedPhotoViewHolder.java
  3. 17
      app/src/main/java/awais/instagrabber/adapters/viewholder/feed/FeedSliderViewHolder.java
  4. 44
      app/src/main/java/awais/instagrabber/adapters/viewholder/feed/FeedVideoViewHolder.java
  5. 113
      app/src/main/res/layout/item_feed_bottom.xml
  6. 20
      app/src/main/res/layout/item_feed_photo.xml
  7. 20
      app/src/main/res/layout/item_feed_slider.xml
  8. 121
      app/src/main/res/layout/item_feed_top.xml
  9. 27
      app/src/main/res/layout/item_feed_video.xml
  10. 105
      app/src/main/res/layout/item_full_post_view.xml

133
app/src/main/java/awais/instagrabber/adapters/viewholder/feed/FeedItemViewHolder.java

@ -1,39 +1,45 @@
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.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import awais.instagrabber.R;
import awais.instagrabber.adapters.FeedAdapterV2;
import awais.instagrabber.databinding.ItemFeedBottomBinding;
import awais.instagrabber.customviews.VerticalImageSpan;
import awais.instagrabber.databinding.ItemFeedTopBinding;
import awais.instagrabber.databinding.LayoutPostViewBottomBinding;
import awais.instagrabber.models.enums.MediaItemType;
import awais.instagrabber.repositories.responses.Caption;
import awais.instagrabber.repositories.responses.Location;
import awais.instagrabber.repositories.responses.Media;
import awais.instagrabber.repositories.responses.User;
import awais.instagrabber.utils.TextUtils;
import awais.instagrabber.utils.Utils;
import static android.text.TextUtils.TruncateAt.END;
public abstract class FeedItemViewHolder extends RecyclerView.ViewHolder {
public static final int MAX_LINES_COLLAPSED = 5;
private final ItemFeedTopBinding topBinding;
private final ItemFeedBottomBinding bottomBinding;
private final LayoutPostViewBottomBinding bottomBinding;
private final ViewGroup bottomFrame;
private final FeedAdapterV2.FeedItemCallback feedItemCallback;
public FeedItemViewHolder(@NonNull final View root,
final ItemFeedTopBinding topBinding,
final ItemFeedBottomBinding bottomBinding,
public FeedItemViewHolder(@NonNull final ViewGroup root,
final FeedAdapterV2.FeedItemCallback feedItemCallback) {
super(root);
this.topBinding = topBinding;
this.bottomBinding = bottomBinding;
topBinding.title.setMovementMethod(new LinkMovementMethod());
this.bottomFrame = root;
this.topBinding = ItemFeedTopBinding.bind(root);
this.bottomBinding = LayoutPostViewBottomBinding.bind(root);
this.feedItemCallback = feedItemCallback;
}
@ -42,33 +48,35 @@ public abstract class FeedItemViewHolder extends RecyclerView.ViewHolder {
return;
}
setupProfilePic(media);
setupLocation(media);
bottomBinding.tvPostDate.setText(media.getDate());
bottomBinding.date.setText(media.getDate());
setupComments(media);
setupCaption(media);
setupActions(media);
if (media.getType() != MediaItemType.MEDIA_TYPE_SLIDER) {
bottomBinding.btnDownload.setOnClickListener(v ->
bottomBinding.download.setOnClickListener(v ->
feedItemCallback.onDownloadClick(media, -1, null)
);
}
bindItem(media);
bottomFrame.post(() -> setupLocation(media));
}
private void setupComments(@NonNull final Media feedModel) {
final long commentsCount = feedModel.getCommentCount();
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) {
final User user = media.getUser();
if (user == null) {
topBinding.ivProfilePic.setVisibility(View.GONE);
topBinding.profilePic.setVisibility(View.GONE);
topBinding.title.setVisibility(View.GONE);
topBinding.subtitle.setVisibility(View.GONE);
return;
}
topBinding.ivProfilePic.setOnClickListener(v -> feedItemCallback.onProfilePicClick(media, topBinding.ivProfilePic));
topBinding.ivProfilePic.setImageURI(user.getProfilePicUrl());
topBinding.profilePic.setOnClickListener(v -> feedItemCallback.onProfilePicClick(media));
topBinding.profilePic.setImageURI(user.getProfilePicUrl());
setupTitle(media);
}
@ -78,68 +86,97 @@ public abstract class FeedItemViewHolder extends RecyclerView.ViewHolder {
// spannableString.setSpan(new CommentMentionClickSpan(), 0, titleLen, 0);
final User user = media.getUser();
if (user == null) return;
final String title = "@" + user.getUsername();
topBinding.title.setText(title);
topBinding.title.setOnClickListener(v -> feedItemCallback.onNameClick(media, topBinding.ivProfilePic));
setUsername(user);
topBinding.title.setOnClickListener(v -> feedItemCallback.onNameClick(media));
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) {
bottomBinding.viewerCaption.clearOnMentionClickListeners();
bottomBinding.viewerCaption.clearOnHashtagClickListeners();
bottomBinding.viewerCaption.clearOnURLClickListeners();
bottomBinding.viewerCaption.clearOnEmailClickListeners();
bottomBinding.caption.clearOnMentionClickListeners();
bottomBinding.caption.clearOnHashtagClickListeners();
bottomBinding.caption.clearOnURLClickListeners();
bottomBinding.caption.clearOnEmailClickListeners();
final Caption caption = media.getCaption();
if (caption == null) {
bottomBinding.viewerCaption.setVisibility(View.GONE);
bottomBinding.caption.setVisibility(View.GONE);
return;
}
final CharSequence postCaption = caption.getText();
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;
bottomBinding.viewerCaption.setText(postCaption);
bottomBinding.viewerCaption.setMaxLines(MAX_LINES_COLLAPSED);
bottomBinding.viewerCaption.setEllipsize(END);
bottomBinding.viewerCaption.setOnClickListener(v -> bottomBinding.getRoot().post(() -> {
TransitionManager.beginDelayedTransition(bottomBinding.getRoot());
if (bottomBinding.viewerCaption.getMaxLines() == MAX_LINES_COLLAPSED) {
bottomBinding.viewerCaption.setMaxLines(Integer.MAX_VALUE);
bottomBinding.viewerCaption.setEllipsize(null);
bottomBinding.caption.setText(postCaption);
bottomBinding.caption.setMaxLines(MAX_LINES_COLLAPSED);
bottomBinding.caption.setEllipsize(END);
bottomBinding.caption.setOnClickListener(v -> bottomFrame.post(() -> {
TransitionManager.beginDelayedTransition(bottomFrame);
if (bottomBinding.caption.getMaxLines() == MAX_LINES_COLLAPSED) {
bottomBinding.caption.setMaxLines(Integer.MAX_VALUE);
bottomBinding.caption.setEllipsize(null);
return;
}
bottomBinding.viewerCaption.setMaxLines(MAX_LINES_COLLAPSED);
bottomBinding.viewerCaption.setEllipsize(END);
bottomBinding.caption.setMaxLines(MAX_LINES_COLLAPSED);
bottomBinding.caption.setEllipsize(END);
}));
bottomBinding.viewerCaption.addOnMentionClickListener(autoLinkItem -> feedItemCallback.onMentionClick(autoLinkItem.getOriginalText()));
bottomBinding.viewerCaption.addOnHashtagListener(autoLinkItem -> feedItemCallback.onHashtagClick(autoLinkItem.getOriginalText()));
bottomBinding.viewerCaption.addOnEmailClickListener(autoLinkItem -> feedItemCallback.onEmailClick(autoLinkItem.getOriginalText()));
bottomBinding.viewerCaption.addOnURLClickListener(autoLinkItem -> feedItemCallback.onURLClick(autoLinkItem.getOriginalText()));
bottomBinding.caption.addOnMentionClickListener(autoLinkItem -> feedItemCallback.onMentionClick(autoLinkItem.getOriginalText()));
bottomBinding.caption.addOnHashtagListener(autoLinkItem -> feedItemCallback.onHashtagClick(autoLinkItem.getOriginalText()));
bottomBinding.caption.addOnEmailClickListener(autoLinkItem -> feedItemCallback.onEmailClick(autoLinkItem.getOriginalText()));
bottomBinding.caption.addOnURLClickListener(autoLinkItem -> feedItemCallback.onURLClick(autoLinkItem.getOriginalText()));
}
private void setupLocation(@NonNull final Media media) {
final Location location = media.getLocation();
if (location == null) {
topBinding.location.setVisibility(View.GONE);
topBinding.title.setLayoutParams(new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT
));
} else {
final String locationName = location.getName();
if (TextUtils.isEmpty(locationName)) {
topBinding.location.setVisibility(View.GONE);
topBinding.title.setLayoutParams(new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT
));
} else {
topBinding.location.setVisibility(View.VISIBLE);
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));
}
}
}
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);
}

6
app/src/main/java/awais/instagrabber/adapters/viewholder/feed/FeedPhotoViewHolder.java

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

17
app/src/main/java/awais/instagrabber/adapters/viewholder/feed/FeedSliderViewHolder.java

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

44
app/src/main/java/awais/instagrabber/adapters/viewholder/feed/FeedVideoViewHolder.java

@ -3,10 +3,12 @@ package awais.instagrabber.adapters.viewholder.feed;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.constraintlayout.widget.ConstraintLayout;
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
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 awais.instagrabber.R;
import awais.instagrabber.adapters.FeedAdapterV2;
import awais.instagrabber.customviews.VideoPlayerCallbackAdapter;
import awais.instagrabber.customviews.VideoPlayerViewHelper;
import awais.instagrabber.databinding.ItemFeedVideoBinding;
import awais.instagrabber.databinding.LayoutPostViewBottomBinding;
import awais.instagrabber.databinding.LayoutVideoPlayerWithThumbnailBinding;
import awais.instagrabber.fragments.settings.PreferenceKeys;
import awais.instagrabber.repositories.responses.Media;
import awais.instagrabber.repositories.responses.MediaCandidate;
import awais.instagrabber.utils.NullSafePair;
import awais.instagrabber.utils.NumberUtils;
import awais.instagrabber.utils.ResponseBodyUtils;
import awais.instagrabber.utils.Utils;
@ -35,6 +41,7 @@ public class FeedVideoViewHolder extends FeedItemViewHolder {
private final Handler handler;
private final DefaultDataSourceFactory dataSourceFactory;
private final LayoutPostViewBottomBinding bottom;
private CacheDataSourceFactory cacheDataSourceFactory;
private Media media;
@ -47,10 +54,11 @@ public class FeedVideoViewHolder extends FeedItemViewHolder {
public FeedVideoViewHolder(@NonNull final ItemFeedVideoBinding binding,
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.feedItemCallback = feedItemCallback;
binding.itemFeedBottom.btnViews.setVisibility(View.VISIBLE);
bottom.viewsCount.setVisibility(View.VISIBLE);
handler = new Handler(Looper.getMainLooper());
final Context context = binding.getRoot().getContext();
dataSourceFactory = new DefaultDataSourceFactory(context, "instagram");
@ -64,7 +72,19 @@ public class FeedVideoViewHolder extends FeedItemViewHolder {
public void bindItem(final Media media) {
// Log.d(TAG, "Binding post: " + feedModel.getPostId());
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 VideoPlayerViewHelper.VideoPlayerCallback videoPlayerCallback = new VideoPlayerCallbackAdapter() {
@ -75,12 +95,12 @@ public class FeedVideoViewHolder extends FeedItemViewHolder {
@Override
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 resultingHeight = NumberUtils.getResultingHeight(requiredWidth, media.getOriginalHeight(), media.getOriginalWidth());
layoutParams.width = requiredWidth;
layoutParams.height = resultingHeight;
binding.videoPost.playerView.requestLayout();
videoPost.playerView.requestLayout();
}
};
final float aspectRatio = (float) media.getOriginalWidth() / media.getOriginalHeight();
@ -91,7 +111,7 @@ public class FeedVideoViewHolder extends FeedItemViewHolder {
videoUrl = videoVersion.getUrl();
}
final VideoPlayerViewHelper videoPlayerViewHelper = new VideoPlayerViewHelper(binding.getRoot().getContext(),
binding.videoPost,
videoPost,
videoUrl,
vol,
aspectRatio,
@ -99,11 +119,11 @@ public class FeedVideoViewHolder extends FeedItemViewHolder {
false,
// null,
videoPlayerCallback);
binding.videoPost.thumbnail.post(() -> {
videoPost.thumbnail.post(() -> {
if (media.getOriginalHeight() > 0.8 * Utils.displayMetrics.heightPixels) {
final ViewGroup.LayoutParams layoutParams = binding.videoPost.thumbnail.getLayoutParams();
layoutParams.height = (int) (0.8 * Utils.displayMetrics.heightPixels);
binding.videoPost.thumbnail.requestLayout();
final ViewGroup.LayoutParams tLayoutParams = videoPost.thumbnail.getLayoutParams();
tLayoutParams.height = (int) (0.8 * Utils.displayMetrics.heightPixels);
videoPost.thumbnail.requestLayout();
}
});
}
@ -118,8 +138,8 @@ public class FeedVideoViewHolder extends FeedItemViewHolder {
// if (player != null) {
// player.release();
// }
// if (binding.videoPost.root.getDisplayedChild() == 1) {
// binding.videoPost.root.showPrevious();
// if (videoPost.root.getDisplayedChild() == 1) {
// videoPost.root.showPrevious();
// }
// }
//

113
app/src/main/res/layout/item_feed_bottom.xml

@ -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>

20
app/src/main/res/layout/item_feed_photo.xml

@ -1,13 +1,11 @@
<?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:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
android:layout_height="wrap_content">
<include
android:id="@+id/item_feed_top"
layout="@layout/item_feed_top" />
<include layout="@layout/item_feed_top" />
<awais.instagrabber.customviews.drawee.ZoomableDraweeView
android:id="@+id/imageViewer"
@ -17,9 +15,9 @@
android:clickable="true"
android:focusable="true"
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
android:id="@+id/item_feed_bottom"
layout="@layout/item_feed_bottom" />
</LinearLayout>
<include layout="@layout/layout_post_view_bottom" />
</androidx.constraintlayout.widget.ConstraintLayout>

20
app/src/main/res/layout/item_feed_slider.xml

@ -1,18 +1,18 @@
<?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:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
android:layout_height="wrap_content">
<include
android:id="@+id/item_feed_top"
layout="@layout/item_feed_top" />
<include layout="@layout/item_feed_top" />
<FrameLayout
android:id="@+id/post_container"
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
android:id="@+id/media_list"
@ -39,7 +39,5 @@
android:textColor="@android:color/white" />
</FrameLayout>
<include
android:id="@+id/item_feed_bottom"
layout="@layout/item_feed_bottom" />
</LinearLayout>
<include layout="@layout/layout_post_view_bottom" />
</androidx.constraintlayout.widget.ConstraintLayout>

121
app/src/main/res/layout/item_feed_top.xml

@ -1,63 +1,86 @@
<?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:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="8dp">
<com.facebook.drawee.view.SimpleDraweeView
android:id="@+id/ivProfilePic"
android:layout_width="@dimen/profile_pic_size_regular"
android:layout_height="@dimen/profile_pic_size_regular"
android:background="?selectableItemBackgroundBorderless"
app:roundAsCircle="true" />
tools:parentTag="androidx.constraintlayout.widget.ConstraintLayout">
<RelativeLayout
android:id="@+id/infoContainer"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:animateLayoutChanges="true"
android:background="@null"
android:gravity="center"
android:orientation="vertical"
android:paddingStart="8dp"
android:paddingLeft="8dp"
android:paddingEnd="8dp"
android:paddingRight="8dp"
android:weightSum="2">
<awais.instagrabber.customviews.ProfilePicView
android:id="@+id/profile_pic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="12dp"
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" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
tools:text="username" />
android:ellipsize="marquee"
android:singleLine="true"
android:textAppearance="@style/TextAppearance.MaterialComponents.Headline6"
app:layout_constrainedWidth="true"
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"
android:layout_width="match_parent"
style="?borderlessButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/title"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:elevation="0dp"
android:ellipsize="end"
android:gravity="center_vertical"
android:insetTop="0dp"
android:insetBottom="0dp"
android:maxWidth="200dp"
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>
android:minHeight="32dp"
android:paddingStart="8dp"
android:paddingEnd="8dp"
android:textAlignment="viewStart"
android:textAllCaps="false"
android:textColor="@android:color/white"
android:visibility="gone"
app:backgroundTint="@color/black_a50"
app:elevation="0dp"
app:icon="@drawable/ic_round_location_on_24"
app:iconSize="16dp"
app:iconTint="@color/white"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/top_barrier"
app:rippleColor="@color/grey_600"
tools:text="Location, Location, Location, Location, "
tools:visibility="visible" />
</merge>

27
app/src/main/res/layout/item_feed_video.xml

@ -1,19 +1,20 @@
<?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:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
android:layout_height="wrap_content">
<include
android:id="@+id/item_feed_top"
layout="@layout/item_feed_top" />
<include layout="@layout/item_feed_top" />
<include
android:id="@+id/video_post"
layout="@layout/layout_video_player_with_thumbnail" />
<FrameLayout
android:id="@+id/post_container"
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
android:id="@+id/item_feed_bottom"
layout="@layout/item_feed_bottom" />
</LinearLayout>
<include layout="@layout/layout_post_view_bottom" />
</androidx.constraintlayout.widget.ConstraintLayout>

105
app/src/main/res/layout/item_full_post_view.xml

@ -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>
Loading…
Cancel
Save