diff --git a/app/src/main/java/org/pixeldroid/app/posts/StatusViewHolder.kt b/app/src/main/java/org/pixeldroid/app/posts/StatusViewHolder.kt index af29b15b..5ea2834f 100644 --- a/app/src/main/java/org/pixeldroid/app/posts/StatusViewHolder.kt +++ b/app/src/main/java/org/pixeldroid/app/posts/StatusViewHolder.kt @@ -22,6 +22,7 @@ import androidx.core.view.WindowCompat import androidx.core.view.WindowInsetsCompat import androidx.core.view.WindowInsetsControllerCompat import androidx.lifecycle.LifecycleCoroutineScope +import androidx.preference.PreferenceManager import androidx.recyclerview.widget.RecyclerView import androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat import androidx.viewbinding.ViewBinding @@ -164,6 +165,9 @@ class StatusViewHolder(val binding: PostFragmentBinding) : RecyclerView.ViewHold binding: PostFragmentBinding, request: RequestBuilder, ) { + val alwaysShowNsfw = + PreferenceManager.getDefaultSharedPreferences(binding.root.context.applicationContext) + .getBoolean("always_show_nsfw", false) // Standard layout binding.postPager.visibility = View.VISIBLE @@ -178,7 +182,7 @@ class StatusViewHolder(val binding: PostFragmentBinding) : RecyclerView.ViewHold binding.postIndicator.visibility = View.GONE } - if (status?.sensitive == true) { + if (status?.sensitive == true && !alwaysShowNsfw) { setupSensitiveLayout() } else { // GONE is the default, but have to set it again because of how RecyclerViews work @@ -843,6 +847,10 @@ class AlbumViewPagerAdapter( override fun getItemCount() = media_attachments.size override fun onBindViewHolder(holder: ViewHolder, position: Int) { + val alwaysShowNsfw = + PreferenceManager.getDefaultSharedPreferences(holder.binding.root.context) + .getBoolean("always_show_nsfw", false) + media_attachments[position].apply { val video = type == Attachment.AttachmentType.video val blurhashBitMap = blurhash?.let { @@ -853,7 +861,7 @@ class AlbumViewPagerAdapter( meta?.original?.height ) } - if (sensitive == false) { + if (sensitive == false || alwaysShowNsfw) { val imageUrl = if(video) preview_url else url if(opened){ Glide.with(holder.binding.root) @@ -939,4 +947,4 @@ class AlbumViewPagerAdapter( override val image: ImageView = binding.imageImageView override val videoPlayButton: ImageView = binding.videoPlayButton } -} \ No newline at end of file +} diff --git a/app/src/main/res/drawable/eye_black_24dp.xml b/app/src/main/res/drawable/eye_black_24dp.xml new file mode 100644 index 00000000..e3b1e75a --- /dev/null +++ b/app/src/main/res/drawable/eye_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ba9f8bbd..2d56dece 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -35,6 +35,8 @@ Dark + Always show sensitive content + %1$s followed you @@ -327,4 +329,5 @@ For more info about Pixelfed, you can check here: https://pixelfed.org" Change your profile picture Contains NSFW media Switch accounts - \ No newline at end of file + NSFW/CW posts will not be blurred, and will be shown by default. + diff --git a/app/src/main/res/xml/root_preferences.xml b/app/src/main/res/xml/root_preferences.xml index 11ed9ee1..c7df4cde 100644 --- a/app/src/main/res/xml/root_preferences.xml +++ b/app/src/main/res/xml/root_preferences.xml @@ -1,3 +1,4 @@ + @@ -23,6 +24,10 @@ app:title="@string/language" app:icon="@drawable/translate_black_24dp" /> + +