diff --git a/Browser Resources/BookmarkFoldersForm.xib b/Browser Resources/BookmarkFoldersForm.xib
index 1d22bf4..710345f 100644
--- a/Browser Resources/BookmarkFoldersForm.xib
+++ b/Browser Resources/BookmarkFoldersForm.xib
@@ -1,8 +1,8 @@
-
+
-
-
+
+
@@ -13,7 +13,7 @@
-
+
@@ -31,4 +31,4 @@
-
\ No newline at end of file
+
diff --git a/Browser Resources/BookmarkItem.xib b/Browser Resources/BookmarkItem.xib
index 21cafda..c6ee9a8 100644
--- a/Browser Resources/BookmarkItem.xib
+++ b/Browser Resources/BookmarkItem.xib
@@ -1,7 +1,7 @@
-
+
-
+
@@ -45,13 +45,13 @@
-
+
diff --git a/Browser Resources/Bookmarks.xib b/Browser Resources/Bookmarks.xib
index 06cd48a..5613e62 100644
--- a/Browser Resources/Bookmarks.xib
+++ b/Browser Resources/Bookmarks.xib
@@ -1,691 +1,74 @@
-
-
-
- 1056
- 10K549
- 851
- 1038.36
- 461.00
-
-
-
-
-
- YES
-
- IBFilesOwner
- IBCocoaTouchFramework
-
-
- IBFirstResponder
- IBCocoaTouchFramework
-
-
-
- 274
-
- YES
-
-
- 274
- {320, 417}
-
-
- 3
- MQA
-
- YES
- IBCocoaTouchFramework
- YES
- 1
- 0
- YES
- 44
- 22
- 22
-
-
-
- 266
- {{0, 416}, {320, 44}}
-
- NO
- NO
- IBCocoaTouchFramework
-
- YES
-
- Edit
- IBCocoaTouchFramework
- 1
-
-
-
-
-
-
- -2147483382
- {{0, 416}, {320, 44}}
-
- NO
- NO
- IBCocoaTouchFramework
-
- YES
-
- IBCocoaTouchFramework
- 1
-
- 0
-
-
- IBCocoaTouchFramework
- 163
-
- 6
-
-
- New Folder
- IBCocoaTouchFramework
- 1
-
-
-
-
-
- {320, 460}
-
-
- 3
- MQA
-
- 2
-
-
-
- IBCocoaTouchFramework
-
-
-
-
- YES
-
-
- view
-
-
-
- 3
-
-
-
- dataSource
-
-
-
- 9
-
-
-
- delegate
-
-
-
- 10
-
-
-
- toolbar
-
-
-
- 35
-
-
-
- editToolbar
-
-
-
- 36
-
-
-
- enableEditMode:
-
-
-
- 37
-
-
-
- tableView
-
-
-
- 38
-
-
-
- finishEditMode:
-
-
-
- 39
-
-
-
- addFolder:
-
-
-
- 40
-
-
-
-
- YES
-
- 0
-
-
-
-
-
- 1
-
-
- YES
-
-
-
-
-
-
-
- -1
-
-
- File's Owner
-
-
- -2
-
-
-
-
- 4
-
-
- YES
-
-
-
-
- 7
-
-
- YES
-
-
-
-
-
- 8
-
-
-
-
- 32
-
-
- YES
-
-
-
-
-
- EditToolbar
-
-
- 33
-
-
-
-
- 30
-
-
-
-
- 34
-
-
-
-
-
-
- YES
-
- YES
- -1.CustomClassName
- -2.CustomClassName
- 1.IBEditorWindowLastContentRect
- 1.IBPluginDependency
- 30.IBPluginDependency
- 32.IBPluginDependency
- 32.IBViewBoundsToFrameTransform
- 33.IBPluginDependency
- 34.IBPluginDependency
- 4.IBPluginDependency
- 4.IBViewBoundsToFrameTransform
- 7.IBPluginDependency
- 7.IBViewBoundsToFrameTransform
- 8.IBPluginDependency
-
-
- YES
- BookmarksController
- UIResponder
- {{357, 356}, {320, 480}}
- com.apple.InterfaceBuilder.IBCocoaTouchPlugin
- com.apple.InterfaceBuilder.IBCocoaTouchPlugin
- com.apple.InterfaceBuilder.IBCocoaTouchPlugin
-
- P4AAAL+AAAAAAAAAw8+AAA
-
- com.apple.InterfaceBuilder.IBCocoaTouchPlugin
- com.apple.InterfaceBuilder.IBCocoaTouchPlugin
- com.apple.InterfaceBuilder.IBCocoaTouchPlugin
-
- P4AAAL+AAAAAAAAAw8+AAA
-
- com.apple.InterfaceBuilder.IBCocoaTouchPlugin
-
- P4AAAL+AAAA/gAAAw+SAAA
-
- com.apple.InterfaceBuilder.IBCocoaTouchPlugin
-
-
-
- YES
-
-
- YES
-
-
-
-
- YES
-
-
- YES
-
-
-
- 40
-
-
-
- YES
-
- BookmarksController
- UIViewController
-
- YES
-
- YES
- addFolder:
- enableEditMode:
- finishEditMode:
- switchToBrowser:
-
-
- YES
- id
- id
- id
- id
-
-
-
- YES
-
- YES
- addFolder:
- enableEditMode:
- finishEditMode:
- switchToBrowser:
-
-
- YES
-
- addFolder:
- id
-
-
- enableEditMode:
- id
-
-
- finishEditMode:
- id
-
-
- switchToBrowser:
- id
-
-
-
-
- YES
-
- YES
- editToolbar
- tableView
- toolbar
-
-
- YES
- UIToolbar
- UITableView
- UIToolbar
-
-
-
- YES
-
- YES
- editToolbar
- tableView
- toolbar
-
-
- YES
-
- editToolbar
- UIToolbar
-
-
- tableView
- UITableView
-
-
- toolbar
- UIToolbar
-
-
-
-
- IBProjectSource
- Classes/BookmarksController.h
-
-
-
-
- YES
-
- NSObject
-
- IBFrameworkSource
- Foundation.framework/Headers/NSError.h
-
-
-
- NSObject
-
- IBFrameworkSource
- Foundation.framework/Headers/NSFileManager.h
-
-
-
- NSObject
-
- IBFrameworkSource
- Foundation.framework/Headers/NSKeyValueCoding.h
-
-
-
- NSObject
-
- IBFrameworkSource
- Foundation.framework/Headers/NSKeyValueObserving.h
-
-
-
- NSObject
-
- IBFrameworkSource
- Foundation.framework/Headers/NSKeyedArchiver.h
-
-
-
- NSObject
-
- IBFrameworkSource
- Foundation.framework/Headers/NSObject.h
-
-
-
- NSObject
-
- IBFrameworkSource
- Foundation.framework/Headers/NSRunLoop.h
-
-
-
- NSObject
-
- IBFrameworkSource
- Foundation.framework/Headers/NSThread.h
-
-
-
- NSObject
-
- IBFrameworkSource
- Foundation.framework/Headers/NSURL.h
-
-
-
- NSObject
-
- IBFrameworkSource
- Foundation.framework/Headers/NSURLConnection.h
-
-
-
- NSObject
-
- IBFrameworkSource
- QuartzCore.framework/Headers/CAAnimation.h
-
-
-
- NSObject
-
- IBFrameworkSource
- QuartzCore.framework/Headers/CALayer.h
-
-
-
- NSObject
-
- IBFrameworkSource
- UIKit.framework/Headers/UIAccessibility.h
-
-
-
- NSObject
-
- IBFrameworkSource
- UIKit.framework/Headers/UINibLoading.h
-
-
-
- NSObject
-
- IBFrameworkSource
- UIKit.framework/Headers/UIResponder.h
-
-
-
- NSObject
-
- IBFrameworkSource
- YAJLiOS.framework/Headers/NSObject+YAJL.h
-
-
-
- UIBarButtonItem
- UIBarItem
-
- IBFrameworkSource
- UIKit.framework/Headers/UIBarButtonItem.h
-
-
-
- UIBarItem
- NSObject
-
- IBFrameworkSource
- UIKit.framework/Headers/UIBarItem.h
-
-
-
- UIResponder
- NSObject
-
-
-
- UIScrollView
- UIView
-
- IBFrameworkSource
- UIKit.framework/Headers/UIScrollView.h
-
-
-
- UISearchBar
- UIView
-
- IBFrameworkSource
- UIKit.framework/Headers/UISearchBar.h
-
-
-
- UISearchDisplayController
- NSObject
-
- IBFrameworkSource
- UIKit.framework/Headers/UISearchDisplayController.h
-
-
-
- UITableView
- UIScrollView
-
- IBFrameworkSource
- UIKit.framework/Headers/UITableView.h
-
-
-
- UIToolbar
- UIView
-
- IBFrameworkSource
- UIKit.framework/Headers/UIToolbar.h
-
-
-
- UIView
-
- IBFrameworkSource
- UIKit.framework/Headers/UIPrintFormatter.h
-
-
-
- UIView
-
- IBFrameworkSource
- UIKit.framework/Headers/UITextField.h
-
-
-
- UIView
- UIResponder
-
- IBFrameworkSource
- UIKit.framework/Headers/UIView.h
-
-
-
- UIViewController
-
- IBFrameworkSource
- UIKit.framework/Headers/UINavigationController.h
-
-
-
- UIViewController
-
- IBFrameworkSource
- UIKit.framework/Headers/UIPopoverController.h
-
-
-
- UIViewController
-
- IBFrameworkSource
- UIKit.framework/Headers/UISplitViewController.h
-
-
-
- UIViewController
-
- IBFrameworkSource
- UIKit.framework/Headers/UITabBarController.h
-
-
-
- UIViewController
- UIResponder
-
- IBFrameworkSource
- UIKit.framework/Headers/UIViewController.h
-
-
-
-
- 0
- IBCocoaTouchFramework
-
- com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS
-
-
-
- com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3
-
-
- YES
- 3
- 141
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Browser Resources/BookmarksForm.xib b/Browser Resources/BookmarksForm.xib
index 1a9f4b2..d9cc9ed 100644
--- a/Browser Resources/BookmarksForm.xib
+++ b/Browser Resources/BookmarksForm.xib
@@ -1,12 +1,13 @@
-
+
-
-
+
+
+
@@ -15,7 +16,7 @@
-
+
@@ -61,4 +62,4 @@
-
\ No newline at end of file
+
diff --git a/Browser Resources/Images/arrow-left.png b/Browser Resources/Images/arrow-left.png
deleted file mode 100644
index d952e74..0000000
Binary files a/Browser Resources/Images/arrow-left.png and /dev/null differ
diff --git a/Browser Resources/Images/arrow-right.png b/Browser Resources/Images/arrow-right.png
deleted file mode 100644
index 11770c6..0000000
Binary files a/Browser Resources/Images/arrow-right.png and /dev/null differ
diff --git a/Browser Resources/Images/folder.png b/Browser Resources/Images/folder.png
index 52cd9bd..d6c707e 100644
Binary files a/Browser Resources/Images/folder.png and b/Browser Resources/Images/folder.png differ
diff --git a/Browser Resources/Images/left.png b/Browser Resources/Images/left.png
new file mode 100644
index 0000000..f05c602
Binary files /dev/null and b/Browser Resources/Images/left.png differ
diff --git a/Browser Resources/Images/right.png b/Browser Resources/Images/right.png
new file mode 100644
index 0000000..310855e
Binary files /dev/null and b/Browser Resources/Images/right.png differ
diff --git a/Browser Resources/MainWindow-iPad.xib b/Browser Resources/MainWindow-iPad.xib
index 4fa6046..8186db2 100644
--- a/Browser Resources/MainWindow-iPad.xib
+++ b/Browser Resources/MainWindow-iPad.xib
@@ -1,5 +1,5 @@
-
+
@@ -12,8 +12,6 @@
-
-
@@ -61,45 +59,32 @@
-
+
-
+
-
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -173,12 +158,12 @@
-
-
+
+
-
+
@@ -188,34 +173,34 @@
-
-
-
+
+
+
-
-
-
+
-
+
+
+
+
-
-
+
@@ -263,11 +248,9 @@
-
-
-
-
+
+
diff --git a/Browser Resources/MainWindow.xib b/Browser Resources/MainWindow.xib
index 2015274..d88120a 100644
--- a/Browser Resources/MainWindow.xib
+++ b/Browser Resources/MainWindow.xib
@@ -1,7 +1,7 @@
-
+
-
+
@@ -12,8 +12,6 @@
-
-
@@ -197,45 +195,32 @@
-
+
-
+
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -281,11 +266,9 @@
-
-
-
-
+
+
diff --git a/Browser Resources/bookmarks.strings b/Browser Resources/bookmarks.strings
new file mode 100644
index 0000000..d2651e7
--- /dev/null
+++ b/Browser Resources/bookmarks.strings
@@ -0,0 +1,9 @@
+/*
+ bookmarks.strings
+ TestBrowser
+
+ Created by Alexandru Catighera on 8/7/14.
+ Copyright (c) 2014 Alexandru Catighera. All rights reserved.
+*/
+
+"Default/Reddit" = "http://www.reddit.com";
diff --git a/Browser/BookmarkFolderFormController.h b/Browser/BookmarkFolderFormController.h
index 6cb4516..d7873d1 100644
--- a/Browser/BookmarkFolderFormController.h
+++ b/Browser/BookmarkFolderFormController.h
@@ -6,7 +6,6 @@
//
#import
-#import
@class BookmarksController;
@@ -14,21 +13,18 @@
BookmarksController *bookmarksController;
IBOutlet UITextField *nameField;
+
+ NSInteger folderIndex;
char mode;
-
- NSManagedObjectContext *managedObjectContext;
- NSManagedObject *folder;
}
@property(nonatomic,strong) BookmarksController *bookmarksController;
@property(nonatomic,strong) UITextField *nameField;
-@property(nonatomic,assign) char mode;
-
-@property(nonatomic, strong) NSManagedObjectContext *managedObjectContext;
-@property(nonatomic, strong) NSManagedObject *folder;
+@property(nonatomic,assign) NSInteger folderIndex;
+@property(nonatomic,assign) char mode;
-(IBAction) saveFolder:(id)sender;
diff --git a/Browser/BookmarkFolderFormController.m b/Browser/BookmarkFolderFormController.m
index 76fa825..2a3d94d 100644
--- a/Browser/BookmarkFolderFormController.m
+++ b/Browser/BookmarkFolderFormController.m
@@ -7,86 +7,90 @@
#import "BookmarkFolderFormController.h"
#import "BookmarksController.h"
-#import "BrowserDelegate.h"
+#import "BookmarksFormController.h"
+#import "BrowserViewController.h"
@implementation BookmarkFolderFormController
-@synthesize nameField, folder, managedObjectContext, mode, bookmarksController;
-
-// The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
-/*
-- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
- self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
- if (self) {
- // Custom initialization.
- }
- return self;
-}
-*/
-
-/*
-// Implement loadView to create a view hierarchy programmatically, without using a nib.
-- (void)loadView {
-}
-*/
-
+@synthesize nameField, folderIndex, mode, bookmarksController;
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
- //set up DB
- if (managedObjectContext == nil)
- {
- managedObjectContext = [(BrowserDelegate *)[[UIApplication sharedApplication] delegate] managedObjectContext];
- NSLog(@"After managedObjectContext: %@", managedObjectContext);
- }
-
if (!mode) {
mode = 'A';
}
[nameField becomeFirstResponder];
- self.contentSizeForViewInPopover = CGSizeMake(320.0, 480.0);
+ if ([self respondsToSelector:@selector(setPreferredContentSize:)]) {
+ self.preferredContentSize = CGSizeMake(320.0, 480.0);
+ } else {
+ self.contentSizeForViewInPopover = CGSizeMake(320.0, 480.0);
+ }
[super viewDidLoad];
}
- (void)viewWillAppear:(BOOL)animated {
+ //Set the folder index to the bookmarkcontroller folder index
+ self.folderIndex = bookmarksController.folderIndex;
+ //Reset the folder index back to the bookmarks root, since we're navigating back to the folder root
+ bookmarksController.folderIndex = BOOKMARKS_ROOT;
+ //Disable edit mode in the bookmarks controller
+ [bookmarksController finishEditMode:self];
if (mode == 'A') {
- folder = nil;
self.navigationItem.title = @"New Bookmark Folder";
[nameField setText:@""];
} else if (mode == 'E') {
self.navigationItem.title = @"Edit Bookmark Folder";
- [nameField setText:[folder valueForKey:@"name"]];
+ NSDictionary* folderDict = (NSDictionary*)[bookmarksController.folders objectAtIndex:self.folderIndex];
+ NSString* folderTitle = (NSString*)[folderDict objectForKey:@"title"];
+ [nameField setText:folderTitle];
}
}
- (IBAction)saveFolder:(id)sender {
- NSArray *controllers = [self.navigationController viewControllers];
- BookmarksController *newBookmarksController = (BookmarksController *)[controllers objectAtIndex:[controllers count] - 2];
+
+ NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
+ NSMutableArray* foldersArray = (NSMutableArray*)[[defaults objectForKey:FOLDERS_KEY] mutableCopy];
+ NSMutableDictionary* folderDict = nil;
+
+ if([[nameField.text stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@" "]] length] == 0)
+ {
+ [nameField setText:@"New Folder"];
+ }
+
if (mode == 'A') {
- folder = [NSEntityDescription insertNewObjectForEntityForName:@"Folder" inManagedObjectContext:managedObjectContext];
// check for parent folder
- if ([controllers count] > 2) {
- BookmarksController *parentBookmarksController = (BookmarksController *)[controllers objectAtIndex:[controllers count] - 3];
- NSMutableArray *folders = (NSMutableArray *)[parentBookmarksController bookmarks];
- NSIndexPath *selectedIndexPath = [[parentBookmarksController tableView] indexPathForSelectedRow];
- NSManagedObject *parentFolder = [folders objectAtIndex:[selectedIndexPath row]];
- [folder setValue:parentFolder forKey:@"Parent"];
- }
+ NSMutableArray* bookmarksArray = [[NSMutableArray alloc] init];
+ folderDict = [NSMutableDictionary dictionaryWithObjectsAndKeys:nameField.text,@"title",bookmarksArray,@"bookmarks", nil];
+ [foldersArray addObject:folderDict];
} else if (mode == 'E') {
- NSMutableArray *folders = (NSMutableArray *)[newBookmarksController bookmarks];
- NSIndexPath *selectedIndexPath = [[newBookmarksController tableView] indexPathForSelectedRow];
- folder = [folders objectAtIndex:[selectedIndexPath row]];
+ folderDict = (NSMutableDictionary*)[[bookmarksController.folders objectAtIndex:self.folderIndex] mutableCopy];
+ [folderDict setObject:nameField.text forKey:@"title"];
+ [foldersArray setObject:folderDict atIndexedSubscript:self.folderIndex];
+ self.folderIndex = [foldersArray count] - 1;
}
-
- [folder setValue:nameField.text forKey:@"name"];
-
- [managedObjectContext save:nil];
-
- [bookmarksController reloadBookmarks];
- [[bookmarksController tableView] reloadData];
- [self.navigationController popViewControllerAnimated:YES];
+
+ [defaults setObject:foldersArray forKey:FOLDERS_KEY];
+ [defaults synchronize];
+
+ //Reset the folder index back to the bookmarks root, since we're navigating back to the folder root
+ bookmarksController.folderIndex = BOOKMARKS_ROOT;
+ //Reload all bC controllers on the navigation stack
+ BookmarksFormController *formController;
+ for (UIViewController* bC in self.navigationController.viewControllers)
+ {
+ if([bC isKindOfClass:[BookmarksController class]])
+ {
+ [(BookmarksController *) bC setFolderIndex:folderIndex];
+ [(BookmarksController *) bC loadBookmarks];
+ [((BookmarksController *) bC).tableView reloadData];
+ }
+ }
+
+ [self.navigationController popViewControllerAnimated:YES];
+ [[[self.navigationController viewControllers] lastObject] setMode:'P'];
+
}
- (void)didReceiveMemoryWarning {
diff --git a/Browser/BookmarkImporter.h b/Browser/BookmarkImporter.h
index a21c839..c98c93d 100644
--- a/Browser/BookmarkImporter.h
+++ b/Browser/BookmarkImporter.h
@@ -10,11 +10,7 @@
#import
#import
-@interface BookmarkImporter : NSObject {
- NSManagedObjectContext *managedObjectContext;
- NSManagedObject *rootFolder;
- xmlNodeSetPtr allNodes;
-}
+@interface BookmarkImporter : NSObject
- (void)loadBookmarksFromUrl:(NSURL *) url;
- (void) loadBookmarksFromNodes:(NSArray *)nodes inFolder:(NSManagedObject *)parentFolder scanDL:(BOOL)scanDL;
diff --git a/Browser/BookmarkImporter.m b/Browser/BookmarkImporter.m
index b67fe3f..c45d812 100644
--- a/Browser/BookmarkImporter.m
+++ b/Browser/BookmarkImporter.m
@@ -16,19 +16,17 @@
@implementation BookmarkImporter
-@synthesize managedObjectContext, rootFolder;
-
- (void)loadBookmarksFromUrl:(NSURL *) url{
NSError *error;
- if (managedObjectContext == nil)
+ if (_managedObjectContext == nil)
{
- managedObjectContext = [(BrowserDelegate *)[[UIApplication sharedApplication] delegate] managedObjectContext];
- NSLog(@"After managedObjectContext: %@", managedObjectContext);
+ _managedObjectContext = [(BrowserDelegate *)[[UIApplication sharedApplication] delegate] managedObjectContext];
+ NSLog(@"After managedObjectContext: %@", _managedObjectContext);
}
- NSString *bookmarkHTML = [NSString stringWithContentsOfURL:url];
+ NSString *bookmarkHTML = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil];
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"|||
|FOLDED|\n|\t|\r|]*||" options:NSRegularExpressionCaseInsensitive error:&error];
bookmarkHTML = [regex stringByReplacingMatchesInString:bookmarkHTML options:0 range:NSMakeRange(0, [bookmarkHTML length]) withTemplate:@""];
@@ -36,14 +34,14 @@ - (void)loadBookmarksFromUrl:(NSURL *) url{
if ([[bookmarkHTML lowercaseString] rangeOfString:@""].location != NSNotFound) {
bookmarkHTML = [bookmarkHTML stringByReplacingOccurrencesOfString:@"" withString:@""];
bookmarkHTML = [bookmarkHTML stringByReplacingOccurrencesOfString:@"" withString:@""];
- bookmarkHTML = [bookmarkHTML stringByReplacingOccurrencesOfString:@"<\HTML>" withString:@"<\root>"];
- bookmarkHTML = [bookmarkHTML stringByReplacingOccurrencesOfString:@"<\html>" withString:@"<\root>"];
+ bookmarkHTML = [bookmarkHTML stringByReplacingOccurrencesOfString:@"<\\HTML>" withString:@"<\root>"];
+ bookmarkHTML = [bookmarkHTML stringByReplacingOccurrencesOfString:@"<\\html>" withString:@"<\root>"];
} else {
bookmarkHTML = [NSString stringWithFormat:@"%@", bookmarkHTML];
}
NSData *bookmarkData = [bookmarkHTML dataUsingEncoding:NSUTF8StringEncoding];
- NSManagedObject *parentFolder = [NSEntityDescription insertNewObjectForEntityForName:@"Folder" inManagedObjectContext:managedObjectContext];
+ NSManagedObject *parentFolder = [NSEntityDescription insertNewObjectForEntityForName:@"Folder" inManagedObjectContext:_managedObjectContext];
[parentFolder setValue:[NSString stringWithFormat:@"import folder %@", [[NSDate date] description]] forKey:@"name"];
[parentFolder setNilValueForKey:@"Parent"];
@@ -74,7 +72,7 @@ - (void) loadBookmarksFromNodes:(NSArray *)nodes inFolder:(NSManagedObject *)par
nodeName = [[NSString stringWithCString:(const char *)node->name encoding:NSUTF8StringEncoding] lowercaseString];
}
if (nodeName != nil && [nodeName isEqualToString:@"h3"]) {
- NSManagedObject *folder = [NSEntityDescription insertNewObjectForEntityForName:@"Folder" inManagedObjectContext:managedObjectContext];
+ NSManagedObject *folder = [NSEntityDescription insertNewObjectForEntityForName:@"Folder" inManagedObjectContext:_managedObjectContext];
NSString *name = [NSString stringWithCString:node->children->content encoding:NSUTF8StringEncoding];
name = [name stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
@@ -105,12 +103,12 @@ - (void) loadBookmarksFromNodes:(NSArray *)nodes inFolder:(NSManagedObject *)par
if ([attrName isEqualToString:@"href"] &&
[attrVal hasPrefix:@"http"] &&
![attrVal hasPrefix:@"http://localhost"]) {
- NSManagedObject *bookmark = [NSEntityDescription insertNewObjectForEntityForName:@"Bookmark" inManagedObjectContext:managedObjectContext];
+ NSManagedObject *bookmark = [NSEntityDescription insertNewObjectForEntityForName:@"Bookmark" inManagedObjectContext:_managedObjectContext];
NSString *name = [NSString stringWithCString:(const char *)node->children->content encoding:NSUTF8StringEncoding];
[bookmark setValue:name forKey:@"name"];
[bookmark setValue:attrVal forKey:@"url"];
[bookmark setValue:parentFolder forKey:@"Folder"];
- if (![managedObjectContext save:nil]) {
+ if (![_managedObjectContext save:nil]) {
NSLog(@"save attempt %@ | %@",name, attrVal);
}
}
@@ -145,9 +143,9 @@ - (void) loadBookmarksFromAllNodesinFolder:(NSManagedObject *)parentFolder scanD
}
- (void) save:(NSError **) err {
- if (managedObjectContext != nil)
+ if (_managedObjectContext != nil)
{
- [managedObjectContext save:err];
+ [_managedObjectContext save:err];
//NSLog(@"managed error: %@ %@ %@ %i", [*err localizedDescription], [*err helpAnchor], [*err domain], [*err code]);
}
}
diff --git a/Browser/BookmarkItem.h b/Browser/BookmarkItem.h
index 83e6956..42b7dad 100644
--- a/Browser/BookmarkItem.h
+++ b/Browser/BookmarkItem.h
@@ -6,7 +6,6 @@
//
#import
-#import
@class BookmarksController;
@@ -40,6 +39,5 @@
-(IBAction) deleteCircleClick:(id)sender;
-(IBAction) deleteItem:(id)sender;
-- (void) deleteItemFromDB:(NSManagedObject *) dbItem;
@end
diff --git a/Browser/BookmarkItem.m b/Browser/BookmarkItem.m
index bd41972..72ff33d 100644
--- a/Browser/BookmarkItem.m
+++ b/Browser/BookmarkItem.m
@@ -85,31 +85,40 @@ -(IBAction) deleteCircleClick:(id)sender {
-(IBAction) deleteItem:(id)sender {
NSArray *indexPaths = [NSArray arrayWithObject:indexPath];
- NSManagedObject *bookmarkToDelete = [[bookmarksController bookmarks] objectAtIndex:[indexPath row]];
-
- [[bookmarksController bookmarks] removeObject:bookmarkToDelete];
- [self deleteItemFromDB:bookmarkToDelete];
- [[bookmarksController managedObjectContext] save:nil];
+ [self deleteFromBookmarks:[indexPath row]];
[tableView deleteRowsAtIndexPaths:indexPaths withRowAnimation:YES];
[tableView reloadData];
}
-- (void) deleteItemFromDB:(NSManagedObject *) dbItem {
- if ([[[dbItem entity] name] isEqualToString:@"Folder"]) {
- NSFetchRequest *request = [[NSFetchRequest alloc] init];
- NSEntityDescription *folderEntity = [NSEntityDescription entityForName:@"Folder" inManagedObjectContext:[bookmarksController managedObjectContext]];
- NSPredicate *predicateF = [NSPredicate predicateWithFormat:[NSString stringWithFormat:@"Parent.name == '%@'", [dbItem valueForKey:@"name"]]];
- [request setEntity:folderEntity];
- [request setPredicate:predicateF];
- for (id child in [[bookmarksController managedObjectContext] executeFetchRequest:request error:nil]) {
- [self deleteItemFromDB:child];
- }
-
+-(void)deleteFromBookmarks:(NSInteger)index {
+
+ NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
+
+ if (bookmarksController.folderIndex == BOOKMARKS_ROOT)
+ {
+ [bookmarksController.folders removeObjectAtIndex:index];
+ }
+ else
+ {
+ [bookmarksController.bookmarks removeObjectAtIndex:index];
+ NSMutableDictionary* folderDict = (NSMutableDictionary*)[[bookmarksController.folders objectAtIndex:bookmarksController.folderIndex] mutableCopy];
+ [folderDict setObject:bookmarksController.bookmarks forKey:@"bookmarks"];
+ [bookmarksController.folders setObject:folderDict atIndexedSubscript:bookmarksController.folderIndex];
}
- [[bookmarksController managedObjectContext] deleteObject:dbItem];
+
+ [defaults setObject:bookmarksController.folders forKey:FOLDERS_KEY];
+ [defaults synchronize];
+ [bookmarksController loadBookmarks];
}
-
-
+- (void)layoutSubviews
+{
+ [super layoutSubviews];
+
+ [self.deleteConfirmation setFrame:CGRectMake(self.tableView.frame.size.width - self.deleteConfirmation.frame.size.width,
+ self.deleteConfirmation.frame.origin.y,
+ self.deleteConfirmation.frame.size.width,
+ self.deleteConfirmation.frame.size.height)];
+}
@end
diff --git a/Browser/BookmarksController.h b/Browser/BookmarksController.h
index 34bdcbe..b614fd9 100644
--- a/Browser/BookmarksController.h
+++ b/Browser/BookmarksController.h
@@ -6,26 +6,31 @@
//
#import
-#import
+
+#define FOLDERS_KEY @"BookmarksFolders"
+#define BOOKMARKS_ROOT -1
+#define MAX_BOOKMARKS 1000
+#define BOOKMARKS_SEED_RESOURCE_NAME @"bookmarks"
@class BookmarksFormController;
@class BookmarkFolderFormController;
@class BrowserViewController;
@class BookmarkItem;
-@interface BookmarksController : UIViewController {
+@interface BookmarksController : UIViewController {
BrowserViewController *browserController;
BookmarksFormController *formController;
BookmarkFolderFormController *folderController;
-
- NSManagedObjectContext *managedObjectContext;
- NSManagedObject *currentFolder;
+
char mode;
-
+ NSInteger folderIndex;
+ NSInteger bookmarkIndex;
+
NSMutableArray *bookmarks;
+ NSMutableArray *folders;
- IBOutlet UITableView *tableView;
-
+ NSString *bookmarksSeedResourceName;
+
UIImage *bookmarkImage;
UIImage *folderImage;
IBOutlet UIToolbar *toolbar;
@@ -36,14 +41,16 @@
@property(nonatomic, strong) BookmarksFormController *formController;
@property(nonatomic, strong) BookmarkFolderFormController *folderController;
-@property(nonatomic, strong) NSManagedObjectContext *managedObjectContext;
-@property(nonatomic, strong) NSManagedObject *currentFolder;
-
@property(nonatomic, assign) char mode;
+@property(nonatomic, assign) NSInteger folderIndex;
+@property(nonatomic, assign) NSInteger bookmarkIndex;
@property(nonatomic, strong) NSMutableArray *bookmarks;
+@property(nonatomic, strong) NSMutableArray *folders;
-@property(nonatomic, strong) UITableView *tableView;
+@property(nonatomic, strong) NSString *bookmarksSeedResourceName;
+
+@property(nonatomic, strong) IBOutlet UITableView *tableView;
@property(nonatomic, strong) UIImage *bookmarkImage;
@property(nonatomic, strong) UIImage *folderImage;
@@ -55,7 +62,12 @@
-(IBAction) finishEditMode:(id)sender;
-(IBAction) addFolder:(id)sender;
--(NSMutableArray *) reloadBookmarks;
+-(void) reloadBookmarksData;
+-(void) loadBookmarks;
-(void) openBookmark:(NSIndexPath *) indexPath;
+
+-(NSString *) getBookmarkImageURLFromUrlString:(NSString *) urlString;
+-(UIImage *) getBookmarkImageFromUrlString:(NSString *) urlString;
+-(void) setBookmarkImageForCellWithURL:(NSArray *) args;
@end
diff --git a/Browser/BookmarksController.m b/Browser/BookmarksController.m
index 9460df8..af09fb3 100644
--- a/Browser/BookmarksController.m
+++ b/Browser/BookmarksController.m
@@ -5,8 +5,8 @@
// Copyright 2011 Evidon. All rights reserved.
//
+#import "Logging.h"
#import "BookmarksController.h"
-#import "BrowserDelegate.h"
#import "BrowserViewController.h"
#import "BookmarkItem.h"
#import "BookmarksFormController.h"
@@ -14,23 +14,80 @@
@implementation BookmarksController
-@synthesize browserController, formController, folderController, managedObjectContext, mode, bookmarks, folderImage, bookmarkImage, toolbar, editToolbar, tableView, currentFolder;
+@synthesize browserController, formController, folderController;
+@synthesize mode, bookmarks, folders, folderImage, bookmarkImage;
+@synthesize toolbar, editToolbar, folderIndex, bookmarkIndex;
+@synthesize bookmarksSeedResourceName;
-// The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
-/*
+// The designated initializer. Override if you create the controller programmatically
+// and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization.
+ self.folderIndex = BOOKMARKS_ROOT;
+ self.bookmarksSeedResourceName = BOOKMARKS_SEED_RESOURCE_NAME;
+ [self loadBookmarks];
}
return self;
}
-*/
-
- (void)viewDidLoad {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ //Load the Folders dictionary from the key in user defaults storage.
+ NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
+ NSDictionary* foldersDict = [defaults objectForKey:FOLDERS_KEY];
+ //Check to see if the folders dict is nil, if it is, create a new folder withe the default structure.
+ if (foldersDict == nil)
+ {
+ NSString *fname = nil;
+ fname = [[NSBundle mainBundle] pathForResource:bookmarksSeedResourceName ofType:@"strings"];
+ NSDictionary *seedBookmarks = [NSDictionary dictionaryWithContentsOfFile:fname];
+
+ NSMutableDictionary *foldersDict = [[NSMutableDictionary alloc] init];
+
+ NSEnumerator *enumerator = [seedBookmarks keyEnumerator];
+ NSString *key;
+ NSArray *bookmarkComponents;
+ NSString *url;
+ NSDictionary *bookmark;
+ NSDictionary *folder;
+ NSString *folderName;
+ NSString *bookmarkName;
+
+
+ while ((key = [enumerator nextObject])) {
+ bookmarkComponents = [key componentsSeparatedByString:@"/"];
+ url = [seedBookmarks objectForKey:key];
+
+ if ([bookmarkComponents count] == 2) {
+ folderName = [bookmarkComponents objectAtIndex:0];
+ bookmarkName = [bookmarkComponents objectAtIndex:1];
+
+ bookmark = [NSDictionary dictionaryWithObjectsAndKeys:
+ bookmarkName, @"title",url,@"URL",nil];
+
+ folder = [foldersDict objectForKey:folderName];
+ if (folder) {
+ [(NSMutableArray *)[folder objectForKey:@"bookmarks"] addObject:bookmark];
+ } else {
+ folder = [NSDictionary dictionaryWithObjectsAndKeys:folderName, @"title",
+ [NSMutableArray arrayWithObject:bookmark], @"bookmarks",nil];
+ [foldersDict setObject:folder forKey:folderName];
+ }
+
+ }
+ }
+
+ [defaults setObject:[foldersDict allValues] forKey:FOLDERS_KEY];
+ [defaults synchronize];
+ }
+
// nav
- UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone
+ UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone
target:self
action:@selector(switchToBrowser:)];
[self.navigationItem setRightBarButtonItem:doneButton];
@@ -43,119 +100,150 @@ - (void)viewDidLoad {
formController = [browserController bookmarksFormController];
- self.contentSizeForViewInPopover = CGSizeMake(320.0, 480.0);
+ /*if ([self respondsToSelector:@selector(setPreferredContentSize:)]) {
+ self.preferredContentSize = CGSizeMake(320.0, 480.0);
+ } else {
+ self.contentSizeForViewInPopover = CGSizeMake(320.0, 480.0);
+ }*/
[super viewDidLoad];
}
-(void) viewDidAppear:(BOOL)animated {
- [tableView deselectRowAtIndexPath:[tableView indexPathForSelectedRow] animated:animated];
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ [_tableView deselectRowAtIndexPath:[_tableView indexPathForSelectedRow] animated:animated];
+ [self.tableView reloadData];
}
-(void) viewWillAppear:(BOOL)animated {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ [super viewWillAppear:animated];
// load bookmark related images
if (folderImage == nil || bookmarkImage == nil) {
folderImage = [UIImage imageNamed:@"folder.png"];
bookmarkImage = [UIImage imageNamed:@"bookmark.png"];
}
- if (mode == 'P') {
+
+
+ /*if (mode == 'P') {
((UIBarItem *)[[toolbar items] objectAtIndex:0]).enabled = NO;
} else {
((UIBarItem *)[[toolbar items] objectAtIndex:0]).enabled = YES;
- }
-
- self.bookmarks = [self reloadBookmarks];
- [tableView reloadData];
- [super viewWillAppear:animated];
+ }*/
+ ((UIBarItem *)[[toolbar items] objectAtIndex:0]).enabled = YES;
+ [self loadBookmarks];
+ [self.tableView reloadData];
}
- (NSUInteger) supportedInterfaceOrientations {
// Return a bitmask of supported orientations. If you need more,
// use bitwise or (see the commented return).
- return UIInterfaceOrientationMaskPortrait;
- // return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;
+ return UIInterfaceOrientationMaskAll;
}
- (UIInterfaceOrientation) preferredInterfaceOrientationForPresentation {
// Return the orientation you'd prefer - this is what it launches to. The
// user can still rotate. You don't have to implement this method, in which
// case it launches in the current orientation
- return UIDeviceOrientationPortrait;
+ return UIInterfaceOrientationPortrait;
}
-- (NSMutableArray *) reloadBookmarks {
- if (managedObjectContext == nil)
- {
- managedObjectContext = [(BrowserDelegate *)[[UIApplication sharedApplication] delegate] managedObjectContext];
- NSLog(@"After managedObjectContext: %@", managedObjectContext);
- }
-
- // Create DB query request for bookmark folders
-
- NSFetchRequest *request = [[NSFetchRequest alloc] init];
- NSEntityDescription *folderEntity = [NSEntityDescription entityForName:@"Folder" inManagedObjectContext:managedObjectContext];
- NSPredicate *predicateF = nil;
- if (mode != 'P') {
- predicateF = [NSPredicate predicateWithFormat:(currentFolder != nil) ? [NSString stringWithFormat:@"Parent.name == '%@'", [currentFolder valueForKey:@"name"]] : @"Parent == nil"];
+-(void)reloadBookmarksData {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ //Get the array of folder dictionaries from NSUSerDefaults
+ NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
+ NSMutableArray* foldersArray = (NSMutableArray*)[defaults objectForKey:FOLDERS_KEY];
+ self.folders = [foldersArray mutableCopy];
+ //If this isn't a folder array, it must be a bookmark array, so return the bookmark array.
+ if (self.folderIndex != BOOKMARKS_ROOT) {
+ NSMutableDictionary* folderDict = [foldersArray objectAtIndex:self.folderIndex];
+ self.bookmarks = [[folderDict objectForKey:@"bookmarks"] mutableCopy];
+ }
+ else {
+ self.bookmarks = nil;
}
- [request setEntity:folderEntity];
- [request setPredicate:predicateF];
- NSMutableArray *folderFetchResults = [[managedObjectContext executeFetchRequest:request error:nil] mutableCopy];
+}
+
+- (void) loadBookmarks {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
- // Create DB query request for bookmarks
-
- NSEntityDescription *entity = [NSEntityDescription entityForName:@"Bookmark" inManagedObjectContext:managedObjectContext];
- NSPredicate *predicate = [NSPredicate predicateWithFormat:@"Folder.name == %@", ((currentFolder == nil) ? nil : [currentFolder valueForKey:@"name"])];
- [request setEntity:entity];
- [request setPredicate:predicate];
- NSArray *bookmarkFetchResults = [managedObjectContext executeFetchRequest:request error:nil];
-
- if (mode != 'P') {
- [folderFetchResults addObjectsFromArray:bookmarkFetchResults];
- } else {
- [folderFetchResults insertObject:@"Bookmarks" atIndex:0];
+ //Get the array of folder dictionaries from NSUSerDefaults
+ NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
+ NSMutableArray* foldersArray = (NSMutableArray*)[defaults objectForKey:FOLDERS_KEY];
+ self.folders = [foldersArray mutableCopy];
+ //If this isn't a folder array, it must be a bookmark array, so return the bookmark array.
+ if (self.folderIndex != BOOKMARKS_ROOT) {
+ NSMutableDictionary* folderDict = [foldersArray objectAtIndex:self.folderIndex];
+ self.bookmarks = [[folderDict objectForKey:@"bookmarks"] mutableCopy];
+ }
+ else {
+ self.bookmarks = nil;
}
-
- return folderFetchResults;
}
- (IBAction)switchToBrowser:(id)sender {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
if (mode == 'E') {
[self finishEditMode:sender];
}
-
- if ([browserController isPad]) {
- [[browserController padPopover] dismissPopoverAnimated:YES];
- } else {
- [UIView transitionFromView:[self.navigationController view]
- toView: [browserController view]
- duration:0.5
- options:(UIViewAnimationOptionTransitionCrossDissolve)
- completion:^(BOOL finished) {}];
- }
-
-
- [self.navigationController popToRootViewControllerAnimated:NO];
+ //[self.navigationController popToRootViewControllerAnimated:NO];
+ [UIView animateWithDuration:0.25 animations:^{
+ [self.navigationController view].alpha =0.0f;
+ [browserController dismissPopups];
+ }];
}
--(void) openBookmark:(NSIndexPath *) indexPath{
- [[browserController addressBar] setText:[[bookmarks objectAtIndex:[indexPath row]] valueForKey:@"url"]];
+-(void) openBookmark:(NSIndexPath *) indexPath{
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ [[browserController addressBar] setText:[[bookmarks objectAtIndex:[indexPath row]] valueForKey:@"URL"]];
[browserController gotoAddress:nil];
[self switchToBrowser:nil];
}
-(IBAction) enableEditMode:(id)sender {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ if(self.mode == 'B')
+ {
+ for (UIBarButtonItem *item in editToolbar.items)
+ {
+ if([[item title] isEqualToString:@"New Folder"])
+ {
+ [item setEnabled:NO];
+ [item setTintColor:[UIColor clearColor]];
+ }
+ }
+ }
+ else
+ {
+ for (UIBarButtonItem *item in editToolbar.items)
+ {
+ if([[item title] isEqualToString:@"New Folder"])
+ {
+ [item setEnabled:YES];
+ [item setTintColor:nil];
+ }
+ }
+ }
self.mode = 'E';
toolbar.hidden = YES;
editToolbar.hidden = NO;
[self.navigationItem setRightBarButtonItem:nil];
-
- [tableView reloadData];
-
+ [_tableView reloadData];
}
-(IBAction) finishEditMode:(id)sender{
- self.mode = 'V';
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ if(self.folderIndex == BOOKMARKS_ROOT || self.mode == 'V')
+ self.mode = 'V';
+ else
+ self.mode = 'B';
toolbar.hidden = NO;
editToolbar.hidden = YES;
@@ -165,10 +253,14 @@ -(IBAction) finishEditMode:(id)sender{
action:@selector(switchToBrowser:)];
[self.navigationItem setRightBarButtonItem:doneButton];
- [tableView reloadData];
+ [_tableView reloadData];
}
--(IBAction) addFolder:(id)sender{
+
+- (IBAction) addFolder:(id)sender{
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
[folderController setMode:'A'];
+ [folderController setBookmarksController:self];
[self.navigationController pushViewController:(UIViewController *)folderController animated:YES];
}
@@ -176,23 +268,43 @@ -(IBAction) addFolder:(id)sender{
#pragma mark Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- // Return the number of rows in the section.
- /*if (showAllBugs) {
- return [[[[NSURLCache sharedURLCache] filterManager] bugArray] count];
- } else {
- return [detectedBugs count];
- }*/
- return [bookmarks count];
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ [self loadBookmarks];
+ if(self.bookmarks != nil && self.folderIndex != BOOKMARKS_ROOT)
+ return [bookmarks count];
+ else
+ return [folders count];
}
+// get images for bookmarks
+-(NSString *) getBookmarkImageURLFromUrlString:(NSString *) urlString {
+ NSString *encodedURL = [urlString stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLHostAllowedCharacterSet]];
+ return [NSString stringWithFormat:@"http://www.google.com/s2/favicons?domain=%@", encodedURL];
+}
+
+-(UIImage *) getBookmarkImageFromUrlString:(NSString *) urlString {
+ NSString *bookmarkImageUrl = [self getBookmarkImageURLFromUrlString:urlString];
+ NSData *bookmarkImageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:bookmarkImageUrl]];
+ return ([bookmarkImageData length] > 0) ? [UIImage imageWithData:bookmarkImageData] : bookmarkImage;
+}
+
+-(void) setBookmarkImageForCellWithURL:(NSArray *) args {
+ BookmarkItem *cell = [args objectAtIndex:0];
+ NSString *urlString = [args objectAtIndex:1];
+ cell.cellImage.image = [self getBookmarkImageFromUrlString:urlString];
+}
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)localTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
static NSString *CellIdentifier = @"BookmarkItem";
@@ -207,44 +319,66 @@ - (UITableViewCell *)tableView:(UITableView *)localTableView cellForRowAtIndexPa
}
}
}
-
- NSManagedObject *item= [bookmarks objectAtIndex:[indexPath row]];
- cell.bookmarksController = self;
+ cell.bookmarksController = self;
cell.tableView = localTableView;
cell.indexPath = indexPath;
- if (![item isEqual:@"Bookmarks"] && [[[item entity] name] isEqualToString:@"Bookmark"]) {
- cell.cellImage.image = bookmarkImage;
+
+ //Load contents of each folder dictionary into a cell if in the Bookmarks root
+ if (self.mode == 'V' || self.mode == 'P')
+ {
+ NSDictionary* folderDict = [self.folders objectAtIndex:[indexPath row]];
+ [cell.cellLabel setText:[folderDict valueForKey:@"title"]];
+ cell.cellImage.image = folderImage;
+ }
+
+ //Load contents of each bookmark dictionary into a cell if in a Folder
+ if (self.mode == 'B')
+ {
+ NSDictionary* folderDict = [self.folders objectAtIndex:self.folderIndex];
+ NSArray* bookmarksArray = [folderDict objectForKey:@"bookmarks"];
+ NSDictionary* bookmarkDict = [bookmarksArray objectAtIndex:[indexPath row]];
+ [cell.cellLabel setText:[bookmarkDict valueForKey:@"title"]];
+ LogInfo(@"Cell Label : %@", cell.cellLabel.text);
+ // load bookmark icon async
+ [self performSelectorInBackground:@selector(setBookmarkImageForCellWithURL:) withObject:@[cell, [bookmarkDict objectForKey:@"URL"]] ];
+ }
+
+ if (self.mode == 'E') {
+ if(self.folderIndex != BOOKMARKS_ROOT)
+ {
+ NSDictionary* folderDict = [self.folders objectAtIndex:self.folderIndex];
+ NSArray* bookmarksArray = [folderDict objectForKey:@"bookmarks"];
+ NSDictionary* bookmarkDict = [bookmarksArray objectAtIndex:[indexPath row]];
+ [cell.cellLabel setText:[bookmarkDict valueForKey:@"title"]];
+ cell.cellImage.image = [self getBookmarkImageFromUrlString:[bookmarkDict objectForKey:@"URL"]];
+
+ [cell enableEdit];
+ }
+ else
+ {
+ NSDictionary* folderDict = [self.folders objectAtIndex:[indexPath row]];
+ [cell.cellLabel setText:[folderDict valueForKey:@"title"]];
+ cell.cellImage.image = folderImage;
+ if ([self.folders count] > 1)
+ {
+ [cell enableEdit];
+ }
+ else
+ {
+ [cell disableEdit];
+ }
+ }
} else {
- cell.cellImage.image = folderImage;
- }
- if ([item isEqual:@"Bookmarks"]) {
- [cell.cellLabel setText:@"Bookmarks"];
- } else {
- [cell.cellLabel setText:[item valueForKey:@"name"]];
+ [cell disableEdit];
}
-
- if (self.mode == 'E') {
- [cell enableEdit];
- } else if (self.mode == 'V') {
- [cell disableEdit];
- }
-
return cell;
}
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
- /*NSMutableArray *bugs = showAllBugs ? [[[NSURLCache sharedURLCache] filterManager] bugArray] : detectedBugs;
- NSManagedObject *bug = [bugs objectAtIndex:[indexPath indexAtPosition:1]];
- NSNumber *block = [bug valueForKey:@"block"];
- if (block.boolValue) {
- cell.textLabel.font = [UIFont italicSystemFontOfSize:19.0];
- cell.textLabel.textColor = [UIColor colorWithRed:0.2 green:0.0 blue:0.0 alpha:0.7];
- } else {
- cell.textLabel.font = [UIFont boldSystemFontOfSize:19.0];
- cell.textLabel.textColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1];
- }*/
- //cell.selectionStyle = UITableViewCellSelectionStyleNone;
- ((BookmarkItem *)cell).cellLabel.font = [UIFont italicSystemFontOfSize:17.0];
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ ((BookmarkItem *)cell).cellLabel.font = [UIFont italicSystemFontOfSize:14.0];
+
}
@@ -292,53 +426,56 @@ - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)
#pragma mark Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
- /*NSMutableArray *bugs = showAllBugs ? [[[NSURLCache sharedURLCache] filterManager] bugArray] : detectedBugs;
- NSManagedObject *bug = [bugs objectAtIndex:[indexPath indexAtPosition:1]];
- NSNumber *block = [bug valueForKey:@"block"];
-
- selectedManagedObject = [bugs objectAtIndex:[indexPath row]];
- if (selectedIndexPath) {
- [selectedIndexPath release];
- }
- selectedIndexPath = [indexPath copy];
-
- if (block.boolValue) {
- [blockButton setTitle:@"Unblock"];
- } else {
- [blockButton setTitle:@"Block"];
- }*/
- NSManagedObject *item = [bookmarks objectAtIndex:[indexPath row]];
- if (mode == 'V') {
- if ([[[item entity] name] isEqualToString:@"Folder"]) {
- BookmarksController *nextBookmarkController = [[BookmarksController alloc] initWithNibName:@"Bookmarks" bundle:[NSBundle mainBundle]];
- [nextBookmarkController setMode:[self mode]];
- [nextBookmarkController setCurrentFolder:item];
- [nextBookmarkController setManagedObjectContext:managedObjectContext];
- [nextBookmarkController setBrowserController:browserController];
- [nextBookmarkController setFolderController:[self folderController]];
- [self.navigationController pushViewController:nextBookmarkController animated:YES];
- } else {
- [self openBookmark:indexPath];
- }
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ if (mode == 'B') {
+ //Open the URL from the bookmark in the folder
+ [self openBookmark:indexPath];
+ } else if (mode == 'V') {
+ //Create a new bookmark controller, set the mode, and folder index
+ BookmarksController *nextBookmarkController = [[BookmarksController alloc] initWithNibName:@"Bookmarks" bundle:[NSBundle mainBundle]];
+ [nextBookmarkController setMode:'B'];
+ [nextBookmarkController setFolderIndex:[indexPath row]];
+ [nextBookmarkController setBrowserController:browserController];
+ [nextBookmarkController setFolderController:[self folderController]];
+ [self.navigationController pushViewController:nextBookmarkController animated:YES];
} else if (mode == 'E') {
- if ([[[item entity] name] isEqualToString:@"Folder"]) {
- [folderController setMode:'E'];
- [folderController setFolder:item];
- [self.navigationController pushViewController:(UIViewController *)folderController animated:YES];
- } else {
- [formController setMode:'E'];
- [self.navigationController pushViewController:formController animated:YES];
- }
+
+ [self loadBookmarks];
+
+ if (self.folderIndex == BOOKMARKS_ROOT)
+ {
+ self.folderIndex = [indexPath row];
+ [folderController setMode:'E'];
+ [self setMode:'V'];
+ [self.navigationController pushViewController:(UIViewController *)folderController animated:YES];
+ }
+ else
+ {
+ [formController setMode:'E'];
+ [self setBookmarkIndex:[indexPath row]];
+ [self.navigationController pushViewController:formController animated:YES];
+ }
+
+ } else if (self.mode == 'P') {
+ NSArray *vControllers = self.navigationController.viewControllers;
+ [[vControllers objectAtIndex:([vControllers count] - 3) ] setFolderIndex:[indexPath row]];
+ [self.navigationController popViewControllerAnimated:YES];
+
+ }
+}
- } else if (mode == 'P') {
- NSArray *vControllers = self.navigationController.viewControllers;
- [[vControllers objectAtIndex:([vControllers count] - 2) ] setSelectedFolder:item];
- [self.navigationController popViewControllerAnimated:YES];
- }
+- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ if ([tableView numberOfRowsInSection:0] < 2 && folderIndex == BOOKMARKS_ROOT) return NO;
+ return YES;
}
- (void)didReceiveMemoryWarning {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
@@ -346,6 +483,8 @@ - (void)didReceiveMemoryWarning {
}
- (void)viewDidUnload {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
diff --git a/Browser/BookmarksFormController.h b/Browser/BookmarksFormController.h
index c80bce0..717ba1a 100644
--- a/Browser/BookmarksFormController.h
+++ b/Browser/BookmarksFormController.h
@@ -6,36 +6,31 @@
//
#import
-#import
+
+@class BrowserViewController;
@interface BookmarksFormController : UIViewController {
+ BrowserViewController *browserController;
IBOutlet UIButton *parentField;
IBOutlet UITextField *nameField;
IBOutlet UITextField *urlField;
+ IBOutlet UILabel *arrowLabel;
UIBarButtonItem *cancelButton;
UIBarButtonItem *doneButton;
-
- NSManagedObject *selectedFolder;
-
NSString *defaultUrlFieldText;
-
char mode;
-
- NSManagedObjectContext *managedObjectContext;
}
+
+@property(nonatomic, strong) BrowserViewController *browserController;
@property(nonatomic, strong) UIButton *parentField;
@property(nonatomic, strong) UITextField *nameField;
@property(nonatomic, strong) UITextField *urlField;
+@property(nonatomic, strong) IBOutlet UILabel *arrowLabel;
@property(nonatomic, strong) UIBarButtonItem *cancelButton;
@property(nonatomic, strong) UIBarButtonItem *doneButton;
-
-@property(nonatomic, strong) NSManagedObject *selectedFolder;
-
@property(nonatomic,strong) NSString *defaultUrlFieldText;
-
@property(nonatomic, assign) char mode;
-@property(nonatomic, strong) NSManagedObjectContext *managedObjectContext;
-(IBAction) switchToBrowser:(id)sender;
-(IBAction) folderSelect:(id)sender;
diff --git a/Browser/BookmarksFormController.m b/Browser/BookmarksFormController.m
index ad049c4..87c2004 100644
--- a/Browser/BookmarksFormController.m
+++ b/Browser/BookmarksFormController.m
@@ -7,7 +7,6 @@
#import "BookmarksController.h"
#import "BookmarksFormController.h"
-#import "BrowserDelegate.h"
#import "BrowserViewController.h"
@class BrowserViewController;
@@ -15,30 +14,11 @@
@implementation BookmarksFormController
-@synthesize parentField, nameField, urlField, cancelButton, doneButton, managedObjectContext, mode, selectedFolder, defaultUrlFieldText;
-
-// The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
-/*
-- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
- self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
- if (self) {
- // Custom initialization.
- }
- return self;
-}
-*/
-
+@synthesize parentField, nameField, urlField, arrowLabel, cancelButton, doneButton, mode, defaultUrlFieldText, browserController;
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
- //set up DB
- if (managedObjectContext == nil)
- {
- managedObjectContext = [(BrowserDelegate *)[[UIApplication sharedApplication] delegate] managedObjectContext];
- NSLog(@"After managedObjectContext: %@", managedObjectContext);
- }
-
if (!mode) {
mode = 'A';
}
@@ -46,15 +26,19 @@ - (void)viewDidLoad {
doneButton = [[UIBarButtonItem alloc] initWithTitle:@"Save" style:UIBarButtonItemStyleDone target:self action:@selector(saveBookmark:)];
cancelButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(switchToBrowser:)];
- self.contentSizeForViewInPopover = CGSizeMake(320.0, 480.0);
+ if ([self respondsToSelector:@selector(setPreferredContentSize:)]) {
+ self.preferredContentSize = CGSizeMake(320.0, 480.0);
+ } else {
+ self.contentSizeForViewInPopover = CGSizeMake(320.0, 480.0);
+ }
[super viewDidLoad];
}
- (void) viewWillAppear:(BOOL)animated {
NSArray *vControllers = [self.navigationController viewControllers];
BookmarksController *bookmarksController = [vControllers objectAtIndex:([vControllers count] - 2)];
- BrowserViewController *browserController = [bookmarksController browserController];
-
+
+ //Edit mode
if (mode == 'E') {
// adjust nav
self.navigationItem.title = @"Edit Bookmark";
@@ -62,22 +46,19 @@ - (void) viewWillAppear:(BOOL)animated {
[self.navigationItem setLeftBarButtonItem:nil];
// load name and url
- [bookmarksController reloadBookmarks];
- NSMutableArray *bookmarks = [bookmarksController bookmarks];
- NSIndexPath *selectedIndexPath = [[bookmarksController tableView] indexPathForSelectedRow];
- NSManagedObject *bookmark = [bookmarks objectAtIndex:[selectedIndexPath row]];
- [urlField setText:[bookmark valueForKey:@"url"]];
- [nameField setText:[bookmark valueForKey:@"name"]];
- if (selectedFolder == nil) {
- selectedFolder = [bookmark valueForKey:@"Folder"];
- }
-
+ [bookmarksController loadBookmarks];
+ [urlField setText:[[bookmarksController.bookmarks objectAtIndex:bookmarksController.bookmarkIndex] valueForKey:@"URL"]];
+ [nameField setText:[[bookmarksController.bookmarks objectAtIndex:bookmarksController.bookmarkIndex] valueForKey:@"title"]];
+ [parentField setHidden:YES];
+ [arrowLabel setHidden:YES];
- } else if (mode == 'A') {
+ } else if (mode == 'A') { //Add Bookmark mode
// adjust nav
self.navigationItem.title = @"Add Bookmark";
[self.navigationItem setRightBarButtonItem:doneButton];
[self.navigationItem setLeftBarButtonItem:cancelButton];
+ [parentField setHidden:NO];
+ [arrowLabel setHidden:NO];
if (defaultUrlFieldText != nil) {
[urlField setText:defaultUrlFieldText];
@@ -93,10 +74,25 @@ - (void) viewWillAppear:(BOOL)animated {
}
}
- if (selectedFolder != nil && ![selectedFolder isEqual:@"Bookmarks"]) {
- [parentField setTitle:[selectedFolder valueForKey:@"name"] forState:UIControlStateNormal];
- } else {
- [parentField setTitle:@"Bookmarks" forState:UIControlStateNormal];
+
+ if (bookmarksController.folders != nil && [bookmarksController.folders count] > 0) {
+ NSDictionary* folderDict = nil;
+ NSString* title;
+
+ if(bookmarksController.folderIndex != BOOKMARKS_ROOT)
+ {
+ folderDict = [bookmarksController.folders objectAtIndex:bookmarksController.folderIndex];
+ title = [folderDict objectForKey:@"title"];
+ }
+ else
+ {
+ folderDict = [bookmarksController.folders objectAtIndex:0];
+ title = [folderDict objectForKey:@"title"];
+ }
+
+ [parentField setTitle:title forState:UIControlStateNormal];
+ [parentField setTitle:title forState:UIControlStateSelected];
+ [parentField setTitle:title forState:UIControlStateHighlighted];
}
[nameField becomeFirstResponder];
}
@@ -112,7 +108,7 @@ - (UIInterfaceOrientation) preferredInterfaceOrientationForPresentation {
// Return the orientation you'd prefer - this is what it launches to. The
// user can still rotate. You don't have to implement this method, in which
// case it launches in the current orientation
- return UIDeviceOrientationPortrait;
+ return UIInterfaceOrientationPortrait;
}
- (IBAction) switchToBrowser:(id)sender {
@@ -120,34 +116,113 @@ - (IBAction) switchToBrowser:(id)sender {
}
- (IBAction) folderSelect:(id)sender {
+ NSArray *vControllers = [self.navigationController viewControllers];
+ BookmarksController *bookmarksController = [vControllers objectAtIndex:([vControllers count] - 2)];
+
BookmarksController *nextBookmarkController = [[BookmarksController alloc] init];
[[NSBundle mainBundle] loadNibNamed:@"Bookmarks" owner:nextBookmarkController options:nil];
- [nextBookmarkController setMode:'P'];
- [nextBookmarkController setManagedObjectContext:managedObjectContext];
+ [nextBookmarkController setBrowserController:self.browserController];
+ [nextBookmarkController setMode:'P'];
+ [nextBookmarkController setFolderController:[bookmarksController folderController]];
+ [nextBookmarkController setFolderIndex:BOOKMARKS_ROOT];
[self.navigationController pushViewController:nextBookmarkController animated:YES];
}
- (IBAction) saveBookmark:(id)sender {
- NSArray *vControllers = [self.navigationController viewControllers];
+
+ NSArray *vControllers = [self.navigationController viewControllers];
BookmarksController *bookmarksController = [vControllers objectAtIndex:([vControllers count] - 2)];
- NSManagedObject *bookmark = nil;
- if (mode == 'A') {
- bookmark = [NSEntityDescription insertNewObjectForEntityForName:@"Bookmark" inManagedObjectContext:managedObjectContext];
- } else if (mode == 'E') {
- NSMutableArray *bookmarks = [bookmarksController bookmarks];
- NSIndexPath *selectedIndexPath = [[bookmarksController tableView] indexPathForSelectedRow];
- bookmark = [bookmarks objectAtIndex:[selectedIndexPath row]];
- }
-
- [bookmark setValue:nameField.text forKey:@"name"];
- [bookmark setValue:urlField.text forKey:@"url"];
- [bookmark setValue:([selectedFolder isEqual:@"Bookmarks"] ? nil : selectedFolder) forKey:@"Folder"];
-
- [managedObjectContext save:nil];
-
- [bookmarksController reloadBookmarks];
- [[bookmarksController tableView] reloadData];
- [bookmarksController switchToBrowser:sender];
+
+ //New Code to save bookmark - NSUserDefaults
+
+ //Load the Folders dictionary from the key in user defaults storage.
+ NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
+ NSMutableArray* foldersArray = [[defaults objectForKey:FOLDERS_KEY] mutableCopy];
+
+ //Create a bookmarks Dictionary
+ NSMutableDictionary* bookmarkDict = [[NSMutableDictionary alloc] init];
+ [bookmarkDict setObject:nameField.text forKey:@"title"];
+ [bookmarkDict setObject:[urlField.text stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding] forKey:@"URL"];
+
+ //Loop to check if the bookmarks have reached the max capacity and check if the bookmark exists
+ NSUInteger totalBookmarks = 0;
+ if(self.mode != 'E')
+ {
+ for (NSDictionary* folderDict in foldersArray)
+ {
+ //increment bookmarks counter
+ NSArray* bookmarkArray = (NSArray*)[folderDict objectForKey:@"bookmarks"];
+ totalBookmarks += [bookmarkArray count];
+
+ //Return after proper alert message if the bookmark exists
+ for (NSDictionary* bookmarkDict in bookmarkArray)
+ {
+ if([[urlField.text stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]
+ isEqualToString:[bookmarkDict objectForKey:@"URL"]])
+ {
+ UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Duplicate Bookmark"
+ message:[NSString stringWithFormat:@"This is in bookmark from folder \"%@\"",[folderDict objectForKey:@"title"]]
+ delegate:self
+ cancelButtonTitle:@"OK"
+ otherButtonTitles:nil];
+ [alert show];
+ return;
+ }
+ }
+ }
+ }
+
+ //Show alert if at max capacity and return
+ if(totalBookmarks >= MAX_BOOKMARKS)
+ {
+ UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Unable to Add Bookmark"
+ message:@"Bookmarks have reached max. capacity"
+ delegate:self
+ cancelButtonTitle:@"OK"
+ otherButtonTitles:nil];
+ [alert show];
+ return;
+ }
+
+ //Add the bookmark dictionary to the current folder's bookmark array
+ if(bookmarksController.folderIndex == BOOKMARKS_ROOT) bookmarksController.folderIndex = 0;
+ NSMutableDictionary* folderDict = (NSMutableDictionary*)[[foldersArray objectAtIndex:bookmarksController.folderIndex] mutableCopy];
+ NSMutableArray* bookmarksArray = [[folderDict objectForKey:@"bookmarks"] mutableCopy];
+ if(self.mode == 'E')
+ {
+ [bookmarksArray setObject:bookmarkDict atIndexedSubscript:bookmarksController.bookmarkIndex];
+ }
+ else
+ {
+ [bookmarksArray addObject:bookmarkDict];
+ }
+ [folderDict setObject:bookmarksArray forKey:@"bookmarks"];
+ [foldersArray setObject:folderDict atIndexedSubscript:bookmarksController.folderIndex];
+
+ //Save the bookmark into the correct folder
+ [defaults setObject:foldersArray forKey:FOLDERS_KEY];
+ [defaults synchronize];
+
+ //Reload all bC controllers on the navigation stack
+ for (BookmarksController* bC in self.navigationController.viewControllers)
+ {
+ if([bC isKindOfClass:[BookmarksController class]])
+ {
+ [bC loadBookmarks];
+ [bC.tableView reloadData];
+ }
+ }
+
+ if(self.mode == 'A')
+ {
+ [bookmarksController switchToBrowser:sender];
+ }
+ else
+ {
+ self.mode = 'B';
+ [self.navigationController popViewControllerAnimated:YES];
+ }
+
}
- (void)didReceiveMemoryWarning {
diff --git a/Browser/BrowserMainWindow.h b/Browser/BrowserMainWindow.h
new file mode 100644
index 0000000..ec6e221
--- /dev/null
+++ b/Browser/BrowserMainWindow.h
@@ -0,0 +1,15 @@
+//
+// BrowserMainWindow.h
+//
+// Created by Alexandru Catighera on 10/28/13.
+//
+//
+
+#import
+
+@interface BrowserMainWindow : UIWindow {
+ CGPoint tapLocation;
+ NSTimer *contextualMenuTimer;
+}
+
+@end
diff --git a/Browser/BrowserMainWindow.m b/Browser/BrowserMainWindow.m
new file mode 100644
index 0000000..5170742
--- /dev/null
+++ b/Browser/BrowserMainWindow.m
@@ -0,0 +1,53 @@
+//
+// BrowserMainWindow.m
+//
+// Created by Alexandru Catighera on 10/28/13.
+//
+//
+
+#import "BrowserMainWindow.h"
+
+@implementation BrowserMainWindow
+
+- (void)tapAndHoldAction:(NSTimer*)timer
+{
+ contextualMenuTimer = nil;
+ NSDictionary *coord = [NSDictionary dictionaryWithObjectsAndKeys:
+ [NSNumber numberWithFloat:tapLocation.x],@"x",
+ [NSNumber numberWithFloat:tapLocation.y],@"y",nil];
+ [[NSNotificationCenter defaultCenter] postNotificationName:@"TapAndHoldNotification" object:coord];
+}
+
+- (void)sendEvent:(UIEvent *)event
+{
+ NSSet *touches = [event touchesForWindow:self];
+
+ [super sendEvent:event]; // Call super to make sure the event is processed as usual
+
+ if ([touches count] == 1) { // We're only interested in one-finger events
+ UITouch *touch = [touches anyObject];
+
+ switch ([touch phase]) {
+ case UITouchPhaseBegan: // A finger touched the screen
+ tapLocation = [touch locationInView:self];
+ [contextualMenuTimer invalidate];
+ contextualMenuTimer = [NSTimer scheduledTimerWithTimeInterval:0.8
+ target:self selector:@selector(tapAndHoldAction:)
+ userInfo:nil repeats:NO];
+ break;
+
+ case UITouchPhaseEnded:
+ case UITouchPhaseMoved:
+ case UITouchPhaseStationary:
+ case UITouchPhaseCancelled:
+ [contextualMenuTimer invalidate];
+ contextualMenuTimer = nil;
+ break;
+ }
+ } else { // Multiple fingers are touching the screen
+ [contextualMenuTimer invalidate];
+ contextualMenuTimer = nil;
+ }
+}
+
+@end
diff --git a/Browser/BrowserViewController.h b/Browser/BrowserViewController.h
index 5ca5394..d296789 100644
--- a/Browser/BrowserViewController.h
+++ b/Browser/BrowserViewController.h
@@ -8,94 +8,52 @@
#import
#import
#import
+
+#define kStartedLoadingNotification @"kStartedLoadingNotification"
+#define kFinishedLoadingNotification @"kFinishedLoadingNotification"
+
+//reference: http://stackoverflow.com/a/18085584/347339
+#define DEVICE_SIZE [[UIScreen mainScreen] bounds].size
+
@class Tab, BookmarksController, BookmarksFormController, Reachability;
-@interface BrowserViewController : UIViewController {
-
- IBOutlet UIView *webViewTemplate;
- IBOutlet UIScrollView *tabsView;
- IBOutlet UIView *topBar;
- IBOutlet UIToolbar *bottomBar;
- IBOutlet UIToolbar *navBar;
-
- IBOutlet UITextField *addressBar;
- NSMutableString *oldAddressText;
-
- IBOutlet UIActivityIndicatorView *activityIndicator;
- IBOutlet UIView *addressBarButtonsView;
- IBOutlet UIButton *refreshButton;
- IBOutlet UIButton *stopButton;
-
- IBOutlet UIBarButtonItem *forwardButton;
- IBOutlet UIBarButtonItem *backButton;
- IBOutlet UIBarButtonItem *addressItem;
- IBOutlet UIBarButtonItem *searchItem;
- IBOutlet UIBarButtonItem *customButton;
- IBOutlet UIBarButtonItem *customButton2;
- IBOutlet UIBarButtonItem *moreButton;
- IBOutlet UIBarButtonItem *bookmarkButton;
-
- UIBarButtonItem *barItemPopoverPresenter;
- UIActionSheet *popupQuery;
- UIPopoverController *padPopover;
-
- IBOutlet UIButton *addTab;
- Tab *selectedTab;
- NSMutableArray *tabs;
-
- NSURL *gotoUrl;
-
- UINavigationController *bookmarksController;
- BookmarksFormController *bookmarksFormController;
-
- BOOL reloadOnPageLoad;
- BOOL initialPageLoad;
- BOOL saveScrollPosition;
-
- NSString *userAgent;
-
-
- IBOutlet UIProgressView *progressBar;
- float contentSize;
-
-}
-@property(nonatomic,strong) UIView *webViewTemplate;
-
-@property(nonatomic,strong) UIScrollView *tabsView;
-@property(nonatomic,strong) UIView *topBar;
-@property(nonatomic,strong) UIToolbar *bottomBar;
-
-@property(nonatomic,strong) UIToolbar *navBar;
+@interface BrowserViewController : UIViewController
+
+@property(nonatomic,strong) IBOutlet UIView *webViewTemplate;
+
+@property(nonatomic,strong) IBOutlet UIScrollView *tabsView;
+@property(nonatomic,strong) IBOutlet UIView *topBar;
+@property(nonatomic,strong) IBOutlet UIToolbar *bottomBar;
+
+@property(nonatomic,strong) IBOutlet UIToolbar *navBar;
@property(nonatomic,strong) UIToolbar *bugListNavBar;
-@property(nonatomic,strong) UITextField *addressBar;
+@property(nonatomic,strong) IBOutlet UITextField *addressBar;
@property(nonatomic,strong) UITextField *searchBar;
@property(nonatomic,strong) NSMutableString *oldAddressText;
-@property(nonatomic,strong) UIActivityIndicatorView *activityIndicator;
-@property(nonatomic,strong) UIView *addressBarButtonsView;
-@property(nonatomic,strong) UIButton *refreshButton;
-@property(nonatomic,strong) UIButton *stopButton;
+@property(nonatomic,strong) IBOutlet UIActivityIndicatorView *activityIndicator;
+@property(nonatomic,strong) IBOutlet UIView *addressBarButtonsView;
+@property(nonatomic,strong) IBOutlet UIButton *refreshButton;
+@property(nonatomic,strong) IBOutlet UIButton *stopButton;
-@property(nonatomic,strong) UIBarButtonItem *forwardButton;
-@property(nonatomic,strong) UIBarButtonItem *backButton;
-@property(nonatomic,strong) UIBarButtonItem *addressItem;
-@property(nonatomic,strong) UIBarButtonItem *searchItem;
-@property(nonatomic,strong) UIBarButtonItem *customButton;
-@property(nonatomic,strong) UIBarButtonItem *customButton2;
-@property(nonatomic,strong) UIBarButtonItem *moreButton;
-@property(nonatomic,strong) UIBarButtonItem *bookmarkButton;
+@property(nonatomic,strong) IBOutlet UIBarButtonItem *forwardButton;
+@property(nonatomic,strong) IBOutlet UIBarButtonItem *backButton;
+@property(nonatomic,strong) IBOutlet UIBarButtonItem *addressItem;
+@property(nonatomic,strong) IBOutlet UIBarButtonItem *searchItem;
+@property(nonatomic,strong) IBOutlet UIBarButtonItem *moreButton;
+@property(nonatomic,strong) IBOutlet UIBarButtonItem *bookmarkButton;
@property(nonatomic,strong) UIBarButtonItem *barItemPopoverPresenter;
@property(nonatomic,strong) UIActionSheet *popupQuery;
@property(nonatomic,strong) UIPopoverController *padPopover;
-@property(nonatomic,strong) UIButton *addTab;
+@property(nonatomic,strong) IBOutlet UIButton *addTab;
@property(nonatomic,strong) Tab *selectedTab;
@property(nonatomic,strong) NSMutableArray *tabs;
@property(nonatomic,strong) NSURL *gotoUrl;
-@property(nonatomic,strong) UINavigationController *bookmarksController;
+@property(nonatomic,strong) UINavigationController *bookmarksNavController;
@property(nonatomic,strong) BookmarksFormController *bookmarksFormController;
@property(nonatomic,strong) BrowserViewController *browserController;
@@ -106,7 +64,7 @@
@property(nonatomic,strong) NSString *userAgent;
-@property(nonatomic,strong) UIProgressView *progressBar;
+@property(nonatomic,strong) IBOutlet UIProgressView *progressBar;
@property(nonatomic,assign) float contentSize;
-(IBAction) gotoAddress:(id)sender;
@@ -116,10 +74,10 @@
-(IBAction) goForward:(id)sender;
-(IBAction) stopLoading:(id)sender;
-(IBAction) showBookmarks:(id)sender;
--(IBAction) customButtonClick:(id)sender;
--(IBAction) customButtonClick2:(id)sender;
-(IBAction) scrollToTop:(id)sender;
+-(void) toggleBottomBarWithCompletion:(void (^)(BOOL finished))completion;
+
-(NSArray *) actionSheetButtons;
-(IBAction) showActionSheet:(id)sender;
-(void) actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex;
@@ -128,7 +86,7 @@
-(void) addTabWithAddress:(NSString *)urlAddress;
-(IBAction) selectTab:(id)sender;
-(IBAction) removeTab:(id)sender;
--(IBAction) toggleTabsView:(id)sender;
+//-(IBAction) toggleTabsView:(id)sender;
-(void) loadTabs:(UIWebView *) webView;
-(void) switchTabFrom:(Tab *)fromTab ToTab:(Tab *)toTab;
@@ -151,5 +109,6 @@
-(void) saveOpenTabs;
-(void) openSavedTabs;
-(void) deleteSavedTabs;
+-(void) dismissPopups;
@end
diff --git a/Browser/BrowserViewController.m b/Browser/BrowserViewController.m
index 17804d4..f1a2801 100644
--- a/Browser/BrowserViewController.m
+++ b/Browser/BrowserViewController.m
@@ -11,8 +11,8 @@
#import "BookmarksFormController.h"
#import "BookmarkFolderFormController.h"
#import "UIMainView.h"
-#import "BrowserDelegate.h"
#import "Reachability.h"
+#import "Logging.h"
#import
@@ -25,20 +25,21 @@
ScrollDirectionCrazy,
} ScrollDirection;
-@interface BrowserViewController ()
-
-@end
-
-@implementation BrowserViewController {
-
+@interface BrowserViewController () {
+
BOOL localWiFiRef;
SCNetworkReachabilityRef reachabilityRef;
}
-@synthesize addressBar, addressBarButtonsView, addressItem, searchItem, activityIndicator, topBar, bottomBar, refreshButton, forwardButton, backButton, navBar, oldAddressText, addTab, selectedTab, tabs, tabsView, webViewTemplate, bookmarksController, bookmarksFormController, bookmarkButton, bugListNavBar, stopButton, moreButton, reloadOnPageLoad, initialPageLoad, progressBar, gotoUrl, contentSize, barItemPopoverPresenter, padPopover, popupQuery, saveScrollPosition, customButton, customButton2, userAgent;
+@end
+
+@implementation BrowserViewController
+
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
if (nibNameOrNil == nil) {
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
nibNameOrNil = @"MainWindow";
@@ -50,34 +51,41 @@ - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
return self;
}
+- (id)initWithCoder:(NSCoder *)aDecoder{
+ if ((self = [super initWithCoder:aDecoder])){
+ NSString *nibNameOrNil;
+ if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
+ nibNameOrNil = @"MainWindow";
+ } else {
+ nibNameOrNil = @"MainWindow-iPad";
+ }
+
+ [self setView:
+ [[[NSBundle mainBundle] loadNibNamed:nibNameOrNil
+ owner:self
+ options:nil] objectAtIndex:0]];
+ }
+ return self;
+}
+
- (void)viewDidLoad
{
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
[super viewDidLoad];
//set background for toolbar in top bar
if ([self isPad]) {
UIImage *img = [UIImage imageNamed:@"gray-pixel.png"];
- [bottomBar setBackgroundImage:img forToolbarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
+ [_bottomBar setBackgroundImage:img forToolbarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
}
//size statusbar
[(UIMainView *)[self view] sizeStatusBar];
// Set up bookmark controllers
- BookmarksFormController *bookmarksFormController = [[BookmarksFormController alloc]
- initWithNibName:@"BookmarksForm"
- bundle:[NSBundle mainBundle]];
- BookmarkFolderFormController *bookmarkFolderFormController = [[BookmarkFolderFormController alloc]
- initWithNibName:@"BookmarkFoldersForm"
- bundle:[NSBundle mainBundle]];
-
- BookmarksController *bookmarksController = [[BookmarksController alloc] initWithNibName:@"Bookmarks" bundle:[NSBundle mainBundle]];
- UINavigationController *bookmarksNavController = [[UINavigationController alloc] initWithRootViewController:bookmarksController];
-
- [self setBookmarksFormController:bookmarksFormController];
- [bookmarksController setBrowserController:self];
- [bookmarkFolderFormController setBookmarksController:bookmarksController];
- [bookmarksController setFolderController:bookmarkFolderFormController];
- [self setBookmarksController:bookmarksNavController];
+ [self createBookmarksController:YES];
+ [self.view addSubview:self.bookmarksNavController.view];
+ self.bookmarksNavController.view.alpha = 0.0f; //Hide the bookmarks controller
// Tweak address bar view so text doesn't overflow
UIView *addressBarStatusView = [[ UIView alloc ] initWithFrame:
@@ -86,14 +94,43 @@ - (void)viewDidLoad
[self.addressBar setRightViewMode: UITextFieldViewModeUnlessEditing];
self.oldAddressText = [NSMutableString stringWithString:@""];
- selectedTab.currentURLString = @"";
+ _selectedTab.currentURLString = @"";
[self registerForKeyboardNotifications];
+ [self registerForBrowserNotifications];
+}
+
+- (UINavigationController *)createBookmarksController:(BOOL)isMainController {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+ BookmarksFormController *bookmarksFormController = [[BookmarksFormController alloc]
+ initWithNibName:@"BookmarksForm"
+ bundle:[NSBundle mainBundle]];
+ [bookmarksFormController setBrowserController:self];
+ BookmarkFolderFormController *bookmarkFolderFormController = [[BookmarkFolderFormController alloc]
+ initWithNibName:@"BookmarkFoldersForm"
+ bundle:[NSBundle mainBundle]];
+ BookmarksController *bookmarksController = [[BookmarksController alloc] initWithNibName:@"Bookmarks" bundle:[NSBundle mainBundle]];
+ UINavigationController *bookmarksNavController = [[UINavigationController alloc] initWithRootViewController:bookmarksController];
+ [bookmarksController setBrowserController:self];
+ [bookmarkFolderFormController setBookmarksController:bookmarksController];
+ [bookmarksController setFolderController:bookmarkFolderFormController];
+ if(isMainController) //Creating the main bookmarks page which persists by hiding/unhiding
+ {
+ [self setBookmarksNavController:bookmarksNavController];
+ [self setBookmarksFormController:bookmarksFormController];
+ }
+ else //Creating a temporary bookmark controller for the popup with a form controller on the top of the nav stack
+ {
+ [bookmarksNavController pushViewController:bookmarksFormController animated:NO];
+ }
+ return bookmarksNavController;
}
- (void)registerForKeyboardNotifications
{
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWasShown:)
name:UIKeyboardDidShowNotification object:nil];
@@ -105,20 +142,71 @@ - (void)registerForKeyboardNotifications
}
- (void)keyboardWasShown:(NSNotification *)aNotification {
- if (![self isPad] && [selectedTab currentURL] == nil && ![addressBar isFirstResponder]) {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ if (![self isPad] && [_selectedTab currentURL] == nil && ![_addressBar isFirstResponder]) {
[self scrollToTop:aNotification];
- [[selectedTab webView] stringByEvaluatingJavaScriptFromString:@"document.getElementById('contain').style.top = '-15px'"];
+ [[_selectedTab webView] stringByEvaluatingJavaScriptFromString:@"document.getElementById('contain').style.top = '-15px'"];
}
}
- (void)keyboardWasHidden:(NSNotification*)aNotification {
- if (![self isPad] && [selectedTab currentURL] == nil && ![addressBar isFirstResponder]) {
- [[selectedTab webView] stringByEvaluatingJavaScriptFromString:@"document.getElementById('contain').style.top = '15%'"];
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ if (![self isPad] && [_selectedTab currentURL] == nil && ![_addressBar isFirstResponder]) {
+ [[_selectedTab webView] stringByEvaluatingJavaScriptFromString:@"document.getElementById('contain').style.top = '15%'"];
[self scrollToTop:aNotification];
}
}
+- (void)registerForBrowserNotifications
+{
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ [[NSNotificationCenter defaultCenter] removeObserver:self name:kStartedLoadingNotification object:nil];
+ [[NSNotificationCenter defaultCenter] removeObserver:self name:kFinishedLoadingNotification object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(startedLoadingNotification:)
+ name:kStartedLoadingNotification
+ object:_selectedTab];
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(finishedLoadingNotification:)
+ name:kFinishedLoadingNotification
+ object:_selectedTab];
+
+}
+
+- (void)startedLoadingNotification:(NSNotification *)notification {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ [self displayAsLoading];
+}
+
+- (void)finishedLoadingNotification:(NSNotification *)notification {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ [self displayAsNotLoading];
+}
+
+- (void)displayAsLoading {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ [_stopButton setHidden:NO];
+ [_refreshButton setHidden:YES];
+}
+
+- (void)displayAsNotLoading {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ [_stopButton setHidden:YES];
+ [_refreshButton setHidden:NO];
+}
+
-(void) saveOpenTabs {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ //Core Data Fix
+ /*
NSManagedObjectContext *managedObjectContext = [(BrowserDelegate *)[[UIApplication sharedApplication] delegate] managedObjectContext];
NSError *error;
int orderCount = 0;
@@ -132,9 +220,14 @@ -(void) saveOpenTabs {
if (![managedObjectContext save:&error]) {
NSLog(@"Error inserting %@ - error:%@",[self tabs],error);
}
+ */
}
-(void) openSavedTabs {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ //Core Data Fix
+ /*
NSManagedObjectContext *managedObjectContext = [(BrowserDelegate *)[[UIApplication sharedApplication] delegate] managedObjectContext];
NSFetchRequest *request = [[NSFetchRequest alloc] init];
NSError *error = nil;
@@ -147,17 +240,22 @@ -(void) openSavedTabs {
for (NSManagedObject *tab in tabFetchResults) {
[self addTabWithAddress:[tab valueForKey:@"url"]];
- [selectedTab setTitle:[tab valueForKey:@"title"]];
+ [_selectedTab setTitle:[tab valueForKey:@"title"]];
[managedObjectContext deleteObject:tab];
}
if (![managedObjectContext save:&error]) {
NSLog(@"Error deleting %@ - error:%@",tabFetchResults,error);
}
+ */
}
-(void) deleteSavedTabs {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ //Core Data Fix
+ /*
NSManagedObjectContext *managedObjectContext = [(BrowserDelegate *)[[UIApplication sharedApplication] delegate] managedObjectContext];
NSFetchRequest *request = [[NSFetchRequest alloc] init];
NSError *error = nil;
@@ -171,10 +269,13 @@ -(void) deleteSavedTabs {
if (![managedObjectContext save:&error]) {
NSLog(@"Error deleting %@ - error:%@",tabFetchResults,error);
}
+ */
}
- (void) viewDidAppear:(BOOL)animated {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
[super viewDidAppear:animated];
//create initial tab
if ([self.tabs count] == 0) {
@@ -184,16 +285,22 @@ - (void) viewDidAppear:(BOOL)animated {
}
- (void) viewWillAppear:(BOOL)animated {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
//[refreshButton setHidden:YES];
[super viewWillAppear:animated];
}
-(void) viewWillDisappear:(BOOL)animated {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
[self.navigationController setNavigationBarHidden:NO animated:animated];
}
- (void)didReceiveMemoryWarning
{
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@@ -201,28 +308,32 @@ - (void)didReceiveMemoryWarning
// Scrolling
-(IBAction)scrollToTop:(id)sender {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
if (![self isPad]) {
- BOOL animated = ![sender isKindOfClass:[NSNotification class]];
- [[[self webView] scrollView] setContentOffset:CGPointMake(0, - topBar.frame.size.height) animated:NO];
+// BOOL animated = ![sender isKindOfClass:[NSNotification class]];
+ [[[self webView] scrollView] setContentOffset:CGPointMake(0, - _topBar.frame.size.height) animated:NO];
[[[self webView] scrollView] setContentInset:UIEdgeInsetsMake(-[[self webView] scrollView].contentOffset.y, 0, 0, 0)];
}
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
- ScrollDirection scrollDirection;
- int minWebViewSize = webViewTemplate.frame.size.height;
- int maxWebViewSize = minWebViewSize + bottomBar.frame.size.height;
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ ScrollDirection scrollDirection = ScrollDirectionNone;
+ int minWebViewSize = _webViewTemplate.frame.size.height;
+ int maxWebViewSize = minWebViewSize + _bottomBar.frame.size.height;
if (self.lastScrollContentOffset > scrollView.contentOffset.y)
scrollDirection = ScrollDirectionUp;
else if (self.lastScrollContentOffset < scrollView.contentOffset.y)
scrollDirection = ScrollDirectionDown;
- if (saveScrollPosition) {
- selectedTab.scrollPosition = scrollView.contentOffset.y;
+ if (_saveScrollPosition) {
+ _selectedTab.scrollPosition = scrollView.contentOffset.y;
}
if(![self isPad]) {
UIView *statusBarView = [(UIMainView *)self.view statusBarView];
- if (scrollView.contentOffset.y <= -topBar.frame.size.height) {
+ if (scrollView.contentOffset.y <= -_topBar.frame.size.height) {
// noop
} else if (scrollView.contentOffset.y < -statusBarView.frame.size.height) {
[[[self webView] scrollView] setContentInset:UIEdgeInsetsMake(-scrollView.contentOffset.y, 0, 0, 0)];
@@ -231,52 +342,29 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView{
}
// show bottom toolbar when scrolling up fast
- if (scrollDirection == ScrollDirectionUp && scrollView.contentOffset.y - self.lastScrollContentOffset < -20 && bottomBar.alpha == 0.0) {
- [UIView animateWithDuration: 0.5
- delay: 0.0
- options: UIViewAnimationOptionCurveEaseOut
- animations:^{
- bottomBar.alpha = 1.0;
- }
- completion:^(BOOL finished){
+ if (scrollDirection == ScrollDirectionUp && scrollView.contentOffset.y - self.lastScrollContentOffset < -20 && _bottomBar.alpha == 0.0) {
+ [self toggleBottomBarWithCompletion:^(BOOL finished){
if (finished) {
- [selectedTab webView].frame = CGRectMake([selectedTab webView].frame.origin.x, [selectedTab webView].frame.origin.y, [selectedTab webView].frame.size.width, minWebViewSize);
+ [_selectedTab webView].frame = CGRectMake([_selectedTab webView].frame.origin.x, [_selectedTab webView].frame.origin.y, [_selectedTab webView].frame.size.width, minWebViewSize);
}
}];
- topBar.frame=CGRectMake(0,0, topBar.frame.size.width, topBar.frame.size.height);
+ _topBar.frame=CGRectMake(0,0, _topBar.frame.size.width, _topBar.frame.size.height);
} else if (scrollView.contentOffset.y > 0 && scrollView.contentOffset.y + scrollView.frame.size.height < scrollView.contentSize.height) {
- if (scrollDirection == ScrollDirectionDown && bottomBar.alpha == 1.0) {
- [selectedTab webView].frame = CGRectMake([selectedTab webView].frame.origin.x, [selectedTab webView].frame.origin.y, [selectedTab webView].frame.size.width, maxWebViewSize);
+ if (scrollDirection == ScrollDirectionDown && _bottomBar.alpha == 1.0) {
+ [_selectedTab webView].frame = CGRectMake([_selectedTab webView].frame.origin.x, [_selectedTab webView].frame.origin.y, [_selectedTab webView].frame.size.width, maxWebViewSize);
- [UIView animateWithDuration: 1.0
- delay: 0.0
- options: UIViewAnimationOptionCurveEaseIn
- animations:^{
- bottomBar.alpha = 0.0;
- }
- completion:^(BOOL finished){
- if (finished) {
- }
- }];
+ [self toggleBottomBarWithCompletion:nil];
}
// show bottom toolbar
- } else if (bottomBar.alpha == 0.0) {
-
-
- [UIView animateWithDuration: 0.5
- delay: 0.0
- options: UIViewAnimationOptionCurveEaseOut
- animations:^{
- bottomBar.alpha = 1.0;
- }
- completion:^(BOOL finished){
+ } else if (_bottomBar.alpha == 0.0) {
+ [self toggleBottomBarWithCompletion:^(BOOL finished){
if (finished) {
- [selectedTab webView].frame = CGRectMake([selectedTab webView].frame.origin.x, [selectedTab webView].frame.origin.y, [selectedTab webView].frame.size.width, minWebViewSize);
+ [_selectedTab webView].frame = CGRectMake([_selectedTab webView].frame.origin.x, [_selectedTab webView].frame.origin.y, [_selectedTab webView].frame.size.width, minWebViewSize);
if (scrollView.contentOffset.y > 0) {
- CGPoint bottomOffset = CGPointMake(0, scrollView.contentSize.height - [selectedTab webView].frame.size.height);
+ CGPoint bottomOffset = CGPointMake(0, scrollView.contentSize.height - [_selectedTab webView].frame.size.height);
[scrollView setContentOffset:bottomOffset animated:NO];
}
}
@@ -286,33 +374,31 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView{
}
//topbar logic
- if(![self isPad] && scrollView.contentOffset.y>=-topBar.frame.size.height && (scrollView.contentOffset.y <= 0 || scrollDirection == ScrollDirectionDown))
+ if(![self isPad] && scrollView.contentOffset.y>=-_topBar.frame.size.height && (scrollView.contentOffset.y <= 0 || scrollDirection == ScrollDirectionDown))
{
- topBar.frame=CGRectMake(0,-topBar.frame.size.height-scrollView.contentOffset.y, topBar.frame.size.width, topBar.frame.size.height);
+ _topBar.frame=CGRectMake(0,-_topBar.frame.size.height-scrollView.contentOffset.y, _topBar.frame.size.width, _topBar.frame.size.height);
}
self.lastScrollContentOffset = scrollView.contentOffset.y;
}
-- (void)showHideView
+- (void)toggleBottomBarWithCompletion:(void (^)(BOOL finished))completion
{
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+ float alpha = 0.0;
+ //UIViewAnimationCurve *options = UIViewAnimationCurveEaseO
+
+ if (_bottomBar.alpha == 0.0) {
+ alpha = 1.0;
+ }
// Fade out the view right away
[UIView animateWithDuration:1.0
delay: 0.0
- options: UIViewAnimationOptionCurveEaseIn
+ options: UIViewAnimationOptionCurveEaseInOut
animations:^{
- bottomBar.alpha = 0.0;
+ _bottomBar.alpha = alpha;
}
- completion:^(BOOL finished){
- // Wait one second and then fade in the view
- [UIView animateWithDuration:1.0
- delay: 1.0
- options:UIViewAnimationOptionCurveEaseOut
- animations:^{
- bottomBar.alpha = 1.0;
- }
- completion:nil];
- }];
+ completion: completion];
}
@@ -320,51 +406,57 @@ - (void)showHideView
// Web methods
- (void) currentWebViewDidStartLoading:(UIWebView *) webView {
- if (addressBar.editing) {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ if (_addressBar.editing) {
[webView stopLoading];
return;
}
Tab *tab = nil;
- for (id cTab in tabs) {
+ for (id cTab in _tabs) {
if ([cTab webView] == webView) {
tab = cTab;
}
}
- if (tab == selectedTab) {
+ if (tab == _selectedTab) {
- if (initialPageLoad) {
- [refreshButton setHidden:true];
- [stopButton setHidden:false];
+ if (_initialPageLoad) {
+ [_refreshButton setHidden:YES];
+ [_stopButton setHidden:NO];
}
}
- if (progressBar.progress < 0.95) {
- [progressBar setProgress: progressBar.progress + 0.05];
+ if (_progressBar.progress < 0.95) {
+ [_progressBar setProgress:_progressBar.progress + 0.05];
}
[self setInitialPageLoad:NO];
}
--(void) currentWebViewDidFinishFinalLoad:(UIWebView *) webView {
- [progressBar setProgress:1.0 animated:NO];
- [progressBar setHidden:YES];
+- (void)currentWebViewDidFinishFinalLoad:(UIWebView *) webView {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ [_progressBar setProgress:1.0 animated:NO];
+ [_progressBar setHidden:YES];
- [stopButton setHidden:YES];
+ [_stopButton setHidden:YES];
NSURL *url = [webView.request URL];
if ([url isFileURL] || [[url absoluteString] isEqualToString:@"about:blank"]) {
- [refreshButton setHidden:YES];
+ [_refreshButton setHidden:YES];
} else {
- [refreshButton setHidden:NO];
+ [_refreshButton setHidden:NO];
}
- if (saveScrollPosition && [selectedTab scrollPosition] > 0) {
- [[[self webView] scrollView] setContentOffset:CGPointMake(0, [selectedTab scrollPosition]) animated:NO];
+ if (_saveScrollPosition && [_selectedTab scrollPosition] > 0) {
+ [[[self webView] scrollView] setContentOffset:CGPointMake(0, [_selectedTab scrollPosition]) animated:NO];
}
[self loadTabs:webView];
}
--(void) gotoAddress:(id) sender withRequestObj:(NSURLRequest *)request inTab:(Tab *)tab {
+- (void)gotoAddress:(id)sender withRequestObj:(NSURLRequest *)request inTab:(Tab *)tab {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
// Clear detected bugs
tab.currentURLString = @"";
[self setInitialPageLoad:YES];
@@ -373,33 +465,33 @@ -(void) gotoAddress:(id) sender withRequestObj:(NSURLRequest *)request inTab:(Ta
[[self webView] stopLoading];
//[[self webView] loadHTMLString:@"" baseURL:[NSURL URLWithString:@"about:blank" ]];
- saveScrollPosition = [[[request URL] host] isEqualToString:@"duckduckgo.com"] || [[[request URL] host] isEqualToString:@"www.duckduckgo.com"];
+ _saveScrollPosition = [[[request URL] host] isEqualToString:@"duckduckgo.com"] || [[[request URL] host] isEqualToString:@"www.duckduckgo.com"];
if (![self isPad]) {
[self scrollToTop:nil];
}
- [oldAddressText setString:[addressBar text]];
+ [_oldAddressText setString:[_addressBar text]];
// Load the request in the UIWebView.
if ([self checkNetworkStatus]) {
//[[self webView] loadRequest:requestObj];
NSMutableURLRequest *mRequest = [request mutableCopy];
- NSString *d = [self isPad] ? @"iPad" : @"iPhone";
+ NSString *deviceString = [self isPad] ? @"iPad" : @"iPhone";
if (!self.userAgent) {
self.userAgent = [[tab webView] stringByEvaluatingJavaScriptFromString:@"navigator.userAgent"];
}
- [mRequest setValue:[NSString stringWithFormat:self.userAgent, d] forHTTPHeaderField:@"User-Agent"];
+ [mRequest setValue:[NSString stringWithFormat:self.userAgent, deviceString] forHTTPHeaderField:@"User-Agent"];
- if ( [[[request URL] host] isEqualToString:@"itunes.apple.com"]) {
+ if ([[[request URL] host] isEqualToString:@"itunes.apple.com"]) {
[[UIApplication sharedApplication] openURL: mRequest.URL ];
} else {
- [progressBar setHidden:NO];
- [progressBar setProgress:0.1 animated:NO];
+ [_progressBar setHidden:NO];
+ [_progressBar setProgress:0.1 animated:NO];
tab.urlConnection = nil;
tab.urlConnection = [[NSURLConnection alloc] initWithRequest:mRequest delegate:tab];
- if (sender != refreshButton) {
+ if (sender != _refreshButton) {
[tab updateHistory];
}
}
@@ -413,49 +505,58 @@ -(void) gotoAddress:(id) sender withRequestObj:(NSURLRequest *)request inTab:(Ta
otherButtonTitles:@"Okay", nil];
[netAlert show];*/
- [progressBar setHidden:YES];
+ [_progressBar setHidden:YES];
[self cannotConnect:nil];
}
- [addressBar resignFirstResponder];
+ [_addressBar resignFirstResponder];
}
-(IBAction) didStartEditingAddressBar:(id)sender {
- if ([[addressBar text] length] > 0) {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ if ([[_addressBar text] length] > 0) {
[self performSelector:@selector(selectAllAddressText) withObject:nil afterDelay:0.0];
}
- [addressBarButtonsView setHidden:YES];
+ [_addressBarButtonsView setHidden:YES];
}
-(void) selectAllAddressText {
- [addressBar setSelectedTextRange:[addressBar textRangeFromPosition:addressBar.beginningOfDocument toPosition:addressBar.endOfDocument]];
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ [_addressBar setSelectedTextRange:[_addressBar textRangeFromPosition:_addressBar.beginningOfDocument toPosition:_addressBar.endOfDocument]];
}
-(IBAction) gotoAddress:(id) sender {
- [addressBarButtonsView setHidden:NO];
- [stopButton setHidden:NO];
- [refreshButton setHidden:YES];
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
- NSString *inputText = [[addressBar text] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
- gotoUrl = [NSURL URLWithString:inputText];
- if (gotoUrl != nil && (!([[gotoUrl scheme] isEqualToString:@"http"] || [[gotoUrl scheme] isEqualToString:@"https"]))) {
- gotoUrl = [NSURL URLWithString: [@"http://" stringByAppendingString: [gotoUrl absoluteString]]];
+ [_addressBarButtonsView setHidden:NO];
+ [_stopButton setHidden:NO];
+ [_refreshButton setHidden:YES];
+
+ NSString *inputText = [[_addressBar text] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
+ _gotoUrl = [NSURL URLWithString:inputText];
+ if (_gotoUrl != nil && (!([[_gotoUrl scheme] isEqualToString:@"http"] || [[_gotoUrl scheme] isEqualToString:@"https"]))) {
+ _gotoUrl = [NSURL URLWithString: [@"http://" stringByAppendingString:[_gotoUrl absoluteString]]];
}
- NSURLRequest *request = [NSURLRequest requestWithURL:gotoUrl];
+ NSURLRequest *request = [NSURLRequest requestWithURL:_gotoUrl];
if ([inputText rangeOfString:@"."].location != NSNotFound && [NSURLConnection canHandleRequest:request]){
- [self gotoAddress:sender withRequestObj:request inTab:selectedTab];
+ [self gotoAddress:sender withRequestObj:request inTab:_selectedTab];
} else {
[self searchWeb:sender];
}
}
-(IBAction) didEndEditingAddressBar:(id)sender {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
}
-(IBAction) searchWeb:(id) sender {
- NSString *searchQuery = [addressBar text];
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ NSString *searchQuery = [_addressBar text];
NSString *encodedSearchQuery = (NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(
NULL,
(CFStringRef)searchQuery,
@@ -466,97 +567,125 @@ -(IBAction) searchWeb:(id) sender {
// Load the request in the UIWebView.
if ([self checkNetworkStatus]) {
- [self gotoAddress:sender withRequestObj:[NSURLRequest requestWithURL:[NSURL URLWithString:urlString]] inTab:selectedTab];
+ [self gotoAddress:sender withRequestObj:[NSURLRequest requestWithURL:[NSURL URLWithString:urlString]] inTab:_selectedTab];
} else {
[self cannotConnect:nil];
- [progressBar setHidden:YES];
+ [_progressBar setHidden:YES];
}
//Load the request in the UIWebView.
- [addressBar resignFirstResponder];
+ [_addressBar resignFirstResponder];
}
-(void) cannotConnect:(UIWebView *) cnWebView {
- [stopButton setHidden:NO];
- [refreshButton setHidden:YES];
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ [_stopButton setHidden:NO];
+ [_refreshButton setHidden:YES];
NSURL *ucUrl = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"unable_to_connect" ofType:@"html"] isDirectory:NO];
NSString *ucContentString = [NSString stringWithContentsOfURL:ucUrl encoding:NSUTF8StringEncoding error:nil];
[[self webView] loadHTMLString:ucContentString baseURL:nil];
}
-(IBAction) goBack:(id)sender {
-
- [selectedTab goBack];
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ [_selectedTab goBack];
self.reloadOnPageLoad = YES;
}
-(IBAction) goForward:(id)sender {
-
- [selectedTab goForward];
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ [_selectedTab goForward];
//[[self webView] stringByEvaluatingJavaScriptFromString:@"history.forward();"];
}
-(IBAction) cancel:(id)sender {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
//[self contractBar: sender];
}
-(IBAction) showBookmarks:(id)sender {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
[self showBookmarksView:sender];
}
-(void) showBookmarksView:(id)sender {
-
- [UIView transitionFromView:self.view
- toView:[bookmarksController view]
- duration:0.5
- options:(UIViewAnimationOptionTransitionCrossDissolve)
- completion:^(BOOL finished) {}];
-
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ [self dismissPopups];
+ [self.view bringSubviewToFront:self.bookmarksNavController.view];
+ self.bookmarksNavController.view.frame = CGRectMake(0, 0, self.bookmarksNavController.view.frame.size.width, [[UIScreen mainScreen] bounds].size.height);
+ //Reload all bC controllers on the navigation stack
+ for (BookmarksController* bC in self.bookmarksNavController.viewControllers)
+ {
+ if([bC isKindOfClass:[BookmarksController class]])
+ {
+ [bC loadBookmarks];
+ [bC setBrowserController:self];
+ [bC.tableView reloadData];
+ }
+ }
+ [UIView animateWithDuration:0.25 animations:^{
+ self.bookmarksNavController.view.alpha =1.0f;
+ }];
}
-(IBAction) stopLoading:(id)sender {
- [stopButton setHidden:true];
- [refreshButton setHidden:false];
- [progressBar setHidden:YES];
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ [_stopButton setHidden:YES];
+ [_refreshButton setHidden:NO];
+ [_progressBar setHidden:YES];
//[activityIndicator stopAnimating];
- if ([tabs count] > 0) {
- [[selectedTab webView] stopLoading];
+ if ([_tabs count] > 0) {
+ [[_selectedTab webView] stopLoading];
}
}
-(NSArray *) actionSheetButtons {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
// hide add bookmark for local html files
- if ([[[selectedTab webView] request].URL isFileURL]) {
- return [NSArray arrayWithObjects:@"Clear Cookies", @"Clear Cache", @"Import Bookmarks", nil];
+ NSURL *url = [[self webView].request URL];
+ if ([url isFileURL] || [[url absoluteString] isEqualToString:@"about:blank"]) {
+ return [NSArray arrayWithObjects:@"Clear Cookies", @"Clear Cache", nil];
} else {
- return [NSArray arrayWithObjects:@"Add Bookmark", @"Clear Cookies", @"Clear Cache", @"Import Bookmarks", nil];
+ return [NSArray arrayWithObjects:@"Add Bookmark", @"Clear Cookies", @"Clear Cache", nil];
}
}
-(IBAction)showActionSheet:(id)sender {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
// Hide popover for ipad
if ([self isPad] ) {
- if (padPopover.popoverVisible) {
- [padPopover dismissPopoverAnimated:YES];
+ if (_padPopover.popoverVisible) {
+ [_padPopover dismissPopoverAnimated:YES];
}
- if (popupQuery.visible || barItemPopoverPresenter == moreButton) {
- barItemPopoverPresenter = nil;
- [popupQuery dismissWithClickedButtonIndex:nil animated:YES];
+ if (_popupQuery.visible) {
+ _barItemPopoverPresenter = nil;
+ [_popupQuery dismissWithClickedButtonIndex:_popupQuery.cancelButtonIndex animated:YES];
} else {
[self generatePopupQuery];
- barItemPopoverPresenter = moreButton;
- [popupQuery showFromBarButtonItem:moreButton animated:YES];
+ _barItemPopoverPresenter = _moreButton;
+ [_popupQuery showFromBarButtonItem:_moreButton animated:YES];
}
} else {
[self generatePopupQuery];
- [popupQuery showInView:self.view];
+ [_popupQuery showInView:self.view];
}
}
-(void) generatePopupQuery {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
UIActionSheet *pQuery= [[UIActionSheet alloc] initWithTitle:nil
delegate:self
cancelButtonTitle:nil
@@ -568,12 +697,15 @@ -(void) generatePopupQuery {
pQuery.cancelButtonIndex = [pQuery addButtonWithTitle:@"Cancel"];
- self.popupQuery = pQuery;
+ _popupQuery = pQuery;
}
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
// skip add bookmarks if we are loading a local file
- if ([[[selectedTab webView] request].URL isFileURL]) {
+ NSURL *url = [[self webView].request URL];
+ if ([url isFileURL] || [[url absoluteString] isEqualToString:@"about:blank"]) {
buttonIndex += 1;
}
// Add Bookmark
@@ -597,57 +729,76 @@ -(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)
// Import Bookmarks
- else if (buttonIndex == 3) {
+ /*else if (buttonIndex == 3) {
[self addTab:actionSheet];
NSString *urlAddress = @"";
//[[self webView] loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"import_bookmark_howto" ofType:@"html"]isDirectory:NO]]];
NSString *path = [[NSBundle mainBundle] pathForResource:@"import_bookmark_howto" ofType:@"html"];
NSData *launchData = [NSData dataWithContentsOfFile:path];
[[self webView] loadData:launchData MIMEType:@"text/html" textEncodingName:@"utf-8" baseURL:nil];
- [addressBar setText:urlAddress];
- }
+ [_addressBar setText:urlAddress];
+ }*/
}
-(void) addBookmarkFromSheet:(UIActionSheet *) sheet {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
[sheet dismissWithClickedButtonIndex:0 animated:YES];
+
+ // Set up bookmark controllers
+ UINavigationController *bookmarksNavController = [self createBookmarksController:NO];
+ BookmarksFormController* bookmarksFormController = (BookmarksFormController*)[[bookmarksNavController viewControllers] objectAtIndex:1];
[bookmarksFormController setMode:'A'];
[[bookmarksFormController navigationItem] setHidesBackButton:YES animated:NO];
- [bookmarksController pushViewController:bookmarksFormController animated:NO];
+
if ([self isPad]) {
- if (padPopover == nil) {
+ if (_padPopover == nil) {
UIPopoverController *ppop = [[UIPopoverController alloc]
- initWithContentViewController:bookmarksController];
+ initWithContentViewController:bookmarksNavController];
self.padPopover = ppop;
} else {
- [self.padPopover setContentViewController:bookmarksController animated:YES];
+ [self.padPopover setContentViewController:bookmarksNavController animated:YES];
}
- [self.padPopover presentPopoverFromBarButtonItem: bookmarkButton
+ [self.padPopover presentPopoverFromBarButtonItem:_bookmarkButton
permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
} else {
- [UIView transitionFromView:self.view
- toView:[bookmarksController view]
- duration:0.5
- options:(UIViewAnimationOptionTransitionCrossDissolve)
- completion:^(BOOL finished) {}];
+ [self presentViewController:bookmarksNavController animated:YES completion:nil];
+ }
+}
+
+-(void) dismissPopups {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ if([self isPad])
+ {
+ [_popupQuery dismissWithClickedButtonIndex:_popupQuery.cancelButtonIndex animated:NO];
+ [_padPopover dismissPopoverAnimated:NO];
+ }
+ else
+ {
+ [self dismissViewControllerAnimated:YES completion:nil];
}
}
// TABS
-(IBAction) addTab:(id)sender {
- if (tabsView.hidden) {
- [self toggleTabsView:sender];
- }
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+// if (_tabsView.hidden) {
+// [self toggleTabsView:sender];
+// }
[self addTabWithAddress:@""];
}
-(void) addTabWithAddress:(NSString *)urlAddress {
-
- if ([tabs count] == 0) {
- tabs = [[NSMutableArray alloc] initWithCapacity:8];
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ if ([_tabs count] == 0) {
+ _tabs = [[NSMutableArray alloc] initWithCapacity:8];
}
// reset navbar
//[self contractBar:sender];
@@ -655,101 +806,143 @@ -(void) addTabWithAddress:(NSString *)urlAddress {
[self stopLoading:sender];
}*/
- Tab *nTab = [[Tab alloc] initWithFrame:CGRectMake((100.0 * [tabs count]) + 2.0, 2.0, 100.0, 34.0) addTarget: self];
+ Tab *rightMostTab = [_tabs lastObject];
+ CGFloat rightMostTabEdge = (rightMostTab) ? rightMostTab.frame.origin.x + rightMostTab.frame.size.width : 0;
+ CGFloat tabWidth = rightMostTab.frame.size.width;
+ CGFloat initialX = (rightMostTabEdge < DEVICE_SIZE.width) ? DEVICE_SIZE.width + tabWidth : rightMostTabEdge + tabWidth;
+ Tab *nTab = [[Tab alloc] initWithFrame:CGRectMake(initialX, 2.0, kTabWidth, 34.0)
+ addTarget: self];
- [self switchTabFrom:selectedTab ToTab:nTab];
- [tabsView addSubview:selectedTab];
+ [self switchTabFrom:_selectedTab ToTab:nTab];
+ [_tabsView addSubview:_selectedTab];
- [tabs addObject:selectedTab];
- [selectedTab select];
+ [_tabs addObject:_selectedTab];
+ [_selectedTab select];
+
+ [UIView animateWithDuration:0.35 animations:^{
+ CGRect newFrame = nTab.frame;
+ newFrame.origin.x = (kTabWidth * ([_tabs count] - 1)) + 2.0;
+ nTab.frame = newFrame;
+ } completion:^(BOOL finished) {
+ if (!finished) {
+ CGRect newFrame = nTab.frame;
+ newFrame.origin.x = (kTabWidth * ([_tabs count] - 1)) + 2.0;
+ nTab.frame = newFrame;
+ }
+ }];
//scrolling
- tabsView.contentSize = CGSizeMake(((100.0) * [tabs count]) + 5.0, 23.0);
- if (tabsView.frame.size.width < tabsView.contentSize.width) {
- tabsView.contentOffset = CGPointMake(tabsView.contentSize.width - tabsView.frame.size.width,0);
+ _tabsView.contentSize = CGSizeMake((kTabWidth * [_tabs count]) + 5.0, 23.0);
+ if (_tabsView.frame.size.width < _tabsView.contentSize.width) {
+ _tabsView.contentOffset = CGPointMake(_tabsView.contentSize.width - _tabsView.frame.size.width,0);
}
- tabsView.clipsToBounds = YES;
- tabsView.showsHorizontalScrollIndicator = NO;
+ _tabsView.clipsToBounds = YES;
+ _tabsView.showsHorizontalScrollIndicator = NO;
if ([urlAddress isEqualToString:@""]) {
NSString *path = [[NSBundle mainBundle] pathForResource:@"launch" ofType:@"html"];
NSData *launchData = [NSData dataWithContentsOfFile:path];
[[self webView] loadData:launchData MIMEType:@"text/html" textEncodingName:@"utf-8" baseURL:nil];
- if (![addressBar isFirstResponder]) {
- [addressBar setText:urlAddress];
+ if (![_addressBar isFirstResponder]) {
+ [_addressBar setText:urlAddress];
}
} else {
- [self gotoAddress:nil withRequestObj:[[NSURLRequest alloc] initWithURL:[NSURL URLWithString:urlAddress]] inTab:selectedTab];
+ [self gotoAddress:nil withRequestObj:[[NSURLRequest alloc] initWithURL:[NSURL URLWithString:urlAddress]] inTab:_selectedTab];
}
- [self loadTabs:[selectedTab webView]];
+ [self loadTabs:[_selectedTab webView]];
}
-(IBAction) removeTab:(id)sender {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
[sender setEnabled:NO];
Tab *toBeRemoved = (Tab *)[sender superview];
[[toBeRemoved tabButton] setEnabled:NO];
- BOOL removed = false;
- BOOL select = false;
-
- for (id cTab in tabs) {
- if (select) {
- [self switchTabFrom:selectedTab ToTab:cTab];
- select = false;
- }
- if (removed) {
- [cTab incrementOffset];
- }
- if ([cTab closeButton] == sender) {
- removed = YES;
- select = (selectedTab == cTab);
- }
+ [UIView animateWithDuration:0.20 animations:^{
+ CGRect newFrame = toBeRemoved.frame;
+ newFrame.origin.y += toBeRemoved.frame.size.height;
+ toBeRemoved.frame = newFrame;
+ } completion:^(BOOL finished) {
+ BOOL removed = NO;
+ BOOL select = NO;
- }
+ for (id cTab in _tabs) {
+ if (select) {
+ [self switchTabFrom:_selectedTab ToTab:cTab];
+ select = NO;
+ }
+ if (removed) {
+ if (!finished) {
+ [cTab incrementOffset];
+ } else {
+ [UIView animateWithDuration:0.20 animations:^{
+ [cTab incrementOffset];
+ } completion:nil];
+ }
+ }
+ if ([cTab closeButton] == sender) {
+ removed = YES;
+ select = (_selectedTab == cTab);
+ }
+
+ }
+
+ if (toBeRemoved == [_tabs lastObject] && [_tabs lastObject] != [NSNull null] && [_tabs count] > 1) {
+ [self switchTabFrom:_selectedTab ToTab:[_tabs objectAtIndex:[_tabs count]-2]];
+ } else if ([_tabs count] == 0) {
+ self.webView = nil; // why?
+ }
+ [toBeRemoved removeFromSuperview];
+ [[toBeRemoved webView] removeFromSuperview];
+ [_tabs removeObject:toBeRemoved];
+
+
+ if ([_tabs count] == 0) {
+ [self addTab:nil];
+ }
+ [self loadTabs:[_selectedTab webView]];
+
+ //scrolling
+ _tabsView.contentSize = CGSizeMake((kTabWidth * [_tabs count]) + 40.0, 23.0);
+ }];
- if (toBeRemoved == [tabs lastObject] && [tabs lastObject] != [NSNull null] && [tabs count] > 1) {
- [self switchTabFrom:selectedTab ToTab:[tabs objectAtIndex:[tabs count]-2]];
- } else if ([tabs count] == 0) {
- self.webView = nil;
- }
- [toBeRemoved removeFromSuperview];
- [[toBeRemoved webView] removeFromSuperview];
- [tabs removeObject: toBeRemoved];
-
-
- if ([tabs count] == 0) {
- [self addTab:nil];
- }
- [self loadTabs:[selectedTab webView]];
-
- //scrolling
- tabsView.contentSize = CGSizeMake(((100.0) * [tabs count]) + 40.0, 23.0);
}
-(IBAction) selectTab:(id)sender {
- for (id cTab in tabs) {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ for (id cTab in _tabs) {
if ([cTab tabButton] == sender) {
- [self switchTabFrom:selectedTab ToTab:cTab];
+ [self switchTabFrom:_selectedTab ToTab:cTab];
+ if ([_selectedTab isLoading]) {
+ [self displayAsLoading];
+ } else {
+ [self displayAsNotLoading];
+ }
+ [self registerForBrowserNotifications];
}
}
- [self loadTabs:[selectedTab webView]];
+ [self loadTabs:[_selectedTab webView]];
}
-(void) switchTabFrom:(Tab *)fromTab ToTab:(Tab *)toTab {
- if ([tabs count] > 0) {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ if ([_tabs count] > 0) {
[fromTab deselect];
}
[toTab select];
- selectedTab = toTab;
+ _selectedTab = toTab;
if (![toTab loading]) {
[[self progressBar] setHidden:YES];
[[self stopButton] setHidden:YES];
[[self refreshButton] setHidden:NO];
- [[self addressBar] setText:[selectedTab currentURLString]];
+ [[self addressBar] setText:[_selectedTab currentURLString]];
} else {
[[self progressBar] setHidden:NO];
[[self stopButton] setHidden:NO];
@@ -809,21 +1002,27 @@ -(void) switchTabFrom:(Tab *)fromTab ToTab:(Tab *)toTab {
// WEBVIEW
-(UIWebView *) webView {
- return [selectedTab webView];
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ return [_selectedTab webView];
}
-(UIWebView *) setWebView:(UIWebView *)newWebView {
- [selectedTab setWebView:newWebView];
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ [_selectedTab setWebView:newWebView];
return newWebView;
}
-(void) loadTabs:(UIWebView *)webView {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
Tab *tab = nil;
[[self view] sendSubviewToBack:webView];
- for (id cTab in tabs) {
+ for (id cTab in _tabs) {
if ([cTab webView] == webView) {
tab = cTab;
} else {
@@ -831,34 +1030,34 @@ -(void) loadTabs:(UIWebView *)webView {
}
}
- if (tab == selectedTab) {
+ if (tab == _selectedTab) {
if ([webView request] == nil || [[webView request].URL isFileURL]) {
- if (![addressBar isFirstResponder]) {
- [addressBar setText: @""];
+ if (![_addressBar isFirstResponder]) {
+ [_addressBar setText: @""];
}
} else {
NSString *addressText = tab.currentURLString;
if (![addressText isEqualToString:@"about:blank"] && [addressText rangeOfString:@"https://duckduckgo.com"].location == NSNotFound) {
- if (![addressBar isFirstResponder]) {
- [addressBar setText: addressText];
+ if (![_addressBar isFirstResponder]) {
+ [_addressBar setText:addressText];
}
- [refreshButton setHidden:[tab loading]];
+ [_refreshButton setHidden:[tab loading]];
}
}
- if([selectedTab canGoForward]) {
- forwardButton.enabled = TRUE;
+ if([_selectedTab canGoForward]) {
+ _forwardButton.enabled = TRUE;
}
- else if(![selectedTab canGoForward]) {
- forwardButton.enabled = FALSE;
+ else if(![_selectedTab canGoForward]) {
+ _forwardButton.enabled = FALSE;
}
- if([selectedTab canGoBack]) {
- backButton.enabled = TRUE;
+ if([_selectedTab canGoBack]) {
+ _backButton.enabled = TRUE;
}
- else if(![selectedTab canGoBack]) {
- backButton.enabled = FALSE;
+ else if(![_selectedTab canGoBack]) {
+ _backButton.enabled = FALSE;
}
}
@@ -870,6 +1069,8 @@ -(void) loadTabs:(UIWebView *)webView {
// Orientation
- (NSUInteger) supportedInterfaceOrientations {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
// Return a bitmask of supported orientations. If you need more,
// use bitwise or (see the commented return).
return UIInterfaceOrientationMaskAll;
@@ -877,23 +1078,29 @@ - (NSUInteger) supportedInterfaceOrientations {
}
- (UIInterfaceOrientation) preferredInterfaceOrientationForPresentation {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
// Return the orientation you'd prefer - this is what it launches to. The
// user can still rotate. You don't have to implement this method, in which
// case it launches in the current orientation
- return UIDeviceOrientationPortrait;
+ return UIInterfaceOrientationPortrait;
}
// Reachability
- (BOOL) checkNetworkStatus
{
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
Reachability *reachability = [Reachability reachabilityForInternetConnection];
- NetworkStatus *netstat = [reachability currentReachabilityStatus];
+ NetworkStatus netstat = [reachability currentReachabilityStatus];
return netstat != NotReachable;
}
// HARDWARE
- (BOOL) isPad {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
#ifdef UI_USER_INTERFACE_IDIOM
return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad);
#else
diff --git a/Browser/Logging/Logging.h b/Browser/Logging/Logging.h
new file mode 100755
index 0000000..8fb7793
--- /dev/null
+++ b/Browser/Logging/Logging.h
@@ -0,0 +1,163 @@
+/*
+ * Logging.h
+ *
+ * $Version: Logging 1.0 (1e09f90c5fec) on 2010-07-22 $
+ * Author: Bill Hollings
+ * Copyright (c) 2010 The Brenwill Workshop Ltd.
+ * http://www.brenwill.com
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * http://en.wikipedia.org/wiki/MIT_License
+ *
+ * Thanks to Nick Dalton for providing the underlying ideas for using variadic macros as
+ * well as for outputting the code location as part of the log entry. For his ideas, see:
+ * http://iphoneincubator.com/blog/debugging/the-evolution-of-a-replacement-for-nslog
+ */
+
+/**
+ * For Objective-C code, this library adds flexible, non-intrusive logging capabilities
+ * that can be efficiently enabled or disabled via compile switches.
+ *
+ * There are four levels of logging: Trace, Info, Error and Debug, and each can be enabled
+ * independently via the LOGGING_LEVEL_TRACE, LOGGING_LEVEL_INFO, LOGGING_LEVEL_ERROR and
+ * LOGGING_LEVEL_DEBUG switches, respectively.
+ *
+ * In addition, ALL logging can be enabled or disabled via the LOGGING_ENABLED switch.
+ *
+ * Logging functions are implemented here via macros. Disabling logging, either entirely, or
+ * at a specific level, completely removes the corresponding log invocations from the compiled
+ * code, thus eliminating both the memory and CPU overhead that the logging calls would add.
+ * You might choose, for example, to completely remove all logging from production release code,
+ * by setting LOGGING_ENABLED off in your production builds settings. Or, as another example,
+ * you might choose to include Error logging in your production builds by turning only
+ * LOGGING_ENABLED and LOGGING_LEVEL_ERROR on, and turning the others off.
+ *
+ * To perform logging, use any of the following function calls in your code:
+ *
+ * LogTrace(fmt, ...) - recommended for detailed tracing of program flow
+ * - will print if LOGGING_LEVEL_TRACE is set on.
+ *
+ * LogInfo(fmt, ...) - recommended for general, infrequent, information messages
+ * - will print if LOGGING_LEVEL_INFO is set on.
+ *
+ * LogError(fmt, ...) - recommended for use only when there is an error to be logged
+ * - will print if LOGGING_LEVEL_ERROR is set on.
+ *
+ * LogDebug(fmt, ...) - recommended for temporary use during debugging
+ * - will print if LOGGING_LEVEL_DEBUG is set on.
+ *
+ * In each case, the functions follow the general NSLog/printf template, where the first argument
+ * "fmt" is an NSString that optionally includes embedded Format Specifiers, and subsequent optional
+ * arguments indicate data to be formatted and inserted into the string. As with NSLog, the number
+ * of optional arguments must match the number of embedded Format Specifiers. For more info, see the
+ * core documentation for NSLog and String Format Specifiers.
+ *
+ * You can choose to have each logging entry automatically include class, method and line information
+ * by enabling the LOGGING_INCLUDE_CODE_LOCATION switch.
+ *
+ * Although you can directly edit this file to turn on or off the switches below, the preferred
+ * technique is to set these switches via the compiler build setting GCC_PREPROCESSOR_DEFINITIONS
+ * in your build configuration.
+ */
+
+/**
+ * Set this switch to enable or disable logging capabilities.
+ * This can be set either here or via the compiler build setting GCC_PREPROCESSOR_DEFINITIONS
+ * in your build configuration. Using the compiler build setting is preferred for this to
+ * ensure that logging is not accidentally left enabled by accident in release builds.
+ */
+#ifndef LOGGING_ENABLED
+# define LOGGING_ENABLED 1
+#endif
+
+/**
+ * Set any or all of these switches to enable or disable logging at specific levels.
+ * These can be set either here or as a compiler build settings.
+ * For these settings to be effective, LOGGING_ENABLED must also be defined and non-zero.
+ */
+#ifndef LOGGING_LEVEL_TRACE
+# define LOGGING_LEVEL_TRACE 1
+#endif
+#ifndef LOGGING_LEVEL_INFO
+# define LOGGING_LEVEL_INFO 1
+#endif
+#ifndef LOGGING_LEVEL_ERROR
+# define LOGGING_LEVEL_ERROR 1
+#endif
+#ifndef LOGGING_LEVEL_DEBUG
+# define LOGGING_LEVEL_DEBUG 1
+#endif
+
+/**
+ * Set this switch to indicate whether or not to include class, method and line information
+ * in the log entries. This can be set either here or as a compiler build setting.
+ */
+#ifndef LOGGING_INCLUDE_CODE_LOCATION
+ #define LOGGING_INCLUDE_CODE_LOCATION 0
+#endif
+
+// *********** END OF USER SETTINGS - Do not change anything below this line ***********
+
+
+#if !(defined(LOGGING_ENABLED) && LOGGING_ENABLED)
+ #undef LOGGING_LEVEL_TRACE
+ #undef LOGGING_LEVEL_INFO
+ #undef LOGGING_LEVEL_ERROR
+ #undef LOGGING_LEVEL_DEBUG
+#endif
+
+// Logging format
+#define LOG_FORMAT_NO_LOCATION(fmt, lvl, ...) NSLog((@"[%@] " fmt), lvl, ##__VA_ARGS__)
+#define LOG_FORMAT_WITH_LOCATION(fmt, lvl, ...) NSLog((@"%s[Line %d] [%@] " fmt), __PRETTY_FUNCTION__, __LINE__, lvl, ##__VA_ARGS__)
+
+#if defined(LOGGING_INCLUDE_CODE_LOCATION) && LOGGING_INCLUDE_CODE_LOCATION
+ #define LOG_FORMAT(fmt, lvl, ...) LOG_FORMAT_WITH_LOCATION(fmt, lvl, ##__VA_ARGS__)
+#else
+ #define LOG_FORMAT(fmt, lvl, ...) LOG_FORMAT_NO_LOCATION(fmt, lvl, ##__VA_ARGS__)
+#endif
+
+// Trace logging - for detailed tracing
+#if defined(LOGGING_LEVEL_TRACE) && LOGGING_LEVEL_TRACE
+ #define LogTrace(fmt, ...) LOG_FORMAT(fmt, @"trace", ##__VA_ARGS__)
+#else
+ #define LogTrace(...)
+#endif
+
+// Info logging - for general, non-performance affecting information messages
+#if defined(LOGGING_LEVEL_INFO) && LOGGING_LEVEL_INFO
+ #define LogInfo(fmt, ...) LOG_FORMAT(fmt, @"info", ##__VA_ARGS__)
+#else
+ #define LogInfo(...)
+#endif
+
+// Error logging - only when there is an error to be logged
+#if defined(LOGGING_LEVEL_ERROR) && LOGGING_LEVEL_ERROR
+ #define LogError(fmt, ...) LOG_FORMAT(fmt, @"***ERROR***", ##__VA_ARGS__)
+#else
+ #define LogError(...)
+ #endif
+
+// Debug logging - use only temporarily for highlighting and tracking down problems
+#if defined(LOGGING_LEVEL_DEBUG) && LOGGING_LEVEL_DEBUG
+ #define LogDebug(fmt, ...) LOG_FORMAT(fmt, @"DEBUG", ##__VA_ARGS__)
+#else
+ #define LogDebug(...)
+#endif
+
diff --git a/Browser/Tab.h b/Browser/Tab.h
index 385895a..a557a7d 100644
--- a/Browser/Tab.h
+++ b/Browser/Tab.h
@@ -8,41 +8,18 @@
#import
#import
+#define kTabWidth 100.0
+
@class BrowserViewController, FilterManager;
-@interface Tab : UIView {
- UIButton *tabButton;
- UILabel *tabTitle;
- UIWebView *webView;
- UIButton *closeButton;
-
- NSString *currentURLString;
- NSURL *currentURL;
- NSString *connectionURLString;
- NSURLConnection *urlConnection;
- NSHTTPURLResponse *response;
- NSMutableData *pageData;
-
- NSMutableArray *history;
- int traverse;
- int history_position;
-
- int scrollPosition;
-
- BOOL loading;
- BOOL current;
- BOOL actionSheetVisible;
-
- double loadStartTime;
- double loadEndTime;
- NSString *pageInfoJS;
-
- BrowserViewController *viewController;
-
-}
+@interface Tab : UIView
+
+@property (assign) NSUInteger loadingCount;
@property(nonatomic,strong) UIButton *tabButton;
-@property(nonatomic,strong) UILabel *tabTitle;
+@property (nonatomic, strong) UILabel *tabTitle;
+@property (nonatomic, strong) UIActivityIndicatorView *activityIndicator;
+@property (nonatomic, assign) CGRect tabTitleFrame;
@property(nonatomic,strong) UIWebView *webView;
@property(nonatomic,strong) UIButton *closeButton;
@@ -55,10 +32,11 @@
@property(nonatomic,strong) NSMutableArray *history;
@property(nonatomic,assign) int traverse;
-@property(nonatomic,assign) int history_position;
+@property(nonatomic,assign) NSInteger history_position;
@property(nonatomic,assign) int scrollPosition;
+@property(nonatomic,assign) BOOL isLoading;
@property(nonatomic,assign) BOOL loading;
@property(nonatomic,assign) BOOL current;
@property(nonatomic,assign) BOOL actionSheetVisible;
diff --git a/Browser/Tab.m b/Browser/Tab.m
index daff045..963f871 100644
--- a/Browser/Tab.m
+++ b/Browser/Tab.m
@@ -9,98 +9,181 @@
#import "BrowserViewController.h"
#import "BookmarksFormController.h"
#import "UIMainView.h"
+#import "Logging.h"
-@implementation Tab
+@interface Tab ()
+
+/**
+ Counter that increments when webViewDidStartLoad: is called and decrements
+ when webViewDidFinishLoad: is called.
+ */
+
+
+@end
-@synthesize tabButton, webView, closeButton, tabTitle, history, traverse, history_position, scrollPosition, currentURLString, currentURL, current, urlConnection, connectionURLString, actionSheetVisible, loadStartTime, loadEndTime, pageInfoJS, response, viewController, loading;
+@implementation Tab
-(id) initWithFrame:(CGRect)frame addTarget:(BrowserViewController *) vc {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
if ((self = [super initWithFrame:frame])) {
- viewController = vc;
+ _viewController = vc;
NSString *path = [[NSBundle mainBundle] pathForResource:@"page_info" ofType:@"js"];
- pageInfoJS = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
+ _pageInfoJS = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
// Create tab button
[self setTabButton:[UIButton buttonWithType:UIButtonTypeCustom]];
// Style tab button
- [[tabButton layer] setCornerRadius: 5.0f];
- [[tabButton layer] setMasksToBounds:YES];
- [[tabButton layer] setBorderWidth: 0.5f];
+ [[_tabButton layer] setCornerRadius: 5.0f];
+ [[_tabButton layer] setMasksToBounds:YES];
+ [[_tabButton layer] setBorderWidth: 0.5f];
- [tabButton setBackgroundColor:[UIColor grayColor]];
+ [_tabButton setBackgroundColor:[UIColor grayColor]];
- tabButton.titleLabel.font = [UIFont systemFontOfSize: 11];
- [tabButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
+ _tabButton.titleLabel.font = [UIFont systemFontOfSize:11];
+ [_tabButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
- tabButton.contentEdgeInsets = UIEdgeInsetsMake(0.0, 8.0, 0.0, 0.0);
- tabButton.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
- tabButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
+ _tabButton.contentEdgeInsets = UIEdgeInsetsMake(0.0, 8.0, 0.0, 0.0);
+ _tabButton.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
+ _tabButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
- tabButton.frame = CGRectMake(0.0, 0.0, 100.0, 26.0);
+ _tabButton.frame = CGRectMake(0.0, 0.0, kTabWidth, 26.0);
+
+ _activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
+ _activityIndicator.frame = CGRectMake(5, 2, 20, 20);
// Create close tab button
[self setCloseButton:[UIButton buttonWithType:UIButtonTypeCustom]];
- [closeButton setTitle:@"x" forState:UIControlStateNormal];
- [closeButton setAccessibilityLabel:@"close tab"];
- [closeButton setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
- closeButton.frame = CGRectMake(79.0, -1.0, 25.0, 25.0);
- closeButton.titleLabel.font = [UIFont systemFontOfSize: 18];
+ [_closeButton setTitle:@"x" forState:UIControlStateNormal];
+ [_closeButton setAccessibilityLabel:@"close tab"];
+ [_closeButton setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
+ _closeButton.frame = CGRectMake(kTabWidth - 21.0, -1.0, 25.0, 25.0);
+ _closeButton.titleLabel.font = [UIFont systemFontOfSize:18];
+ _tabTitleFrame = CGRectMake(5, 1, 80, 22);
+ _tabTitle = [[UILabel alloc] initWithFrame:_tabTitleFrame];
+ _tabTitle.font = [UIFont systemFontOfSize:11];
+ _tabTitle.text = @"New Tab";
+
// append views
- [self addSubview:tabButton];
- [self addSubview:closeButton];
+ [_tabButton addSubview:_tabTitle];
+ [self addSubview:_tabButton];
+ [self addSubview:_closeButton];
+ [self addSubview:_activityIndicator];
// Set up webview
- UIWebView *wvTemplate = (UIView *)[viewController webViewTemplate];
+ UIWebView *wvTemplate = (UIWebView *)[_viewController webViewTemplate];
int minWebViewSize = wvTemplate.frame.size.height;
- int maxWebViewSize = minWebViewSize + [viewController bottomBar].frame.size.height;
- int height = [viewController bottomBar].alpha > 0.0 ? minWebViewSize : maxWebViewSize;
+ int maxWebViewSize = minWebViewSize + [_viewController bottomBar].frame.size.height;
+ int height = [_viewController bottomBar].alpha > 0.0 ? minWebViewSize : maxWebViewSize;
CGRect frame = CGRectMake(wvTemplate.frame.origin.x, wvTemplate.frame.origin.y, wvTemplate.frame.size.width, height);
- webView = [[UIWebView alloc] initWithFrame:frame];
- webView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
- webView.scalesPageToFit = true;
- webView.scrollView.scrollEnabled = YES;
- webView.scrollView.bounces = YES;
- webView.backgroundColor = [UIColor whiteColor];
- [webView sizeToFit];
- [webView setDelegate:self];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(contextualMenuAction:) name:@"TapAndHoldNotification" object:nil];
+ _webView = [[UIWebView alloc] initWithFrame:frame];
+ _webView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
+ _webView.scalesPageToFit = true;
+ _webView.scrollView.scrollEnabled = YES;
+ _webView.scrollView.bounces = YES;
+ _webView.backgroundColor = [UIColor whiteColor];
+ [_webView sizeToFit];
+ [_webView setDelegate:self];
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(contextualMenuAction:)
+ name:@"TapAndHoldNotification"
+ object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(startedLoadingNotification:)
+ name:kStartedLoadingNotification
+ object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(finishedLoadingNotification:)
+ name:kFinishedLoadingNotification
+ object:nil];
// Scroll topbar
- [[webView scrollView] setDelegate:viewController];
- [[webView scrollView] setContentInset:UIEdgeInsetsMake([viewController topBar].frame.size.height, 0, 0, 0)];
- [[webView scrollView] setContentOffset:CGPointMake(0, - [viewController topBar].frame.size.height)];
+ [[_webView scrollView] setDelegate:_viewController];
+ [[_webView scrollView] setContentInset:UIEdgeInsetsMake([_viewController topBar].frame.size.height, 0, 0, 0)];
+ [[_webView scrollView] setContentOffset:CGPointMake(0, - [_viewController topBar].frame.size.height)];
- [[viewController view] addSubview:webView];
- [[viewController view] sendSubviewToBack:webView];
- [[viewController view] sendSubviewToBack:[viewController webViewTemplate]];
+ [[_viewController view] addSubview:_webView];
+ [[_viewController view] sendSubviewToBack:_webView];
+ [[_viewController view] sendSubviewToBack:[_viewController webViewTemplate]];
// Set up interactions
- [tabButton addTarget:viewController
- action:@selector(selectTab:)
- forControlEvents:UIControlEventTouchDown];
- [closeButton addTarget:viewController
- action:@selector(removeTab:)
- forControlEvents:UIControlEventTouchDown];
+ [_tabButton addTarget:_viewController
+ action:@selector(selectTab:)
+ forControlEvents:UIControlEventTouchDown];
+ [_closeButton addTarget:_viewController
+ action:@selector(removeTab:)
+ forControlEvents:UIControlEventTouchDown];
//Set history
[self setHistory:[[NSMutableArray alloc] initWithCapacity:0]];
- traverse = 0;
- history_position = 0;
+ _traverse = 0;
+ _history_position = 0;
+ _loadingCount = 0;
//Set title
- [tabButton setTitle:@"New Tab" forState:UIControlStateNormal];
- [tabButton setTitle:@"New Tab" forState:UIControlStateHighlighted];
+// [_tabButton setTitle:@"New Tab" forState:UIControlStateNormal];
+// [_tabButton setTitle:@"New Tab" forState:UIControlStateHighlighted];
}
return self;
}
+- (void)startedLoadingNotification:(NSNotification *)notification {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+
+}
+
+- (void)finishedLoadingNotification:(NSNotification *)notification {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+
+}
+
+- (void)incrementLoadingCount {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ BOOL startedAtZero = NO;
+ if (_loadingCount == 0) {
+ startedAtZero = YES;
+ }
+ _loadingCount++;
+ if (startedAtZero) {
+ CGRect newTabButtonFrame = _tabTitle.frame;
+ CGFloat offset = _activityIndicator.frame.size.width + 5;
+ LogDebug(@"offset: %f", offset);
+ newTabButtonFrame.origin.x += offset;
+ newTabButtonFrame.size.width -= offset;
+ _tabTitle.frame = newTabButtonFrame;
+ [_activityIndicator startAnimating];
+ }
+}
+
+- (void)decrementLoadingCount {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ if (_loadingCount > 0) {
+ _loadingCount--;
+ }
+ if (_loadingCount == 0) {
+ [_activityIndicator stopAnimating];
+// CGRect newTabButtonFrame = _tabTitle.frame;
+// CGFloat offset = _activityIndicator.frame.size.width + 5;
+// LogDebug(@"offset: %f", offset);
+// newTabButtonFrame.origin.x -= offset;
+// newTabButtonFrame.size.width += offset;
+ _tabTitle.frame = _tabTitleFrame;
+ }
+}
+
-(void) setTitle:(NSString *)title {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
if ([title length] > 11) {
title = [[title substringToIndex:11] stringByAppendingString:@".."];
}
@@ -112,33 +195,43 @@ -(void) setTitle:(NSString *)title {
}
-(void) select {
- current = YES;
- [tabButton setBackgroundColor:[UIColor whiteColor]];
- tabButton.selected = YES;
- tabButton.enabled = NO;
- [webView.superview bringSubviewToFront:webView];
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ _current = YES;
+ [_tabButton setBackgroundColor:[UIColor whiteColor]];
+ _tabButton.selected = YES;
+ _tabButton.enabled = NO;
+ [_webView.superview bringSubviewToFront:_webView];
[self.superview bringSubviewToFront:self];
}
-(void) deselect {
- current = NO;
- [tabButton setBackgroundColor:[UIColor lightGrayColor]];
- tabButton.selected = NO;
- tabButton.enabled = YES;
- [webView.superview sendSubviewToBack:webView];
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ _current = NO;
+ [_tabButton setBackgroundColor:[UIColor lightGrayColor]];
+ _tabButton.selected = NO;
+ _tabButton.enabled = YES;
+ [_webView.superview sendSubviewToBack:_webView];
[self.superview sendSubviewToBack:self];
}
-(void) incrementOffset {
- self.frame = CGRectOffset(self.frame, -100.0, 0.0);
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ self.frame = CGRectOffset(self.frame, -kTabWidth, 0.0);
}
-(void) hideText {
- [tabButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ [_tabButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
}
-(void) showText {
- [tabButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ [_tabButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
}
// CONNECTION
@@ -146,6 +239,8 @@ -(void) showText {
#pragma mark urlConnection delegate
- (NSURLRequest *)connection:(NSURLConnection *)connection willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
self.loading =YES;
self.urlConnection = connection;
self.connectionURLString = [[[connection currentRequest] URL] absoluteString];
@@ -166,18 +261,22 @@ - (NSURLRequest *)connection:(NSURLConnection *)connection willSendRequest:(NSUR
- (void)connection: (NSURLConnection*) connection didReceiveResponse: (NSHTTPURLResponse*) response
{
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
self.currentURL = [response URL];
self.currentURLString = [[response URL] absoluteString];
[self setResponse:response];
- if (current) {
+ if (_current) {
[[self progressBar] setProgress:0.25 animated:NO];
}
- pageData = [[NSMutableData alloc] initWithLength:0];
+ _pageData = [[NSMutableData alloc] initWithLength:0];
}
- (void) connection: (NSURLConnection*) connection didReceiveData: (NSData*) data
{
- [pageData appendData: data];
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ [_pageData appendData: data];
if ([[self progressBar] progress] < 0.75) {
[[self progressBar] setProgress:[[self progressBar] progress] + .05 animated:NO];
}
@@ -185,61 +284,76 @@ - (void) connection: (NSURLConnection*) connection didReceiveData: (NSData*) dat
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
- NSURLRequest *request = [connection originalRequest];
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+// NSURLRequest *request = [connection originalRequest];/
- if ([pageData length] == 0) {
+ if ([_pageData length] == 0) {
[[self history] removeLastObject];
self.currentURL = [[[self history] lastObject] URL];
self.currentURLString = [[[[self history] lastObject] URL] absoluteString];
- if (current && ![currentURLString isEqualToString:@"about:blank"] && [currentURLString rangeOfString:@"https://duckduckgo.com"].location == NSNotFound) {
- [[viewController addressBar] setText:self.currentURLString];
+ if (_current && ![_currentURLString isEqualToString:@"about:blank"] &&
+ [_currentURLString rangeOfString:@"https://duckduckgo.com"].location == NSNotFound)
+ {
+ [[_viewController addressBar] setText:self.currentURLString];
}
[[self progressBar] setHidden:YES];
return;
}
- if ([[response MIMEType] isEqualToString:@"text/html"] || [[response MIMEType] isEqualToString:@"application/xhtml+xml"] || [[response MIMEType] isEqualToString:@"text/vnd.wap.wml"]) {
- NSStringEncoding *enc;
- if ([response textEncodingName] != nil) {
- enc = CFStringConvertEncodingToNSStringEncoding(CFStringConvertIANACharSetNameToEncoding((CFStringRef)[response textEncodingName]));
- } else {
- enc = NSUTF8StringEncoding;
+ if ([[_response MIMEType] isEqualToString:@"text/html"] ||
+ [[_response MIMEType] isEqualToString:@"application/xhtml+xml"] ||
+ [[_response MIMEType] isEqualToString:@"text/vnd.wap.wml"])
+ {
+ NSStringEncoding enc = NSUTF8StringEncoding;
+ if ([_response textEncodingName] != nil) {
+ enc = CFStringConvertEncodingToNSStringEncoding(CFStringConvertIANACharSetNameToEncoding((CFStringRef)[_response textEncodingName]));
}
- NSString *page = (NSString *)[[NSString alloc] initWithData:pageData encoding:enc];
+ NSString *page = (NSString *)[[NSString alloc] initWithData:_pageData encoding:enc];
[[self webView] stopLoading];
[[self webView] loadHTMLString:page baseURL:self.currentURL];
} else {
[[self webView] stopLoading];
- [[self webView] loadData:pageData MIMEType:[response MIMEType] textEncodingName:[response textEncodingName] baseURL:self.currentURL];
+ [[self webView] loadData:_pageData MIMEType:[_response MIMEType] textEncodingName:[_response textEncodingName] baseURL:self.currentURL];
//[whiteView setHidden:YES];
}
[[self progressBar] setProgress:0.75 animated:NO];
- pageData = nil;
+ _pageData = nil;
}
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
[[self progressBar] setHidden:YES];
if ([[connection currentRequest] URL] != NULL) {
- [viewController cannotConnect:webView];
+ [_viewController cannotConnect:_webView];
} else {
- NSString *urlAddress = @"";
[[self webView] loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"launch" ofType:@"html"]isDirectory:NO]]];
- [[viewController addressBar] setText:@""];
+ [[_viewController addressBar] setText:@""];
}
}
--(UIProgressView *) progressBar {
- return current ? [viewController progressBar] : nil;
+- (UIProgressView *)progressBar {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ return _current ? [_viewController progressBar] : nil;
+}
+
+- (void)loadingBegan {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+
}
#pragma mark -
#pragma mark webview delegate
-(BOOL) webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
if (request == nil) {
return NO;
@@ -258,10 +372,10 @@ -(BOOL) webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)re
return YES;
}
if ([[URL scheme] isEqualToString:@"http"] || [[URL scheme] isEqualToString:@"https"]) {
- if (current) {
- [[viewController addressBar] setText:[URL absoluteString]];
+ if (_current) {
+ [[_viewController addressBar] setText:[URL absoluteString]];
}
- [viewController gotoAddress:nil withRequestObj:request inTab:self];
+ [_viewController gotoAddress:nil withRequestObj:request inTab:self];
}
return NO;
}
@@ -270,30 +384,50 @@ -(BOOL) webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)re
}
-(void) webViewDidStartLoad:(UIWebView *)webView {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ if (_loadingCount == 0) {
+ _isLoading = YES;
+ [[NSNotificationCenter defaultCenter] postNotificationName:kStartedLoadingNotification object:self];
+ }
+ [self incrementLoadingCount];
+ LogDebug(@"loading count: %lu", (unsigned long)_loadingCount);
}
-(void) webViewDidFinishFinalLoad:(UIWebView *)webView {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+// _loadingCount--;
+// LogDebug(@"loading count: %lu", (unsigned long)_loadingCount);
self.loading = NO;
- if (current) {
- [viewController currentWebViewDidFinishFinalLoad:webView];
+ if (_current) {
+ [_viewController currentWebViewDidFinishFinalLoad:webView];
}
NSLog(@"Loaded url: %@", [webView.request mainDocumentURL]);
// set title
NSString *tabTitle = [webView stringByEvaluatingJavaScriptFromString:@"document.title"];
- NSString *url = [webView stringByEvaluatingJavaScriptFromString:@"window.location.href"];
+// NSString *url = [webView stringByEvaluatingJavaScriptFromString:@"window.location.href"];
if ([tabTitle length] == 0) {
- [self setTitle:@"Untitled"];
+ _tabTitle.text = @"New Tab";
+// [self setTitle:@"Untitled"];
} else {
- [self setTitle:tabTitle];
+// [self setTitle:tabTitle];
+ _tabTitle.text = tabTitle;
}
}
-(void) webViewDidFinishLoad:(UIWebView *)webView {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
-
- if (![[[webView request] URL] isFileURL] && currentURL != nil) {
+ [self decrementLoadingCount];
+ LogDebug(@"loading count: %lu", (unsigned long)_loadingCount);
+ if (_loadingCount == 0) {
+ _isLoading = NO;
+ [[NSNotificationCenter defaultCenter] postNotificationName:kFinishedLoadingNotification object:self];
+ }
+ if (![[[webView request] URL] isFileURL] && _currentURL != nil) {
[webView stringByEvaluatingJavaScriptFromString:@"if (document.getElementById('gh-page-loaded') == null && document.documentElement.innerHTML != '') {"
"var iframe = document.createElement('IFRAME');"
"iframe.setAttribute('id','gh-page-loaded');"
@@ -305,9 +439,28 @@ -(void) webViewDidFinishLoad:(UIWebView *)webView {
}
}
+- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ LogDebug(@"error: %@", error);
+
+ BOOL wasLoadingBeforeDecrement = NO;
+ if (_loadingCount > 0) {
+ wasLoadingBeforeDecrement = YES;
+ }
+ [self decrementLoadingCount];
+ if (wasLoadingBeforeDecrement && _loadingCount == 0) {
+ _isLoading = NO;
+ [[NSNotificationCenter defaultCenter] postNotificationName:kFinishedLoadingNotification object:self];
+ }
+ LogDebug(@"loading count: %lu", (unsigned long)_loadingCount);
+}
+
- (void)contextualMenuAction:(NSNotification*)notification
{
- if (actionSheetVisible || webView != [viewController webView]) {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ if (_actionSheetVisible || _webView != [_viewController webView] || !(_viewController.isViewLoaded && _viewController.view.window)) {
return;
}
CGPoint pt;
@@ -316,11 +469,11 @@ - (void)contextualMenuAction:(NSNotification*)notification
pt.y = [[coord objectForKey:@"y"] floatValue];
// convert point from window to view coordinate system
- pt = [webView convertPoint:pt fromView:nil];
+ pt = [_webView convertPoint:pt fromView:nil];
// convert point from view to HTML coordinate system
- CGPoint offset = [self scrollOffset];
- CGSize viewSize = [webView frame].size;
+// CGPoint offset = [self scrollOffset];
+ CGSize viewSize = [_webView frame].size;
CGSize windowSize = [self windowSize];
CGFloat f = windowSize.width / viewSize.width;
@@ -332,21 +485,23 @@ - (void)contextualMenuAction:(NSNotification*)notification
- (void)openContextualMenuAt:(CGPoint)pt
{
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
// Load the JavaScript code from the Resources and inject it into the web page
NSString *path = [[NSBundle mainBundle] pathForResource:@"JSTools" ofType:@"js"];
NSString *jsCode = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
- [webView stringByEvaluatingJavaScriptFromString: jsCode];
+ [_webView stringByEvaluatingJavaScriptFromString:jsCode];
NSInteger topOffset;
- if ([viewController isPad]) {
- topOffset = ((NSInteger)[viewController topBar].frame.size.height) +
- ((NSInteger)[(UIMainView *)[viewController view] statusBarView].frame.size.height);
+ if ([_viewController isPad]) {
+ topOffset = ((NSInteger)[_viewController topBar].frame.size.height) +
+ ((NSInteger)[(UIMainView *)[_viewController view] statusBarView].frame.size.height);
} else {
- topOffset = ((NSInteger)[(UIMainView *)[viewController view] statusBarView].frame.size.height);
+ topOffset = ((NSInteger)[(UIMainView *)[_viewController view] statusBarView].frame.size.height);
}
// get the Tags at the touch location
- NSArray *r = [[webView stringByEvaluatingJavaScriptFromString:
+ NSArray *r = [[_webView stringByEvaluatingJavaScriptFromString:
[NSString stringWithFormat:@"MyAppGetHTMLElementsAtPoint(%i,%i);",(NSInteger)pt.x,(NSInteger)pt.y - topOffset]] componentsSeparatedByString:@"|"];
NSString *tags = [r objectAtIndex:0];
@@ -357,10 +512,11 @@ - (void)openContextualMenuAt:(CGPoint)pt
return;
}
UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:[url isEqualToString:@""] ? @"Menu" : url
- delegate:self cancelButtonTitle:@"Cancel"
- destructiveButtonTitle:nil otherButtonTitles:nil];
-
-
+ delegate:self
+ cancelButtonTitle:nil
+ destructiveButtonTitle:nil
+ otherButtonTitles:nil];
+
// If a link was touched, add link-related buttons
if ([tags rangeOfString:@",A,"].location != NSNotFound) {
[sheet addButtonWithTitle:@"Open Link"];
@@ -375,32 +531,46 @@ - (void)openContextualMenuAt:(CGPoint)pt
[sheet addButtonWithTitle:@"Save Page as Bookmark"];
[sheet addButtonWithTitle:@"Open Page in Safari"];
- [sheet showInView:webView];
+ if ([_viewController isPad]) {
+ sheet.cancelButtonIndex = -1;
+ } else {
+ sheet.cancelButtonIndex = [sheet addButtonWithTitle:@"Cancel"];
+ }
+
+ [sheet showInView:_webView];
}
- (CGSize)windowSize
{
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
CGSize size;
- size.width = [[webView stringByEvaluatingJavaScriptFromString:@"window.innerWidth"] integerValue];
- size.height = [[webView stringByEvaluatingJavaScriptFromString:@"window.innerHeight"] integerValue];
+ size.width = [[_webView stringByEvaluatingJavaScriptFromString:@"window.innerWidth"] integerValue];
+ size.height = [[_webView stringByEvaluatingJavaScriptFromString:@"window.innerHeight"] integerValue];
return size;
}
- (CGPoint)scrollOffset
{
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
CGPoint pt;
- pt.x = [[webView stringByEvaluatingJavaScriptFromString:@"window.pageXOffset"] integerValue];
- pt.y = [[webView stringByEvaluatingJavaScriptFromString:@"window.pageYOffset"] integerValue];
+ pt.x = [[_webView stringByEvaluatingJavaScriptFromString:@"window.pageXOffset"] integerValue];
+ pt.y = [[_webView stringByEvaluatingJavaScriptFromString:@"window.pageYOffset"] integerValue];
return pt;
}
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+ if (buttonIndex == -1) {
+ return;
+ }
NSURL *url = [NSURL URLWithString:[actionSheet title]];
NSString *clickedButton = [actionSheet buttonTitleAtIndex:buttonIndex];
if ([clickedButton isEqualToString:@"Open Link"]) {
- [viewController gotoAddress:nil withRequestObj:[[NSURLRequest alloc] initWithURL:url] inTab:self];
+ [_viewController gotoAddress:nil withRequestObj:[[NSURLRequest alloc] initWithURL:url] inTab:self];
} else if ([clickedButton isEqualToString:@"Open Link in New Tab"]) {
- [viewController addTabWithAddress:[actionSheet title]];
+ [_viewController addTabWithAddress:[actionSheet title]];
} else if ([clickedButton isEqualToString:@"Copy Link"]) {
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
pasteboard.string = [url absoluteString];
@@ -409,8 +579,8 @@ - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger
UIImage *imageToBeSaved = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:url]];
UIImageWriteToSavedPhotosAlbum(imageToBeSaved, nil, nil, nil);
} else if ([clickedButton isEqualToString:@"Save Page as Bookmark"]) {
- [[viewController bookmarksFormController] setDefaultUrlFieldText:[url absoluteString]];
- [viewController addBookmarkFromSheet:actionSheet];
+ [[_viewController bookmarksFormController] setDefaultUrlFieldText:[url absoluteString]];
+ [_viewController addBookmarkFromSheet:actionSheet];
[actionSheet resignFirstResponder];
} else if ([clickedButton isEqualToString:@"Open Page in Safari"]) {
[actionSheet dismissWithClickedButtonIndex:buttonIndex animated:YES];
@@ -419,60 +589,82 @@ - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger
}
- (void)didPresentActionSheet:(UIActionSheet *)actionSheet {
- actionSheetVisible = YES;
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ _actionSheetVisible = YES;
}
- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex {
- actionSheetVisible = NO;
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ _actionSheetVisible = NO;
}
// HISTORY
-(BOOL) canGoBack {
- return history.count > 0 && history_position > 0;
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ return _history.count > 0 && _history_position > 0;
}
-(BOOL) canGoForward {
- return history.count > 0 && history_position < history.count - 1;
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ return _history.count > 0 && _history_position < _history.count - 1;
}
-(void) goBack {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
[self go:-1];
}
-(void) goForward {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
[self go:1];
}
-(void) go:(int)t {
- NSArray *req;
- [viewController forwardButton].enabled = FALSE;
- [viewController backButton].enabled = FALSE;
- traverse = t;
- history_position += traverse;
- if (history_position >= [history count] || history_position < 0) {
- req = [history lastObject];
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ NSURLRequest *req;
+ [_viewController forwardButton].enabled = FALSE;
+ [_viewController backButton].enabled = FALSE;
+ _traverse = t;
+ _history_position += _traverse;
+ if (_history_position >= [_history count] || _history_position < 0) {
+ req = [_history lastObject];
}
- req = [history objectAtIndex:history_position];
+ req = [_history objectAtIndex:_history_position];
//[[viewController addressBar] setText:[[req URL] absoluteString]];
if (req != nil) {
- [viewController gotoAddress:nil withRequestObj:req inTab:self];
+ [_viewController gotoAddress:nil withRequestObj:req inTab:self];
}
}
-(void) updateHistory {
- if (traverse == 0) {
- if (history_position + 1 < history.count) {
- [history removeObjectsInRange:NSMakeRange(history_position + 1, history.count - history_position - 1)];
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ if (_traverse == 0) {
+ if (_history_position + 1 < _history.count) {
+ [_history removeObjectsInRange:NSMakeRange(_history_position + 1, _history.count - _history_position - 1)];
}
NSURLRequest *req = [[[self urlConnection] currentRequest] mutableCopy];
- [history addObject:req];
- history_position = history.count - 1;
+ [_history addObject:req];
+ _history_position = _history.count - 1;
}
- traverse = 0;
+ _traverse = 0;
+}
+
+- (void)dealloc {
+ LogTrace(@"%s", __PRETTY_FUNCTION__);
+
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
}
diff --git a/Browser/UIMainView.h b/Browser/UIMainView.h
index 4034745..a64fde5 100644
--- a/Browser/UIMainView.h
+++ b/Browser/UIMainView.h
@@ -8,14 +8,10 @@
#import
@class BrowserViewController;
-@interface UIMainView : UIView {
- IBOutlet UIView *statusBarView;
- IBOutlet BrowserViewController *controller;
- IBOutlet NSLayoutConstraint *statusViewHeightConstraint;
-}
+@interface UIMainView : UIView
-@property(nonatomic,strong) UIView *statusBarView;
-@property(nonatomic,strong) BrowserViewController *controller;
+@property(nonatomic, strong) IBOutlet UIView *statusBarView;
+@property(nonatomic, strong) IBOutlet BrowserViewController *controller;
@property(nonatomic, strong) IBOutlet NSLayoutConstraint *statusViewHeightConstraint;
- (void) sizeStatusBar;
diff --git a/Browser/UIMainView.m b/Browser/UIMainView.m
index 0ff7f1d..86dc400 100644
--- a/Browser/UIMainView.m
+++ b/Browser/UIMainView.m
@@ -10,8 +10,6 @@
@implementation UIMainView
-@synthesize statusBarView, statusViewHeightConstraint, controller;
-
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
@@ -29,8 +27,8 @@ - (void) sizeStatusBar {
- (UIView*)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
if ([event type]==UIEventTypeTouches) {
UIView *v=[super hitTest:point withEvent:event];
- if (statusBarView==v) {
- [controller scrollToTop:self];
+ if (_statusBarView==v) {
+ [_controller scrollToTop:self];
} else {
return v;
}
diff --git a/README.md b/README.md
index 7476a94..842d846 100644
--- a/README.md
+++ b/README.md
@@ -26,25 +26,19 @@ Since libxml is not a framework but rather a dylib you will also have to add it
The recommended way to integrate the browser code is to make your view controller a subclass of the browser controller. Which should look something like this:
+ #import // only necessary if using banshee cocoapod
+
@interface ViewController : BrowserViewController
### AppDelegate
-Your app delegate needs to inherit from the browser delegate as so:
- #import "BrowserDelegate.h"
-
- @interface AppDelegate : BrowserDelegate
-
-The browser code does reference the app delegate, so you must have an AppDelegate Task. In the app delegate you should place this code in your `didFinishLaunchingWithOptions`:
-
- self.viewController = [[BrowserViewController alloc] init];
-
-## Misc
+In the app delegate you should place this code in your `didFinishLaunchingWithOptions`:
- There is a `customButton` UIBarButtonitem which you can customize programmatically in your view controller. This button appears in the bottom toolbar on the right. You can also overwrite the click handler method `-(IBAction) customButtonClick:(id)sender`.
+ self.window = [[BrowserMainWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
+ [self.window setRootViewController:[[ViewController alloc] init]];
- There are now 2 custom buttons.
+Note: These instructions only work if you create an empty project file. If you create a different type of project like a "single page" app, you will have to use a different approach since story board files are pulled in via plist file.
## License
diff --git a/banshee.podspec b/banshee.podspec
index 21a0825..82d4ae7 100644
--- a/banshee.podspec
+++ b/banshee.podspec
@@ -1,19 +1,19 @@
Pod::Spec.new do |s|
s.name = "banshee"
- s.version = "0.1.2"
+ s.version = "0.1.17"
s.summary = "An iOS browser built on top of UIWebView."
- s.homepage = "https://github.com/ghostery/banshee"
+ s.homepage = "https://github.com/acatighera/banshee"
s.screenshots = "https://d1k68i4h6ifyxa.cloudfront.net/screens/banshee_screen1.png"
s.license = 'MIT'
s.author = { "Alex Catighera" => "acatighera@gmail.com" }
- s.source = { :git => "https://github.com/ghostery/banshee.git", :tag => s.version.to_s }
+ s.source = { :git => "https://github.com/acatighera/banshee.git", :tag => s.version.to_s }
s.social_media_url = 'https://twitter.com/acatighera'
- s.platform = :ios, '7.0'
+ s.platform = :ios, '7.0'
s.requires_arc = true
- s.source_files = 'Browser/*.{h,m,c}'
- s.resources = 'Browser Resources/*'
+ s.source_files = [ 'Browser/*.{h,m,c}', 'Browser/*/*.{h,m.c}' ]
+ s.resources = [ 'Browser Resources/*', 'Browser Resources/**/*' ]
s.frameworks = [ 'CoreData', 'SystemConfiguration' ]
s.xcconfig = { 'HEADER_SEARCH_PATHS' => '$(SDKROOT)/usr/include/libxml2' }
diff --git a/sample-app/TestBrowser.xcodeproj/project.pbxproj b/sample-app/TestBrowser.xcodeproj/project.pbxproj
index 7be6630..0d8a9d5 100644
--- a/sample-app/TestBrowser.xcodeproj/project.pbxproj
+++ b/sample-app/TestBrowser.xcodeproj/project.pbxproj
@@ -7,22 +7,27 @@
objects = {
/* Begin PBXBuildFile section */
- 71ED23B819447163002ACD24 /* BrowserDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 71ED23B5194470B2002ACD24 /* BrowserDelegate.m */; };
B572E55718D08D2A005E4834 /* Tab.m in Sources */ = {isa = PBXBuildFile; fileRef = B572E54718D08D2A005E4834 /* Tab.m */; };
B572E55818D08D2A005E4834 /* BookmarksController.m in Sources */ = {isa = PBXBuildFile; fileRef = B572E54818D08D2A005E4834 /* BookmarksController.m */; };
B572E55918D08D2A005E4834 /* BookmarksFormController.m in Sources */ = {isa = PBXBuildFile; fileRef = B572E54A18D08D2A005E4834 /* BookmarksFormController.m */; };
B572E55A18D08D2A005E4834 /* BrowserViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B572E54C18D08D2A005E4834 /* BrowserViewController.m */; };
B572E55B18D08D2A005E4834 /* UIMainView.m in Sources */ = {isa = PBXBuildFile; fileRef = B572E54F18D08D2A005E4834 /* UIMainView.m */; };
B572E55C18D08D2A005E4834 /* BookmarkFolderFormController.m in Sources */ = {isa = PBXBuildFile; fileRef = B572E55118D08D2A005E4834 /* BookmarkFolderFormController.m */; };
- B572E55D18D08D2A005E4834 /* BookmarkImporter.m in Sources */ = {isa = PBXBuildFile; fileRef = B572E55318D08D2A005E4834 /* BookmarkImporter.m */; };
B572E55E18D08D2A005E4834 /* BookmarkItem.m in Sources */ = {isa = PBXBuildFile; fileRef = B572E55518D08D2A005E4834 /* BookmarkItem.m */; };
B5A210C218D091F700D65141 /* Reachability.m in Sources */ = {isa = PBXBuildFile; fileRef = B5A210C118D091F700D65141 /* Reachability.m */; };
+ B5E88BDA19A68C5D0021ED10 /* BrowserMainWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = B5E88BD919A68C5D0021ED10 /* BrowserMainWindow.m */; };
+ B5E88C1F19A697490021ED10 /* JSTools.js in Sources */ = {isa = PBXBuildFile; fileRef = FAF75EE118A17BFD007B317D /* JSTools.js */; };
+ B5E88C2019A698DF0021ED10 /* JSTools.js in Resources */ = {isa = PBXBuildFile; fileRef = FAF75EE118A17BFD007B317D /* JSTools.js */; };
+ FA157C3019941ACB0002C146 /* bookmarks.strings in Resources */ = {isa = PBXBuildFile; fileRef = FA157C2F19941ACB0002C146 /* bookmarks.strings */; };
+ FA3CD2AD1993D98800B3ACF0 /* right.png in Resources */ = {isa = PBXBuildFile; fileRef = FA3CD2AB1993D98800B3ACF0 /* right.png */; };
+ FA3CD2AE1993D98800B3ACF0 /* left.png in Resources */ = {isa = PBXBuildFile; fileRef = FA3CD2AC1993D98800B3ACF0 /* left.png */; };
FAA4557418A19A2E00B1BDF4 /* gsearch.png in Resources */ = {isa = PBXBuildFile; fileRef = FAA4557118A19A2E00B1BDF4 /* gsearch.png */; };
FAA4557518A19A2E00B1BDF4 /* magglass.png in Resources */ = {isa = PBXBuildFile; fileRef = FAA4557218A19A2E00B1BDF4 /* magglass.png */; };
FAA4557618A19A2E00B1BDF4 /* tab_add.png in Resources */ = {isa = PBXBuildFile; fileRef = FAA4557318A19A2E00B1BDF4 /* tab_add.png */; };
FAA4557918A19D9500B1BDF4 /* unable_to_connect.html in Resources */ = {isa = PBXBuildFile; fileRef = FAA4557818A19D9500B1BDF4 /* unable_to_connect.html */; };
FAA4557B18A19F1E00B1BDF4 /* configure.png in Resources */ = {isa = PBXBuildFile; fileRef = FAA4557A18A19F1E00B1BDF4 /* configure.png */; };
FAA4557D18A19F7A00B1BDF4 /* bookmarks.png in Resources */ = {isa = PBXBuildFile; fileRef = FAA4557C18A19F7A00B1BDF4 /* bookmarks.png */; };
+ FAB6B8FF19945091001666A7 /* folder.png in Resources */ = {isa = PBXBuildFile; fileRef = FAB6B8FE19945091001666A7 /* folder.png */; };
FAC9B25E16F27BF800E37710 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FAC9B25D16F27BF800E37710 /* UIKit.framework */; };
FAC9B26016F27BF800E37710 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FAC9B25F16F27BF800E37710 /* Foundation.framework */; };
FAC9B26216F27BF800E37710 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FAC9B26116F27BF800E37710 /* CoreGraphics.framework */; };
@@ -34,7 +39,6 @@
FAC9B27416F27BF800E37710 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = FAC9B27316F27BF800E37710 /* Default-568h@2x.png */; };
FAC9B27716F27BF800E37710 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FAC9B27616F27BF800E37710 /* ViewController.m */; };
FAC9B3B116F3863500E37710 /* libxml2.2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = FAC9B3B016F3863500E37710 /* libxml2.2.dylib */; };
- FAC9B3B516F38C6500E37710 /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FAC9B3B416F38C6500E37710 /* CoreData.framework */; };
FAC9B3B916F38D3700E37710 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FAC9B3B816F38D3700E37710 /* SystemConfiguration.framework */; };
FAF75E9618A17A77007B317D /* BookmarkFoldersForm.xib in Resources */ = {isa = PBXBuildFile; fileRef = FAF75E8118A17A77007B317D /* BookmarkFoldersForm.xib */; };
FAF75E9718A17A77007B317D /* BookmarkItem.xib in Resources */ = {isa = PBXBuildFile; fileRef = FAF75E8218A17A77007B317D /* BookmarkItem.xib */; };
@@ -44,48 +48,45 @@
FAF75EA518A17A77007B317D /* MainWindow-iPad.xib in Resources */ = {isa = PBXBuildFile; fileRef = FAF75E9118A17A77007B317D /* MainWindow-iPad.xib */; };
FAF75EA618A17A77007B317D /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = FAF75E9218A17A77007B317D /* MainWindow.xib */; };
FAF75EA718A17A77007B317D /* Bookmarks.xib in Resources */ = {isa = PBXBuildFile; fileRef = FAF75E9318A17A77007B317D /* Bookmarks.xib */; };
- FAF75EA818A17A77007B317D /* BrowserModel.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = FAF75E9418A17A77007B317D /* BrowserModel.xcdatamodeld */; };
- FAF75EE218A17BFD007B317D /* BrowserModel.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = FAF75ED418A17BFD007B317D /* BrowserModel.xcdatamodeld */; };
- FAF75EE318A17BFD007B317D /* arrow-left.png in Resources */ = {isa = PBXBuildFile; fileRef = FAF75ED718A17BFD007B317D /* arrow-left.png */; };
- FAF75EE418A17BFD007B317D /* arrow-right.png in Resources */ = {isa = PBXBuildFile; fileRef = FAF75ED818A17BFD007B317D /* arrow-right.png */; };
FAF75EE518A17BFD007B317D /* bookmark.png in Resources */ = {isa = PBXBuildFile; fileRef = FAF75ED918A17BFD007B317D /* bookmark.png */; };
FAF75EE618A17BFD007B317D /* cell_arrow.png in Resources */ = {isa = PBXBuildFile; fileRef = FAF75EDA18A17BFD007B317D /* cell_arrow.png */; };
FAF75EE718A17BFD007B317D /* delete_circle.png in Resources */ = {isa = PBXBuildFile; fileRef = FAF75EDB18A17BFD007B317D /* delete_circle.png */; };
- FAF75EE818A17BFD007B317D /* folder.png in Resources */ = {isa = PBXBuildFile; fileRef = FAF75EDC18A17BFD007B317D /* folder.png */; };
FAF75EE918A17BFD007B317D /* gray-pixel.png in Resources */ = {isa = PBXBuildFile; fileRef = FAF75EDD18A17BFD007B317D /* gray-pixel.png */; };
FAF75EEA18A17BFD007B317D /* iphone_delete_button.png in Resources */ = {isa = PBXBuildFile; fileRef = FAF75EDE18A17BFD007B317D /* iphone_delete_button.png */; };
FAF75EEB18A17BFD007B317D /* refresh.png in Resources */ = {isa = PBXBuildFile; fileRef = FAF75EDF18A17BFD007B317D /* refresh.png */; };
FAF75EEC18A17BFD007B317D /* tabs.png in Resources */ = {isa = PBXBuildFile; fileRef = FAF75EE018A17BFD007B317D /* tabs.png */; };
- FAF75EED18A17BFD007B317D /* JSTools.js in Sources */ = {isa = PBXBuildFile; fileRef = FAF75EE118A17BFD007B317D /* JSTools.js */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
- 71ED23B4194470B2002ACD24 /* BrowserDelegate.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 4; name = BrowserDelegate.h; path = ../Browser/BrowserDelegate.h; sourceTree = ""; };
- 71ED23B5194470B2002ACD24 /* BrowserDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BrowserDelegate.m; path = ../Browser/BrowserDelegate.m; sourceTree = ""; };
+ 4B1C68B2197DEC050014AB79 /* Logging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Logging.h; sourceTree = ""; };
B572E54718D08D2A005E4834 /* Tab.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Tab.m; path = ../Browser/Tab.m; sourceTree = ""; };
- B572E54818D08D2A005E4834 /* BookmarksController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BookmarksController.m; path = ../Browser/BookmarksController.m; sourceTree = ""; };
- B572E54918D08D2A005E4834 /* BookmarksFormController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BookmarksFormController.h; path = ../Browser/BookmarksFormController.h; sourceTree = ""; };
- B572E54A18D08D2A005E4834 /* BookmarksFormController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BookmarksFormController.m; path = ../Browser/BookmarksFormController.m; sourceTree = ""; };
+ B572E54818D08D2A005E4834 /* BookmarksController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BookmarksController.m; sourceTree = ""; };
+ B572E54918D08D2A005E4834 /* BookmarksFormController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BookmarksFormController.h; sourceTree = ""; };
+ B572E54A18D08D2A005E4834 /* BookmarksFormController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BookmarksFormController.m; sourceTree = ""; };
B572E54B18D08D2A005E4834 /* BrowserViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BrowserViewController.h; path = ../Browser/BrowserViewController.h; sourceTree = ""; };
B572E54C18D08D2A005E4834 /* BrowserViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BrowserViewController.m; path = ../Browser/BrowserViewController.m; sourceTree = ""; };
B572E54D18D08D2A005E4834 /* Tab.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Tab.h; path = ../Browser/Tab.h; sourceTree = ""; };
B572E54E18D08D2A005E4834 /* UIMainView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UIMainView.h; path = ../Browser/UIMainView.h; sourceTree = ""; };
B572E54F18D08D2A005E4834 /* UIMainView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = UIMainView.m; path = ../Browser/UIMainView.m; sourceTree = ""; };
- B572E55018D08D2A005E4834 /* BookmarkFolderFormController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BookmarkFolderFormController.h; path = ../Browser/BookmarkFolderFormController.h; sourceTree = ""; };
- B572E55118D08D2A005E4834 /* BookmarkFolderFormController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BookmarkFolderFormController.m; path = ../Browser/BookmarkFolderFormController.m; sourceTree = ""; };
- B572E55218D08D2A005E4834 /* BookmarkImporter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BookmarkImporter.h; path = ../Browser/BookmarkImporter.h; sourceTree = ""; };
- B572E55318D08D2A005E4834 /* BookmarkImporter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BookmarkImporter.m; path = ../Browser/BookmarkImporter.m; sourceTree = ""; };
- B572E55418D08D2A005E4834 /* BookmarkItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BookmarkItem.h; path = ../Browser/BookmarkItem.h; sourceTree = ""; };
- B572E55518D08D2A005E4834 /* BookmarkItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BookmarkItem.m; path = ../Browser/BookmarkItem.m; sourceTree = ""; };
- B572E55618D08D2A005E4834 /* BookmarksController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BookmarksController.h; path = ../Browser/BookmarksController.h; sourceTree = ""; };
+ B572E55018D08D2A005E4834 /* BookmarkFolderFormController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BookmarkFolderFormController.h; sourceTree = ""; };
+ B572E55118D08D2A005E4834 /* BookmarkFolderFormController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BookmarkFolderFormController.m; sourceTree = ""; };
+ B572E55418D08D2A005E4834 /* BookmarkItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BookmarkItem.h; sourceTree = ""; };
+ B572E55518D08D2A005E4834 /* BookmarkItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BookmarkItem.m; sourceTree = ""; };
+ B572E55618D08D2A005E4834 /* BookmarksController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BookmarksController.h; sourceTree = ""; };
B5A210C018D091F700D65141 /* Reachability.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Reachability.h; path = ../Browser/Reachability.h; sourceTree = ""; };
B5A210C118D091F700D65141 /* Reachability.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Reachability.m; path = ../Browser/Reachability.m; sourceTree = ""; };
+ B5E88BD819A68C5D0021ED10 /* BrowserMainWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BrowserMainWindow.h; sourceTree = ""; };
+ B5E88BD919A68C5D0021ED10 /* BrowserMainWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BrowserMainWindow.m; sourceTree = ""; };
+ FA157C2F19941ACB0002C146 /* bookmarks.strings */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; path = bookmarks.strings; sourceTree = ""; };
+ FA3CD2AB1993D98800B3ACF0 /* right.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = right.png; sourceTree = ""; };
+ FA3CD2AC1993D98800B3ACF0 /* left.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = left.png; sourceTree = ""; };
FAA4557118A19A2E00B1BDF4 /* gsearch.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = gsearch.png; sourceTree = ""; };
FAA4557218A19A2E00B1BDF4 /* magglass.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = magglass.png; sourceTree = ""; };
FAA4557318A19A2E00B1BDF4 /* tab_add.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = tab_add.png; sourceTree = ""; };
FAA4557818A19D9500B1BDF4 /* unable_to_connect.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = unable_to_connect.html; sourceTree = ""; };
FAA4557A18A19F1E00B1BDF4 /* configure.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = configure.png; sourceTree = ""; };
FAA4557C18A19F7A00B1BDF4 /* bookmarks.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = bookmarks.png; sourceTree = ""; };
+ FAB6B8FE19945091001666A7 /* folder.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = folder.png; sourceTree = ""; };
FAC9B25A16F27BF800E37710 /* TestBrowser.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TestBrowser.app; sourceTree = BUILT_PRODUCTS_DIR; };
FAC9B25D16F27BF800E37710 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
FAC9B25F16F27BF800E37710 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
@@ -102,7 +103,6 @@
FAC9B27516F27BF800E37710 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; };
FAC9B27616F27BF800E37710 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; };
FAC9B3B016F3863500E37710 /* libxml2.2.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libxml2.2.dylib; path = usr/lib/libxml2.2.dylib; sourceTree = SDKROOT; };
- FAC9B3B416F38C6500E37710 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; };
FAC9B3B816F38D3700E37710 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; };
FAF75E8118A17A77007B317D /* BookmarkFoldersForm.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = BookmarkFoldersForm.xib; sourceTree = ""; };
FAF75E8218A17A77007B317D /* BookmarkItem.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = BookmarkItem.xib; sourceTree = ""; };
@@ -112,14 +112,9 @@
FAF75E9118A17A77007B317D /* MainWindow-iPad.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = "MainWindow-iPad.xib"; sourceTree = ""; };
FAF75E9218A17A77007B317D /* MainWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MainWindow.xib; sourceTree = ""; };
FAF75E9318A17A77007B317D /* Bookmarks.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = Bookmarks.xib; sourceTree = ""; };
- FAF75E9518A17A77007B317D /* BrowserModel.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = BrowserModel.xcdatamodel; sourceTree = ""; };
- FAF75ED518A17BFD007B317D /* BrowserModel.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = BrowserModel.xcdatamodel; sourceTree = ""; };
- FAF75ED718A17BFD007B317D /* arrow-left.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "arrow-left.png"; sourceTree = ""; };
- FAF75ED818A17BFD007B317D /* arrow-right.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "arrow-right.png"; sourceTree = ""; };
FAF75ED918A17BFD007B317D /* bookmark.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = bookmark.png; sourceTree = ""; };
FAF75EDA18A17BFD007B317D /* cell_arrow.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = cell_arrow.png; sourceTree = ""; };
FAF75EDB18A17BFD007B317D /* delete_circle.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = delete_circle.png; sourceTree = ""; };
- FAF75EDC18A17BFD007B317D /* folder.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = folder.png; sourceTree = ""; };
FAF75EDD18A17BFD007B317D /* gray-pixel.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "gray-pixel.png"; sourceTree = ""; };
FAF75EDE18A17BFD007B317D /* iphone_delete_button.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = iphone_delete_button.png; sourceTree = ""; };
FAF75EDF18A17BFD007B317D /* refresh.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = refresh.png; sourceTree = ""; };
@@ -133,7 +128,6 @@
buildActionMask = 2147483647;
files = (
FAC9B3B916F38D3700E37710 /* SystemConfiguration.framework in Frameworks */,
- FAC9B3B516F38C6500E37710 /* CoreData.framework in Frameworks */,
FAC9B3B116F3863500E37710 /* libxml2.2.dylib in Frameworks */,
FAC9B25E16F27BF800E37710 /* UIKit.framework in Frameworks */,
FAC9B26016F27BF800E37710 /* Foundation.framework in Frameworks */,
@@ -144,9 +138,66 @@
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
+ 0E54DB6D197DAE31005BF033 /* Bookmarks */ = {
+ isa = PBXGroup;
+ children = (
+ B572E55418D08D2A005E4834 /* BookmarkItem.h */,
+ B572E55518D08D2A005E4834 /* BookmarkItem.m */,
+ B572E55618D08D2A005E4834 /* BookmarksController.h */,
+ B572E54818D08D2A005E4834 /* BookmarksController.m */,
+ B572E54918D08D2A005E4834 /* BookmarksFormController.h */,
+ B572E54A18D08D2A005E4834 /* BookmarksFormController.m */,
+ B572E55018D08D2A005E4834 /* BookmarkFolderFormController.h */,
+ B572E55118D08D2A005E4834 /* BookmarkFolderFormController.m */,
+ );
+ name = Bookmarks;
+ sourceTree = "";
+ };
+ 0E54DB6E197DAEA7005BF033 /* Web */ = {
+ isa = PBXGroup;
+ children = (
+ FAF75EE118A17BFD007B317D /* JSTools.js */,
+ FAF75E8F18A17A77007B317D /* import_bookmark_howto.html */,
+ FAA4557818A19D9500B1BDF4 /* unable_to_connect.html */,
+ FAF75E9018A17A77007B317D /* launch.html */,
+ );
+ name = Web;
+ sourceTree = "";
+ };
+ 0E54DB6F197DAECA005BF033 /* Views */ = {
+ isa = PBXGroup;
+ children = (
+ FAF75E8118A17A77007B317D /* BookmarkFoldersForm.xib */,
+ FAF75E8218A17A77007B317D /* BookmarkItem.xib */,
+ FAF75E8318A17A77007B317D /* BookmarksForm.xib */,
+ FAF75E9118A17A77007B317D /* MainWindow-iPad.xib */,
+ FAF75E9218A17A77007B317D /* MainWindow.xib */,
+ FAF75E9318A17A77007B317D /* Bookmarks.xib */,
+ );
+ name = Views;
+ sourceTree = "";
+ };
+ 4B1C68B1197DEC050014AB79 /* Logging */ = {
+ isa = PBXGroup;
+ children = (
+ 4B1C68B2197DEC050014AB79 /* Logging.h */,
+ );
+ path = Logging;
+ sourceTree = "";
+ };
+ FA157C2E19941AB90002C146 /* Bookmarks */ = {
+ isa = PBXGroup;
+ children = (
+ FA157C2F19941ACB0002C146 /* bookmarks.strings */,
+ );
+ name = Bookmarks;
+ sourceTree = "";
+ };
FAA4557718A19B2700B1BDF4 /* Buttons */ = {
isa = PBXGroup;
children = (
+ FA3CD2AB1993D98800B3ACF0 /* right.png */,
+ FA3CD2AC1993D98800B3ACF0 /* left.png */,
FAA4557C18A19F7A00B1BDF4 /* bookmarks.png */,
FAA4557A18A19F1E00B1BDF4 /* configure.png */,
FAA4557318A19A2E00B1BDF4 /* tab_add.png */,
@@ -159,9 +210,6 @@
children = (
FAF75E8018A17A59007B317D /* Browser Resources */,
FAF75E6A18A179D1007B317D /* Browser */,
- FAC9B3B816F38D3700E37710 /* SystemConfiguration.framework */,
- FAC9B3B416F38C6500E37710 /* CoreData.framework */,
- FAC9B3B016F3863500E37710 /* libxml2.2.dylib */,
FAC9B26316F27BF800E37710 /* TestBrowser */,
FAC9B25C16F27BF800E37710 /* Frameworks */,
FAC9B25B16F27BF800E37710 /* Products */,
@@ -179,6 +227,8 @@
FAC9B25C16F27BF800E37710 /* Frameworks */ = {
isa = PBXGroup;
children = (
+ FAC9B3B016F3863500E37710 /* libxml2.2.dylib */,
+ FAC9B3B816F38D3700E37710 /* SystemConfiguration.framework */,
FAC9B25D16F27BF800E37710 /* UIKit.framework */,
FAC9B25F16F27BF800E37710 /* Foundation.framework */,
FAC9B26116F27BF800E37710 /* CoreGraphics.framework */,
@@ -215,26 +265,18 @@
FAF75E6A18A179D1007B317D /* Browser */ = {
isa = PBXGroup;
children = (
- B572E54718D08D2A005E4834 /* Tab.m */,
- B572E54818D08D2A005E4834 /* BookmarksController.m */,
- B572E54918D08D2A005E4834 /* BookmarksFormController.h */,
- B572E54A18D08D2A005E4834 /* BookmarksFormController.m */,
- B572E54B18D08D2A005E4834 /* BrowserViewController.h */,
- B572E54C18D08D2A005E4834 /* BrowserViewController.m */,
+ 4B1C68B1197DEC050014AB79 /* Logging */,
+ 0E54DB6D197DAE31005BF033 /* Bookmarks */,
B572E54D18D08D2A005E4834 /* Tab.h */,
+ B572E54718D08D2A005E4834 /* Tab.m */,
B572E54E18D08D2A005E4834 /* UIMainView.h */,
B572E54F18D08D2A005E4834 /* UIMainView.m */,
- B572E55018D08D2A005E4834 /* BookmarkFolderFormController.h */,
+ B5E88BD819A68C5D0021ED10 /* BrowserMainWindow.h */,
+ B5E88BD919A68C5D0021ED10 /* BrowserMainWindow.m */,
B5A210C018D091F700D65141 /* Reachability.h */,
B5A210C118D091F700D65141 /* Reachability.m */,
- B572E55118D08D2A005E4834 /* BookmarkFolderFormController.m */,
- B572E55218D08D2A005E4834 /* BookmarkImporter.h */,
- B572E55318D08D2A005E4834 /* BookmarkImporter.m */,
- B572E55418D08D2A005E4834 /* BookmarkItem.h */,
- B572E55518D08D2A005E4834 /* BookmarkItem.m */,
- 71ED23B4194470B2002ACD24 /* BrowserDelegate.h */,
- 71ED23B5194470B2002ACD24 /* BrowserDelegate.m */,
- B572E55618D08D2A005E4834 /* BookmarksController.h */,
+ B572E54B18D08D2A005E4834 /* BrowserViewController.h */,
+ B572E54C18D08D2A005E4834 /* BrowserViewController.m */,
);
name = Browser;
path = ../Browser;
@@ -243,19 +285,10 @@
FAF75E8018A17A59007B317D /* Browser Resources */ = {
isa = PBXGroup;
children = (
- FAA4557818A19D9500B1BDF4 /* unable_to_connect.html */,
- FAF75ED418A17BFD007B317D /* BrowserModel.xcdatamodeld */,
+ FA157C2E19941AB90002C146 /* Bookmarks */,
+ 0E54DB6F197DAECA005BF033 /* Views */,
+ 0E54DB6E197DAEA7005BF033 /* Web */,
FAF75ED618A17BFD007B317D /* Images */,
- FAF75EE118A17BFD007B317D /* JSTools.js */,
- FAF75E8118A17A77007B317D /* BookmarkFoldersForm.xib */,
- FAF75E8218A17A77007B317D /* BookmarkItem.xib */,
- FAF75E8318A17A77007B317D /* BookmarksForm.xib */,
- FAF75E8F18A17A77007B317D /* import_bookmark_howto.html */,
- FAF75E9018A17A77007B317D /* launch.html */,
- FAF75E9118A17A77007B317D /* MainWindow-iPad.xib */,
- FAF75E9218A17A77007B317D /* MainWindow.xib */,
- FAF75E9318A17A77007B317D /* Bookmarks.xib */,
- FAF75E9418A17A77007B317D /* BrowserModel.xcdatamodeld */,
);
name = "Browser Resources";
path = "../Browser Resources";
@@ -266,13 +299,11 @@
children = (
FAA4557718A19B2700B1BDF4 /* Buttons */,
FAA4557118A19A2E00B1BDF4 /* gsearch.png */,
+ FAB6B8FE19945091001666A7 /* folder.png */,
FAF75ED918A17BFD007B317D /* bookmark.png */,
FAA4557218A19A2E00B1BDF4 /* magglass.png */,
- FAF75ED718A17BFD007B317D /* arrow-left.png */,
- FAF75ED818A17BFD007B317D /* arrow-right.png */,
FAF75EDA18A17BFD007B317D /* cell_arrow.png */,
FAF75EDB18A17BFD007B317D /* delete_circle.png */,
- FAF75EDC18A17BFD007B317D /* folder.png */,
FAF75EDD18A17BFD007B317D /* gray-pixel.png */,
FAF75EDE18A17BFD007B317D /* iphone_delete_button.png */,
FAF75EDF18A17BFD007B317D /* refresh.png */,
@@ -332,6 +363,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
+ B5E88C2019A698DF0021ED10 /* JSTools.js in Resources */,
FAF75EA518A17A77007B317D /* MainWindow-iPad.xib in Resources */,
FAA4557D18A19F7A00B1BDF4 /* bookmarks.png in Resources */,
FAF75EE918A17BFD007B317D /* gray-pixel.png in Resources */,
@@ -339,24 +371,25 @@
FAF75EE718A17BFD007B317D /* delete_circle.png in Resources */,
FAF75E9818A17A77007B317D /* BookmarksForm.xib in Resources */,
FAF75EEC18A17BFD007B317D /* tabs.png in Resources */,
+ FAB6B8FF19945091001666A7 /* folder.png in Resources */,
FAF75EE518A17BFD007B317D /* bookmark.png in Resources */,
FAF75EA318A17A77007B317D /* import_bookmark_howto.html in Resources */,
FAF75EA718A17A77007B317D /* Bookmarks.xib in Resources */,
FAC9B26816F27BF800E37710 /* InfoPlist.strings in Resources */,
FAF75EEA18A17BFD007B317D /* iphone_delete_button.png in Resources */,
- FAF75EE318A17BFD007B317D /* arrow-left.png in Resources */,
+ FA157C3019941ACB0002C146 /* bookmarks.strings in Resources */,
FAA4557B18A19F1E00B1BDF4 /* configure.png in Resources */,
FAF75EA418A17A77007B317D /* launch.html in Resources */,
- FAF75EE418A17BFD007B317D /* arrow-right.png in Resources */,
FAA4557518A19A2E00B1BDF4 /* magglass.png in Resources */,
FAC9B27016F27BF800E37710 /* Default.png in Resources */,
- FAF75EE818A17BFD007B317D /* folder.png in Resources */,
FAA4557418A19A2E00B1BDF4 /* gsearch.png in Resources */,
FAA4557618A19A2E00B1BDF4 /* tab_add.png in Resources */,
FAF75EEB18A17BFD007B317D /* refresh.png in Resources */,
+ FA3CD2AD1993D98800B3ACF0 /* right.png in Resources */,
FAF75E9718A17A77007B317D /* BookmarkItem.xib in Resources */,
FAC9B27216F27BF800E37710 /* Default@2x.png in Resources */,
FAC9B27416F27BF800E37710 /* Default-568h@2x.png in Resources */,
+ FA3CD2AE1993D98800B3ACF0 /* left.png in Resources */,
FAF75EA618A17A77007B317D /* MainWindow.xib in Resources */,
FAF75E9618A17A77007B317D /* BookmarkFoldersForm.xib in Resources */,
FAA4557918A19D9500B1BDF4 /* unable_to_connect.html in Resources */,
@@ -370,22 +403,19 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
- 71ED23B819447163002ACD24 /* BrowserDelegate.m in Sources */,
- B572E55D18D08D2A005E4834 /* BookmarkImporter.m in Sources */,
B572E55918D08D2A005E4834 /* BookmarksFormController.m in Sources */,
B572E55E18D08D2A005E4834 /* BookmarkItem.m in Sources */,
- FAF75EA818A17A77007B317D /* BrowserModel.xcdatamodeld in Sources */,
B5A210C218D091F700D65141 /* Reachability.m in Sources */,
B572E55718D08D2A005E4834 /* Tab.m in Sources */,
- FAF75EE218A17BFD007B317D /* BrowserModel.xcdatamodeld in Sources */,
FAC9B26A16F27BF800E37710 /* main.m in Sources */,
FAC9B26E16F27BF800E37710 /* AppDelegate.m in Sources */,
B572E55B18D08D2A005E4834 /* UIMainView.m in Sources */,
B572E55818D08D2A005E4834 /* BookmarksController.m in Sources */,
+ B5E88BDA19A68C5D0021ED10 /* BrowserMainWindow.m in Sources */,
B572E55A18D08D2A005E4834 /* BrowserViewController.m in Sources */,
FAC9B27716F27BF800E37710 /* ViewController.m in Sources */,
- FAF75EED18A17BFD007B317D /* JSTools.js in Sources */,
B572E55C18D08D2A005E4834 /* BookmarkFolderFormController.m in Sources */,
+ B5E88C1F19A697490021ED10 /* JSTools.js in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -469,7 +499,7 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "TestBrowser/TestBrowser-Prefix.pch";
INFOPLIST_FILE = "TestBrowser/TestBrowser-Info.plist";
- IPHONEOS_DEPLOYMENT_TARGET = 7.0;
+ IPHONEOS_DEPLOYMENT_TARGET = 7.1;
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
@@ -481,7 +511,7 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "TestBrowser/TestBrowser-Prefix.pch";
INFOPLIST_FILE = "TestBrowser/TestBrowser-Info.plist";
- IPHONEOS_DEPLOYMENT_TARGET = 7.0;
+ IPHONEOS_DEPLOYMENT_TARGET = 7.1;
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
@@ -509,29 +539,6 @@
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
-
-/* Begin XCVersionGroup section */
- FAF75E9418A17A77007B317D /* BrowserModel.xcdatamodeld */ = {
- isa = XCVersionGroup;
- children = (
- FAF75E9518A17A77007B317D /* BrowserModel.xcdatamodel */,
- );
- currentVersion = FAF75E9518A17A77007B317D /* BrowserModel.xcdatamodel */;
- path = BrowserModel.xcdatamodeld;
- sourceTree = "";
- versionGroupType = wrapper.xcdatamodel;
- };
- FAF75ED418A17BFD007B317D /* BrowserModel.xcdatamodeld */ = {
- isa = XCVersionGroup;
- children = (
- FAF75ED518A17BFD007B317D /* BrowserModel.xcdatamodel */,
- );
- currentVersion = FAF75ED518A17BFD007B317D /* BrowserModel.xcdatamodel */;
- path = BrowserModel.xcdatamodeld;
- sourceTree = "";
- versionGroupType = wrapper.xcdatamodel;
- };
-/* End XCVersionGroup section */
};
rootObject = FAC9B25216F27BF800E37710 /* Project object */;
}
diff --git a/sample-app/TestBrowser/AppDelegate.h b/sample-app/TestBrowser/AppDelegate.h
index 889c807..f505307 100644
--- a/sample-app/TestBrowser/AppDelegate.h
+++ b/sample-app/TestBrowser/AppDelegate.h
@@ -7,11 +7,10 @@
//
#import
-#import "BrowserDelegate.h"
@class BrowserViewController;
-@interface AppDelegate : BrowserDelegate
+@interface AppDelegate : UIResponder
@property (strong, nonatomic) UIWindow *window;
diff --git a/sample-app/TestBrowser/AppDelegate.m b/sample-app/TestBrowser/AppDelegate.m
index fc0867d..a11c3dd 100644
--- a/sample-app/TestBrowser/AppDelegate.m
+++ b/sample-app/TestBrowser/AppDelegate.m
@@ -8,14 +8,15 @@
#import "AppDelegate.h"
#import "BrowserViewController.h"
+#import "BrowserMainWindow.h"
@implementation AppDelegate
-@synthesize window;
+@synthesize window, viewController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
- self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
+ self.window = [[BrowserMainWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.viewController = [[BrowserViewController alloc] init];
diff --git a/sample-app/TestBrowser/TestBrowser-Info.plist b/sample-app/TestBrowser/TestBrowser-Info.plist
index 07b5c12..2ee64ea 100644
--- a/sample-app/TestBrowser/TestBrowser-Info.plist
+++ b/sample-app/TestBrowser/TestBrowser-Info.plist
@@ -31,6 +31,7 @@
UISupportedInterfaceOrientations
UIInterfaceOrientationPortrait
+ UIInterfaceOrientationPortraitUpsideDown
UIInterfaceOrientationLandscapeLeft
UIInterfaceOrientationLandscapeRight