Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'release/1.0'

  • Loading branch information...
commit fc9aba6fec72fc000c2bea318715f4c7dec847b1 2 parents e0736a0 + c9e09e6
@anagromataf anagromataf authored
View
9 .gitmodules
@@ -1,9 +0,0 @@
-[submodule "Outsourced/OAuth2Client"]
- path = Outsourced/OAuth2Client
- url = git://github.com/nxtbgthng/OAuth2Client.git
-[submodule "Outsourced/JSONKit"]
- path = Outsourced/JSONKit
- url = https://github.com/johnezang/JSONKit.git
-[submodule "Outsourced/SoundCloudUI"]
- path = Outsourced/SoundCloudUI
- url = https://github.com/soundcloud/CocoaSoundCloudUI.git
1  Outsourced/JSONKit
@@ -1 +0,0 @@
-Subproject commit c2146ffeb10d92bfa1537d2033a3235825d1b261
1  Outsourced/OAuth2Client
@@ -1 +0,0 @@
-Subproject commit 10ea6ce3f5a2c17886dfab291db8c6f94c6e88f6
1  Outsourced/SoundCloudUI
@@ -1 +0,0 @@
-Subproject commit 06c7b04752abd056cf43dea0fec3c6c15b5a4e8a
View
44 README.md
@@ -29,23 +29,31 @@ We're taking a fresh new iOS Project as an example. Integration into an existing
1. Go to your project directory.
-2. Add SoundCloudAPI as a Git Submodule
+2. Add the required GIT Submodules
- git submodule add git://github.com/soundcloud/CocoaSoundCloudAPI.git SoundCloudAPI
-
-3. Update the Submodules
+ // For the API
+ git submodule add git://github.com/nxtbgthng/OAuth2Client.git
+ git submodule add git://github.com/soundcloud/CocoaSoundCloudAPI.git
+
+ // For the UI (iOS only)
+ git submodule add git://github.com/nxtbgthng/JSONKit.git
+ git aubmodule add git://github.com/nxtbgthng/OHAttributedLabel.git
+ git submodule add git://github.com/soundcloud/CocoaSoundCloudUI.git
- git submodule update --init --recursive
### In Xcode
-1. Drag the `SoundCloudAPI.xcodeproj` file below your project file. If it asks you to save this as a Workspace, say yes. For projects in the _root_ hierarchy of a workspace, Xcode ensures "implicit dependencies" between them. That's a good thing.
+1. Create a Workspace containing all those submodules added above.
-2. To be able to find the Headers, you still need to add `SoundCloudAPI/**` to the `Header Search Path` of the main project.
+2. To be able to find the Headers, you still need to add `../**` (or `./**` depending on your setup) to the `Header Search Path` of the main project.
3. Now the Target needs to know about the new libraries it should link against. So in the _Project_, select the _Target_, and in _Build Phases_ go to the _Link Binary with Libraries_ section. Add the following:
- * `libSoundCloudAPI.a` (or `SoundCloudAPI.framework` for a Desktop projects)
+ * `libSoundCloudAPI.a` (`SoundCloudAPI.framework` on Mac OS X)
+ * `libOAuth2Client.a` (`OAuth2Client.framework` on Mac OS X)
+ * `libJSONKit.a` (iOS only)
+ * `libOHAttributedLabel.a` (iOS only)
+ * `libSoundCloudUI.a` (iOS only)
* `QuartzCore.framework`
* `AddressBook.framework`
* `AddressBookUI.framework`
@@ -55,10 +63,10 @@ We're taking a fresh new iOS Project as an example. Integration into an existing
* `CoreText.framework`
4. Next step is to make sure that the Linker finds everything it needs: So go to the Build settings of the project and add the following to *Other Linker Flags*
-
+
-all_load -ObjC
-5. We need a few graphics: Please move the `SoundCloud.bundle` from the `SoundCloudAPI/Outsourced/SoundCloudUI/` directory to your Resources.
+5. On iOS we need a few graphics: Please move the `SoundCloud.bundle` from the `CocoaSoundCloudUI/` directory to your Resources.
Yay, done! Congrats! Everything is set up, and you can start using it.
@@ -84,39 +92,39 @@ You will get your App's _Client ID_, it's _Client Secret_ from [the SoundCloud p
### Using the Share UI (iOS only)
-To share a track you just have to create a `SCShareViewController` with the URL to the file you want to share and present it on the current view controller. After a successful upload, the track info can be accessed in the completion handler.
+To share a track you just have to create a `SCShareViewController` with the URL to the file you want to share and present it on the current view controller. After a successful upload, the track info can be accessed in the completion handler.
- (void)upload;
{
NSURL *trackURL = // ... an URL to the audio file
-
+
SCShareViewController *shareViewController;
shareViewController = [SCShareViewController shareViewControllerWithFileURL:trackURL
completionHandler:^(NSDictionary *trackInfo, NSError *error){
-
+
if (SC_CANCELED(error)) {
NSLog(@"Canceled!");
} else if (error) {
NSLog(@"Ooops, something went wrong: %@", [error localizedDescription]);
} else {
- // If you want to do something with the uploaded
+ // If you want to do something with the uploaded
// track this is the right place for that.
NSLog(@"Uploaded track: %@", trackInfo);
}
}];
-
+
// If your app is a registered foursquare app, you can set the client id and secret.
// The user will then see a place picker where a location can be selected.
// If you don't set them, the user sees a plain plain text filed for the place.
[shareViewController setFoursquareClientID:@"<foursquare client id>"
clientSecret:@"<foursquare client secret>"];
-
+
// We can preset the title ...
[shareViewController setTitle:@"Funny sounds"];
-
+
// ... and other options like the private flag.
[shareViewController setPrivate:NO];
-
+
// Now present the share view controller.
[self presentModalViewController:shareViewController animated:YES];
}
View
163 SoundCloudAPI.xcodeproj/project.pbxproj
@@ -14,7 +14,6 @@
9454819A1248D95E00E6BD3D /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 945481851248D94900E6BD3D /* AudioToolbox.framework */; };
9454819B1248D95E00E6BD3D /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AACBBE490F95108600F1A2B1 /* Foundation.framework */; };
94F5B56E1282FD16000D7CD1 /* CoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 94F5B56D1282FD16000D7CD1 /* CoreServices.framework */; };
- 99F79A5D13A15371002555F0 /* OAuth2Client.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 99F79A5C13A15371002555F0 /* OAuth2Client.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
AA747D9F0F9514B9006C5449 /* SoundCloudAPI_Prefix.pch in Headers */ = {isa = PBXBuildFile; fileRef = AA747D9E0F9514B9006C5449 /* SoundCloudAPI_Prefix.pch */; };
AACBBE4A0F95108600F1A2B1 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AACBBE490F95108600F1A2B1 /* Foundation.framework */; };
F60811E313D050180040EC66 /* SCSoundCloud.h in Headers */ = {isa = PBXBuildFile; fileRef = F60811E113D050180040EC66 /* SCSoundCloud.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -29,18 +28,12 @@
F60811F013D051840040EC66 /* SCRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = F60811ED13D051840040EC66 /* SCRequest.h */; };
F60811F113D051840040EC66 /* SCRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = F60811EE13D051840040EC66 /* SCRequest.m */; };
F60811F213D051840040EC66 /* SCRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = F60811EE13D051840040EC66 /* SCRequest.m */; };
- F61580FA13FD13430049FF2E /* JSONKit.h in Headers */ = {isa = PBXBuildFile; fileRef = F61580F713FD13430049FF2E /* JSONKit.h */; };
- F61580FB13FD13430049FF2E /* JSONKit.m in Sources */ = {isa = PBXBuildFile; fileRef = F61580F813FD13430049FF2E /* JSONKit.m */; };
- F615810C13FD142F0049FF2E /* libSoundCloudUI.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F61580CF13FD132D0049FF2E /* libSoundCloudUI.a */; };
- F64109B113D87F9500561D0B /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F64109B013D87F9500561D0B /* UIKit.framework */; };
- F64109B313D87F9F00561D0B /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F64109B213D87F9F00561D0B /* CoreGraphics.framework */; };
+ F62E0CBA148FAF6400BE8F14 /* OAuth2Client.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 99F79A5C13A15371002555F0 /* OAuth2Client.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
F6525B7D13D5B34A00ACAE8F /* SCSoundCloud+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = F6525B7B13D5B34A00ACAE8F /* SCSoundCloud+Private.h */; settings = {ATTRIBUTES = (Public, ); }; };
F6525B7E13D5B34A00ACAE8F /* SCSoundCloud+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = F6525B7B13D5B34A00ACAE8F /* SCSoundCloud+Private.h */; };
F6525B7F13D5B34A00ACAE8F /* SCSoundCloud+Private.m in Sources */ = {isa = PBXBuildFile; fileRef = F6525B7C13D5B34A00ACAE8F /* SCSoundCloud+Private.m */; };
F6525B8013D5B34A00ACAE8F /* SCSoundCloud+Private.m in Sources */ = {isa = PBXBuildFile; fileRef = F6525B7C13D5B34A00ACAE8F /* SCSoundCloud+Private.m */; };
F6622B6713D84A2B0057ADD0 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F6622B6613D84A2B0057ADD0 /* Cocoa.framework */; };
- F66BAD2E13D97FAB00996800 /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F66BAD2D13D97FAB00996800 /* CoreLocation.framework */; };
- F6E37EAD13FE8B7100D6DDC0 /* libOAuth2Client.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 94E5ADA4122C192900C7021A /* libOAuth2Client.a */; };
F6E88D2513D41F8A008B9CD5 /* SCConstants.h in Headers */ = {isa = PBXBuildFile; fileRef = F6E88D2313D41F8A008B9CD5 /* SCConstants.h */; settings = {ATTRIBUTES = (Public, ); }; };
F6E88D2613D41F8A008B9CD5 /* SCConstants.h in Headers */ = {isa = PBXBuildFile; fileRef = F6E88D2313D41F8A008B9CD5 /* SCConstants.h */; };
F6E88D2713D41F8A008B9CD5 /* SCConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = F6E88D2413D41F8A008B9CD5 /* SCConstants.m */; };
@@ -51,57 +44,11 @@
F6E88D3213D43B67008B9CD5 /* SCAccount+Private.m in Sources */ = {isa = PBXBuildFile; fileRef = F6E88D3013D43B67008B9CD5 /* SCAccount+Private.m */; };
/* End PBXBuildFile section */
-/* Begin PBXContainerItemProxy section */
- 94E5ADA3122C192900C7021A /* PBXContainerItemProxy */ = {
- isa = PBXContainerItemProxy;
- containerPortal = 94E5AD94122C192900C7021A /* OAuth2Client.xcodeproj */;
- proxyType = 2;
- remoteGlobalIDString = D2AAC07E0554694100DB518D;
- remoteInfo = OAuth2Client;
- };
- 94E5ADA7122C193000C7021A /* PBXContainerItemProxy */ = {
- isa = PBXContainerItemProxy;
- containerPortal = 94E5AD94122C192900C7021A /* OAuth2Client.xcodeproj */;
- proxyType = 1;
- remoteGlobalIDString = D2AAC07D0554694100DB518D;
- remoteInfo = OAuth2Client;
- };
- 94EE49C31238D66200EFDAB1 /* PBXContainerItemProxy */ = {
- isa = PBXContainerItemProxy;
- containerPortal = 94E5AD94122C192900C7021A /* OAuth2Client.xcodeproj */;
- proxyType = 2;
- remoteGlobalIDString = 942FFCD612315E0A00E6C65E;
- remoteInfo = "OAuth2Client Framework";
- };
- 99EF0E7C13BB1B29000D7FEA /* PBXContainerItemProxy */ = {
- isa = PBXContainerItemProxy;
- containerPortal = 94E5AD94122C192900C7021A /* OAuth2Client.xcodeproj */;
- proxyType = 1;
- remoteGlobalIDString = 942FFCD512315E0A00E6C65E;
- remoteInfo = OAuth2Client.framework;
- };
- F61580CE13FD132D0049FF2E /* PBXContainerItemProxy */ = {
- isa = PBXContainerItemProxy;
- containerPortal = F61580C713FD132D0049FF2E /* SoundCloudUI.xcodeproj */;
- proxyType = 2;
- remoteGlobalIDString = F6EF8C6113F929D700B20B40;
- remoteInfo = SoundCloudUI;
- };
- F615810913FD14060049FF2E /* PBXContainerItemProxy */ = {
- isa = PBXContainerItemProxy;
- containerPortal = F61580C713FD132D0049FF2E /* SoundCloudUI.xcodeproj */;
- proxyType = 1;
- remoteGlobalIDString = F6EF8C6013F929D700B20B40;
- remoteInfo = SoundCloudUI;
- };
-/* End PBXContainerItemProxy section */
-
/* Begin PBXFileReference section */
9429A5D2122659D500D31807 /* SCAPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SCAPI.h; sourceTree = "<group>"; };
94535F86123FAFDF00BD668A /* SoundCloudAPI.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SoundCloudAPI.framework; sourceTree = BUILT_PRODUCTS_DIR; };
94535F87123FAFDF00BD668A /* SoundCloudAPI.framework-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "SoundCloudAPI.framework-Info.plist"; sourceTree = "<group>"; };
945481851248D94900E6BD3D /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = /System/Library/Frameworks/AudioToolbox.framework; sourceTree = "<absolute>"; };
- 94E5AD94122C192900C7021A /* OAuth2Client.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = OAuth2Client.xcodeproj; path = OAuth2Client/OAuth2Client.xcodeproj; sourceTree = "<group>"; };
94F5B56D1282FD16000D7CD1 /* CoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreServices.framework; path = /System/Library/Frameworks/CoreServices.framework; sourceTree = "<absolute>"; };
99F79A5C13A15371002555F0 /* OAuth2Client.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = OAuth2Client.framework; sourceTree = BUILT_PRODUCTS_DIR; };
AA747D9E0F9514B9006C5449 /* SoundCloudAPI_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SoundCloudAPI_Prefix.pch; sourceTree = "<group>"; };
@@ -113,9 +60,6 @@
F60811E813D051420040EC66 /* SCAccount.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SCAccount.m; sourceTree = "<group>"; };
F60811ED13D051840040EC66 /* SCRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SCRequest.h; sourceTree = "<group>"; };
F60811EE13D051840040EC66 /* SCRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SCRequest.m; sourceTree = "<group>"; };
- F61580C713FD132D0049FF2E /* SoundCloudUI.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = SoundCloudUI.xcodeproj; path = SoundCloudUI/SoundCloudUI.xcodeproj; sourceTree = "<group>"; };
- F61580F713FD13430049FF2E /* JSONKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSONKit.h; sourceTree = "<group>"; };
- F61580F813FD13430049FF2E /* JSONKit.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JSONKit.m; sourceTree = "<group>"; };
F64109B013D87F9500561D0B /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/System/Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; };
F64109B213D87F9F00561D0B /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/System/Library/Frameworks/CoreGraphics.framework; sourceTree = DEVELOPER_DIR; };
F6525B7B13D5B34A00ACAE8F /* SCSoundCloud+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "SCSoundCloud+Private.h"; sourceTree = "<group>"; };
@@ -133,9 +77,9 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
+ F62E0CBA148FAF6400BE8F14 /* OAuth2Client.framework in Frameworks */,
F6622B6713D84A2B0057ADD0 /* Cocoa.framework in Frameworks */,
9454819A1248D95E00E6BD3D /* AudioToolbox.framework in Frameworks */,
- 99F79A5D13A15371002555F0 /* OAuth2Client.framework in Frameworks */,
9454819B1248D95E00E6BD3D /* Foundation.framework in Frameworks */,
94F5B56E1282FD16000D7CD1 /* CoreServices.framework in Frameworks */,
);
@@ -145,11 +89,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
- F6E37EAD13FE8B7100D6DDC0 /* libOAuth2Client.a in Frameworks */,
- F615810C13FD142F0049FF2E /* libSoundCloudUI.a in Frameworks */,
- F66BAD2E13D97FAB00996800 /* CoreLocation.framework in Frameworks */,
- F64109B313D87F9F00561D0B /* CoreGraphics.framework in Frameworks */,
- F64109B113D87F9500561D0B /* UIKit.framework in Frameworks */,
AACBBE4A0F95108600F1A2B1 /* Foundation.framework in Frameworks */,
945481861248D94900E6BD3D /* AudioToolbox.framework in Frameworks */,
);
@@ -170,7 +109,6 @@
0867D691FE84028FC02AAC07 /* SoundCloudAPI */ = {
isa = PBXGroup;
children = (
- 9429A5CF1226591400D31807 /* Outsourced */,
08FB77AEFE84172EC02AAC07 /* Sources */,
0867D69AFE84028FC02AAC07 /* Frameworks */,
034768DFFF38A50411DB9C8B /* Products */,
@@ -203,16 +141,6 @@
path = Sources;
sourceTree = "<group>";
};
- 9429A5CF1226591400D31807 /* Outsourced */ = {
- isa = PBXGroup;
- children = (
- F61580D013FD13430049FF2E /* JSONKit */,
- 94E5AD94122C192900C7021A /* OAuth2Client.xcodeproj */,
- F61580C713FD132D0049FF2E /* SoundCloudUI.xcodeproj */,
- );
- path = Outsourced;
- sourceTree = "<group>";
- };
9429A5D1122659D500D31807 /* SoundCloudAPI */ = {
isa = PBXGroup;
children = (
@@ -246,32 +174,6 @@
name = Resources;
sourceTree = "<group>";
};
- 94E5AD95122C192900C7021A /* Products */ = {
- isa = PBXGroup;
- children = (
- 94EE49C41238D66200EFDAB1 /* OAuth2Client.framework */,
- 94E5ADA4122C192900C7021A /* libOAuth2Client.a */,
- );
- name = Products;
- sourceTree = "<group>";
- };
- F61580C813FD132D0049FF2E /* Products */ = {
- isa = PBXGroup;
- children = (
- F61580CF13FD132D0049FF2E /* libSoundCloudUI.a */,
- );
- name = Products;
- sourceTree = "<group>";
- };
- F61580D013FD13430049FF2E /* JSONKit */ = {
- isa = PBXGroup;
- children = (
- F61580F713FD13430049FF2E /* JSONKit.h */,
- F61580F813FD13430049FF2E /* JSONKit.m */,
- );
- path = JSONKit;
- sourceTree = "<group>";
- };
F6525B8213D5B34E00ACAE8F /* Private */ = {
isa = PBXGroup;
children = (
@@ -313,7 +215,6 @@
F6E88D2613D41F8A008B9CD5 /* SCConstants.h in Headers */,
F6E88D2D13D43A74008B9CD5 /* SCAccount+Private.h in Headers */,
F6525B7E13D5B34A00ACAE8F /* SCSoundCloud+Private.h in Headers */,
- F61580FA13FD13430049FF2E /* JSONKit.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -332,7 +233,6 @@
buildRules = (
);
dependencies = (
- 99EF0E7D13BB1B29000D7FEA /* PBXTargetDependency */,
);
name = SoundCloudAPI.framework;
productName = SoundCloudAPI.framework;
@@ -350,8 +250,6 @@
buildRules = (
);
dependencies = (
- F615810A13FD14060049FF2E /* PBXTargetDependency */,
- 94E5ADA8122C193000C7021A /* PBXTargetDependency */,
);
name = SoundCloudAPI;
productName = SoundCloudAPI;
@@ -379,16 +277,6 @@
mainGroup = 0867D691FE84028FC02AAC07 /* SoundCloudAPI */;
productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;
projectDirPath = "";
- projectReferences = (
- {
- ProductGroup = 94E5AD95122C192900C7021A /* Products */;
- ProjectRef = 94E5AD94122C192900C7021A /* OAuth2Client.xcodeproj */;
- },
- {
- ProductGroup = F61580C813FD132D0049FF2E /* Products */;
- ProjectRef = F61580C713FD132D0049FF2E /* SoundCloudUI.xcodeproj */;
- },
- );
projectRoot = "";
targets = (
94535F85123FAFDF00BD668A /* SoundCloudAPI.framework */,
@@ -397,30 +285,6 @@
};
/* End PBXProject section */
-/* Begin PBXReferenceProxy section */
- 94E5ADA4122C192900C7021A /* libOAuth2Client.a */ = {
- isa = PBXReferenceProxy;
- fileType = archive.ar;
- path = libOAuth2Client.a;
- remoteRef = 94E5ADA3122C192900C7021A /* PBXContainerItemProxy */;
- sourceTree = BUILT_PRODUCTS_DIR;
- };
- 94EE49C41238D66200EFDAB1 /* OAuth2Client.framework */ = {
- isa = PBXReferenceProxy;
- fileType = wrapper.framework;
- path = OAuth2Client.framework;
- remoteRef = 94EE49C31238D66200EFDAB1 /* PBXContainerItemProxy */;
- sourceTree = BUILT_PRODUCTS_DIR;
- };
- F61580CF13FD132D0049FF2E /* libSoundCloudUI.a */ = {
- isa = PBXReferenceProxy;
- fileType = archive.ar;
- path = libSoundCloudUI.a;
- remoteRef = F61580CE13FD132D0049FF2E /* PBXContainerItemProxy */;
- sourceTree = BUILT_PRODUCTS_DIR;
- };
-/* End PBXReferenceProxy section */
-
/* Begin PBXResourcesBuildPhase section */
94535F82123FAFDF00BD668A /* Resources */ = {
isa = PBXResourcesBuildPhase;
@@ -455,30 +319,11 @@
F6E88D2813D41F8A008B9CD5 /* SCConstants.m in Sources */,
F6E88D3213D43B67008B9CD5 /* SCAccount+Private.m in Sources */,
F6525B8013D5B34A00ACAE8F /* SCSoundCloud+Private.m in Sources */,
- F61580FB13FD13430049FF2E /* JSONKit.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
-/* Begin PBXTargetDependency section */
- 94E5ADA8122C193000C7021A /* PBXTargetDependency */ = {
- isa = PBXTargetDependency;
- name = OAuth2Client;
- targetProxy = 94E5ADA7122C193000C7021A /* PBXContainerItemProxy */;
- };
- 99EF0E7D13BB1B29000D7FEA /* PBXTargetDependency */ = {
- isa = PBXTargetDependency;
- name = OAuth2Client.framework;
- targetProxy = 99EF0E7C13BB1B29000D7FEA /* PBXContainerItemProxy */;
- };
- F615810A13FD14060049FF2E /* PBXTargetDependency */ = {
- isa = PBXTargetDependency;
- name = SoundCloudUI;
- targetProxy = F615810913FD14060049FF2E /* PBXContainerItemProxy */;
- };
-/* End PBXTargetDependency section */
-
/* Begin XCBuildConfiguration section */
1DEB921F08733DC00010E9CD /* Debug */ = {
isa = XCBuildConfiguration;
@@ -498,7 +343,7 @@
PRODUCT_NAME = SoundCloudAPI;
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
- USER_HEADER_SEARCH_PATHS = "Outsourced/**";
+ USER_HEADER_SEARCH_PATHS = "../**";
};
name = Debug;
};
@@ -517,7 +362,7 @@
PRODUCT_NAME = SoundCloudAPI;
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
- USER_HEADER_SEARCH_PATHS = "Outsourced/**";
+ USER_HEADER_SEARCH_PATHS = "../**";
};
name = Release;
};
View
1,283 Sources/SoundCloudUI/SCRecordingSaveViewController.m.orig
@@ -1,1283 +0,0 @@
-//
-// SCRecordingSaveViewController.m
-// Soundcloud
-//
-// Created by Gernot Poetsch on 25.10.10.
-// Copyright 2010 nxtbgthng. All rights reserved.
-//
-
-#import "QuartzCore_GPKit.h"
-#import "UIImage_GPKit.h"
-#import "SCSwitch.h"
-#import "GPTableCellBackgroundView.h"
-#import "GPURLConnection.h"
-
-#import "JSONKit.h"
-
-#import "SCSharingMailPickerController.h"
-#import "SCFoursquarePlacePickerController.h"
-#import "SCConstants.h"
-#import "SCAddConnectionViewController.h"
-#import "SCAccount.h"
-#import "SCSoundCloud.h"
-#import "SCRequest.h"
-#import "SCLoginViewController.h"
-
-#import "SCBundle.h"
-#import "SCSCRecordingSaveViewControllerTitleView.h"
-#import "SCRecordingSaveViewControllerHeaderView.h"
-#import "SCRecordingUploadProgressView.h"
-
-#import "UIColor+SoundCloud.h"
-
-#import "SCRecordingSaveViewController.h"
-
-
-#define COVER_WIDTH 600.0
-
-
-@interface SCRecordingSaveViewController ()
-
-#pragma mark Accessors
-@property (nonatomic, retain) NSArray *availableConnections;
-@property (nonatomic, retain) NSArray *unconnectedServices;
-@property (nonatomic, retain) NSArray *sharingConnections;
-@property (nonatomic, retain) NSArray *sharingMailAddresses;
-
-@property (nonatomic, retain) NSURL *fileURL;
-@property (nonatomic, retain) NSData *fileData;
-@property (nonatomic, assign) BOOL isPrivate;
-@property (nonatomic, retain) UIImage *coverImage;
-@property (nonatomic, retain) NSString *title;
-@property (nonatomic, retain) NSDate *trackCreationDate;
-
-@property (nonatomic, retain) CLLocation *location;
-@property (nonatomic, copy) NSString *locationTitle;
-@property (nonatomic, copy) NSString *foursquareID;
-
-@property (nonatomic, readwrite, retain) SCAccount *account;
-
-@property (nonatomic, retain) SCFoursquarePlacePickerController *foursquareController;
-
-@property (nonatomic, assign) SCRecordingSaveViewControllerHeaderView *headerView;
-@property (nonatomic, assign) SCRecordingUploadProgressView *uploadProgressView;
-@property (nonatomic, assign) UITableView *tableView;
-
-@property (nonatomic, copy) SCRecordingSaveViewControllerCompletionHandler completionHandler;
-
-@property (nonatomic, assign) UIToolbar *toolBar;
-
-#pragma mark UI
-- (void)updateInterface;
-
-#pragma mark Actions
-- (IBAction)shareConnectionSwitchToggled:(id)sender;
-- (IBAction)openCameraPicker;
-- (IBAction)openImageLibraryPicker;
-- (IBAction)openPlacePicker;
-- (IBAction)closePlacePicker;
-- (IBAction)privacyChanged:(id)sender;
-- (IBAction)selectImage;
-- (IBAction)resetImage;
-- (IBAction)upload;
-- (IBAction)cancel;
-- (IBAction)relogin;
-
-#pragma mark Notification Handling
-- (void)accountDidChange:(NSNotification *)aNotification;
-- (void)didFailToRequestAccess:(NSNotification *)aNotification;
-
-
-#pragma mark Tool Bar Animation
-- (void)hideToolBar;
-- (void)showToolBar;
-
-#pragma mark Helpers
-- (NSString *)generatedTitle;
-- (NSString *)generatedSharingNote;
-- (NSString *)dateString;
-@end
-
-
-NSString * const SCDefaultsKeyRecordingIsPrivate = @"SCRecordingIsPrivate";
-
-
-@implementation SCRecordingSaveViewController
-
-
-#pragma mark Class methods
-
-const NSArray *allServices = nil;
-
-+ (void)initialize;
-{
- [[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWithObjectsAndKeys:
- [NSNumber numberWithBool:NO], SCDefaultsKeyRecordingIsPrivate,
- nil]];
- allServices = [[NSArray alloc] initWithObjects:
- [NSDictionary dictionaryWithObjectsAndKeys:
- SCLocalizedString(@"service_twitter", @"Twitter"), @"displayName",
- @"twitter", @"service",
- nil],
- [NSDictionary dictionaryWithObjectsAndKeys:
- SCLocalizedString(@"service_facebook", @"Facebook"), @"displayName",
- @"facebook_profile", @"service",
- nil],
- [NSDictionary dictionaryWithObjectsAndKeys:
- SCLocalizedString(@"service_tumblr", @"Tumblr"), @"displayName",
- @"tumblr", @"service",
- nil],
- [NSDictionary dictionaryWithObjectsAndKeys:
- SCLocalizedString(@"service_foursquare", @"Foursquare"), @"displayName",
- @"foursquare", @"service",
- nil],
- nil];
-}
-
-
-@synthesize availableConnections;
-@synthesize unconnectedServices;
-@synthesize sharingConnections;
-@synthesize sharingMailAddresses;
-@synthesize fileURL;
-@synthesize fileData;
-@synthesize isPrivate;
-@synthesize coverImage;
-@synthesize title;
-@synthesize trackCreationDate;
-@synthesize location;
-@synthesize locationTitle;
-@synthesize foursquareID;
-@synthesize account;
-@synthesize foursquareController;
-@synthesize headerView;
-@synthesize uploadProgressView;
-@synthesize completionHandler;
-@synthesize tableView;
-@synthesize toolBar;
-
-
-#pragma mark Lifecycle
-
-- (id)init;
-{
- self = [super init];
- if (self) {
- unconnectedServices = [[NSArray alloc] init];
- availableConnections = [[NSArray alloc] init];
- sharingConnections = [[NSArray alloc] init];
- sharingMailAddresses = [[NSArray alloc] init];
-
- isPrivate = [[NSUserDefaults standardUserDefaults] boolForKey:SCDefaultsKeyRecordingIsPrivate];
- location = nil;
- locationTitle = nil;
- foursquareID = nil;
-
- coverImage = nil;
- title = nil;
-
- trackCreationDate = [[NSDate date] retain];
-
- completionHandler = nil;
-
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(accountDidChange:)
- name:SCSoundCloudAccountDidChangeNotification
- object:nil];
-
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(didFailToRequestAccess:)
- name:SCSoundCloudDidFailToRequestAccessNotification
- object:nil];
-
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(cancel)
- name:SCLoginViewControllerCancelNotification
- object:nil];
- }
- return self;
-}
-
-- (void)dealloc;
-{
- [[NSNotificationCenter defaultCenter] removeObserver:self];
-
- [availableConnections release];
- [unconnectedServices release];
- [sharingConnections release];
- [sharingMailAddresses release];
- [account release];
- [coverImage release];
- [title release];
- [trackCreationDate release];
- [location release];
- [locationTitle release];
- [foursquareID release];
- [foursquareController release];
- [completionHandler release];
-
- [super dealloc];
-}
-
-
-#pragma mark Accessors
-
-- (void)setFileURL:(NSURL *)aFileURL;
-{
- if (fileURL != aFileURL) {
- [fileURL release];
- [aFileURL retain];
- fileURL = aFileURL;
- }
-}
-
-- (void)setFileData:(NSData *)someFileData;
-{
- if (fileData != someFileData) {
- [fileData release];
- [someFileData retain];
- fileData = someFileData;
- }
-}
-
-- (void)setAccount:(SCAccount *)anAccount;
-{
- if (account != anAccount) {
- [account release];
- [anAccount retain];
- account = anAccount;
-
- if (self.account) {
- [SCRequest performMethod:SCRequestMethodGET
- onResource:[NSURL URLWithString:@"https://api.soundcloud.com/me/connections.json"]
- usingParameters:nil
- withAccount:self.account
- sendingProgressHandler:nil
- responseHandler:^(NSURLResponse *response, NSData *data, NSError *error){
- if (data) {
- NSError *jsonError = nil;
- NSArray *result = [data objectFromJSONData];
- if (result) {
- [self setAvailableConnections:result];
- } else {
- NSLog(@"%s json error: %@", __FUNCTION__, [jsonError localizedDescription]);
- }
- } else {
- NSLog(@"%s error: %@", __FUNCTION__, [error localizedDescription]);
- }
- }];
-
- [SCRequest performMethod:SCRequestMethodGET
- onResource:[NSURL URLWithString:@"https://api.soundcloud.com/me.json"]
- usingParameters:nil
- withAccount:self.account
- sendingProgressHandler:nil
- responseHandler:^(NSURLResponse *response, NSData *data, NSError *error){
- if (data) {
- NSError *jsonError = nil;
- id result = [data objectFromJSONData];
- if (result) {
-// NSLog(@"Me: %@", result);
-
- NSURL *avatarURL = [NSURL URLWithString:[result objectForKey:@"avatar_url"]];
- NSData *avatarData = [NSData dataWithContentsOfURL:avatarURL];
- [self.headerView setAvatarImage:[UIImage imageWithData:avatarData]];
- [self.headerView setUserName:[result objectForKey:@"username"]];
-
- } else {
- NSLog(@"%s json error: %@", __FUNCTION__, [jsonError localizedDescription]);
- }
- } else {
- NSLog(@"%s error: %@", __FUNCTION__, [error localizedDescription]);
- }
- }];
- }
- }
-}
-
-- (void)setPrivate:(BOOL)p;
-{
- isPrivate = p;
-}
-
-- (void)setCoverImage:(UIImage *)aCoverImage;
-{
- if (coverImage != aCoverImage) {
- [coverImage release];
- [aCoverImage retain];
- coverImage = aCoverImage;
- [self.headerView setCoverImage:aCoverImage];
- }
-}
-
-- (void)setTitle:(NSString *)aTitle;
-{
- if (title != aTitle) {
- [title release];
- [aTitle retain];
- title = aTitle;
- }
-}
-
-- (void)setCreationDate:(NSDate *)aCreationDate;
-{
- self.trackCreationDate = aCreationDate;
-}
-
-- (void)setAvailableConnections:(NSArray *)value;
-{
- [value retain]; [availableConnections release]; availableConnections = value;
-
- NSMutableArray *newUnconnectedServices = [allServices mutableCopy];
-
- //Set the unconnected Services
- for (NSDictionary *connection in availableConnections) {
- NSDictionary *connectedService = nil;
- for (NSDictionary *unconnectedService in newUnconnectedServices) {
- if ([[connection objectForKey:@"service"] isEqualToString:[unconnectedService objectForKey:@"service"]]) {
- connectedService = unconnectedService;
- }
- }
- if (connectedService) [newUnconnectedServices removeObject:connectedService];
- }
-
- self.unconnectedServices = newUnconnectedServices;
- [newUnconnectedServices release];
- [self.tableView reloadData];
-}
-
-
-#pragma mark Foursquare
-
-- (void)setFoursquareClientID:(NSString *)aClientID clientSecret:(NSString *)aClientSecret;
-{
- self.foursquareController = [[[SCFoursquarePlacePickerController alloc] initWithDelegate:self
- clientID:aClientID
- clientSecret:aClientSecret] autorelease];
-
- self.foursquareController.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel
- target:self
- action:@selector(closePlacePicker)] autorelease];
-
- if (self.foursquareController) {
- self.headerView.disclosureButton.hidden = NO;
- [self.headerView.disclosureButton addTarget:self
- action:@selector(openPlacePicker)
- forControlEvents:UIControlEventTouchUpInside];
- } else {
- self.headerView.disclosureButton.hidden = YES;
- [self.headerView.disclosureButton removeTarget:self
- action:@selector(openPlacePicker)
- forControlEvents:UIControlEventTouchUpInside];
- }
-}
-
-
-#pragma mark ViewController
-
-- (void)viewDidLoad;
-{
- [super viewDidLoad];
-
- NSLog(@"%s frame: %@", __FUNCTION__, NSStringFromCGRect(self.view.frame));
- NSLog(@"%s bounds: %@", __FUNCTION__, NSStringFromCGRect(self.view.bounds));
-
- self.view.autoresizingMask = (UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin);
-
-
- // Background
- UIImage *bg = [SCBundle imageFromPNGWithName:@"darkTexturedBackgroundPattern"];
- self.view.backgroundColor = [UIColor colorWithPatternImage:bg];
-
-
- // Navigation Bar
- self.navigationController.navigationBarHidden = YES;
-
-
- // Banner
-// [self.view addSubview:[[[SCSCRecordingSaveViewControllerTitleView alloc] initWithFrame:CGRectMake(0.0, 0.0, CGRectGetWidth(self.tableView.bounds), 28.0)] autorelease]];
-
-
- // Toolbar
- self.toolBar = [[[UIToolbar alloc] init] autorelease];
- self.toolBar.barStyle = UIBarStyleBlack;
- self.toolBar.autoresizingMask = (UIViewAutoresizingFlexibleWidth |
- UIViewAutoresizingFlexibleTopMargin);
- [self.view addSubview:self.toolBar];
-
-
- NSMutableArray *toolbarItems = [NSMutableArray arrayWithCapacity:3];
-
- [toolbarItems addObject:[[[UIBarButtonItem alloc] initWithTitle:SCLocalizedString(@"cancel", @"Cancel")
- style:UIBarButtonItemStyleBordered
- target:self
- action:@selector(cancel)] autorelease]];
-
- [toolbarItems addObject:[[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil] autorelease]];
-
- [toolbarItems addObject:[[[UIBarButtonItem alloc] initWithTitle:SCLocalizedString(@"upload_and_share", @"Upload & Share")
- style:UIBarButtonItemStyleBordered
- target:self
- action:@selector(upload)] autorelease]];
-
- [self.toolBar setItems:toolbarItems];
-
-
- // Table View
- self.tableView = [[[UITableView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)
- style:UITableViewStyleGrouped] autorelease];
-
- self.tableView.autoresizingMask = (UIViewAutoresizingFlexibleHeight |
- UIViewAutoresizingFlexibleWidth);
-
- self.tableView.backgroundView = nil;
- self.tableView.backgroundColor = [UIColor clearColor];
- self.tableView.opaque = NO;
- self.tableView.delegate = self;
- self.tableView.dataSource = self;
-
- [self.view addSubview:self.tableView];
-
-
- // Header
- self.headerView = [[[SCRecordingSaveViewControllerHeaderView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(tableView.bounds), 0)] autorelease];
-
- self.headerView.whatTextField.delegate = self;
- self.headerView.whereTextField.delegate = self;
-
- [self.headerView.coverImageButton addTarget:self
- action:@selector(selectImage)
- forControlEvents:UIControlEventTouchUpInside];
-
- [self.headerView.privateSwitch addTarget:self
- action:@selector(privacyChanged:)
- forControlEvents:UIControlEventValueChanged];
-
- if (self.foursquareController) {
- self.headerView.disclosureButton.hidden = NO;
- [self.headerView.disclosureButton addTarget:self
- action:@selector(openPlacePicker)
- forControlEvents:UIControlEventTouchUpInside];
- } else {
- self.headerView.disclosureButton.hidden = YES;
- [self.headerView.disclosureButton removeTarget:self
- action:@selector(openPlacePicker)
- forControlEvents:UIControlEventTouchUpInside];
- }
-
- [self.headerView.logoutButton addTarget:self
- action:@selector(relogin)
- forControlEvents:UIControlEventTouchUpInside];
-
- self.tableView.tableHeaderView = self.headerView;
-
-
-
- [self updateInterface];
-}
-
-- (void)viewWillAppear:(BOOL)animated;
-{
- [super viewWillAppear:animated];
-
- [self.view addSubview:[[[SCSCRecordingSaveViewControllerTitleView alloc] initWithFrame:CGRectMake(0.0, 0.0, CGRectGetWidth(self.view.bounds), 28.0)] autorelease]];
-
- [self.toolBar sizeToFit];
- [self.toolBar setFrame:CGRectMake(0.0,
- self.view.frame.size.height - self.toolBar.frame.size.height,
- self.toolBar.frame.size.width,
- self.toolBar.frame.size.height)];
-
- CGRect tableViewFrame = self.view.bounds;
- tableViewFrame.origin.y += 28.0; // Banner
- tableViewFrame.size.height -= 28.0; // Banner
- tableViewFrame.size.height -= CGRectGetHeight(self.toolBar.frame); // Toolbar
-
- self.tableView.frame = tableViewFrame;
-
- self.account = [SCSoundCloud account];
-
- [tableView reloadData];
- [self updateInterface];
-}
-
-- (void)viewDidAppear:(BOOL)animated;
-{
- [super viewDidAppear:animated];
-
- if (!self.account) {
- [self relogin];
- }
-}
-
-- (void)viewWillDisappear:(BOOL)animated;
-{
- [super viewWillDisappear:animated];
- self.title = self.headerView.whatTextField.text;
- self.locationTitle = self.headerView.whereTextField.text;
-}
-
-- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation;
-{
- return YES;
- if (UIInterfaceOrientationIsPortrait(toInterfaceOrientation)) {
- return YES;
- }
- return NO;
-}
-
-- (void)updateInterface;
-{
- self.headerView.whatTextField.text = self.title;
- self.headerView.whereTextField.text = self.locationTitle;
- self.headerView.privateSwitch.on = !isPrivate;
- [self.headerView setCoverImage:self.coverImage];
-}
-
-
-#pragma mark TableView
-
-- (NSInteger)tableView:(UITableView *)table numberOfRowsInSection:(NSInteger)section;
-{
- if (isPrivate){
- return 1;
- } else {
- return self.availableConnections.count + self.unconnectedServices.count;
- }
-}
-
-- (UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
-{
- if (isPrivate) {
- UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:@"mailShare"];
- if (!cell) {
- cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"mailShare"] autorelease];
- GPTableCellBackgroundView *backgroundView = [[[GPTableCellBackgroundView alloc] initWithFrame:CGRectMake(0.0, 0.0, CGRectGetWidth(self.tableView.bounds), 44.0)] autorelease];
- backgroundView.opaque = NO;
- backgroundView.backgroundColor = [UIColor transparentBlack];
- backgroundView.borderColor = [UIColor blackColor];
- cell.backgroundView = backgroundView;
- cell.textLabel.backgroundColor = [UIColor clearColor];
- cell.textLabel.font = [UIFont systemFontOfSize:15.0];
- cell.textLabel.textColor = [UIColor listSubtitleColor];
- cell.textLabel.highlightedTextColor = [UIColor whiteColor];
- cell.detailTextLabel.backgroundColor = [UIColor clearColor];
- cell.detailTextLabel.font = [UIFont systemFontOfSize:15.0];
- cell.detailTextLabel.textColor = [UIColor whiteColor];
- cell.selectionStyle = UITableViewCellSelectionStyleGray;
- }
-
- cell.textLabel.text = SCLocalizedString(@"sc_upload_with_access", @"With access");
- if (self.sharingMailAddresses.count == 0) {
- cell.detailTextLabel.text = SCLocalizedString(@"sc_upload_only_you", @"Only you");
- } else {
- cell.detailTextLabel.text = [self.sharingMailAddresses componentsJoinedByString:@", "];
- }
-
- [(GPTableCellBackgroundView *)cell.backgroundView setPosition:[aTableView cellPositionForIndexPath:indexPath]];
-
- return cell;
-
- } else {
-
- if (indexPath.row < self.availableConnections.count) {
- UITableViewCell *cell = nil; // WORKAROUND: Reusing cells causes a problem with the boarder
- //[aTableView dequeueReusableCellWithIdentifier:@"connection"];
- if (!cell) {
- cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"connection"] autorelease];
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- cell.opaque = NO;
- GPTableCellBackgroundView *backgroundView = [[[GPTableCellBackgroundView alloc] initWithFrame:CGRectMake(0.0, 0.0, CGRectGetWidth(self.tableView.bounds), 44.0)] autorelease];
- backgroundView.opaque = NO;
- backgroundView.backgroundColor = [UIColor transparentBlack];
- backgroundView.borderColor = [UIColor blackColor];
- cell.backgroundView = backgroundView;
- cell.textLabel.backgroundColor = [UIColor clearColor];
- cell.textLabel.font = [UIFont systemFontOfSize:15.0];
- cell.textLabel.textColor = [UIColor whiteColor];
- }
-
-
- NSDictionary *connection = [self.availableConnections objectAtIndex:indexPath.row];
-
- cell.textLabel.text = [connection objectForKey:@"display_name"];
-
- SCSwitch *accessorySwitch = [[[SCSwitch alloc] init] autorelease];
- accessorySwitch.offBackgroundImage = [[SCBundle imageFromPNGWithName:@"switch_gray"] stretchableImageWithLeftCapWidth:5 topCapHeight:5];
-
- accessorySwitch.on = NO;
- [self.sharingConnections enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop){
- if ([[obj objectForKey:@"id"] isEqual:[connection objectForKey:@"id"]]) {
- if (self.foursquareID || ![[connection objectForKey:@"service"] isEqualToString:@"foursquare"]) {
- accessorySwitch.on = YES;
- }
- *stop = YES;
- }
- }];
-
- [accessorySwitch addTarget:self action:@selector(shareConnectionSwitchToggled:) forControlEvents:UIControlEventValueChanged];
-
- cell.accessoryView = accessorySwitch;
-
- cell.imageView.image = [SCBundle imageFromPNGWithName:[NSString stringWithFormat:@"service_%@", [connection objectForKey:@"service"]]];
-
- [(GPTableCellBackgroundView *)cell.backgroundView setPosition:[aTableView cellPositionForIndexPath:indexPath]];
-
- return cell;
- } else {
- UITableViewCell *cell = nil; // WORKAROUND: Reusing cells causes a problem with the boarder
- // [aTableView dequeueReusableCellWithIdentifier:@"newConnection"];
- if (!cell) {
- cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"newConnection"] autorelease];
- cell.selectionStyle = UITableViewCellSelectionStyleGray;
- GPTableCellBackgroundView *backgroundView = [[[GPTableCellBackgroundView alloc] initWithFrame:CGRectMake(0.0, 0.0, CGRectGetWidth(self.tableView.bounds), 44.0)] autorelease];
- backgroundView.opaque = NO;
- backgroundView.backgroundColor = [UIColor transparentBlack];
- backgroundView.borderColor = [UIColor blackColor];
- cell.backgroundView = backgroundView;
- cell.textLabel.backgroundColor = [UIColor clearColor];
- cell.textLabel.font = [UIFont systemFontOfSize:15.0];
- cell.textLabel.textColor = [UIColor whiteColor];
- cell.accessoryView = [[UIImageView alloc] initWithImage:[SCBundle imageFromPNGWithName:@"DisclosureIndicator"]];
- cell.detailTextLabel.text = SCLocalizedString(@"configure", @"Configure");
- cell.detailTextLabel.textColor = [UIColor whiteColor];
- cell.detailTextLabel.backgroundColor = [UIColor clearColor];
- }
-
- NSDictionary *service = [self.unconnectedServices objectAtIndex:indexPath.row - self.availableConnections.count];
- cell.textLabel.text = [service objectForKey:@"displayName"];
- cell.imageView.image = [SCBundle imageFromPNGWithName:[NSString stringWithFormat:@"service_%@", [service objectForKey:@"service"]]];
-
- [(GPTableCellBackgroundView *)cell.backgroundView setPosition:[aTableView cellPositionForIndexPath:indexPath]];
- return cell;
- }
- }
-}
-
-- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section;
-{
- if (self.isPrivate) {
- // TODO: Insert correct text describing the private options
- return SCLocalizedString(@"sc_upload_sharing_options_private", @"Your track will be private after the upload. You want to share it with others?");
- } else {
- return SCLocalizedString(@"sc_upload_sharing_options_public", @"Your track will be available for the public after the upload. You want to push it to other services afterwards?");
- }
-}
-
-- (UIView *)tableView:(UITableView *)aTableView viewForHeaderInSection:(NSInteger)section;
-{
- NSString *text = [self tableView:aTableView titleForHeaderInSection:section];
-
- CGSize textSize = [text sizeWithFont:[UIFont systemFontOfSize:15.0]
- constrainedToSize:CGSizeMake(CGRectGetWidth(self.tableView.bounds) - 10, CGFLOAT_MAX)
- lineBreakMode:UILineBreakModeWordWrap];
-
-<<<<<<< Updated upstream
- UIView *sectionHeaderView = [[[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, textSize.height + 2 * 10.0)] autorelease];
-=======
- UIView *sectionHeaderView = [[[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, CGRectGetWidth(self.tableView.bounds), textSize.height)] autorelease];
->>>>>>> Stashed changes
- sectionHeaderView.backgroundColor = [UIColor clearColor];
- UILabel *label = [[UILabel alloc] initWithFrame:CGRectInset(sectionHeaderView.bounds, 10.0, 0.0)];
- label.autoresizingMask = UIViewAutoresizingFlexibleWidth;
- label.backgroundColor = [UIColor clearColor];
- label.textColor = [UIColor listSubtitleColor];
- label.lineBreakMode = UILineBreakModeWordWrap;
- label.numberOfLines = 0;
- label.font = [UIFont systemFontOfSize:15.0];
- label.text = text;
- [sectionHeaderView addSubview:label];
- [label release];
- return sectionHeaderView;
-}
-
-- (CGFloat)tableView:(UITableView *)aTableView heightForHeaderInSection:(NSInteger)section;
-{
- NSString *text = [self tableView:aTableView titleForHeaderInSection:section];
-
- CGSize textSize = [text sizeWithFont:[UIFont systemFontOfSize:15.0]
- constrainedToSize:CGSizeMake(CGRectGetWidth(self.tableView.bounds) - 10, CGFLOAT_MAX)
- lineBreakMode:UILineBreakModeWordWrap];
-
- return textSize.height + 2 * 10.0;
-}
-
-- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section;
-{
- if (isPrivate) {
- return nil;
- } else {
- if (availableConnections.count == 0) {
- return nil; // @"To add sharing options, go to your settings on SoundCloud.com and select 'Connections'";
- } else {
- return SCLocalizedString(@"connection_list_footer", @"To change your default sharing options, go to your settings on SoundCloud and select 'Connections'");
- }
- }
-}
-
-- (UIView *)tableView:(UITableView *)aTableView viewForFooterInSection:(NSInteger)section;
-{
- if (isPrivate) {
- return nil;
- } else {
- UIView *footerView = [[[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, CGRectGetWidth(self.tableView.bounds), 20.0)] autorelease];
- footerView.backgroundColor = [UIColor clearColor];
- UILabel *label = [[UILabel alloc] initWithFrame:CGRectInset(footerView.bounds, 10.0, 0.0)];
- label.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
- label.backgroundColor = [UIColor clearColor];
- label.textColor = [UIColor listSubtitleColor];
- label.font = [UIFont systemFontOfSize:13.0];
- label.text = [self tableView:aTableView titleForFooterInSection:section];
- label.numberOfLines = 2;
- [footerView addSubview:label];
- [label release];
- return footerView;
- }
-}
-
-- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section;
-{
- return 48.0;
-}
-
-- (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;
-{
- if (isPrivate) {
- if (indexPath.section == 0 && indexPath.row == 0) {
- SCSharingMailPickerController *controller = [[SCSharingMailPickerController alloc] initWithDelegate:self];
- UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:controller];
- navController.navigationBar.barStyle = self.navigationController.navigationBar.barStyle;
- controller.title = SCLocalizedString(@"sc_upload_with_access", @"With Access");
- controller.result = self.sharingMailAddresses;
- [self presentModalViewController:navController animated:YES];
- [controller release];
- [navController release];
-
- [aTableView deselectRowAtIndexPath:indexPath animated:YES];
- }
- } else {
- if (indexPath.row >= availableConnections.count) {
- NSDictionary *service = [unconnectedServices objectAtIndex:indexPath.row - availableConnections.count];
- SCAddConnectionViewController *controller = [[SCAddConnectionViewController alloc] initWithService:[service objectForKey:@"service"] account:account delegate:self];
- controller.title = [NSString stringWithFormat:SCLocalizedString(@"sc_upload_connect_to", @"Connect %@"), [service objectForKey:@"displayName"]];
-
- [self.navigationController pushViewController:controller animated:YES];
- [controller release];
- [aTableView deselectRowAtIndexPath:indexPath animated:YES];
- }
- }
-}
-
-
-#pragma mark SCSharingMailPickerControllerDelegate
-
-- (void)sharingMailPickerController:(SCSharingMailPickerController *)controller didFinishWithResult:(NSArray *)emailAdresses;
-{
- self.sharingMailAddresses = emailAdresses;
- [self.tableView reloadData];
- [self dismissModalViewControllerAnimated:YES];
-}
-
-- (void)sharingMailPickerControllerDidCancel:(SCSharingMailPickerController *)controller;
-{
- [self dismissModalViewControllerAnimated:YES];
-}
-
-
-#pragma mark UITextFieldDelegate
-
-- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string;
-{
- NSString *text = [textField.text stringByReplacingCharactersInRange:range withString:string];
-
- if (textField == self.headerView.whatTextField) {
- self.title = text;
- } else if (textField == self.headerView.whereTextField) {
- self.locationTitle = text;
- }
- return YES;
-}
-
-- (BOOL)textFieldShouldEndEditing:(UITextField *)textField;
-{
- if (textField == self.headerView.whatTextField) {
- self.title = textField.text;
- } else if (textField == self.headerView.whereTextField) {
- self.locationTitle = textField.text;
- }
- return YES;
-}
-
-- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField;
-{
- if (self.foursquareController && textField == self.headerView.whereTextField) {
- [self.headerView.whatTextField resignFirstResponder]; //So we don't get the keyboard when coming back
- [self openPlacePicker];
- return NO;
- }
- return YES;
-}
-
-- (BOOL)textFieldShouldReturn:(UITextField *)textField;
-{
- [textField resignFirstResponder];
- return NO;
-}
-
-
-#pragma mark ActionSheet Delegate
-
-- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex;
-{
- if (buttonIndex == actionSheet.firstOtherButtonIndex) {
- [self openImageLibraryPicker];
- } else if (buttonIndex == actionSheet.firstOtherButtonIndex + 1
- && [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera].count > 0) {
- [self openCameraPicker];
- } else if (buttonIndex == actionSheet.destructiveButtonIndex) {
- [self resetImage];
- }
-
- [self updateInterface];
-}
-
-
-#pragma mark Image Picker Delegate
-
-- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo;
-{
- UIImage *actualImage = image;
- if (!CGSizeEqualToSize(actualImage.size, CGSizeMake(COVER_WIDTH, COVER_WIDTH))) {
- actualImage = [actualImage imageByResizingTo:CGSizeMake(COVER_WIDTH, COVER_WIDTH)];
- }
-
- self.coverImage = actualImage;
- [self dismissModalViewControllerAnimated:YES];
-}
-
-
-#pragma mark Place Picker Delegate
-
-- (void)foursquarePlacePicker:(SCFoursquarePlacePickerController *)aPicker
- didFinishWithTitle:(NSString *)aTitle
- foursquareID:(NSString *)aFoursquareID
- location:(CLLocation *)aLocation;
-{
- self.headerView.whereTextField.text = aTitle;
- self.locationTitle = aTitle;
- self.location = aLocation;
- self.foursquareID = aFoursquareID;
-
- [self dismissModalViewControllerAnimated:YES];
-}
-
-
-#pragma mark Add Connection Delegate
-
-- (void)addConnectionController:(SCAddConnectionViewController *)controller didFinishWithService:(NSString *)service success:(BOOL)success;
-{
- if (success) {
-
- // Update the sharing connections of this user and set the new connection to "on".
- // Dismiss the connection view controller after the connections where updated.
-
- [SCRequest performMethod:SCRequestMethodGET
- onResource:[NSURL URLWithString:@"https://api.soundcloud.com/me/connections.json"]
- usingParameters:nil
- withAccount:account
- sendingProgressHandler:nil
- responseHandler:^(NSURLResponse *response, NSData *data, NSError *error){
- if (data) {
- NSError *jsonError = nil;
- NSArray *result = [data objectFromJSONData];
- if (result) {
- [self setAvailableConnections:result];
- } else {
- NSLog(@"%s json error: %@", __FUNCTION__, [jsonError localizedDescription]);
- }
- } else {
- NSLog(@"%s error: %@", __FUNCTION__, [error localizedDescription]);
- }
-
- NSIndexSet *idxs = [availableConnections indexesOfObjectsPassingTest:^(id obj, NSUInteger i, BOOL *stop){
- if ([[obj objectForKey:@"service"] isEqual:service]) {
- *stop = YES;
- return YES;
- } else {
- return NO;
- }
- }];
-
- NSMutableArray *newSharingConnections = [self.sharingConnections mutableCopy];
- [newSharingConnections addObject:[availableConnections objectAtIndex:[idxs firstIndex]]];
- self.sharingConnections = newSharingConnections;
-
- if (self.navigationController.topViewController == controller) {
- [self.navigationController popViewControllerAnimated:YES];
- }
- }];
- }
-}
-
-
-#pragma mark Actions
-
-- (IBAction)shareConnectionSwitchToggled:(SCSwitch *)sender
-{
- UITableViewCell *cell = (UITableViewCell *)[(UIView *)sender superview];
- NSIndexPath *indexPath = [tableView indexPathForCell:cell];
-
- NSDictionary *connection = [availableConnections objectAtIndex:indexPath.row];
-
- //If this is a foursquare switch, we don't have a venue and want to switch it on, display place picker
- if ([[connection objectForKey:@"service"] isEqualToString:@"foursquare"] && !self.foursquareID && [sender isOn]) {
- [self openPlacePicker];
- }
-
- NSMutableArray *newSharingConnections = [self.sharingConnections mutableCopy];
- if ([sender isOn]) {
- [newSharingConnections addObject:connection];
- } else {
- NSIndexSet *idxs = [newSharingConnections indexesOfObjectsPassingTest:^(id obj, NSUInteger i, BOOL *stop){
- if ([[obj objectForKey:@"id"] isEqual:[connection objectForKey:@"id"]]) {
- *stop = YES;
- return YES;
- } else {
- return NO;
- }
- }];
- [newSharingConnections removeObjectsAtIndexes:idxs];
- }
-
- self.sharingConnections = newSharingConnections;
- [newSharingConnections release];
-}
-
-- (IBAction)privacyChanged:(id)sender;
-{
- if (sender == self.headerView.privateSwitch) {
- isPrivate = !self.headerView.privateSwitch.on;
- [[NSUserDefaults standardUserDefaults] setBool:!self.headerView.privateSwitch.on forKey:SCDefaultsKeyRecordingIsPrivate];
- [self.tableView reloadData];
- }
-}
-
-- (IBAction)selectImage;
-{
- UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:SCLocalizedString(@"recording_image", @"Cover Image")
- delegate:self
- cancelButtonTitle:SCLocalizedString(@"cancel", @"Cancel")
- destructiveButtonTitle:self.coverImage ? SCLocalizedString(@"artwork_reset", @"Reset") : nil
- otherButtonTitles:
- ([UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypePhotoLibrary].count > 0) ? SCLocalizedString(@"use_existing_image", @"Photo Library") : nil,
- ([UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera].count > 0) ? SCLocalizedString(@"take_new_picture", @"Camera") : nil,
- nil];
- [sheet showInView:self.view];
- [sheet release];
-}
-
-- (IBAction)openCameraPicker;
-{
- UIImagePickerController *picker = [[UIImagePickerController alloc] init];
- picker.delegate = self;
- picker.sourceType = UIImagePickerControllerSourceTypeCamera;
- picker.allowsEditing = YES;
- [self presentModalViewController:picker animated:YES];
- [picker release];
-}
-
-- (IBAction)openImageLibraryPicker;
-{
- UIImagePickerController *picker = [[UIImagePickerController alloc] init];
- picker.delegate = self;
- picker.allowsEditing = YES;
- picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
- [self presentModalViewController:picker animated:YES];
- [picker release];
-}
-
-- (IBAction)openPlacePicker;
-{
- if (self.foursquareController) {
- UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:self.foursquareController];
- navController.navigationBar.barStyle = self.navigationController.navigationBar.barStyle;
- [self presentModalViewController:navController animated:YES];
- [navController release];
- }
-}
-
-- (IBAction)closePlacePicker;
-{
- [self dismissModalViewControllerAnimated:YES];
-}
-
-- (IBAction)resetImage;
-{
- self.coverImage = nil;
-}
-
-- (IBAction)upload;
-{
- NSLog(@"Uploading ...");
-
- [self hideToolBar];
-
- // setup progress view
- self.tableView.hidden = YES;
- [self.navigationController setToolbarHidden:YES animated:YES];
-
- if (self.uploadProgressView) {
- [self.uploadProgressView removeFromSuperview];
- }
-
- self.uploadProgressView = [[SCRecordingUploadProgressView alloc] initWithFrame:CGRectMake(26, 58, CGRectGetWidth(self.view.bounds) - 52, CGRectGetHeight(self.view.bounds) - 26 - 58)];
- [self.view addSubview:self.uploadProgressView];
-
- [self.uploadProgressView setTitle:[self generatedTitle]];
- [self.uploadProgressView setCoverImage:self.coverImage];
-
- [self.uploadProgressView.cancelButton addTarget:self
- action:@selector(cancel)
- forControlEvents:UIControlEventTouchUpInside];
-
-
- // set up request
- NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
-
- // track
- if (self.fileURL) {
- [parameters setObject:self.fileURL forKey:@"track[asset_data]"];
- } else {
- [parameters setObject:self.fileData forKey:@"track[asset_data]"];
- }
-
- // metadata
- [parameters setObject:[self generatedTitle] forKey:@"track[title]"];
- [parameters setObject:(self.isPrivate) ? @"private" : @"public" forKey: @"track[sharing]"];
- [parameters setObject:[self generatedSharingNote] forKey:@"track[sharing_note]"];
- [parameters setObject:@"recording" forKey:@"track[track_type]"];
- [parameters setObject:@"1" forKey:@"track[downloadable]"];
-
- // sharing
- if (self.isPrivate) {
- if (self.sharingMailAddresses.count > 0) {
- [parameters setObject:self.sharingMailAddresses forKey:@"track[shared_to][emails][][address]"];
- }
- } else {
- if (self.sharingConnections.count > 0) {
- NSMutableArray *idArray = [NSMutableArray arrayWithCapacity:self.sharingConnections.count];
- for (NSDictionary *sharingConnection in sharingConnections) {
- if ([[sharingConnection objectForKey:@"service"] isEqualToString:@"foursquare"] && !self.foursquareID) {
- //Ignore Foursquare sharing when there is no venue ID set.
- } else {
- [idArray addObject:[NSString stringWithFormat:@"%@", [sharingConnection objectForKey:@"id"]]];
- }
- }
- [parameters setObject:idArray forKey:@"track[post_to][][id]"];
- } else {
- [parameters setObject:@"" forKey:@"track[post_to][]"];
- }
- }
-
- // artwork
- if (self.coverImage) {
- NSData *coverData = UIImageJPEGRepresentation(self.coverImage, 0.8);
- [parameters setObject:coverData forKey:@"track[artwork_data]"];
- }
-
- // tags (location)
- NSMutableArray *tags = [NSMutableArray array];
- [tags addObject:@"soundcloud:source=iphone-record"];
- if (self.location) {
- [tags addObject:[NSString stringWithFormat:@"geo:lat=%f", self.location.coordinate.latitude]];
- [tags addObject:[NSString stringWithFormat:@"geo:lon=%f", self.location.coordinate.longitude]];
- }
- if (self.foursquareID) {
- [tags addObject:[NSString stringWithFormat:@"foursquare:venue=%@", self.foursquareID]];
- }
- [parameters setObject:[tags componentsJoinedByString:@" "] forKey:@"track[tag_list]"];
-
-
- // perform request
- [SCRequest performMethod:SCRequestMethodPOST
- onResource:[NSURL URLWithString:@"https://api.soundcloud.com/tracks.json"]
- usingParameters:parameters
- withAccount:self.account
- sendingProgressHandler:^(unsigned long long bytesSend, unsigned long long bytesTotal){self.uploadProgressView.progressView.progress = (float)bytesSend / bytesTotal;}
- responseHandler:^(NSURLResponse *response, NSData *data, NSError *error){
- if (data) {
- NSError *jsonError = nil;
- id result = [data objectFromJSONData]; //[NSJSONSerialization JSONObjectWithData:data options:0 error:&jsonError];
- if (result) {
-
- [self.uploadProgressView setSuccess:YES];
-
- double delayInSeconds = 2.0;
- dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
- dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
- self.completionHandler(NO, result);
- });
- } else {
- NSLog(@"Upload failed with json error: %@", [jsonError localizedDescription]);
-
- [self.uploadProgressView setSuccess:NO];
- UIBarButtonItem *button = [self.toolBar.items lastObject];
- [self showToolBar];
- button.title = SCLocalizedString(@"retry_upload", @"Retry upload");
- }
- } else {
- NSLog(@"Upload failed with error: %@", [error localizedDescription]);
-
- [self.uploadProgressView setSuccess:NO];
- UIBarButtonItem *button = [self.toolBar.items lastObject];
- [self showToolBar];
- button.title = SCLocalizedString(@"retry_upload", @"Retry upload");
- }
- }];
-}
-
-- (IBAction)cancel;
-{
- NSLog(@"canceling ...");
- self.completionHandler(YES, nil);
-}
-
-- (IBAction)relogin;
-{
- NSLog(@"Logging out ...");
- [SCSoundCloud removeAccess];
- self.account = nil;
- [SCSoundCloud requestAccessWithPreparedAuthorizationURLHandler:^(NSURL *preparedURL){
- SCLoginViewController *loginViewController = [[[SCLoginViewController alloc] initWithURL:preparedURL authentication:nil] autorelease];
- [self presentModalViewController:[[[UINavigationController alloc] initWithRootViewController:loginViewController] autorelease] animated:YES];
- }];
-}
-
-
-#pragma mark Notification Handling
-
-- (void)accountDidChange:(NSNotification *)aNotification;
-{
-// NSLog(@"%s", __FUNCTION__);
- self.account = [SCSoundCloud account];
- if (self.account && self.modalViewController){
- [self dismissModalViewControllerAnimated:YES];
- }
-}
-
-- (void)didFailToRequestAccess:(NSNotification *)aNotification;
-{
- NSLog(@"%s: %@", __FUNCTION__, aNotification);
- [self cancel];
-}
-
-
-
-#pragma mark Tool Bar Animation
-- (void)hideToolBar;
-{
- [UIView animateWithDuration:0.2
- animations:^{
- CGPoint center = self.toolBar.center;
- self.toolBar.center = CGPointMake(center.x, center.y + CGRectGetHeight(self.toolBar.frame));
- }];
-}
-
-- (void)showToolBar;
-{
- [UIView animateWithDuration:0.2
- animations:^{
- CGPoint center = self.toolBar.center;
- self.toolBar.center = CGPointMake(center.x, center.y - CGRectGetHeight(self.toolBar.frame));
- }];
-}
-
-#pragma mark Helpers
-
-
-- (NSString *)generatedTitle;
-{
- if (self.title.length > 0) {
- if (self.locationTitle.length > 0) {
- return [NSString stringWithFormat:SCLocalizedString(@"recording_title_at_location_name", @"%@ at %@"), self.title, self.locationTitle];
- } else {
- return self.title;
- }
- } else {
- if (self.locationTitle.length > 0) {
- return [NSString stringWithFormat:SCLocalizedString(@"recording_at_location", @"Sounds at %@"), self.locationTitle];
- } else {
- return [NSString stringWithFormat:SCLocalizedString(@"recording_from_data", @"Sounds from %@"), [self dateString]];
- }
- }
-}
-
-- (NSString *)generatedSharingNote;
-{
- NSString *note = nil;
-
- if (self.title.length > 0) {
- if (self.locationTitle.length > 0) {
- note = [NSString stringWithFormat:SCLocalizedString(@"recording_title_at_location_name", @"%@ at %@"), self.title, self.locationTitle];
- } else {
- note = self.title;
- }
- } else {
- if (self.locationTitle.length > 0) {
- note = [NSString stringWithFormat:SCLocalizedString(@"recording_at_location", @"Sounds at %@"), self.locationTitle];
- } else {
- note = [NSString stringWithFormat:SCLocalizedString(@"recording_from_data", @"Sounds from %@"), [self dateString]];
- }
- }
-
- return note;
-}
-
-- (NSString *)dateString;
-{
- NSString *weekday = nil;
- NSString *time = nil;
-
- NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
- NSDateComponents *components = [gregorian components:(NSWeekdayCalendarUnit | NSHourCalendarUnit) fromDate:self.trackCreationDate];
- [gregorian release];
-
- switch ([components weekday]) {
- case 1:
- weekday = SCLocalizedString(@"recording_weekday_sunday", @"Sunday");
- break;
- case 2:
- weekday = SCLocalizedString(@"recording_weekday_monday", @"Monday");
- break;
- case 3:
- weekday = SCLocalizedString(@"weekday_tuesday", @"Tuesday");
- break;
- case 4:
- weekday = SCLocalizedString(@"weekday_wednesday", @"Wednesday");
- break;
- case 5:
- weekday = SCLocalizedString(@"weekday_thursday", @"Thursday");
- break;
- case 6:
- weekday = SCLocalizedString(@"weekday_friday", @"Friday");
- break;
- case 7:
- weekday = SCLocalizedString(@"weekday_saturday", @"Saturday");
- break;
- }
-
- if ([components hour] <= 12) {
- time = SCLocalizedString(@"timeframe_morning", @"morning");
- } else if ([components hour] <= 17) {
- time = SCLocalizedString(@"timeframe_afternoon", @"afternoon");
- } else if ([components hour] <= 21) {
- time = SCLocalizedString(@"timeframe_evening", @"evening");
- } else {
- time = SCLocalizedString(@"timeframe_night", @"night");
- }
-
- return [NSString stringWithFormat:@"%@ %@", weekday, time];
-}
-
-@end
-
Please sign in to comment.
Something went wrong with that request. Please try again.