2
0

Dumped Google+ SDK.

[UPDATED]   Google+ SDK.
This commit is contained in:
Maarten Billemont
2013-04-27 17:14:05 -04:00
parent dc3c30a2f7
commit a6e3b83ebb
206 changed files with 8949 additions and 1417 deletions

View File

@@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:GooglePlusSample.xcodeproj">
</FileRef>
</Workspace>

View File

@@ -18,27 +18,16 @@
#import <UIKit/UIKit.h>
@class GPPShare;
@class GPPSignInButton;
#import "GPPDeepLink.h"
@class GTMOAuth2Authentication;
@interface GooglePlusSampleAppDelegate : UIResponder<UIApplicationDelegate>
@interface GooglePlusSampleAppDelegate : UIResponder<
UIApplicationDelegate, GPPDeepLinkDelegate>
// The sample app's |UIWindow|.
@property (retain, nonatomic) UIWindow *window;
// The navigation controller.
@property (retain, nonatomic) UINavigationController *navigationController;
// The Google+ sign-in button to handle the URL redirect.
@property (retain, nonatomic) GPPSignInButton *signInButton;
// The OAuth 2.0 authentication used in the application.
@property (retain, nonatomic) GTMOAuth2Authentication *auth;
// The Google+ share object to handle the URL redirect.
@property (retain, nonatomic) GPPShare *share;
// Whether or not to use Google+ history's
// https://www.googleapis.com/auth/plus.moments.write scope.
@property (assign, nonatomic) BOOL plusMomentsWriteScope;
// The OAuth 2.0 client ID to be used for Google+ sign-in, share, and moments.
+ (NSString *)clientID;
@end

View File

@@ -19,42 +19,31 @@
#import "GooglePlusSampleAppDelegate.h"
#import "GooglePlusSampleMasterViewController.h"
#import "GPPDeepLink.h"
#import "GPPSignIn.h"
#import "GPPSignInButton.h"
#import "GPPURLHandler.h"
@implementation GooglePlusSampleAppDelegate
@synthesize window = window_;
@synthesize navigationController = navigationController_;
@synthesize signInButton = signInButton_;
@synthesize auth = auth_;
@synthesize share = share_;
@synthesize plusMomentsWriteScope = plusMomentsWriteScope_;
// DO NOT USE THIS CLIENT ID. IT WILL NOT WORK FOR YOUR APP.
// Please use the client ID created for you by Google.
static NSString * const kClientID =
@"122385832599-2mcvobo565un3ab7d6d06m6fjemocto9.apps.googleusercontent.com";
+ (NSString *)clientID {
return kClientID;
}
@"452265719636.apps.googleusercontent.com";
#pragma mark Object life-cycle.
- (void)dealloc {
[window_ release];
[navigationController_ release];
[signInButton_ release];
[auth_ release];
[share_ release];
[super dealloc];
}
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
plusMomentsWriteScope_ = YES;
// Set app's client ID for |GPPSignIn| and |GPPShare|.
[GPPSignIn sharedInstance].clientID = kClientID;
self.window = [[[UIWindow alloc]
initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
@@ -69,16 +58,8 @@ static NSString * const kClientID =
[self.window makeKeyAndVisible];
// Read Google+ deep-link data.
GPPDeepLink *deepLink = [GPPDeepLink readDeepLinkAfterInstall];
if (deepLink) {
UIAlertView *alert = [[[UIAlertView alloc]
initWithTitle:@"Read Deep-link Data"
message:[deepLink deepLinkID]
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil] autorelease];
[alert show];
}
[GPPDeepLink setDelegate:self];
[GPPDeepLink readDeepLinkAfterInstall];
return YES;
}
@@ -86,34 +67,22 @@ static NSString * const kClientID =
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
// Handle Google+ share dialog URL.
if ([share_ handleURL:url
sourceApplication:sourceApplication
annotation:annotation]) {
return YES;
}
return [GPPURLHandler handleURL:url
sourceApplication:sourceApplication
annotation:annotation];
}
// Handle Google+ sign-in button URL.
if ([signInButton_ handleURL:url
sourceApplication:sourceApplication
annotation:annotation]) {
return YES;
}
#pragma mark - GPPDeepLinkDelegate
// Handle Google+ deep-link data URL.
GPPDeepLink *deepLink = [GPPDeepLink handleURL:url
sourceApplication:sourceApplication
annotation:annotation];
if (deepLink) {
UIAlertView *alert = [[[UIAlertView alloc]
initWithTitle:@"Handle Deep-link Data"
message:[deepLink deepLinkID]
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil] autorelease];
[alert show];
}
return NO;
- (void)didReceiveDeepLink:(GPPDeepLink *)deepLink {
// An example to handle the deep link data.
UIAlertView *alert = [[[UIAlertView alloc]
initWithTitle:@"Deep-link Data"
message:[deepLink deepLinkID]
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil] autorelease];
[alert show];
}
@end

View File

@@ -0,0 +1,48 @@
//
// GooglePlusSampleListMomentsViewController.h
//
// Copyright 2012 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#import <UIKit/UIKit.h>
@class GTLPlusMoment;
@interface GooglePlusSampleListMomentsViewController : UIViewController<
UITableViewDelegate,
UITableViewDataSource> {
// A map from activities to verbs used for display.
NSDictionary *verbMap_;
// An array of |GTLPlusMoment|, as the data source.
NSMutableArray *momentsData_;
// Currently selected moment in the |momentsData_| array.
GTLPlusMoment *selectedMoment_;
}
// The table that displays the list of moments for the user.
@property (retain, nonatomic) IBOutlet UITableView *momentsTable;
// A label to display the status of selected moment, or general status.
@property (retain, nonatomic) IBOutlet UILabel *momentStatus;
// A label to display the target of selected moment.
@property (retain, nonatomic) IBOutlet UILabel *momentTarget;
// A label to display the time of selected moment.
@property (retain, nonatomic) IBOutlet UILabel *momentTime;
// A button to remove selected moment.
@property (retain, nonatomic) IBOutlet UIButton *momentRemoval;
// Called when the remove button is pressed.
- (IBAction)removeMoment:(id)sender;
@end

View File

@@ -0,0 +1,229 @@
//
// GooglePlusSampleListMomentsViewController.m
//
// Copyright 2012 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#import "GooglePlusSampleListMomentsViewController.h"
#import "GPPSignIn.h"
#import "GTLPlus.h"
#import "GTMLogger.h"
#import "GTMOAuth2Authentication.h"
@interface GooglePlusSampleListMomentsViewController ()
- (void)clearSelectedMoment;
- (void)refreshData;
- (NSString *)textForMoment:(GTLPlusMoment *)moment;
@end
#pragma mark - View lifecycle
@implementation GooglePlusSampleListMomentsViewController
@synthesize momentsTable = momentsTable_;
@synthesize momentStatus = momentStatus_;
@synthesize momentTarget = momentTarget_;
@synthesize momentTime = momentTime_;
@synthesize momentRemoval = momentsRemoval_;
#pragma mark - Object lifecycle
- (id)initWithNibName:(NSString *)nibNameOrNil
bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
verbMap_ = [[NSDictionary dictionaryWithObjectsAndKeys:
@"Added", @"http://schemas.google.com/AddActivity",
@"Bought", @"http://schemas.google.com/BuyActivity",
@"Checked in", @"http://schemas.google.com/CheckInActivity",
@"Commented on", @"http://schemas.google.com/CommentActivity",
@"Created", @"http://schemas.google.com/CreateActivity",
@"Listened to", @"http://schemas.google.com/ListenActivity",
@"Made a reservation at", @"http://schemas.google.com/ReserveActivity",
@"Reviewed", @"http://schemas.google.com/ReviewActivity",
nil] retain];
}
return self;
}
- (void)dealloc {
[verbMap_ release];
[momentsData_ release];
[selectedMoment_ release];
[momentsTable_ release];
[momentStatus_ release];
[momentTarget_ release];
[momentTime_ release];
[super dealloc];
}
#pragma mark - View lifecycle
- (void)viewDidLoad {
[super viewDidLoad];
[self refreshData];
}
#pragma mark - UITableViewDelegate/UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section {
return momentsData_.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString * const kCellIdentifier = @"Cell";
UITableViewCell *cell =
[tableView dequeueReusableCellWithIdentifier:kCellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:kCellIdentifier]
autorelease];
cell.accessoryType = UITableViewCellAccessoryNone;
}
// Configure the cell.
GTLPlusMoment *moment = momentsData_[indexPath.row];
cell.textLabel.text = [self textForMoment:moment];
return cell;
}
- (void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
GTLPlusMoment *moment = momentsData_[indexPath.row];
[selectedMoment_ autorelease];
selectedMoment_ = [moment retain];
momentStatus_.text = [NSString stringWithFormat:@"Target for \"%@\":",
[self textForMoment:moment]];
momentTarget_.text = moment.target.url;
momentTime_.text = [NSString stringWithFormat:@"Start time: %@",
[NSDateFormatter localizedStringFromDate:moment.startDate.date
dateStyle:kCFDateFormatterMediumStyle
timeStyle:kCFDateFormatterMediumStyle]];
momentsRemoval_.hidden = NO;
}
- (void)tableView:(UITableView *)tableView
didDeselectRowAtIndexPath:(NSIndexPath *)indexPath {
[self clearSelectedMoment];
}
#pragma mark - IBActions
- (IBAction)removeMoment:(id)sender {
if (!selectedMoment_) {
return;
}
// Here is an example of removing a moment from Google+:
// 1. Create a |GTLServicePlus| instance to send a request to Google+.
GTLServicePlus* plusService = [[[GTLServicePlus alloc] init] autorelease];
plusService.retryEnabled = YES;
// 2. Set a valid |GTMOAuth2Authentication| object as the authorizer.
GTMOAuth2Authentication *auth = [GPPSignIn sharedInstance].authentication;
[plusService setAuthorizer:auth];
// 3. Create a |GTLQuery| object to remove the moment.
GTLQueryPlus *query = [GTLQueryPlus
queryForMomentsRemoveWithIdentifier:selectedMoment_.identifier];
[plusService executeQuery:query
completionHandler:^(GTLServiceTicket *ticket,
id object,
NSError *error) {
if (error) {
momentStatus_.text =
[NSString stringWithFormat:@"Error: %@", error];
GTMLoggerError(@"Status: Error: %@", error);
} else {
[momentsData_ removeObject:selectedMoment_];
[self clearSelectedMoment];
[momentsTable_ reloadData];
}
}];
}
#pragma mark - Helper methods
- (void)clearSelectedMoment {
[selectedMoment_ autorelease];
selectedMoment_ = nil;
momentStatus_.text = @"";
momentTarget_.text = @"";
momentTime_.text = @"";
momentsRemoval_.hidden = YES;
}
- (void)refreshData {
GTMOAuth2Authentication *auth = [GPPSignIn sharedInstance].authentication;
if (!auth) {
// To authenticate, use Google+ sign-in button.
momentStatus_.text = @"Status: Not authenticated";
return;
}
// Clear old moments data.
[momentsData_ autorelease];
momentsData_ = nil;
[momentsTable_ reloadData];
[self clearSelectedMoment];
momentStatus_.text = @"Status: Loading";
// Here is an example of reading list of moments from Google+:
// 1. Create a |GTLServicePlus| instance to send a request to Google+.
GTLServicePlus* plusService = [[[GTLServicePlus alloc] init] autorelease];
plusService.retryEnabled = YES;
// 2. Set a valid |GTMOAuth2Authentication| object as the authorizer.
[plusService setAuthorizer:auth];
// 3. Create a |GTLQuery| object to list moments.
GTLQueryPlus *query =
[GTLQueryPlus queryForMomentsListWithUserId:@"me"
collection:kGTLPlusCollectionVault];
[plusService executeQuery:query
completionHandler:^(GTLServiceTicket *ticket,
id object,
NSError *error) {
if (error) {
momentStatus_.text =
[NSString stringWithFormat:@"Error: %@", error];
GTMLoggerError(@"Status: Error: %@", error);
} else {
GTLPlusMomentsFeed *moments = (GTLPlusMomentsFeed *)object;
momentsData_ =
[[NSMutableArray arrayWithArray:moments.items] retain];
momentStatus_.text = [NSString stringWithFormat:
@"Status: Loaded %d moment(s)", momentsData_.count];
[momentsTable_ reloadData];
}
}];
}
- (NSString *)textForMoment:(GTLPlusMoment *)moment {
NSString *verb = [verbMap_ objectForKey:moment.type];
if (!verb) {
// Fallback for verbs we don't recognize.
verb = [moment.type lastPathComponent];
}
return [NSString stringWithFormat:@"%@ %@", verb, moment.target.name];
}
@end

View File

