Skip to content
This repository has been archived by the owner on Nov 6, 2021. It is now read-only.

Replaced deprecated UISearchDisplayController with new UISearchController #78

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
9f4e140
Replaced deprecated UISearchDisplayController with new UISearchContro…
tladesignz Mar 12, 2019
52b9598
README: endless is no longer in the App Store
jcs Mar 18, 2019
122b559
Merge remote-tracking branch 'upstream/master'
tladesignz Mar 22, 2019
803b52c
Allow automatic size adjustment of menu labels. Important for transla…
tladesignz Mar 22, 2019
1c5a845
Fixed stupid translation.
tladesignz Mar 22, 2019
5e58b4e
Silence deprecation warnings about stuff (esp. UIWebView) this app is…
tladesignz Mar 22, 2019
2465e72
Fixed retain cycle warnings.
tladesignz Mar 22, 2019
40b1e65
Silence warning about leak when calling #performSelector, since the c…
tladesignz Mar 22, 2019
7da71cc
Removed deprecated method #application:openURL:sourceAplication:annot…
tladesignz Mar 22, 2019
8f998f8
Update to CocoaPods 1.6.1.
tladesignz Mar 22, 2019
440f66f
Fixed issue on iPhone X, where the address field moves under the notc…
tladesignz Mar 22, 2019
fa8f89c
Fixed issues presented by new Xcode 10.2.
tladesignz Apr 2, 2019
e3a0bb8
Removed check for orientation when calculating status bar height. Loo…
tladesignz Apr 2, 2019
ba947f5
Allow static image files when using "strict" content mode.
tladesignz Apr 3, 2019
9f64ab4
Added "Open in Background Tab" feature into long-tap context menu for…
tladesignz Apr 3, 2019
ce20980
Fixed broken "Save Image" functionality.
tladesignz Apr 3, 2019
09cc4d9
Improve UI for settings: "Content Policy: Strict" can't have "Allow W…
tladesignz Apr 9, 2019
6a6ac9e
Added missing localizations.
tladesignz Apr 9, 2019
50eff1d
Added missing localizations.
tladesignz Apr 9, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion Endless.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
01FE82961FC0DC94006E5777 /* BlackIcon-83.5@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 01FE82951FC0DC94006E5777 /* BlackIcon-83.5@2x.png */; };
A024D5AE1ECEF10F00B28CC5 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = A024D5AA1ECEF10F00B28CC5 /* Localizable.strings */; };
A024D5AF1ECEF10F00B28CC5 /* OnePasswordExtension.strings in Resources */ = {isa = PBXBuildFile; fileRef = A024D5AC1ECEF10F00B28CC5 /* OnePasswordExtension.strings */; };
A09A2AA52254BB2E00A3EEF0 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = A09A2AA72254BB2E00A3EEF0 /* InfoPlist.strings */; };
AA9A5FECA2E668F834FDECD9 /* libPods-Endless.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 095BC7BD685DE17FADDBF166 /* libPods-Endless.a */; };
D919EA71FF999D55CCC96334 /* libPods-Endless Tests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FC10255E5E506A0C25D6276B /* libPods-Endless Tests.a */; };
/* End PBXBuildFile section */
Expand Down Expand Up @@ -241,6 +242,9 @@
A024D5AD1ECEF10F00B28CC5 /* Base */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = Base; path = Endless/Base.lproj/OnePasswordExtension.strings; sourceTree = "<group>"; };
A024D5B01ECEF11A00B28CC5 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = Endless/de.lproj/Localizable.strings; sourceTree = "<group>"; };
A024D5B11ECEF11A00B28CC5 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = Endless/de.lproj/OnePasswordExtension.strings; sourceTree = "<group>"; };
A07E147222381A8700B76F77 /* SilenceWarnings.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SilenceWarnings.h; sourceTree = "<group>"; };
A09A2AA62254BB2E00A3EEF0 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
A09A2AA82254BB2F00A3EEF0 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/InfoPlist.strings; sourceTree = "<group>"; };
FC10255E5E506A0C25D6276B /* libPods-Endless Tests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Endless Tests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
FDEC322B35C8D861612E24E3 /* Pods-Endless Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Endless Tests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Endless Tests/Pods-Endless Tests.debug.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -360,6 +364,7 @@
01D42C3B1E0A37DB00566022 /* Endless.entitlements */,
018333CF1A351B3B00670CD1 /* Endless-Prefix.pch */,
01801E961A32CA2A002B4718 /* Info.plist */,
A09A2AA72254BB2E00A3EEF0 /* InfoPlist.strings */,
01801E971A32CA2A002B4718 /* main.m */,
01F7CB4C1A52FC4E00F42B73 /* NSString+IPAddress.h */,
01F7CB4D1A52FC4E00F42B73 /* NSString+IPAddress.m */,
Expand All @@ -372,6 +377,7 @@
013E71CF1E5150C000BB0572 /* urlblocker.json */,
015748031E208C5000DB2044 /* UIResponder+FirstResponder.h */,
015748041E208C5000DB2044 /* UIResponder+FirstResponder.m */,
A07E147222381A8700B76F77 /* SilenceWarnings.h */,
);
name = "Supporting Files";
path = Endless;
Expand Down Expand Up @@ -602,7 +608,7 @@
};
buildConfigurationList = 01801E8D1A32CA2A002B4718 /* Build configuration list for PBXProject "Endless" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Expand Down Expand Up @@ -633,6 +639,7 @@
018333E91A35746500670CD1 /* https-everywhere_rules.plist in Resources */,
01801EC31A3360F8002B4718 /* InAppSettings.bundle in Resources */,
A024D5AF1ECEF10F00B28CC5 /* OnePasswordExtension.strings in Resources */,
A09A2AA52254BB2E00A3EEF0 /* InfoPlist.strings in Resources */,
01D7412C1A45F8EB007B7033 /* injected.js in Resources */,
01801EA61A32CA2A002B4718 /* Images.xcassets in Resources */,
01BFEE4A1E3D3CD60069AC83 /* urlblocker.json in Resources */,
Expand Down Expand Up @@ -838,6 +845,15 @@
name = OnePasswordExtension.strings;
sourceTree = "<group>";
};
A09A2AA72254BB2E00A3EEF0 /* InfoPlist.strings */ = {
isa = PBXVariantGroup;
children = (
A09A2AA62254BB2E00A3EEF0 /* en */,
A09A2AA82254BB2F00A3EEF0 /* de */,
);
name = InfoPlist.strings;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */

/* Begin XCBuildConfiguration section */
Expand Down
35 changes: 16 additions & 19 deletions Endless/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -111,22 +111,6 @@ - (void)applicationWillTerminate:(UIApplication *)application
[application ignoreSnapshotOnNextApplicationLaunch];
}

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
#ifdef TRACE
NSLog(@"[AppDelegate] request to open url at launch: %@", url);
#endif
if ([[[url scheme] lowercaseString] isEqualToString:@"endlesshttp"])
url = [NSURL URLWithString:[[url absoluteString] stringByReplacingCharactersInRange:NSMakeRange(0, [@"endlesshttp" length]) withString:@"http"]];
else if ([[[url scheme] lowercaseString] isEqualToString:@"endlesshttps"])
url = [NSURL URLWithString:[[url absoluteString] stringByReplacingCharactersInRange:NSMakeRange(0, [@"endlesshttps" length]) withString:@"https"]];

