Skip to content

Commit

Permalink
Merge branch 'main' into 7.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
l-olson1214 authored Jan 30, 2025
2 parents fc33413 + 0e14331 commit 43412f3
Show file tree
Hide file tree
Showing 68 changed files with 1,125 additions and 625 deletions.
35 changes: 0 additions & 35 deletions CONTRIBUTING.md

This file was deleted.

2 changes: 1 addition & 1 deletion ContinueReadingWidget/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>XPC!</string>
<key>CFBundleShortVersionString</key>
<string>7.7.0</string>
<string>7.7.1</string>
<key>CFBundleVersion</key>
<string>0</string>
<key>NSExtension</key>
Expand Down
2 changes: 1 addition & 1 deletion NotificationServiceExtension/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>7.7.0</string>
<string>7.7.1</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSExtension</key>
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ If you'd rather install the development prerequisites yourself without our scrip
* [**ClangFormat**](https://clang.llvm.org/docs/ClangFormat.html) - We use this for linting Objective-C code.

## Contributing
Covered in the [contributing document](CONTRIBUTING.md).
Covered in our [contributing documention](https://www.mediawiki.org/wiki/Wikimedia_Apps/Team/iOS#Contribute_to_development) on MediaWiki.

## Development Guidelines
These are general guidelines rather than hard rules.
Expand Down
2 changes: 2 additions & 0 deletions WMF Framework/Event Platform/EventPlatformClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ import WMFData
case appDonorExperience = "app_donor_experience"
case editInteraction = "ios.edit_interaction"
case imageRecommendation = "android.image_recommendation_event"
case articleLinkInteraction = "ios.article_link_interaction"
}

/**
Expand All @@ -159,6 +160,7 @@ import WMFData
case watchlist = "/analytics/mobile_apps/ios_watchlists/4.1.0"
case appInteraction = "/analytics/mobile_apps/app_interaction/1.1.0"
case imageRecommendation = "/analytics/mobile_apps/android_image_recommendation_event/1.1.0"
case articleLinkInteraction = "/analytics/mobile_apps/ios_article_link_interaction/1.0.0"
}

/**
Expand Down
2 changes: 1 addition & 1 deletion WMF Framework/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>7.7.0</string>
<string>7.7.1</string>
<key>CFBundleVersion</key>
<string>0</string>
<key>NSPrincipalClass</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,18 @@ public struct WMFNavigationBarProfileButtonConfig {
public let needsBadge: Bool
public let target: Any
public let action: Selector
public let leadingBarButtonItem: UIBarButtonItem?
public let trailingBarButtonItem: UIBarButtonItem?

public init(accessibilityLabelNoNotifications: String, accessibilityLabelHasNotifications: String, accessibilityHint: String, needsBadge: Bool, target: Any, action: Selector) {
public init(accessibilityLabelNoNotifications: String, accessibilityLabelHasNotifications: String, accessibilityHint: String, needsBadge: Bool, target: Any, action: Selector, leadingBarButtonItem: UIBarButtonItem?, trailingBarButtonItem: UIBarButtonItem?) {
self.accessibilityLabelNoNotifications = accessibilityLabelNoNotifications
self.accessibilityLabelHasNotifications = accessibilityLabelHasNotifications
self.accessibilityHint = accessibilityHint
self.needsBadge = needsBadge
self.target = target
self.action = action
self.leadingBarButtonItem = leadingBarButtonItem
self.trailingBarButtonItem = trailingBarButtonItem
}
}

Expand All @@ -88,6 +92,10 @@ public struct WMFNavigationBarSearchConfig {

public extension WMFNavigationBarConfiguring where Self: UIViewController {

private var profileButtonAccessibilityID: String {
"profile-button"
}

/// Shared method to apply navigation bar styling on an individual view controller basis. Call within viewWillAppear. For common UINavigationBar styling that should be shared across the app, update WMFComponentNavigationController.
/// - Parameters:
/// - titleConfig: Config for title setup
Expand Down Expand Up @@ -151,8 +159,20 @@ public extension WMFNavigationBarConfiguring where Self: UIViewController {
if let profileButtonConfig {
let image = profileButtonImage(theme: WMFAppEnvironment.current.theme, needsBadge: profileButtonConfig.needsBadge)
let profileButton = UIBarButtonItem(image: image, style: .plain, target: profileButtonConfig.target, action: profileButtonConfig.action)

profileButton.accessibilityLabel = profileButtonAccessibilityStrings(config: profileButtonConfig)
navigationItem.rightBarButtonItem = profileButton
profileButton.accessibilityIdentifier = profileButtonAccessibilityID

var rightBarButtonItems: [UIBarButtonItem] = [profileButton]
if let leadingBarButtonItem = profileButtonConfig.leadingBarButtonItem {
rightBarButtonItems.append(leadingBarButtonItem)
}

if let trailingBarButtonItem = profileButtonConfig.trailingBarButtonItem {
rightBarButtonItems.insert(trailingBarButtonItem, at: 0)
}

navigationItem.rightBarButtonItems = rightBarButtonItems
}

// Setup close button if needed
Expand Down Expand Up @@ -218,19 +238,24 @@ public extension WMFNavigationBarConfiguring where Self: UIViewController {
navigationItem.titleView?.tintColor = WMFAppEnvironment.current.theme.text
}

var currentProfileBarButtonItem: UIBarButtonItem? {
return navigationItem.rightBarButtonItems?.filter { $0.accessibilityIdentifier == profileButtonAccessibilityID }.first
}

/// Call from UIViewController when theme changes, or when badge needs to change
/// - from apply(theme:) if legacy
/// - from appEnvironmentDidChange() if WMFComponents
/// - whenever badge logic changes (YiR or unread notifications)
/// - Parameter needsBadge: true if red dot needs to be applied to profile button, false if not
func updateNavigationBarProfileButton(needsBadge: Bool, needsBadgeLabel: String, noBadgeLabel: String) {
let image = profileButtonImage(theme: WMFAppEnvironment.current.theme, needsBadge: needsBadge)

navigationItem.rightBarButtonItem?.image = image
navigationItem.rightBarButtonItem?.accessibilityLabel = needsBadge ? needsBadgeLabel : noBadgeLabel
if let currentProfileBarButtonItem {
currentProfileBarButtonItem.image = image
currentProfileBarButtonItem.accessibilityLabel = needsBadge ? needsBadgeLabel : noBadgeLabel
}
}

func profileButtonImage(theme: WMFTheme, needsBadge: Bool) -> UIImage? {
private func profileButtonImage(theme: WMFTheme, needsBadge: Bool) -> UIImage? {
let paletteColors: [UIColor]

if needsBadge {
Expand Down
15 changes: 10 additions & 5 deletions WMFComponents/Sources/WMFComponents/Utility/HTMLUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -471,12 +471,17 @@ public struct HtmlUtils {
}

if tagNameString == "/ol" {
types.removeLast()
indent = indent - 1
orderedListCounts.removeLast()

if !types.isEmpty && !orderedListCounts.isEmpty { // Prevent crashes from malformed html
types.removeLast()
indent = indent - 1
orderedListCounts.removeLast()
}
} else if tagNameString == "/ul" {
types.removeLast()
indent = indent - 1
if !types.isEmpty { // Prevent crashes from malformed html
types.removeLast()
indent = indent - 1
}
}

if tagNameString == "li" {
Expand Down
9 changes: 9 additions & 0 deletions WMFComponents/Tests/WMFComponentsTests/HtmlUtilsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,13 @@ final class HtmlUtilsTests: XCTestCase {
XCTAssertEqual(result, expectedText, "Unexpected result when attempting to strip html and entities.")
}

func testMalformedListHtml() throws {

let html = "<div class=\"mw-fr-edit-messages\"><div class=\"cdx-message mw-fr-message-box cdx-message--inline cdx-message--notice\"><span class=\"cdx-message__icon\"></span><div class=\"cdx-message__content\"><p><b>Note:</b> Edits to this page from new or unregistered users are subject to review prior to publication (<a href=\"/wiki/Wikipedia:Pending_changes\" title=\"Wikipedia:Pending changes\">help</a>).\n</p><div id=\"mw-fr-logexcerpt\"><ul class=\'mw-logevent-loglines\'>\n<li data-mw-logid=\"166878532\" data-mw-logaction=\"stable/config\" class=\"mw-logline-stable\"> <a href=\"/w/index.php?title=Special:Log&amp;logid=166878532\" title=\"Special:Log\">21:42, 2 January 2025</a> <a href=\"/wiki/User:Ymblanter\" class=\"mw-userlink\" title=\"User:Ymblanter\"><bdi>Ymblanter</bdi></a> configured pending changes settings for <a href=\"/wiki/Josh_Allen\" title=\"Josh Allen\">Josh Allen</a> [Auto-accept: require &quot;autoconfirmed&quot; permission] (expires 21:42, 2 January 2026 (UTC)) <span class=\"comment\">(Persistent <a href=\"/wiki/Wikipedia:Vandalism\" title=\"Wikipedia:Vandalism\">vandalism</a>; requested at <a href=\"/wiki/Wikipedia:RfPP\" class=\"mw-redirect\" title=\"Wikipedia:RfPP\">WP:RfPP</a> (<a href=\"/wiki/Wikipedia:TW\" class=\"mw-redirect\" title=\"Wikipedia:TW\">TW</a>))</span> <span class=\"mw-logevent-actionlink\">(<a href=\"/w/index.php?title=Josh_Allen&amp;action=history&amp;offset=20250102214253\" title=\"Josh Allen\">hist</a>)</span> </li>\n</ul></ul>\n</div></div></div></div>"

let largeTraitCollection = UITraitCollection(preferredContentSizeCategory: .large)
let styles: HtmlUtils.Styles = HtmlUtils.Styles(font: WMFFont.for(.callout, compatibleWith: largeTraitCollection), boldFont: WMFFont.for(.boldCallout, compatibleWith: largeTraitCollection), italicsFont: WMFFont.for(.italicCallout, compatibleWith: largeTraitCollection), boldItalicsFont: WMFFont.for(.boldItalicCallout, compatibleWith: largeTraitCollection), color: WMFTheme.light.text, linkColor: WMFTheme.light.link, lineSpacing: 3)
let attributedString = try HtmlUtils.attributedStringFromHtml(html, styles: styles)
XCTAssertNotNil(attributedString, "Test extra unordered list did not cause crash")
}
}
2 changes: 1 addition & 1 deletion Widgets/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>7.7.0</string>
<string>7.7.1</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSExtension</key>
Expand Down
2 changes: 1 addition & 1 deletion Wikipedia Stickers/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>XPC!</string>
<key>CFBundleShortVersionString</key>
<string>7.7.0</string>
<string>7.7.1</string>
<key>CFBundleVersion</key>
<string>0</string>
<key>UIRequiredDeviceCapabilities</key>
Expand Down
Loading

0 comments on commit 43412f3

Please sign in to comment.