mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-12-27 07:06:58 +00:00
Fix chat layouts
This commit is contained in:
parent
0ec3691cac
commit
788358eb35
@ -8,7 +8,6 @@ import androidx.annotation.NonNull;
|
||||
import androidx.core.util.Pair;
|
||||
|
||||
import com.facebook.drawee.drawable.ScalingUtils;
|
||||
import com.facebook.drawee.generic.GenericDraweeHierarchy;
|
||||
import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder;
|
||||
import com.facebook.drawee.generic.RoundingParams;
|
||||
|
||||
@ -33,6 +32,8 @@ public class DirectItemMediaShareViewHolder extends DirectItemViewHolder {
|
||||
|
||||
private final LayoutDmMediaShareBinding binding;
|
||||
private final int maxWidth;
|
||||
private final RoundingParams incomingRoundingParams;
|
||||
private final RoundingParams outgoingRoundingParams;
|
||||
|
||||
public DirectItemMediaShareViewHolder(@NonNull final LayoutDmBaseBinding baseBinding,
|
||||
@NonNull final LayoutDmMediaShareBinding binding,
|
||||
@ -43,20 +44,18 @@ public class DirectItemMediaShareViewHolder extends DirectItemViewHolder {
|
||||
super(baseBinding, currentUser, thread, onClickListener);
|
||||
this.binding = binding;
|
||||
maxWidth = windowWidth - margin - dmRadiusSmall;
|
||||
incomingRoundingParams = RoundingParams.fromCornersRadii(dmRadiusSmall, dmRadius, dmRadius, dmRadius);
|
||||
outgoingRoundingParams = RoundingParams.fromCornersRadii(dmRadius, dmRadiusSmall, dmRadius, dmRadius);
|
||||
setItemView(binding.getRoot());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindItem(final DirectItem item, final MessageDirection messageDirection) {
|
||||
removeBg();
|
||||
final RoundingParams roundingParams = messageDirection == MessageDirection.INCOMING
|
||||
? RoundingParams.fromCornersRadii(dmRadiusSmall, dmRadius, dmRadius, dmRadius)
|
||||
: RoundingParams.fromCornersRadii(dmRadius, dmRadiusSmall, dmRadius, dmRadius);
|
||||
final GenericDraweeHierarchy hierarchy = new GenericDraweeHierarchyBuilder(itemView.getResources())
|
||||
.setActualImageScaleType(ScalingUtils.ScaleType.CENTER_CROP)
|
||||
.setRoundingParams(roundingParams)
|
||||
.build();
|
||||
binding.mediaPreview.setHierarchy(hierarchy);
|
||||
final RoundingParams roundingParams = messageDirection == MessageDirection.INCOMING ? incomingRoundingParams : outgoingRoundingParams;
|
||||
binding.mediaPreview.setHierarchy(new GenericDraweeHierarchyBuilder(itemView.getResources())
|
||||
.setActualImageScaleType(ScalingUtils.ScaleType.CENTER_CROP)
|
||||
.setRoundingParams(roundingParams)
|
||||
.build());
|
||||
binding.topBg.setBackgroundResource(messageDirection == MessageDirection.INCOMING
|
||||
? R.drawable.bg_media_share_top_incoming
|
||||
: R.drawable.bg_media_share_top_outgoing);
|
||||
@ -107,7 +106,7 @@ public class DirectItemMediaShareViewHolder extends DirectItemViewHolder {
|
||||
media.getOriginalHeight(),
|
||||
media.getOriginalWidth(),
|
||||
mediaImageMaxHeight,
|
||||
maxWidth
|
||||
mediaImageMaxWidth
|
||||
);
|
||||
final ViewGroup.LayoutParams layoutParams = binding.mediaPreview.getLayoutParams();
|
||||
layoutParams.width = widthHeight.first != null ? widthHeight.first : 0;
|
||||
|
@ -25,7 +25,6 @@ import awais.instagrabber.utils.ResponseBodyUtils;
|
||||
public class DirectItemMediaViewHolder extends DirectItemViewHolder {
|
||||
|
||||
private final LayoutDmMediaBinding binding;
|
||||
private final int maxWidth;
|
||||
private final RoundingParams incomingRoundingParams;
|
||||
private final RoundingParams outgoingRoundingParams;
|
||||
|
||||
@ -37,7 +36,6 @@ public class DirectItemMediaViewHolder extends DirectItemViewHolder {
|
||||
final View.OnClickListener onClickListener) {
|
||||
super(baseBinding, currentUser, thread, onClickListener);
|
||||
this.binding = binding;
|
||||
maxWidth = windowWidth - margin - dmRadiusSmall;
|
||||
incomingRoundingParams = RoundingParams.fromCornersRadii(dmRadiusSmall, dmRadius, dmRadius, dmRadius);
|
||||
outgoingRoundingParams = RoundingParams.fromCornersRadii(dmRadius, dmRadiusSmall, dmRadius, dmRadius);
|
||||
setItemView(binding.getRoot());
|
||||
@ -59,7 +57,7 @@ public class DirectItemMediaViewHolder extends DirectItemViewHolder {
|
||||
media.getOriginalHeight(),
|
||||
media.getOriginalWidth(),
|
||||
mediaImageMaxHeight,
|
||||
maxWidth
|
||||
mediaImageMaxWidth
|
||||
);
|
||||
final ViewGroup.LayoutParams layoutParams = binding.mediaPreview.getLayoutParams();
|
||||
final int width = widthHeight.first != null ? widthHeight.first : 0;
|
||||
|
@ -25,6 +25,7 @@ import awais.instagrabber.repositories.responses.directmessages.DirectThread;
|
||||
import awais.instagrabber.repositories.responses.directmessages.DirectUser;
|
||||
import awais.instagrabber.repositories.responses.directmessages.ImageVersions2;
|
||||
import awais.instagrabber.utils.ResponseBodyUtils;
|
||||
import awais.instagrabber.utils.TextUtils;
|
||||
|
||||
public class DirectItemProfileViewHolder extends DirectItemViewHolder {
|
||||
|
||||
@ -60,7 +61,6 @@ public class DirectItemProfileViewHolder extends DirectItemViewHolder {
|
||||
@Override
|
||||
public void bindItem(@NonNull final DirectItem item,
|
||||
final MessageDirection messageDirection) {
|
||||
removeBg();
|
||||
binding.getRoot().setBackgroundResource(messageDirection == MessageDirection.INCOMING
|
||||
? R.drawable.bg_speech_bubble_incoming
|
||||
: R.drawable.bg_speech_bubble_outgoing);
|
||||
@ -108,7 +108,13 @@ public class DirectItemProfileViewHolder extends DirectItemViewHolder {
|
||||
if (location == null) return;
|
||||
binding.profilePic.setVisibility(View.GONE);
|
||||
binding.username.setText(location.getName());
|
||||
binding.fullName.setText(location.getAddress());
|
||||
final String address = location.getAddress();
|
||||
if (!TextUtils.isEmpty(address)) {
|
||||
binding.fullName.setText(address);
|
||||
binding.fullName.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
binding.fullName.setVisibility(View.GONE);
|
||||
}
|
||||
binding.isVerified.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ import awais.instagrabber.utils.TextUtils;
|
||||
public class DirectItemStoryShareViewHolder extends DirectItemViewHolder {
|
||||
|
||||
private final LayoutDmStoryShareBinding binding;
|
||||
private final int maxWidth;
|
||||
// private final int maxWidth;
|
||||
|
||||
public DirectItemStoryShareViewHolder(@NonNull final LayoutDmBaseBinding baseBinding,
|
||||
@NonNull final LayoutDmStoryShareBinding binding,
|
||||
@ -37,13 +37,12 @@ public class DirectItemStoryShareViewHolder extends DirectItemViewHolder {
|
||||
final View.OnClickListener onClickListener) {
|
||||
super(baseBinding, currentUser, thread, onClickListener);
|
||||
this.binding = binding;
|
||||
maxWidth = windowWidth - margin - dmRadiusSmall;
|
||||
// maxWidth = windowWidth - margin - dmRadiusSmall;
|
||||
setItemView(binding.getRoot());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindItem(final DirectItem item, final MessageDirection messageDirection) {
|
||||
removeBg();
|
||||
String format = "@%s's story";
|
||||
final String reelType = item.getStoryShare().getReelType();
|
||||
if (reelType == null || item.getStoryShare().getMedia() == null) {
|
||||
@ -79,7 +78,7 @@ public class DirectItemStoryShareViewHolder extends DirectItemViewHolder {
|
||||
storyShareMedia.getOriginalHeight(),
|
||||
storyShareMedia.getOriginalWidth(),
|
||||
mediaImageMaxHeight,
|
||||
maxWidth
|
||||
mediaImageMaxWidth
|
||||
);
|
||||
final ViewGroup.LayoutParams layoutParams = binding.ivMediaPreview.getLayoutParams();
|
||||
layoutParams.width = widthHeight.first != null ? widthHeight.first : 0;
|
||||
|
@ -70,9 +70,10 @@ public abstract class DirectItemViewHolder extends RecyclerView.ViewHolder {
|
||||
messageInfoPaddingSmall = resources.getDimensionPixelSize(R.dimen.dm_message_info_padding_small);
|
||||
windowWidth = resources.getDisplayMetrics().widthPixels;
|
||||
mediaImageMaxHeight = resources.getDimensionPixelSize(R.dimen.dm_media_img_max_height);
|
||||
mediaImageMaxWidth = windowWidth - margin;
|
||||
final int groupWidthCorrection = avatarSize + messageInfoPaddingSmall * 3;
|
||||
mediaImageMaxWidth = windowWidth - margin - (thread.isGroup() ? groupWidthCorrection : 0);
|
||||
// messageInfoPaddingSmall is used cuz it's also 4dp, 1 avatar margin + 2 paddings = 3
|
||||
groupMessageWidth = windowWidth - margin - avatarSize - messageInfoPaddingSmall * 3;
|
||||
groupMessageWidth = windowWidth - margin - groupWidthCorrection;
|
||||
}
|
||||
|
||||
public void bind(final DirectItem item) {
|
||||
@ -120,7 +121,8 @@ public abstract class DirectItemViewHolder extends RecyclerView.ViewHolder {
|
||||
messageInfoPaddingSmall,
|
||||
dmRadiusSmall);
|
||||
}
|
||||
if (itemType == DirectItemType.MEDIA) {
|
||||
if (itemType == DirectItemType.MEDIA || itemType == DirectItemType.MEDIA_SHARE || itemType == DirectItemType.CLIP || itemType == DirectItemType.STORY_SHARE
|
||||
|| itemType == DirectItemType.LOCATION || itemType == DirectItemType.FELIX_SHARE) {
|
||||
// no background for media items
|
||||
binding.background.setBackgroundResource(0);
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ public class ChatMessageLayout extends FrameLayout {
|
||||
if (firstChildId == R.id.media_container) {
|
||||
widthSize += viewPartMainWidth;
|
||||
heightSize += viewPartMainHeight;
|
||||
} else if (firstChildId == R.id.raven_media_container || firstChildId == R.id.profile_container || firstChildId == R.id.voice_media) {
|
||||
} else if (firstChildId == R.id.raven_media_container || firstChildId == R.id.profile_container || firstChildId == R.id.voice_media || firstChildId == R.id.story_container) {
|
||||
widthSize += viewPartMainWidth;
|
||||
heightSize += viewPartMainHeight + viewPartInfoHeight;
|
||||
} else {
|
||||
|
@ -17,7 +17,7 @@
|
||||
app:layout_constraintHorizontal_chainStyle="packed"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:visibility="visible" />
|
||||
tools:visibility="gone" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/username"
|
||||
@ -35,6 +35,7 @@
|
||||
app:layout_constraintEnd_toStartOf="@id/isVerified"
|
||||
app:layout_constraintStart_toEndOf="@id/profile_pic"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_goneMarginBottom="8dp"
|
||||
app:layout_goneMarginEnd="8dp"
|
||||
app:layout_goneMarginStart="8dp"
|
||||
tools:text="Long..long... Long..long... Long..long..." />
|
||||
@ -61,6 +62,7 @@
|
||||
android:ellipsize="end"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="@style/TextAppearance.MaterialComponents.Body2"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toTopOf="@id/barrier"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="@id/username"
|
||||
|
@ -2,6 +2,7 @@
|
||||
<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:id="@+id/story_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
Loading…
Reference in New Issue
Block a user