Skip to content
This repository was archived by the owner on Oct 30, 2024. It is now read-only.

Commit 653e73d

Browse files
committed
Save AsyncTextAttachment rounded image separately, Fixed bug in SettingsTheme, Fixed iOS 12 rotation crash
1 parent 367ea34 commit 653e73d

File tree

8 files changed

+61
-38
lines changed

8 files changed

+61
-38
lines changed

Slide for Reddit.xcodeproj/xcshareddata/xcschemes/Slide for Apple Watch.xcscheme

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,33 +65,46 @@
6565
debugServiceExtension = "internal"
6666
allowLocationSimulation = "YES"
6767
notificationPayloadFile = "Slide for Apple Watch Extension/PushNotificationPayload.apns">
68-
<BuildableProductRunnable
69-
runnableDebuggingMode = "0">
68+
<RemoteRunnable
69+
runnableDebuggingMode = "2"
70+
BundleIdentifier = "com.apple.Carousel"
71+
RemotePath = "/$(USR_DISPLAY_NAME)">
7072
<BuildableReference
7173
BuildableIdentifier = "primary"
7274
BlueprintIdentifier = "BE20851021588F3900D8F33C"
7375
BuildableName = "Slide for Apple Watch.app"
7476
BlueprintName = "Slide for Apple Watch"
7577
ReferencedContainer = "container:Slide for Reddit.xcodeproj">
7678
</BuildableReference>
77-
</BuildableProductRunnable>
79+
</RemoteRunnable>
7880
</LaunchAction>
7981
<ProfileAction
8082
buildConfiguration = "Release"
8183
shouldUseLaunchSchemeArgsEnv = "YES"
8284
savedToolIdentifier = ""
8385
useCustomWorkingDirectory = "NO"
8486
debugDocumentVersioning = "YES">
85-
<BuildableProductRunnable
86-
runnableDebuggingMode = "0">
87+
<RemoteRunnable
88+
runnableDebuggingMode = "2"
89+
BundleIdentifier = "com.apple.Carousel"
90+
RemotePath = "/$(USR_DISPLAY_NAME)">
8791
<BuildableReference
8892
BuildableIdentifier = "primary"
8993
BlueprintIdentifier = "BE20851021588F3900D8F33C"
9094
BuildableName = "Slide for Apple Watch.app"
9195
BlueprintName = "Slide for Apple Watch"
9296
ReferencedContainer = "container:Slide for Reddit.xcodeproj">
9397
</BuildableReference>
94-
</BuildableProductRunnable>
98+
</RemoteRunnable>
99+
<MacroExpansion>
100+
<BuildableReference
101+
BuildableIdentifier = "primary"
102+
BlueprintIdentifier = "BE20851021588F3900D8F33C"
103+
BuildableName = "Slide for Apple Watch.app"
104+
BlueprintName = "Slide for Apple Watch"
105+
ReferencedContainer = "container:Slide for Reddit.xcodeproj">
106+
</BuildableReference>
107+
</MacroExpansion>
95108
</ProfileAction>
96109
<AnalyzeAction
97110
buildConfiguration = "Debug">

Slide for Reddit/AsyncTextAttachment.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,14 @@ public class AsyncTextAttachment: NSTextAttachment {
8484
}
8585

8686
private func getCacheImage(with: URL) -> UIImage? {
87-
return SDImageCache.shared.imageFromCache(forKey: with.absoluteString)
87+
return SDImageCache.shared.imageFromCache(forKey: with.absoluteString + "-round")
8888
}
8989