@@ -0,0 +1,429 @@
<?xml version="1.0" encoding="UTF-8"?>
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="8.00">
<data>
<int key="IBDocument.SystemTarget">1552</int>
<string key="IBDocument.SystemVersion">12C60</string>
<string key="IBDocument.InterfaceBuilderVersion">3084</string>
<string key="IBDocument.AppKitVersion">1187.34</string>
<string key="IBDocument.HIToolboxVersion">625.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="NS.object.0">2083</string>
</object>
<array key="IBDocument.IntegratedClassDependencies">
<string>IBProxyObject</string>
<string>IBUIButton</string>
<string>IBUILabel</string>
<string>IBUITableView</string>
<string>IBUIView</string>
</array>
<array key="IBDocument.PluginDependencies">
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
</array>
<object class="NSMutableDictionary" key="IBDocument.Metadata">
<string key="NS.key.0">PluginDependencyRecalculationVersion</string>
<integer value="1" key="NS.object.0"/>
</object>
<array class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
<object class="IBProxyObject" id="372490531">
<string key="IBProxiedObjectIdentifier">IBFilesOwner</string>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
<object class="IBProxyObject" id="975951072">
<string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
<object class="IBUIView" id="191373211">
<reference key="NSNextResponder"/>
<int key="NSvFlags">274</int>
<array class="NSMutableArray" key="NSSubviews">
<object class="IBUILabel" id="1065162584">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{15, 240}, {285, 42}}</string>
<reference key="NSSuperview" ref="191373211"/>
<reference key="NSWindow"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
<int key="IBUIContentMode">7</int>
<bool key="IBUIUserInteractionEnabled">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<string key="IBUIText"/>
<object class="NSColor" key="IBUITextColor" id="535034633">
<int key="NSColorSpace">1</int>
<bytes key="NSRGB">MCAwIDAAA</bytes>
<string key="IBUIColorCocoaTouchKeyPath">darkTextColor</string>
</object>
<nil key="IBUIHighlightedColor"/>
<int key="IBUIBaselineAdjustment">0</int>
<int key="IBUINumberOfLines">2</int>
<object class="IBUIFontDescription" key="IBUIFontDescription" id="301803659">
<int key="type">1</int>
<double key="pointSize">17</double>
</object>
<object class="NSFont" key="IBUIFont" id="965205771">
<string key="NSName">Helvetica</string>
<double key="NSSize">17</double>
<int key="NSfFlags">16</int>
</object>
<bool key="IBUIAdjustsFontSizeToFit">NO</bool>
<double key="preferredMaxLayoutWidth">285</double>
</object>
<object class="IBUIButton" id="550280117">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{15, 359}, {89, 44}}</string>
<reference key="NSSuperview" ref="191373211"/>
<reference key="NSWindow"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<int key="IBUIContentHorizontalAlignment">0</int>
<int key="IBUIContentVerticalAlignment">0</int>
<int key="IBUIButtonType">1</int>
<string key="IBUINormalTitle">Remove</string>
<object class="NSColor" key="IBUIHighlightedTitleColor" id="475673723">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MQA</bytes>
</object>
<object class="NSColor" key="IBUINormalTitleColor">
<int key="NSColorSpace">1</int>
<bytes key="NSRGB">MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA</bytes>
</object>
<object class="NSColor" key="IBUINormalTitleShadowColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MC41AA</bytes>
</object>
<object class="IBUIFontDescription" key="IBUIFontDescription">
<int key="type">2</int>
<double key="pointSize">15</double>
</object>
<object class="NSFont" key="IBUIFont">
<string key="NSName">Helvetica-Bold</string>
<double key="NSSize">15</double>
<int key="NSfFlags">16</int>
</object>
</object>
<object class="IBUIView" id="624954994">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
<array class="NSMutableArray" key="NSSubviews">
<object class="IBUITableView" id="307593524">
<reference key="NSNextResponder" ref="624954994"/>
<int key="NSvFlags">274</int>
<string key="NSFrame">{{20, 20}, {320, 238}}</string>
<reference key="NSSuperview" ref="624954994"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="1065162584"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<reference key="IBUIBackgroundColor" ref="475673723"/>
<bool key="IBUIClipsSubviews">YES</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<bool key="IBUIAlwaysBounceVertical">YES</bool>
<int key="IBUISeparatorStyle">1</int>
<int key="IBUISectionIndexMinimumDisplayRowCount">0</int>
<bool key="IBUIShowsSelectionImmediatelyOnTouchBegin">YES</bool>
<float key="IBUIRowHeight">44</float>
<float key="IBUISectionHeaderHeight">22</float>
<float key="IBUISectionFooterHeight">22</float>
</object>
</array>
<string key="NSFrame">{{-20, -20}, {360, 258}}</string>
<reference key="NSSuperview" ref="191373211"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="307593524"/>
<string key="NSReuseIdentifierKey">_NS:10</string>
<object class="NSColor" key="IBUIBackgroundColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MQA</bytes>
<object class="NSColorSpace" key="NSCustomColorSpace" id="619355701">
<int key="NSID">2</int>
</object>
</object>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
<object class="IBUILabel" id="422188795">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{15, 284}, {285, 42}}</string>
<reference key="NSSuperview" ref="191373211"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="153778411"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
<int key="IBUIContentMode">7</int>
<bool key="IBUIUserInteractionEnabled">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<string key="IBUIText"/>
<reference key="IBUITextColor" ref="535034633"/>
<nil key="IBUIHighlightedColor"/>
<int key="IBUIBaselineAdjustment">0</int>
<int key="IBUINumberOfLines">2</int>
<reference key="IBUIFontDescription" ref="301803659"/>
<reference key="IBUIFont" ref="965205771"/>
<bool key="IBUIAdjustsFontSizeToFit">NO</bool>
<double key="preferredMaxLayoutWidth">285</double>
</object>
<object class="IBUILabel" id="153778411">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{15, 330}, {285, 21}}</string>
<reference key="NSSuperview" ref="191373211"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="550280117"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
<int key="IBUIContentMode">7</int>
<bool key="IBUIUserInteractionEnabled">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<string key="IBUIText"/>
<reference key="IBUITextColor" ref="535034633"/>
<nil key="IBUIHighlightedColor"/>
<int key="IBUIBaselineAdjustment">0</int>
<reference key="IBUIFontDescription" ref="301803659"/>
<reference key="IBUIFont" ref="965205771"/>
<bool key="IBUIAdjustsFontSizeToFit">NO</bool>
</object>
</array>
<string key="NSFrame">{{0, 20}, {320, 460}}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="624954994"/>
<object class="NSColor" key="IBUIBackgroundColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MQA</bytes>
<reference key="NSCustomColorSpace" ref="619355701"/>
</object>
<object class="IBUISimulatedStatusBarMetrics" key="IBUISimulatedStatusBarMetrics"/>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
</array>
<object class="IBObjectContainer" key="IBDocument.Objects">
<array class="NSMutableArray" key="connectionRecords">
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">view</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="191373211"/>
</object>
<int key="connectionID">3</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">momentRemoval</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="550280117"/>
</object>
<int key="connectionID">61</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">momentsTable</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="307593524"/>
</object>
<int key="connectionID">33</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">momentStatus</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="1065162584"/>
</object>
<int key="connectionID">76</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">momentTarget</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="422188795"/>
</object>
<int key="connectionID">101</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">momentTime</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="153778411"/>
</object>
<int key="connectionID">107</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">delegate</string>
<reference key="source" ref="307593524"/>
<reference key="destination" ref="372490531"/>
</object>
<int key="connectionID">35</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">dataSource</string>
<reference key="source" ref="307593524"/>
<reference key="destination" ref="372490531"/>
</object>
<int key="connectionID">34</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">removeMoment:</string>
<reference key="source" ref="550280117"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">7</int>
</object>
<int key="connectionID">62</int>
</object>
</array>
<object class="IBMutableOrderedSet" key="objectRecords">
<array key="orderedObjects">
<object class="IBObjectRecord">
<int key="objectID">0</int>
<array key="object" id="0"/>
<reference key="children" ref="1000"/>
<nil key="parent"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">1</int>
<reference key="object" ref="191373211"/>
<array class="NSMutableArray" key="children">
<reference ref="624954994"/>
<reference ref="153778411"/>
<reference ref="1065162584"/>
<reference ref="422188795"/>
<reference ref="550280117"/>
</array>
<reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">-1</int>
<reference key="object" ref="372490531"/>
<reference key="parent" ref="0"/>
<string key="objectName">File's Owner</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">-2</int>
<reference key="object" ref="975951072"/>
<reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">14</int>
<reference key="object" ref="1065162584"/>
<array class="NSMutableArray" key="children"/>
<reference key="parent" ref="191373211"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">56</int>
<reference key="object" ref="550280117"/>
<array class="NSMutableArray" key="children"/>
<reference key="parent" ref="191373211"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">66</int>
<reference key="object" ref="624954994"/>
<array class="NSMutableArray" key="children">
<reference ref="307593524"/>
</array>
<reference key="parent" ref="191373211"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">4</int>
<reference key="object" ref="307593524"/>
<array class="NSMutableArray" key="children"/>
<reference key="parent" ref="624954994"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">93</int>
<reference key="object" ref="422188795"/>
<array class="NSMutableArray" key="children"/>
<reference key="parent" ref="191373211"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">103</int>
<reference key="object" ref="153778411"/>
<array class="NSMutableArray" key="children"/>
<reference key="parent" ref="191373211"/>
</object>
</array>
</object>
<dictionary class="NSMutableDictionary" key="flattenedProperties">
<string key="-1.CustomClassName">GooglePlusSampleListMomentsViewController</string>
<string key="-1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="-2.CustomClassName">UIResponder</string>
<string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="103.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="14.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="4.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="56.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<real value="0.0" key="56.IBUIButtonInspectorSelectedStateConfigurationMetadataKey"/>
<string key="66.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="93.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
<int key="maxID">151</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
<object class="IBPartialClassDescription">
<string key="className">GooglePlusSampleListMomentsViewController</string>
<string key="superclassName">UIViewController</string>
<object class="NSMutableDictionary" key="actions">
<string key="NS.key.0">removeMoment:</string>
<string key="NS.object.0">id</string>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
<string key="NS.key.0">removeMoment:</string>
<object class="IBActionInfo" key="NS.object.0">
<string key="name">removeMoment:</string>
<string key="candidateClassName">id</string>
</object>
</object>
<dictionary class="NSMutableDictionary" key="outlets">
<string key="momentRemoval">UIButton</string>
<string key="momentStatus">UILabel</string>
<string key="momentTarget">UILabel</string>
<string key="momentTime">UILabel</string>
<string key="momentsTable">UITableView</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="toOneOutletInfosByName">
<object class="IBToOneOutletInfo" key="momentRemoval">
<string key="name">momentRemoval</string>
<string key="candidateClassName">UIButton</string>
</object>
<object class="IBToOneOutletInfo" key="momentStatus">
<string key="name">momentStatus</string>
<string key="candidateClassName">UILabel</string>
</object>
<object class="IBToOneOutletInfo" key="momentTarget">
<string key="name">momentTarget</string>
<string key="candidateClassName">UILabel</string>
</object>
<object class="IBToOneOutletInfo" key="momentTime">
<string key="name">momentTime</string>
<string key="candidateClassName">UILabel</string>
</object>
<object class="IBToOneOutletInfo" key="momentsTable">
<string key="name">momentsTable</string>
<string key="candidateClassName">UITableView</string>
</object>
</dictionary>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/GooglePlusSampleListMomentsViewController.h</string>
</object>
</object>
</array>
</object>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
<string key="IBCocoaTouchPluginVersion">2083</string>
</data>
</archive>

View File

@@ -0,0 +1,38 @@
//
// GooglePlusSamplePeopleListViewController.h
//
// Copyright 2012 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#import <UIKit/UIKit.h>
// A view controller for listing people that are visible to this sample app.
// The open-source GTLPlus libraries are required.
@interface GooglePlusSampleListPeopleViewController : UIViewController<
UITableViewDelegate,
UITableViewDataSource>
// A label to display the result of the listing people action.
@property (retain, nonatomic) IBOutlet UILabel *peopleStatus;
// The table that displays a list of people that is visible to this sample app.
@property (retain, nonatomic) IBOutlet UITableView *peopleTable;
// A list of people that is visible to this sample app.
@property (retain, nonatomic) NSArray *peopleList;
// A list of people profile images that we will prefetch that is
// visible to this sample app.
@property (retain, nonatomic) NSMutableArray *peopleImageList;
@end

View File

@@ -0,0 +1,190 @@
//
// GooglePlusSampleListPeopleViewController.m
//
// Copyright 2012 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#import "GooglePlusSampleListPeopleViewController.h"
#import "GPPSignIn.h"
#import "GTLPlus.h"
#import "GTMLogger.h"
#import "GTMOAuth2Authentication.h"
@interface GooglePlusSampleListPeopleViewController()
- (void)listPeople:(NSString *)collection;
- (void)reportAuthStatus;
- (void)fetchPeopleImages;
@end
@implementation GooglePlusSampleListPeopleViewController
@synthesize peopleTable = peopleTable_;
@synthesize peopleList = peopleList_;
@synthesize peopleStatus = peopleStatus_;
@synthesize peopleImageList = peopleImageList_;
#pragma mark - Object lifecycle
- (void)dealloc {
[peopleStatus_ release];
[super dealloc];
}
#pragma mark - View lifecycle
- (void)viewDidLoad {
// Report whether the user is authenticated with
// https://www.googleapis.com/auth/plus.login scope.
[self reportAuthStatus];
// Send Google+ request to get list of people that is visible to this app.
[self listPeople:kGTLPlusCollectionVisible];
[super viewDidLoad];
}
- (void)viewDidUnload {
[peopleImageList_ release];
[peopleList_ release];
[peopleStatus_ release];
[super viewDidUnload];
}
#pragma mark - UITableViewDelegate/UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section {
return peopleList_.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *const kCellIdentifier = @"Cell";
UITableViewCell *cell =
[tableView dequeueReusableCellWithIdentifier:kCellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:kCellIdentifier]
autorelease];
cell.accessoryType = UITableViewCellAccessoryNone;
}
// Configure the cell by extracting a person's name and image from the list
// of people.
if (indexPath.row < peopleList_.count) {
GTLPlusPerson *person = peopleList_[indexPath.row];
NSString *name = person.displayName;
cell.textLabel.text = name;
if (indexPath.row < [peopleImageList_ count] &&
![[peopleImageList_ objectAtIndex:indexPath.row]
isEqual:[NSNull null]]) {
cell.imageView.image =
[[[UIImage alloc]
initWithData:[peopleImageList_ objectAtIndex:indexPath.row]]
autorelease];
} else {
cell.imageView.image = nil;
}
}
return cell;
}
#pragma mark - Helper methods
- (void)listPeople:(NSString *)collection {
GTMOAuth2Authentication *auth = [GPPSignIn sharedInstance].authentication;
if (!auth) {
// To authenticate, use Google+ sign-in button.
peopleStatus_.text = @"Status: Not authenticated";
return;
}
// 1. Create a |GTLServicePlus| instance to send a request to Google+.
GTLServicePlus* plusService = [[[GTLServicePlus alloc] init] autorelease];
plusService.retryEnabled = YES;
// 2. Set a valid |GTMOAuth2Authentication| object as the authorizer.
[plusService setAuthorizer:auth];
// 3. Create a |GTLQuery| object to list people that are visible to this
// sample app.
GTLQueryPlus *query =
[GTLQueryPlus queryForPeopleListWithUserId:@"me"
collection:collection];
[plusService executeQuery:query
completionHandler:^(GTLServiceTicket *ticket,
GTLPlusPeopleFeed *peopleFeed,
NSError *error) {
if (error) {
GTMLoggerError(@"Error: %@", error);
peopleStatus_.text =
[NSString stringWithFormat:@"Status: Error: %@", error];
} else {
// Get an array of people from |GTLPlusPeopleFeed| and reload
// the table view.
peopleList_ = [peopleFeed.items retain];
[peopleTable_ reloadData];
// Render the status of the Google+ request.
NSNumber *count = peopleFeed.totalItems;
if (count.intValue == 1) {
peopleStatus_.text = [NSString stringWithFormat:
@"Status: Listed 1 person"];
} else {
peopleStatus_.text = [NSString stringWithFormat:
@"Status: Listed %@ people", count];
}
[self fetchPeopleImages];
}
}];
}
- (void)fetchPeopleImages {
NSInteger index = 0;
peopleImageList_ =
[[NSMutableArray alloc] initWithCapacity:[peopleList_ count]];
for (GTLPlusPerson *person in peopleList_) {
NSString *imageURLString = person.image.url;
if (imageURLString) {
NSURL *imageURL = [NSURL URLWithString:imageURLString];
NSData *imageData = [NSData dataWithContentsOfURL:imageURL];
[peopleImageList_ setObject:imageData atIndexedSubscript:index];
} else {
[peopleImageList_ setObject:[NSNull null] atIndexedSubscript:index];
}
++index;
}
}
- (void)reportAuthStatus {
if (![GPPSignIn sharedInstance].authentication) {
return;
}
if ([[GPPSignIn sharedInstance].scopes containsObject:
kGTLAuthScopePlusLogin]) {
peopleStatus_.text = @"Status: Authenticated with plus.login scope";
} else {
// To authenticate, use Google+ sign-in button.
peopleStatus_.text = @"Status: Not authenticated with plus.login scope";
}
}
@end

View File