/* delay until we're done drawing the UI */
self.urlToOpenAtLaunch = url;

return YES;
}

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
#ifdef TRACE
Expand All @@ -138,9 +122,22 @@ - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDiction
else if ([[[url scheme] lowercaseString] isEqualToString:@"endlesshttps"])
url = [NSURL URLWithString:[[url absoluteString] stringByReplacingCharactersInRange:NSMakeRange(0, [@"endlesshttps" length]) withString:@"https"]];

[[self webViewController] dismissViewControllerAnimated:YES completion:nil];
[[self webViewController] addNewTabForURL:url];

// In case, a modal view controller is overlaying the WebViewController,
// we need to close it *before* adding a new tab. Otherwise, the UI will
// be broken on iPhone-X-type devices: The address field will be in the
// notch area.
if ([self webViewController].presentedViewController != nil)
{
[[self webViewController] dismissViewControllerAnimated:YES completion:^{
[[self webViewController] addNewTabForURL:url];
}];
}
// If there's no modal view controller, however, the completion block would
// never be called.
else {
[[self webViewController] addNewTabForURL:url];
}

return YES;
}

Expand Down
Binary file modified Endless/Base.lproj/Localizable.strings
Binary file not shown.
43 changes: 40 additions & 3 deletions Endless/HostSettingsController.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
#import "HostSettings.h"
#import "HostSettingsController.h"

#import "SilenceWarnings.h"

SILENCE_DEPRECATION_ON
#import "XLForm.h"
SILENCE_WARNINGS_OFF

