Skip to content

Commit 926c91b

Browse files
committed
Merge remote-tracking branch 'origin/trunk' into task/jetpack-overlay-universal-linking
2 parents f438d4b + fd04a11 commit 926c91b

File tree

162 files changed

+3310
-568
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

162 files changed

+3310
-568
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash -eu
2+
3+
echo "--- :rubygems: Setting up Gems"
4+
install_gems
5+
6+
echo "--- :cocoapods: Setting up Pods"
7+
install_cocoapods
8+
9+
echo "--- :writing_hand: Copy Files"
10+
mkdir -pv ~/.configure/wordpress-ios/secrets
11+
cp -v fastlane/env/project.env-example ~/.configure/wordpress-ios/secrets/project.env
12+
13+
echo "--- Lint Localized Strings Format"
14+
LOGS=logs.txt
15+
set +e
16+
set -o pipefail
17+
bundle exec fastlane generate_strings_file_for_glotpress skip_commit:true | tee $LOGS
18+
EXIT_CODE=$?
19+
set -e
20+
21+
echo $EXIT_CODE
22+
23+
if [[ $EXIT_CODE -ne 0 ]]; then
24+
# Strings generation finished with errors, extract the errors in an easy-to-find section
25+
echo "--- Report genstrings errors"
26+
ERRORS=errors.txt
27+
echo "Found errors when trying to run \`genstrings\` to generate the \`.strings\` files from \`*LocalizedStrings\` calls:" | tee $ERRORS
28+
echo '' >> $ERRORS
29+
# Print the errors inline.
30+
#
31+
# Notice the second `sed` call that removes the ANSI escape sequences that
32+
# Fastlane uses to color the output.
33+
grep -e "\[.*\].*genstrings:" $LOGS \
34+
| sed -e 's/\[.*\].*genstrings: error: /- /' \
35+
| sed -e $'s/\x1b\[[0-9;]*m//g' \
36+
| sort \
37+
| uniq \
38+
| tee -a $ERRORS
39+
# Annotate the build with the errors
40+
cat $ERRORS | buildkite-agent annotate --style error --context genstrings
41+
fi
42+
43+
exit $EXIT_CODE

.buildkite/pipeline.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,10 @@ steps:
123123
plugins: *common_plugins
124124
agents:
125125
queue: "android"
126+
# Runs the `.strings` generation automation to ensure all the
127+
# `LocalizedString` calls in the code can be correctly parsed by Apple's
128+
# `genstrings`.
129+
- label: "Lint Localized Strings Format"
130+
command: .buildkite/commands/lint-localized-strings-format.sh
131+
plugins: *common_plugins
132+
env: *common_env

Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ abstract_target 'Apps' do
218218

219219
pod 'NSURL+IDN', '~> 0.4'
220220

221-
pod 'WPMediaPicker', '~> 1.8.4'
221+
pod 'WPMediaPicker', '~> 1.8.7'
222222
# pod 'WPMediaPicker', :git => 'https://github.com/wordpress-mobile/MediaPicker-iOS.git', :tag => '1.7.0'
223223
## while PR is in review:
224224
# pod 'WPMediaPicker', :git => 'https://github.com/wordpress-mobile/MediaPicker-iOS.git', :branch => ''

