Add ability to always show sensitive content
This commit is contained in:
parent
b9df1e1a89
commit
43c4520316
@ -22,6 +22,7 @@ import androidx.core.view.WindowCompat
|
|||||||
import androidx.core.view.WindowInsetsCompat
|
import androidx.core.view.WindowInsetsCompat
|
||||||
import androidx.core.view.WindowInsetsControllerCompat
|
import androidx.core.view.WindowInsetsControllerCompat
|
||||||
import androidx.lifecycle.LifecycleCoroutineScope
|
import androidx.lifecycle.LifecycleCoroutineScope
|
||||||
|
import androidx.preference.PreferenceManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat
|
import androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat
|
||||||
import androidx.viewbinding.ViewBinding
|
import androidx.viewbinding.ViewBinding
|
||||||
@ -164,6 +165,9 @@ class StatusViewHolder(val binding: PostFragmentBinding) : RecyclerView.ViewHold
|
|||||||
binding: PostFragmentBinding,
|
binding: PostFragmentBinding,
|
||||||
request: RequestBuilder<Drawable>,
|
request: RequestBuilder<Drawable>,
|
||||||
) {
|
) {
|
||||||
|
val alwaysShowNsfw =
|
||||||
|
PreferenceManager.getDefaultSharedPreferences(binding.root.context.applicationContext)
|
||||||
|
.getBoolean("always_show_nsfw", false)
|
||||||
|
|
||||||
// Standard layout
|
// Standard layout
|
||||||
binding.postPager.visibility = View.VISIBLE
|
binding.postPager.visibility = View.VISIBLE
|
||||||
@ -178,7 +182,7 @@ class StatusViewHolder(val binding: PostFragmentBinding) : RecyclerView.ViewHold
|
|||||||
binding.postIndicator.visibility = View.GONE
|
binding.postIndicator.visibility = View.GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status?.sensitive == true) {
|
if (status?.sensitive == true && !alwaysShowNsfw) {
|
||||||
setupSensitiveLayout()
|
setupSensitiveLayout()
|
||||||
} else {
|
} else {
|
||||||
// GONE is the default, but have to set it again because of how RecyclerViews work
|
// 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 getItemCount() = media_attachments.size
|
||||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||||
|
val alwaysShowNsfw =
|
||||||
|
PreferenceManager.getDefaultSharedPreferences(holder.binding.root.context)
|
||||||
|
.getBoolean("always_show_nsfw", false)
|
||||||
|
|
||||||
media_attachments[position].apply {
|
media_attachments[position].apply {
|
||||||
val video = type == Attachment.AttachmentType.video
|
val video = type == Attachment.AttachmentType.video
|
||||||
val blurhashBitMap = blurhash?.let {
|
val blurhashBitMap = blurhash?.let {
|
||||||
@ -853,7 +861,7 @@ class AlbumViewPagerAdapter(
|
|||||||
meta?.original?.height
|
meta?.original?.height
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (sensitive == false) {
|
if (sensitive == false || alwaysShowNsfw) {
|
||||||
val imageUrl = if(video) preview_url else url
|
val imageUrl = if(video) preview_url else url
|
||||||
if(opened){
|
if(opened){
|
||||||
Glide.with(holder.binding.root)
|
Glide.with(holder.binding.root)
|
||||||
@ -939,4 +947,4 @@ class AlbumViewPagerAdapter(
|
|||||||
override val image: ImageView = binding.imageImageView
|
override val image: ImageView = binding.imageImageView
|
||||||
override val videoPlayButton: ImageView = binding.videoPlayButton
|
override val videoPlayButton: ImageView = binding.videoPlayButton
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
9
app/src/main/res/drawable/eye_black_24dp.xml
Normal file
9
app/src/main/res/drawable/eye_black_24dp.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path 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"
|
||||||
|
android:fillColor="?attr/colorOnBackground"
|
||||||
|
/>
|
||||||
|
</vector>
|
@ -35,6 +35,8 @@
|
|||||||
<!-- Theme Preferences: dark theme option -->
|
<!-- Theme Preferences: dark theme option -->
|
||||||
<string name="dark_theme">Dark</string>
|
<string name="dark_theme">Dark</string>
|
||||||
|
|
||||||
|
<string name="always_show_nsfw">Always show sensitive content</string>
|
||||||
|
|
||||||
<!-- Notifications: follow notification -->
|
<!-- Notifications: follow notification -->
|
||||||
<string name="followed_notification">%1$s followed you</string>
|
<string name="followed_notification">%1$s followed you</string>
|
||||||
|
|
||||||
@ -327,4 +329,5 @@ For more info about Pixelfed, you can check here: https://pixelfed.org"</string>
|
|||||||
<string name="change_profile_picture">Change your profile picture</string>
|
<string name="change_profile_picture">Change your profile picture</string>
|
||||||
<string name="contains_nsfw">Contains NSFW media</string>
|
<string name="contains_nsfw">Contains NSFW media</string>
|
||||||
<string name="switch_accounts">Switch accounts</string>
|
<string name="switch_accounts">Switch accounts</string>
|
||||||
</resources>
|
<string name="summary_always_show_nsfw">NSFW/CW posts will not be blurred, and will be shown by default.</string>
|
||||||
|
</resources>
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto"
|
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
@ -23,6 +24,10 @@
|
|||||||
app:title="@string/language"
|
app:title="@string/language"
|
||||||
app:icon="@drawable/translate_black_24dp" />
|
app:icon="@drawable/translate_black_24dp" />
|
||||||
|
|
||||||
|
<CheckBoxPreference app:key="always_show_nsfw" app:title="@string/always_show_nsfw"
|
||||||
|
app:icon="@drawable/eye_black_24dp" android:defaultValue="false"
|
||||||
|
android:summary="@string/summary_always_show_nsfw"/>
|
||||||
|
|
||||||
<Preference android:title="@string/notifications_settings"
|
<Preference android:title="@string/notifications_settings"
|
||||||
android:key="notification"
|
android:key="notification"
|
||||||
android:summary="@string/notifications_settings_summary"
|
android:summary="@string/notifications_settings_summary"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user