@interface HostSettingsXLFormViewController : XLFormViewController
@property (copy, nonatomic) void (^disappearCallback)(HostSettingsXLFormViewController *);
Expand Down Expand Up @@ -163,6 +167,8 @@ - (void)showDetailsForHost:(NSString *)thost

XLFormDescriptor *form = [XLFormDescriptor formDescriptorWithTitle:[host hostname]];

HostSettingsXLFormViewController *formController = [[HostSettingsXLFormViewController alloc] initWithForm:form];

/* hostname */
{
XLFormSectionDescriptor *section = [XLFormSectionDescriptor formSection];
Expand Down Expand Up @@ -207,7 +213,24 @@ - (void)showDetailsForHost:(NSString *)thost
{
XLFormRowDescriptor *row = [XLFormRowDescriptor formRowDescriptorWithTag:HOST_SETTINGS_KEY_ALLOW_WEBRTC rowType:XLFormRowDescriptorTypeSelectorActionSheet title:NSLocalizedString(@"Allow WebRTC", nil)];
[self setYesNoSelectorOptionsForSetting:HOST_SETTINGS_KEY_ALLOW_WEBRTC host:host row:row withDefault:(![host isDefault])];


row.onChangeBlock = ^(XLFormOptionsObject * _Nullable oldValue, XLFormOptionsObject * _Nullable newValue, XLFormRowDescriptor * _Nonnull rowDescriptor) {
if ([newValue.formValue isEqual:HOST_SETTINGS_VALUE_YES]) {
XLFormRowDescriptor *row = [form formRowWithTag:HOST_SETTINGS_KEY_CSP];

if ([((XLFormOptionsObject *)row.value).formValue isEqual:HOST_SETTINGS_CSP_STRICT]) {
for (XLFormOptionsObject *opt in row.selectorOptions) {
if ([opt.valueData isEqual:HOST_SETTINGS_CSP_BLOCK_CONNECT]) {
row.value = opt;
break;
}
}

[formController reloadFormRow: row];
}
}
};

section = [XLFormSectionDescriptor formSection];
[section setTitle:@""];
[section setFooterTitle:([host isDefault]
Expand Down Expand Up @@ -304,7 +327,22 @@ - (void)showDetailsForHost:(NSString *)thost
for (XLFormOptionsObject *opt in opts)
if ([[opt valueData] isEqualToString:val])
[row setValue:opt];


row.onChangeBlock = ^(XLFormOptionsObject * _Nullable oldValue, XLFormOptionsObject * _Nullable newValue, XLFormRowDescriptor * _Nonnull rowDescriptor) {
if ([newValue.formValue isEqual:HOST_SETTINGS_CSP_STRICT]) {
XLFormRowDescriptor *row = [form formRowWithTag:HOST_SETTINGS_KEY_ALLOW_WEBRTC];

for (XLFormOptionsObject *opt in row.selectorOptions) {
if ([opt.valueData isEqual:HOST_SETTINGS_VALUE_NO]) {
row.value = opt;
break;
}
}

[formController reloadFormRow: row];
}
};

section = [XLFormSectionDescriptor formSection];
[section setTitle:@""];
[section setFooterTitle:([host isDefault]
Expand Down Expand Up @@ -358,7 +396,6 @@ - (void)showDetailsForHost:(NSString *)thost
}
}

HostSettingsXLFormViewController *formController = [[HostSettingsXLFormViewController alloc] initWithForm:form];
[formController setDisappearCallback:^(HostSettingsXLFormViewController *form) {
if (![host isDefault])
[host setHostname:[[form formValues] objectForKey:HOST_SETTINGS_KEY_HOST]];
Expand Down
2 changes: 2 additions & 0 deletions Endless/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,7 @@
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<true/>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>Needed to store the selected image to your photos.</string>
</dict>
</plist>
3 changes: 1 addition & 2 deletions Endless/RuleEditorController.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@
#import "AppDelegate.h"
#import "RuleEditorRow.h"

@interface RuleEditorController : UITableViewController <UISearchBarDelegate, UISearchDisplayDelegate, UITableViewDelegate>
@interface RuleEditorController : UITableViewController <UISearchResultsUpdating>

@property AppDelegate *appDelegate;
@property NSMutableArray<RuleEditorRow *> *sortedRuleRows;
@property NSMutableArray<RuleEditorRow *> *inUseRuleRows;

@property UISearchBar *searchBar;
@property NSMutableArray<RuleEditorRow *> *searchResult;

- (NSString *)ruleDisabledReason:(RuleEditorRow *)row;
Expand Down
95 changes: 56 additions & 39 deletions Endless/RuleEditorController.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

@implementation RuleEditorController

UISearchDisplayController *searchDisplayController;
UISearchController *searchController;

- (id)initWithStyle:(UITableViewStyle)style
{
Expand All @@ -29,19 +29,17 @@ - (void)viewDidLoad
{
[super viewDidLoad];

self.searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];

searchDisplayController = [[UISearchDisplayController alloc] initWithSearchBar:self.searchBar contentsController:self];
searchDisplayController.delegate = self;
searchDisplayController.searchResultsDataSource = self;
searchDisplayController.searchResultsTableView.delegate = self;
searchController = [[UISearchController alloc] initWithSearchResultsController:nil];
searchController.searchResultsUpdater = self;
searchController.obscuresBackgroundDuringPresentation = NO;
self.definesPresentationContext = YES;
self.navigationItem.searchController = searchController;

self.tableView.delegate = self;

[[self tableView] setTableHeaderView:self.searchBar];
}

#pragma mark - Table view data source

#pragma mark - UITableViewDataSource

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
Expand All @@ -60,7 +58,7 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger
{
if (section == 0)
return [self.inUseRuleRows count];
else if (tableView == self.searchDisplayController.searchResultsTableView)
else if ([self isFiltering])
return [self.searchResult count];
else
return [self.sortedRuleRows count];
Expand Down Expand Up @@ -121,77 +119,96 @@ - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEd
[tableView reloadData];
}


#pragma mark - UITableViewDelegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}

- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString
- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(nonnull NSIndexPath *)indexPath
{
RuleEditorRow *row = [self ruleForTableView:tableView atIndexPath:indexPath];

if ([self ruleDisabledReason:row] == nil)
return NSLocalizedString(@"Disable", nil);
else
return NSLocalizedString(@"Enable", nil);
}


# pragma mark - UISearchResultsUpdating

- (void)updateSearchResultsForSearchController:(UISearchController *)searchController
{
NSString *search = searchController.searchBar.text;

[self.searchResult removeAllObjects];

for (RuleEditorRow *row in self.sortedRuleRows) {
if ([row textLabel] != nil) {
NSRange range = [[row textLabel] rangeOfString:searchString options:NSCaseInsensitiveSearch];
NSRange range = [[row textLabel] rangeOfString:search options:NSCaseInsensitiveSearch];

if (range.length > 0) {
[self.searchResult addObject:row];
continue;
}
}
if ([row detailTextLabel] != nil) {
NSRange range = [[row detailTextLabel] rangeOfString:searchString options:NSCaseInsensitiveSearch];
NSRange range = [[row detailTextLabel] rangeOfString:search options:NSCaseInsensitiveSearch];

if (range.length > 0) {
[self.searchResult addObject:row];
continue;
}
}
}
return YES;

[self.tableView reloadData];
}

- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(nonnull NSIndexPath *)indexPath

# pragma mark - Public Methods

- (NSString *)ruleDisabledReason:(RuleEditorRow *)row
{
RuleEditorRow *row = [self ruleForTableView:tableView atIndexPath:indexPath];
return nil;
}

if ([self ruleDisabledReason:row] == nil)
return NSLocalizedString(@"Disable", nil);
else
return NSLocalizedString(@"Enable", nil);
- (void)disableRuleForRow:(RuleEditorRow *)row withReason:(NSString *)reason
{
abort();
}

- (void)enableRuleForRow:(RuleEditorRow *)row
{
abort();
}


# pragma mark - Private Methods

- (RuleEditorRow *)ruleForTableView:(UITableView *)tableView atIndexPath:(NSIndexPath *)indexPath
{
NSMutableArray *group;

if ([indexPath section] == 0)
group = [self inUseRuleRows];
else if (tableView == self.searchDisplayController.searchResultsTableView)
else if ([self isFiltering])
group = [self searchResult];
else
group = [self sortedRuleRows];

if (group && [group count] > [indexPath row])
return [group objectAtIndex:indexPath.row];
else
return nil;
}

- (NSString *)ruleDisabledReason:(RuleEditorRow *)row
- (BOOL)isFiltering
{
return nil;
}

- (void)disableRuleForRow:(RuleEditorRow *)row withReason:(NSString *)reason
{
abort();
}

- (void)enableRuleForRow:(RuleEditorRow *)row
{
abort();
return searchController.isActive && searchController.searchBar.text.length != 0;
}

@end
Loading