Skip to content
Closed
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
5 changes: 3 additions & 2 deletions WordPress/Classes/PostSettingsViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#import "CPopoverManager.h"
#import "PostAnnotation.h"
#import "UIImageView+AFNetworking.h"
#import "QuickPicturePreviewView.h"

// the amount of vertical shift upwards keep the text field in view as the keyboard appears
#define kOFFSET_FOR_KEYBOARD 150.0
Expand Down Expand Up @@ -46,7 +47,7 @@
NSString *address;
BOOL isUpdatingLocation, isUploadingFeaturedImage;
IBOutlet UILabel *visibilityTitleLabel, *statusTitleLabel, *postFormatTitleLabel, *featuredImageLabel;
IBOutlet UIImageView *featuredImageView;
IBOutlet QuickPicturePreviewView *featuredImageView;
IBOutlet UITableViewCell *featuredImageTableViewCell;
IBOutlet UIActivityIndicatorView *featuredImageSpinner;
}
Expand All @@ -55,11 +56,11 @@
@property (nonatomic, strong) IBOutlet UITableViewCell *postFormatTableViewCell;

- (id)initWithPost:(AbstractPost *)aPost;

- (void)reloadData;
- (void)endEditingAction:(id)sender;
- (UITableViewCell*) getGeolactionCellWithIndexPath: (NSIndexPath*)indexPath;
- (void)featuredImageUploadFailed: (NSNotification *)notificationInfo;
- (void)featuredImageUploadSucceeded: (NSNotification *)notificationInfo;
- (void)showFeaturedImageUploader: (NSNotification *)notificationInfo;

@end
53 changes: 43 additions & 10 deletions WordPress/Classes/PostSettingsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ @interface PostSettingsViewController () {
}

@property (nonatomic, strong) AbstractPost *apost;

- (void)showPicker:(UIView *)picker;
- (void)geocodeCoordinate:(CLLocationCoordinate2D)c;
- (void)geolocationCellTapped:(NSIndexPath *)indexPath;
Expand All @@ -27,6 +28,7 @@ - (void)loadFeaturedImage:(NSURL *)imageURL;
@end

@implementation PostSettingsViewController

@synthesize postDetailViewController, postFormatTableViewCell;

#pragma mark -
Expand Down Expand Up @@ -61,7 +63,9 @@ - (void)viewDidLoad {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showFeaturedImageUploader:) name:@"UploadingFeaturedImage" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(featuredImageUploadSucceeded:) name:FeaturedImageUploadSuccessful object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(featuredImageUploadFailed:) name:FeaturedImageUploadFailed object:nil];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationWillChange:) name:UIApplicationWillChangeStatusBarOrientationNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationDidChange:) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];

[tableView setBackgroundView:nil];
[tableView setBackgroundColor:[UIColor clearColor]]; //Fix for black corners on iOS4. http://stackoverflow.com/questions/1557856/black-corners-on-uitableview-group-style
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"settings_bg"]];
Expand Down Expand Up @@ -111,12 +115,12 @@ - (void)viewDidLoad {
[locationManager startUpdatingLocation];
}
}

featuredImageView.layer.shadowOffset = CGSizeMake(0.0, 1.0f);
featuredImageView.layer.shadowColor = [[UIColor blackColor] CGColor];
featuredImageView.layer.shadowOpacity = 0.5f;
featuredImageView.layer.shadowRadius = 1.0f;

