Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preference to disable "ALT" badge on captioned images #3221

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ public void setMediaPreviewEnabled(boolean mediaPreviewEnabled) {
statusDisplayOptions.useAbsoluteTime(),
statusDisplayOptions.showBotOverlay(),
statusDisplayOptions.useBlurhash(),
statusDisplayOptions.showDescriptionBadge(),
CardViewMode.NONE,
statusDisplayOptions.confirmReblogs(),
statusDisplayOptions.confirmFavourites(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,8 @@ protected void setMediaPreviews(
boolean sensitive,
final StatusActionListener listener,
boolean showingContent,
boolean useBlurhash
boolean useBlurhash,
boolean showDescriptionBadge
) {

mediaPreview.setVisibility(View.VISIBLE);
Expand Down Expand Up @@ -502,7 +503,7 @@ protected void setMediaPreviews(
sensitiveMediaWarning.setVisibility(showingContent ? View.GONE : View.VISIBLE);
sensitiveMediaShow.setVisibility(showingContent ? View.VISIBLE : View.GONE);

descriptionIndicator.setVisibility(hasDescription && showingContent ? View.VISIBLE : View.GONE);
descriptionIndicator.setVisibility(showDescriptionBadge && hasDescription && showingContent ? View.VISIBLE : View.GONE);

sensitiveMediaShow.setOnClickListener(v -> {
if (getBindingAdapterPosition() != RecyclerView.NO_POSITION) {
Expand All @@ -518,7 +519,7 @@ protected void setMediaPreviews(
}
v.setVisibility(View.GONE);
sensitiveMediaShow.setVisibility(View.VISIBLE);
descriptionIndicator.setVisibility(hasDescription ? View.VISIBLE : View.GONE);
descriptionIndicator.setVisibility(showDescriptionBadge && hasDescription ? View.VISIBLE : View.GONE);
});

return null;
Expand Down Expand Up @@ -731,7 +732,7 @@ public void setupWithStatus(@NonNull StatusViewData.Concrete status,
List<Attachment> attachments = actionable.getAttachments();
boolean sensitive = actionable.getSensitive();
if (statusDisplayOptions.mediaPreviewEnabled() && hasPreviewableAttachment(attachments)) {
setMediaPreviews(attachments, sensitive, listener, status.isShowingContent(), statusDisplayOptions.useBlurhash());
setMediaPreviews(attachments, sensitive, listener, status.isShowingContent(), statusDisplayOptions.useBlurhash(), statusDisplayOptions.showDescriptionBadge());

if (attachments.size() == 0) {
hideSensitiveMediaWarning();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void setupWithConversation(
boolean sensitive = status.getSensitive();
if (statusDisplayOptions.mediaPreviewEnabled() && hasPreviewableAttachment(attachments)) {
setMediaPreviews(attachments, sensitive, listener, statusViewData.isShowingContent(),
statusDisplayOptions.useBlurhash());
statusDisplayOptions.useBlurhash(), statusDisplayOptions.showDescriptionBadge());

if (attachments.size() == 0) {
hideSensitiveMediaWarning();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class ConversationsFragment : SFragment(), StatusActionListener, Injectable, Res
useAbsoluteTime = preferences.getBoolean("absoluteTimeView", false),
showBotOverlay = preferences.getBoolean("showBotOverlay", true),
useBlurhash = preferences.getBoolean("useBlurhash", true),
showDescriptionBadge = preferences.getBoolean("showDescriptionBadge", true),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not related to the patch, but is it weird that this very similar block of code to create a StatusDisplayOptions is duplicated so many times? Is it weird that some of the instances use PrefKeys and some use literal strings?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cardViewMode = CardViewMode.NONE,
confirmReblogs = preferences.getBoolean("confirmReblogs", true),
confirmFavourites = preferences.getBoolean("confirmFavourites", false),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ class PreferencesActivity :
this.restartCurrentActivity()
}
"statusTextSize", "absoluteTimeView", "showBotOverlay", "animateGifAvatars", "useBlurhash",
"showSelfUsername", "showCardsInTimelines", "confirmReblogs", "confirmFavourites",
"enableSwipeForTabs", "mainNavPosition", PrefKeys.HIDE_TOP_TOOLBAR -> {
"showDescriptionBadge", "showSelfUsername", "showCardsInTimelines", "confirmReblogs",
"confirmFavourites", "enableSwipeForTabs", "mainNavPosition", PrefKeys.HIDE_TOP_TOOLBAR -> {
restartActivitiesOnBackPressedCallback.isEnabled = true
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,13 @@ class PreferencesFragment : PreferenceFragmentCompat(), Injectable {
isSingleLineTitle = false
}

switchPreference {
setDefaultValue(true)
key = PrefKeys.SHOW_DESCRIPTION_BADGE
setTitle(R.string.pref_title_badge_for_descriptions)
isSingleLineTitle = false
}

switchPreference {
setDefaultValue(false)
key = PrefKeys.SHOW_CARDS_IN_TIMELINES
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ class ReportStatusesFragment : Fragment(R.layout.fragment_report_statuses), Inje
useAbsoluteTime = preferences.getBoolean("absoluteTimeView", false),
showBotOverlay = false,
useBlurhash = preferences.getBoolean("useBlurhash", true),
showDescriptionBadge = preferences.getBoolean("showDescriptionBadge", true),
cardViewMode = CardViewMode.NONE,
confirmReblogs = preferences.getBoolean("confirmReblogs", true),
confirmFavourites = preferences.getBoolean("confirmFavourites", false),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class SearchStatusesFragment : SearchFragment<StatusViewData.Concrete>(), Status
useAbsoluteTime = preferences.getBoolean("absoluteTimeView", false),
showBotOverlay = preferences.getBoolean("showBotOverlay", true),
useBlurhash = preferences.getBoolean("useBlurhash", true),
showDescriptionBadge = preferences.getBoolean("showDescriptionBadge", true),
cardViewMode = CardViewMode.NONE,
confirmReblogs = preferences.getBoolean("confirmReblogs", true),
confirmFavourites = preferences.getBoolean("confirmFavourites", false),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ class TimelineFragment :
useAbsoluteTime = preferences.getBoolean(PrefKeys.ABSOLUTE_TIME_VIEW, false),
showBotOverlay = preferences.getBoolean(PrefKeys.SHOW_BOT_OVERLAY, true),
useBlurhash = preferences.getBoolean(PrefKeys.USE_BLURHASH, true),
showDescriptionBadge = preferences.getBoolean(PrefKeys.SHOW_DESCRIPTION_BADGE, true),
cardViewMode = if (preferences.getBoolean(
PrefKeys.SHOW_CARDS_IN_TIMELINES,
false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class ViewThreadFragment : SFragment(), OnRefreshListener, StatusActionListener,
useAbsoluteTime = preferences.getBoolean("absoluteTimeView", false),
showBotOverlay = preferences.getBoolean("showBotOverlay", true),
useBlurhash = preferences.getBoolean("useBlurhash", true),
showDescriptionBadge = preferences.getBoolean("showDescriptionBadge", true),
cardViewMode = if (preferences.getBoolean("showCardsInTimelines", false)) {
CardViewMode.INDENTED
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c
preferences.getBoolean("absoluteTimeView", false),
preferences.getBoolean("showBotOverlay", true),
preferences.getBoolean("useBlurhash", true),
preferences.getBoolean("showDescriptionBadge", true),
CardViewMode.NONE,
preferences.getBoolean("confirmReblogs", true),
preferences.getBoolean("confirmFavourites", false),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ object PrefKeys {
const val SHOW_BOT_OVERLAY = "showBotOverlay"
const val ANIMATE_GIF_AVATARS = "animateGifAvatars"
const val USE_BLURHASH = "useBlurhash"
const val SHOW_DESCRIPTION_BADGE = "showDescriptionBadge"
const val SHOW_SELF_USERNAME = "showSelfUsername"
const val SHOW_NOTIFICATIONS_FILTER = "showNotificationsFilter"
const val SHOW_CARDS_IN_TIMELINES = "showCardsInTimelines"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ data class StatusDisplayOptions(
val showBotOverlay: Boolean,
@get:JvmName("useBlurhash")
val useBlurhash: Boolean,
@get:JvmName("showDescriptionBadge")
val showDescriptionBadge: Boolean,
@get:JvmName("cardViewMode")
val cardViewMode: CardViewMode,
@get:JvmName("confirmReblogs")
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@
<string name="pref_title_bot_overlay">Show indicator for bots</string>
<string name="pref_title_animate_gif_avatars">Animate GIF avatars</string>
<string name="pref_title_gradient_for_media">Show colorful gradients for hidden media</string>
<string name="pref_title_badge_for_descriptions">Show \"ALT\" badge for images with descriptions</string>
<string name="pref_title_animate_custom_emojis">Animate custom emojis</string>

<string name="pref_title_post_filter">Timeline filtering</string>
Expand Down