Skip to content

Commit

Permalink
fix pol filter selection if user is not verified.
Browse files Browse the repository at this point in the history
  • Loading branch information
mopsalarm committed Jan 23, 2024
1 parent 7555956 commit d127a2e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -775,30 +775,16 @@ class FeedFragment : BaseFragment("FeedFragment", R.layout.fragment_feed), Filte
)
}

menu.findItem(R.id.action_change_content_type__not_verified)?.let { item ->
item.isVisible = userService.isAuthorized && !userService.userIsVerified
item.icon = ContentTypeDrawable(activity, listOf(SFW)).also { icon ->
icon.textSize = resources.getDimensionPixelSize(
R.dimen.feed_content_type_action_icon_text_size
).toFloat()
}
}

menu.findItem(R.id.action_change_content_type)?.let { item ->
if (userService.userIsVerified) {
val icon = ContentTypeDrawable(activity, selectedContentType)
icon.textSize = resources.getDimensionPixelSize(
R.dimen.feed_content_type_action_icon_text_size
).toFloat()

item.icon = icon
item.isVisible = true
val icon = ContentTypeDrawable(activity, selectedContentType)
icon.textSize = resources.getDimensionPixelSize(
R.dimen.feed_content_type_action_icon_text_size
).toFloat()

updateContentTypeItems(menu)
item.icon = icon
item.isVisible = true

} else {
item.isVisible = false
}
updateContentTypeItems(menu)
}

val bookmark = menu.findItem(R.id.action_bookmark)
Expand Down Expand Up @@ -840,13 +826,26 @@ class FeedFragment : BaseFragment("FeedFragment", R.layout.fragment_feed), Filte
R.id.action_content_type_pol to "pref_feed_type_pol",
)

val requireVerification = setOf(
R.id.action_content_type_nsfw,
R.id.action_content_type_nsfl,
)

if (contentTypes.containsKey(item.itemId)) {
val newState = !item.isChecked

if (newState && item.itemId in requireVerification) {
if (userService.isAuthorized && !userService.userIsVerified) {
hintUserIsNotVerified()
return true
}
}

// this applies the new content types and refreshes the menu.
Settings.edit {
putBoolean(contentTypes[item.itemId], newState)
}

// this applies the new content types and refreshes the menu.
return true
}

Expand All @@ -860,7 +859,6 @@ class FeedFragment : BaseFragment("FeedFragment", R.layout.fragment_feed), Filte
R.id.action_open_in_admin -> openUserInAdmin()
R.id.action_scroll_seen -> scrollToNextSeenAsync()
R.id.action_scroll_unseen -> scrollToNextUnseenAsync()
R.id.action_change_content_type__not_verified -> hintUserIsNotVerified()

else -> super.onOptionsItemSelected(item)
}
Expand Down
6 changes: 0 additions & 6 deletions app/src/main/res/menu/menu_feed.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@
</menu>
</item>

<item
android:id="@+id/action_change_content_type__not_verified"
android:title="@string/action_change_content_type"
app:iconTint="?android:textColorPrimary"
app:showAsAction="always"></item>

<item
android:id="@+id/action_bookmark"
android:icon="@drawable/ic_white_action_pin"
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/raw/changelog.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
{
"type": "Fix",
"change": "Icon auf dem Videospieler wieder farbig gemacht."
},
{
"type": "Fix",
"change": "Nicht verifizierte Nutzer können zwischen SFW/POL wählen."
}
]
},
Expand Down

0 comments on commit d127a2e

Please sign in to comment.