Podfile.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ PODS:
512512
- CocoaLumberjack (~> 3.4)
513513
- FormatterKit/TimeIntervalFormatter (~> 1.8)
514514
- WordPressUI (1.12.5)
515-
- WPMediaPicker (1.8.6)
515+
- WPMediaPicker (1.8.7)
516516
- wpxmlrpc (0.9.0)
517517
- Yoga (1.14.0)
518518
- ZendeskCommonUISDK (6.1.2)
@@ -605,7 +605,7 @@ DEPENDENCIES:
605605
- WordPressKit (>= 4.58.2, ~> 4.58)
606606
- WordPressShared (~> 1.18.0)
607607
- WordPressUI (~> 1.12.5)
608-
- WPMediaPicker (~> 1.8.4)
608+
- WPMediaPicker (~> 1.8.7)
609609
- Yoga (from `https://raw.githubusercontent.com/wordpress-mobile/gutenberg-mobile/v1.85.0/third-party-podspecs/Yoga.podspec.json`)
610610
- ZendeskSupportSDK (= 5.3.0)
611611
- ZIPFoundation (~> 0.9.8)
@@ -868,7 +868,7 @@ SPEC CHECKSUMS:
868868
WordPressKit: d8bc00bce09273fc241cf171b0e61ef8f4f29479
869869
WordPressShared: e5a479220643f46dc4d7726ef8dd45f18bf0c53b
870870
WordPressUI: c5be816f6c7b3392224ac21de9e521e89fa108ac
871-
WPMediaPicker: 749ebfa75fb2b6df4f5e5d9d0847e9512ad74d28
871+
WPMediaPicker: 0d45dfd7b3c5651c5236ffd48c1b0b2f60a2d5d2
872872
wpxmlrpc: bf55a43a7e710bd2a4fb8c02dfe83b1246f14f13
873873
Yoga: 2ca978c40e0fd6d7f54bcb1602bc0cbbc79454a7
874874
ZendeskCommonUISDK: 5f0a83f412e07ae23701f18c412fe783b3249ef5
@@ -880,6 +880,6 @@ SPEC CHECKSUMS:
880880
ZendeskSupportSDK: 3a8e508ab1d9dd22dc038df6c694466414e037ba
881881
ZIPFoundation: ae5b4b813d216d3bf0a148773267fff14bd51d37
882882

883-
PODFILE CHECKSUM: 879b8a4d9da3b3bad6cfed2de24977912ce560b0
883+
PODFILE CHECKSUM: e4762593ef0d1097286d309c828f611976c1e771
884884

885885
COCOAPODS: 1.11.2