// Check if blog supports featured images
id supportsFeaturedImages = [self.post.blog getOptionValue:@"post_thumbnail"];
if (supportsFeaturedImages != nil) {
Expand All @@ -129,7 +133,7 @@ - (void)viewDidLoad {
[featuredImageSpinner setHidden:NO];
if (!featuredImageSpinner.isAnimating)
[featuredImageSpinner startAnimating];
[tableView reloadData];
[self reloadData];

[self.post getFeaturedImageURLWithSuccess:^{
if (self.post.featuredImageURL) {
Expand Down Expand Up @@ -186,6 +190,10 @@ - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}

- (void)viewDidLayoutSubviews {
[featuredImageView orientationDidChange:nil];
}

#pragma mark -
#pragma mark Rotation Methods

Expand All @@ -195,9 +203,18 @@ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interface
}

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
[featuredImageView setupForOrientation:fromInterfaceOrientation];
[self reloadData];
}

- (void)orientationWillChange:(NSNotification *)notification {
[featuredImageView orientationWillChange:notification];
}

- (void)orientationDidChange:(NSNotification *)notification {
[featuredImageView orientationDidChange:notification];
[self reloadData];
}

#pragma mark -
#pragma mark Instance Methods
Expand All @@ -220,7 +237,7 @@ - (void)loadFeaturedImage:(NSURL *)imageURL {
[featuredImageSpinner stopAnimating];
[featuredImageSpinner setHidden:YES];
[featuredImageLabel setHidden:YES];

[self reloadData];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
// private blog, auth needed.
if (operation.response.statusCode == 403) {
Expand Down Expand Up @@ -282,7 +299,7 @@ - (void)endEditingForTextFieldAction:(id)sender {

- (void)reloadData {
passwordTextField.text = self.apost.password;
[featuredImageView setBorderAndClipShowing:NO];
[tableView reloadData];
}

Expand Down Expand Up @@ -610,10 +627,26 @@ - (UITableViewCell*) getGeolactionCellWithIndexPath: (NSIndexPath*)indexPath {
return nil;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if ((indexPath.section == 0) && (indexPath.row == 1) && (self.apost.password))
- (CGFloat)tableView:(UITableView *)tblView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if ((indexPath.section == 0) && (indexPath.row == 1) && (self.apost.password)) {
return 88.f;
else if (
} else if (blogSupportsFeaturedImage && self.post.post_thumbnail && featuredImageView.image && indexPath.section == 2 && indexPath.row == 0) {
// find a suitable size for the featured image preview
CGRect topBounds = tblView.bounds;
CGFloat fillWidth = topBounds.size.width * 0.85f;
CGFloat fillHeight = featuredImageView.image.size.height / featuredImageView.image.size.width * fillWidth;
CGSize size = [UIScreen mainScreen].bounds.size;
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
if (UIInterfaceOrientationIsLandscape(orientation))
{
size = CGSizeMake(size.height, size.width);
}
if (fillHeight > size.height * 0.85f) {
return size.height * 0.85f;
} else {
return fillHeight;
}
} else if (
(!blogSupportsFeaturedImage && (indexPath.section == 2) && (indexPath.row == 1))
|| (blogSupportsFeaturedImage && (self.post.post_thumbnail || isUploadingFeaturedImage) && indexPath.section == 2 && indexPath.row == 0)
|| (blogSupportsFeaturedImage && (indexPath.section == 3) && (indexPath.row == 1))
Expand Down Expand Up @@ -683,7 +716,7 @@ - (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath
break;
case 1:
actionSheet = [[UIActionSheet alloc] initWithTitle:NSLocalizedString(@"Remove this Featured Image?", @"Prompt when removing a featured image from a post") delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", "Cancel a prompt") destructiveButtonTitle:NSLocalizedString(@"Remove", @"Remove an image/posts/etc") otherButtonTitles:nil];
[actionSheet showFromRect:cell.frame inView:postDetailViewController.view animated:YES];
[actionSheet showFromRect:cell.frame inView:tableView animated:YES];
break;
}
} else {
Expand Down
18 changes: 15 additions & 3 deletions WordPress/Classes/QuickPhotoViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ - (void)dealloc {
[FileLogger log:@"%@ %@", self, NSStringFromSelector(_cmd)];
self.photoImageView.delegate = nil;
self.popController.delegate = nil;
[[NSNotificationCenter defaultCenter] removeObserver:self];
}

#if !__has_feature(objc_arc)
Expand Down Expand Up @@ -96,6 +97,8 @@ - (void)viewDidLoad {

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleKeyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleKeyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationWillChange:) name:UIApplicationWillChangeStatusBarOrientationNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationDidChange:) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];
}

- (void)viewDidAppear:(BOOL)animated {
Expand Down Expand Up @@ -143,7 +146,7 @@ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interface

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
[super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];

if (self.popController) {
showPickerAfterRotation = YES;
[popController dismissPopoverAnimated:NO];
Expand All @@ -153,13 +156,21 @@ - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrie

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
[super didRotateFromInterfaceOrientation:fromInterfaceOrientation];

if (showPickerAfterRotation) {
showPickerAfterRotation = NO;
[self showPicker];
}
}

- (void)orientationWillChange:(NSNotification *)notification {
[photoImageView orientationWillChange:notification];
}

- (void)orientationDidChange:(NSNotification *)notification {
[photoImageView orientationDidChange:notification];
}


#pragma mark -
#pragma mark Custom methods
Expand Down Expand Up @@ -323,6 +334,8 @@ - (void)imagePickerController:(UIImagePickerController *)picker didFinishPicking

self.photo = (UIImage *)[info objectForKey:UIImagePickerControllerOriginalImage];
self.photoImageView.image = self.photo;
self.photoImageView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
self.photoImageView.frame = CGRectMake(self.view.frame.size.width-150, 0, 150, 150);

if (![self isViewLoaded]) {
// If we get a memory warning on the way here our view could have unloaded.
Expand Down Expand Up @@ -368,7 +381,6 @@ - (void)blogSelectorButtonDidBecomeInactive:(BlogSelectorButton *)button {
- (void)pictureWillZoom {
[self.titleTextField resignFirstResponder];
[self.contentTextView resignFirstResponder];
[self.view bringSubviewToFront:photoImageView];
}

- (void)pictureDidRestore {
Expand Down
14 changes: 12 additions & 2 deletions WordPress/Classes/QuickPicturePreviewView.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,25 @@

@end

@interface QuickPicturePreviewView : UIView {
UIImageView *imageView, *paperClipImageView;
@interface QuickPicturePreviewView : UIView <UIScrollViewDelegate> {
UIView *backgroundView;
UIScrollView *scrollView;
UIImageView *imageView, *paperClipImageView, *zoomView;
CALayer *frameLayer;
BOOL zoomed;
BOOL zooming;
BOOL hasBorderAndClip;
CGRect normalFrame, normalImageFrame;
CGRect originalFrame;
}

@property (nonatomic, strong) UIImage *image;
@property (nonatomic, weak) IBOutlet id<QuickPicturePreviewViewDelegate> delegate;
@property (nonatomic, assign) BOOL zoomed;

- (void)setupForOrientation:(UIInterfaceOrientation)orientation;
- (void)setBorderAndClipShowing:(BOOL)visible;
- (void)orientationWillChange:(NSNotification *)note;
- (void)orientationDidChange:(NSNotification *)note;

@end
Loading