Developer Area

Show
Ignore:
Timestamp:
06/26/09 11:18:18 (5 years ago)
Author:
henri
Message:

Fixed behavior of cancel button in search bar.
Refactored search text filtering.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • apps/iphone/superbook/trunk/Classes/LocateThem_ViewController.m

    r415 r418  
    292292 
    293293- (void)searchBarTextDidEndEditing:(UISearchBar *)searchBar { 
    294         if ([telSearch.text length] == 0) 
     294} 
     295 
     296- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar { 
     297    [searchBar resignFirstResponder]; 
     298} 
     299 
     300- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar { 
     301        NSMutableString *qry = [NSMutableString stringWithString:telSearch.text]; 
     302    [searchBar resignFirstResponder]; 
     303        if ([qry length] == 0) 
    295304                return; 
    296         if ([telSearch.text hasPrefix:@"http"]) { 
    297                 telSearch.text = [telSearch.text stringByReplacingOccurrencesOfString:@"http://" withString:@""]; 
    298                 telSearch.text = [telSearch.text stringByReplacingOccurrencesOfString:@"https://" withString:@""]; 
    299         } 
    300         if ([telSearch.text hasPrefix:@"www."]) { 
    301                 telSearch.text = [telSearch.text substringFromIndex:[@"www." length]]; 
    302         } 
    303         if ([telSearch.text hasPrefix:@"+"]) { 
     305        if ([qry hasPrefix:@"http://"]) { 
     306                [qry deleteCharactersInRange:NSMakeRange(0, [@"http://" length])]; 
     307        } else if ([qry hasPrefix:@"https://"]) { 
     308                [qry deleteCharactersInRange:NSMakeRange(0, [@"https://" length])]; 
     309        } 
     310        if ([qry hasPrefix:@"www."]) { 
     311                [qry deleteCharactersInRange:NSMakeRange(0, [@"www." length])]; 
     312        } 
     313        if ([qry hasPrefix:@"+"]) { 
    304314                // Check if it's a phone number, try the sip version 
    305315                BOOL isValidNumber = YES; 
    306316                NSMutableString *enumStr = [NSMutableString stringWithCapacity:30]; 
    307317                NSRange prefixR = NSMakeRange(0, 0); 
    308                 for (int i = 1; i < [telSearch.text length]; i++) { 
    309                         unichar aChar = [telSearch.text characterAtIndex:i]; 
     318                for (int i = 1; i < [qry length]; i++) { 
     319                        unichar aChar = [qry characterAtIndex:i]; 
    310320                        if ((aChar < 47) || (aChar > 58)) {     // Not in range of Unicode digits 0-9 
    311321                                isValidNumber = NO; 
     
    316326                if (isValidNumber) { 
    317327                        [enumStr appendString:@"e164.arpa"]; 
    318                         telSearch.text = enumStr; 
     328                        qry = enumStr; 
    319329                } 
    320         } else if ([telSearch.text hasSuffix:@".tel"]) { 
     330        } else if ([qry hasSuffix:@".tel"]) { 
    321331                // .tel domain, do nothing 
    322         } else if ([telSearch.text hasSuffix:@".e164.arpa"]) { 
     332        } else if ([qry hasSuffix:@".e164.arpa"]) { 
    323333                // ENUM domain, let's add support for it, why not! 
    324334                // Superbook will be the best ENUM client too! :) 
    325335        } else { 
    326                 telSearch.text = [NSString stringWithFormat:@"%@.tel", telSearch.text]; 
    327         } 
    328         [self launchNavControllerForTel:telSearch.text personId:nil]; 
    329 } 
    330  
    331 - (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar { 
    332     [searchBar resignFirstResponder]; 
    333 } 
    334  
    335 - (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar { 
    336     [searchBar resignFirstResponder]; 
     336                qry = [NSString stringWithFormat:@"%@.tel", qry]; 
     337        } 
     338        [self launchNavControllerForTel:qry personId:nil]; 
    337339} 
    338340 
Telnic
Search This Site
Partners
Neustar
ICANN
Main site | WHOIS | Sell .tel | FAQ | Archived Site | About Telnic | Contact Us