RELEASE-NOTES.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1+
21.3
2+
-----
3+
* [*] [internal] Blogging Reminders notifications and scheduling can be turned off for WordPress as part of Jetpack focus behind a feature flag. [#19611]
4+
* [*] [internal] Weekly Roundup notifications and scheduling can be turned off for WordPress as part of Jetpack focus behind a feature flag. [#19590]
5+
* [*] Fixed a minor UI issue where the segmented control under My SIte was being clipped when "Home" is selected. [#19595]
6+
17
21.2
28
-----
39
* [*] [internal] Refactored fetching posts in the Reader tab. [#19539]
4-
10+
* [*] Fixed an issue where the message "No media matching your search" for the media picker is not visible [#19555]
511

612
21.1
713
-----

WordPress/Classes/Extensions/UIImageView+SiteIcon.swift

Lines changed: 55 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,14 @@ extension UIImageView {
1111
/// Default Settings
1212
///
1313
struct SiteIconDefaults {
14-
1514
/// Default SiteIcon's Image Size, in points.
1615
///
17-
static let imageSize = 40
18-
19-
/// Default SiteIcon's Image Size, in pixels.
20-
///
21-
static var imageSizeInPixels: Int {
22-
return imageSize * Int(UIScreen.main.scale)
23-
}
16+
static let imageSize = CGSize(width: 40, height: 40)
2417
}
2518

2619

2720
/// Downloads the SiteIcon Image, hosted at the specified path. This method will attempt to optimize the URL, so that
28-
/// the download Image Size matches `SiteIconDefaults.imageSize`.
21+
/// the download Image Size matches `imageSize`.
2922
///
3023
/// TODO: This is a convenience method. Nuke me once we're all swifted.
3124
///
@@ -38,35 +31,42 @@ extension UIImageView {
3831

3932

4033
/// Downloads the SiteIcon Image, hosted at the specified path. This method will attempt to optimize the URL, so that
41-
/// the download Image Size matches `SiteIconDefaults.imageSize`.
34+
/// the download Image Size matches `imageSize`.
4235
///
4336
/// - Parameters:
4437
/// - path: SiteIcon's url (string encoded) to be downloaded.
38+
/// - imageSize: Request site icon in the specified image size.
4539
/// - placeholderImage: Yes. It's the "place holder image", Sherlock.
4640
///
4741
@objc
48-
func downloadSiteIcon(at path: String, placeholderImage: UIImage?) {
49-
guard let siteIconURL = optimizedURL(for: path) else {
42+
func downloadSiteIcon(
43+
at path: String,
44+
imageSize: CGSize = SiteIconDefaults.imageSize,
45+
placeholderImage: UIImage?
46+
) {
47+
guard let siteIconURL = optimizedURL(for: path, imageSize: imageSize) else {
5048
image = placeholderImage
5149
return
5250
}
5351

5452
logURLOptimization(from: path, to: siteIconURL)
5553

5654
let request = URLRequest(url: siteIconURL)
57-
downloadSiteIcon(with: request, placeholderImage: placeholderImage)
55+
downloadSiteIcon(with: request, imageSize: imageSize, placeholderImage: placeholderImage)
5856
}
5957

6058
/// Downloads a SiteIcon image, using a specified request.
6159
///
6260
/// - Parameters:
63-
/// - request: the request for the SiteIcon.
61+
/// - request: The request for the SiteIcon.
62+
/// - imageSize: Request site icon in the specified image size.
6463
/// - placeholderImage: Yes. It's the "place holder image".
6564
///
6665
private func downloadSiteIcon(
6766
with request: URLRequest,
68-
placeholderImage: UIImage?) {
69-
67+
imageSize expectedSize: CGSize = SiteIconDefaults.imageSize,
68+
placeholderImage: UIImage?
69+
) {
7070
af_setImage(withURLRequest: request, placeholderImage: placeholderImage, completion: { [weak self] dataResponse in
7171
switch dataResponse.result {
7272
case .success(let image):
@@ -82,8 +82,6 @@ extension UIImageView {
8282
// The following lines of code ensure that we resize the image to the default Site Icon size, to
8383
// ensure there is no UI breakage due to having larger images set here.
8484
//
85-
let expectedSize = CGSize(width: SiteIconDefaults.imageSize, height: SiteIconDefaults.imageSize)
86-
8785
if image.size != expectedSize {
8886
self.image = image.resizedImage(with: .scaleAspectFill, bounds: expectedSize, interpolationQuality: .default)
8987
} else {
@@ -103,19 +101,21 @@ extension UIImageView {
103101

104102

105103
/// Downloads the SiteIcon Image, associated to a given Blog. This method will attempt to optimize the URL, so that
106-
/// the download Image Size matches `SiteIconDefaults.imageSize`.
104+
/// the download Image Size matches `imageSize`.
107105
///
108106
/// - Parameters:
109107
/// - blog: reference to the source blog
110108
/// - placeholderImage: Yes. It's the "place holder image".
111109
///
112-
@objc
113-
func downloadSiteIcon(for blog: Blog, placeholderImage: UIImage? = .siteIconPlaceholder) {
114-
guard let siteIconPath = blog.icon, let siteIconURL = optimizedURL(for: siteIconPath) else {
110+
@objc func downloadSiteIcon(
111+
for blog: Blog,
112+
imageSize: CGSize = SiteIconDefaults.imageSize,
113+
placeholderImage: UIImage? = .siteIconPlaceholder
114+
) {
115+
guard let siteIconPath = blog.icon, let siteIconURL = optimizedURL(for: siteIconPath, imageSize: imageSize) else {
115116

116117
if blog.isWPForTeams() && placeholderImage == .siteIconPlaceholder {
117-
let standardSize = CGSize(width: SiteIconDefaults.imageSize, height: SiteIconDefaults.imageSize)
118-
image = UIImage.gridicon(.p2, size: standardSize)
118+
image = UIImage.gridicon(.p2, size: imageSize)
119119
return
120120
}
121121

@@ -135,7 +135,7 @@ extension UIImageView {
135135
for: siteIconURL,
136136
from: host,
137137
onComplete: { [weak self] request in
138-
self?.downloadSiteIcon(with: request, placeholderImage: placeholderImage)
138+
self?.downloadSiteIcon(with: request, imageSize: imageSize, placeholderImage: placeholderImage)
139139
}) { error in
140140
DDLogError(error.localizedDescription)
141141
}
@@ -145,31 +145,31 @@ extension UIImageView {
145145

146146
// MARK: - Private Methods
147147
//
148-
private extension UIImageView {
148+
extension UIImageView {
149149
/// Returns the Size Optimized URL for a given Path.
150150
///
151-
func optimizedURL(for path: String) -> URL? {
151+
func optimizedURL(for path: String, imageSize: CGSize = SiteIconDefaults.imageSize) -> URL? {
152152
if isPhotonURL(path) || isDotcomURL(path) {
153-
return optimizedDotcomURL(from: path)
153+
return optimizedDotcomURL(from: path, imageSize: imageSize)
154154
}
155155

156156
if isBlavatarURL(path) {
157-
return optimizedBlavatarURL(from: path)
157+
return optimizedBlavatarURL(from: path, imageSize: imageSize)
158158
}
159159

160-
return optimizedPhotonURL(from: path)
160+
return optimizedPhotonURL(from: path, imageSize: imageSize)
161161
}
162162

163163

164164
// MARK: - Private Helpers
165165

166-
/// Returns the download URL for a square icon with a size of `SiteIconDefaults.imageSizeInPixels`
166+
/// Returns the download URL for a square icon with a size of `imageSize` in pixels.
167167
///
168168
/// - Parameter path: SiteIcon URL (string encoded).
169169
///
170-
private func optimizedDotcomURL(from path: String) -> URL? {
171-
let size = SiteIconDefaults.imageSizeInPixels
172-
let query = String(format: "w=%d&h=%d", size, size)
170+
private func optimizedDotcomURL(from path: String, imageSize: CGSize = SiteIconDefaults.imageSize) -> URL? {
171+
let size = imageSize.toPixels()
172+
let query = String(format: "w=%d&h=%d", Int(size.width), Int(size.height))
173173

174174
return parseURL(path: path, query: query)
175175
}
@@ -179,9 +179,9 @@ private extension UIImageView {
179179
///
180180
/// - Parameter path: Blavatar URL (string encoded).
181181
///
182-
private func optimizedBlavatarURL(from path: String) -> URL? {
183-
let size = SiteIconDefaults.imageSizeInPixels
184-
let query = String(format: "d=404&s=%d", size)
182+
private func optimizedBlavatarURL(from path: String, imageSize: CGSize = SiteIconDefaults.imageSize) -> URL? {
183+
let size = imageSize.toPixels()
184+
let query = String(format: "d=404&s=%d", Int(max(size.width, size.height)))
185185

186186
return parseURL(path: path, query: query)
187187
}
@@ -191,13 +191,12 @@ private extension UIImageView {
191191
///
192192
/// - Parameter siteIconPath: SiteIcon URL (string encoded).
193193
///
194-
private func optimizedPhotonURL(from path: String) -> URL? {
194+
private func optimizedPhotonURL(from path: String, imageSize: CGSize = SiteIconDefaults.imageSize) -> URL? {
195195
guard let url = URL(string: path) else {
196196
return nil
197197
}
198198

199-
let size = CGSize(width: SiteIconDefaults.imageSize, height: SiteIconDefaults.imageSize)
200-
return PhotonImageURLHelper.photonURL(with: size, forImageURL: url)
199+
return PhotonImageURLHelper.photonURL(with: imageSize, forImageURL: url)
201200
}
202201

203202

@@ -267,3 +266,19 @@ private extension UIImageView {
267266
DDLogInfo("URL optimized from \(original) to \(optimized.absoluteString) for blog \(blogInfo)")
268267
}
269268
}
269+
270+
// MARK: - CGFloat Extension
271+
272+
private extension CGSize {
273+
274+
func toPixels() -> CGSize {
275+
return CGSize(width: width.toPixels(), height: height.toPixels())
276+
}
277+
}
278+
279+
private extension CGFloat {
280+
281+
func toPixels() -> CGFloat {
282+
return self * UIScreen.main.scale
283+
}
284+
}

WordPress/Classes/Models/Notifications/NotificationSettings.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,15 @@ open class NotificationSettings {
139139
}
140140

141141
// MARK: - Private Properties
142-
fileprivate let blogPreferenceKeys: [String] = {
142+
fileprivate var blogPreferenceKeys: [String] {
143143
var keys = [Keys.commentAdded, Keys.commentLiked, Keys.postLiked, Keys.follower, Keys.achievement, Keys.mention]
144144

145145
if Feature.enabled(.weeklyRoundup) {
146146
keys.append(Keys.weeklyRoundup)
147147
}
148148

149149
return keys
150-
}()
150+
}
151151
fileprivate let blogEmailPreferenceKeys = [Keys.commentAdded, Keys.commentLiked, Keys.postLiked, Keys.follower, Keys.mention]
152152
fileprivate let otherPreferenceKeys = [Keys.commentLiked, Keys.commentReplied]
153153
fileprivate let wpcomPreferenceKeys = [Keys.marketing, Keys.research, Keys.community]

0 commit comments

Comments
 (0)