[ios] Bug fixies

This commit is contained in:
Igor Khmurets 2014-05-30 18:51:20 +03:00 committed by Alex Zolotarev
parent 9e5e4a0312
commit fc7c42fd8b
12 changed files with 117 additions and 64 deletions

View file

@ -64,3 +64,8 @@
@interface SolidTouchView : UIView
@end
@interface SolidTouchViewImageView : UIImageView
@end

View file

@ -225,3 +225,16 @@
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {}
@end
@implementation SolidTouchViewImageView
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {}
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {}
@end

View file

@ -17,7 +17,7 @@
self.backgroundColor = [UIColor clearColor];
UIView * highlightView = [[UIView alloc] initWithFrame:self.bounds];
highlightView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.25];
highlightView.backgroundColor = [UIColor colorWithColorCode:@"15d081"];
self.selectedBackgroundView = highlightView;
[self.contentView addSubview:self.titleLabel];

View file

@ -6,4 +6,5 @@
#define BOOKMARK_CATEGORY_DELETED_NOTIFICATION @"BookmarkCategoryDeletedNotification"
#define METRICS_CHANGED_NOTIFICATION @"MetricsChangedNotification"
#define BOOKMARK_DELETED_NOTIFICATION @"BookmarkDeletedNotification"
#define BOOKMARK_DELETED_NOTIFICATION @"BookmarkDeletedNotification"
#define LOCATION_MANAGER_STARTED_NOTIFICATION @"LocationManagerStartedNotification"

View file

@ -3,8 +3,6 @@
#import "EAGLView.h"
#import "BookmarksRootVC.h"
#import "PlacePageVC.h"
#import "PlacePreviewViewController.h"
#import "MWMApi.h"
#import "UIKitCategories.h"
#import "SettingsViewController.h"
#import "UIViewController+Navigation.h"
@ -180,6 +178,7 @@ const long long LITE_IDL = 431183278L;
[[MapsAppDelegate theApp] disableStandby];
[[MapsAppDelegate theApp].m_locationManager start:self];
[[NSNotificationCenter defaultCenter] postNotificationName:LOCATION_MANAGER_STARTED_NOTIFICATION object:nil];
return;
}
@ -767,7 +766,8 @@ const long long LITE_IDL = 431183278L;
- (void)backToApiApp:(id)sender
{
[[UIApplication sharedApplication] openURL:[[self class] getBackUrl]];
NSURL * url = [NSURL URLWithString:[NSString stringWithUTF8String:GetFramework().GetApiDataHolder().GetGlobalBackUrl().c_str()]];
[[UIApplication sharedApplication] openURL:url];
}
- (void)toolbar:(ToolbarView *)toolbar didPressItemWithName:(NSString *)itemName
@ -1071,11 +1071,6 @@ const long long LITE_IDL = 431183278L;
_apiMode = apiMode;
}
+ (NSURL *)getBackUrl
{
return [NSURL URLWithString:[NSString stringWithUTF8String:GetFramework().GetApiDataHolder().GetGlobalBackUrl().c_str()]];
}
- (void)setupMeasurementSystem
{
GetFramework().SetupMeasurementSystem();

View file

@ -43,6 +43,7 @@
_priceButton.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
_priceButton.titleLabel.font = [UIFont fontWithName:@"HelveticaNeue-Medium" size:12.5];
_priceButton.userInteractionEnabled = NO;
_priceButton.contentEdgeInsets = UIEdgeInsetsMake(0, 1, 0, 0);
[_priceButton setBackgroundImage:image forState:UIControlStateNormal];
[_priceButton setTitleColor:[UIColor colorWithColorCode:@"007aff"] forState:UIControlStateNormal];
}

View file

@ -36,11 +36,16 @@
[self addSubview:self.selectedColorView];
[self addSubview:self.separatorView];
[[MapsAppDelegate theApp].m_locationManager start:self];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(startMonitoringLocation:) name:LOCATION_MANAGER_STARTED_NOTIFICATION object:nil];
return self;
}
- (void)startMonitoringLocation:(NSNotification *)notification
{
[[MapsAppDelegate theApp].m_locationManager start:self];
}
- (NSString *)distance
{
CLLocation * location = [MapsAppDelegate theApp].m_locationManager.lastLocation;
@ -237,6 +242,7 @@
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
[[MapsAppDelegate theApp].m_locationManager stop:self];
}

