Skip to content

Commit 289f44c

Browse files
committed
fix: Fixes old preferences not being loaded properly
1 parent 6882798 commit 289f44c

File tree

5 files changed

+35
-18
lines changed

5 files changed

+35
-18
lines changed

Sources/Pinnacle/Hooks/SBIconViewHook.x.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,13 +234,19 @@ class SBIconViewHook: ClassHook<SBIconView> {
234234
activeIconList = nil
235235
}
236236

237+
// orion:new
238+
func _pinnacleGetImageSize() -> CGRect {
239+
return target.iconImageFrame()
240+
}
241+
237242
// orion:new
238243
/// Moves by the values provided
239244
func _pinnacleMoveWith(x: Int, y: Int) {
240245
let amount = _pinnacleGetEffectiveIconSpacing()
246+
let imageSize = target._pinnacleGetImageSize()
241247

242-
let height = target.iconImageFrame.height + amount.height
243-
let width = target.iconImageFrame.width + amount.width
248+
let height = imageSize.height + amount.height
249+
let width = imageSize.width + amount.width
244250

245251
UIView.animate(
246252
withDuration: settings!.iconMoveDuration,

Sources/Pinnacle/PinnacleIconView.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ class PinnacleIconView: SBIconView {
1010
var parentBundle = ""
1111
var index = 0
1212

13+
var imageView: UIImageView? = nil
14+
1315
convenience init(fromIconView: SBIconView, xDir: Int, yDir: Int, bundle: String, parentBundle: String, index: Int, isEditing: Bool) {
1416
self.init()
1517
setupCommonProperties(xDir: xDir, yDir: yDir, bundle: bundle, parentBundle: parentBundle, index: index)
@@ -44,6 +46,8 @@ class PinnacleIconView: SBIconView {
4446

4547
imageView.addGestureRecognizer(gesture)
4648

49+
self.imageView = imageView
50+
4751
self.addSubview(imageView)
4852
self.isPlaceholder = true
4953

@@ -80,6 +84,14 @@ class PinnacleIconView: SBIconView {
8084

8185
}
8286

87+
override func _pinnacleGetImageSize() -> CGRect {
88+
if let imageView = self.imageView {
89+
return imageView.frame
90+
} else {
91+
return iconImageFrame()
92+
}
93+
}
94+
8395
@objc func handleTap() {
8496
let window = PinnacleIconPicker(frame: UIScreen.main.bounds)
8597
if !isPlaceholder {

Sources/Pinnacle/Tweak.x.swift

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,8 @@ class Pinnacle: Tweak {
2424

2525

2626
func loadSettings() {
27-
do {
28-
try TweakPreferences.shared.loadSettings()
27+
TweakPreferences.shared.loadSettings()
2928
settings = TweakPreferences.shared.settings
30-
} catch {
31-
remLog("Failed to load settings: \(error)")
32-
remLog(error)
33-
}
3429
}
3530

3631
var active: Bool = false

Sources/Pinnacle/TweakPreferences.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ final class TweakPreferences {
77

88
private let preferencesFilePath = "/var/mobile/Library/Preferences/dev.rugmj.pinnacleprefs.plist"
99

10-
func loadSettings() throws {
11-
if let data = FileManager.default.contents(atPath: preferencesFilePath) {
12-
self.settings = try PropertyListDecoder().decode(Settings.self, from: data)
10+
func loadSettings() {
11+
if let data = try? Data(contentsOf: URL(fileURLWithPath: preferencesFilePath)),
12+
let decodedSettings = try? PropertyListDecoder().decode(Settings.self, from: data) {
13+
self.settings = decodedSettings
1314
} else {
1415
self.settings = Settings()
1516
}

Sources/PinnacleC/include/Tweak.h

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#import <AltList/LSApplicationProxy+AltList.h>
2-
#include <UIKit/UIViewController.h>
32
#import <Foundation/NSValue.h>
43
#import <MobileCoreServices/LSApplicationProxy.h>
54
#import <MobileCoreServices/LSApplicationWorkspace.h>
@@ -26,20 +25,24 @@ NSString *plusCirclePath();
2625
@end
2726

2827
@interface SBFloatingDockController : UIViewController
29-
- (void)_presentFloatingDockIfDismissedAnimated:(BOOL)present completionHandler:(id)completionHandler;
30-
- (void)_dismissFloatingDockIfPresentedAnimated:(BOOL)dismiss completionHandler:(id)completionHandler;
28+
- (void)_presentFloatingDockIfDismissedAnimated:(BOOL)present
29+
completionHandler:(id)completionHandler;
30+
- (void)_dismissFloatingDockIfPresentedAnimated:(BOOL)dismiss
31+
completionHandler:(id)completionHandler;
3132
@end
3233

3334
@interface SBFloatingDockBehaviorAssertion : NSObject
3435
@property SBFloatingDockController *floatingDockController;
3536
@end
3637

3738
@interface SBHomeScreenViewController : UIViewController
38-
@property (nonatomic, strong, readwrite) SBFloatingDockBehaviorAssertion *homeScreenFloatingDockAssertion;
39+
@property(nonatomic, strong, readwrite)
40+
SBFloatingDockBehaviorAssertion *homeScreenFloatingDockAssertion;
3941
@end
4042

4143
@interface SBIconController ()
42-
@property (nonatomic, weak, readwrite) SBHomeScreenViewController *parentViewController;
44+
@property(nonatomic, weak, readwrite)
45+
SBHomeScreenViewController *parentViewController;
4346
@end
4447

4548
@interface SBRootFolderView ()
@@ -74,9 +77,9 @@ NSString *plusCirclePath();
7477
- (void)_pinnacleReset;
7578
- (void)_pinnacleCalculateRowAndColumn;
7679
- (CGSize)_pinnacleGetEffectiveIconSpacing;
80+
- (CGRect)_pinnacleGetImageSize;
7781
- (SBIconListView *)_pinnacleGetIconList;
78-
@property CGRect iconImageFrame;
79-
- (NSString *)applicationBundleIdentifierForShortcuts;
82+
- (CGRect)iconImageFrame;
8083
- (NSArray<NSNumber *> *)_pinnacleCalcAvailableDirections;
8184
- (void)_removeJitter;
8285
- (void)setEditing:(BOOL)arg;

0 commit comments

Comments
 (0)