@@ -0,0 +1,300 @@
<?xml version="1.0" encoding="UTF-8"?>
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="8.00">
<data>
<int key="IBDocument.SystemTarget">1552</int>
<string key="IBDocument.SystemVersion">12C60</string>
<string key="IBDocument.InterfaceBuilderVersion">3084</string>
<string key="IBDocument.AppKitVersion">1187.34</string>
<string key="IBDocument.HIToolboxVersion">625.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="NS.object.0">2083</string>
</object>
<array key="IBDocument.IntegratedClassDependencies">
<string>IBProxyObject</string>
<string>IBUILabel</string>
<string>IBUITableView</string>
<string>IBUIView</string>
</array>
<array key="IBDocument.PluginDependencies">
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
</array>
<object class="NSMutableDictionary" key="IBDocument.Metadata">
<string key="NS.key.0">PluginDependencyRecalculationVersion</string>
<integer value="1" key="NS.object.0"/>
</object>
<array class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
<object class="IBProxyObject" id="372490531">
<string key="IBProxiedObjectIdentifier">IBFilesOwner</string>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
<object class="IBProxyObject" id="975951072">
<string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
<object class="IBUIView" id="191373211">
<reference key="NSNextResponder"/>
<int key="NSvFlags">274</int>
<array class="NSMutableArray" key="NSSubviews">
<object class="IBUILabel" id="407476461">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{6, 11}, {253, 21}}</string>
<reference key="NSSuperview" ref="191373211"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="523394245"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<string key="NSHuggingPriority">{250, 250}</string>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
<int key="IBUIContentMode">7</int>
<bool key="IBUIUserInteractionEnabled">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<string key="IBUIText">People visible to this sample app:</string>
<object class="NSColor" key="IBUITextColor" id="586080610">
<int key="NSColorSpace">1</int>
<bytes key="NSRGB">MCAwIDAAA</bytes>
<string key="IBUIColorCocoaTouchKeyPath">darkTextColor</string>
</object>
<nil key="IBUIHighlightedColor"/>
<int key="IBUIBaselineAdjustment">0</int>
<object class="IBUIFontDescription" key="IBUIFontDescription" id="889799447">
<int key="type">1</int>
<double key="pointSize">17</double>
</object>
<object class="NSFont" key="IBUIFont" id="516920208">
<string key="NSName">Helvetica</string>
<double key="NSSize">17</double>
<int key="NSfFlags">16</int>
</object>
<bool key="IBUIAdjustsFontSizeToFit">NO</bool>
</object>
<object class="IBUILabel" id="421795987">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{6, 329}, {285, 67}}</string>
<reference key="NSSuperview" ref="191373211"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
<bool key="IBUIUserInteractionEnabled">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<string key="IBUIText">Status:</string>
<reference key="IBUITextColor" ref="586080610"/>
<nil key="IBUIHighlightedColor"/>
<int key="IBUIBaselineAdjustment">0</int>
<int key="IBUINumberOfLines">2</int>
<reference key="IBUIFontDescription" ref="889799447"/>
<reference key="IBUIFont" ref="516920208"/>
<bool key="IBUIAdjustsFontSizeToFit">NO</bool>
<double key="preferredMaxLayoutWidth">285</double>
</object>
<object class="IBUIView" id="523394245">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
<array class="NSMutableArray" key="NSSubviews">
<object class="IBUITableView" id="580697286">
<reference key="NSNextResponder" ref="523394245"/>
<int key="NSvFlags">274</int>
<string key="NSFrame">{{20, 20}, {320, 263}}</string>
<reference key="NSSuperview" ref="523394245"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="421795987"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<object class="NSColor" key="IBUIBackgroundColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MQA</bytes>
</object>
<bool key="IBUIClipsSubviews">YES</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<bool key="IBUIAlwaysBounceVertical">YES</bool>
<int key="IBUISeparatorStyle">1</int>
<int key="IBUISectionIndexMinimumDisplayRowCount">0</int>
<bool key="IBUIShowsSelectionImmediatelyOnTouchBegin">YES</bool>
<float key="IBUIRowHeight">44</float>
<float key="IBUISectionHeaderHeight">22</float>
<float key="IBUISectionFooterHeight">22</float>
</object>
</array>
<string key="NSFrame">{{-20, 40}, {360, 303}}</string>
<reference key="NSSuperview" ref="191373211"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="580697286"/>
<string key="NSReuseIdentifierKey">_NS:10</string>
<object class="NSColor" key="IBUIBackgroundColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MQA</bytes>
<object class="NSColorSpace" key="NSCustomColorSpace" id="165733047">
<int key="NSID">2</int>
</object>
</object>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
</array>
<string key="NSFrame">{{0, 64}, {320, 416}}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="407476461"/>
<object class="NSColor" key="IBUIBackgroundColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MQA</bytes>
<reference key="NSCustomColorSpace" ref="165733047"/>
</object>
<object class="IBUISimulatedStatusBarMetrics" key="IBUISimulatedStatusBarMetrics"/>
<object class="IBUISimulatedNavigationBarMetrics" key="IBUISimulatedTopBarMetrics">
<bool key="IBUIPrompted">NO</bool>
</object>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
</array>
<object class="IBObjectContainer" key="IBDocument.Objects">
<array class="NSMutableArray" key="connectionRecords">
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">peopleStatus</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="421795987"/>
</object>
<int key="connectionID">55</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">view</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="191373211"/>
</object>
<int key="connectionID">56</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">peopleTable</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="580697286"/>
</object>
<int key="connectionID">54</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">delegate</string>
<reference key="source" ref="580697286"/>
<reference key="destination" ref="372490531"/>
</object>
<int key="connectionID">32</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">dataSource</string>
<reference key="source" ref="580697286"/>
<reference key="destination" ref="372490531"/>
</object>
<int key="connectionID">31</int>
</object>
</array>
<object class="IBMutableOrderedSet" key="objectRecords">
<array key="orderedObjects">
<object class="IBObjectRecord">
<int key="objectID">0</int>
<array key="object" id="0"/>
<reference key="children" ref="1000"/>
<nil key="parent"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">1</int>
<reference key="object" ref="191373211"/>
<array class="NSMutableArray" key="children">
<reference ref="407476461"/>
<reference ref="523394245"/>
<reference ref="421795987"/>
</array>
<reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">-1</int>
<reference key="object" ref="372490531"/>
<reference key="parent" ref="0"/>
<string key="objectName">File's Owner</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">-2</int>
<reference key="object" ref="975951072"/>
<reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">10</int>
<reference key="object" ref="407476461"/>
<reference key="parent" ref="191373211"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">34</int>
<reference key="object" ref="421795987"/>
<array class="NSMutableArray" key="children"/>
<reference key="parent" ref="191373211"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">129</int>
<reference key="object" ref="523394245"/>
<array class="NSMutableArray" key="children">
<reference ref="580697286"/>
</array>
<reference key="parent" ref="191373211"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">3</int>
<reference key="object" ref="580697286"/>
<array class="NSMutableArray" key="children"/>
<reference key="parent" ref="523394245"/>
</object>
</array>
</object>
<dictionary class="NSMutableDictionary" key="flattenedProperties">
<string key="-1.CustomClassName">GooglePlusSampleListPeopleViewController</string>
<string key="-1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="-2.CustomClassName">UIResponder</string>
<string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="10.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="129.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="3.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="34.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
<int key="maxID">157</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
<object class="IBPartialClassDescription">
<string key="className">GooglePlusSampleListPeopleViewController</string>
<string key="superclassName">UIViewController</string>
<dictionary class="NSMutableDictionary" key="outlets">
<string key="peopleStatus">UILabel</string>
<string key="peopleTable">UITableView</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="toOneOutletInfosByName">
<object class="IBToOneOutletInfo" key="peopleStatus">
<string key="name">peopleStatus</string>
<string key="candidateClassName">UILabel</string>
</object>
<object class="IBToOneOutletInfo" key="peopleTable">
<string key="name">peopleTable</string>
<string key="candidateClassName">UITableView</string>
</object>
</dictionary>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/GooglePlusSampleListPeopleViewController.h</string>
</object>
</object>
</array>
</object>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
<string key="IBCocoaTouchPluginVersion">2083</string>
</data>
</archive>

View File

@@ -18,25 +18,23 @@
#import "GooglePlusSampleMasterViewController.h"
#import "GooglePlusSampleAppDelegate.h"
#import "GooglePlusSampleShareViewController.h"
#import "GooglePlusSampleSignInViewController.h"
#import "GooglePlusSampleMomentsViewController.h"
#import "GPPSignIn.h"
static const int kNumViewControllers = 3;
static const int kNumViewControllers = 5;
static NSString * const kMenuOptions[kNumViewControllers] = {
@"Sign In", @"Share", @"Moments" };
@"Sign in", @"Share", @"List people", @"Write moments",
@"List & remove moments" };
static NSString * const kUnselectableMenuOptions[kNumViewControllers] = {
@"", @"", @"Sign in to use moments" };
nil, nil, @"Sign in to list people", @"Sign in to write moments",
@"Sign in to list/remove moments" };
static NSString * const kNibNames[kNumViewControllers] = {
@"GooglePlusSampleSignInViewController",
@"GooglePlusSampleShareViewController",
@"GooglePlusSampleMomentsViewController" };
static const int kMomentsIndex = 2;
@"GooglePlusSampleListPeopleViewController",
@"GooglePlusSampleMomentsViewController",
@"GooglePlusSampleListMomentsViewController" };
@interface GooglePlusSampleMasterViewController () {
NSIndexPath *momentsIndexPath_;
}
@interface GooglePlusSampleMasterViewController ()
- (BOOL)isSelectable:(NSIndexPath *)indexPath;
@end
@@ -58,7 +56,6 @@ static const int kMomentsIndex = 2;
}
- (void)dealloc {
[momentsIndexPath_ release];
[super dealloc];
}
@@ -75,11 +72,7 @@ static const int kMomentsIndex = 2;
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
if (momentsIndexPath_) {
[self.tableView
reloadRowsAtIndexPaths:[NSArray arrayWithObject:momentsIndexPath_]
withRowAnimation:UITableViewRowAnimationFade];
}
[self.tableView reloadData];
}
#pragma mark - UITableViewDelegate/UITableViewDataSource
@@ -132,14 +125,9 @@ static const int kMomentsIndex = 2;
#pragma mark - Helper methods
- (BOOL)isSelectable:(NSIndexPath *)indexPath {
if (indexPath.row == kMomentsIndex) {
if (!momentsIndexPath_) {
momentsIndexPath_ = [indexPath retain];
}
// To use Google+ History API, you need to sign in.
GooglePlusSampleAppDelegate *appDelegate = (GooglePlusSampleAppDelegate *)
[[UIApplication sharedApplication] delegate];
return appDelegate.auth && appDelegate.plusMomentsWriteScope;
if (kUnselectableMenuOptions[indexPath.row]) {
// To use Google+ moments, you need to sign in.
return [GPPSignIn sharedInstance].authentication != nil;
}
return YES;
}

View File

@@ -20,9 +20,9 @@
@class GTLServicePlus;
// A view controller for writing different kinds of moments to Google+ history.
// A view controller for writing different kinds of moments to Google+.
// The open-source GTLPlus libraries are required. For more details, see
// https://developers.google.com/+/history/ .
// https://developers.google.com/+/features/app-activities .
@interface GooglePlusSampleMomentsViewController : UIViewController<
UITableViewDelegate,
UITableViewDataSource,
@@ -30,8 +30,12 @@
BOOL keyboardVisible_;
}
// A label to prompt the selection of a moment.
@property (retain, nonatomic) IBOutlet UILabel *selectionLabel;
// The table that displays the different kinds of moments available.
@property (retain, nonatomic) IBOutlet UITableView *momentsTable;
// The view for the bootom controls.
@property (retain, nonatomic) IBOutlet UIView *bottomControls;
// The target URL to associate with this moment.
@property (retain, nonatomic) IBOutlet UITextField *momentURL;
// A label to display the result of writing a moment.

View File