View file

@ -34,6 +34,8 @@ typedef NS_ENUM(NSUInteger, CellRow)
@property (nonatomic) UIImageView * arrowImageView;
@property (nonatomic) UIView * pickerView;
@property (nonatomic) UIView * swipeView;
@property (nonatomic) NSString * title;
@property (nonatomic) NSString * types;
@property (nonatomic) NSString * address;
@ -58,7 +60,6 @@ typedef NS_ENUM(NSUInteger, CellRow)
self = [super initWithFrame:frame];
self.autoresizingMask = UIViewAutoresizingFlexibleWidth;
self.clipsToBounds = YES;
self.statusBarIncluded = !SYSTEM_VERSION_IS_LESS_THAN(@"7");
m_mark = NULL;
m_cachedMark = NULL;
@ -76,6 +77,7 @@ typedef NS_ENUM(NSUInteger, CellRow)
[self addSubview:self.tableView];
[self addSubview:self.headerView];
[self addSubview:self.arrowImageView];
[self addSubview:self.swipeView];
NSNotificationCenter * nc = [NSNotificationCenter defaultCenter];
[nc addObserver:self selector:@selector(bookmarkDeletedNotification:) name:BOOKMARK_DELETED_NOTIFICATION object:nil];
@ -86,16 +88,21 @@ typedef NS_ENUM(NSUInteger, CellRow)
[self.tableView registerClass:[PlacePageEditCell class] forCellReuseIdentifier:[PlacePageEditCell className]];
[self.tableView registerClass:[PlacePageShareCell class] forCellReuseIdentifier:[PlacePageShareCell className]];
[[MapsAppDelegate theApp].m_locationManager start:self];
CGFloat const defaultHeight = 93;
[self updateHeight:defaultHeight];
updatingTable = NO;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(startMonitoringLocation:) name:LOCATION_MANAGER_STARTED_NOTIFICATION object:nil];
return self;
}
- (void)startMonitoringLocation:(NSNotification *)notification
{
[[MapsAppDelegate theApp].m_locationManager start:self];
}
- (void)onLocationError:(location::TLocationError)errorCode
{
NSLog(@"Location error %i in %@", errorCode, [[self class] className]);
@ -217,12 +224,12 @@ typedef NS_ENUM(NSUInteger, CellRow)
- (CGFloat)titleWidth
{
return self.width - 94;
return self.width - 90;
}
- (CGFloat)typesWidth
{
return self.width - 94;
return self.width - 90;
}
- (CGFloat)headerHeight
@ -264,6 +271,7 @@ typedef NS_ENUM(NSUInteger, CellRow)
// [self reloadHeader];
// [self alignAnimated:YES];
// self.tableView.contentInset = UIEdgeInsetsMake([self headerHeight], 0, 0, 0);
self.swipeView.frame = self.bounds;
}
}
@ -289,7 +297,7 @@ typedef NS_ENUM(NSUInteger, CellRow)
[UIView animateWithDuration:(animated ? 0.4 : 0) delay:0 damping:damping initialVelocity:0 options:options animations:^{
self.arrowImageView.alpha = 1;
[self updateHeight:[self headerHeight]];
self.minY = self.statusBarIncluded ? 0 : -20;
self.minY = self.statusBarIncluded ? (SYSTEM_VERSION_IS_LESS_THAN(@"7") ? -20 : 0) : -20;
self.headerSeparator.alpha = 0;
} completion:nil];
}
@ -307,7 +315,7 @@ typedef NS_ENUM(NSUInteger, CellRow)
[UIView animateWithDuration:(animated ? 0.4 : 0) delay:0 damping:damping initialVelocity:0 options:options animations:^{
self.arrowImageView.alpha = 0;
[self updateHeight:fullHeight];
self.minY = self.statusBarIncluded ? 0 : -20;
self.minY = self.statusBarIncluded ? (SYSTEM_VERSION_IS_LESS_THAN(@"7") ? -20 : 0) : -20;
self.headerSeparator.alpha = 1;
} completion:^(BOOL finished){
}];
@ -393,9 +401,20 @@ typedef NS_ENUM(NSUInteger, CellRow)
[self.tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:ROW_COMMON inSection:0]] withRowAnimation:UITableViewRowAnimationNone];
}
- (void)abortBookmarkState
{
Framework & framework = GetFramework();
m_mark = [self cachedMark];
framework.ActivateUserMark(m_mark);
[self clearCachedProperties];
[self reloadHeader];
[self updateBookmarkStateAnimated:NO];
[self updateBookmarkViewsAlpha:NO];
}
- (void)bookmarkCategoryDeletedNotification:(NSNotification *)notification
{
#warning <#message#>
if (m_categoryIndex == [[notification object] integerValue])
[self abortBookmarkState];
}
@ -408,18 +427,6 @@ typedef NS_ENUM(NSUInteger, CellRow)
[self abortBookmarkState];
}
- (void)abortBookmarkState
{
Framework & framework = GetFramework();
m_mark = m_cachedMark != NULL ? m_cachedMark : framework.GetAddressMark([self pinPoint]);
framework.ActivateUserMark(m_mark);
[self clearCachedProperties];
[self reloadHeader];
[self updateBookmarkStateAnimated:NO];
[self updateBookmarkViewsAlpha:NO];
}
- (void)swipe:(UISwipeGestureRecognizer *)sender
{
if (sender.direction == UISwipeGestureRecognizerDirectionUp)
@ -740,12 +747,17 @@ typedef NS_ENUM(NSUInteger, CellRow)
return iconImage;
}
- (UserMark const *)cachedMark
{
return (m_cachedMark != NULL) ? m_cachedMark : GetFramework().GetAddressMark([self pinPoint]);
}
- (void)deleteBookmark
{
Framework & framework = GetFramework();
BookmarkAndCategory const & bookmarkAndCategory = framework.FindBookmark(m_mark);
BookmarkCategory * category = framework.GetBmCategory(bookmarkAndCategory.first);
m_mark = m_cachedMark != NULL ? m_cachedMark : framework.GetAddressMark([self pinPoint]);
m_mark = [self cachedMark];
framework.ActivateUserMark(m_mark);
if (category)
{
@ -808,13 +820,22 @@ typedef NS_ENUM(NSUInteger, CellRow)
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
UIScrollView * sv = scrollView;
if ((sv.contentOffset.y + sv.height > sv.contentSize.height + 60) && !sv.dragging && sv.decelerating)
if ((sv.contentOffset.y + sv.height > sv.contentSize.height + 70) && !sv.dragging && sv.decelerating)
{
if (self.state == PlacePageStateOpened)
[self setState:PlacePageStatePreview animated:YES withCallback:YES];
}
}
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset
{
NSLog(@"%f %f", scrollView.contentSize.height, scrollView.height);
if (scrollView.contentSize.height <= scrollView.height && (*targetContentOffset).y <= scrollView.contentOffset.y)
{
[self setState:PlacePageStateHidden animated:YES withCallback:YES];
}
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex != alertView.cancelButtonIndex)
@ -926,7 +947,6 @@ typedef NS_ENUM(NSUInteger, CellRow)
_tableView.dataSource = self;
_tableView.backgroundColor = [UIColor clearColor];
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
_tableView.alwaysBounceVertical = NO;
}
return _tableView;
}

