fixed quote status

This commit is contained in:
Mariotaku Lee 2016-09-01 14:02:17 +08:00
parent 752c13c777
commit 7aab9e34d1
3 changed files with 105 additions and 152 deletions

View File

@ -282,6 +282,8 @@ public class CardMediaContainer extends ViewGroup implements Constants {
if (contentHeight > 0) {
heightSum = contentHeight;
}
} else if (contentHeight > 0) {
heightSum = contentHeight;
}
final int height = heightSum + getPaddingTop() + getPaddingBottom();
setMeasuredDimension(widthMeasureSpec, MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));

View File

@ -51,20 +51,16 @@ class StatusViewHolder(private val adapter: IStatusesAdapter<*>, itemView: View)
private val timeView by lazy { itemView.time }
private val replyCountView by lazy { itemView.replyCount }
private val retweetCountView by lazy { itemView.retweetCount }
private val quoteIndicator by lazy { itemView.quoteIndicator }
private val quoteIndicatorAnchorTop by lazy { itemView.quoteIndicatorAnchorTop }
private val quoteIndicatorAnchorBottom by lazy { itemView.quoteIndicatorAnchorBottom }
private val quotedView by lazy { itemView.quotedView }
private val quotedTextView by lazy { itemView.quotedText }
private val actionButtons by lazy { itemView.actionButtons }
private val mediaLabel by lazy { itemView.mediaLabel }
private val quotedMediaLabel by lazy { itemView.quotedMediaLabel }
private val statusContentLowerSpace by lazy { itemView.statusContentLowerSpace }
private val quotedMediaPreview by lazy { itemView.quotedMediaPreview }
private val favoriteIcon by lazy { itemView.favoriteIcon }
private val retweetIcon by lazy { itemView.retweetIcon }
private val favoriteCountView by lazy { itemView.favoriteCount }
private val mediaLabelTextView by lazy { itemView.mediaLabelText }
private val quotedMediaLabelTextView by lazy { itemView.quotedMediaLabelText }
private val replyButton by lazy { itemView.reply }
private val retweetButton by lazy { itemView.retweet }
private val favoriteButton by lazy { itemView.favorite }
@ -112,7 +108,6 @@ class StatusViewHolder(private val adapter: IStatusesAdapter<*>, itemView: View)
mediaPreview.visibility = View.GONE
mediaLabel.visibility = View.VISIBLE
}
quotedMediaLabel.visibility = View.GONE
actionButtons.visibility = if (showCardActions) View.VISIBLE else View.GONE
itemMenu.visibility = if (showCardActions) View.VISIBLE else View.GONE
statusContentLowerSpace.visibility = if (showCardActions) View.GONE else View.VISIBLE
@ -182,9 +177,7 @@ class StatusViewHolder(private val adapter: IStatusesAdapter<*>, itemView: View)
val skipLinksInText = status.extras != null && status.extras.support_entities
if (status.is_quote) {
quoteIndicator.visibility = View.VISIBLE
quoteIndicatorAnchorTop.visibility = View.VISIBLE
quoteIndicatorAnchorBottom.visibility = View.VISIBLE
quotedView.visibility = View.VISIBLE
val quoteContentAvailable = status.quoted_text_plain != null && status.quoted_text_unescaped != null
if (quoteContentAvailable) {
@ -223,7 +216,31 @@ class StatusViewHolder(private val adapter: IStatusesAdapter<*>, itemView: View)
quotedTextView.visibility = View.VISIBLE
}
quoteIndicator.color = status.quoted_user_color
if (status.quoted_user_color != 0) {
quotedView.drawStart(status.quoted_user_color)
} else {
quotedView.drawStart(ThemeUtils.getColorFromAttribute(context, R.attr.quoteIndicatorBackgroundColor, 0))
}
if (status.quoted_media?.isNotEmpty() ?: false) {
if (!adapter.sensitiveContentEnabled && status.is_possibly_sensitive) {
// Sensitive content, show label instead of media view
quotedMediaPreview.visibility = View.GONE
} else if (!adapter.mediaPreviewEnabled) {
// Media preview disabled, just show label
} else {
// Show media
quotedMediaPreview.visibility = View.VISIBLE
quotedMediaPreview.displayMedia(status.quoted_media, loader, status.account_key, -1,
null, null)
}
} else {
// No media, hide all related views
quotedMediaPreview.visibility = View.GONE
}
} else {
quotedNameView.visibility = View.GONE
quotedTextView.visibility = View.VISIBLE
@ -235,17 +252,12 @@ class StatusViewHolder(private val adapter: IStatusesAdapter<*>, itemView: View)
string.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
quotedTextView.text = string
quoteIndicator.color = 0
quotedView.drawStart(ThemeUtils.getColorFromAttribute(context, R.attr.quoteIndicatorBackgroundColor, 0))
}
itemContent.drawStart(status.user_color)
} else {
quoteIndicatorAnchorTop.visibility = View.GONE
quoteIndicatorAnchorBottom.visibility = View.GONE
quotedNameView.visibility = View.GONE
quotedTextView.visibility = View.GONE
quoteIndicator.visibility = View.GONE
quotedView.visibility = View.GONE
if (status.is_retweet) {
val retweetUserColor = status.retweet_user_color
@ -290,54 +302,32 @@ class StatusViewHolder(private val adapter: IStatusesAdapter<*>, itemView: View)
itemContent.drawEnd()
}
val hasQuotedMedia = status.quoted_media?.isNotEmpty() ?: false
val hasPrimaryMedia = !hasQuotedMedia && status.media?.isNotEmpty() ?: false
if (!hasPrimaryMedia && !hasQuotedMedia) {
// No media, hide all related views
mediaLabel.visibility = View.GONE
quotedMediaLabel.visibility = View.GONE
mediaPreview.visibility = View.GONE
quotedMediaPreview.visibility = View.GONE
} else {
if (status.media?.isNotEmpty() ?: false) {
if (!adapter.sensitiveContentEnabled && status.is_possibly_sensitive) {
// Sensitive content, show label instead of media view
mediaLabel.visibility = if (hasPrimaryMedia) View.VISIBLE else View.GONE
quotedMediaLabel.visibility = if (hasQuotedMedia) View.VISIBLE else View.GONE
mediaLabel.visibility = View.VISIBLE
mediaPreview.visibility = View.GONE
quotedMediaPreview.visibility = View.GONE
} else if (!adapter.mediaPreviewEnabled) {
// Media preview disabled, just show label
mediaLabel.visibility = if (hasPrimaryMedia) View.VISIBLE else View.GONE
quotedMediaLabel.visibility = if (hasQuotedMedia) View.VISIBLE else View.GONE
mediaLabel.visibility = View.VISIBLE
mediaPreview.visibility = View.GONE
quotedMediaPreview.visibility = View.GONE
} else {
// Show media
mediaLabel.visibility = View.GONE
quotedMediaLabel.visibility = View.GONE
mediaPreview.setStyle(adapter.mediaPreviewStyle)
quotedMediaPreview.setStyle(adapter.mediaPreviewStyle)
mediaPreview.visibility = if (hasPrimaryMedia) View.VISIBLE else View.GONE
quotedMediaPreview.visibility = if (hasQuotedMedia) View.VISIBLE else View.GONE
mediaPreview.visibility = View.VISIBLE
mediaPreview.displayMedia(status.media, loader, status.account_key, -1, this,
adapter.mediaLoadingHandler)
quotedMediaPreview.displayMedia(status.quoted_media, loader, status.account_key, -1, this,
adapter.mediaLoadingHandler)
}
} else {
// No media, hide all related views
mediaLabel.visibility = View.GONE
mediaPreview.visibility = View.GONE
}
var displayEnd = -1
if (status.extras.display_text_range != null) {
displayEnd = status.extras.display_text_range!![1]
@ -440,7 +430,6 @@ class StatusViewHolder(private val adapter: IStatusesAdapter<*>, itemView: View)
favoriteButton.setOnClickListener(eventListener)
mediaLabel.setOnClickListener(eventListener)
quotedMediaLabel.setOnClickListener(eventListener)
}
@ -455,7 +444,6 @@ class StatusViewHolder(private val adapter: IStatusesAdapter<*>, itemView: View)
statusInfoLabel.textSize = textSize * 0.75f
mediaLabelTextView.textSize = textSize * 0.95f
quotedMediaLabelTextView.textSize = textSize * 0.95f
replyCountView.textSize = textSize
retweetCountView.textSize = textSize
@ -465,6 +453,7 @@ class StatusViewHolder(private val adapter: IStatusesAdapter<*>, itemView: View)
fun setupViewOptions() {
setTextSize(adapter.textSize)
mediaPreview.setStyle(adapter.mediaPreviewStyle)
quotedMediaPreview.setStyle(adapter.mediaPreviewStyle)
// profileImageView.setStyle(adapter.getProfileImageStyle());
val nameFirst = adapter.nameFirst
@ -592,10 +581,6 @@ class StatusViewHolder(private val adapter: IStatusesAdapter<*>, itemView: View)
val firstMedia = holder.adapter.getStatus(position)?.media?.firstOrNull() ?: return
listener.onMediaClick(holder, v, firstMedia, position)
}
holder.quotedMediaLabel -> {
val firstMedia = holder.adapter.getStatus(position)?.quoted_media?.firstOrNull() ?: return
listener.onMediaClick(holder, v, firstMedia, position)
}
}
}

