Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Browser Resources/BookmarkItem.xib
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@
</connections>
</button>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" id="7" userLabel="Logo">
<rect key="frame" x="8" y="7" width="33" height="28"/>
<rect key="frame" x="20" y="15" width="16" height="16"/>
<autoresizingMask key="autoresizingMask"/>
</imageView>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" text="Label" lineBreakMode="tailTruncation" minimumFontSize="10" adjustsFontSizeToFit="NO" id="8" userLabel="Name">
<rect key="frame" x="48" y="12" width="252" height="22"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" name="Helvetica" family="Helvetica" pointSize="18"/>
<fontDescription key="fontDescription" name="Helvetica" family="Helvetica" pointSize="14"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="highlightedColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</label>
Expand Down
Binary file removed Browser Resources/Images/arrow-left.png
Binary file not shown.
Binary file removed Browser Resources/Images/arrow-right.png
Binary file not shown.
Binary file modified Browser Resources/Images/folder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Browser Resources/Images/left.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Browser Resources/Images/right.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 8 additions & 10 deletions Browser Resources/MainWindow-iPad.xib
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.iPad.XIB" version="3.0" toolsVersion="5056" systemVersion="13E28" targetRuntime="iOS.CocoaTouch.iPad" variant="6xAndEarlier" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.iPad.XIB" version="3.0" toolsVersion="5056" systemVersion="13E28" targetRuntime="iOS.CocoaTouch.iPad" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment defaultVersion="1536" identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3733"/>
Expand Down Expand Up @@ -59,27 +59,27 @@
</constraints>
<items>
<barButtonItem style="plain" systemItem="flexibleSpace" id="l6j-iK-U6V"/>
<barButtonItem enabled="NO" image="arrow-left.png" width="28" style="plain" id="9rt-QG-NlJ" userLabel="Back">
<barButtonItem enabled="NO" image="left.png" width="28" style="plain" id="9rt-QG-NlJ" userLabel="Back">
<inset key="imageInsets" minX="0.0" minY="2" maxX="0.0" maxY="-1"/>
<connections>
<action selector="goBack:" destination="-1" id="IYq-kP-pfY"/>
</connections>
</barButtonItem>
<barButtonItem style="plain" systemItem="flexibleSpace" id="6s0-B2-FP1"/>
<barButtonItem enabled="NO" image="arrow-right.png" width="43" style="plain" id="hJx-zz-ow8" userLabel="Forward">
<barButtonItem enabled="NO" image="right.png" width="43" style="plain" id="hJx-zz-ow8" userLabel="Forward">
<inset key="imageInsets" minX="0.0" minY="1" maxX="0.0" maxY="-1"/>
<connections>
<action selector="goForward:" destination="-1" id="0rp-TK-dkY"/>
</connections>
</barButtonItem>
<barButtonItem style="plain" systemItem="flexibleSpace" id="3MH-u4-8zd"/>
<barButtonItem image="configure.png" style="plain" id="BFd-HB-iTN" userLabel="More">
<barButtonItem style="plain" systemItem="action" id="BFd-HB-iTN" userLabel="More">
<connections>
<action selector="showActionSheet:" destination="-1" id="D8I-NO-dFe"/>
</connections>
</barButtonItem>
<barButtonItem style="plain" systemItem="flexibleSpace" id="Fsw-lv-dyq"/>
<barButtonItem image="bookmarks.png" style="plain" id="LNT-s5-BBY" userLabel="Bookmarks">
<barButtonItem style="plain" systemItem="bookmarks" id="LNT-s5-BBY" userLabel="Bookmarks">
<inset key="imageInsets" minX="0.0" minY="0.0" maxX="-5" maxY="0.0"/>
<connections>
<action selector="showBookmarks:" destination="-1" id="Vvq-aC-fzd"/>
Expand Down Expand Up @@ -198,7 +198,7 @@
<constraint firstAttribute="trailing" secondItem="jQR-GJ-1lz" secondAttribute="trailing" constant="55" id="ymc-ch-3Ag"/>
</constraints>
</view>
<progressView hidden="YES" opaque="NO" contentMode="scaleToFill" misplaced="YES" progress="0.5" translatesAutoresizingMaskIntoConstraints="NO" id="183">
<progressView hidden="YES" opaque="NO" contentMode="scaleToFill" progress="0.5" translatesAutoresizingMaskIntoConstraints="NO" id="183">
<rect key="frame" x="-5" y="82" width="778" height="2"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
<constraints>
Expand Down Expand Up @@ -243,11 +243,9 @@
</view>
</objects>
<resources>
<image name="arrow-left.png" width="20" height="20"/>
<image name="arrow-right.png" width="20" height="20"/>
<image name="bookmarks.png" width="40" height="40"/>
<image name="configure.png" width="40" height="40"/>
<image name="left.png" width="24" height="32"/>
<image name="refresh.png" width="48" height="48"/>
<image name="right.png" width="24" height="32"/>
<image name="tab_add.png" width="32" height="32"/>
</resources>
</document>
22 changes: 10 additions & 12 deletions Browser Resources/MainWindow.xib
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="5056" systemVersion="13E28" targetRuntime="iOS.CocoaTouch" variant="6xAndEarlier" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="5056" systemVersion="13E28" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment defaultVersion="1536" identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3733"/>
Expand All @@ -25,7 +25,7 @@
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="123" userLabel="Main" customClass="UIMainView">
<rect key="frame" x="0.0" y="20" width="320" height="460"/>
<rect key="frame" x="0.0" y="0.0" width="320" height="480"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="163" userLabel="Status Bar Line">
Expand Down Expand Up @@ -188,34 +188,34 @@
</constraints>
</view>
<toolbar opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="18" userLabel="Bottom Toolbar">
<rect key="frame" x="0.0" y="416" width="321" height="44"/>
<rect key="frame" x="0.0" y="436" width="321" height="44"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" red="0.91326530610000001" green="0.89858857680000004" blue="0.90959612379999999" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="height" constant="44" id="tAZ-Hf-gOT"/>
</constraints>
<items>
<barButtonItem enabled="NO" image="arrow-left.png" width="28" style="plain" id="22" userLabel="Back">
<barButtonItem enabled="NO" image="left.png" width="28" style="plain" id="22" userLabel="Back">
<inset key="imageInsets" minX="0.0" minY="2" maxX="0.0" maxY="-1"/>
<connections>
<action selector="goBack:" destination="-1" id="31"/>
</connections>
</barButtonItem>
<barButtonItem style="plain" systemItem="flexibleSpace" id="184"/>
<barButtonItem enabled="NO" image="arrow-right.png" width="43" style="plain" id="20" userLabel="Forward">
<barButtonItem enabled="NO" image="right.png" width="43" style="plain" id="20" userLabel="Forward">
<inset key="imageInsets" minX="0.0" minY="1" maxX="0.0" maxY="-1"/>
<connections>
<action selector="goForward:" destination="-1" id="30"/>
</connections>
</barButtonItem>
<barButtonItem style="plain" systemItem="flexibleSpace" id="185"/>
<barButtonItem image="configure.png" style="plain" id="71" userLabel="More">
<barButtonItem style="plain" systemItem="action" id="71" userLabel="More">
<connections>
<action selector="showActionSheet:" destination="-1" id="166"/>
</connections>
</barButtonItem>
<barButtonItem style="plain" systemItem="flexibleSpace" id="186"/>
<barButtonItem image="bookmarks.png" style="plain" id="73" userLabel="Bookmarks">
<barButtonItem style="plain" systemItem="bookmarks" id="73" userLabel="Bookmarks">
<inset key="imageInsets" minX="0.0" minY="0.0" maxX="-5" maxY="0.0"/>
<connections>
<action selector="showBookmarks:" destination="-1" id="183"/>
Expand All @@ -225,7 +225,7 @@
<color key="tintColor" red="0.23921568627450979" green="0.70588235294117641" blue="0.89803921568627454" alpha="1" colorSpace="calibratedRGB"/>
</toolbar>
<view hidden="YES" clearsContextBeforeDrawing="NO" userInteractionEnabled="NO" alpha="0.0" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="169" userLabel="Browser">
<rect key="frame" x="0.0" y="0.0" width="321" height="416"/>
<rect key="frame" x="0.0" y="0.0" width="321" height="436"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
Expand Down Expand Up @@ -266,11 +266,9 @@
</view>
</objects>
<resources>
<image name="arrow-left.png" width="20" height="20"/>
<image name="arrow-right.png" width="20" height="20"/>
<image name="bookmarks.png" width="40" height="40"/>
<image name="configure.png" width="40" height="40"/>
<image name="left.png" width="24" height="32"/>
<image name="refresh.png" width="48" height="48"/>
<image name="right.png" width="24" height="32"/>
<image name="tab_add.png" width="32" height="32"/>
</resources>
</document>
9 changes: 9 additions & 0 deletions Browser Resources/bookmarks.strings
Original file line number Diff line number Diff line change
@@ -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";
11 changes: 10 additions & 1 deletion Browser/BookmarksController.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#define FOLDERS_KEY @"BookmarksFolders"
#define BOOKMARKS_ROOT -1
#define MAX_BOOKMARKS 1000
#define BOOKMARKS_SEED_RESOURCE_NAME @"bookmarks"