View file

@ -1,5 +1,6 @@
#import <UIKit/UIKit.h>
#import "UIKitCategories.h"
@class SearchBar;
@protocol SearchBarDelegate <NSObject>
@ -14,7 +15,7 @@
@property (nonatomic, readonly) UITextField * textField;
@property (nonatomic, readonly) UIButton * clearButton;
@property (nonatomic, readonly) UIButton * cancelButton;
@property (nonatomic, readonly) UIImageView * fieldBackgroundView;
@property (nonatomic, readonly) SolidTouchViewImageView * fieldBackgroundView;
@property (nonatomic, weak) id <SearchBarDelegate> delegate;

View file

@ -1,6 +1,5 @@
#import "SearchBar.h"
#import "UIKitCategories.h"
#import "Framework.h"
@interface SearchBar ()
@ -8,7 +7,7 @@
@property (nonatomic) UITextField * textField;
@property (nonatomic) UIButton * clearButton;
@property (nonatomic) UIButton * cancelButton;
@property (nonatomic) UIImageView * fieldBackgroundView;
@property (nonatomic) SolidTouchViewImageView * fieldBackgroundView;
@end
@ -68,7 +67,7 @@
_cancelButton.titleLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:15];
_cancelButton.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleBottomMargin;
[_cancelButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[_cancelButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateHighlighted];
[_cancelButton setTitleColor:[UIColor colorWithWhite:1 alpha:0.5] forState:UIControlStateHighlighted];
[_cancelButton setTitle:@"cancel" forState:UIControlStateNormal];
[_cancelButton addTarget:self action:@selector(cancelButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
}
@ -88,12 +87,12 @@
return _clearButton;
}
- (UIImageView *)fieldBackgroundView
- (SolidTouchViewImageView *)fieldBackgroundView
{
if (!_fieldBackgroundView)
{
UIImage * image = [[UIImage imageNamed:@"SearchFieldBackground"] resizableImageWithCapInsets:UIEdgeInsetsMake(6, 6, 6, 6)];
_fieldBackgroundView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 0, image.size.height)];
_fieldBackgroundView = [[SolidTouchViewImageView alloc] initWithFrame:CGRectMake(0, 0, 0, image.size.height)];
_fieldBackgroundView.image = image;
_fieldBackgroundView.userInteractionEnabled = YES;
_fieldBackgroundView.autoresizingMask = UIViewAutoresizingFlexibleWidth;

View file

@ -88,7 +88,7 @@
@interface SearchView () <UITextFieldDelegate, UITableViewDelegate, UITableViewDataSource, SearchBarDelegate, LocationObserver, UIAlertViewDelegate>
@property (nonatomic) UITableView * tableView;
@property (nonatomic) UIImageView * topBackgroundView;
@property (nonatomic) SolidTouchViewImageView * topBackgroundView;
@property (nonatomic) UILabel * emptyResultLabel;
- (BOOL)isShowingCategories;
@ -125,21 +125,25 @@ __weak SearchView * selfPointer;
double latitude;
double longitude;
LocationManager * locationManager = [MapsAppDelegate theApp].m_locationManager;
bool const hasPt = [locationManager getLat:latitude Lon:longitude];
bool const hasPt = [[MapsAppDelegate theApp].m_locationManager getLat:latitude Lon:longitude];
GetFramework().PrepareSearch(hasPt, latitude, longitude);
[locationManager start:self];
[self addObserver:self forKeyPath:@"state" options:NSKeyValueObservingOptionNew context:nil];
needToScroll = NO;
[self.tableView registerClass:[SearchUniversalCell class] forCellReuseIdentifier:[SearchUniversalCell className]];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(startMonitoringLocation:) name:LOCATION_MANAGER_STARTED_NOTIFICATION object:nil];
return self;
}
- (void)startMonitoringLocation:(NSNotification *)notification
{
[[MapsAppDelegate theApp].m_locationManager start:self];
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
if (object == self && [keyPath isEqualToString:@"state"])
@ -177,6 +181,7 @@ __weak SearchView * selfPointer;
self.searchBar.alpha = 1;
self.searchBar.fieldBackgroundView.frame = fieldBackgroundFrame;
self.searchBar.textField.frame = textFieldFrame;
[self.searchBar.clearButton setImage:[UIImage imageNamed:@"SearchBarClearButton"] forState:UIControlStateNormal];
} completion:^(BOOL finished){
if (needToScroll)
{
@ -196,6 +201,7 @@ __weak SearchView * selfPointer;
self.tableView.alpha = 0;
self.searchBar.fieldBackgroundView.frame = shiftedFieldBackgroundFrame;
self.searchBar.textField.frame = shiftedTextFieldFrame;
[self.searchBar.clearButton setImage:[UIImage imageNamed:@"SearchBarClearResultsButton"] forState:UIControlStateNormal];
} completion:nil];
}
else if (state == SearchViewStateHidden)
@ -209,6 +215,7 @@ __weak SearchView * selfPointer;
self.tableView.alpha = 0;
self.searchBar.fieldBackgroundView.frame = fieldBackgroundFrame;
self.searchBar.textField.frame = textFieldFrame;
[self.searchBar.clearButton setImage:[UIImage imageNamed:@"SearchBarClearButton"] forState:UIControlStateNormal];
} completion:nil];
}
else if (state == SearchViewStateAlpha)
@ -263,11 +270,6 @@ __weak SearchView * selfPointer;
}
}
- (void)onCompassUpdate:(location::CompassInfo const &)info
{
}
- (search::SearchParams)searchParameters
{
search::SearchParams params;
@ -318,15 +320,20 @@ static void OnSearchResultCallback(search::Results const & results)
}
}
- (void)clearSearchResultsMode
{
Framework & framework = GetFramework();
framework.GetBalloonManager().RemovePin();
framework.GetBalloonManager().Dismiss();
framework.GetBookmarkManager().UserMarksClear(UserMarkContainer::SEARCH_MARK);
framework.Invalidate();
}
- (void)searchBarDidPressClearButton:(SearchBar *)searchBar
{
if (self.state == SearchViewStateResults)
{
Framework & framework = GetFramework();
framework.GetBalloonManager().RemovePin();
framework.GetBalloonManager().Dismiss();
framework.GetBookmarkManager().UserMarksClear(UserMarkContainer::SEARCH_MARK);
framework.Invalidate();
[self clearSearchResultsMode];
[self setState:SearchViewStateHidden animated:YES withCallback:YES];
}
else
@ -353,6 +360,8 @@ static void OnSearchResultCallback(search::Results const & results)
- (void)textFieldBegin:(id)sender
{
if (self.state == SearchViewStateResults)
[self clearSearchResultsMode];
[self setState:SearchViewStateFullscreen animated:YES withCallback:YES];
}
@ -373,13 +382,12 @@ static void OnSearchResultCallback(search::Results const & results)
{
if ([self.wrapper count] && ![self isShowingCategories])
{
GetFramework().ShowAllSearchResults();
if (!GetFramework().ShowAllSearchResults())
{
ToastView * toastView = [[ToastView alloc] initWithMessage:NSLocalizedString(@"Sorry, but we could not find anything. Download any map and try again", nil)];
[toastView show];
}
[self setState:SearchViewStateResults animated:YES withCallback:YES];
#warning Change text
ToastView * toastView = [[ToastView alloc] initWithMessage:@"Sorry, but we could not find anything. Download any map and try again"];
[toastView show];
return YES;
}
return NO;
@ -616,11 +624,11 @@ static void OnSearchResultCallback(search::Results const & results)
return _tableView;
}
- (UIImageView *)topBackgroundView
- (SolidTouchViewImageView *)topBackgroundView
{
if (!_topBackgroundView)
{
_topBackgroundView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.width, 0)];
_topBackgroundView = [[SolidTouchViewImageView alloc] initWithFrame:CGRectMake(0, 0, self.width, 0)];
_topBackgroundView.image = [[UIImage imageNamed:@"SearchViewTopBackground"] resizableImageWithCapInsets:UIEdgeInsetsMake(10, 0, 10, 0) resizingMode:UIImageResizingModeStretch];
_topBackgroundView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
_topBackgroundView.userInteractionEnabled = YES;
@ -657,4 +665,9 @@ static void OnSearchResultCallback(search::Results const & results)
return _emptyResultLabel;
}
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
@end

View file

@ -11,7 +11,6 @@
@implementation ToastView
- (id)initWithMessage:(NSString *)message
{
CGFloat const xOffset = 18;