Skip to content

Commit

Permalink
Change NSFW Blur toggle to drop-down menu with new options (LemmyNet#957
Browse files Browse the repository at this point in the history
)
  • Loading branch information
MakcNmyc committed Sep 14, 2023
1 parent 1ea34d7 commit 316e331
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
16 changes: 8 additions & 8 deletions app/src/main/java/com/jerboa/feat/BlurNsfwTypes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ import kotlinx.parcelize.Parcelize

@Parcelize
enum class BlurNsfwTypes(@StringRes val resId: Int) : Parcelable {
DoNotBlur(R.string.app_settings_do_not_blur),
BlurEverywhere(R.string.app_settings_blur_everywhere),
BlurEverywhereExceptNsfw(R.string.app_settings_blur_everywhere_except_nsfw),
BlurOnlyNsfwCommunity(R.string.app_settings_blur_only_nsfw_community);
Nothing(R.string.app_settings_blur_nothing),
All(R.string.app_settings_blur_all),
OnlyInsideNsfwCommunities(R.string.app_settings_blur_only_inside_nsfw_community),
OnlyOutsideNsfwCommunities(R.string.app_settings_blur_only_outside_nsfw_community);
}

fun BlurNsfwTypes.needNsfwBlur(postView : PostView) =
this.needNsfwBlur(postView.community.nsfw, postView.post.nsfw)

fun BlurNsfwTypes.needNsfwBlur(isCommunityNsfw: Boolean, isPostNsfw: Boolean = isCommunityNsfw): Boolean {
return isPostNsfw && when(this){
BlurNsfwTypes.DoNotBlur -> false
BlurNsfwTypes.BlurEverywhere -> true
BlurNsfwTypes.BlurEverywhereExceptNsfw -> !isCommunityNsfw
BlurNsfwTypes.BlurOnlyNsfwCommunity -> isCommunityNsfw
BlurNsfwTypes.Nothing -> false
BlurNsfwTypes.All -> true
BlurNsfwTypes.OnlyInsideNsfwCommunities -> !isCommunityNsfw
BlurNsfwTypes.OnlyOutsideNsfwCommunities -> isCommunityNsfw
}
}
8 changes: 4 additions & 4 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,8 @@
<string name="open_link">Open link</string>
<string name="open_link_external">Open link in external</string>
<string name="no_activity_found">No activity (app) found that can open this link</string>
<string name="app_settings_blur_everywhere">Blur everywhere</string>
<string name="app_settings_blur_everywhere_except_nsfw">Blur everywhere except NSFW</string>
<string name="app_settings_blur_only_nsfw_community">Blur only NSFW Community</string>
<string name="app_settings_do_not_blur">Do not blur</string>
<string name="app_settings_blur_nothing">Blur nothing</string>
<string name="app_settings_blur_all">Blur all</string>
<string name="app_settings_blur_only_inside_nsfw_community">Blur only inside NSFW communities</string>
<string name="app_settings_blur_only_outside_nsfw_community">Blur only outside NSFW communities</string>
</resources>

0 comments on commit 316e331

Please sign in to comment.