@class BookmarksFormController;
@class BookmarkFolderFormController;
Expand All @@ -24,10 +25,12 @@
char mode;
NSInteger folderIndex;
NSInteger bookmarkIndex;
NSMutableArray *bookmarks;
NSMutableArray *folders;

NSString *bookmarksSeedResourceName;

UIImage *bookmarkImage;
UIImage *folderImage;
IBOutlet UIToolbar *toolbar;
Expand All @@ -45,6 +48,8 @@
@property(nonatomic, strong) NSMutableArray *bookmarks;
@property(nonatomic, strong) NSMutableArray *folders;

@property(nonatomic, strong) NSString *bookmarksSeedResourceName;

@property(nonatomic, strong) IBOutlet UITableView *tableView;

@property(nonatomic, strong) UIImage *bookmarkImage;
Expand All @@ -61,4 +66,8 @@
-(void) loadBookmarks;
-(void) openBookmark:(NSIndexPath *) indexPath;


-(NSString *) getBookmarkImageURLFromUrlString:(NSString *) urlString;
-(UIImage *) getBookmarkImageFromUrlString:(NSString *) urlString;

@end
69 changes: 57 additions & 12 deletions Browser/BookmarksController.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ @implementation BookmarksController
@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.
Expand All @@ -27,6 +28,7 @@ - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
if (self) {
// Custom initialization.
self.folderIndex = BOOKMARKS_ROOT;
self.bookmarksSeedResourceName = BOOKMARKS_SEED_RESOURCE_NAME;
[self loadBookmarks];
}
return self;
Expand All @@ -41,16 +43,46 @@ - (void)viewDidLoad {
//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];

NSMutableArray* folderArray = [[NSMutableArray alloc] init];
NSMutableArray* bookmarksArray = [[NSMutableArray alloc] init];
NSDictionary* defaultBookmark = [NSDictionary dictionaryWithObjectsAndKeys:@"Reddit", @"title",
@"http://www.reddit.com",@"URL",nil];
[bookmarksArray addObject:defaultBookmark];
foldersDict = [NSDictionary dictionaryWithObjectsAndKeys:@"Default", @"title",
bookmarksArray, @"bookmarks",nil];
[folderArray addObject:foldersDict];
[defaults setObject:folderArray forKey:FOLDERS_KEY];
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];
}

