Adding font size overrides.

This commit is contained in:
Samuel Clay 2013-11-23 13:03:14 -08:00
parent 8fdeb1e617
commit 8727b683a5
11 changed files with 168 additions and 44 deletions

View file

@ -103,6 +103,7 @@ static UIFont *indicatorFont = nil;
@synthesize cell;
- (void)drawRect:(CGRect)r {
NSUserDefaults *userPreferences = [NSUserDefaults standardUserDefaults];
int riverPadding = 0;
if (cell.isRiverOrSocial) {
riverPadding = 20;
@ -123,6 +124,19 @@ static UIFont *indicatorFont = nil;
UIColor *textColor;
UIFont *font;
UIFontDescriptor *fontDescriptor = [UIFontDescriptor preferredFontDescriptorWithTextStyle: UIFontTextStyleCaption1];
if (![userPreferences boolForKey:@"use_system_font_size"]) {
if ([[userPreferences stringForKey:@"feed_list_font_size"] isEqualToString:@"xs"]) {
fontDescriptor = [fontDescriptor fontDescriptorWithSize:10.0f];
} else if ([[userPreferences stringForKey:@"feed_list_font_size"] isEqualToString:@"small"]) {
fontDescriptor = [fontDescriptor fontDescriptorWithSize:11.0f];
} else if ([[userPreferences stringForKey:@"feed_list_font_size"] isEqualToString:@"medium"]) {
fontDescriptor = [fontDescriptor fontDescriptorWithSize:12.0f];
} else if ([[userPreferences stringForKey:@"feed_list_font_size"] isEqualToString:@"large"]) {
fontDescriptor = [fontDescriptor fontDescriptorWithSize:14.0f];
} else if ([[userPreferences stringForKey:@"feed_list_font_size"] isEqualToString:@"xl"]) {
fontDescriptor = [fontDescriptor fontDescriptorWithSize:16.0f];
}
}
if (cell.isRead) {
font = [UIFont fontWithDescriptor:fontDescriptor size:0.0];

View file

@ -72,6 +72,7 @@
- (void)scrollViewDidScroll:(UIScrollView *)scroll;
- (void)changeIntelligence:(NSInteger)newLevel;
- (NSDictionary *)getStoryAtRow:(NSInteger)indexPathRow;
- (UIFontDescriptor *)fontDescriptorUsingPreferredSize:(NSString *)textStyle;
- (void)checkScroll;
- (void)setUserAvatarLayout:(UIInterfaceOrientation)orientation;

View file

@ -1035,7 +1035,7 @@ heightForRowAtIndexPath:(NSIndexPath *)indexPath {
&& UIInterfaceOrientationIsPortrait(orientation)) {
height = height - kTableViewShortRowDifference;
}
UIFontDescriptor *fontDescriptor = [UIFontDescriptor preferredFontDescriptorWithTextStyle: UIFontTextStyleCaption1];
UIFontDescriptor *fontDescriptor = [self fontDescriptorUsingPreferredSize:UIFontTextStyleCaption1];
UIFont *font = [UIFont fontWithDescriptor:fontDescriptor size:0.0];
return height + font.pointSize*2;
} else {
@ -1045,7 +1045,7 @@ heightForRowAtIndexPath:(NSIndexPath *)indexPath {
&& UIInterfaceOrientationIsPortrait(orientation)) {
height = height - kTableViewShortRowDifference;
}
UIFontDescriptor *fontDescriptor = [UIFontDescriptor preferredFontDescriptorWithTextStyle: UIFontTextStyleCaption1];
UIFontDescriptor *fontDescriptor = [self fontDescriptorUsingPreferredSize:UIFontTextStyleCaption1];
UIFont *font = [UIFont fontWithDescriptor:fontDescriptor size:0.0];
return height + font.pointSize*2;
}
@ -1058,6 +1058,26 @@ heightForRowAtIndexPath:(NSIndexPath *)indexPath {
[self checkScroll];
}
- (UIFontDescriptor *)fontDescriptorUsingPreferredSize:(NSString *)textStyle {
UIFontDescriptor *fontDescriptor = [UIFontDescriptor preferredFontDescriptorWithTextStyle:textStyle];
NSUserDefaults *userPreferences = [NSUserDefaults standardUserDefaults];
if (![userPreferences boolForKey:@"use_system_font_size"]) {
if ([[userPreferences stringForKey:@"feed_list_font_size"] isEqualToString:@"xs"]) {
fontDescriptor = [fontDescriptor fontDescriptorWithSize:10.0f];
} else if ([[userPreferences stringForKey:@"feed_list_font_size"] isEqualToString:@"small"]) {
fontDescriptor = [fontDescriptor fontDescriptorWithSize:11.0f];
} else if ([[userPreferences stringForKey:@"feed_list_font_size"] isEqualToString:@"medium"]) {
fontDescriptor = [fontDescriptor fontDescriptorWithSize:12.0f];
} else if ([[userPreferences stringForKey:@"feed_list_font_size"] isEqualToString:@"large"]) {
fontDescriptor = [fontDescriptor fontDescriptorWithSize:14.0f];
} else if ([[userPreferences stringForKey:@"feed_list_font_size"] isEqualToString:@"xl"]) {
fontDescriptor = [fontDescriptor fontDescriptorWithSize:16.0f];
}
}
return fontDescriptor;
}
- (void)checkScroll {
NSInteger currentOffset = self.storyTitlesTable.contentOffset.y;
NSInteger maximumOffset = self.storyTitlesTable.contentSize.height - self.storyTitlesTable.frame.size.height;

View file

@ -144,10 +144,24 @@ static UIFont *textFont = nil;
[UIColor blackColor]:
UIColorFromRGB(0x3a3a3a);
UIFont *font;
UIFontDescriptor *fontDescriptor = [UIFontDescriptor preferredFontDescriptorWithTextStyle: UIFontTextStyleFootnote];
NSUserDefaults *userPreferences = [NSUserDefaults standardUserDefaults];
UIFontDescriptor *fontDescriptor = [UIFontDescriptor preferredFontDescriptorWithTextStyle:UIFontTextStyleFootnote];
if (![userPreferences boolForKey:@"use_system_font_size"]) {
if ([[userPreferences stringForKey:@"feed_list_font_size"] isEqualToString:@"xs"]) {
fontDescriptor = [fontDescriptor fontDescriptorWithSize:11.0f];
} else if ([[userPreferences stringForKey:@"feed_list_font_size"] isEqualToString:@"small"]) {
fontDescriptor = [fontDescriptor fontDescriptorWithSize:12.0f];
} else if ([[userPreferences stringForKey:@"feed_list_font_size"] isEqualToString:@"medium"]) {
fontDescriptor = [fontDescriptor fontDescriptorWithSize:13.0f];
} else if ([[userPreferences stringForKey:@"feed_list_font_size"] isEqualToString:@"large"]) {
fontDescriptor = [fontDescriptor fontDescriptorWithSize:14.0f];
} else if ([[userPreferences stringForKey:@"feed_list_font_size"] isEqualToString:@"xl"]) {
fontDescriptor = [fontDescriptor fontDescriptorWithSize:16.0f];
}
}
if (cell.negativeCount || cell.neutralCount || cell.positiveCount) {
UIFontDescriptor *boldFontDescriptor = [fontDescriptor fontDescriptorWithSymbolicTraits: UIFontDescriptorTraitBold];
font = [UIFont fontWithDescriptor: boldFontDescriptor size:0.0];
UIFontDescriptor *boldFontDescriptor = [fontDescriptor fontDescriptorWithSymbolicTraits:UIFontDescriptorTraitBold];
font = [UIFont fontWithDescriptor:boldFontDescriptor size:0.0];
} else {
font = [UIFont fontWithDescriptor:fontDescriptor size:0.0];
}

View file

@ -102,6 +102,19 @@
UIColor *textColor = [UIColor colorWithRed:0.3 green:0.3 blue:0.3 alpha:1.0];
UIFontDescriptor *fontDescriptor = [UIFontDescriptor preferredFontDescriptorWithTextStyle: UIFontTextStyleCaption1];
UIFontDescriptor *boldFontDescriptor = [fontDescriptor fontDescriptorWithSymbolicTraits: UIFontDescriptorTraitBold];
if (![userPreferences boolForKey:@"use_system_font_size"]) {
if ([[userPreferences stringForKey:@"feed_list_font_size"] isEqualToString:@"xs"]) {
boldFontDescriptor = [boldFontDescriptor fontDescriptorWithSize:10.0f];
} else if ([[userPreferences stringForKey:@"feed_list_font_size"] isEqualToString:@"small"]) {
boldFontDescriptor = [boldFontDescriptor fontDescriptorWithSize:11.0f];
} else if ([[userPreferences stringForKey:@"feed_list_font_size"] isEqualToString:@"medium"]) {
boldFontDescriptor = [boldFontDescriptor fontDescriptorWithSize:12.0f];
} else if ([[userPreferences stringForKey:@"feed_list_font_size"] isEqualToString:@"large"]) {
boldFontDescriptor = [boldFontDescriptor fontDescriptorWithSize:14.0f];
} else if ([[userPreferences stringForKey:@"feed_list_font_size"] isEqualToString:@"xl"]) {
boldFontDescriptor = [boldFontDescriptor fontDescriptorWithSize:16.0f];
}
}
UIFont *font = [UIFont fontWithDescriptor: boldFontDescriptor size:0.0];
NSInteger titleOffsetY = ((rect.size.height - font.pointSize) / 2) - 1;
NSString *folderTitle;

View file

@ -52,17 +52,17 @@
}
}
if([userPreferences stringForKey:@"fontSizing"]){
NSString *fontSize = [NSString stringWithFormat:@"%@", [userPreferences stringForKey:@"fontSizing"]];
if ([fontSize isEqualToString:@"NB-extra-small"]) {
if([userPreferences stringForKey:@"story_font_size"]){
NSString *fontSize = [userPreferences stringForKey:@"story_font_size"];
if ([fontSize isEqualToString:@"xs"]) {
[fontSizeSegment setSelectedSegmentIndex:0];
} else if ([fontSize isEqualToString:@"NB-small"]) {
} else if ([fontSize isEqualToString:@"small"]) {
[fontSizeSegment setSelectedSegmentIndex:1];
} else if ([fontSize isEqualToString:@"NB-medium"]) {
} else if ([fontSize isEqualToString:@"medium"]) {
[fontSizeSegment setSelectedSegmentIndex:2];
} else if ([fontSize isEqualToString:@"NB-large"]) {
} else if ([fontSize isEqualToString:@"large"]) {
[fontSizeSegment setSelectedSegmentIndex:3];
} else if ([fontSize isEqualToString:@"NB-extra-large"]) {
} else if ([fontSize isEqualToString:@"xl"]) {
[fontSizeSegment setSelectedSegmentIndex:4];
}
}
@ -94,20 +94,20 @@
- (IBAction)changeFontSize:(id)sender {
NSUserDefaults *userPreferences = [NSUserDefaults standardUserDefaults];
if ([sender selectedSegmentIndex] == 0) {
[appDelegate.storyPageControl changeFontSize:@"NB-extra-small"];
[userPreferences setObject:@"NB-extra-small" forKey:@"fontSizing"];
[appDelegate.storyPageControl changeFontSize:@"xs"];
[userPreferences setObject:@"xs" forKey:@"story_font_size"];
} else if ([sender selectedSegmentIndex] == 1) {
[appDelegate.storyPageControl changeFontSize:@"NB-small"];
[userPreferences setObject:@"NB-small" forKey:@"fontSizing"];
[appDelegate.storyPageControl changeFontSize:@"small"];
[userPreferences setObject:@"small" forKey:@"story_font_size"];
} else if ([sender selectedSegmentIndex] == 2) {
[appDelegate.storyPageControl changeFontSize:@"NB-medium"];
[userPreferences setObject:@"NB-medium" forKey:@"fontSizing"];
[appDelegate.storyPageControl changeFontSize:@"medium"];
[userPreferences setObject:@"medium" forKey:@"story_font_size"];
} else if ([sender selectedSegmentIndex] == 3) {
[appDelegate.storyPageControl changeFontSize:@"NB-large"];
[userPreferences setObject:@"NB-large" forKey:@"fontSizing"];
[appDelegate.storyPageControl changeFontSize:@"large"];
[userPreferences setObject:@"large" forKey:@"story_font_size"];
} else if ([sender selectedSegmentIndex] == 4) {
[appDelegate.storyPageControl changeFontSize:@"NB-extra-large"];
[userPreferences setObject:@"NB-extra-large" forKey:@"fontSizing"];
[appDelegate.storyPageControl changeFontSize:@"xl"];
[userPreferences setObject:@"xl" forKey:@"story_font_size"];
}
[userPreferences synchronize];
}

View file

@ -43,7 +43,8 @@
@class IASKAppSettingsViewController;
@class UnreadCounts;
@interface NewsBlurAppDelegate : BaseViewController <UIApplicationDelegate, UIAlertViewDelegate, UINavigationControllerDelegate> {
@interface NewsBlurAppDelegate : BaseViewController
<UIApplicationDelegate, UIAlertViewDelegate, UINavigationControllerDelegate> {
UIWindow *window;
UINavigationController *ftuxNavigationController;
UINavigationController *navigationController;

View file

@ -864,6 +864,7 @@ static UIFont *userLabelFont;
} else {
[appDelegate.navigationController dismissViewControllerAnimated:YES completion:nil];
}
[self.feedTitlesTable reloadData];
}
- (void)settingDidChange:(NSNotification*)notification {

View file

@ -130,7 +130,7 @@
NSString *sharingHtmlString;
NSString *footerString;
NSString *fontStyleClass = @"";
NSString *fontSizeClass = @"";
NSString *fontSizeClass = @"NB-";
NSString *storyContent = [self.activeStory objectForKey:@"story_content"];
NSUserDefaults *userPreferences = [NSUserDefaults standardUserDefaults];
@ -139,11 +139,7 @@
} else {
fontStyleClass = [fontStyleClass stringByAppendingString:@"NB-san-serif"];
}
if ([userPreferences stringForKey:@"fontSizing"]){
fontSizeClass = [fontSizeClass stringByAppendingString:[userPreferences stringForKey:@"fontSizing"]];
} else {
fontSizeClass = [fontSizeClass stringByAppendingString:@"NB-medium"];
}
fontSizeClass = [fontSizeClass stringByAppendingString:[userPreferences stringForKey:@"story_font_size"]];
int contentWidth = self.appDelegate.storyPageControl.view.frame.size.width;
NSString *contentWidthClass;
@ -1071,18 +1067,14 @@ shouldStartLoadWithRequest:(NSURLRequest *)request
- (void)webViewDidStartLoad:(UIWebView *)webView {
NSUserDefaults *userPreferences = [NSUserDefaults standardUserDefaults];
if ([userPreferences integerForKey:@"fontSizing"]){
[self changeFontSize:[userPreferences stringForKey:@"fontSizing"]];
}
[self changeFontSize:[userPreferences stringForKey:@"story_font_size"]];
}
- (void)webViewDidFinishLoad:(UIWebView *)webView {
[MBProgressHUD hideHUDForView:self.view animated:YES];
NSUserDefaults *userPreferences = [NSUserDefaults standardUserDefaults];
if ([userPreferences integerForKey:@"fontSizing"]){
[self changeFontSize:[userPreferences stringForKey:@"fontSizing"]];
}
[self changeFontSize:[userPreferences stringForKey:@"story_font_size"]];
if ([appDelegate.activeFeedStories count] &&
self.activeStoryId &&
@ -1138,7 +1130,7 @@ shouldStartLoadWithRequest:(NSURLRequest *)request
}
- (void)changeFontSize:(NSString *)fontSize {
NSString *jsString = [[NSString alloc] initWithFormat:@"document.getElementById('NB-font-size').setAttribute('class', '%@')",
NSString *jsString = [[NSString alloc] initWithFormat:@"document.getElementById('NB-font-size').setAttribute('class', 'NB-%@')",
fontSize];
[self.webView stringByEvaluatingJavaScriptFromString:jsString];

View file

@ -70,6 +70,74 @@
<key>Key</key>
<string>default_feed_read_filter</string>
</dict>
<dict>
<key>Title</key>
<string>Text Size</string>
<key>Type</key>
<string>PSGroupSpecifier</string>
</dict>
<dict>
<key>Type</key>
<string>PSToggleSwitchSpecifier</string>
<key>Title</key>
<string>Use system size</string>
<key>Key</key>
<string>use_system_font_size</string>
<key>DefaultValue</key>
<true/>
</dict>
<dict>
<key>Type</key>
<string>PSMultiValueSpecifier</string>
<key>Title</key>
<string>Feed and story list</string>
<key>Titles</key>
<array>
<string>Extra small</string>
<string>Small</string>
<string>Medium</string>
<string>Large</string>
<string>Extra Large</string>
</array>
<key>DefaultValue</key>
<string>medium</string>
<key>Values</key>
<array>
<string>xs</string>
<string>small</string>
<string>medium</string>
<string>large</string>
<string>xl</string>
</array>
<key>Key</key>
<string>feed_list_font_size</string>
</dict>
<dict>
<key>Type</key>
<string>PSMultiValueSpecifier</string>
<key>Title</key>
<string>Story detail</string>
<key>Titles</key>
<array>
<string>Extra small</string>
<string>Small</string>
<string>Medium</string>
<string>Large</string>
<string>Extra Large</string>
</array>
<key>DefaultValue</key>
<string>medium</string>
<key>Values</key>
<array>
<string>xs</string>
<string>small</string>
<string>medium</string>
<string>large</string>
<string>xl</string>
</array>
<key>Key</key>
<string>story_font_size</string>
</dict>
<dict>
<key>Title</key>
<string>Offline stories</string>

View file

@ -5,9 +5,9 @@
.NB-story {
line-height: 1.5em;
}
.NB-extra-small .NB-story,
.NB-extra-small .NB-story-comment,
.NB-extra-small .NB-header {
.NB-xs .NB-story,
.NB-xs .NB-story-comment,
.NB-xs .NB-header {
font-size: 12px;
}
@ -29,9 +29,9 @@
font-size: 15px;
}
.NB-extra-large .NB-story,
.NB-extra-large .NB-story-comment,
.NB-extra-large .NB-header {
.NB-xl .NB-story,
.NB-xl .NB-story-comment,
.NB-xl .NB-header {
font-size: 17px;
}
@ -212,7 +212,7 @@ body.NB-iphone {
background: transparent url("data:image/png;charset=utf-8;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACVElEQVQ4EXVTPW8TQRCd/XCM7QgF2QSnsYQbRGKgpA+QitY/IBUSrgAjQWW5oojocCTSRKJ1SRMpgCIhIVrERwlSmthnsBXLd7bPtzvM7HFgkDlrvbuz782+N7srEBHmv/395+tCQY2imwCiHK/hVwHwBg20trfvfJnHiyRBu91eGgU/dohYI4CaB82NDSVqLWfzD6vVashxl4DJQ//7S5pvcbB4YQ2KxTXIZDI8hfF4DJ3OCXS6J25OtMOzufxtTiI5cjrq7ViLW+l0GiqVq1AqlUBrDWEYusZjjvEaY6y1t5jDXLG392wDJX6gsapsXCHAGTA2YhAk9oQQIKUEJTVMpxP49PkjAEKECq9pC+YuWlCr51dBKQWTyRiM+U8CpZ2yQr4AXs/TIoKaNoibVBhYWTlH5AlE0YwUGECLtEl8QgLoJwUpUJQg5bBdrwuWTkqT1DIn4I/lRf/sHq+Q1182jDEuibMIUNZI+vkqTMOpk86AxHtCTnpOwsSIMNxT2pAVfCOll4LAd4ViciI9ISY9W2GitVPX0/xYgsHX7HcwGJAC45o1BFrQknXGuhpZeyStwV2L1gyHQ1fEeAfeZXHjQjOWOcxVBweHvXfv3xZI+nVeTKVSrmDOCtuZa3yx+v2+U0m2WvfvPXqh2d/oNKxnl/Xl2Wx20/M8yGazkMvl3JlzApbu+z4EQRCXA+GVP5rVefL7MTWbzaVMTtL1FPwSFz4mOm6DAnYnI1NvNBp/HlOcNv5/8rS5LlDW6Chu0H29SH1IxT8mX0cobOvxg8Zfz/knWROSyKoTDHAAAAAASUVORK5CYII=") no-repeat center center;
background-size: 8px;
}
.NB-extra-small .NB-story-unread {
.NB-xs .NB-story-unread {
margin-top: 4px;
}
.NB-small .NB-story-unread {
@ -221,7 +221,7 @@ body.NB-iphone {
.NB-large .NB-story-unread {
margin-top: 7px;
}
.NB-extra-large .NB-story-unread {
.NB-xl .NB-story-unread {
margin-top: 8px;
}
.NB-story-unread.NB-positive {