Skip to content

Commit

Permalink
Default to low-priority announcements
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 562794503
  • Loading branch information
Janette James authored and material-automation committed Sep 5, 2023
1 parent 7f5bf12 commit d656f6b
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions components/Snackbar/src/MDCSnackbarMessage.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
// limitations under the License.

#import "MDCSnackbarMessage.h"
#import "MDCSnackbarMessageView.h"
#import "private/MDCSnackbarMessageInternal.h"
#import "MDCAvailability.h"
#import "MDCSnackbarMessageView.h"

static const NSTimeInterval kDefaultDuration = 4;

Expand Down Expand Up @@ -108,7 +109,17 @@ - (NSString *)description {
#pragma mark Text

- (void)setText:(NSString *)text {
self.attributedText = [[NSAttributedString alloc] initWithString:[text copy]];
NSDictionary *attributes = @{};

// TODO(b/298435271): Remove the #if check below once all users are building with Xcode 15.
#if MDC_AVAILABLE_SDK_IOS(17_0)
if (@available(iOS 17.0, *)) {
// Default to low-priority announcements.
attributes = @{UIAccessibilitySpeechAttributeAnnouncementPriority : UIAccessibilityPriorityLow};
}
#endif
self.attributedText = [[NSAttributedString alloc] initWithString:[text copy]
attributes:attributes];
}

- (NSString *)text {
Expand All @@ -130,8 +141,18 @@ - (void)setAccessibilityLabel:(NSString *)accessibilityLabel {
if (accessibilityLabel == nil) {
self.attributedAccessibilityLabel = nil;
} else {
NSDictionary *attributes = @{};

// TODO(b/298435271): Remove the #if check below once all users are building with Xcode 15.
#if MDC_AVAILABLE_SDK_IOS(17_0)
if (@available(iOS 17.0, *)) {
// Default to low-priority announcements.
attributes =
@{UIAccessibilitySpeechAttributeAnnouncementPriority : UIAccessibilityPriorityLow};
}
#endif
self.attributedAccessibilityLabel =
[[NSAttributedString alloc] initWithString:[accessibilityLabel copy]];
[[NSAttributedString alloc] initWithString:[accessibilityLabel copy] attributes:attributes];
}
}

Expand Down

0 comments on commit d656f6b

Please sign in to comment.