Browse files

Merge branch 'master' of github.com:chute/photo-picker-plus

  • Loading branch information...
2 parents bb06437 + a3e1712 commit 264a2c7368f91b42feda12dd2f7165f9c227e569 @bluewhalelabs bluewhalelabs committed Feb 16, 2012
Showing with 328 additions and 191 deletions.
  1. +1 −1 Android/ChutePhotoPicker+/README.md
  2. BIN Android/ChutePhotoPicker+/screenshots/SS_Slidechute2.png
  3. BIN Android/ChutePhotoPicker+/screenshots/SS_Slidechute3.png
  4. BIN Android/ChutePhotoPicker+/screenshots/SS_Slidechute4.png
  5. +1 −1 Android/ChutePhotoPicker+/src/com/chute/android/photopickerplus/adapter/AlbumsAdapter.java
  6. +1 −1 ...oid/ChutePhotoPicker+/src/com/chute/android/photopickerplus/adapter/PhotoSelectCursorAdapter.java
  7. +1 −1 Android/ChutePhotoPicker+/src/com/chute/android/photopickerplus/adapter/PhotosAdapter.java
  8. +1 −1 Android/ChutePhotoPicker+/src/com/chute/android/photopickerplus/app/ChooseServiceActivity.java
  9. +1 −1 Android/ChutePhotoPicker+/src/com/chute/android/photopickerplus/app/PhotoPickerPlusApp.java
  10. +70 −69 ...toPicker+/src/com/chute/android/photopickerplus/util/intent/PhotoStreamActivityIntentWrapper.java
  11. +14 −7 Android/PhotoPickerPlusTutorial/README.md
  12. BIN Android/PhotoPickerPlusTutorial/screenshots/IMG_Tutorial3.png
  13. BIN Android/PhotoPickerPlusTutorial/screenshots/IMG_Tutorial4.png
  14. +1 −1 ...PickerPlusTutorial/src/com/chute/photopickerplustutorial/app/PhotoPickerPlusTutorialActivity.java
  15. +11 −0 iOS/PhotoPickerPlus/PhotoPickerPlus/PhotoPickerPlus.h
  16. +6 −0 iOS/PhotoPickerPlus/PhotoPickerPlus/PhotoPickerPlus.m
  17. +1 −1 iOS/PhotoPickerPlus/README.md
  18. +88 −0 iOS/tutorial/AddToExisting.md
  19. +116 −0 iOS/tutorial/ChuteStarterProject.md
  20. BIN iOS/tutorial/ChuteStarterProject.pdf
  21. +2 −2 iOS/tutorial/ChuteStarterProject/Chute SDK/GCConstants.h
  22. +13 −105 iOS/tutorial/README.md
  23. BIN iOS/tutorial/screenshots/5.png
  24. BIN iOS/tutorial/screenshots/6.png
  25. BIN iOS/tutorial/screenshots/8.png
  26. BIN iOS/tutorial/screenshots/9.png