View File

@ -221,114 +221,80 @@
</org.mariotaku.twidere.view.CardMediaContainer>
<org.mariotaku.twidere.view.ForegroundColorView
android:id="@+id/quoteIndicator"
android:layout_width="@dimen/element_spacing_small"
android:layout_height="wrap_content"
android:layout_above="@+id/quoteIndicatorAnchorBottom"
android:layout_below="@+id/quoteIndicatorAnchorTop"
android:layout_marginEnd="@dimen/element_spacing_normal"
android:layout_marginRight="@dimen/element_spacing_normal"
android:background="?quoteIndicatorBackgroundColor"
android:visibility="gone"
tools:visibility="visible"/>
<android.support.v4.widget.Space
android:id="@+id/quoteIndicatorAnchorTop"
<org.mariotaku.twidere.view.ColorLabelRelativeLayout
android:id="@+id/quotedView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_height="wrap_content"
android:layout_below="@+id/mediaPreview"
android:layout_marginTop="@dimen/element_spacing_small"
android:visibility="visible"/>
<org.mariotaku.twidere.view.NameView
android:id="@+id/quotedName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/quoteIndicatorAnchorTop"
android:layout_marginTop="@dimen/element_spacing_small"
android:layout_toEndOf="@+id/quoteIndicator"
android:layout_toRightOf="@+id/quoteIndicator"
android:gravity="center_vertical|start"
android:orientation="horizontal"
android:tag="font_family|user"
android:visibility="gone"
app:nv_primaryTextColor="?android:textColorPrimary"
app:nv_primaryTextStyle="bold"
app:nv_secondaryTextColor="?android:textColorSecondary"
tools:visibility="visible"/>
<org.mariotaku.twidere.view.TimelineContentTextView
android:id="@+id/quotedText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/quotedName"
android:layout_toEndOf="@+id/quoteIndicator"
android:layout_toRightOf="@+id/quoteIndicator"
android:paddingBottom="@dimen/element_spacing_small"
android:paddingEnd="@dimen/element_spacing_small"
android:paddingLeft="@dimen/element_spacing_normal"
android:paddingRight="@dimen/element_spacing_small"
android:paddingStart="@dimen/element_spacing_normal"
android:paddingTop="@dimen/element_spacing_small"
android:tag="font_family|user"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorPrimary"
android:visibility="gone"
tools:text="@string/sample_status_text"
tools:visibility="visible"/>
app:ignorePadding="true">
<LinearLayout
android:id="@+id/quotedMediaLabel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/quotedText"
android:layout_marginTop="@dimen/element_spacing_xsmall"
android:layout_toEndOf="@+id/quoteIndicator"
android:layout_toRightOf="@+id/quoteIndicator"
android:background="?selectableItemBackground"
android:gravity="center_vertical"
android:orientation="horizontal">
<org.mariotaku.twidere.view.CardMediaContainer
android:id="@+id/quotedMediaPreview"
android:layout_width="112dp"
android:layout_height="112dp"
android:layout_alignParentTop="true"
android:layout_toEndOf="@+id/quoteIndicator"
android:layout_toRightOf="@+id/quoteIndicator"
android:horizontalSpacing="@dimen/element_spacing_xsmall"
android:verticalSpacing="@dimen/element_spacing_xsmall"
tools:visibility="visible">
<org.mariotaku.twidere.view.IconActionView
android:layout_width="@dimen/element_size_small"
android:layout_height="@dimen/element_size_small"
android:layout_weight="0"
android:color="?android:textColorSecondary"
android:scaleType="centerInside"
android:src="@drawable/ic_action_gallery"
tools:tint="?android:textColorSecondary"/>
<!-- Child views will be inflated if media preview enabled in ViewHolder -->
<include layout="@layout/layout_card_media_preview"/>
<TextView
android:id="@+id/quotedMediaLabelText"
android:layout_width="wrap_content"
</org.mariotaku.twidere.view.CardMediaContainer>
<org.mariotaku.twidere.view.NameView
android:id="@+id/quotedName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/media"
android:textAppearance="?android:textAppearanceSmall"
android:textStyle="bold"/>
android:layout_alignTop="@+id/quotedMediaPreview"
android:layout_toEndOf="@+id/quotedMediaPreview"
android:layout_toRightOf="@+id/quotedMediaPreview"
android:gravity="center_vertical|start"
android:orientation="horizontal"
android:paddingBottom="0dp"
android:paddingEnd="0dp"
android:paddingLeft="@dimen/element_spacing_small"
android:paddingRight="0dp"
android:paddingStart="@dimen/element_spacing_small"
android:paddingTop="@dimen/element_spacing_small"
android:tag="font_family|user"
android:visibility="gone"
app:nv_primaryTextColor="?android:textColorPrimary"
app:nv_primaryTextStyle="bold"
app:nv_secondaryTextColor="?android:textColorSecondary"
tools:visibility="visible"/>
</LinearLayout>
<org.mariotaku.twidere.view.TimelineContentTextView
android:id="@+id/quotedText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/quotedName"
android:layout_alignStart="@+id/quotedName"
android:layout_below="@+id/quotedName"
android:paddingBottom="@dimen/element_spacing_small"
android:paddingEnd="0dp"
android:paddingLeft="@dimen/element_spacing_small"
android:paddingRight="0dp"
android:paddingStart="@dimen/element_spacing_small"
android:paddingTop="@dimen/element_spacing_small"
android:tag="font_family|user"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorPrimary"
android:visibility="gone"
tools:text="@string/sample_status_text"
tools:visibility="visible"/>
<org.mariotaku.twidere.view.CardMediaContainer
android:id="@+id/quotedMediaPreview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/quotedMediaLabel"
android:layout_marginTop="@dimen/element_spacing_xsmall"
android:layout_toEndOf="@+id/quoteIndicator"
android:layout_toRightOf="@+id/quoteIndicator"
android:horizontalSpacing="@dimen/element_spacing_xsmall"
android:verticalSpacing="@dimen/element_spacing_xsmall"
tools:visibility="gone">
<!-- Child views will be inflated if media preview enabled in ViewHolder -->
<!--<include layout="@layout/layout_card_media_preview"/>-->
</org.mariotaku.twidere.view.CardMediaContainer>
<android.support.v4.widget.Space
android:id="@+id/quoteIndicatorAnchorBottom"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_below="@+id/quotedMediaPreview"
android:visibility="visible"/>
</org.mariotaku.twidere.view.ColorLabelRelativeLayout>
</RelativeLayout>