Merge pull request #378 from torrentcome/#377

(#377) hide sensitive images after showing them
This commit is contained in:
Konrad Pozniak 2017-10-17 09:44:31 +02:00 committed by GitHub
commit 25a489fe03
5 changed files with 42 additions and 1 deletions

View file

@ -47,6 +47,7 @@ class StatusBaseViewHolder extends RecyclerView.ViewHolder {
private ImageView mediaPreview2;
private ImageView mediaPreview3;
private View sensitiveMediaWarning;
private View sensitiveMediaShow;
private View videoIndicator;
private TextView mediaLabel;
private View contentWarningBar;
@ -75,6 +76,7 @@ class StatusBaseViewHolder extends RecyclerView.ViewHolder {
mediaPreview2 = (ImageView) itemView.findViewById(R.id.status_media_preview_2);
mediaPreview3 = (ImageView) itemView.findViewById(R.id.status_media_preview_3);
sensitiveMediaWarning = itemView.findViewById(R.id.status_sensitive_media_warning);
sensitiveMediaShow = itemView.findViewById(R.id.status_sensitive_media_button);
videoIndicator = itemView.findViewById(R.id.status_video_indicator);
mediaLabel = (TextView) itemView.findViewById(R.id.status_media_label);
contentWarningBar = itemView.findViewById(R.id.status_content_warning_bar);
@ -230,6 +232,14 @@ class StatusBaseViewHolder extends RecyclerView.ViewHolder {
Boolean isAlwayShowSensitive = pm.getBoolean("alwayShowSensitiveMedia",false);
if (sensitive && (!isAlwayShowSensitive)) {
sensitiveMediaWarning.setVisibility(showingSensitive ? View.GONE : View.VISIBLE);
sensitiveMediaShow.setVisibility(showingSensitive ? View.VISIBLE : View.GONE);
sensitiveMediaShow.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
v.setVisibility(View.GONE);
sensitiveMediaWarning.setVisibility(View.VISIBLE);
}
});
sensitiveMediaWarning.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -237,7 +247,7 @@ class StatusBaseViewHolder extends RecyclerView.ViewHolder {
listener.onContentHiddenChange(true, getAdapterPosition());
}
v.setVisibility(View.GONE);
v.setOnClickListener(null);
sensitiveMediaShow.setVisibility(View.VISIBLE);
}
});
}
@ -312,6 +322,7 @@ class StatusBaseViewHolder extends RecyclerView.ViewHolder {
private void hideSensitiveMediaWarning() {
sensitiveMediaWarning.setVisibility(View.GONE);
sensitiveMediaShow.setVisibility(View.GONE);
}
private void setSpoilerText(String spoilerText, final boolean expanded,

View file

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FFF"
android:pathData="M12,4.5C7,4.5 2.73,7.61 1,12c1.73,4.39 6,7.5 11,7.5s9.27,-3.11 11,-7.5c-1.73,-4.39 -6,-7.5 -11,-7.5zM12,17c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5 5,2.24 5,5 -2.24,5 -5,5zM12,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3 3,-1.34 3,-3 -1.34,-3 -3,-3z"/>
</vector>

View file

@ -250,6 +250,16 @@
android:contentDescription="@null"
android:visibility="gone" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/status_sensitive_media_button"
app:srcCompat="@drawable/ic_remove_red_eye_black_24dp"
android:alpha="0.7"
android:layout_alignParentTop="true"
android:contentDescription="@null"
android:padding="@dimen/status_sensitive_media_button_padding"
android:visibility="gone" />
</RelativeLayout>
<LinearLayout

View file

@ -189,6 +189,16 @@
android:contentDescription="@null"
android:visibility="gone" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/status_sensitive_media_button"
app:srcCompat="@drawable/ic_remove_red_eye_black_24dp"
android:alpha="0.7"
android:layout_alignParentTop="true"
android:contentDescription="@null"
android:padding="@dimen/status_sensitive_media_button_padding"
android:visibility="gone" />
</RelativeLayout>
<LinearLayout

View file

@ -20,4 +20,5 @@
<dimen name="tab_page_margin">8dp</dimen>
<dimen name="status_left_line_margin">38dp</dimen>
<dimen name="text_content_margin">16dp</dimen>
<dimen name="status_sensitive_media_button_padding">5dp</dimen>
</resources>