View
2 Android/ChutePhotoPicker+/README.md
@@ -1,7 +1,7 @@
Introduction
====
-PhotoPicker+ is a component made for developers to easily integrate it inside their app and enable photo picking functionality. Enable browsing photos from services such as Facebook, Picasa, Instagram or Flickr, also take photos with the native camera application and choose photos from the users device.
+PhotoPicker+ is a component made for developers to easily integrate it inside their app and enable photo picking functionality. This component enables browsing photos from services such as Facebook, Picasa, Instagram or Flickr, also enables taking photos with the native camera application and choosing photos from the users device.
Screenshots
View
BIN Android/ChutePhotoPicker+/screenshots/SS_Slidechute2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN Android/ChutePhotoPicker+/screenshots/SS_Slidechute3.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN Android/ChutePhotoPicker+/screenshots/SS_Slidechute4.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
2 Android/ChutePhotoPicker+/src/com/chute/android/photopickerplus/adapter/AlbumsAdapter.java
@@ -26,7 +26,7 @@ public AlbumsAdapter(final Activity context, final GCAccountObjectCollection col
this.context = context;
this.collection = collection;
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- loader = ImageLoader.get(context);
+ loader = ImageLoader.getLoader(context);
}
@Override
View
2 ...ePhotoPicker+/src/com/chute/android/photopickerplus/adapter/PhotoSelectCursorAdapter.java
@@ -37,7 +37,7 @@ public PhotoSelectCursorAdapter(Context context, Cursor c) {
super(context, c);
inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- loader = ImageLoader.get(context);
+ loader = ImageLoader.getLoader(context);
dataIndex = c.getColumnIndex(MediaStore.Images.Media.DATA);
displayMetrics = context.getResources().getDisplayMetrics();
}
View
2 Android/ChutePhotoPicker+/src/com/chute/android/photopickerplus/adapter/PhotosAdapter.java
@@ -33,7 +33,7 @@ public PhotosAdapter(Activity context, GCAccountMediaCollection collection) {
this.collection = collection;
}
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- loader = ImageLoader.get(context);
+ loader = ImageLoader.getLoader(context);
displayMetrics = context.getResources().getDisplayMetrics();
// tick = new HashMap<Integer, GCAccountMediaModel>();
}
View
2 ...id/ChutePhotoPicker+/src/com/chute/android/photopickerplus/app/ChooseServiceActivity.java
@@ -61,7 +61,7 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.service_layout);
- loader = ImageLoader.get(ChooseServiceActivity.this);
+ loader = ImageLoader.getLoader(ChooseServiceActivity.this);
txtFacebook = (TextView) findViewById(R.id.txt_facebook);
txtFacebook.setTag(AccountType.FACEBOOK);
View
2 Android/ChutePhotoPicker+/src/com/chute/android/photopickerplus/app/PhotoPickerPlusApp.java
@@ -14,7 +14,7 @@
private static ImageLoader createImageLoader(Context context) {
ImageLoader imageLoader = new ImageLoader(context, R.drawable.placeholder);
- imageLoader.setRequiredSize((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
+ imageLoader.setDefaultImageSize((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
75, context.getResources().getDisplayMetrics()));
return imageLoader;
}
View
139 ...+/src/com/chute/android/photopickerplus/util/intent/PhotoStreamActivityIntentWrapper.java
@@ -11,73 +11,74 @@
public class PhotoStreamActivityIntentWrapper {
- public static final int ACTIVITY_FOR_RESULT_STREAM_KEY = 113;
-
- private static final String EXTRA_KEY_PATH_LIST = "key_path_list";
- private static final String EXTRA_KEY_PATH = "key_path";
- private static final String EXTRA_KEY_CURSOR_PHOTOS = "cursor_photos";
- private static final String EXTRA_KEY_PHOTOMODEL="photoModel";
-
- public static final int TYPE_CAMERA_ROLL = 0;
- public static final int TYPE_ALL_PHOTOS = 1;
-
- @SuppressWarnings("unused")
- private static final String TAG = PhotoStreamActivityIntentWrapper.class.getSimpleName();
-
- private final Intent intent;
-
- public PhotoStreamActivityIntentWrapper(Intent intent) {
- super();
- this.intent = intent;
- }
-
- public PhotoStreamActivityIntentWrapper(Context packageContext, Class<?> cls) {
- super();
- intent = new Intent(packageContext, cls);
- }
-
- public PhotoStreamActivityIntentWrapper(Context packageContext) {
- super();
- intent = new Intent(packageContext, PhotoStreamActivity.class);
- }
-
- public Intent getIntent() {
- return intent;
- }
-
- public void setAssetPathList(ArrayList<String> pathList) {
- intent.putStringArrayListExtra(EXTRA_KEY_PATH_LIST, pathList);
- }
-
- public ArrayList<String> getAssetPathList() {
- return intent.getExtras().getStringArrayList(EXTRA_KEY_PATH_LIST);
- }
-
- public void setAssetPath(String path) {
- intent.putExtra(EXTRA_KEY_PATH, path);
- }
-
- public String getAssetPath() {
- return intent.getExtras().getString(EXTRA_KEY_PATH);
- }
-
- public int getFilterType() {
- return intent.getExtras().getInt(EXTRA_KEY_CURSOR_PHOTOS);
- }
-
- public void setFilterType(int type) {
- intent.putExtra(EXTRA_KEY_CURSOR_PHOTOS, type);
- }
-
- public GCAccountMediaModel getMediaModel() {
- return getIntent().getExtras().getParcelable(EXTRA_KEY_PHOTOMODEL);
- }
-
- public void setMediaModel(GCAccountMediaModel model) {
- getIntent().putExtra(EXTRA_KEY_PHOTOMODEL, model);
- }
-
- public void startActivityForResult(Activity context, int code) {
- context.startActivityForResult(intent, code);
- }
+ public static final int ACTIVITY_FOR_RESULT_STREAM_KEY = 113;
+
+ private static final String EXTRA_KEY_PATH_LIST = "key_path_list";
+ private static final String EXTRA_KEY_PATH = "key_path";
+ private static final String EXTRA_KEY_CURSOR_PHOTOS = "cursor_photos";
+ private static final String EXTRA_KEY_PHOTOMODEL = "photoModel";
+
+ public static final int TYPE_CAMERA_ROLL = 0;
+ public static final int TYPE_ALL_PHOTOS = 1;
+
+ @SuppressWarnings("unused")
+ private static final String TAG = PhotoStreamActivityIntentWrapper.class
+ .getSimpleName();
+
+ private final Intent intent;
+
+ public PhotoStreamActivityIntentWrapper(Intent intent) {
+ super();
+ this.intent = intent;
+ }
+
+ public PhotoStreamActivityIntentWrapper(Context packageContext, Class<?> cls) {
+ super();
+ intent = new Intent(packageContext, cls);
+ }
+
+ public PhotoStreamActivityIntentWrapper(Context packageContext) {
+ super();
+ intent = new Intent(packageContext, PhotoStreamActivity.class);
+ }
+
+ public Intent getIntent() {
+ return intent;
+ }
+
+ public void setAssetPathList(ArrayList<String> pathList) {
+ intent.putStringArrayListExtra(EXTRA_KEY_PATH_LIST, pathList);
+ }
+
+ public ArrayList<String> getAssetPathList() {
+ return intent.getExtras().getStringArrayList(EXTRA_KEY_PATH_LIST);
+ }
+
+ public void setAssetPath(String path) {
+ intent.putExtra(EXTRA_KEY_PATH, path);
+ }
+
+ public String getAssetPath() {
+ return intent.getExtras().getString(EXTRA_KEY_PATH);
+ }
+
+ public int getFilterType() {
+ return intent.getExtras().getInt(EXTRA_KEY_CURSOR_PHOTOS);
+ }
+
+ public void setFilterType(int type) {
+ intent.putExtra(EXTRA_KEY_CURSOR_PHOTOS, type);
+ }
+
+ public GCAccountMediaModel getMediaModel() {
+ return getIntent().getExtras().getParcelable(EXTRA_KEY_PHOTOMODEL);
+ }
+
+ public void setMediaModel(GCAccountMediaModel model) {
+ getIntent().putExtra(EXTRA_KEY_PHOTOMODEL, model);
+ }
+
+ public void startActivityForResult(Activity context, int code) {
+ context.startActivityForResult(intent, code);
+ }
}
View
21 Android/PhotoPickerPlusTutorial/README.md
@@ -11,8 +11,15 @@ Setup
* Follow the ProjectSetup tutorial that can be found and downloaded at
[https://github.com/chute/chute-tutorials/tree/master/Android/ProjectSetup](https://github.com/chute/chute-tutorials/tree/master/Android/ProjectSetup) for a complete guide on how to setup the chute SDK.
-* Add the PhotoPicker+ component to your project by either copying all the resources and source code or by adding it as an Android Library project
+* Additionally you can visit http://developer.getchute.com/ for more information about creating a new developer account and obtaining chute credentials.
+ You can create a Chute developer account and make a new app in Chute at http://apps.getchute.com/
+ * For the URL you can enter http://getchute.com/ if you don't have a site for your app.
+ * For the Callback URL you can use http://getchute.com/oauth/callback if you don't need callbacks for another purpose.
+
+ ![IMG_TUTORIAL3](https://github.com/chute/photo-picker-plus/raw/master/Android/PhotoPickerPlusTutorial/screenshots/IMG_Tutorial3.png)![IMG_TUTORIAL4](https://github.com/chute/photo-picker-plus/raw/master/Android/PhotoPickerPlusTutorial/screenshots/IMG_Tutorial4.png)
+* Add the PhotoPicker+ component to your project by either copying all the resources and source code or by adding it as an Android Library project.
+
* The next thing you need to do is register the activities, services and the application class into the AndroidManifest.xml file:
```
@@ -67,18 +74,18 @@ Usage
====
##PhotoPickerPlusTutorialApp.java
-This class is the extended Application class. It is registered inside the "application" tag in the manifest and is used for initializing the utility classes used in the component
-PhotoPickerPlusTutorialApp can extend PhotoPickerPlusApp like shown in this tutorial
+This class is the extended Application class. It is registered inside the "application" tag in the manifest and is used for initializing the utility classes used in the component.
+PhotoPickerPlusTutorialApp can extend PhotoPickerPlusApp like shown in this tutorial:
<pre><code>
public class PhotoPickerPlusTutorialApp extends PhotoPickerPlusApp {
}
</code></pre>
-This way the developer can use his own methods and code inside the application class.
+This way the developer can use his own methods and code inside the Application class.
-If the developer decides to extend the application class instead of PhotoPickerPlusApp he must copy the all the code below into it
+If the developer decides to extend the Application class instead of PhotoPickerPlusApp he must copy the all the code below:
<pre><code>
public class PhotoPickerPlusTutorialApp extends Application {
@@ -110,7 +117,7 @@ public class PhotoPickerPlusTutorialApp extends Application {
}
</code></pre>
-PhotoPickerPlusTutorialApp can also be neglected by registering PhotoPickerPlusApp into the manifest instead of PhotoPickerPlusTutoiralApp if the developer doesn't have the need for extending the application class.
+PhotoPickerPlusTutorialApp can also be neglected by registering PhotoPickerPlusApp into the manifest instead of PhotoPickerPlusTutoiralApp if the developer doesn't have the need for extending the Application class.
##PhotoPickerPlusTutorialActivity.java
This class is an Activity class. It contains a Button and an ImageView. When the button is clicked, PhotoPickerPlusIntentWrapper starts ChooseServiceActivity. PhotoPickerPlusIntentWrapper is a wrapper class that wraps the parameters needed for the intent.
@@ -124,7 +131,7 @@ private class OnPhotoPickerClickListener implements OnClickListener {
}
</code></pre>
-ChooseServiceActivity contains a list of services and device photos albums is shown. You can authenticate using Facebook, Flickr, Instagram and Picasa, browse albums and photos, browse device photos as well as take a photo with the camera.
+ChooseServiceActivity contains a list of services and device photos albums. You can authenticate using Facebook, Flickr, Instagram and Picasa, browse albums and photos, browse device photos as well as take a photo with the camera.
After clicking a photo, a result is returned to the activity that started the component where the selected photo is displayed using the ImageLoader.
<pre><code>
View
BIN Android/PhotoPickerPlusTutorial/screenshots/IMG_Tutorial3.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN Android/PhotoPickerPlusTutorial/screenshots/IMG_Tutorial4.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
2 ...usTutorial/src/com/chute/photopickerplustutorial/app/PhotoPickerPlusTutorialActivity.java
@@ -44,7 +44,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
return;
}
final PhotoActivityIntentWrapper wrapper = new PhotoActivityIntentWrapper(data);
- ImageLoader.get(this).displayImage(wrapper.getMediaModel().getUrl(), image);
+ ImageLoader.getLoader(this).displayImage(wrapper.getMediaModel().getUrl(), image);
Log.d(TAG, wrapper.toString());
String path;
View
11 iOS/PhotoPickerPlus/PhotoPickerPlus/PhotoPickerPlus.h
@@ -9,6 +9,14 @@
#import <UIKit/UIKit.h>
#import "GetChute.h"
+enum {
+ PhotoPickerPlusSourceTypeNone,
+ PhotoPickerPlusSourceTypePhotoLibrary,
+ PhotoPickerPlusSourceTypeCamera,
+ PhotoPickerPlusSourceTypeService
+};
+typedef NSUInteger PhotoPickerPlusSourceType;
+
@protocol PhotoPickerPlusDelegate;
@interface PhotoPickerPlus : GCUIBaseViewController <UIImagePickerControllerDelegate, UINavigationControllerDelegate, UITableViewDataSource, UITableViewDelegate, UIActionSheetDelegate, UIWebViewDelegate>
@@ -40,6 +48,9 @@
@property (nonatomic, readonly) IBOutlet UIView *AddServiceView;
@property (nonatomic, readonly) IBOutlet UIWebView *AddServiceWebView;
+//set to the source of the image selected
+@property (nonatomic, readonly) PhotoPickerPlusSourceType sourceType;
+
@property (nonatomic) BOOL appeared;
View
6 iOS/PhotoPickerPlus/PhotoPickerPlus/PhotoPickerPlus.m
@@ -23,6 +23,7 @@ @implementation PhotoPickerPlus
@synthesize photoCountView, photoCountLabel;
@synthesize appeared;
@synthesize AddServiceView, AddServiceWebView;
+@synthesize sourceType;
-(void)dealloc{
[photoAlbums release];
@@ -114,17 +115,20 @@ -(IBAction)closeSelected:(id)sender{
[photoView removeFromSuperview];
[albumView removeFromSuperview];
[accountView removeFromSuperview];
+ sourceType = PhotoPickerPlusSourceTypeNone;
if(delegate && [delegate respondsToSelector:@selector(PhotoPickerPlusControllerDidCancel:)])
[delegate PhotoPickerPlusControllerDidCancel:self];
}
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
+ sourceType = PhotoPickerPlusSourceTypeCamera;
[self dismissViewControllerAnimated:YES completion:^(void){
if(delegate && [delegate respondsToSelector:@selector(PhotoPickerPlusController:didFinishPickingMediaWithInfo:)])
[delegate PhotoPickerPlusController:self didFinishPickingMediaWithInfo:info];
}];
}
-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{
+ sourceType = PhotoPickerPlusSourceTypeNone;
[self dismissViewControllerAnimated:YES completion:^(void){
if(delegate && [delegate respondsToSelector:@selector(PhotoPickerPlusControllerDidCancel:)])
[delegate PhotoPickerPlusControllerDidCancel:self];
@@ -239,6 +243,7 @@ -(void)objectTappedWithGesture:(UIGestureRecognizer*)gesture{
[temp setObject:[UIImage imageWithCGImage:[[asset defaultRepresentation] fullResolutionImage] scale:1 orientation:(UIImageOrientation)[[asset defaultRepresentation] orientation]] forKey:UIImagePickerControllerOriginalImage];
[temp setObject:[[asset defaultRepresentation] url] forKey:UIImagePickerControllerReferenceURL];
dispatch_async(dispatch_get_main_queue(), ^(void) {
+ sourceType = PhotoPickerPlusSourceTypePhotoLibrary;
if(delegate && [delegate respondsToSelector:@selector(PhotoPickerPlusController:didFinishPickingMediaWithInfo:)])
[delegate PhotoPickerPlusController:self didFinishPickingMediaWithInfo:temp];
[self setAccounts:NULL];
@@ -293,6 +298,7 @@ -(void)objectTappedWithGesture:(UIGestureRecognizer*)gesture{
}
[temp setObject:asset forKey:UIImagePickerControllerMediaMetadata];
dispatch_async(dispatch_get_main_queue(), ^(void) {
+ sourceType = PhotoPickerPlusSourceTypeService;
if(delegate && [delegate respondsToSelector:@selector(PhotoPickerPlusController:didFinishPickingMediaWithInfo:)])
[delegate PhotoPickerPlusController:self didFinishPickingMediaWithInfo:temp];
[self setAccounts:NULL];
View
2 iOS/PhotoPickerPlus/README.md
@@ -1,7 +1,7 @@
PhotoPickerPlus
==============
-no external dependancies beyond Chute SDK (version 1.120206 or newer)
+no external dependancies beyond Chute SDK (version 1.0.4 or newer)
Description
-----------
View
88 iOS/tutorial/AddToExisting.md
@@ -0,0 +1,88 @@
+Adding Photo Picker+ To A Project
+=================================
+
+Photo Picker Plus is a drop-in component that replaces the default photo picker in your app. It allows you to take a photo as well as choose a photo from the device or from several online sources. This tutorial will show you how to replace the default UIImagePicker in your application with Photo Picker Plus. This tutorial was written using version 5.0 of the iOS SDK and version 4.2 of Xcode. Uses Chute SDK version 1.0.4 or newer (the version number can be found in the GCConstants.h file). Some changes may need to be made for other software versions.
+
+![image1](https://github.com/chute/photo-picker-plus/raw/master/iOS/tutorial/screenshots/1.png)
+![image2](https://github.com/chute/photo-picker-plus/raw/master/iOS/tutorial/screenshots/2.png)
+![image3](https://github.com/chute/photo-picker-plus/raw/master/iOS/tutorial/screenshots/3.png)
+
+Preparation
+-----------
+1. Download the Chute SDK from https://github.com/chute/Chute-SDK/tree/master/iOS
+2. Download the PhotoPickerPlus component from https://github.com/chute/photo-picker-plus/tree/master/iOS/PhotoPickerPlus
+3. If you don't have a Chute developer account or an app created on chute for this project then create a Chute developer account and make a new app in Chute at http://apps.getchute.com/
+ * For the URL you can enter http://getchute.com/ if you don't have a site for your app
+ * For the Callback URL you can use http://getchute.com/oauth/callback if you don't need callbacks for another purpose.
+
+![image5](https://github.com/chute/photo-picker-plus/raw/master/iOS/tutorial/screenshots/5.png)
+![image6](https://github.com/chute/photo-picker-plus/raw/master/iOS/tutorial/screenshots/6.png)
+
+Add The SDK And Component And Link Dependancies
+-----------------------------------------------
+1. Add the Chute SDK to the project
+2. Add the Photo Picker Plus component
+3. Link the required libraries
+ * AssetsLibrary
+ * CFNetwork
+ * EventKit
+ * libz.dylib
+ * MessageUI
+ * MobileCoreServices
+ * Security
+ * SystemConfiguration
+
+![image7](https://github.com/chute/photo-picker-plus/raw/master/iOS/tutorial/screenshots/7.png)
+
+Edit Your App ID And Secret
+---------------------------
+The next step is to enter your chute app information in the GCConstants.h file. This file can be found at the root of the Chute SDK directory. You will need to fill in your APP ID and APP secret from the summary tab of your admin panel. If you used a custom Redirect URL when setting up your app on Chute you will also need to adjust the `kOauthCallbackURL` to match the callback url you set. Then set the `kOauthCallbackRelativeURL` to everything after the base in the callback url. If you used `http://getchute.com/oauth/callback` then you can leave these as they are.
+
+![image8](https://github.com/chute/photo-picker-plus/raw/master/iOS/tutorial/screenshots/8.png)
+
+At this point you may want to try running the project to make sure that everything is added ok. If it builds then everything should be correctly added and linked.
+
+Change your delegate
+--------------------
+In the header for the controller that will be using the component `#import "PhotoPickerPlus.h"` and inherit the `PhotoPickerPlusDelegate` instead of the `UIImagePickerDelegate` protocol.
+
+```objective-c
+ #import <UIKit/UIKit.h>
+ #import "PhotoPickerPlus.h"
+
+ @interface ViewController : UIViewController <PhotoPickerPlusDelegate>
+
+ //existing code for your class
+
+ @end
+```
+
+Change The Delegate Methods
+---------------------------
+In your class change `imagePickerControllerDidCancel:` to `PhotoPickerPlusControllerDidCancel:` and change `imagePickerController:didFinishPickingMediaWithInfo:` to `PhotoPickerPlusController:didFinishPickingMediaWithInfo:`. You can leave the code in these methods exactly the same as you had before because the return values are the same format. If you need to know which source the info came from you can call `sourceType` on the picker.
+
+```objective-c
+ -(void) PhotoPickerPlusControllerDidCancel:(PhotoPickerPlus *)picker{
+ //cancel code
+ }
+ -(void) PhotoPickerPlusController:(PhotoPickerPlus *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
+ //image picked code
+ }
+```
+
+Displaying The Image Picker
+---------------------------
+Finally replace the code to display the image picker. Photo Picker Plus lets the user select a source for the image so you don't need to set it ahead of time. The only other difference is that you should set your viewController's `ModalPresentationStyle` to `UIModalPresentationCurrentContext` for a non-navigation based project or set your navigationViewController's `ModalPresentationStyle` to `UIModalPresentationCurrentContext` for a navigation based project.
+
+```objective-c
+ PhotoPickerPlus *temp = [[PhotoPickerPlus alloc] init];
+ [temp setDelegate:self];
+ [self setModalPresentationStyle:UIModalPresentationCurrentContext];
+ [self presentViewController:temp animated:YES completion:^(void){
+ [temp release];
+ }];
+```
+
+Conclusion
+----------
+You now have a multi-service photo picker in your app instead of Apple's UIImagePickerController. Most of your existing code for the imagePicker should still work because the info dictionary returned is designed to match the info dictionary returned by the UIImagePicker.
View
116 iOS/tutorial/ChuteStarterProject.md
@@ -0,0 +1,116 @@
+Chute Starter Project Tutorial
+==============================
+
+Photo Picker Plus is a drop-in component that replaces the default photo picker in your app. It allows you to take a photo as well as choose a photo from the device or from several online sources. This tutorial will show you how to use the Photo Picker Plus component to present the user with a multi-service photo picker and use the chosen image to set an imageView. This tutorial was written using version 5.0 of the iOS SDK and version 4.2 of Xcode. Uses Chute SDK version 1.0.4 or newer (the version number can be found in the GCConstants.h file). Some changes may need to be made for other software versions.
+
+![image1](https://github.com/chute/photo-picker-plus/raw/master/iOS/tutorial/screenshots/1.png)
+![image2](https://github.com/chute/photo-picker-plus/raw/master/iOS/tutorial/screenshots/2.png)
+![image3](https://github.com/chute/photo-picker-plus/raw/master/iOS/tutorial/screenshots/3.png)
+
+Create A New Project
+--------------------
+Start by creating a new Xcode project. A single view application will be easiest to modify for this tutorial. You can choose whatever name you like, I'll call it PhotoPickerPlus. Be sure that “Use Automatic Reference Counting” is unchecked as the SDK does not currently support ARC.
+
+![image4](https://github.com/chute/photo-picker-plus/raw/master/iOS/tutorial/screenshots/4.png)
+
+Preparation
+-----------
+1. Download the Chute SDK from https://github.com/chute/Chute-SDK/tree/master/iOS
+2. Download the PhotoPickerPlus component from https://github.com/chute/photo-picker-plus/tree/master/iOS/PhotoPickerPlus
+3. Create a Chute developer account and make a new app in Chute at http://apps.getchute.com/
+ * For the URL you can enter http://getchute.com/ if you don't have a site for your app
+ * For the Callback URL you can use http://getchute.com/oauth/callback if you don't need callbacks for another purpose.
+
+![image5](https://github.com/chute/photo-picker-plus/raw/master/iOS/tutorial/screenshots/5.png)
+![image6](https://github.com/chute/photo-picker-plus/raw/master/iOS/tutorial/screenshots/6.png)
+
+Add The SDK And Component And Link Dependancies
+-----------------------------------------------
+1. Add the SDK to the project
+2. Add the picker component
+3. Link the required libraries
+ * AssetsLibrary
+ * CFNetwork
+ * EventKit
+ * libz.dylib
+ * MessageUI
+ * MobileCoreServices
+ * Security
+ * SystemConfiguration
+
+![image7](https://github.com/chute/photo-picker-plus/raw/master/iOS/tutorial/screenshots/7.png)
+
+Edit Your App ID And Secret
+---------------------------
+The next step is to enter your chute app information in the GCConstants.h file. This file can be found at the root of the Chute SDK directory. You will need to fill in your APP ID and APP secret from the summary tab of your admin panel. If you used a custom Redirect URL when setting up your app on Chute you will also need to adjust the `kOauthCallbackURL` to match the callback url you set. Then set the `kOauthCallbackRelativeURL` to everything after the base in the callback url. If you used `http://getchute.com/oauth/callback` then you can leave these as they are.
+
+![image8](https://github.com/chute/photo-picker-plus/raw/master/iOS/tutorial/screenshots/8.png)
+
+At this point you may want to try running the project to make sure that everything is added ok. If it builds then everything should be correctly added and linked.
+
+Set ViewController As Delegate And Add Objects/Methods
+-----------------------------------------------
+In your viewController.h file import PhotoPickerPlus.h and set up the class as a `PhotoPickerPlusDelegate`. Then add an object for the image view and a method for pressing the pick photo button. This should look similar to this
+
+viewController.h
+
+```objective-c
+ #import <UIKit/UIKit.h>
+ #import "PhotoPickerPlus.h"
+
+ @interface ViewController : UIViewController <PhotoPickerPlusDelegate>
+
+ @property (nonatomic, readonly) IBOutlet UIImageView *imageView;
+
+ -(IBAction)pickPhotoSelected:(id)sender;
+
+ @end
+```
+
+Synthesize ImageView And Write The Display Method
+-------------------------------------------------
+In viewController.m you now need to synthesize your imageView object and write the method to display the photo picker plus component. The method will initialize the controller, set itself as the delegate, present it and release it. We also want to have out current view visible behind the first screen of the picker so we will add a line for that as well. The code for all this is
+
+viewController.m
+
+```objective-c
+ @synthesize imageView;
+
+ -(IBAction)pickPhotoSelected:(id)sender{
+ PhotoPickerPlus *temp = [[PhotoPickerPlus alloc] init];
+ [temp setDelegate:self];
+ [self setModalPresentationStyle:UIModalPresentationCurrentContext];
+ [self presentViewController:temp animated:YES completion:^(void){
+ [temp release];
+ }];
+ }
+```
+
+Write The Delegate Methods
+--------------------------
+The PhotoPickerPlusDelegate methods are `PhotoPickerPlusControllerDidCancel:` and `PhotoPickerPlusController:didFinishPickingMediaWithInfo:`. These work exactly the same as the UIImagePickerController delegate methods to make things easier. You can refer to Apple's documentation on UIImagePickerControllerDelegate to see what the keys in the dictionary are. The only one we are going to be concerned with is `UIImagePickerControllerOriginalImage`. So our cancel method will just dismiss the picker and our success method will display the image in the imageView and dismiss the picker. The code for these methods is
+
+viewController.m
+
+```objective-c
+ -(void) PhotoPickerPlusControllerDidCancel:(PhotoPickerPlus *)picker{
+ [self dismissViewControllerAnimated:YES completion:^(void){
+
+ }];
+ }
+ -(void) PhotoPickerPlusController:(PhotoPickerPlus *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
+ [self dismissViewControllerAnimated:YES completion:^(void){
+ [[self imageView] setImage:[info objectForKey:UIImagePickerControllerOriginalImage]];
+ }];
+ }
+```
+
+Create The UI
+-------------
+Open viewController.xib and add an UIImageView covering most of the view and a UIButton below it. Hook the UIImageView up to the imageView object and hook up the pickPhotoSelected method to the touchUpInside event of the button. You do this by right clicking on the file's owner and dragging from the circle for the outlet or action that you want to it's corresponding object either in the object's list or in the view itself. You can set the title for the button whatever you want by selecting it then changing it's title in the attribute inspector on the right side of the screen. I called mine Pick Photo. You also probably want to set the mode for the UIImageView to aspectFit which is accessed from the attribute inspector for the UIImageView.
+
+![image9](https://github.com/chute/photo-picker-plus/raw/master/iOS/tutorial/screenshots/9.png)
+
+Conclusion
+----------
+You should have a fully working app now that allows you to take a photo, pick an image from the device, or pick an image from a variety of online sources. Due to the picker accessing the ALAssets it will present the user with a dialog asking if they want to allow location services. This is because ALAssets have location data associated with the images. If the user declines then the picker will not allow them to choose images that are on the device however all other sources should still work.
View
BIN iOS/tutorial/ChuteStarterProject.pdf
Binary file not shown.
View
4 iOS/tutorial/ChuteStarterProject/Chute SDK/GCConstants.h
@@ -35,8 +35,8 @@
//replace the following setting with your own client info
#define kOAuthCallbackURL @"http://getchute.com/oauth/callback"
#define kOAuthCallbackRelativeURL @"/oauth/callback"
-#define kOAuthAppID @"PUT_CLIENT_ID_HERE"
-#define kOAuthAppSecret @"PUT_CLIENT_SECRET_HERE"
+#define kOAuthAppID @"XXXXXXXXXXXXXXXXXXXXXXXX"
+#define kOAuthAppSecret @"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
#define kOAuthPermissions @"all_resources manage_resources profile resources"
View
118 iOS/tutorial/README.md
@@ -1,112 +1,20 @@
-Chute Starter Project Tutorial
-==============================
+Photo Picker Plus Tutorials
+===========================
-This tutorial will show you how to use the Photo Picker Plus component to present the user with a multi-service photo picker. This tutorial was written using version 5.0 of the iOS SDK and version 4.2 of Xcode. Uses Chute SDK version 1.0.4 or newer (the version number can be found in the GCConstants.h file). Some changes may need to be made for other software versions.
-
-![image1](https://github.com/chute/photo-picker-plus/raw/master/iOS/tutorial/screenshots/1.png)
-![image2](https://github.com/chute/photo-picker-plus/raw/master/iOS/tutorial/screenshots/2.png)
-![image3](https://github.com/chute/photo-picker-plus/raw/master/iOS/tutorial/screenshots/3.png)
-
-Create A New Project
---------------------
-Start by creating a new Xcode project. A single view application will be easiest to modify for this tutorial. You can choose whatever name you like, I'll call it PhotoPickerPlus. Be sure that “Use Automatic Reference Counting” is unchecked as the SDK does not currently support ARC.
-
-![image4](https://github.com/chute/photo-picker-plus/raw/master/iOS/tutorial/screenshots/4.png)
-
-Preparation
+Description
-----------
-1. Download the Chute SDK from https://github.com/chute/Chute-SDK
-2. Download the PhotoPickerPlus component from https://github.com/chute/photo-picker-plus/tree/master/iOS/PhotoPickerPlus
-3. Create a Chute developer account and make a new app in Chute at http://apps.getchute.com/
-
-![image5](https://github.com/chute/photo-picker-plus/raw/master/iOS/tutorial/screenshots/5.png)
-![image6](https://github.com/chute/photo-picker-plus/raw/master/iOS/tutorial/screenshots/6.png)
-
-Add The SDK And Component And Link Dependancies
------------------------------------------------
-1. Add the SDK to the project
-2. Add the picker component
-3. Link the required libraries
- * AssetsLibrary
- * CFNetwork
- * EventKit
- * libz.dylib
- * MessageUI
- * MobileCoreServices
- * Security
- * SystemConfiguration
-
-![image7](https://github.com/chute/photo-picker-plus/raw/master/iOS/tutorial/screenshots/7.png)
-
-At this point you may want to try running the project to make sure that everything is added ok. You will get a few warnings, but if there are no errors then everything should be correctly added and linked.
-
-Edit Your App ID And Secret
----------------------------
-The next step is to enter your chute app information in the GCConstants.h file. This file can be found at the root of the Chute SDK directory. You will need to fill in your APP ID and APP secret from the summary tab of your admin panel. You will also need to adjust the redirect URL to match the callback url from the admin panel. Then set the redirect relative url to everything after the base in the callback url.
-
-Set ViewController As Delegate And Add Objects/Methods
------------------------------------------------
-In your viewController.h file import PhotoPickerPlus.h and set up the class as a PhotoPickerPlusDelegate. Then add an object for the image view and a method for pressing the pick photo button. This should look similar to this
-
-viewController.h
+Photo Picker Plus is a drop-in component that replaces the default photo picker in your app. It allows you to take a photo as well as choose a photo from the device or from several online sources.
-```objective-c
- #import <UIKit/UIKit.h>
- #import "PhotoPickerPlus.h"
+Tutorials
+---------
- @interface ViewController : UIViewController <PhotoPickerPlusDelegate>
+[Adding PhotoPicker+ to an Existing Project](https://github.com/chute/photo-picker-plus/blob/master/iOS/tutorial/AddToExisting.md)
- @property (nonatomic, readonly) IBOutlet UIImageView *imageView;
+[Creating a PhotoPicker+ Sample Project](https://github.com/chute/photo-picker-plus/blob/master/iOS/tutorial/ChuteStarterProject.md)
- -(IBAction)pickPhotoSelected:(id)sender;
+Screens
+-------
- @end
-```
-
-Synthesize ImageView And Write The Display Method
--------------------------------------------------
-In viewController.m you now need to synthesize your imageView object and write the method to display the photo picker plus component. The method will initialize the controller, set itself as the delegate, present it and release it. We also want to have out current view visible behind the first screen of the picker so we will add a line for that as well. The code for all this is
-
-viewController.m
-
-```objective-c
- @synthesize imageView;
-
- -(IBAction)pickPhotoSelected:(id)sender{
- PhotoPickerPlus *temp = [[PhotoPickerPlus alloc] init];
- [temp setDelegate:self];
- [self setModalPresentationStyle:UIModalPresentationCurrentContext];
- [self presentViewController:temp animated:YES completion:^(void){
- [temp release];
- }];
- }
-```
-
-Write The Delegate Methods
---------------------------
-The PhotoPickerPlusDelegate methods are PhotoPickerPlusControllerDidCancel: and PhotoPickerPlusController:didFinishPickingMediaWithInfo:. These work exactly the same as the UIImagePickerController delegate methods to make things easier. You can refer to Apple's documentation on UIImagePickerControllerDelegate to see what the keys in the dictionary are. The only one we are going to be concerned with is UIImagePickerControllerOriginalImage. So our cancel method will just dismiss the picker and our success method will display the image in the imageView and dismiss the picker. The code for these methods is
-
-viewController.m
-
-```
- -(void) PhotoPickerPlusControllerDidCancel:(PhotoPickerPlus *)picker{
- [self dismissViewControllerAnimated:YES completion:^(void){
-
- }];
- }
- -(void) PhotoPickerPlusController:(PhotoPickerPlus *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
- [self dismissViewControllerAnimated:YES completion:^(void){
- [[self imageView] setImage:[info objectForKey:UIImagePickerControllerOriginalImage]];
- }];
- }
-```
-
-Create The UI
--------------
-Open viewController.xib and add an UIImageView covering most of the view and a UIButton below it. Hook the UIImageView up to the imageView object and hook up the pickPhotoSelected method to the touchUpInside event of the button. You do this by right clicking on the file's owner and dragging from the circle for the outlet or action that you want to it's corresponding object either in the object's list or in the view itself. You can set the title for the button whatever you want by selecting it then changing it's title in the attribute inspector on the right side of the screen. I called mine Pick Photo. You also probably want to set the mode for the UIImageView to aspectFit which is accessed from the attribute inspector for the UIImageView.
-
-![image8](https://github.com/chute/photo-picker-plus/raw/master/iOS/tutorial/screenshots/8.png)
-
-Conclusion
-----------
-You should have a fully working app now that allows you to take a photo, pick an image from the device, or pick an image from a variety of online sources. Due to the picker accessing the ALAssets it will present the user with a dialog asking if they want to allow location services. This is because ALAssets have location data associated with the images. If the user declines then the picker will not allow them to choose images that are on the device however all other sources should still work.
+![image1](https://github.com/chute/photo-picker-plus/raw/master/iOS/tutorial/screenshots/1.png)
+![image2](https://github.com/chute/photo-picker-plus/raw/master/iOS/tutorial/screenshots/2.png)
+![image3](https://github.com/chute/photo-picker-plus/raw/master/iOS/tutorial/screenshots/3.png)
View
BIN iOS/tutorial/screenshots/5.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN iOS/tutorial/screenshots/6.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN iOS/tutorial/screenshots/8.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN iOS/tutorial/screenshots/9.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 264a2c7

Please sign in to comment.