Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/iphone
diff options
context:
space:
mode:
authorKirill Zhdanovich <kzhdanovich@gmail.com>2013-03-20 11:03:38 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:52:04 +0300
commiteaa62b1d27a8e1a6c61ededd41046d02f1393a3d (patch)
tree4f80bed02d3321ceb1bc7e4d475cb35464da4120 /iphone
parentdae5129316eee833c4c024721223e0eff2233dfc (diff)
[iOS]Fixes for new bookmark's logic
Diffstat (limited to 'iphone')
-rw-r--r--iphone/Maps/Bookmarks/AddSetVC.mm7
-rw-r--r--iphone/Maps/Bookmarks/BalloonView.h2
-rw-r--r--iphone/Maps/Bookmarks/BalloonView.mm19
-rw-r--r--iphone/Maps/Bookmarks/BookmarksVC.mm1
-rw-r--r--iphone/Maps/Bookmarks/SelectSetVC.mm63
-rw-r--r--iphone/Maps/Classes/MapViewController.mm6
6 files changed, 32 insertions, 66 deletions
diff --git a/iphone/Maps/Bookmarks/AddSetVC.mm b/iphone/Maps/Bookmarks/AddSetVC.mm
index 2169a4f4f6..692481bd67 100644
--- a/iphone/Maps/Bookmarks/AddSetVC.mm
+++ b/iphone/Maps/Bookmarks/AddSetVC.mm
@@ -31,8 +31,11 @@
if (text.length)
{
m_balloon.setName = text;
- // Create category if it doesn't exist
- (void)GetFramework().GetBmCategory([text UTF8String]);
+ [m_balloon deleteBookmark];
+
+ Framework &f = GetFramework();
+ size_t pos = f.AddCategory([text UTF8String]);
+ [m_balloon addBookmarkToCategory:pos];
// Show Place Page dialog with new set selected
[self onCancelClicked];
diff --git a/iphone/Maps/Bookmarks/BalloonView.h b/iphone/Maps/Bookmarks/BalloonView.h
index 88c80dec87..f357b682d5 100644
--- a/iphone/Maps/Bookmarks/BalloonView.h
+++ b/iphone/Maps/Bookmarks/BalloonView.h
@@ -38,4 +38,6 @@
// and does nothing if called for "new", not added bookmark
- (void) deleteBookmark;
+- (void) addBookmarkToCategory:(size_t)index;
+
@end
diff --git a/iphone/Maps/Bookmarks/BalloonView.mm b/iphone/Maps/Bookmarks/BalloonView.mm
index 915ab452e6..23ece1fb1e 100644
--- a/iphone/Maps/Bookmarks/BalloonView.mm
+++ b/iphone/Maps/Bookmarks/BalloonView.mm
@@ -223,11 +223,12 @@
- (void) addOrEditBookmark
{
- // If coordinates are be the same, bookmark is automatically replaced
- Bookmark bm(m2::PointD(self.globalPosition.x, self.globalPosition.y),
- [self.title UTF8String], [self.color UTF8String]);
+ Framework &f = GetFramework();
+ Bookmark bm(m2::PointD(globalPosition.x, globalPosition.y),
+ [title UTF8String], [color UTF8String]);
+ f.GetBmCategory(editedBookmark.first)->ReplaceBookmark(editedBookmark.second, bm);
- BookmarkCategory * cat = GetFramework().AddBookmark([self.setName UTF8String], bm);
+ BookmarkCategory * cat = f.GetBmCategory(editedBookmark.first);
// Enable category visibility if it was turned off, so user can see newly added or edited bookmark
if (!cat->IsVisible())
@@ -252,4 +253,14 @@
}
}
+- (void) addBookmarkToCategory:(size_t)index
+{
+ Framework &f = GetFramework();
+ Bookmark bm(m2::PointD(globalPosition.x, globalPosition.y),
+ [title UTF8String], [color UTF8String]);
+ size_t newPosition = f.AddBookmark(index, bm);
+ self.editedBookmark = pair <int, int> (index, newPosition);
+ self.setName = [NSString stringWithUTF8String:f.GetBmCategory(index)->GetName().c_str()];
+}
+
@end
diff --git a/iphone/Maps/Bookmarks/BookmarksVC.mm b/iphone/Maps/Bookmarks/BookmarksVC.mm
index 0a2fe3376f..f8506cd068 100644
--- a/iphone/Maps/Bookmarks/BookmarksVC.mm
+++ b/iphone/Maps/Bookmarks/BookmarksVC.mm
@@ -2,7 +2,6 @@
#import "CustomNavigationView.h"
#import "BalloonView.h"
#import "MapsAppDelegate.h"
-#import "SelectSetVC.h"
#import "CompassView.h"
#import "BookmarkCell.h"
#import "MapViewController.h"
diff --git a/iphone/Maps/Bookmarks/SelectSetVC.mm b/iphone/Maps/Bookmarks/SelectSetVC.mm
index dc3e1db930..0fc3fa9cca 100644
--- a/iphone/Maps/Bookmarks/SelectSetVC.mm
+++ b/iphone/Maps/Bookmarks/SelectSetVC.mm
@@ -11,26 +11,12 @@
if (self)
{
m_balloon = view;
-
- // Always autocreate bookmark category if it's absent
- GetFramework().GetBmCategory([m_balloon.setName UTF8String]);
self.title = NSLocalizedString(@"bookmark_sets", @"Bookmark Sets dialog title");
}
return self;
}
-- (void)viewWillAppear:(BOOL)animated
-{
- // Do not show Edit button if we have only one bookmarks set
- if (GetFramework().GetBmCategoriesCount() > 1)
- self.navigationItem.rightBarButtonItem = self.editButtonItem;
- else
- self.navigationItem.rightBarButtonItem = nil;
-
- [super viewWillAppear:animated];
-}
-
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
@@ -68,7 +54,7 @@
if (cat)
cell.textLabel.text = [NSString stringWithUTF8String:cat->GetName().c_str()];
- if ([m_balloon.setName isEqualToString:cell.textLabel.text])
+ if (m_balloon.editedBookmark.first == indexPath.row)
cell.accessoryType = UITableViewCellAccessoryCheckmark;
else
cell.accessoryType = UITableViewCellAccessoryNone;
@@ -91,51 +77,10 @@
}
else
{
- if (![m_balloon.setName isEqualToString:cell.textLabel.text])
- m_balloon.setName = cell.textLabel.text;
- [self.navigationController popViewControllerAnimated:YES];
- }
-}
+ [m_balloon deleteBookmark];
+ [m_balloon addBookmarkToCategory:indexPath.row];
-- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
-{
- // Return NO if you do not want the specified item to be editable.
- if (indexPath.section == 0)
- return NO;
- // Disable deleting of the last remaining set (can be activated by swipe right on a set item)
- if (GetFramework().GetBmCategoriesCount() > 1)
- return YES;
- return NO;
-}
-
-- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
-{
- if (indexPath.section == 1)
- {
- if (editingStyle == UITableViewCellEditingStyleDelete)
- {
- // Move checkmark to another category if we're deleting the checked one
- Framework & f = GetFramework();
- BookmarkCategory * cat = f.GetBmCategory(indexPath.row);
- bool moveCheckMark = false;
- if (cat && cat->GetName() == [m_balloon.setName UTF8String])
- moveCheckMark = true;
-
- if (f.DeleteBmCategory(indexPath.row))
- [self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
- if (f.GetBmCategoriesCount() == 1)
- {
- // Disable edit mode to leave at least one bookmarks category
- [self setEditing:NO animated:YES];
- self.navigationItem.rightBarButtonItem = nil;
- }
- if (moveCheckMark)
- {
- UITableViewCell * cell = [tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:1]];
- cell.accessoryType = UITableViewCellAccessoryCheckmark;
- m_balloon.setName = cell.textLabel.text;
- }
- }
+ [self.navigationController popViewControllerAnimated:YES];
}
}
diff --git a/iphone/Maps/Classes/MapViewController.mm b/iphone/Maps/Classes/MapViewController.mm
index 9b10a8600a..f3174dda7b 100644
--- a/iphone/Maps/Classes/MapViewController.mm
+++ b/iphone/Maps/Classes/MapViewController.mm
@@ -257,6 +257,12 @@
}
else
{
+ Framework &f = GetFramework();
+ int categoryPos = f.LastEditedCategory();
+ if (!IsValid(m_balloonView.editedBookmark))
+ {
+ [m_balloonView addBookmarkToCategory:categoryPos];
+ }
PlacePageVC * placePageVC = [[PlacePageVC alloc] initWithBalloonView:m_balloonView];
[self.navigationController pushViewController:placePageVC animated:YES];
[placePageVC release];