Skip to content

Commit 4816aee

Browse files
1.52.10/1.15.4
1 parent 2e6c2ca commit 4816aee

File tree

171 files changed

+5401
-2437
lines changed

Some content is hidden

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

171 files changed

+5401
-2437
lines changed

About/AboutViewController.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#import "DebugHelper.h"
1111
#import "ClipboardManager.h"
1212
#import "Alerts.h"
13-
#import "SharedAppAndAutoFillSettings.h"
13+
#import "AppPreferences.h"
1414
#import "Utils.h"
1515
#import "ProUpgradeIAPManager.h"
1616

@@ -27,7 +27,7 @@ @implementation AboutViewController
2727
- (void)viewDidLoad {
2828
[super viewDidLoad];
2929

30-
if([[SharedAppAndAutoFillSettings sharedInstance] isPro]) {
30+
if([[AppPreferences sharedInstance] isPro]) {
3131
NSString* about = [NSString stringWithFormat:
3232
NSLocalizedString(@"prefs_vc_app_version_info_pro_fmt", @"About Strongbox Pro %@"), [Utils getAppVersion]];
3333

AppPrivacyShieldMode.h

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//
2+
// AppPrivacyShieldMode.h
3+
// Strongbox
4+
//
5+
// Created by Strongbox on 16/03/2021.
6+
// Copyright © 2021 Mark McGuill. All rights reserved.
7+
//
8+
9+
#ifndef AppPrivacyShieldMode_h
10+
#define AppPrivacyShieldMode_h
11+
12+
typedef NS_ENUM (NSInteger, AppPrivacyShieldMode) {
13+
kAppPrivacyShieldModeNone,
14+
kAppPrivacyShieldModeBlur,
15+
kAppPrivacyShieldModePixellate,
16+
kAppPrivacyShieldModeBlueScreen,
17+
};
18+
19+
#endif /* AppPrivacyShieldMode_h */

CustomFieldTableCell.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#import "CustomFieldTableCell.h"
1010
#import "ColoredStringHelper.h"
11-
#import "SharedAppAndAutoFillSettings.h"
11+
#import "AppPreferences.h"
1212

1313
NSString *const CustomFieldCellHeightChanged = @"CustomFieldCellHeightChangedNotification";
1414

@@ -83,7 +83,7 @@ - (void)bindConcealed {
8383
if (@available(iOS 12.0, *)) {
8484
dark = self.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark;
8585
}
86-
BOOL colorBlind = SharedAppAndAutoFillSettings.sharedInstance.colorizeUseColorBlindPalette;
86+
BOOL colorBlind = AppPreferences.sharedInstance.colorizeUseColorBlindPalette;
8787

8888
self.valueLabel.attributedText = [ColoredStringHelper getColorizedAttributedString:self._value
8989
colorize:self.colorize

FileManager.m

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#import "FileManager.h"
1010
#import "SafesList.h"
1111
#import "DatabaseModel.h"
12-
#import "SharedAppAndAutoFillSettings.h"
12+
#import "AppPreferences.h"
1313

1414
static NSString* const kEncAttachmentDirectoryName = @"_strongbox_enc_att";
1515

@@ -102,9 +102,9 @@ - (NSURL *)preferencesDirectory {
102102
}
103103

104104
- (NSURL *)sharedAppGroupDirectory {
105-
NSURL* url = [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:SharedAppAndAutoFillSettings.sharedInstance.appGroupName];
105+
NSURL* url = [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:AppPreferences.sharedInstance.appGroupName];
106106
if(!url) {
107-
NSLog(@"Could not get container URL for App Group: [%@]", SharedAppAndAutoFillSettings.sharedInstance.appGroupName);
107+
NSLog(@"Could not get container URL for App Group: [%@]", AppPreferences.sharedInstance.appGroupName);
108108
return nil;
109109
}
110110

@@ -242,7 +242,7 @@ - (void)setIncludeExcludeFromBackup:(NSURL*)URL include:(BOOL)include {
242242
NSLog(@"Error setting include/exclude %@ from backup %@", [URL lastPathComponent], error);
243243
}
244244
else {
245-
NSLog(@"%@ [%@] from backup", include ? @"Included" : @"Excluded", URL);
245+
246246
}
247247
}
248248

@@ -329,7 +329,7 @@ - (NSString*)tmpAttachmentPreviewPath {
329329
NSLog(@"Error Creating Directory: %@ => [%@]", ret, error.localizedDescription);
330330
}
331331

332-
NSLog(@"Temp Attachment Path = [%@]", ret);
332+
333333

334334
return ret;
335335
}

GzipDecompressOutputStream.m

+13-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ @interface GzipDecompressOutputStream ()
1616
@property z_stream* stream;
1717
@property NSError* error;
1818

19+
1920
@end
2021

2122
@implementation GzipDecompressOutputStream
@@ -101,9 +102,20 @@ - (NSInteger)write:(const uint8_t *)buffer maxLength:(NSUInteger)len {
101102
}
102103

103104
size_t writtenThisTime = len - self.stream->avail_out;
104-
[self.outputStream write:decompressed maxLength:writtenThisTime];
105105

106+
if ( writtenThisTime > 0 ) {
107+
NSInteger res = [self.outputStream write:decompressed maxLength:writtenThisTime];
108+
if ( res < 0 ) {
109+
NSLog(@"GzipDecompressOutputStream: Could not write to output stream.");
110+
return res;
111+
}
112+
}
113+
114+
106115
totalWritten += writtenThisTime;
116+
117+
118+
107119
remainingIn = self.stream->avail_in;
108120
}
109121

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Big thank you to all the localization contributors
2929
- Italian - Marco Ermini
3030
- Japanese - Anonymous
3131
- Norwegian - Ole Aldric
32+
- Portuguese (PT-BR) - Wolfgang Marcos
3233
- Russian - Wishes to remain anonymous
3334
- Spanish - Wishes to remain anonymous
3435
- Swedish - Jari Häkkinen

StrongBox Auto Fill/AutoFillPreferencesViewController.h

+3
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@
77
//
88

99
#import <UIKit/UIKit.h>
10+
#import "Model.h"
1011

1112
NS_ASSUME_NONNULL_BEGIN
1213

1314
@interface AutoFillPreferencesViewController : UITableViewController
1415

16+
@property Model* viewModel;
17+
1518
@end
1619

1720
NS_ASSUME_NONNULL_END

StrongBox Auto Fill/AutoFillPreferencesViewController.m

+212-10
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,27 @@
77
//
88

99
#import "AutoFillPreferencesViewController.h"
10-
#import "AutoFillSettings.h"
10+
#import "AppPreferences.h"
11+
#import "AutoFillManager.h"
12+
#import "NSArray+Extensions.h"
13+
#import "SelectItemTableViewController.h"
14+
#import "Utils.h"
1115

1216
@interface AutoFillPreferencesViewController ()
1317

1418
@property (weak, nonatomic) IBOutlet UISwitch *autoProceed;
1519
@property (weak, nonatomic) IBOutlet UISwitch *addServiceIds;
1620
@property (weak, nonatomic) IBOutlet UISwitch *useHostOnlyUrl;
17-
@property (weak, nonatomic) IBOutlet UISwitch *mainAppSyncReminder;
21+
22+
@property (weak, nonatomic) IBOutlet UISwitch *switchAutoFill;
23+
@property (weak, nonatomic) IBOutlet UISwitch *switchQuickTypeAutoFill;
24+
@property (weak, nonatomic) IBOutlet UITableViewCell *cellQuickTypeFormat;
25+
@property (weak, nonatomic) IBOutlet UILabel *labelQuickTypeFormat;
26+
@property (weak, nonatomic) IBOutlet UITableViewCell *cellConvenienceAutoUnlock;
27+
@property (weak, nonatomic) IBOutlet UILabel *labelConvenienceAutoUnlockTimeout;
28+
@property (weak, nonatomic) IBOutlet UISwitch *switchCopyTOTP;
29+
@property (weak, nonatomic) IBOutlet UISwitch *switchAutoLaunchSingle;
30+
@property (weak, nonatomic) IBOutlet UISwitch *switchShowPinned;
1831

1932
@end
2033

@@ -27,23 +40,212 @@ - (void)viewDidLoad {
2740
}
2841

2942
- (void)bind {
30-
self.autoProceed.on = AutoFillSettings.sharedInstance.autoProceedOnSingleMatch;
31-
self.addServiceIds.on = AutoFillSettings.sharedInstance.storeAutoFillServiceIdentifiersInNotes;
32-
self.useHostOnlyUrl.on = !AutoFillSettings.sharedInstance.useFullUrlAsURLSuggestion;
33-
self.mainAppSyncReminder.on = !AutoFillSettings.sharedInstance.dontNotifyToSwitchToMainAppForSync;
43+
self.autoProceed.on = AppPreferences.sharedInstance.autoProceedOnSingleMatch;
44+
self.addServiceIds.on = AppPreferences.sharedInstance.storeAutoFillServiceIdentifiersInNotes;
45+
self.useHostOnlyUrl.on = !AppPreferences.sharedInstance.useFullUrlAsURLSuggestion;
46+
47+
self.switchAutoFill.on = self.viewModel.metadata.autoFillEnabled;
48+
49+
50+
51+
self.switchQuickTypeAutoFill.on = self.viewModel.metadata.autoFillEnabled && self.viewModel.metadata.quickTypeEnabled;
52+
self.switchQuickTypeAutoFill.enabled = self.switchAutoFill.on;
53+
54+
55+
56+
self.cellQuickTypeFormat.userInteractionEnabled = self.switchQuickTypeAutoFill.on;
57+
self.labelQuickTypeFormat.text = quickTypeFormatString(self.viewModel.metadata.quickTypeDisplayFormat);
58+
if (@available(iOS 13.0, *)) {
59+
self.labelQuickTypeFormat.textColor = self.switchQuickTypeAutoFill.on ? UIColor.labelColor : UIColor.secondaryLabelColor;
60+
}
61+
else {
62+
self.labelQuickTypeFormat.textColor = self.switchQuickTypeAutoFill.on ? UIColor.blackColor : UIColor.lightGrayColor;
63+
}
64+
65+
66+
67+
self.cellConvenienceAutoUnlock.userInteractionEnabled = self.viewModel.metadata.autoFillEnabled;
68+
self.labelConvenienceAutoUnlockTimeout.text = stringForConvenienceAutoUnlock(self.viewModel.metadata.autoFillConvenienceAutoUnlockTimeout);
69+
70+
if (@available(iOS 13.0, *)) {
71+
self.labelConvenienceAutoUnlockTimeout.textColor = self.viewModel.metadata.autoFillEnabled ? UIColor.labelColor : UIColor.secondaryLabelColor;
72+
}
73+
else {
74+
self.labelConvenienceAutoUnlockTimeout.textColor = self.viewModel.metadata.autoFillEnabled ? UIColor.blackColor : UIColor.lightGrayColor;
75+
}
76+
77+
78+
79+
self.switchAutoLaunchSingle.on = AppPreferences.sharedInstance.autoFillAutoLaunchSingleDatabase;
80+
81+
82+
83+
self.switchCopyTOTP.on = self.viewModel.metadata.autoFillCopyTotp;
84+
85+
86+
87+
self.switchShowPinned.on = AppPreferences.sharedInstance.autoFillShowPinned;
88+
}
89+
90+
static NSString* stringForConvenienceAutoUnlock(NSInteger val) {
91+
if (val == -1) {
92+
return NSLocalizedString(@"generic_preference_not_configured", @"Not Configured");
93+
}
94+
else if ( val == 0 ) {
95+
return NSLocalizedString(@"prefs_vc_setting_disabled", @"Disabled");
96+
}
97+
else {
98+
return [Utils formatTimeInterval:val];
99+
}
34100
}
35101

36102
- (IBAction)onDone:(id)sender {
37103
[self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
38104
}
39105

40106
- (IBAction)onChanged:(id)sender {
41-
AutoFillSettings.sharedInstance.autoProceedOnSingleMatch = self.autoProceed.on;
42-
AutoFillSettings.sharedInstance.storeAutoFillServiceIdentifiersInNotes = self.addServiceIds.on;
43-
AutoFillSettings.sharedInstance.useFullUrlAsURLSuggestion = !self.useHostOnlyUrl.on;
44-
AutoFillSettings.sharedInstance.dontNotifyToSwitchToMainAppForSync = !self.mainAppSyncReminder.on;
107+
AppPreferences.sharedInstance.autoProceedOnSingleMatch = self.autoProceed.on;
108+
AppPreferences.sharedInstance.storeAutoFillServiceIdentifiersInNotes = self.addServiceIds.on;
109+
AppPreferences.sharedInstance.useFullUrlAsURLSuggestion = !self.useHostOnlyUrl.on;
110+
AppPreferences.sharedInstance.autoFillAutoLaunchSingleDatabase = self.switchAutoLaunchSingle.on;
111+
AppPreferences.sharedInstance.autoFillShowPinned = self.switchShowPinned.on;
45112

46113
[self bind];
47114
}
48115

116+
- (IBAction)onCopyTotp:(id)sender {
117+
self.viewModel.metadata.autoFillCopyTotp = self.switchCopyTOTP.on;
118+
[[SafesList sharedInstance] update:self.viewModel.metadata];
119+
120+
[self bind];
121+
}
122+
123+
- (IBAction)onSwitchQuickTypeAutoFill:(id)sender {
124+
if ( !self.switchQuickTypeAutoFill.on ) {
125+
[AutoFillManager.sharedInstance clearAutoFillQuickTypeDatabase];
126+
}
127+
else {
128+
[AutoFillManager.sharedInstance updateAutoFillQuickTypeDatabase:self.viewModel.database
129+
databaseUuid:self.viewModel.metadata.uuid
130+
displayFormat:self.viewModel.metadata.quickTypeDisplayFormat];
131+
}
132+
133+
self.viewModel.metadata.quickTypeEnabled = self.switchQuickTypeAutoFill.on;
134+
[[SafesList sharedInstance] update:self.viewModel.metadata];
135+
136+
[self bind];
137+
}
138+
139+
- (IBAction)onSwitchAutoFill:(id)sender {
140+
if (!self.switchAutoFill.on) {
141+
[self.viewModel disableAndClearAutoFill];
142+
[self bind];
143+
}
144+
else {
145+
[self.viewModel enableAutoFill];
146+
147+
if ( self.viewModel.metadata.quickTypeEnabled ) {
148+
[AutoFillManager.sharedInstance updateAutoFillQuickTypeDatabase:self.viewModel.database
149+
databaseUuid:self.viewModel.metadata.uuid
150+
displayFormat:self.viewModel.metadata.quickTypeDisplayFormat];
151+
}
152+
153+
[self bind];
154+
}
155+
}
156+
157+
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
158+
UITableViewCell* cell = [self.tableView cellForRowAtIndexPath:indexPath];
159+
160+
if ( cell == self.cellQuickTypeFormat ) {
161+
[self promptForQuickTypeFormat];
162+
}
163+
else if ( cell == self.cellConvenienceAutoUnlock ) {
164+
[self promptForConvenienceAutoUnlock];
165+
}
166+
167+
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
168+
}
169+
170+
- (void)promptForConvenienceAutoUnlock {
171+
NSArray<NSNumber*>* options = @[@(0), @(15), @(30), @(60), @(120), @(180), @(300), @(600), @(1200), @(1800), @(3600), @(2 * 3600), @(8 * 3600), @(24 * 3600), @(48 * 3600), @(72 * 3600)];
172+
173+
NSArray<NSString*>* optionsStrings = [options map:^id _Nonnull(NSNumber * _Nonnull obj, NSUInteger idx) {
174+
return stringForConvenienceAutoUnlock(obj.integerValue);
175+
}];
176+
177+
NSUInteger currentlySelected = [options indexOfObject:@(self.viewModel.metadata.autoFillConvenienceAutoUnlockTimeout)];
178+
179+
[self promptForChoice:NSLocalizedString(@"prefs_vc_autofill_convenience_auto_unlock", @"Convenience Auto Unlock")
180+
options:optionsStrings
181+
currentlySelectIndex:currentlySelected
182+
completion:^(BOOL success, NSInteger selectedIndex) {
183+
if (success) {
184+
NSNumber *numFormat = options[selectedIndex];
185+
self.viewModel.metadata.autoFillConvenienceAutoUnlockTimeout = numFormat.integerValue;
186+
[SafesList.sharedInstance update:self.viewModel.metadata];
187+
188+
if (self.viewModel.metadata.autoFillConvenienceAutoUnlockTimeout == 0) {
189+
self.viewModel.metadata.autoFillConvenienceAutoUnlockPassword = nil;
190+
}
191+
192+
[self bind];
193+
}
194+
}];
195+
}
196+
197+
- (void)promptForQuickTypeFormat {
198+
NSArray<NSNumber*>* options = @[@(kQuickTypeFormatTitleThenUsername),
199+
@(kQuickTypeFormatUsernameOnly),
200+
@(kQuickTypeFormatTitleOnly)];
201+
202+
NSArray<NSString*>* optionsStrings = [options map:^id _Nonnull(NSNumber * _Nonnull obj, NSUInteger idx) {
203+
return quickTypeFormatString(obj.integerValue);
204+
}];
205+
206+
NSUInteger currentlySelected = [options indexOfObject:@(self.viewModel.metadata.quickTypeDisplayFormat)];
207+
208+
[self promptForChoice:NSLocalizedString(@"prefs_vc_quick_type_format", @"QuickType Format")
209+
options:optionsStrings
210+
currentlySelectIndex:currentlySelected
211+
completion:^(BOOL success, NSInteger selectedIndex) {
212+
if (success) {
213+
NSNumber *numFormat = options[selectedIndex];
214+
self.viewModel.metadata.quickTypeDisplayFormat = numFormat.integerValue;
215+
[SafesList.sharedInstance update:self.viewModel.metadata];
216+
217+
218+
[AutoFillManager.sharedInstance updateAutoFillQuickTypeDatabase:self.viewModel.database
219+
databaseUuid:self.viewModel.metadata.uuid
220+
displayFormat:self.viewModel.metadata.quickTypeDisplayFormat];
221+
222+
[self bind];
223+
}
224+
}];
225+
}
226+
227+
- (void)promptForChoice:(NSString*)title
228+
options:(NSArray<NSString*>*)items
229+
currentlySelectIndex:(NSUInteger)currentlySelectIndex
230+
completion:(void(^)(BOOL success, NSInteger selectedIndex))completion {
231+
UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@"SelectItem" bundle:nil];
232+
UINavigationController* nav = (UINavigationController*)[storyboard instantiateInitialViewController];
233+
SelectItemTableViewController *vc = (SelectItemTableViewController*)nav.topViewController;
234+
235+
vc.groupItems = @[items];
236+
237+
if ( currentlySelectIndex != NSNotFound ) {
238+
vc.selectedIndexPaths = @[[NSIndexSet indexSetWithIndex:currentlySelectIndex]];
239+
}
240+
241+
vc.onSelectionChange = ^(NSArray<NSIndexSet *> * _Nonnull selectedIndices) {
242+
NSIndexSet* set = selectedIndices.firstObject;
243+
[self.navigationController popViewControllerAnimated:YES];
244+
completion(YES, set.firstIndex);
245+
};
246+
247+
vc.title = title;
248+
[self.navigationController pushViewController:vc animated:YES];
249+
}
250+
49251
@end

0 commit comments

Comments
 (0)