diff --git a/app/src/main/java/com/keylesspalace/tusky/Status.java b/app/src/main/java/com/keylesspalace/tusky/Status.java
index 1b5100cd..bb093574 100644
--- a/app/src/main/java/com/keylesspalace/tusky/Status.java
+++ b/app/src/main/java/com/keylesspalace/tusky/Status.java
@@ -42,7 +42,8 @@ public class Status {
/** whether the authenticated user has favourited this status */
private boolean favourited;
private Visibility visibility;
- private MediaAttachment[] attachments = null;
+ private MediaAttachment[] attachments;
+ private boolean sensitive;
public static final int MAX_MEDIA_ATTACHMENTS = 4;
@@ -110,6 +111,10 @@ public class Status {
return attachments;
}
+ public boolean getSensitive() {
+ return sensitive;
+ }
+
public void setRebloggedByUsername(String name) {
rebloggedByUsername = name;
}
@@ -122,8 +127,9 @@ public class Status {
this.favourited = favourited;
}
- public void setAttachments(MediaAttachment[] attachments) {
+ public void setAttachments(MediaAttachment[] attachments, boolean sensitive) {
this.attachments = attachments;
+ this.sensitive = sensitive;
}
@Override
@@ -181,6 +187,7 @@ public class Status {
Date createdAt = parseDate(object.getString("created_at"));
boolean reblogged = object.getBoolean("reblogged");
boolean favourited = object.getBoolean("favourited");
+ boolean sensitive = object.optBoolean("sensitive");
String visibility = object.getString("visibility");
JSONObject account = object.getJSONObject("account");
@@ -225,7 +232,7 @@ public class Status {
reblogged, favourited, visibility);
}
if (attachments != null) {
- status.setAttachments(attachments);
+ status.setAttachments(attachments, sensitive);
}
return status;
}
diff --git a/app/src/main/java/com/keylesspalace/tusky/TimelineAdapter.java b/app/src/main/java/com/keylesspalace/tusky/TimelineAdapter.java
index 388021bb..89e72e51 100644
--- a/app/src/main/java/com/keylesspalace/tusky/TimelineAdapter.java
+++ b/app/src/main/java/com/keylesspalace/tusky/TimelineAdapter.java
@@ -55,7 +55,11 @@ public class TimelineAdapter extends RecyclerView.Adapter {
} else {
holder.setRebloggedByUsername(rebloggedByUsername);
}
- holder.setMediaPreviews(status.getAttachments(), listener);
+ boolean sensitive = status.getSensitive();
+ holder.setMediaPreviews(status.getAttachments(), sensitive, listener);
+ if (!sensitive) {
+ holder.hideSensitiveMediaWarning();
+ }
holder.setupButtons(listener, position);
if (status.getVisibility() == Status.Visibility.PRIVATE) {
holder.disableReblogging();
@@ -119,7 +123,7 @@ public class TimelineAdapter extends RecyclerView.Adapter {
private NetworkImageView mediaPreview1;
private NetworkImageView mediaPreview2;
private NetworkImageView mediaPreview3;
- private String[] mediaAttachmentUrls;
+ private View sensitiveMediaWarning;
public ViewHolder(View itemView) {
super(itemView);
@@ -140,6 +144,7 @@ public class TimelineAdapter extends RecyclerView.Adapter {
mediaPreview1 = (NetworkImageView) itemView.findViewById(R.id.status_media_preview_1);
mediaPreview2 = (NetworkImageView) itemView.findViewById(R.id.status_media_preview_2);
mediaPreview3 = (NetworkImageView) itemView.findViewById(R.id.status_media_preview_3);
+ sensitiveMediaWarning = itemView.findViewById(R.id.status_sensitive_media_warning);
}
public void setDisplayName(String name) {
@@ -247,7 +252,7 @@ public class TimelineAdapter extends RecyclerView.Adapter {
}
public void setMediaPreviews(final Status.MediaAttachment[] attachments,
- final StatusActionListener listener) {
+ boolean sensitive, final StatusActionListener listener) {
final NetworkImageView[] previews = {
mediaPreview0,
mediaPreview1,
@@ -256,11 +261,15 @@ public class TimelineAdapter extends RecyclerView.Adapter {
};
Context context = mediaPreview0.getContext();
ImageLoader imageLoader = VolleySingleton.getInstance(context).getImageLoader();
- 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++) {
String previewUrl = attachments[i].getPreviewUrl();
previews[i].setImageUrl(previewUrl, imageLoader);
- previews[i].setVisibility(View.VISIBLE);
+ if (!sensitive) {
+ previews[i].setVisibility(View.VISIBLE);
+ } else {
+ previews[i].setVisibility(View.GONE);
+ }
final String url = attachments[i].getUrl();
final Status.MediaAttachment.Type type = attachments[i].getType();
previews[i].setOnClickListener(new View.OnClickListener() {
@@ -270,6 +279,19 @@ public class TimelineAdapter extends RecyclerView.Adapter {
}
});
}
+ if (sensitive) {
+ sensitiveMediaWarning.setVisibility(View.VISIBLE);
+ sensitiveMediaWarning.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ v.setVisibility(View.GONE);
+ for (int i = 0; i < n; i++) {
+ previews[i].setVisibility(View.VISIBLE);
+ }
+ v.setOnClickListener(null);
+ }
+ });
+ }
// Hide any of the placeholder previews beyond the ones set.
for (int i = n; i < Status.MAX_MEDIA_ATTACHMENTS; i++) {
previews[i].setImageUrl(null, imageLoader);
@@ -277,6 +299,10 @@ public class TimelineAdapter extends RecyclerView.Adapter {
}
}
+ public void hideSensitiveMediaWarning() {
+ sensitiveMediaWarning.setVisibility(View.GONE);
+ }
+
public void setupButtons(final StatusActionListener listener, final int position) {
reblogButton.setOnClickListener(new View.OnClickListener() {
@Override
diff --git a/app/src/main/res/layout/item_status.xml b/app/src/main/res/layout/item_status.xml
index b9f42f21..560b410c 100644
--- a/app/src/main/res/layout/item_status.xml
+++ b/app/src/main/res/layout/item_status.xml
@@ -84,6 +84,33 @@
android:layout_below="@+id/status_content"
android:layout_toRightOf="@+id/status_avatar">
+
+
+
+
+
+
+
+
@@ -100,7 +127,7 @@
@@ -114,13 +141,14 @@
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:scaleType="centerCrop" />
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
index eeda0aca..dc9fb7a7 100644
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -5,4 +5,5 @@
#FF4081
#4F4F4F
#000000
+ #303030
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 75385759..c316faff 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -49,6 +49,8 @@
\@%s
%s boosted
+ Sensitive Media
+ Click to view.
%s boosted your status
%s favourited your status