@@ -19,13 +19,8 @@
#import "GooglePlusSampleMomentsViewController.h"
#import <QuartzCore/QuartzCore.h>
#import "GooglePlusSampleAppDelegate.h"
#import "GPPSignIn.h"
#import "GTLPlus.h"
#import "GTLPlusConstants.h"
#import "GTLPlusItemScope.h"
#import "GTLPlusMoment.h"
#import "GTLQueryPlus.h"
#import "GTLServicePlus.h"
#import "GTMLogger.h"
#import "GTMOAuth2Authentication.h"
@@ -39,13 +34,15 @@
@implementation GooglePlusSampleMomentsViewController
@synthesize selectionLabel = selectionLabel_;
@synthesize momentsTable = momentsTable_;
@synthesize bottomControls = bottomControls_;
@synthesize momentURL = momentURL_;
@synthesize momentStatus = momentStatus_;
@synthesize addButton = addButton_;
// The different kinds of moments.
static const int kNumMomentTypes = 9;
static const int kNumMomentTypes = 8;
static NSString * const kMomentTypes[kNumMomentTypes] = {
@"AddActivity",
@"BuyActivity",
@@ -54,8 +51,7 @@ static NSString * const kMomentTypes[kNumMomentTypes] = {
@"CreateActivity",
@"ListenActivity",
@"ReserveActivity",
@"ReviewActivity",
@"ViewActivity" };
@"ReviewActivity" };
static NSString * const kMomentURLs[kNumMomentTypes] = {
@"thing",
@"a-book",
@@ -64,8 +60,7 @@ static NSString * const kMomentURLs[kNumMomentTypes] = {
@"photo",
@"song",
@"restaurant",
@"widget",
@"video" };
@"widget" };
static NSString * const kMomentURLFormat =
@"https://developers.google.com/+/plugins/snippet/examples/%@";
@@ -81,7 +76,9 @@ static NSString * const kMomentURLFormat =
removeObserver:self
name:UIKeyboardWillHideNotification
object:nil];
[selectionLabel_ release];
[momentsTable_ release];
[bottomControls_ release];
[momentURL_ release];
[momentStatus_ release];
[addButton_ release];
@@ -121,6 +118,23 @@ static NSString * const kMomentURLFormat =
selector:@selector(keyboardWillHide:)
name:UIKeyboardWillHideNotification
object:nil];
// Scale the table view vertically down to its contents if necessary.
[momentsTable_ reloadData];
CGRect frame = momentsTable_.frame;
if (frame.size.height > momentsTable_.contentSize.height) {
CGFloat shift = frame.size.height - momentsTable_.contentSize.height;
frame.size.height = momentsTable_.contentSize.height;
momentsTable_.frame = frame;
// Also update the prompt by removing the "scroll for more" part.
selectionLabel_.text = @"Select an activity";
// And move the bottom view up for the same shift amount.
frame = bottomControls_.frame;
frame.origin.y -= shift;
bottomControls_.frame = frame;
}
}
- (void)viewWillDisappear:(BOOL)animated {
@@ -140,24 +154,23 @@ static NSString * const kMomentURLFormat =
#pragma mark - IBActions
- (IBAction)momentButton:(id)sender {
GooglePlusSampleAppDelegate *appDelegate = (GooglePlusSampleAppDelegate *)
[[UIApplication sharedApplication] delegate];
if (!appDelegate.auth) {
GTMOAuth2Authentication *auth = [GPPSignIn sharedInstance].authentication;
if (!auth) {
// To authenticate, use Google+ sign-in button.
momentStatus_.text = @"Status: Not authenticated";
return;
}
// Here is an example of writing a moment to Google+ history:
// Here is an example of writing a moment to Google+:
// 1. Create a |GTLServicePlus| instance to send a request to Google+.
GTLServicePlus* plusService = [[[GTLServicePlus alloc] init] autorelease];
plusService.retryEnabled = YES;
// 2. Set a valid |GTMOAuth2Authentication| object as the authorizer.
[plusService setAuthorizer:appDelegate.auth];
[plusService setAuthorizer:auth];
// 3. Create a |GTLPlusMoment| object with required fields. For reference, see
// https://developers.google.com/+/history/ .
// https://developers.google.com/+/features/app-activities .
int selectedRow = [[momentsTable_ indexPathForSelectedRow] row];
NSString *selectedMoment = kMomentTypes[selectedRow];
@@ -194,7 +207,7 @@ static NSString * const kMomentURLFormat =
[NSString stringWithFormat:@"Status: Error: %@", error];
} else {
momentStatus_.text = [NSString stringWithFormat:
@"Status: Saved to Google+ history (%@)",
@"Status: Saved to Google+ (%@)",
selectedMoment];
}
}];
@@ -264,7 +277,7 @@ static NSString * const kMomentURLFormat =
result.text = @"I can't wait to use it on my site :)";
return result;
} else if ([selectedMoment isEqualToString:@"ReserveActivity"]) {
result.type = @"http://schema.org/Reservation";
result.type = @"http://schemas.google.com/Reservation";
result.startDate = @"2012-06-28T19:00:00-08:00";
result.attendeeCount = [[[NSNumber alloc] initWithInt:3] autorelease];
return result;
@@ -316,18 +329,12 @@ static NSString * const kMomentURLFormat =
}
- (void)reportAuthStatus {
NSString *authStatus = @"";
GooglePlusSampleAppDelegate *appDelegate = (GooglePlusSampleAppDelegate *)
[[UIApplication sharedApplication] delegate];
if (appDelegate.auth) {
authStatus = @"Status: Authenticated";
if ([GPPSignIn sharedInstance].authentication) {
momentStatus_.text = @"Status: Authenticated";
} else {
// To authenticate, use Google+ sign-in button.
authStatus = @"Status: Not authenticated";
momentStatus_.text = @"Status: Not authenticated";
}
momentStatus_.text = authStatus;
}
@end

View File

@@ -1,22 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="8.00">
<data>
<int key="IBDocument.SystemTarget">1280</int>
<string key="IBDocument.SystemVersion">10K549</string>
<string key="IBDocument.InterfaceBuilderVersion">1938</string>
<string key="IBDocument.AppKitVersion">1038.36</string>
<string key="IBDocument.HIToolboxVersion">461.00</string>
<int key="IBDocument.SystemTarget">1552</int>
<string key="IBDocument.SystemVersion">12C60</string>
<string key="IBDocument.InterfaceBuilderVersion">3084</string>
<string key="IBDocument.AppKitVersion">1187.34</string>
<string key="IBDocument.HIToolboxVersion">625.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="NS.object.0">933</string>
<string key="NS.object.0">2083</string>
</object>
<array key="IBDocument.IntegratedClassDependencies">
<string>IBUITextField</string>
<string>IBUITableView</string>
<string>IBUIButton</string>
<string>IBUIView</string>
<string>IBUILabel</string>
<string>IBProxyObject</string>
<string>IBUIButton</string>
<string>IBUILabel</string>
<string>IBUITableView</string>
<string>IBUITextField</string>
<string>IBUIView</string>
</array>
<array key="IBDocument.PluginDependencies">
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
@@ -35,7 +35,7 @@
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
<object class="IBUIView" id="191373211">
<reference key="NSNextResponder"/>
<nil key="NSNextResponder"/>
<int key="NSvFlags">274</int>
<array class="NSMutableArray" key="NSSubviews">
<object class="IBUILabel" id="29623071">
@@ -43,7 +43,6 @@
<int key="NSvFlags">290</int>
<string key="NSFrame">{{10, 5}, {296, 21}}</string>
<reference key="NSSuperview" ref="191373211"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="1013113918"/>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
@@ -54,6 +53,7 @@
<object class="NSColor" key="IBUITextColor" id="216027142">
<int key="NSColorSpace">1</int>
<bytes key="NSRGB">MCAwIDAAA</bytes>
<string key="IBUIColorCocoaTouchKeyPath">darkTextColor</string>
</object>
<nil key="IBUIHighlightedColor"/>
<int key="IBUIBaselineAdjustment">1</int>
@@ -73,7 +73,6 @@
<int key="NSvFlags">274</int>
<string key="NSFrame">{{0, 32}, {320, 132}}</string>
<reference key="NSSuperview" ref="191373211"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="885245054"/>
<object class="NSColor" key="IBUIBackgroundColor" id="373936525">
<int key="NSColorSpace">3</int>
@@ -98,7 +97,6 @@
<int key="NSvFlags">266</int>
<string key="NSFrame">{{11, 20}, {296, 21}}</string>
<reference key="NSSuperview" ref="885245054"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="621451586"/>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
@@ -118,7 +116,6 @@
<int key="NSvFlags">266</int>
<string key="NSFrame">{{11, 51}, {291, 31}}</string>
<reference key="NSSuperview" ref="885245054"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="525343048"/>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
@@ -153,7 +150,6 @@
<int key="NSvFlags">264</int>
<string key="NSFrame">{{12, 113}, {142, 37}}</string>
<reference key="NSSuperview" ref="885245054"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="851809288"/>
<bool key="IBUIOpaque">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
@@ -191,8 +187,6 @@
<int key="NSvFlags">266</int>
<string key="NSFrame">{{11, 180}, {290, 21}}</string>
<reference key="NSSuperview" ref="885245054"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
<int key="IBUIContentMode">7</int>
@@ -209,15 +203,12 @@
</array>
<string key="NSFrame">{{0, 172}, {320, 244}}</string>
<reference key="NSSuperview" ref="191373211"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="625104685"/>
<reference key="IBUIBackgroundColor" ref="373936525"/>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
</array>
<string key="NSFrame">{{0, 64}, {320, 416}}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="29623071"/>
<object class="NSColor" key="IBUIBackgroundColor">
<int key="NSColorSpace">3</int>
@@ -274,6 +265,22 @@
</object>
<int key="connectionID">30</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">selectionLabel</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="29623071"/>
</object>
<int key="connectionID">32</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">bottomControls</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="885245054"/>
</object>
<int key="connectionID">34</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">dataSource</string>
@@ -400,7 +407,7 @@
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
<int key="maxID">31</int>
<int key="maxID">34</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -420,15 +427,21 @@
</object>
<dictionary class="NSMutableDictionary" key="outlets">
<string key="addButton">UIButton</string>
<string key="bottomView">UIView</string>
<string key="momentStatus">UILabel</string>
<string key="momentURL">UITextField</string>
<string key="momentsTable">UITableView</string>
<string key="selectionLabel">UILabel</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="toOneOutletInfosByName">
<object class="IBToOneOutletInfo" key="addButton">
<string key="name">addButton</string>
<string key="candidateClassName">UIButton</string>
</object>
<object class="IBToOneOutletInfo" key="bottomView">
<string key="name">bottomView</string>
<string key="candidateClassName">UIView</string>
</object>
<object class="IBToOneOutletInfo" key="momentStatus">
<string key="name">momentStatus</string>
<string key="candidateClassName">UILabel</string>
@@ -441,6 +454,10 @@
<string key="name">momentsTable</string>
<string key="candidateClassName">UITableView</string>
</object>
<object class="IBToOneOutletInfo" key="selectionLabel">
<string key="name">selectionLabel</string>
<string key="candidateClassName">UILabel</string>
</object>
</dictionary>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
@@ -457,6 +474,6 @@
<string key="NS.key.0">button_background.png</string>
<string key="NS.object.0">{1, 1}</string>
</object>
<string key="IBCocoaTouchPluginVersion">933</string>
<string key="IBCocoaTouchPluginVersion">2083</string>
</data>
</archive>

View File

@@ -28,15 +28,18 @@
GPPShareDelegate,
UITextFieldDelegate,
UIActionSheetDelegate,
UIPickerViewDataSource,
UIPickerViewDelegate,
MFMailComposeViewControllerDelegate> {
// The Google+ share object to manage the share dialog.
GPPShare *share_;
// Whether the keyboard is visible or not.
BOOL keyboardVisible_;
// The text field being edited.
UITextField *activeField_;
}
@property (retain, nonatomic) NSArray *callToActions;
@property (copy, nonatomic) NSString *selectedCallToAction;
@property (retain, nonatomic) UIPickerView *callToActionPickerView;
// The text to prefill the user comment in the share dialog.
@property (retain, nonatomic) IBOutlet UITextField *sharePrefillText;
// The URL resource to share in the share dialog.
@@ -45,36 +48,39 @@
@property (retain, nonatomic) IBOutlet UILabel *shareStatus;
// A toolbar to share via Google+ or email.
@property (retain, nonatomic) IBOutlet UIToolbar *shareToolbar;
// A switch to toggle Google+ share with deep linking.
@property (retain, nonatomic) IBOutlet UISwitch *attachDeepLinkSwitch;
// The deep-link ID to be attached with the Google+ share to qualify as
// A switch to toggle Google+ share with content deep linking.
@property (retain, nonatomic) IBOutlet UISwitch *addContentDeepLinkSwitch;
// The content deep-link ID to be attached with the Google+ share to qualify as
// a deep-link share.
@property (retain, nonatomic) IBOutlet UITextField *deepLinkID;
@property (retain, nonatomic) IBOutlet UITextField *contentDeepLinkID;
// The share's title.
@property (retain, nonatomic) IBOutlet UITextField *deepLinkTitle;
@property (retain, nonatomic) IBOutlet UITextField *contentDeepLinkTitle;
// The share's description.
@property (retain, nonatomic) IBOutlet UITextField *deepLinkDescription;
@property (retain, nonatomic) IBOutlet UITextField *contentDeepLinkDescription;
// The share's thumbnail URL.
@property (retain, nonatomic) IBOutlet UITextField *deepLinkThumbnailURL;
@property (retain, nonatomic) IBOutlet UITextField *contentDeepLinkThumbnailURL;
// The share view.
@property (retain, nonatomic) IBOutlet UIScrollView *shareScrollView;
@property (retain, nonatomic) IBOutlet UIView *shareView;
// Labels for Google+ share sample.
@property (retain, nonatomic) IBOutlet UILabel *attachDeepLinkDataLabel;
@property (retain, nonatomic) IBOutlet UILabel *addContentDeepLinkLabel;
@property (retain, nonatomic) IBOutlet UILabel *urlToShareLabel;
@property (retain, nonatomic) IBOutlet UILabel *prefillTextLabel;
@property (retain, nonatomic) IBOutlet UILabel *deepLinkIDLabel;
@property (retain, nonatomic) IBOutlet UILabel *deepLinkTitleLabel;
@property (retain, nonatomic) IBOutlet UILabel *deepLinkDescriptionLabel;
@property (retain, nonatomic) IBOutlet UILabel *deepLinkThumbnailURLLabel;
@property (retain, nonatomic) IBOutlet UILabel *contentDeepLinkIDLabel;
@property (retain, nonatomic) IBOutlet UILabel *contentDeepLinkTitleLabel;
@property (retain, nonatomic) IBOutlet UILabel *contentDeepLinkDescriptionLabel;
@property (retain, nonatomic) IBOutlet UILabel *contentDeepLinkThumbnailURLLabel;
@property (retain, nonatomic) IBOutlet UIButton *shareButton;
@property (retain, nonatomic) IBOutlet UISwitch *urlForDeepLinkMetadataSwitch;
@property (retain, nonatomic) IBOutlet UILabel *urlForDeepLinkMetadataLabel;
@property (retain, nonatomic) IBOutlet UISwitch *urlForContentDeepLinkMetadataSwitch;
@property (retain, nonatomic) IBOutlet UILabel *urlForContentDeepLinkMetadataLabel;
// The switch for adding call-to-action button.
@property (retain, nonatomic) IBOutlet UISwitch *addCallToActionButtonSwitch;
@property (retain, nonatomic) IBOutlet UILabel *addCallToActionButtonLabel;
// Called when the switch for deep-link data is toggled.
- (IBAction)deepLinkSwitchToggle:(id)sender;
// Called when the switch for content deep link is toggled.
- (IBAction)contentDeepLinkSwitchToggle:(id)sender;
// Called when the switch for metadata from URL preview is toggled.
- (IBAction)urlForDeepLinkMetadataSwitchToggle:(id)sender;
- (IBAction)urlForContentDeepLinkMetadataSwitchToggle:(id)sender;
// Called when the share button is pressed.
- (IBAction)shareButton:(id)sender;
// Called when the toolbar share button is pressed.

View File

@@ -18,7 +18,10 @@
#import "GooglePlusSampleShareViewController.h"
#import "GooglePlusSampleAppDelegate.h"
#import <QuartzCore/QuartzCore.h>
#import "GPPSignIn.h"
#import "GTLPlusConstants.h"
#import "GTMOAuth2Authentication.h"
@interface GooglePlusSampleShareViewController()
- (void)animateKeyboard:(NSNotification *)notification
@@ -30,51 +33,64 @@
@implementation GooglePlusSampleShareViewController
@synthesize attachDeepLinkSwitch = attachDeepLinkSwitch_;
@synthesize deepLinkDescription = deepLinkDescription_;
@synthesize deepLinkID = deepLinkID_;
@synthesize deepLinkTitle = deepLinkTitle_;
@synthesize deepLinkThumbnailURL = deepLinkThumbnailURL_;
@synthesize callToActions = callToActions_;
@synthesize selectedCallToAction = selectedCallToAction_;
@synthesize callToActionPickerView = callToActionPickerView_;
@synthesize addContentDeepLinkSwitch = addContentDeepLinkSwitch_;
@synthesize contentDeepLinkDescription = contentDeepLinkDescription_;
@synthesize contentDeepLinkID = contentDeepLinkID_;
@synthesize contentDeepLinkTitle = contentDeepLinkTitle_;
@synthesize contentDeepLinkThumbnailURL = contentDeepLinkThumbnailURL_;
@synthesize sharePrefillText = sharePrefillText_;
@synthesize shareURL = shareURL_;
@synthesize shareStatus = shareStatus_;
@synthesize shareToolbar = shareToolbar_;
@synthesize shareScrollView = shareScrollView_;
@synthesize shareView = shareView_;
@synthesize attachDeepLinkDataLabel = attachDeepLinkDataLabel_;
@synthesize addContentDeepLinkLabel = addContentDeepLinkLabel_;
@synthesize urlToShareLabel = urlToShareLabel_;
@synthesize prefillTextLabel = prefillTextLabel_;
@synthesize deepLinkIDLabel = deepLinkIDLabel_;
@synthesize deepLinkTitleLabel = deepLinkTitleLabel_;
@synthesize deepLinkDescriptionLabel = deepLinkDescriptionLabel_;
@synthesize deepLinkThumbnailURLLabel = deepLinkThumbnailURLLabel_;
@synthesize contentDeepLinkIDLabel = contentDeepLinkIDLabel_;
@synthesize contentDeepLinkTitleLabel = contentDeepLinkTitleLabel_;
@synthesize contentDeepLinkDescriptionLabel =
contentDeepLinkDescriptionLabel_;
@synthesize contentDeepLinkThumbnailURLLabel =
contentDeepLinkThumbnailURLLabel_;
@synthesize shareButton = shareButton_;
@synthesize urlForDeepLinkMetadataSwitch = urlForDeepLinkMetadataSwitch_;
@synthesize urlForDeepLinkMetadataLabel = urlForDeepLinkMetadataLabel_;
@synthesize urlForContentDeepLinkMetadataSwitch =
urlForContentDeepLinkMetadataSwitch_;
@synthesize urlForContentDeepLinkMetadataLabel =
urlForContentDeepLinkMetadataLabel_;
@synthesize addCallToActionButtonSwitch = addCallToActionButtonSwitch_;
@synthesize addCallToActionButtonLabel = addCallToActionButtonLabel_;
- (void)dealloc {
[attachDeepLinkSwitch_ release];
[deepLinkID_ release];
[deepLinkTitle_ release];
[deepLinkDescription_ release];
[deepLinkThumbnailURL_ release];
[callToActions_ release];
[selectedCallToAction_ release];
[callToActionPickerView_ release];
[addContentDeepLinkSwitch_ release];
[contentDeepLinkID_ release];
[contentDeepLinkTitle_ release];
[contentDeepLinkDescription_ release];
[contentDeepLinkThumbnailURL_ release];
[sharePrefillText_ release];
[shareURL_ release];
[shareStatus_ release];
[share_ release];
[shareToolbar_ release];
[shareScrollView_ release];
[shareView_ release];
[attachDeepLinkDataLabel_ release];
[addContentDeepLinkLabel_ release];
[urlToShareLabel_ release];
[prefillTextLabel_ release];
[deepLinkIDLabel_ release];
[deepLinkTitleLabel_ release];
[deepLinkDescriptionLabel_ release];
[deepLinkThumbnailURLLabel_ release];
[contentDeepLinkIDLabel_ release];
[contentDeepLinkTitleLabel_ release];
[contentDeepLinkDescriptionLabel_ release];
[contentDeepLinkThumbnailURLLabel_ release];
[shareButton_ release];
[urlForDeepLinkMetadataSwitch_ release];
[urlForDeepLinkMetadataLabel_ release];
[urlForContentDeepLinkMetadataSwitch_ release];
[urlForContentDeepLinkMetadataLabel_ release];
[addCallToActionButtonSwitch_ release];
[addCallToActionButtonLabel_ release];
[super dealloc];
}
@@ -82,14 +98,120 @@
- (void)viewDidLoad {
// Set up Google+ share dialog.
GooglePlusSampleAppDelegate *appDelegate = (GooglePlusSampleAppDelegate *)
[[UIApplication sharedApplication] delegate];
NSString *clientID = [GooglePlusSampleAppDelegate clientID];
share_ = [[GPPShare alloc] initWithClientID:clientID];
share_.delegate = self;
appDelegate.share = share_;
[GPPShare sharedInstance].delegate = self;
[attachDeepLinkSwitch_ setOn:NO];
[addCallToActionButtonSwitch_ setOn:NO];
[addContentDeepLinkSwitch_ setOn:NO];
if (![GPPSignIn sharedInstance].authentication ||
![[GPPSignIn sharedInstance].scopes containsObject:
kGTLAuthScopePlusLogin]) {
addCallToActionButtonLabel_.text = @"Sign in for call-to-action";
addCallToActionButtonSwitch_.enabled = NO;
}
addCallToActionButtonLabel_.adjustsFontSizeToFitWidth = YES;
self.callToActions = [NSArray arrayWithObjects:
@"ACCEPT",
@"ACCEPT_GIFT",
@"ADD",
@"ANSWER",
@"ADD_TO_CALENDAR",
@"APPLY",
@"ASK",
@"ATTACK",
@"BEAT",
@"BID",
@"BOOK",
@"BOOKMARK",
@"BROWSE",
@"BUY",
@"CAPTURE",
@"CHALLENGE",
@"CHANGE",
@"CHECKIN",
@"CLICK_HERE",
@"CLICK_ME",
@"COLLECT",
@"COMMENT",
@"COMPARE",
@"COMPLAIN",
@"CONFIRM",
@"CONNECT",
@"CONTRIBUTE",
@"COOK",
@"CREATE",
@"DEFEND",
@"DINE",
@"DISCOVER",
@"DISCUSS",
@"DONATE",
@"DOWNLOAD",
@"EARN",
@"EAT",
@"EXPLAIN",
@"FOLLOW",
@"GET",
@"GIFT",
@"GIVE",
@"GO",
@"HELP",
@"IDENTIFY",
@"INSTALL_APP",
@"INTRODUCE",
@"INVITE",
@"JOIN",
@"JOIN_ME",
@"LEARN",
@"LEARN_MORE",
@"LISTEN",
@"LOVE",
@"MAKE",
@"MATCH",
@"OFFER",
@"OPEN",
@"OPEN_APP",
@"OWN",
@"PAY",
@"PIN",
@"PLAN",
@"PLAY",
@"RATE",
@"READ",
@"RECOMMEND",
@"RECORD",
@"REDEEM",
@"REPLY",
@"RESERVE",
@"REVIEW",
@"RSVP",
@"SAVE",
@"SAVE_OFFER",
@"SELL",
@"SEND",
@"SHARE_X",
@"SIGN_IN",
@"SIGN_UP",
@"START",
@"ST0P",
@"TEST",
@"UPVOTE",
@"VIEW",
@"VIEW_ITEM",
@"VIEW_PROFILE",
@"VISIT",
@"VOTE",
@"WANT",
@"WATCH",
@"WRITE",
nil
];
self.selectedCallToAction = [callToActions_ objectAtIndex:0];
self.callToActionPickerView = [[[UIPickerView alloc] init] autorelease];
callToActionPickerView_.delegate = self;
callToActionPickerView_.dataSource = self;
[addCallToActionButtonSwitch_ addTarget:self
action:@selector(addCallToActionSwitched)
forControlEvents:UIControlEventValueChanged];
[self layout];
[self populateTextFields];
@@ -97,12 +219,7 @@
}
- (void)viewDidUnload {
GooglePlusSampleAppDelegate *appDelegate = (GooglePlusSampleAppDelegate *)
[[UIApplication sharedApplication] delegate];
appDelegate.share = nil;
share_.delegate = nil;
[share_ release];
share_ = nil;
[GPPShare sharedInstance].delegate = nil;
[[NSNotificationCenter defaultCenter]
removeObserver:self
name:UIKeyboardWillShowNotification
@@ -112,29 +229,32 @@
name:UIKeyboardWillHideNotification
object:nil];
[self setAttachDeepLinkSwitch:nil];
[self setDeepLinkID:nil];
[self setDeepLinkTitle:nil];
[self setDeepLinkDescription:nil];
[self setDeepLinkThumbnailURL:nil];
[self setAddContentDeepLinkSwitch:nil];
[self setContentDeepLinkID:nil];
[self setContentDeepLinkTitle:nil];
[self setContentDeepLinkDescription:nil];
[self setContentDeepLinkThumbnailURL:nil];
[self setShareScrollView:nil];
[self setShareView:nil];
[self setShareToolbar:nil];
[self setAttachDeepLinkDataLabel:nil];
[self setAddContentDeepLinkLabel:nil];
[self setUrlToShareLabel:nil];
[self setPrefillTextLabel:nil];
[self setDeepLinkIDLabel:nil];
[self setDeepLinkTitleLabel:nil];
[self setDeepLinkDescriptionLabel:nil];
[self setDeepLinkThumbnailURLLabel:nil];
[self setContentDeepLinkIDLabel:nil];
[self setContentDeepLinkTitleLabel:nil];
[self setContentDeepLinkDescriptionLabel:nil];
[self setContentDeepLinkThumbnailURLLabel:nil];
[self setShareButton:nil];
[self setUrlForDeepLinkMetadataSwitch:nil];
[self setUrlForDeepLinkMetadataLabel:nil];
[self setUrlForContentDeepLinkMetadataSwitch:nil];
[self setUrlForContentDeepLinkMetadataLabel:nil];
[self setAddCallToActionButtonSwitch:nil];
[self setAddCallToActionButtonLabel:nil];
[super viewDidUnload];
}
- (void)viewWillAppear:(BOOL)animated {
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad){
if ([[UIDevice currentDevice] userInterfaceIdiom]
== UIUserInterfaceIdiomPad) {
shareScrollView_.frame = self.view.frame;
}
[super viewWillAppear:animated];
@@ -247,30 +367,40 @@
- (IBAction)shareButton:(id)sender {
shareStatus_.text = @"Status: Sharing...";
id<GPPShareBuilder> shareBuilder = [share_ shareDialog];
id<GPPShareBuilder> shareBuilder = [[GPPShare sharedInstance] shareDialog];
NSString *inputURL = shareURL_.text;
NSURL *urlToShare = [inputURL length] ? [NSURL URLWithString:inputURL] : nil;
if (urlToShare) {
shareBuilder = [shareBuilder setURLToShare:urlToShare];
[shareBuilder setURLToShare:urlToShare];
}
if ([deepLinkID_ text]) {
shareBuilder = [shareBuilder setContentDeepLinkID:[deepLinkID_ text]];
NSString *title = [deepLinkTitle_ text];
NSString *description = [deepLinkDescription_ text];
if ([contentDeepLinkID_ text]) {
[shareBuilder setContentDeepLinkID:[contentDeepLinkID_ text]];
NSString *title = [contentDeepLinkTitle_ text];
NSString *description = [contentDeepLinkDescription_ text];
if (title && description) {
NSURL *thumbnailURL = [NSURL URLWithString:[deepLinkThumbnailURL_ text]];
shareBuilder = [shareBuilder setTitle:title
description:description
thumbnailURL:thumbnailURL];
NSURL *thumbnailURL =
[NSURL URLWithString:[contentDeepLinkThumbnailURL_ text]];
[shareBuilder setTitle:title
description:description
thumbnailURL:thumbnailURL];
}
}
NSString *inputText = sharePrefillText_.text;
NSString *text = [inputText length] ? inputText : nil;
if (text) {
shareBuilder = [shareBuilder setPrefillText:text];
[shareBuilder setPrefillText:text];
}
if ([addCallToActionButtonSwitch_ isOn]) {
// Please replace the URL below with your own call-to-action button URL.
NSURL *callToActionURL = [NSURL URLWithString:
@"http://developers.google.com/+/mobile/ios/"];
[shareBuilder setCallToActionButtonWithLabel:selectedCallToAction_
URL:callToActionURL
deepLinkID:@"call-to-action"];
}
if (![shareBuilder open]) {
@@ -289,54 +419,62 @@
[actionSheet showFromToolbar:shareToolbar_];
}
- (IBAction)urlForDeepLinkMetadataSwitchToggle:(id)sender {
- (IBAction)urlForContentDeepLinkMetadataSwitchToggle:(id)sender {
[self layout];
[self populateTextFields];
}
- (IBAction)deepLinkSwitchToggle:(id)sender {
if (!attachDeepLinkSwitch_.on) {
[urlForDeepLinkMetadataSwitch_ setOn:YES];
- (IBAction)contentDeepLinkSwitchToggle:(id)sender {
if (!addContentDeepLinkSwitch_.on) {
[urlForContentDeepLinkMetadataSwitch_ setOn:YES];
}
[self layout];
[self populateTextFields];
}
#pragma mark - helper methods
#pragma mark - Helper methods
- (void) placeView:(UIView *)view x:(CGFloat)x y:(CGFloat)y {
- (void)placeView:(UIView *)view x:(CGFloat)x y:(CGFloat)y {
CGSize frameSize = view.frame.size;
view.frame = CGRectMake(x, y, frameSize.width, frameSize.height);
}
- (void) layout {
- (void)layout {
CGFloat originX = 20.0;
CGFloat originY = 20.0;
CGFloat yPadding = 20.0;
CGFloat originY = 10.0;
CGFloat yPadding = 10.0;
CGFloat currentY = originY;
CGFloat middleX = 150;
// Place the switch for attaching deep-link data.
[self placeView:attachDeepLinkDataLabel_ x:originX y:currentY];
[self placeView:attachDeepLinkSwitch_ x:middleX + 50 y:currentY];
CGSize frameSize = attachDeepLinkSwitch_.frame.size;
// Place the switch for adding call-to-action button.
[self placeView:addCallToActionButtonLabel_ x:originX y:currentY];
[self placeView:addCallToActionButtonSwitch_ x:middleX * 1.5 y:currentY];
CGSize frameSize = addCallToActionButtonSwitch_.frame.size;
currentY += frameSize.height + yPadding;
// Place the switch for attaching content deep-link data.
[self placeView:addContentDeepLinkLabel_ x:originX y:currentY];
[self placeView:addContentDeepLinkSwitch_ x:middleX * 1.5 y:currentY];
frameSize = addContentDeepLinkSwitch_.frame.size;
currentY += frameSize.height + yPadding;
// Place the switch for preview URL.
if (attachDeepLinkSwitch_.on) {
[self placeView:urlForDeepLinkMetadataLabel_ x:originX y:currentY];
[self placeView:urlForDeepLinkMetadataSwitch_ x:middleX + 50 y:currentY];
frameSize = urlForDeepLinkMetadataSwitch_.frame.size;
if (addContentDeepLinkSwitch_.on) {
[self placeView:urlForContentDeepLinkMetadataLabel_ x:originX y:currentY];
[self placeView:urlForContentDeepLinkMetadataSwitch_
x:middleX * 1.5
y:currentY];
frameSize = urlForContentDeepLinkMetadataSwitch_.frame.size;
currentY += frameSize.height + yPadding;
urlForDeepLinkMetadataSwitch_.hidden = NO;
urlForDeepLinkMetadataLabel_.hidden = NO;
urlForContentDeepLinkMetadataSwitch_.hidden = NO;
urlForContentDeepLinkMetadataLabel_.hidden = NO;
} else {
urlForDeepLinkMetadataSwitch_.hidden = YES;
urlForDeepLinkMetadataLabel_.hidden = YES;
urlForContentDeepLinkMetadataSwitch_.hidden = YES;
urlForContentDeepLinkMetadataLabel_.hidden = YES;
}
// Place the field for URL to share.
if (urlForDeepLinkMetadataSwitch_.on) {
if (urlForContentDeepLinkMetadataSwitch_.on) {
[self placeView:urlToShareLabel_ x:originX y:currentY];
frameSize = urlToShareLabel_.frame.size;
currentY += frameSize.height + 0.5 * yPadding;
@@ -360,62 +498,70 @@
currentY += frameSize.height + yPadding;
// Place the content deep-link ID field.
if (attachDeepLinkSwitch_.on) {
[self placeView:deepLinkIDLabel_ x:originX y:currentY];
frameSize = deepLinkIDLabel_.frame.size;
if (addContentDeepLinkSwitch_.on) {
[self placeView:contentDeepLinkIDLabel_ x:originX y:currentY];
frameSize = contentDeepLinkIDLabel_.frame.size;
currentY += frameSize.height + 0.5 * yPadding;
[self placeView:deepLinkID_ x:originX y:currentY];
frameSize = deepLinkID_.frame.size;
[self placeView:contentDeepLinkID_ x:originX y:currentY];
frameSize = contentDeepLinkID_.frame.size;
currentY += frameSize.height + yPadding;
deepLinkIDLabel_.hidden = NO;
deepLinkID_.hidden = NO;
contentDeepLinkIDLabel_.hidden = NO;
contentDeepLinkID_.hidden = NO;
} else {
deepLinkIDLabel_.hidden = YES;
deepLinkID_.hidden = YES;
contentDeepLinkIDLabel_.hidden = YES;
contentDeepLinkID_.hidden = YES;
}
// Place fields for content deep-link metadata.
if (attachDeepLinkSwitch_.on && !urlForDeepLinkMetadataSwitch_.on) {
[self placeView:deepLinkTitleLabel_ x:originX y:currentY];
frameSize = deepLinkTitleLabel_.frame.size;
if (addContentDeepLinkSwitch_.on &&
!urlForContentDeepLinkMetadataSwitch_.on) {
[self placeView:contentDeepLinkTitleLabel_ x:originX y:currentY];
frameSize = contentDeepLinkTitleLabel_.frame.size;
currentY += frameSize.height + 0.5 * yPadding;
[self placeView:deepLinkTitle_ x:originX y:currentY];
frameSize = deepLinkTitle_.frame.size;
[self placeView:contentDeepLinkTitle_ x:originX y:currentY];
frameSize = contentDeepLinkTitle_.frame.size;
currentY += frameSize.height + yPadding;
[self placeView:deepLinkDescriptionLabel_ x:originX y:currentY];
frameSize = deepLinkDescriptionLabel_.frame.size;
[self placeView:contentDeepLinkDescriptionLabel_ x:originX y:currentY];
frameSize = contentDeepLinkDescriptionLabel_.frame.size;
currentY += frameSize.height + 0.5 * yPadding;
[self placeView:deepLinkDescription_ x:originX y:currentY];
frameSize = deepLinkDescription_.frame.size;
[self placeView:contentDeepLinkDescription_ x:originX y:currentY];
frameSize = contentDeepLinkDescription_.frame.size;
currentY += frameSize.height + yPadding;
[self placeView:deepLinkThumbnailURLLabel_ x:originX y:currentY];
frameSize = deepLinkThumbnailURLLabel_.frame.size;
[self placeView:contentDeepLinkThumbnailURLLabel_ x:originX y:currentY];
frameSize = contentDeepLinkThumbnailURLLabel_.frame.size;
currentY += frameSize.height + 0.5 * yPadding;
[self placeView:deepLinkThumbnailURL_ x:originX y:currentY];
frameSize = deepLinkThumbnailURL_.frame.size;
[self placeView:contentDeepLinkThumbnailURL_ x:originX y:currentY];
frameSize = contentDeepLinkThumbnailURL_.frame.size;
currentY += frameSize.height + yPadding;
deepLinkTitle_.hidden = NO;
deepLinkTitleLabel_.hidden = NO;
deepLinkDescriptionLabel_.hidden = NO;
deepLinkDescription_.hidden = NO;
deepLinkThumbnailURLLabel_.hidden = NO;
deepLinkThumbnailURL_.hidden = NO;
contentDeepLinkTitle_.hidden = NO;
contentDeepLinkTitleLabel_.hidden = NO;
contentDeepLinkDescriptionLabel_.hidden = NO;
contentDeepLinkDescription_.hidden = NO;
contentDeepLinkThumbnailURLLabel_.hidden = NO;
contentDeepLinkThumbnailURL_.hidden = NO;
} else {
deepLinkTitle_.hidden = YES;
deepLinkTitleLabel_.hidden = YES;
deepLinkDescriptionLabel_.hidden = YES;
deepLinkDescription_.hidden = YES;
deepLinkThumbnailURLLabel_.hidden = YES;
deepLinkThumbnailURL_.hidden = YES;
contentDeepLinkTitle_.hidden = YES;
contentDeepLinkTitleLabel_.hidden = YES;
contentDeepLinkDescriptionLabel_.hidden = YES;
contentDeepLinkDescription_.hidden = YES;
contentDeepLinkThumbnailURLLabel_.hidden = YES;
contentDeepLinkThumbnailURL_.hidden = YES;
}
// Place the share button and status.
[self placeView:shareButton_ x:originX y:currentY];
[[shareButton_ layer] setCornerRadius:5];
[[shareButton_ layer] setMasksToBounds:YES];
CGColorRef borderColor = [[UIColor colorWithWhite:203.0/255.0
alpha:1.0] CGColor];
[[shareButton_ layer] setBorderColor:borderColor];
[[shareButton_ layer] setBorderWidth:1.0];
[self placeView:shareButton_ x:originX y:currentY + yPadding];
frameSize = shareButton_.frame.size;
currentY += frameSize.height + yPadding;
currentY += frameSize.height + yPadding * 2;
[self placeView:shareStatus_ x:originX y:currentY];
frameSize = shareStatus_.frame.size;
@@ -436,31 +582,32 @@
if (shareURL_.hidden) {
shareURL_.text = @"";
} else {
shareURL_.text = @"http://developers.google.com";
shareURL_.text = @"http://developers.google.com/+/mobile/ios/";
}
if (deepLinkID_.hidden) {
deepLinkID_.text = @"";
if (contentDeepLinkID_.hidden) {
contentDeepLinkID_.text = @"";
} else {
deepLinkID_.text = @"reviews/314159265358";
contentDeepLinkID_.text = @"playlist/314159265358";
}
if (deepLinkTitle_.hidden) {
deepLinkTitle_.text = @"";
if (contentDeepLinkTitle_.hidden) {
contentDeepLinkTitle_.text = @"";
} else {
deepLinkTitle_.text = @"Joe's Diner Review";
contentDeepLinkTitle_.text = @"Joe's Pop Music Playlist";
}
if (deepLinkDescription_.hidden) {
deepLinkDescription_.text = @"";
if (contentDeepLinkDescription_.hidden) {
contentDeepLinkDescription_.text = @"";
} else {
deepLinkDescription_.text = @"Check out my review of the awesome toast!";
contentDeepLinkDescription_.text =
@"Check out this playlist of my favorite pop songs!";
}
if (deepLinkThumbnailURL_.hidden) {
deepLinkThumbnailURL_.text = @"";
if (contentDeepLinkThumbnailURL_.hidden) {
contentDeepLinkThumbnailURL_.text = @"";
} else {
deepLinkThumbnailURL_.text =
contentDeepLinkThumbnailURL_.text =
@"http://www.google.com/logos/2012/childrensday-2012-hp.jpg";
}
}
@@ -495,4 +642,62 @@
return;
}
- (void)addCallToActionSwitched {
if (!addCallToActionButtonSwitch_.on) {
return;
}
[self.view addSubview:callToActionPickerView_];
}
#pragma mark - UIPickerViewDataSource
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {
return 1;
}
- (NSInteger)pickerView:(UIPickerView *)pickerView
numberOfRowsInComponent:(NSInteger)component {
return callToActions_.count;
}
#pragma mark - UIPickerViewDelegate
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row
forComponent:(NSInteger)component reusingView:(UIView *)view {
UITableViewCell *cell = (UITableViewCell *)view;
if (cell == nil) {
cell = [[[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:nil] autorelease];
[cell setBackgroundColor:[UIColor clearColor]];
[cell setBounds: CGRectMake(0, 0, cell.frame.size.width - 20 , 44)];
UITapGestureRecognizer *singleTapGestureRecognizer =
[[[UITapGestureRecognizer alloc]
initWithTarget:self
action:@selector(toggleSelection:)] autorelease];
singleTapGestureRecognizer.numberOfTapsRequired = 1;
[cell addGestureRecognizer:singleTapGestureRecognizer];
}
NSString *callToAction = [callToActions_ objectAtIndex:row];
if ([selectedCallToAction_ isEqualToString:callToAction]) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
} else {
cell.accessoryType = UITableViewCellAccessoryNone;
}
cell.textLabel.text = callToAction;
cell.textLabel.font = [UIFont systemFontOfSize:12];
cell.tag = row;
return cell;
}
- (void)toggleSelection:(UITapGestureRecognizer *)recognizer {
int row = recognizer.view.tag;
self.selectedCallToAction = [callToActions_ objectAtIndex:row];
[callToActionPickerView_ removeFromSuperview];
// Force refresh checked/unchecked marks.
[callToActionPickerView_ reloadAllComponents];
addCallToActionButtonLabel_.text =
[NSString stringWithFormat:@"Call-to-Action: %@", selectedCallToAction_];
}
@end

View File

@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="8.00">
<data>
<int key="IBDocument.SystemTarget">1296</int>
<int key="IBDocument.SystemTarget">1536</int>
<string key="IBDocument.SystemVersion">12C60</string>
<string key="IBDocument.InterfaceBuilderVersion">2549</string>
<string key="IBDocument.InterfaceBuilderVersion">2844</string>
<string key="IBDocument.AppKitVersion">1187.34</string>
<string key="IBDocument.HIToolboxVersion">625.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="NS.object.0">1498</string>
<string key="NS.object.0">1930</string>
</object>
<array key="IBDocument.IntegratedClassDependencies">
<string>IBProxyObject</string>
@@ -43,7 +43,7 @@
<array class="NSMutableArray" key="NSSubviews">
<object class="IBUIScrollView" id="692120268">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">268</int>
<int key="NSvFlags">292</int>
<array class="NSMutableArray" key="NSSubviews">
<object class="IBUITextField" id="914769097">
<reference key="NSNextResponder" ref="692120268"/>
@@ -56,7 +56,7 @@
<bool key="IBUIClipsSubviews">YES</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<int key="IBUIContentVerticalAlignment">0</int>
<string key="IBUIText">http://developers.google.com/</string>
<string key="IBUIText">http://developers.google.com/+/mobile/ios/</string>
<int key="IBUIBorderStyle">3</int>
<object class="NSColor" key="IBUITextColor">
<int key="NSColorSpace">3</int>
@@ -97,6 +97,7 @@
<object class="NSColor" key="IBUITextColor" id="867790682">
<int key="NSColorSpace">1</int>
<bytes key="NSRGB">MCAwIDAAA</bytes>
<string key="IBUIColorCocoaTouchKeyPath">darkTextColor</string>
</object>
<nil key="IBUIHighlightedColor"/>
<int key="IBUIBaselineAdjustment">1</int>
@@ -114,21 +115,22 @@
<object class="IBUIButton" id="483186074">
<reference key="NSNextResponder" ref="692120268"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{31, 255}, {112, 32}}</string>
<string key="NSFrame">{{31, 261}, {112, 32}}</string>
<reference key="NSSuperview" ref="692120268"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="940151781"/>
<reference key="NSNextKeyView" ref="94975264"/>
<bool key="IBUIOpaque">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<int key="IBUIContentHorizontalAlignment">0</int>
<int key="IBUIContentVerticalAlignment">0</int>
<string key="IBUINormalTitle">Share</string>
<object class="NSColor" key="IBUIHighlightedTitleColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MQA</bytes>
</object>
<object class="NSColor" key="IBUINormalTitleColor">
<int key="NSColorSpace">1</int>
<bytes key="NSRGB">MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA</bytes>
<bytes key="NSRGB">MC41MjE1Njg2NTYgMC4wNTU3MzQ0MTc0NyAwLjA4MTU0NTQ3OTkzAA</bytes>
</object>
<object class="NSColor" key="IBUINormalTitleShadowColor">
<int key="NSColorSpace">3</int>
@@ -136,7 +138,7 @@
</object>
<object class="NSCustomResource" key="IBUINormalBackgroundImage">
<string key="NSClassName">NSImage</string>
<string key="NSResourceName">google_plus_share_large.png</string>
<string key="NSResourceName">button_background.png</string>
</object>
<object class="IBUIFontDescription" key="IBUIFontDescription">
<int key="type">2</int>
@@ -171,7 +173,7 @@
<object class="IBUILabel" id="94975264">
<reference key="NSNextResponder" ref="692120268"/>
<int key="NSvFlags">290</int>
<string key="NSFrame">{{38, 306}, {268, 21}}</string>
<string key="NSFrame">{{38, 312}, {268, 21}}</string>
<reference key="NSSuperview" ref="692120268"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="780811294"/>
@@ -191,10 +193,10 @@
<object class="IBUISwitch" id="730147218">
<reference key="NSNextResponder" ref="692120268"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{194, 31}, {94, 27}}</string>
<string key="NSFrame">{{208, 35}, {94, 27}}</string>
<reference key="NSSuperview" ref="692120268"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="555388559"/>
<reference key="NSNextKeyView" ref="108661184"/>
<bool key="IBUIOpaque">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<int key="IBUIContentHorizontalAlignment">0</int>
@@ -204,7 +206,7 @@
<object class="IBUILabel" id="1009258783">
<reference key="NSNextResponder" ref="692120268"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{20, 31}, {172, 21}}</string>
<string key="NSFrame">{{20, 38}, {172, 21}}</string>
<reference key="NSSuperview" ref="692120268"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="730147218"/>
@@ -213,7 +215,7 @@
<int key="IBUIContentMode">7</int>
<bool key="IBUIUserInteractionEnabled">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<string key="IBUIText">Attach deep-link data</string>
<string key="IBUIText">Add content deep link</string>
<reference key="IBUITextColor" ref="867790682"/>
<nil key="IBUIHighlightedColor"/>
<int key="IBUIBaselineAdjustment">1</int>
@@ -254,7 +256,7 @@
<string key="NSFrame">{{26, 247}, {280, 30}}</string>
<reference key="NSSuperview" ref="692120268"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="483186074"/>
<reference key="NSNextKeyView" ref="940151781"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
@@ -282,7 +284,7 @@
<string key="NSFrame">{{26, 292}, {246, 21}}</string>
<reference key="NSSuperview" ref="692120268"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="94975264"/>
<reference key="NSNextKeyView" ref="483186074"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
@@ -331,7 +333,7 @@
<int key="IBUIContentMode">7</int>
<bool key="IBUIUserInteractionEnabled">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<string key="IBUIText">Description (required)</string>
<string key="IBUIText">Description (optional)</string>
<reference key="IBUITextColor" ref="867790682"/>
<nil key="IBUIHighlightedColor"/>
<int key="IBUIBaselineAdjustment">0</int>
@@ -394,7 +396,7 @@
<string key="NSFrame">{{26, 498}, {280, 30}}</string>
<reference key="NSSuperview" ref="692120268"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="819777366"/>
<reference key="NSNextKeyView" ref="555388559"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
@@ -447,7 +449,7 @@
<object class="IBUISwitch" id="514197028">
<reference key="NSNextResponder" ref="692120268"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{194, 66}, {94, 27}}</string>
<string key="NSFrame">{{208, 66}, {94, 27}}</string>
<reference key="NSSuperview" ref="692120268"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="914769097"/>
@@ -461,10 +463,10 @@
<object class="IBUILabel" id="555388559">
<reference key="NSNextResponder" ref="692120268"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{20, 66}, {172, 21}}</string>
<string key="NSFrame">{{20, 4530}, {172, 21}}</string>
<reference key="NSSuperview" ref="692120268"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="108661184"/>
<reference key="NSNextKeyView" ref="819777366"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
@@ -479,11 +481,46 @@
<reference key="IBUIFont" ref="1071033096"/>
<bool key="IBUIAdjustsFontSizeToFit">NO</bool>
</object>
<object class="IBUISwitch" id="897754687">
<reference key="NSNextResponder" ref="692120268"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{208, 4}, {94, 27}}</string>
<reference key="NSSuperview" ref="692120268"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="1009258783"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<int key="IBUIContentHorizontalAlignment">0</int>
<int key="IBUIContentVerticalAlignment">0</int>
<bool key="IBUIOn">YES</bool>
</object>
<object class="IBUILabel" id="976503740">
<reference key="NSNextResponder" ref="692120268"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{20, 4}, {184, 21}}</string>
<reference key="NSSuperview" ref="692120268"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="897754687"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
<int key="IBUIContentMode">7</int>
<bool key="IBUIUserInteractionEnabled">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<string key="IBUIText">Add call-to-action button</string>
<reference key="IBUITextColor" ref="867790682"/>
<nil key="IBUIHighlightedColor"/>
<int key="IBUIBaselineAdjustment">0</int>
<reference key="IBUIFontDescription" ref="1056628031"/>
<reference key="IBUIFont" ref="1071033096"/>
<bool key="IBUIAdjustsFontSizeToFit">NO</bool>
</object>
</array>
<string key="NSFrameSize">{320, 372}</string>
<reference key="NSSuperview" ref="191373211"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="1009258783"/>
<reference key="NSNextKeyView" ref="976503740"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIClipsSubviews">YES</bool>
<bool key="IBUIMultipleTouchEnabled">YES</bool>
@@ -557,7 +594,7 @@
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">deepLinkThumbnailURLLabel</string>
<string key="label">contentDeepLinkThumbnailURLLabel</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="929696688"/>
</object>
@@ -565,7 +602,7 @@
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">attachDeepLinkDataLabel</string>
<string key="label">addContentDeepLinkLabel</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="1009258783"/>
</object>
@@ -581,7 +618,7 @@
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">deepLinkTitle</string>
<string key="label">contentDeepLinkTitle</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="493309249"/>
</object>
@@ -597,7 +634,7 @@
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">deepLinkDescriptionLabel</string>
<string key="label">contentDeepLinkDescriptionLabel</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="979896692"/>
</object>
@@ -613,7 +650,7 @@
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">deepLinkTitleLabel</string>
<string key="label">contentDeepLinkTitleLabel</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="780811294"/>
</object>
@@ -621,7 +658,7 @@
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">urlForDeepLinkMetadataLabel</string>
<string key="label">urlForContentDeepLinkMetadataLabel</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="555388559"/>
</object>
@@ -629,7 +666,7 @@
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">deepLinkThumbnailURL</string>
<string key="label">contentDeepLinkThumbnailURL</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="700280641"/>
</object>
@@ -645,7 +682,7 @@
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">deepLinkDescription</string>
<string key="label">contentDeepLinkDescription</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="1057338581"/>
</object>
@@ -661,7 +698,7 @@
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">attachDeepLinkSwitch</string>
<string key="label">addContentDeepLinkSwitch</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="730147218"/>
</object>
@@ -685,7 +722,7 @@
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">deepLinkIDLabel</string>
<string key="label">contentDeepLinkIDLabel</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="940151781"/>
</object>
@@ -693,7 +730,7 @@
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">urlForDeepLinkMetadataSwitch</string>
<string key="label">urlForContentDeepLinkMetadataSwitch</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="514197028"/>
</object>
@@ -701,12 +738,28 @@
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">deepLinkID</string>
<string key="label">contentDeepLinkID</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="341080542"/>
</object>
<int key="connectionID">48</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">addCallToActionButtonLabel</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="976503740"/>
</object>
<int key="connectionID">68</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">addCallToActionButtonSwitch</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="897754687"/>
</object>
<int key="connectionID">69</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">delegate</string>
@@ -742,7 +795,7 @@
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">deepLinkSwitchToggle:</string>
<string key="label">contentDeepLinkSwitchToggle:</string>
<reference key="source" ref="730147218"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">13</int>
@@ -783,7 +836,7 @@
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">urlForDeepLinkMetadataSwitchToggle:</string>
<string key="label">urlForContentDeepLinkMetadataSwitchToggle:</string>
<reference key="source" ref="514197028"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">13</int>
@@ -860,6 +913,8 @@
<reference ref="514197028"/>
<reference ref="555388559"/>
<reference ref="341080542"/>
<reference ref="976503740"/>
<reference ref="897754687"/>
</array>
<reference key="parent" ref="191373211"/>
</object>
@@ -953,6 +1008,16 @@
<reference key="object" ref="341080542"/>
<reference key="parent" ref="692120268"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">65</int>
<reference key="object" ref="897754687"/>
<reference key="parent" ref="692120268"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">66</int>
<reference key="object" ref="976503740"/>
<reference key="parent" ref="692120268"/>
</object>
</array>
</object>
<dictionary class="NSMutableDictionary" key="flattenedProperties">
@@ -982,6 +1047,8 @@
<string key="6.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="60.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="61.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="65.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="66.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="7.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="8.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="9.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
@@ -990,7 +1057,7 @@
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
<int key="maxID">64</int>
<int key="maxID">69</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -998,14 +1065,14 @@
<string key="className">GooglePlusSampleShareViewController</string>
<string key="superclassName">UIViewController</string>
<dictionary class="NSMutableDictionary" key="actions">
<string key="deepLinkSwitchToggle:">id</string>
<string key="contentDeepLinkSwitchToggle:">id</string>
<string key="shareButton:">id</string>
<string key="shareToolbar:">id</string>
<string key="urlForDeepLinkMetadataSwitchToggle:">id</string>
<string key="urlForContentDeepLinkMetadataSwitchToggle:">id</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="actionInfosByName">
<object class="IBActionInfo" key="deepLinkSwitchToggle:">
<string key="name">deepLinkSwitchToggle:</string>
<object class="IBActionInfo" key="contentDeepLinkSwitchToggle:">
<string key="name">contentDeepLinkSwitchToggle:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo" key="shareButton:">
@@ -1016,22 +1083,24 @@
<string key="name">shareToolbar:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo" key="urlForDeepLinkMetadataSwitchToggle:">
<string key="name">urlForDeepLinkMetadataSwitchToggle:</string>
<object class="IBActionInfo" key="urlForContentDeepLinkMetadataSwitchToggle:">
<string key="name">urlForContentDeepLinkMetadataSwitchToggle:</string>
<string key="candidateClassName">id</string>
</object>
</dictionary>
<dictionary class="NSMutableDictionary" key="outlets">
<string key="attachDeepLinkDataLabel">UILabel</string>
<string key="attachDeepLinkSwitch">UISwitch</string>
<string key="deepLinkDescription">UITextField</string>
<string key="deepLinkDescriptionLabel">UILabel</string>
<string key="deepLinkID">UITextField</string>
<string key="deepLinkIDLabel">UILabel</string>
<string key="deepLinkThumbnailURL">UITextField</string>
<string key="deepLinkThumbnailURLLabel">UILabel</string>
<string key="deepLinkTitle">UITextField</string>
<string key="deepLinkTitleLabel">UILabel</string>
<string key="addCallToActionButtonLabel">UILabel</string>
<string key="addCallToActionButtonSwitch">UISwitch</string>
<string key="addContentDeepLinkLabel">UILabel</string>
<string key="addContentDeepLinkSwitch">UISwitch</string>
<string key="contentDeepLinkDescription">UITextField</string>
<string key="contentDeepLinkDescriptionLabel">UILabel</string>
<string key="contentDeepLinkID">UITextField</string>
<string key="contentDeepLinkIDLabel">UILabel</string>
<string key="contentDeepLinkThumbnailURL">UITextField</string>
<string key="contentDeepLinkThumbnailURLLabel">UILabel</string>
<string key="contentDeepLinkTitle">UITextField</string>
<string key="contentDeepLinkTitleLabel">UILabel</string>
<string key="prefillTextLabel">UILabel</string>
<string key="shareButton">UIButton</string>
<string key="sharePrefillText">UITextField</string>
@@ -1040,49 +1109,57 @@
<string key="shareToolbar">UIToolbar</string>
<string key="shareURL">UITextField</string>
<string key="shareView">UIView</string>
<string key="urlForDeepLinkMetadataLabel">UILabel</string>
<string key="urlForDeepLinkMetadataSwitch">UISwitch</string>
<string key="urlForContentDeepLinkMetadataLabel">UILabel</string>
<string key="urlForContentDeepLinkMetadataSwitch">UISwitch</string>
<string key="urlToShareLabel">UILabel</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="toOneOutletInfosByName">
<object class="IBToOneOutletInfo" key="attachDeepLinkDataLabel">
<string key="name">attachDeepLinkDataLabel</string>
<object class="IBToOneOutletInfo" key="addCallToActionButtonLabel">
<string key="name">addCallToActionButtonLabel</string>
<string key="candidateClassName">UILabel</string>
</object>
<object class="IBToOneOutletInfo" key="attachDeepLinkSwitch">
<string key="name">attachDeepLinkSwitch</string>
<object class="IBToOneOutletInfo" key="addCallToActionButtonSwitch">
<string key="name">addCallToActionButtonSwitch</string>
<string key="candidateClassName">UISwitch</string>
</object>
<object class="IBToOneOutletInfo" key="deepLinkDescription">
<string key="name">deepLinkDescription</string>
<string key="candidateClassName">UITextField</string>
</object>
<object class="IBToOneOutletInfo" key="deepLinkDescriptionLabel">
<string key="name">deepLinkDescriptionLabel</string>
<object class="IBToOneOutletInfo" key="addContentDeepLinkLabel">
<string key="name">addContentDeepLinkLabel</string>
<string key="candidateClassName">UILabel</string>
</object>
<object class="IBToOneOutletInfo" key="deepLinkID">
<string key="name">deepLinkID</string>
<object class="IBToOneOutletInfo" key="addContentDeepLinkSwitch">
<string key="name">addContentDeepLinkSwitch</string>
<string key="candidateClassName">UISwitch</string>
</object>
<object class="IBToOneOutletInfo" key="contentDeepLinkDescription">
<string key="name">contentDeepLinkDescription</string>
<string key="candidateClassName">UITextField</string>
</object>
<object class="IBToOneOutletInfo" key="deepLinkIDLabel">
<string key="name">deepLinkIDLabel</string>
<object class="IBToOneOutletInfo" key="contentDeepLinkDescriptionLabel">
<string key="name">contentDeepLinkDescriptionLabel</string>
<string key="candidateClassName">UILabel</string>
</object>
<object class="IBToOneOutletInfo" key="deepLinkThumbnailURL">
<string key="name">deepLinkThumbnailURL</string>
<object class="IBToOneOutletInfo" key="contentDeepLinkID">
<string key="name">contentDeepLinkID</string>
<string key="candidateClassName">UITextField</string>
</object>
<object class="IBToOneOutletInfo" key="deepLinkThumbnailURLLabel">
<string key="name">deepLinkThumbnailURLLabel</string>
<object class="IBToOneOutletInfo" key="contentDeepLinkIDLabel">
<string key="name">contentDeepLinkIDLabel</string>
<string key="candidateClassName">UILabel</string>
</object>
<object class="IBToOneOutletInfo" key="deepLinkTitle">
<string key="name">deepLinkTitle</string>
<object class="IBToOneOutletInfo" key="contentDeepLinkThumbnailURL">
<string key="name">contentDeepLinkThumbnailURL</string>
<string key="candidateClassName">UITextField</string>
</object>
<object class="IBToOneOutletInfo" key="deepLinkTitleLabel">
<string key="name">deepLinkTitleLabel</string>
<object class="IBToOneOutletInfo" key="contentDeepLinkThumbnailURLLabel">
<string key="name">contentDeepLinkThumbnailURLLabel</string>
<string key="candidateClassName">UILabel</string>
</object>
<object class="IBToOneOutletInfo" key="contentDeepLinkTitle">
<string key="name">contentDeepLinkTitle</string>
<string key="candidateClassName">UITextField</string>
</object>
<object class="IBToOneOutletInfo" key="contentDeepLinkTitleLabel">
<string key="name">contentDeepLinkTitleLabel</string>
<string key="candidateClassName">UILabel</string>
</object>
<object class="IBToOneOutletInfo" key="prefillTextLabel">
@@ -1117,12 +1194,12 @@
<string key="name">shareView</string>
<string key="candidateClassName">UIView</string>
</object>
<object class="IBToOneOutletInfo" key="urlForDeepLinkMetadataLabel">
<string key="name">urlForDeepLinkMetadataLabel</string>
<object class="IBToOneOutletInfo" key="urlForContentDeepLinkMetadataLabel">
<string key="name">urlForContentDeepLinkMetadataLabel</string>
<string key="candidateClassName">UILabel</string>
</object>
<object class="IBToOneOutletInfo" key="urlForDeepLinkMetadataSwitch">
<string key="name">urlForDeepLinkMetadataSwitch</string>
<object class="IBToOneOutletInfo" key="urlForContentDeepLinkMetadataSwitch">
<string key="name">urlForContentDeepLinkMetadataSwitch</string>
<string key="candidateClassName">UISwitch</string>
</object>
<object class="IBToOneOutletInfo" key="urlToShareLabel">
@@ -1141,14 +1218,14 @@
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS</string>
<real value="1296" key="NS.object.0"/>
<real value="1536" key="NS.object.0"/>
</object>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
<object class="NSMutableDictionary" key="IBDocument.LastKnownImageSizes">
<string key="NS.key.0">google_plus_share_large.png</string>
<string key="NS.object.0">{112, 32}</string>
<string key="NS.key.0">button_background.png</string>
<string key="NS.object.0">{1, 1}</string>
</object>
<string key="IBCocoaTouchPluginVersion">1498</string>
<string key="IBCocoaTouchPluginVersion">1930</string>
</data>
</archive>

View File

@@ -35,9 +35,8 @@
@property (retain, nonatomic) IBOutlet UILabel *signInDisplayName;
// A button to sign out of this application.
@property (retain, nonatomic) IBOutlet UIButton *signOutButton;
// A switch for whether to request for Google+ History's
// https://www.googleapis.com/auth/plus.moments.write scope.
@property (retain, nonatomic) IBOutlet UISwitch *plusMomentsWriteScope;
// A button to disconnect user from this application.
@property (retain, nonatomic) IBOutlet UIButton *disconnectButton;
// A switch for whether to request
// https://www.googleapis.com/auth/userinfo.email scope to get user's email
// address after the sign-in action.
@@ -45,9 +44,8 @@
// Called when the user presses the "Sign out" button.
- (IBAction)signOut:(id)sender;
// Called when the user toggles Google+ History's
// https://www.googleapis.com/auth/plus.moments.write scope.
- (IBAction)plusMomentsWriteScopeToggle:(id)sender;
// Called when the user presses the "Disconnect" button.
- (IBAction)disconnect:(id)sender;
// Called when the user toggles the
// https://www.googleapis.com/auth/userinfo.email scope.
- (IBAction)userinfoEmailScopeToggle:(id)sender;

View File

@@ -19,22 +19,13 @@
#import "GooglePlusSampleSignInViewController.h"
#import <QuartzCore/QuartzCore.h>
#import "GooglePlusSampleAppDelegate.h"
#import "GPPSignIn.h"
#import "GPPSignInButton.h"
#import "GTLPlus.h"
#import "GTLPlusConstants.h"
#import "GTLQueryPlus.h"
#import "GTLServicePlus.h"
#import "GTMLogger.h"
#import "GTMOAuth2Authentication.h"
@interface GooglePlusSampleSignInViewController () {
// Saved state of |userinfoEmailScope_.on|.
BOOL savedUserinfoEmailScopeState_;
}
- (GooglePlusSampleAppDelegate *)appDelegate;
- (void)setSignInScopes;
@interface GooglePlusSampleSignInViewController ()
- (void)enableSignInSettings:(BOOL)enable;
- (void)reportAuthStatus;
- (void)retrieveUserInfo;
@@ -46,7 +37,7 @@
@synthesize signInAuthStatus = signInAuthStatus_;
@synthesize signInDisplayName = signInDisplayName_;
@synthesize signOutButton = signOutButton_;
@synthesize plusMomentsWriteScope = plusMomentsWriteScope_;
@synthesize disconnectButton = disconnectButton_;
@synthesize userinfoEmailScope = userinfoEmailScope_;
- (void)dealloc {
@@ -54,44 +45,52 @@
[signInAuthStatus_ release];
[signInDisplayName_ release];
[signOutButton_ release];
[userinfoEmailScope_ release];
[super dealloc];
}
#pragma mark - View lifecycle
- (void)viewDidLoad {
GooglePlusSampleAppDelegate *appDelegate = [self appDelegate];
plusMomentsWriteScope_.on = appDelegate.plusMomentsWriteScope;
userinfoEmailScope_.on = savedUserinfoEmailScopeState_;
// Make sure the GPPSignInButton class is linked in because references from
// xib file doesn't count.
[GPPSignInButton class];
// Set up sign-out button.
[[signOutButton_ layer] setCornerRadius:5];
[[signOutButton_ layer] setMasksToBounds:YES];
CGColorRef borderColor = [[UIColor colorWithWhite:203.0/255.0
alpha:1.0] CGColor];
[[signOutButton_ layer] setBorderColor:borderColor];
[[signOutButton_ layer] setBorderWidth:1.0];
GPPSignIn *signIn = [GPPSignIn sharedInstance];
userinfoEmailScope_.on =
signIn.shouldFetchGoogleUserEmail;
// Set up sign-out and disconnect buttons.
[self setUpButton:signOutButton_];
[self setUpButton:disconnectButton_];
// Set up sample view of Google+ sign-in.
signInButton_.delegate = self;
signInButton_.shouldFetchGoogleUserEmail = userinfoEmailScope_.on;
signInButton_.clientID = [GooglePlusSampleAppDelegate clientID];
[self setSignInScopes];
// The client ID has been set in the app delegate.
signIn.delegate = self;
signIn.shouldFetchGoogleUserEmail = userinfoEmailScope_.on;
signIn.actions = [NSArray arrayWithObjects:
@"http://schemas.google.com/AddActivity",
@"http://schemas.google.com/BuyActivity",
@"http://schemas.google.com/CheckInActivity",
@"http://schemas.google.com/CommentActivity",
@"http://schemas.google.com/CreateActivity",
@"http://schemas.google.com/ListenActivity",
@"http://schemas.google.com/ReserveActivity",
@"http://schemas.google.com/ReviewActivity",
nil];
appDelegate.signInButton = signInButton_;
[self reportAuthStatus];
[signIn trySilentAuthentication];
[super viewDidLoad];
}
- (void)viewWillDisappear:(BOOL)animated {
GooglePlusSampleAppDelegate *appDelegate = [self appDelegate];
appDelegate.plusMomentsWriteScope = plusMomentsWriteScope_.on;
savedUserinfoEmailScopeState_ = userinfoEmailScope_.on;
}
- (void)viewDidUnload {
GooglePlusSampleAppDelegate *appDelegate = [self appDelegate];
appDelegate.signInButton = nil;
[self setSignInButton:nil];
[self setSignInAuthStatus:nil];
[self setSignInDisplayName:nil];
[self setSignOutButton:nil];
[self setDisconnectButton:nil];
[self setUserinfoEmailScope:nil];
[super viewDidUnload];
}
@@ -104,37 +103,38 @@
[NSString stringWithFormat:@"Status: Authentication error: %@", error];
return;
}
GooglePlusSampleAppDelegate *appDelegate = [self appDelegate];
appDelegate.auth = auth;
[self reportAuthStatus];
}
- (void)didDisconnectWithError:(NSError *)error {
if (error) {
signInAuthStatus_.text =
[NSString stringWithFormat:@"Status: Failed to disconnect: %@", error];
} else {
signInAuthStatus_.text =
[NSString stringWithFormat:@"Status: Disconnected"];
signInDisplayName_.text = @"";
[self enableSignInSettings:YES];
}
}
#pragma mark - Helper methods
- (GooglePlusSampleAppDelegate *)appDelegate {
return (GooglePlusSampleAppDelegate *)
[[UIApplication sharedApplication] delegate];
}
- (void)setSignInScopes {
signInButton_.scope = plusMomentsWriteScope_.on ?
[NSArray arrayWithObjects:
@"https://www.googleapis.com/auth/plus.moments.write",
@"https://www.googleapis.com/auth/plus.me",
nil] :
[NSArray arrayWithObjects:
@"https://www.googleapis.com/auth/plus.me",
nil];
- (void)setUpButton:(UIButton *)button {
[[button layer] setCornerRadius:5];
[[button layer] setMasksToBounds:YES];
CGColorRef borderColor = [[UIColor colorWithWhite:203.0/255.0
alpha:1.0] CGColor];
[[button layer] setBorderColor:borderColor];
[[button layer] setBorderWidth:1.0];
}
- (void)enableSignInSettings:(BOOL)enable {
plusMomentsWriteScope_.enabled = enable;
userinfoEmailScope_.enabled = enable && !plusMomentsWriteScope_.on;
userinfoEmailScope_.enabled = enable;
}
- (void)reportAuthStatus {
GooglePlusSampleAppDelegate *appDelegate = [self appDelegate];
if (appDelegate.auth) {
if ([GPPSignIn sharedInstance].authentication) {
signInAuthStatus_.text = @"Status: Authenticated";
[self retrieveUserInfo];
[self enableSignInSettings:NO];
@@ -146,36 +146,26 @@
}
- (void)retrieveUserInfo {
GooglePlusSampleAppDelegate *appDelegate = [self appDelegate];
if (appDelegate.auth.userEmail) {
signInDisplayName_.text = appDelegate.auth.userEmail;
} else {
signInDisplayName_.text = @"";
}
signInDisplayName_.text = [NSString stringWithFormat:@"Email: %@",
[GPPSignIn sharedInstance].authentication.userEmail];
}
#pragma mark - IBActions
- (IBAction)signOut:(id)sender {
[[signInButton_ googlePlusSignIn] signOut];
GooglePlusSampleAppDelegate *appDelegate = [self appDelegate];
appDelegate.auth = nil;
[[GPPSignIn sharedInstance] signOut];
[self reportAuthStatus];
signInDisplayName_.text = @"";
}
- (IBAction)plusMomentsWriteScopeToggle:(id)sender {
[self setSignInScopes];
userinfoEmailScope_.enabled = !plusMomentsWriteScope_.on;
if (plusMomentsWriteScope_.on) {
userinfoEmailScope_.on = NO;
}
- (IBAction)disconnect:(id)sender {
[[GPPSignIn sharedInstance] disconnect];
}
- (IBAction)userinfoEmailScopeToggle:(id)sender {
signInButton_.shouldFetchGoogleUserEmail = userinfoEmailScope_.on;
[GPPSignIn sharedInstance].shouldFetchGoogleUserEmail =
userinfoEmailScope_.on;
}
@end

View File

@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="8.00">
<data>
<int key="IBDocument.SystemTarget">1536</int>
<string key="IBDocument.SystemVersion">12C54</string>
<string key="IBDocument.InterfaceBuilderVersion">2843</string>
<int key="IBDocument.SystemTarget">1552</int>
<string key="IBDocument.SystemVersion">12C60</string>
<string key="IBDocument.InterfaceBuilderVersion">3084</string>
<string key="IBDocument.AppKitVersion">1187.34</string>
<string key="IBDocument.HIToolboxVersion">625.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="NS.object.0">1929</string>
<string key="NS.object.0">2083</string>
</object>
<array key="IBDocument.IntegratedClassDependencies">
<string>IBProxyObject</string>
@@ -40,10 +40,10 @@
<object class="IBUIButton" id="306965198">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{19, 218}, {119, 35}}</string>
<string key="NSFrame">{{19, 171}, {117, 35}}</string>
<reference key="NSSuperview" ref="191373211"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="419255470"/>
<reference key="NSNextKeyView" ref="81911376"/>
<bool key="IBUIOpaque">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<int key="IBUIContentHorizontalAlignment">0</int>
@@ -57,19 +57,19 @@
<int key="NSColorSpace">1</int>
<bytes key="NSRGB">MC42MzUyOTQxMTc2IDAuMzIxNTY4NjI3NSAwLjI1ODgyMzUyOTQAA</bytes>
</object>
<object class="NSColor" key="IBUINormalTitleShadowColor">
<object class="NSColor" key="IBUINormalTitleShadowColor" id="292633723">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MC41AA</bytes>
</object>
<object class="NSCustomResource" key="IBUINormalBackgroundImage">
<object class="NSCustomResource" key="IBUINormalBackgroundImage" id="497516568">
<string key="NSClassName">NSImage</string>
<string key="NSResourceName">button_background.png</string>
</object>
<object class="IBUIFontDescription" key="IBUIFontDescription">
<object class="IBUIFontDescription" key="IBUIFontDescription" id="579453245">
<int key="type">2</int>
<double key="pointSize">15</double>
</object>
<object class="NSFont" key="IBUIFont">
<object class="NSFont" key="IBUIFont" id="966414073">
<string key="NSName">Helvetica-Bold</string>
<double key="NSSize">15</double>
<int key="NSfFlags">16</int>
@@ -78,7 +78,7 @@
<object class="IBUIView" id="984977003">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{18, 159}, {118, 32}}</string>
<string key="NSFrame">{{18, 112}, {118, 32}}</string>
<reference key="NSSuperview" ref="191373211"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="306965198"/>
@@ -94,7 +94,7 @@
<object class="IBUILabel" id="419255470">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">290</int>
<string key="NSFrame">{{20, 288}, {280, 21}}</string>
<string key="NSFrame">{{20, 241}, {280, 21}}</string>
<reference key="NSSuperview" ref="191373211"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="534305484"/>
@@ -125,10 +125,9 @@
<object class="IBUILabel" id="534305484">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">290</int>
<string key="NSFrame">{{20, 317}, {280, 21}}</string>
<string key="NSFrame">{{20, 270}, {280, 65}}</string>
<reference key="NSSuperview" ref="191373211"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="11644204"/>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
<int key="IBUIContentMode">7</int>
@@ -139,58 +138,25 @@
<nil key="IBUIHighlightedColor"/>
<int key="IBUIBaselineAdjustment">1</int>
<float key="IBUIMinimumFontSize">13</float>
<int key="IBUINumberOfLines">2</int>
<reference key="IBUIFontDescription" ref="136904364"/>
<reference key="IBUIFont" ref="445796440"/>
<double key="preferredMaxLayoutWidth">280</double>
</object>
<object class="IBUISwitch" id="167649888">
<object class="IBUILabel" id="11644204">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{191, 99}, {94, 27}}</string>
<string key="NSFrame">{{18, 15}, {273, 21}}</string>
<reference key="NSSuperview" ref="191373211"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="175024995"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<int key="IBUIContentHorizontalAlignment">0</int>
<int key="IBUIContentVerticalAlignment">0</int>
<bool key="IBUIOn">YES</bool>
</object>
<object class="IBUILabel" id="11644204">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{18, 20}, {273, 21}}</string>
<reference key="NSSuperview" ref="191373211"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="929313605"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
<int key="IBUIContentMode">7</int>
<bool key="IBUIUserInteractionEnabled">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<string key="IBUIText">Scopes setting (sign out to change)</string>
<reference key="IBUITextColor" ref="515161017"/>
<nil key="IBUIHighlightedColor"/>
<int key="IBUIBaselineAdjustment">0</int>
<reference key="IBUIFontDescription" ref="136904364"/>
<reference key="IBUIFont" ref="445796440"/>
<bool key="IBUIAdjustsFontSizeToFit">NO</bool>
</object>
<object class="IBUILabel" id="929313605">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{20, 99}, {177, 27}}</string>
<reference key="NSSuperview" ref="191373211"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="167649888"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
<int key="IBUIContentMode">7</int>
<bool key="IBUIUserInteractionEnabled">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<string key="IBUIText">plus.moments.write</string>
<string key="IBUIText">Sign-in setting (sign out to change)</string>
<reference key="IBUITextColor" ref="515161017"/>
<nil key="IBUIHighlightedColor"/>
<int key="IBUIBaselineAdjustment">0</int>
@@ -201,7 +167,7 @@
<object class="IBUILabel" id="175024995">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{19, 58}, {178, 27}}</string>
<string key="NSFrame">{{18, 44}, {197, 27}}</string>
<reference key="NSSuperview" ref="191373211"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="300876298"/>
@@ -211,7 +177,7 @@
<int key="IBUIContentMode">7</int>
<bool key="IBUIUserInteractionEnabled">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<string key="IBUIText">userinfo.email</string>
<string key="IBUIText">get userinfo.email scope</string>
<reference key="IBUITextColor" ref="515161017"/>
<nil key="IBUIHighlightedColor"/>
<int key="IBUIBaselineAdjustment">0</int>
@@ -222,9 +188,10 @@
<object class="IBUISwitch" id="300876298">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{191, 58}, {94, 27}}</string>
<string key="NSFrame">{{208, 44}, {94, 27}}</string>
<reference key="NSSuperview" ref="191373211"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="984977003"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
@@ -232,11 +199,36 @@
<int key="IBUIContentHorizontalAlignment">0</int>
<int key="IBUIContentVerticalAlignment">0</int>
</object>
<object class="IBUIButton" id="81911376">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{181, 171}, {119, 35}}</string>
<reference key="NSSuperview" ref="191373211"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="419255470"/>
<bool key="IBUIOpaque">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<int key="IBUIContentHorizontalAlignment">0</int>
<int key="IBUIContentVerticalAlignment">0</int>
<string key="IBUINormalTitle">Disconnect</string>
<object class="NSColor" key="IBUIHighlightedTitleColor">
<int key="NSColorSpace">1</int>
<bytes key="NSRGB">MC42MzUyOTQxMTc2IDAuMzIxNTY4NjI3NSAwLjI1ODgyMzUyOTQAA</bytes>
</object>
<object class="NSColor" key="IBUINormalTitleColor">
<int key="NSColorSpace">1</int>
<bytes key="NSRGB">MC42MzUyOTQxMTc2IDAuMzIxNTY4NjI3NSAwLjI1ODgyMzUyOTQAA</bytes>
</object>
<reference key="IBUINormalTitleShadowColor" ref="292633723"/>
<reference key="IBUINormalBackgroundImage" ref="497516568"/>
<reference key="IBUIFontDescription" ref="579453245"/>
<reference key="IBUIFont" ref="966414073"/>
</object>
</array>
<string key="NSFrame">{{0, 20}, {320, 460}}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="984977003"/>
<reference key="NSNextKeyView" ref="11644204"/>
<object class="NSColor" key="IBUIBackgroundColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MQA</bytes>
@@ -288,14 +280,6 @@
</object>
<int key="connectionID">28</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">plusMomentsWriteScope</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="167649888"/>
</object>
<int key="connectionID">35</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">userinfoEmailScope</string>
@@ -304,6 +288,14 @@
</object>
<int key="connectionID">39</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">disconnectButton</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="81911376"/>
</object>
<int key="connectionID">51</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">signOut:</string>
@@ -313,15 +305,6 @@
</object>
<int key="connectionID">26</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">plusMomentsWriteScopeToggle:</string>
<reference key="source" ref="167649888"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">13</int>
</object>
<int key="connectionID">36</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">userinfoEmailScopeToggle:</string>
@@ -331,6 +314,15 @@
</object>
<int key="connectionID">40</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">disconnect:</string>
<reference key="source" ref="81911376"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">7</int>
</object>
<int key="connectionID">50</int>
</object>
</array>
<object class="IBMutableOrderedSet" key="objectRecords">
<array key="orderedObjects">
@@ -347,12 +339,11 @@
<reference ref="306965198"/>
<reference ref="984977003"/>
<reference ref="419255470"/>
<reference ref="167649888"/>
<reference ref="929313605"/>
<reference ref="300876298"/>
<reference ref="175024995"/>
<reference ref="11644204"/>
<reference ref="534305484"/>
<reference ref="175024995"/>
<reference ref="81911376"/>
</array>
<reference key="parent" ref="0"/>
</object>
@@ -388,8 +379,13 @@
<reference key="parent" ref="191373211"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">29</int>
<reference key="object" ref="167649888"/>
<int key="objectID">37</int>
<reference key="object" ref="175024995"/>
<reference key="parent" ref="191373211"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">38</int>
<reference key="object" ref="300876298"/>
<reference key="parent" ref="191373211"/>
</object>
<object class="IBObjectRecord">
@@ -398,18 +394,8 @@
<reference key="parent" ref="191373211"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">34</int>
<reference key="object" ref="929313605"/>
<reference key="parent" ref="191373211"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">37</int>
<reference key="object" ref="175024995"/>
<reference key="parent" ref="191373211"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">38</int>
<reference key="object" ref="300876298"/>
<int key="objectID">48</int>
<reference key="object" ref="81911376"/>
<reference key="parent" ref="191373211"/>
</object>
</array>
@@ -422,11 +408,11 @@
<string key="1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="22.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="27.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="29.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="30.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="34.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="37.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="38.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="48.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<real value="0.0" key="48.IBUIButtonInspectorSelectedStateConfigurationMetadataKey"/>
<string key="6.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<real value="0.0" key="6.IBUIButtonInspectorSelectedStateConfigurationMetadataKey"/>
<string key="7.CustomClassName">GPPSignInButton</string>
@@ -436,13 +422,13 @@
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
<int key="maxID">40</int>
<int key="maxID">51</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
<object class="IBPartialClassDescription">
<string key="className">GPPSignInButton</string>
<string key="superclassName">UIView</string>
<string key="superclassName">UIButton</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/GPPSignInButton.h</string>
@@ -452,13 +438,13 @@
<string key="className">GooglePlusSampleSignInViewController</string>
<string key="superclassName">UIViewController</string>
<dictionary class="NSMutableDictionary" key="actions">
<string key="plusMomentsWriteScopeToggle:">id</string>
<string key="disconnect:">id</string>
<string key="signOut:">id</string>
<string key="userinfoEmailScopeToggle:">id</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="actionInfosByName">
<object class="IBActionInfo" key="plusMomentsWriteScopeToggle:">
<string key="name">plusMomentsWriteScopeToggle:</string>
<object class="IBActionInfo" key="disconnect:">
<string key="name">disconnect:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo" key="signOut:">
@@ -471,7 +457,7 @@
</object>
</dictionary>
<dictionary class="NSMutableDictionary" key="outlets">
<string key="plusMomentsWriteScope">UISwitch</string>
<string key="disconnectButton">UIButton</string>
<string key="signInAuthStatus">UILabel</string>
<string key="signInButton">GPPSignInButton</string>
<string key="signInDisplayName">UILabel</string>
@@ -479,9 +465,9 @@
<string key="userinfoEmailScope">UISwitch</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="toOneOutletInfosByName">
<object class="IBToOneOutletInfo" key="plusMomentsWriteScope">
<string key="name">plusMomentsWriteScope</string>
<string key="candidateClassName">UISwitch</string>
<object class="IBToOneOutletInfo" key="disconnectButton">
<string key="name">disconnectButton</string>
<string key="candidateClassName">UIButton</string>
</object>
<object class="IBToOneOutletInfo" key="signInAuthStatus">
<string key="name">signInAuthStatus</string>
@@ -515,7 +501,7 @@
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS</string>
<real value="1536" key="NS.object.0"/>
<real value="1552" key="NS.object.0"/>
</object>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
@@ -523,6 +509,6 @@
<string key="NS.key.0">button_background.png</string>
<string key="NS.object.0">{1, 1}</string>
</object>
<string key="IBCocoaTouchPluginVersion">1929</string>
<string key="IBCocoaTouchPluginVersion">2083</string>
</data>
</archive>

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB