<commit_before>#import "PlacePageVC.h"
#import "SelectSetVC.h"
#import "Statistics.h"
#import "MapsAppDelegate.h"
#import "MapViewController.h"
#import "TwoButtonsView.h"
#import "ShareActionSheet.h"
#import "PlaceAndCompasView.h"
#import "CircleView.h"

#include "Framework.h"
#include "../../search/result.hpp"
#include "../../platform/settings.hpp"

#define TEXTFIELD_TAG 999
#define TEXTVIEW_TAG 666
#define COORDINATE_TAG 333
#define MARGIN 20
#define SMALLMARGIN 10
#define DESCRIPTIONHEIGHT 140
#define TWOBUTTONSHEIGHT 44
#define CELLHEIGHT  44
#define COORDINATECOLOR 51.0/255.0
#define BUTTONDIAMETER 18

typedef enum {Editing, Saved} Mode;

@interface PlacePageVC()
{
  int m_selectedRow;
  Mode m_mode;
  size_t m_categoryIndex;

  //statistics purpose
  size_t m_categoryIndexStatistics;
  size_t m_numberOfCategories;
}

@property(nonatomic, copy) NSString * pinTitle;
// Currently displays bookmark description (notes)
@property(nonatomic, copy) NSString * pinNotes;
// Stores displayed bookmark icon file name
@property(nonatomic, retain) NSString * pinColor;
// If we clicked already existing bookmark, it will be here
@property(nonatomic, assign) BookmarkAndCategory pinEditedBookmark;

@property(nonatomic, assign) CGPoint pinGlobalPosition;

@property (nonatomic, retain) PlaceAndCompasView * placeAndCompass;

@property (nonatomic, retain) UIView * pickerView;
@end

@implementation PlacePageVC

- (id) initWithInfo:(search::AddressInfo const &)info point:(CGPoint)point
{
  self = [super initWithStyle:UITableViewStyleGrouped];
  if (self)
  {
    char const * pinName = info.GetPinName().c_str();
    [self initializeProperties:[NSString stringWithUTF8String:pinName ? pinName : ""]
                         notes:@""
                         color:@""
                         category:MakeEmptyBookmarkAndCategory() point:point];
    m_mode = Editing;
  }
  return self;
}

- (id) initWithApiPoint:(url_scheme::ApiPoint const &)apiPoint
{
  self = [super initWithStyle:UITableViewStyleGrouped];
  if (self)
  {
    m_mode = Editing;
    [self initializeProperties:[NSString stringWithUTF8String:apiPoint.m_name.c_str()]
                         notes:@""
                         color:@""
                         category:MakeEmptyBookmarkAndCategory()
                         point:CGPointMake(MercatorBounds::LonToX(apiPoint.m_lon), MercatorBounds::LatToY(apiPoint.m_lat))];
  }
  return self;
}

- (id) initWithBookmark:(BookmarkAndCategory)bmAndCat
{
  self = [super initWithStyle:UITableViewStyleGrouped];
  if (self)
  {
    Framework const & f = GetFramework();

    BookmarkCategory const * cat = f.GetBmCategory(bmAndCat.first);
    Bookmark const * bm = cat->GetBookmark(bmAndCat.second);
    search::AddressInfo info;

    CGPoint const pt = CGPointMake(bm->GetOrg().x, bm->GetOrg().y);
    f.GetAddressInfoForGlobalPoint(bm->GetOrg(), info);


    [self initializeProperties:[NSString stringWithUTF8String:bm->GetName().c_str()]
                         notes:[NSString stringWithUTF8String:bm->GetDescription().c_str()]
                         color:[NSString stringWithUTF8String:bm->GetType().c_str()]
                         category:bmAndCat
                         point:CGPointMake(pt.x, pt.y)];

    m_mode = Saved;
  }
  return self;
}

- (id) initWithName:(NSString *)name andGlobalPoint:(CGPoint)point
{
  self = [super initWithStyle:UITableViewStyleGrouped];
  if (self)
  {
    m_mode = Editing;
    [self initializeProperties:name
                         notes:@""
                         color:@""
                         category:MakeEmptyBookmarkAndCategory()
                         point:point];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged) name:UIDeviceOrientationDidChangeNotification  object:nil];
  }
  return self;
}

- (void) dealloc
{
  [[NSNotificationCenter defaultCenter] removeObserver:self];
  self.pickerView = nil;
  self.pinTitle = nil;
  self.pinNotes = nil;
  self.pinColor = nil;
  self.placeAndCompass = nil;
  [super dealloc];
}

- (void)viewWillAppear:(BOOL)animated
{
  [self.navigationController setNavigationBarHidden:NO animated:YES];
  // Update the table - we can display it after changing set or color
  [self.tableView reloadData];

  // Automatically show keyboard if bookmark has default name
  if ([_pinTitle isEqualToString:NSLocalizedString(@"dropped_pin", nil)])
    [[[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]].contentView viewWithTag:TEXTFIELD_TAG] becomeFirstResponder];

  if (isIPad)
  {
    CGSize size = CGSizeMake(320, 480);
    self.contentSizeForViewInPopover = size;
  }
  [super viewWillAppear:animated];
}

