Developer Area

Changeset 896 for apps

Show
Ignore:
Timestamp:
09/13/11 11:09:35 (3 years ago)
Author:
henri
Message:

Added sharing actions

Location:
apps/iphone/superbook/trunk
Files:
6 modified

Legend:

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

    r864 r896  
    3030#import "TelDomain.h" 
    3131#import "NetworkUtility.h" 
     32#import "SHK.h" 
    3233 
    3334@implementation LocateThem_AppDelegate 
     
    108109        } 
    109110         
     111    [SHK flushOfflineQueue]; 
     112     
    110113        LocateThem_ViewController *lVC = [[[LocateThem_ViewController alloc] initWithNibName:@"MainView" bundle:[NSBundle mainBundle]] autorelease]; 
    111114        navC = [[UINavigationController alloc] initWithRootViewController:lVC]; 
  • apps/iphone/superbook/trunk/Classes/NaptrViewController.h

    r851 r896  
    5050        UIActivityIndicatorView *loadingAIView; 
    5151        UIBarButtonItem *loadingAIButton; 
    52         UIBarButtonItem *storeContactButton; 
     52        UIBarButtonItem *actionContactButton; 
    5353        UIImage *logoImage; 
    5454        NSNumber *abId; // addressbook id 
     
    6666- (void)didFinishRetrievingLogo; 
    6767- (void)actOnUri:(NSString *)uri; 
     68- (IBAction)domainAction:(id)sender; 
    6869- (IBAction)saveContact:(id)sender; 
     70- (IBAction)shareContact:(id)sender; 
    6971 
    7072@property (nonatomic, retain) TelDomain *theDomain; 
    7173@property (nonatomic, retain) UIActivityIndicatorView *loadingAIView; 
    7274@property (nonatomic, retain) UIBarButtonItem *loadingAIButton; 
    73 @property (nonatomic, retain) UIBarButtonItem *storeContactButton; 
     75@property (nonatomic, retain) UIBarButtonItem *actionContactButton; 
    7476@property (nonatomic, retain) UIImage *logoImage; 
    7577@property (nonatomic, retain) NSNumber *abId; 
  • apps/iphone/superbook/trunk/Classes/NaptrViewController.m

    r886 r896  
    3535#import "WebUrlViewController.h" 
    3636#import "RecordNaptr+HAAdditions.h" 
     37#import "SHK.h" 
    3738 
    3839static UIFont *headerFont; 
     
    4142static CGFloat naptrCellRowLineHeight; 
    4243static CGSize maximumLabelSize; 
     44 
     45enum ActionSheets_enum { 
     46    ActionSheet_Action, 
     47    ActionSheet_Call, 
     48    ActionSheet_Share 
     49}; 
    4350 
    4451@interface NaptrViewController (PrivateMethods) 
     
    5865@synthesize loadingAIButton; 
    5966@synthesize logoImage; 
    60 @synthesize storeContactButton; 
     67@synthesize actionContactButton; 
    6168@synthesize abId; 
    6269 
     
    98105        self.loadingAIButton = [[[UIBarButtonItem alloc] initWithCustomView:self.loadingAIView] autorelease]; 
    99106         
    100         self.storeContactButton = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave  
     107        self.actionContactButton = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction  
    101108                                                                                                                                                        target:self  
    102                                                                                                                                                         action:@selector(saveContact:)] autorelease]; 
     109                                                                                                                                                        action:@selector(domainAction:)] autorelease]; 
    103110        self.logoImage = nil; 
    104111     
     
    186193                [self.loadingAIView stopAnimating]; 
    187194        [self performSelector:@selector(stopLoading) withObject:nil afterDelay:0.1]; 
    188                 self.navigationItem.rightBarButtonItem = self.storeContactButton; 
     195                self.navigationItem.rightBarButtonItem = self.actionContactButton; 
    189196        if (! self.theDomain.isCached) { 
    190197            // Cache the domain data if it's new data 
     
    824831                                                                                                   destructiveButtonTitle:nil 
    825832                                                                                                                otherButtonTitles:nil]; 
     833        actionSheet.tag = ActionSheet_Call; 
    826834                callButtonIndex = [actionSheet addButtonWithTitle:NSLocalizedString(@"Call this number", @"Call this number")]; 
    827835                smsButtonIndex = [actionSheet addButtonWithTitle:NSLocalizedString(@"Send an SMS Message", @"Send an SMS Message")]; 
     
    846854                return; 
    847855        } 
    848         NSURL *naptrUrl; 
    849         NSString *uri = [actionSheet title]; 
    850     if (buttonIndex == callButtonIndex) { 
    851                 naptrUrl = [NSURL URLWithString:[uri stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]]; 
    852                 [[UIApplication sharedApplication] openURL:naptrUrl]; 
    853         } else if (buttonIndex == smsButtonIndex) { 
    854                 NSRange telPrefixRange = [uri rangeOfString:@"tel:"]; 
    855                 naptrUrl = [NSURL URLWithString:[uri stringByReplacingCharactersInRange:telPrefixRange withString:@"sms:"]]; 
    856                 [[UIApplication sharedApplication] openURL:naptrUrl]; 
     856    if (actionSheet.tag == ActionSheet_Call) { 
     857        NSURL *naptrUrl; 
     858        NSString *uri = [actionSheet title]; 
     859        if (buttonIndex == callButtonIndex) { 
     860            naptrUrl = [NSURL URLWithString:[uri stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]]; 
     861            [[UIApplication sharedApplication] openURL:naptrUrl]; 
     862        } else if (buttonIndex == smsButtonIndex) { 
     863            NSRange telPrefixRange = [uri rangeOfString:@"tel:"]; 
     864            naptrUrl = [NSURL URLWithString:[uri stringByReplacingCharactersInRange:telPrefixRange withString:@"sms:"]]; 
     865            [[UIApplication sharedApplication] openURL:naptrUrl]; 
     866        } 
     867    } else if (actionSheet.tag == ActionSheet_Action) { 
     868        if (buttonIndex == 0) { // Save 
     869            [self saveContact:nil]; 
     870        } else if (buttonIndex == 1) { // Share 
     871            [self shareContact:nil]; 
     872        } 
    857873    } 
    858874        return; 
    859875} 
    860876 
    861 #pragma mark ------ Methods to save a contact 
     877#pragma mark ------ Action methods 
     878 
     879- (IBAction)domainAction:(id)sender { 
     880    UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil 
     881                                                             delegate:self 
     882                                                    cancelButtonTitle:nil 
     883                                               destructiveButtonTitle:nil 
     884                                                    otherButtonTitles:nil]; 
     885    actionSheet.tag = ActionSheet_Action; 
     886    [actionSheet addButtonWithTitle:NSLocalizedString(@"Save to Address Book", @"Save")]; 
     887    [actionSheet addButtonWithTitle:NSLocalizedString(@"Share this", @"Share")]; 
     888    actionSheet.cancelButtonIndex = [actionSheet addButtonWithTitle:NSLocalizedString(@"Cancel", @"Cancel")]; 
     889    [actionSheet showInView:self.view]; 
     890    [actionSheet release]; 
     891} 
    862892 
    863893- (IBAction)saveContact:(id)sender { 
     
    874904                [self showError:err]; 
    875905        } 
     906} 
     907 
     908- (IBAction)shareContact:(id)sender { 
     909    // Create the item to share (in this example, a url) 
     910        NSURL *url = [NSURL URLWithString:[@"http://" stringByAppendingString:self.theDomain.telName]]; 
     911    NSString *urlString = [url.absoluteString stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; 
     912    NSString *sharingString = [NSString stringWithFormat:NSLocalizedString(@"I just checked out %@ on Superbook", @"sharing string"), urlString]; 
     913        SHKItem *item = [SHKItem text:sharingString]; 
     914     
     915        // Get the ShareKit action sheet 
     916        SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:item];     
     917        // Display the action sheet 
     918    [actionSheet showInView:self.view]; 
    876919} 
    877920 
  • apps/iphone/superbook/trunk/English.lproj/Localizable.strings

    r894 r896  
    110110"Coordinates" = "Coordinates"; 
    111111 
     112/* Share this */ 
     113"Share this" = "Share this"; 
    112114 
    113115/*** AddressBook Mapping ***/ 
  • apps/iphone/superbook/trunk/French.lproj/Localizable.strings

    r894 r896  
    161161"CreateNewContact" = "Créer un nouveau contact"; 
    162162 
     163/* Share this */ 
     164"Share this" = "Partager"; 
    163165 
    164166/*** Map View ***/ 
  • apps/iphone/superbook/trunk/German.lproj/Localizable.strings

    r894 r896  
    110110/* Coordinates */ 
    111111"Coordinates" = "Koordinaten"; 
     112 
     113/* Share this */ 
     114"Share this" = "Teilen"; 
    112115 
    113116 
Telnic
Search This Site
Partners
Neustar
ICANN
Main site | WHOIS | Sell .tel | FAQ | Archived Site | About Telnic | Contact Us