Expand Down Expand Up @@ -249,6 +281,17 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger
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;
}

// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)localTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
Expand Down Expand Up @@ -287,7 +330,8 @@ - (UITableViewCell *)tableView:(UITableView *)localTableView cellForRowAtIndexPa
NSDictionary* bookmarkDict = [bookmarksArray objectAtIndex:[indexPath row]];
[cell.cellLabel setText:[bookmarkDict valueForKey:@"title"]];
LogInfo(@"Cell Label : %@", cell.cellLabel.text);
cell.cellImage.image = bookmarkImage;
cell.cellImage.image = [self getBookmarkImageFromUrlString:[bookmarkDict objectForKey:@"URL"]];

}

if (self.mode == 'E') {
Expand All @@ -297,7 +341,8 @@ - (UITableViewCell *)tableView:(UITableView *)localTableView cellForRowAtIndexPa
NSArray* bookmarksArray = [folderDict objectForKey:@"bookmarks"];
NSDictionary* bookmarkDict = [bookmarksArray objectAtIndex:[indexPath row]];
[cell.cellLabel setText:[bookmarkDict valueForKey:@"title"]];
cell.cellImage.image = bookmarkImage;
cell.cellImage.image = [self getBookmarkImageFromUrlString:[bookmarkDict objectForKey:@"URL"]];

[cell enableEdit];
}
else
Expand All @@ -323,7 +368,7 @@ - (UITableViewCell *)tableView:(UITableView *)localTableView cellForRowAtIndexPa
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
LogTrace(@"%s", __PRETTY_FUNCTION__);

((BookmarkItem *)cell).cellLabel.font = [UIFont italicSystemFontOfSize:17.0];
((BookmarkItem *)cell).cellLabel.font = [UIFont italicSystemFontOfSize:14.0];

}

Expand Down
2 changes: 2 additions & 0 deletions Browser/BrowserViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@
-(IBAction) showBookmarks:(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;
Expand Down
Loading