From edc4f1357ec344dbb173b3f53cbe08e3578f7d06 Mon Sep 17 00:00:00 2001 From: Thomas Date: Wed, 11 Jan 2023 18:04:37 +0100 Subject: [PATCH] NSFW for Pixelfed view --- .../android/ui/drawer/SliderAdapter.java | 59 +++++++++++++++---- .../metadata/android/en/changelogs/463.txt | 1 + 2 files changed, 47 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/app/fedilab/android/ui/drawer/SliderAdapter.java b/app/src/main/java/app/fedilab/android/ui/drawer/SliderAdapter.java index de0975c47..e34051b74 100644 --- a/app/src/main/java/app/fedilab/android/ui/drawer/SliderAdapter.java +++ b/app/src/main/java/app/fedilab/android/ui/drawer/SliderAdapter.java @@ -17,23 +17,29 @@ package app.fedilab.android.ui.drawer; import android.app.Activity; import android.content.Context; import android.content.Intent; +import android.content.SharedPreferences; import android.os.Bundle; +import android.os.CountDownTimer; import android.view.LayoutInflater; import android.view.ViewGroup; import androidx.core.app.ActivityOptionsCompat; +import androidx.preference.PreferenceManager; import com.bumptech.glide.Glide; +import com.bumptech.glide.request.RequestOptions; import com.smarteist.autoimageslider.SliderViewAdapter; import java.util.ArrayList; import java.util.List; +import app.fedilab.android.R; import app.fedilab.android.activities.MediaActivity; import app.fedilab.android.client.entities.api.Attachment; import app.fedilab.android.client.entities.api.Status; import app.fedilab.android.databinding.DrawerSliderBinding; import app.fedilab.android.helper.Helper; +import jp.wasabeef.glide.transformations.BlurTransformation; public class SliderAdapter extends SliderViewAdapter { @@ -63,21 +69,48 @@ public class SliderAdapter extends SliderViewAdapter { - Intent mediaIntent = new Intent(context, MediaActivity.class); - Bundle b = new Bundle(); - b.putInt(Helper.ARG_MEDIA_POSITION, position + 1); - b.putSerializable(Helper.ARG_MEDIA_ARRAY, new ArrayList<>(status.media_attachments)); - mediaIntent.putExtras(b); - ActivityOptionsCompat options = ActivityOptionsCompat - .makeSceneTransitionAnimation((Activity) context, viewHolder.binding.ivAutoImageSlider, status.media_attachments.get(0).url); - // start the new activity - context.startActivity(mediaIntent, options.toBundle()); + if (status.sensitive && !expand_media) { + status.sensitive = false; + notifyDataSetChanged(); + if (timeout > 0) { + new CountDownTimer((timeout * 1000L), 1000) { + public void onTick(long millisUntilFinished) { + } + + public void onFinish() { + status.sensitive = true; + notifyDataSetChanged(); + } + }.start(); + } + } else { + Intent mediaIntent = new Intent(context, MediaActivity.class); + Bundle b = new Bundle(); + b.putInt(Helper.ARG_MEDIA_POSITION, position + 1); + b.putSerializable(Helper.ARG_MEDIA_ARRAY, new ArrayList<>(status.media_attachments)); + mediaIntent.putExtras(b); + ActivityOptionsCompat options = ActivityOptionsCompat + .makeSceneTransitionAnimation((Activity) context, viewHolder.binding.ivAutoImageSlider, status.media_attachments.get(0).url); + // start the new activity + context.startActivity(mediaIntent, options.toBundle()); + } }); } diff --git a/src/fdroid/fastlane/metadata/android/en/changelogs/463.txt b/src/fdroid/fastlane/metadata/android/en/changelogs/463.txt index eaebdeb2d..4fe4c5fe5 100644 --- a/src/fdroid/fastlane/metadata/android/en/changelogs/463.txt +++ b/src/fdroid/fastlane/metadata/android/en/changelogs/463.txt @@ -9,4 +9,5 @@ Fixed: - Fix jumps with the fetch more feature - Fix videos cannot be saved - Tags cannot be pinned when there are no custom tabs +- PixelFed view: NSFW not honored - Fix crashes \ No newline at end of file