-(void)viewDidLoad
{
  [super viewDidLoad];
  self.title = self.pinTitle;<commit_msg>[ios] Do not duplicate pin name in the title (do consistently with non-bookmark place preview pages)<commit_after>#import "PlacePageVC.h"
#import "SelectSetVC.h"
#import "Statistics.h"
#import "MapsAppDelegate.h"
#import "MapViewController.h"
#import "TwoButtonsView.h"
#import "ShareActionSheet.h"
#import "PlaceAndCompasView.h"
#import "CircleView.h"

#include "Framework.h"
#include "../../search/result.hpp"
#include "../../platform/settings.hpp"

#define TEXTFIELD_TAG 999
#define TEXTVIEW_TAG 666
#define COORDINATE_TAG 333
#define MARGIN 20
#define SMALLMARGIN 10
#define DESCRIPTIONHEIGHT 140
#define TWOBUTTONSHEIGHT 44
#define CELLHEIGHT  44
#define COORDINATECOLOR 51.0/255.0
#define BUTTONDIAMETER 18

typedef enum {Editing, Saved} Mode;

@interface PlacePageVC()
{
  int m_selectedRow;
  Mode m_mode;
  size_t m_categoryIndex;

  //statistics purpose
  size_t m_categoryIndexStatistics;
  size_t m_numberOfCategories;
}

@property(nonatomic, copy) NSString * pinTitle;
// Currently displays bookmark description (notes)
@property(nonatomic, copy) NSString * pinNotes;
// Stores displayed bookmark icon file name
@property(nonatomic, retain) NSString * pinColor;
// If we clicked already existing bookmark, it will be here
@property(nonatomic, assign) BookmarkAndCategory pinEditedBookmark;

@property(nonatomic, assign) CGPoint pinGlobalPosition;

@property (nonatomic, retain) PlaceAndCompasView * placeAndCompass;

@property (nonatomic, retain) UIView * pickerView;
@end

@implementation PlacePageVC

- (id) initWithInfo:(search::AddressInfo const &)info point:(CGPoint)point
{
  self = [super initWithStyle:UITableViewStyleGrouped];
  if (self)
  {
    char const * pinName = info.GetPinName().c_str();
    [self initializeProperties:[NSString stringWithUTF8String:pinName ? pinName : ""]
                         notes:@""
                         color:@""
                         category:MakeEmptyBookmarkAndCategory() point:point];
    m_mode = Editing;
  }
  return self;
}

- (id) initWithApiPoint:(url_scheme::ApiPoint const &)apiPoint
{
  self = [super initWithStyle:UITableViewStyleGrouped];
  if (self)
  {
    m_mode = Editing;
    [self initializeProperties:[NSString stringWithUTF8String:apiPoint.m_name.c_str()]
                         notes:@""
                         color:@""
                         category:MakeEmptyBookmarkAndCategory()
                         point:CGPointMake(MercatorBounds::LonToX(apiPoint.m_lon), MercatorBounds::LatToY(apiPoint.m_lat))];
  }
  return self;
}

- (id) initWithBookmark:(BookmarkAndCategory)bmAndCat
{
  self = [super initWithStyle:UITableViewStyleGrouped];
  if (self)
  {
    Framework const & f = GetFramework();

    BookmarkCategory const * cat = f.GetBmCategory(bmAndCat.first);
    Bookmark const * bm = cat->GetBookmark(bmAndCat.second);
    search::AddressInfo info;

    CGPoint const pt = CGPointMake(bm->GetOrg().x, bm->GetOrg().y);
    f.GetAddressInfoForGlobalPoint(bm->GetOrg(), info);


    [self initializeProperties:[NSString stringWithUTF8String:bm->GetName().c_str()]
                         notes:[NSString stringWithUTF8String:bm->GetDescription().c_str()]
                         color:[NSString stringWithUTF8String:bm->GetType().c_str()]
                         category:bmAndCat
                         point:CGPointMake(pt.x, pt.y)];

    m_mode = Saved;
  }
  return self;
}

- (id) initWithName:(NSString *)name andGlobalPoint:(CGPoint)point
{
  self = [super initWithStyle:UITableViewStyleGrouped];
  if (self)
  {
    m_mode = Editing;
    [self initializeProperties:name
                         notes:@""
                         color:@""
                         category:MakeEmptyBookmarkAndCategory()
                         point:point];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged) name:UIDeviceOrientationDidChangeNotification  object:nil];
  }
  return self;
}

- (void) dealloc
{
  [[NSNotificationCenter defaultCenter] removeObserver:self];
  self.pickerView = nil;
  self.pinTitle = nil;
  self.pinNotes = nil;
  self.pinColor = nil;
  self.placeAndCompass = nil;
  [super dealloc];
}

- (void)viewWillAppear:(BOOL)animated
{
  [self.navigationController setNavigationBarHidden:NO animated:YES];
  // Update the table - we can display it after changing set or color
  [self.tableView reloadData];

  // Automatically show keyboard if bookmark has default name
  if ([_pinTitle isEqualToString:NSLocalizedString(@"dropped_pin", nil)])
    [[[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]].contentView viewWithTag:TEXTFIELD_TAG] becomeFirstResponder];

  if (isIPad)
  {
    CGSize size = CGSizeMake(320, 480);
    self.contentSizeForViewInPopover = size;
  }
  [super viewWillAppear:animated];
}

-(void)viewDidLoad
{
  [super viewDidLoad];
  self.title = NSLocalizedString(@"info", nil);
{'fraction_non_alphanumeric': 0.11006905080902814, 'fraction_numerical': 0.008657116355766258, 'mean_word_length': 3.68113844669561, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '804336', 'n_tokens_mistral': 3156, 'n_tokens_neox': 2913, 'n_words': 633}