9090
private func downloadImage(with: URL) {
9191
SDWebImageDownloader.shared.downloadImage(with: with, options: [.decodeFirstFrameOnly], progress: nil) { (image, data, _, _) in
9292
let roundedImage = image?.circleCorners(finalSize: self.bounds.size)
9393
DispatchQueue.global(qos: .background).async {
94-
SDImageCache.shared.storeImage(toMemory: roundedImage, forKey: with.absoluteString)
94+
SDImageCache.shared.storeImage(toMemory: roundedImage, forKey: with.absoluteString + "-round")
9595
}
9696

9797
self.display(roundedImage, with: data, url: with)

Slide for Reddit/NavigationHomeViewController.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -568,10 +568,10 @@ extension NavigationHomeViewController: UITableViewDelegate, UITableViewDataSour
568568
} else {
569569
let thing: String
570570
if isSearching {
571-
print(users)
572-
print(suggestions)
573-
print(indexPath.row)
574571
if (indexPath.row > suggestions.count - 1 || suggestions.count == 0) && users.count > 0 {
572+
if users.count > indexPath.row - suggestions.count {
573+
574+
}
575575
thing = users[indexPath.row - suggestions.count]
576576
let c = tableView.dequeueReusableCell(withIdentifier: "sub", for: indexPath) as! SubredditCellView
577577
c.setProfile(profile: thing, nav: self)

Slide for Reddit/PostActions.swift

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,17 @@ class PostActions: NSObject {
9292

9393
parent.present(activityViewController, animated: true, completion: nil)
9494
case .CHROME:
95-
let open = OpenInChromeController.init()
96-
open.openInChrome(link.url!, callbackURL: nil, createNewTab: true)
95+
if link.url != nil {
96+
let open = OpenInChromeController.init()
97+
open.openInChrome(link.url!, callbackURL: nil, createNewTab: true)
98+
}
9799
case .SAFARI:
98-
if #available(iOS 10.0, *) {
99-
UIApplication.shared.open(link.url!, options: convertToUIApplicationOpenExternalURLOptionsKeyDictionary([:]), completionHandler: nil)
100-
} else {
101-
UIApplication.shared.openURL(link.url!)
100+
if link.url != nil {
101+
if #available(iOS 10.0, *) {
102+
UIApplication.shared.open(link.url!, options: convertToUIApplicationOpenExternalURLOptionsKeyDictionary([:]), completionHandler: nil)
103+
} else {
104+
UIApplication.shared.openURL(link.url!)
105+
}
102106
}
103107
case .FILTER:
104108
delegate.showFilterMenu(cell)

Slide for Reddit/SettingsTheme.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class SettingsTheme: BubbleSettingTableViewController, ColorPickerViewDelegate {
8282
} else {
8383
let alertController = UIAlertController(title: "\n\n\n\n\n\n\n\n", message: nil, preferredStyle: UIAlertController.Style.actionSheet)
8484
let margin: CGFloat = 10.0
85-
let rect = CGRect(x: margin, y: margin, width: UIScreen.main.traitCollection.userInterfaceIdiom == .pad ? 314 - margin * 4.0: alertController.view.bounds.size.width - margin * 4.0, height: 150)
85+
let rect = CGRect(x: margin, y: margin, width: UIScreen.main.traitCollection.userInterfaceIdiom == .pad ? 314 - margin * 4.0: UIScreen.main.bounds.size.width - margin * 4.0, height: 150)
8686
let MKColorPicker = ColorPickerView.init(frame: rect)
8787
MKColorPicker.delegate = self
8888
MKColorPicker.colors = GMPalette.allColor()
@@ -125,10 +125,18 @@ class SettingsTheme: BubbleSettingTableViewController, ColorPickerViewDelegate {
125125
presenter.sourceRect = selectedTableView.bounds
126126
}
127127

128-
present(alertController, animated: false, completion: nil)
128+
UIApplication.shared.keyWindow?.rootViewController?.present(alertController, animated: true, completion: nil)
129129
}
130130
}
131131

132+
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
133+
if indexPath.section > 0 {
134+
return 60
135+
} else {
136+
return UITableView.automaticDimension
137+
}
138+
}
139+
132140
func redoThemes() {
133141
self.customThemes.removeAll()
134142
self.themes.removeAll()

Slide for Reddit/SingleSubredditViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1502,7 +1502,7 @@ class SingleSubredditViewController: MediaViewController, AutoplayScrollViewDele
15021502

15031503
func preloadImages(_ values: [RSubmission]) {
15041504
var urls: [URL] = []
1505-
if !SettingValues.noImages && !(SettingValues.dataSavingDisableWiFi && LinkCellView.checkWiFi()) && SettingValues.dataSavingEnabled {
1505+
if (SettingValues.dataSavingEnabled && (SettingValues.dataSavingDisableWiFi && LinkCellView.checkWiFi()) && SettingValues.noImages) || !SettingValues.dataSavingEnabled {
15061506
for submission in values {
15071507
var thumb = submission.thumbnail
15081508
var big = submission.banner

Slide for Reddit/SwipeForwardNavigationController.swift

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,11 @@ extension SwipeForwardNavigationController {
235235
not14 = false
236236
}
237237
if let secondaryAsNav = secondaryViewController as? UINavigationController, (UIDevice.current.userInterfaceIdiom == .phone || not14) {
238-
viewControllers += secondaryAsNav.viewControllers
238+
for viewController in secondaryAsNav.viewControllers {
239+
if !viewControllers.contains(viewController) {
240+
viewControllers.append(viewController)
241+
}
242+
}
239243
}
240244
}
241245

@@ -255,25 +259,19 @@ extension SwipeForwardNavigationController {
255259

256260
extension SwipeForwardNavigationController: UISplitViewControllerDelegate {
257261
func splitViewController(_ splitViewController: UISplitViewController, separateSecondaryFrom primaryViewController: UIViewController) -> UIViewController? {
258-
var not14 = true
259-
if #available(iOS 14, *) {
260-
not14 = false
261-
}
262-
263-
return self //Disable left sidebar
264-
265-
/*if UIDevice.current.userInterfaceIdiom == .phone || not14 {
266-
guard let primaryNavigation = primaryViewController as? UINavigationController else {
267-
return nil
262+
if #available(iOS 13, *) {
263+
return self //Disable left sidebar
264+
} else {
265+
if UIDevice.current.userInterfaceIdiom == .phone {
266+
guard let primaryNavigation = primaryViewController as? UINavigationController else {
267+
return nil
268+
}
269+
return decomposeStackForTransitionToRegular(primaryNavigation)
268270
}
269-
270-
return decomposeStackForTransitionToRegular(primaryNavigation)
271-
272271
}
273-
return nil*/
272+
return nil
274273
}
275274

276-
/* Unused
277275
func decomposeStackForTransitionToRegular(_ navigationController: UINavigationController) -> UIViewController? {
278276
var main: UIViewController?
279277
var newViewControllers = [UIViewController]()
@@ -299,7 +297,7 @@ extension SwipeForwardNavigationController: UISplitViewControllerDelegate {
299297
return SwipeForwardNavigationController(rootViewController: main)
300298
}
301299
return nil
302-
} */
300+
}
303301
}
304302

305303
extension SwipeForwardNavigationController: UINavigationControllerDelegate {

Slide for Reddit/WebsiteViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ class WebsiteViewController: MediaViewController, WKNavigationDelegate {
304304
}
305305

306306
func loadUrl() {
307-
if url?.host == "twitter.com" {
307+
if url?.host == "twitter.com" && UIDevice.current.userInterfaceIdiom == .pad {
308308
webView.customUserAgent = "Googlebot/2.1 (+http://www.google.com/bot.html)"
309309
}
310310
let myURLRequest: URLRequest = URLRequest(url: url!)

0 commit comments

Comments
 (0)