Attachment previews also use Picasso to load, fix their layout
Fix NSFW overlay
This commit is contained in:
parent
9ec3fd47dc
commit
d9f0b3c99e
6 changed files with 91 additions and 83 deletions
|
@ -16,6 +16,7 @@
|
||||||
package com.keylesspalace.tusky;
|
package com.keylesspalace.tusky;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.media.Image;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.text.SpannableStringBuilder;
|
import android.text.SpannableStringBuilder;
|
||||||
|
@ -51,10 +52,10 @@ class StatusViewHolder extends RecyclerView.ViewHolder {
|
||||||
private ImageButton moreButton;
|
private ImageButton moreButton;
|
||||||
private boolean favourited;
|
private boolean favourited;
|
||||||
private boolean reblogged;
|
private boolean reblogged;
|
||||||
private NetworkImageView mediaPreview0;
|
private ImageView mediaPreview0;
|
||||||
private NetworkImageView mediaPreview1;
|
private ImageView mediaPreview1;
|
||||||
private NetworkImageView mediaPreview2;
|
private ImageView mediaPreview2;
|
||||||
private NetworkImageView mediaPreview3;
|
private ImageView mediaPreview3;
|
||||||
private View sensitiveMediaWarning;
|
private View sensitiveMediaWarning;
|
||||||
private View contentWarningBar;
|
private View contentWarningBar;
|
||||||
private TextView contentWarningDescription;
|
private TextView contentWarningDescription;
|
||||||
|
@ -76,16 +77,10 @@ class StatusViewHolder extends RecyclerView.ViewHolder {
|
||||||
moreButton = (ImageButton) itemView.findViewById(R.id.status_more);
|
moreButton = (ImageButton) itemView.findViewById(R.id.status_more);
|
||||||
reblogged = false;
|
reblogged = false;
|
||||||
favourited = false;
|
favourited = false;
|
||||||
mediaPreview0 = (NetworkImageView) itemView.findViewById(R.id.status_media_preview_0);
|
mediaPreview0 = (ImageView) itemView.findViewById(R.id.status_media_preview_0);
|
||||||
mediaPreview1 = (NetworkImageView) itemView.findViewById(R.id.status_media_preview_1);
|
mediaPreview1 = (ImageView) itemView.findViewById(R.id.status_media_preview_1);
|
||||||
mediaPreview2 = (NetworkImageView) itemView.findViewById(R.id.status_media_preview_2);
|
mediaPreview2 = (ImageView) itemView.findViewById(R.id.status_media_preview_2);
|
||||||
mediaPreview3 = (NetworkImageView) itemView.findViewById(R.id.status_media_preview_3);
|
mediaPreview3 = (ImageView) itemView.findViewById(R.id.status_media_preview_3);
|
||||||
int mediaPreviewUnloadedId = ThemeUtils.getDrawableId(itemView.getContext(),
|
|
||||||
R.attr.media_preview_unloaded_drawable, android.R.color.black);
|
|
||||||
mediaPreview0.setDefaultImageResId(mediaPreviewUnloadedId);
|
|
||||||
mediaPreview1.setDefaultImageResId(mediaPreviewUnloadedId);
|
|
||||||
mediaPreview2.setDefaultImageResId(mediaPreviewUnloadedId);
|
|
||||||
mediaPreview3.setDefaultImageResId(mediaPreviewUnloadedId);
|
|
||||||
sensitiveMediaWarning = itemView.findViewById(R.id.status_sensitive_media_warning);
|
sensitiveMediaWarning = itemView.findViewById(R.id.status_sensitive_media_warning);
|
||||||
contentWarningBar = itemView.findViewById(R.id.status_content_warning_bar);
|
contentWarningBar = itemView.findViewById(R.id.status_content_warning_bar);
|
||||||
contentWarningDescription =
|
contentWarningDescription =
|
||||||
|
@ -225,23 +220,29 @@ class StatusViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
private void setMediaPreviews(final Status.MediaAttachment[] attachments,
|
private void setMediaPreviews(final Status.MediaAttachment[] attachments,
|
||||||
boolean sensitive, final StatusActionListener listener) {
|
boolean sensitive, final StatusActionListener listener) {
|
||||||
final NetworkImageView[] previews = {
|
final ImageView[] previews = {
|
||||||
mediaPreview0,
|
mediaPreview0,
|
||||||
mediaPreview1,
|
mediaPreview1,
|
||||||
mediaPreview2,
|
mediaPreview2,
|
||||||
mediaPreview3
|
mediaPreview3
|
||||||
};
|
};
|
||||||
Context context = mediaPreview0.getContext();
|
Context context = mediaPreview0.getContext();
|
||||||
ImageLoader imageLoader = VolleySingleton.getInstance(context).getImageLoader();
|
|
||||||
|
int mediaPreviewUnloadedId = ThemeUtils.getDrawableId(itemView.getContext(),
|
||||||
|
R.attr.media_preview_unloaded_drawable, android.R.color.black);
|
||||||
|
|
||||||
final int n = Math.min(attachments.length, Status.MAX_MEDIA_ATTACHMENTS);
|
final int n = Math.min(attachments.length, Status.MAX_MEDIA_ATTACHMENTS);
|
||||||
|
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
String previewUrl = attachments[i].getPreviewUrl();
|
String previewUrl = attachments[i].getPreviewUrl();
|
||||||
previews[i].setImageUrl(previewUrl, imageLoader);
|
|
||||||
if (!sensitive) {
|
previews[i].setVisibility(View.VISIBLE);
|
||||||
previews[i].setVisibility(View.VISIBLE);
|
|
||||||
} else {
|
Picasso.with(context)
|
||||||
previews[i].setVisibility(View.GONE);
|
.load(previewUrl)
|
||||||
}
|
.placeholder(mediaPreviewUnloadedId)
|
||||||
|
.into(previews[i]);
|
||||||
|
|
||||||
final String url = attachments[i].getUrl();
|
final String url = attachments[i].getUrl();
|
||||||
final Status.MediaAttachment.Type type = attachments[i].getType();
|
final Status.MediaAttachment.Type type = attachments[i].getType();
|
||||||
previews[i].setOnClickListener(new View.OnClickListener() {
|
previews[i].setOnClickListener(new View.OnClickListener() {
|
||||||
|
@ -251,22 +252,20 @@ class StatusViewHolder extends RecyclerView.ViewHolder {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sensitive) {
|
if (sensitive) {
|
||||||
sensitiveMediaWarning.setVisibility(View.VISIBLE);
|
sensitiveMediaWarning.setVisibility(View.VISIBLE);
|
||||||
sensitiveMediaWarning.setOnClickListener(new View.OnClickListener() {
|
sensitiveMediaWarning.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
v.setVisibility(View.GONE);
|
v.setVisibility(View.GONE);
|
||||||
for (int i = 0; i < n; i++) {
|
|
||||||
previews[i].setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
v.setOnClickListener(null);
|
v.setOnClickListener(null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hide any of the placeholder previews beyond the ones set.
|
// Hide any of the placeholder previews beyond the ones set.
|
||||||
for (int i = n; i < Status.MAX_MEDIA_ATTACHMENTS; i++) {
|
for (int i = n; i < Status.MAX_MEDIA_ATTACHMENTS; i++) {
|
||||||
previews[i].setImageUrl(null, imageLoader);
|
|
||||||
previews[i].setVisibility(View.GONE);
|
previews[i].setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/blocked_user_username"
|
android:id="@+id/blocked_user_username"
|
||||||
android:textColor="?attr/status_text_color_secondary" />
|
android:textColor="?android:textColorSecondary" />
|
||||||
|
|
||||||
<Space
|
<Space
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
|
|
@ -117,6 +117,7 @@
|
||||||
android:textOff="@string/status_content_warning_show_more"
|
android:textOff="@string/status_content_warning_show_more"
|
||||||
android:padding="3dp"
|
android:padding="3dp"
|
||||||
android:textSize="12sp"
|
android:textSize="12sp"
|
||||||
|
android:textAllCaps="true"
|
||||||
android:background="?attr/content_warning_button" />
|
android:background="?attr/content_warning_button" />
|
||||||
|
|
||||||
</com.keylesspalace.tusky.FlowLayout>
|
</com.keylesspalace.tusky.FlowLayout>
|
||||||
|
@ -126,26 +127,81 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textColor="?android:textColorPrimary"
|
android:textColor="?android:textColorPrimary"
|
||||||
|
android:layout_marginBottom="4dp"
|
||||||
android:layout_toRightOf="@+id/status_avatar"
|
android:layout_toRightOf="@+id/status_avatar"
|
||||||
android:layout_toEndOf="@+id/status_avatar"
|
android:layout_toEndOf="@+id/status_avatar"
|
||||||
android:layout_below="@+id/status_content_warning_bar" />
|
android:layout_below="@+id/status_content_warning_bar" />
|
||||||
|
|
||||||
<LinearLayout
|
<FrameLayout
|
||||||
android:id="@+id/status_media_preview_container"
|
android:id="@+id/status_media_preview_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
|
||||||
android:layout_below="@+id/status_content"
|
android:layout_below="@+id/status_content"
|
||||||
android:layout_toRightOf="@+id/status_avatar">
|
android:layout_toRightOf="@+id/status_avatar">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_marginBottom="2dp"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/status_media_preview_0"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="@dimen/status_media_preview_height"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_marginRight="2dp"
|
||||||
|
android:scaleType="centerCrop"
|
||||||
|
android:layout_marginTop="@dimen/status_media_preview_top_margin" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/status_media_preview_1"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="@dimen/status_media_preview_height"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_marginLeft="2dp"
|
||||||
|
android:scaleType="centerCrop"
|
||||||
|
android:layout_marginTop="@dimen/status_media_preview_top_margin" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_marginTop="2dp"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/status_media_preview_2"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="@dimen/status_media_preview_height"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_marginRight="2dp"
|
||||||
|
android:scaleType="centerCrop" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/status_media_preview_3"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="@dimen/status_media_preview_height"
|
||||||
|
android:layout_marginLeft="2dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:scaleType="centerCrop" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/status_sensitive_media_warning"
|
android:id="@+id/status_sensitive_media_warning"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginTop="@dimen/status_media_preview_top_margin"
|
android:layout_marginTop="@dimen/status_media_preview_top_margin"
|
||||||
android:padding="8dp"
|
android:padding="8dp"
|
||||||
android:background="?attr/sensitive_media_warning_background_color"
|
android:gravity="center"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
|
android:background="?attr/sensitive_media_warning_background_color"
|
||||||
android:visibility="gone">
|
android:visibility="gone">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -154,7 +210,7 @@
|
||||||
android:textAlignment="center"
|
android:textAlignment="center"
|
||||||
android:text="@string/status_sensitive_media_title"
|
android:text="@string/status_sensitive_media_title"
|
||||||
android:textColor="@android:color/white"
|
android:textColor="@android:color/white"
|
||||||
android:textStyle="normal|italic" />
|
android:textStyle="bold" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -162,53 +218,8 @@
|
||||||
android:textAlignment="center"
|
android:textAlignment="center"
|
||||||
android:text="@string/status_sensitive_media_directions"
|
android:text="@string/status_sensitive_media_directions"
|
||||||
android:textColor="@android:color/white" />
|
android:textColor="@android:color/white" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
</FrameLayout>
|
||||||
<LinearLayout
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content">
|
|
||||||
|
|
||||||
<com.android.volley.toolbox.NetworkImageView
|
|
||||||
android:id="@+id/status_media_preview_0"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="@dimen/status_media_preview_height"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:scaleType="centerCrop"
|
|
||||||
android:layout_marginTop="@dimen/status_media_preview_top_margin" />
|
|
||||||
|
|
||||||
<com.android.volley.toolbox.NetworkImageView
|
|
||||||
android:id="@+id/status_media_preview_1"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="@dimen/status_media_preview_height"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:scaleType="centerCrop"
|
|
||||||
android:layout_marginTop="@dimen/status_media_preview_top_margin" />
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content">
|
|
||||||
|
|
||||||
<com.android.volley.toolbox.NetworkImageView
|
|
||||||
android:id="@+id/status_media_preview_2"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="@dimen/status_media_preview_height"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:scaleType="centerCrop" />
|
|
||||||
|
|
||||||
<com.android.volley.toolbox.NetworkImageView
|
|
||||||
android:id="@+id/status_media_preview_3"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="@dimen/status_media_preview_height"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:scaleType="centerCrop" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
|
@ -217,7 +228,7 @@
|
||||||
android:layout_below="@id/status_media_preview_container"
|
android:layout_below="@id/status_media_preview_container"
|
||||||
android:layout_toRightOf="@+id/status_avatar"
|
android:layout_toRightOf="@+id/status_avatar"
|
||||||
android:paddingBottom="8dp"
|
android:paddingBottom="8dp"
|
||||||
android:paddingTop="10dp">
|
android:paddingTop="6dp">
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
app:srcCompat="@drawable/ic_reply_24dp"
|
app:srcCompat="@drawable/ic_reply_24dp"
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
<attr name="status_favourite_button_marked_tint" format="reference|color" />
|
<attr name="status_favourite_button_marked_tint" format="reference|color" />
|
||||||
<attr name="content_warning_button" format="reference" />
|
<attr name="content_warning_button" format="reference" />
|
||||||
<attr name="sensitive_media_warning_background_color" format="reference|color" />
|
<attr name="sensitive_media_warning_background_color" format="reference|color" />
|
||||||
<attr name="status_text_color_secondary" format="reference|color" />
|
|
||||||
<attr name="media_preview_unloaded_drawable" format="reference" />
|
<attr name="media_preview_unloaded_drawable" format="reference" />
|
||||||
<attr name="status_divider_drawable" format="reference" />
|
<attr name="status_divider_drawable" format="reference" />
|
||||||
<attr name="tab_page_margin_drawable" format="reference" />
|
<attr name="tab_page_margin_drawable" format="reference" />
|
||||||
|
|
|
@ -75,7 +75,7 @@
|
||||||
<string name="status_username_format">\@%s</string>
|
<string name="status_username_format">\@%s</string>
|
||||||
<string name="status_boosted_format">%s boosted</string>
|
<string name="status_boosted_format">%s boosted</string>
|
||||||
<string name="status_sensitive_media_title">Sensitive Media</string>
|
<string name="status_sensitive_media_title">Sensitive Media</string>
|
||||||
<string name="status_sensitive_media_directions">Click to view.</string>
|
<string name="status_sensitive_media_directions">Click to view</string>
|
||||||
<string name="status_content_warning_show_more">Show More</string>
|
<string name="status_content_warning_show_more">Show More</string>
|
||||||
<string name="status_content_warning_show_less">Show Less</string>
|
<string name="status_content_warning_show_less">Show Less</string>
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
<item name="status_favourite_button_tint">@color/status_favourite_button_dark</item>
|
<item name="status_favourite_button_tint">@color/status_favourite_button_dark</item>
|
||||||
<item name="status_favourite_button_marked_tint">@color/status_favourite_button_marked_dark</item>
|
<item name="status_favourite_button_marked_tint">@color/status_favourite_button_marked_dark</item>
|
||||||
<item name="content_warning_button">@drawable/toggle_small</item>
|
<item name="content_warning_button">@drawable/toggle_small</item>
|
||||||
<item name="sensitive_media_warning_background_color">@color/sensitive_media_warning_background_dark</item>
|
<item name="sensitive_media_warning_background_color">@color/color_background_dark</item>
|
||||||
<item name="media_preview_unloaded_drawable">@drawable/media_preview_unloaded_dark</item>
|
<item name="media_preview_unloaded_drawable">@drawable/media_preview_unloaded_dark</item>
|
||||||
<item name="status_divider_drawable">@drawable/status_divider_dark</item>
|
<item name="status_divider_drawable">@drawable/status_divider_dark</item>
|
||||||
<item name="tab_page_margin_drawable">@drawable/tab_page_margin_dark</item>
|
<item name="tab_page_margin_drawable">@drawable/tab_page_margin_dark</item>
|
||||||
|
@ -91,7 +91,6 @@
|
||||||
<item name="status_favourite_button_marked_tint">@color/status_favourite_button_marked_light</item>
|
<item name="status_favourite_button_marked_tint">@color/status_favourite_button_marked_light</item>
|
||||||
<item name="content_warning_button">@drawable/toggle_small_light</item>
|
<item name="content_warning_button">@drawable/toggle_small_light</item>
|
||||||
<item name="sensitive_media_warning_background_color">@color/sensitive_media_warning_background_light</item>
|
<item name="sensitive_media_warning_background_color">@color/sensitive_media_warning_background_light</item>
|
||||||
<item name="status_text_color_secondary">@color/status_text_secondary_light</item>
|
|
||||||
<item name="media_preview_unloaded_drawable">@drawable/media_preview_unloaded_light</item>
|
<item name="media_preview_unloaded_drawable">@drawable/media_preview_unloaded_light</item>
|
||||||
<item name="status_divider_drawable">@drawable/status_divider_light</item>
|
<item name="status_divider_drawable">@drawable/status_divider_light</item>
|
||||||
<item name="tab_page_margin_drawable">@drawable/tab_page_margin_light</item>
|
<item name="tab_page_margin_drawable">@drawable/tab_page_margin_light</item>
|
||||||
|
|
Loading…
Reference in a new issue