diff --git a/Assets/list_screenshot.png b/Assets/list_screenshot.png new file mode 100644 index 000000000..9abaaac94 Binary files /dev/null and b/Assets/list_screenshot.png differ diff --git a/Assets/player_screenshot.png b/Assets/player_screenshot.png new file mode 100644 index 000000000..3dec1847d Binary files /dev/null and b/Assets/player_screenshot.png differ diff --git a/Audiobook Player.xcodeproj/project.pbxproj b/Audiobook Player.xcodeproj/project.pbxproj index c51a007fc..66c5b5724 100644 --- a/Audiobook Player.xcodeproj/project.pbxproj +++ b/Audiobook Player.xcodeproj/project.pbxproj @@ -7,13 +7,15 @@ objects = { /* Begin PBXBuildFile section */ + 413616401D2E21F000E48944 /* ListBooksViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4136163F1D2E21F000E48944 /* ListBooksViewController.swift */; }; + 413616441D30115700E48944 /* Chameleon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 413616431D30115700E48944 /* Chameleon.framework */; }; 418B6CFC1D2707F800F974FB /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 418B6CFB1D2707F800F974FB /* AppDelegate.swift */; }; - 418B6CFE1D2707F800F974FB /* MasterViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 418B6CFD1D2707F800F974FB /* MasterViewController.swift */; }; - 418B6D001D2707F800F974FB /* DetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 418B6CFF1D2707F800F974FB /* DetailViewController.swift */; }; 418B6D031D2707F800F974FB /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 418B6D011D2707F800F974FB /* Main.storyboard */; }; 418B6D051D2707F800F974FB /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 418B6D041D2707F800F974FB /* Assets.xcassets */; }; 418B6D081D2707F800F974FB /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 418B6D061D2707F800F974FB /* LaunchScreen.storyboard */; }; 418B6D131D2707F800F974FB /* Audiobook_PlayerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 418B6D121D2707F800F974FB /* Audiobook_PlayerTests.swift */; }; + 418B6D5D1D2CB76900F974FB /* PlayerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 418B6D5C1D2CB76900F974FB /* PlayerViewController.swift */; }; + 41AB1C131D30298800AC1AA0 /* MBProgressHUD.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 41AB1C121D30298800AC1AA0 /* MBProgressHUD.framework */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -27,10 +29,10 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 4136163F1D2E21F000E48944 /* ListBooksViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListBooksViewController.swift; sourceTree = ""; }; + 413616431D30115700E48944 /* Chameleon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Chameleon.framework; path = Carthage/Build/iOS/Chameleon.framework; sourceTree = ""; }; 418B6CF81D2707F800F974FB /* Audiobook Player.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Audiobook Player.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 418B6CFB1D2707F800F974FB /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; - 418B6CFD1D2707F800F974FB /* MasterViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MasterViewController.swift; sourceTree = ""; }; - 418B6CFF1D2707F800F974FB /* DetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailViewController.swift; sourceTree = ""; }; 418B6D021D2707F800F974FB /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 418B6D041D2707F800F974FB /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 418B6D071D2707F800F974FB /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; @@ -38,6 +40,8 @@ 418B6D0E1D2707F800F974FB /* Audiobook PlayerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Audiobook PlayerTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; 418B6D121D2707F800F974FB /* Audiobook_PlayerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Audiobook_PlayerTests.swift; sourceTree = ""; }; 418B6D141D2707F800F974FB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 418B6D5C1D2CB76900F974FB /* PlayerViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PlayerViewController.swift; sourceTree = ""; }; + 41AB1C121D30298800AC1AA0 /* MBProgressHUD.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MBProgressHUD.framework; path = Carthage/Build/iOS/MBProgressHUD.framework; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -45,6 +49,8 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 413616441D30115700E48944 /* Chameleon.framework in Frameworks */, + 41AB1C131D30298800AC1AA0 /* MBProgressHUD.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -61,6 +67,8 @@ 418B6CEF1D2707F700F974FB = { isa = PBXGroup; children = ( + 41AB1C121D30298800AC1AA0 /* MBProgressHUD.framework */, + 413616431D30115700E48944 /* Chameleon.framework */, 418B6CFA1D2707F800F974FB /* Audiobook Player */, 418B6D111D2707F800F974FB /* Audiobook PlayerTests */, 418B6CF91D2707F800F974FB /* Products */, @@ -79,9 +87,9 @@ 418B6CFA1D2707F800F974FB /* Audiobook Player */ = { isa = PBXGroup; children = ( + 4136163F1D2E21F000E48944 /* ListBooksViewController.swift */, + 418B6D5C1D2CB76900F974FB /* PlayerViewController.swift */, 418B6CFB1D2707F800F974FB /* AppDelegate.swift */, - 418B6CFD1D2707F800F974FB /* MasterViewController.swift */, - 418B6CFF1D2707F800F974FB /* DetailViewController.swift */, 418B6D011D2707F800F974FB /* Main.storyboard */, 418B6D041D2707F800F974FB /* Assets.xcassets */, 418B6D061D2707F800F974FB /* LaunchScreen.storyboard */, @@ -109,6 +117,7 @@ 418B6CF41D2707F800F974FB /* Sources */, 418B6CF51D2707F800F974FB /* Frameworks */, 418B6CF61D2707F800F974FB /* Resources */, + 413616421D30100100E48944 /* ShellScript */, ); buildRules = ( ); @@ -149,6 +158,11 @@ TargetAttributes = { 418B6CF71D2707F800F974FB = { CreatedOnToolsVersion = 7.3; + SystemCapabilities = { + com.apple.BackgroundModes = { + enabled = 1; + }; + }; }; 418B6D0D1D2707F800F974FB = { CreatedOnToolsVersion = 7.3; @@ -195,14 +209,32 @@ }; /* End PBXResourcesBuildPhase section */ +/* Begin PBXShellScriptBuildPhase section */ + 413616421D30100100E48944 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "$(SRCROOT)/Carthage/Build/iOS/Chameleon.framework", + "$(SRCROOT)/Carthage/Build/iOS/MBProgressHUD.framework", + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/usr/local/bin/carthage copy-frameworks"; + }; +/* End PBXShellScriptBuildPhase section */ + /* Begin PBXSourcesBuildPhase section */ 418B6CF41D2707F800F974FB /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 418B6D001D2707F800F974FB /* DetailViewController.swift in Sources */, - 418B6CFE1D2707F800F974FB /* MasterViewController.swift in Sources */, + 413616401D2E21F000E48944 /* ListBooksViewController.swift in Sources */, 418B6CFC1D2707F800F974FB /* AppDelegate.swift in Sources */, + 418B6D5D1D2CB76900F974FB /* PlayerViewController.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -333,6 +365,10 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Carthage/Build/iOS", + ); INFOPLIST_FILE = "Audiobook Player/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.tortugapower.Audiobook-Player"; @@ -344,6 +380,10 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Carthage/Build/iOS", + ); INFOPLIST_FILE = "Audiobook Player/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.tortugapower.Audiobook-Player"; @@ -394,6 +434,7 @@ 418B6D191D2707F800F974FB /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; 418B6D1A1D2707F800F974FB /* Build configuration list for PBXNativeTarget "Audiobook PlayerTests" */ = { isa = XCConfigurationList; @@ -402,6 +443,7 @@ 418B6D1C1D2707F800F974FB /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; diff --git a/Audiobook Player/AppDelegate.swift b/Audiobook Player/AppDelegate.swift index 5afbf071a..1e18d5550 100644 --- a/Audiobook Player/AppDelegate.swift +++ b/Audiobook Player/AppDelegate.swift @@ -7,6 +7,7 @@ // import UIKit +import AVFoundation @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDelegate { @@ -16,10 +17,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // Override point for customization after application launch. - let splitViewController = self.window!.rootViewController as! UISplitViewController - let navigationController = splitViewController.viewControllers[splitViewController.viewControllers.count-1] as! UINavigationController - navigationController.topViewController!.navigationItem.leftBarButtonItem = splitViewController.displayModeButtonItem() - splitViewController.delegate = self + UIApplication.sharedApplication().statusBarStyle = .LightContent + + UIApplication.sharedApplication().beginReceivingRemoteControlEvents() + try! AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback) return true } @@ -45,17 +46,22 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. } - // MARK: - Split view +} - func splitViewController(splitViewController: UISplitViewController, collapseSecondaryViewController secondaryViewController:UIViewController, ontoPrimaryViewController primaryViewController:UIViewController) -> Bool { - guard let secondaryAsNavController = secondaryViewController as? UINavigationController else { return false } - guard let topAsDetailController = secondaryAsNavController.topViewController as? DetailViewController else { return false } - if topAsDetailController.detailItem == nil { - // Return true to indicate that we have handled the collapse by doing nothing; the secondary controller will be discarded. - return true - } - return false +extension UIViewController { + func showAlert(title: String?, message: String?, style: UIAlertControllerStyle) { + let alert = UIAlertController(title: title, message: message, preferredStyle: style) + let okButton = UIAlertAction(title: "Ok", style: .Default, handler: nil) + + alert.addAction(okButton) + + self.presentViewController(alert, animated: true, completion: nil) } +} +extension UINavigationController { + override public func preferredStatusBarStyle() -> UIStatusBarStyle { + return .LightContent + } } diff --git a/Audiobook Player/Assets.xcassets/AppIcon.appiconset/Contents.json b/Audiobook Player/Assets.xcassets/AppIcon.appiconset/Contents.json index 36d2c80d8..4943e836c 100644 --- a/Audiobook Player/Assets.xcassets/AppIcon.appiconset/Contents.json +++ b/Audiobook Player/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -1,63 +1,81 @@ { "images" : [ { - "idiom" : "iphone", "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-Small@2x.png", "scale" : "2x" }, { - "idiom" : "iphone", "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-Small@3x.png", "scale" : "3x" }, { - "idiom" : "iphone", "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-Small-40@2x.png", "scale" : "2x" }, { - "idiom" : "iphone", "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-Small-40@3x.png", "scale" : "3x" }, { - "idiom" : "iphone", "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-60@2x.png", "scale" : "2x" }, { - "idiom" : "iphone", "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-60@3x.png", "scale" : "3x" }, { - "idiom" : "ipad", "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-Small.png", "scale" : "1x" }, { - "idiom" : "ipad", "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-Small@2x-1.png", "scale" : "2x" }, { - "idiom" : "ipad", "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-Small-40.png", "scale" : "1x" }, { - "idiom" : "ipad", "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-Small-40@2x-1.png", "scale" : "2x" }, { - "idiom" : "ipad", "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-76.png", "scale" : "1x" }, { - "idiom" : "ipad", "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-76@2x.png", + "scale" : "2x" + }, + { + "size" : "83.5x83.5", + "idiom" : "ipad", + "filename" : "Icon-167.png", "scale" : "2x" } ], diff --git a/Audiobook Player/Assets.xcassets/AppIcon.appiconset/Icon-167.png b/Audiobook Player/Assets.xcassets/AppIcon.appiconset/Icon-167.png new file mode 100644 index 000000000..3cff51317 Binary files /dev/null and b/Audiobook Player/Assets.xcassets/AppIcon.appiconset/Icon-167.png differ diff --git a/Audiobook Player/Assets.xcassets/AppIcon.appiconset/Icon-60@2x.png b/Audiobook Player/Assets.xcassets/AppIcon.appiconset/Icon-60@2x.png new file mode 100644 index 000000000..9d27c49f5 Binary files /dev/null and b/Audiobook Player/Assets.xcassets/AppIcon.appiconset/Icon-60@2x.png differ diff --git a/Audiobook Player/Assets.xcassets/AppIcon.appiconset/Icon-60@3x.png b/Audiobook Player/Assets.xcassets/AppIcon.appiconset/Icon-60@3x.png new file mode 100644 index 000000000..d7d753376 Binary files /dev/null and b/Audiobook Player/Assets.xcassets/AppIcon.appiconset/Icon-60@3x.png differ diff --git a/Audiobook Player/Assets.xcassets/AppIcon.appiconset/Icon-76.png b/Audiobook Player/Assets.xcassets/AppIcon.appiconset/Icon-76.png new file mode 100644 index 000000000..503666407 Binary files /dev/null and b/Audiobook Player/Assets.xcassets/AppIcon.appiconset/Icon-76.png differ diff --git a/Audiobook Player/Assets.xcassets/AppIcon.appiconset/Icon-76@2x.png b/Audiobook Player/Assets.xcassets/AppIcon.appiconset/Icon-76@2x.png new file mode 100644 index 000000000..ec227cc40 Binary files /dev/null and b/Audiobook Player/Assets.xcassets/AppIcon.appiconset/Icon-76@2x.png differ diff --git a/Audiobook Player/Assets.xcassets/AppIcon.appiconset/Icon-Small-40.png b/Audiobook Player/Assets.xcassets/AppIcon.appiconset/Icon-Small-40.png new file mode 100644 index 000000000..deea5ed53 Binary files /dev/null and b/Audiobook Player/Assets.xcassets/AppIcon.appiconset/Icon-Small-40.png differ diff --git a/Audiobook Player/Assets.xcassets/AppIcon.appiconset/Icon-Small-40@2x-1.png b/Audiobook Player/Assets.xcassets/AppIcon.appiconset/Icon-Small-40@2x-1.png new file mode 100644 index 000000000..808daf1da Binary files /dev/null and b/Audiobook Player/Assets.xcassets/AppIcon.appiconset/Icon-Small-40@2x-1.png differ diff --git a/Audiobook Player/Assets.xcassets/AppIcon.appiconset/Icon-Small-40@2x.png b/Audiobook Player/Assets.xcassets/AppIcon.appiconset/Icon-Small-40@2x.png new file mode 100644 index 000000000..808daf1da Binary files /dev/null and b/Audiobook Player/Assets.xcassets/AppIcon.appiconset/Icon-Small-40@2x.png differ diff --git a/Audiobook Player/Assets.xcassets/AppIcon.appiconset/Icon-Small-40@3x.png b/Audiobook Player/Assets.xcassets/AppIcon.appiconset/Icon-Small-40@3x.png new file mode 100644 index 000000000..dcf465373 Binary files /dev/null and b/Audiobook Player/Assets.xcassets/AppIcon.appiconset/Icon-Small-40@3x.png differ diff --git a/Audiobook Player/Assets.xcassets/AppIcon.appiconset/Icon-Small.png b/Audiobook Player/Assets.xcassets/AppIcon.appiconset/Icon-Small.png new file mode 100644 index 000000000..60baa623c Binary files /dev/null and b/Audiobook Player/Assets.xcassets/AppIcon.appiconset/Icon-Small.png differ diff --git a/Audiobook Player/Assets.xcassets/AppIcon.appiconset/Icon-Small@2x-1.png b/Audiobook Player/Assets.xcassets/AppIcon.appiconset/Icon-Small@2x-1.png new file mode 100644 index 000000000..37526af12 Binary files /dev/null and b/Audiobook Player/Assets.xcassets/AppIcon.appiconset/Icon-Small@2x-1.png differ diff --git a/Audiobook Player/Assets.xcassets/AppIcon.appiconset/Icon-Small@2x.png b/Audiobook Player/Assets.xcassets/AppIcon.appiconset/Icon-Small@2x.png new file mode 100644 index 000000000..37526af12 Binary files /dev/null and b/Audiobook Player/Assets.xcassets/AppIcon.appiconset/Icon-Small@2x.png differ diff --git a/Audiobook Player/Assets.xcassets/AppIcon.appiconset/Icon-Small@3x.png b/Audiobook Player/Assets.xcassets/AppIcon.appiconset/Icon-Small@3x.png new file mode 100644 index 000000000..61b89d7b6 Binary files /dev/null and b/Audiobook Player/Assets.xcassets/AppIcon.appiconset/Icon-Small@3x.png differ diff --git a/Audiobook Player/Assets.xcassets/Contents.json b/Audiobook Player/Assets.xcassets/Contents.json new file mode 100644 index 000000000..da4a164c9 --- /dev/null +++ b/Audiobook Player/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Audiobook Player/Assets.xcassets/forwardButton.imageset/Contents.json b/Audiobook Player/Assets.xcassets/forwardButton.imageset/Contents.json new file mode 100644 index 000000000..b2b73d889 --- /dev/null +++ b/Audiobook Player/Assets.xcassets/forwardButton.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "forwardButton.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "forwardButton@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "forwardButton@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Audiobook Player/Assets.xcassets/forwardButton.imageset/forwardButton.png b/Audiobook Player/Assets.xcassets/forwardButton.imageset/forwardButton.png new file mode 100644 index 000000000..7e9677a22 Binary files /dev/null and b/Audiobook Player/Assets.xcassets/forwardButton.imageset/forwardButton.png differ diff --git a/Audiobook Player/Assets.xcassets/forwardButton.imageset/forwardButton@2x.png b/Audiobook Player/Assets.xcassets/forwardButton.imageset/forwardButton@2x.png new file mode 100644 index 000000000..4dcce845b Binary files /dev/null and b/Audiobook Player/Assets.xcassets/forwardButton.imageset/forwardButton@2x.png differ diff --git a/Audiobook Player/Assets.xcassets/forwardButton.imageset/forwardButton@3x.png b/Audiobook Player/Assets.xcassets/forwardButton.imageset/forwardButton@3x.png new file mode 100644 index 000000000..d89fc7601 Binary files /dev/null and b/Audiobook Player/Assets.xcassets/forwardButton.imageset/forwardButton@3x.png differ diff --git a/Audiobook Player/Assets.xcassets/miniPauseButton.imageset/Contents.json b/Audiobook Player/Assets.xcassets/miniPauseButton.imageset/Contents.json new file mode 100644 index 000000000..9b729638d --- /dev/null +++ b/Audiobook Player/Assets.xcassets/miniPauseButton.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "miniPauseButton.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "miniPauseButton@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "miniPauseButton@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Audiobook Player/Assets.xcassets/miniPauseButton.imageset/miniPauseButton.png b/Audiobook Player/Assets.xcassets/miniPauseButton.imageset/miniPauseButton.png new file mode 100644 index 000000000..8cd482c7a Binary files /dev/null and b/Audiobook Player/Assets.xcassets/miniPauseButton.imageset/miniPauseButton.png differ diff --git a/Audiobook Player/Assets.xcassets/miniPauseButton.imageset/miniPauseButton@2x.png b/Audiobook Player/Assets.xcassets/miniPauseButton.imageset/miniPauseButton@2x.png new file mode 100644 index 000000000..8c31a2728 Binary files /dev/null and b/Audiobook Player/Assets.xcassets/miniPauseButton.imageset/miniPauseButton@2x.png differ diff --git a/Audiobook Player/Assets.xcassets/miniPauseButton.imageset/miniPauseButton@3x.png b/Audiobook Player/Assets.xcassets/miniPauseButton.imageset/miniPauseButton@3x.png new file mode 100644 index 000000000..a8f220457 Binary files /dev/null and b/Audiobook Player/Assets.xcassets/miniPauseButton.imageset/miniPauseButton@3x.png differ diff --git a/Audiobook Player/Assets.xcassets/miniPlayButton.imageset/Contents.json b/Audiobook Player/Assets.xcassets/miniPlayButton.imageset/Contents.json new file mode 100644 index 000000000..3f2277fc0 --- /dev/null +++ b/Audiobook Player/Assets.xcassets/miniPlayButton.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "miniPlayButton.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "miniPlayButton@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "miniPlayButton@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Audiobook Player/Assets.xcassets/miniPlayButton.imageset/miniPlayButton.png b/Audiobook Player/Assets.xcassets/miniPlayButton.imageset/miniPlayButton.png new file mode 100644 index 000000000..79fc25f55 Binary files /dev/null and b/Audiobook Player/Assets.xcassets/miniPlayButton.imageset/miniPlayButton.png differ diff --git a/Audiobook Player/Assets.xcassets/miniPlayButton.imageset/miniPlayButton@2x.png b/Audiobook Player/Assets.xcassets/miniPlayButton.imageset/miniPlayButton@2x.png new file mode 100644 index 000000000..8462d044f Binary files /dev/null and b/Audiobook Player/Assets.xcassets/miniPlayButton.imageset/miniPlayButton@2x.png differ diff --git a/Audiobook Player/Assets.xcassets/miniPlayButton.imageset/miniPlayButton@3x.png b/Audiobook Player/Assets.xcassets/miniPlayButton.imageset/miniPlayButton@3x.png new file mode 100644 index 000000000..a859c150c Binary files /dev/null and b/Audiobook Player/Assets.xcassets/miniPlayButton.imageset/miniPlayButton@3x.png differ diff --git a/Audiobook Player/Assets.xcassets/pauseButton.imageset/Contents.json b/Audiobook Player/Assets.xcassets/pauseButton.imageset/Contents.json new file mode 100644 index 000000000..9d5fb01e8 --- /dev/null +++ b/Audiobook Player/Assets.xcassets/pauseButton.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "pauseButton.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "pauseButton@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "pauseButton@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Audiobook Player/Assets.xcassets/pauseButton.imageset/pauseButton.png b/Audiobook Player/Assets.xcassets/pauseButton.imageset/pauseButton.png new file mode 100644 index 000000000..675db6522 Binary files /dev/null and b/Audiobook Player/Assets.xcassets/pauseButton.imageset/pauseButton.png differ diff --git a/Audiobook Player/Assets.xcassets/pauseButton.imageset/pauseButton@2x.png b/Audiobook Player/Assets.xcassets/pauseButton.imageset/pauseButton@2x.png new file mode 100644 index 000000000..8800435c0 Binary files /dev/null and b/Audiobook Player/Assets.xcassets/pauseButton.imageset/pauseButton@2x.png differ diff --git a/Audiobook Player/Assets.xcassets/pauseButton.imageset/pauseButton@3x.png b/Audiobook Player/Assets.xcassets/pauseButton.imageset/pauseButton@3x.png new file mode 100644 index 000000000..a7d95332b Binary files /dev/null and b/Audiobook Player/Assets.xcassets/pauseButton.imageset/pauseButton@3x.png differ diff --git a/Audiobook Player/Assets.xcassets/playButton.imageset/Contents.json b/Audiobook Player/Assets.xcassets/playButton.imageset/Contents.json new file mode 100644 index 000000000..8489827aa --- /dev/null +++ b/Audiobook Player/Assets.xcassets/playButton.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "playButton.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "playButton@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "playButton@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Audiobook Player/Assets.xcassets/playButton.imageset/playButton.png b/Audiobook Player/Assets.xcassets/playButton.imageset/playButton.png new file mode 100644 index 000000000..0acbd2e22 Binary files /dev/null and b/Audiobook Player/Assets.xcassets/playButton.imageset/playButton.png differ diff --git a/Audiobook Player/Assets.xcassets/playButton.imageset/playButton@2x.png b/Audiobook Player/Assets.xcassets/playButton.imageset/playButton@2x.png new file mode 100644 index 000000000..8cf5755da Binary files /dev/null and b/Audiobook Player/Assets.xcassets/playButton.imageset/playButton@2x.png differ diff --git a/Audiobook Player/Assets.xcassets/playButton.imageset/playButton@3x.png b/Audiobook Player/Assets.xcassets/playButton.imageset/playButton@3x.png new file mode 100644 index 000000000..2da8f09ac Binary files /dev/null and b/Audiobook Player/Assets.xcassets/playButton.imageset/playButton@3x.png differ diff --git a/Audiobook Player/Assets.xcassets/rewindButton.imageset/Contents.json b/Audiobook Player/Assets.xcassets/rewindButton.imageset/Contents.json new file mode 100644 index 000000000..e73dff889 --- /dev/null +++ b/Audiobook Player/Assets.xcassets/rewindButton.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "rewindButton.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "rewindButton@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "rewindButton@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Audiobook Player/Assets.xcassets/rewindButton.imageset/rewindButton.png b/Audiobook Player/Assets.xcassets/rewindButton.imageset/rewindButton.png new file mode 100644 index 000000000..ff93b08c3 Binary files /dev/null and b/Audiobook Player/Assets.xcassets/rewindButton.imageset/rewindButton.png differ diff --git a/Audiobook Player/Assets.xcassets/rewindButton.imageset/rewindButton@2x.png b/Audiobook Player/Assets.xcassets/rewindButton.imageset/rewindButton@2x.png new file mode 100644 index 000000000..b1f6a98ad Binary files /dev/null and b/Audiobook Player/Assets.xcassets/rewindButton.imageset/rewindButton@2x.png differ diff --git a/Audiobook Player/Assets.xcassets/rewindButton.imageset/rewindButton@3x.png b/Audiobook Player/Assets.xcassets/rewindButton.imageset/rewindButton@3x.png new file mode 100644 index 000000000..b2bfc8091 Binary files /dev/null and b/Audiobook Player/Assets.xcassets/rewindButton.imageset/rewindButton@3x.png differ diff --git a/Audiobook Player/Assets.xcassets/right-arrow.imageset/Contents.json b/Audiobook Player/Assets.xcassets/right-arrow.imageset/Contents.json new file mode 100644 index 000000000..dee67ceae --- /dev/null +++ b/Audiobook Player/Assets.xcassets/right-arrow.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "right-arrow.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "right-arrow@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "right-arrow@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Audiobook Player/Assets.xcassets/right-arrow.imageset/right-arrow.png b/Audiobook Player/Assets.xcassets/right-arrow.imageset/right-arrow.png new file mode 100644 index 000000000..af9377999 Binary files /dev/null and b/Audiobook Player/Assets.xcassets/right-arrow.imageset/right-arrow.png differ diff --git a/Audiobook Player/Assets.xcassets/right-arrow.imageset/right-arrow@2x.png b/Audiobook Player/Assets.xcassets/right-arrow.imageset/right-arrow@2x.png new file mode 100644 index 000000000..2e532ff6a Binary files /dev/null and b/Audiobook Player/Assets.xcassets/right-arrow.imageset/right-arrow@2x.png differ diff --git a/Audiobook Player/Assets.xcassets/right-arrow.imageset/right-arrow@3x.png b/Audiobook Player/Assets.xcassets/right-arrow.imageset/right-arrow@3x.png new file mode 100644 index 000000000..060f06815 Binary files /dev/null and b/Audiobook Player/Assets.xcassets/right-arrow.imageset/right-arrow@3x.png differ diff --git a/Audiobook Player/Base.lproj/LaunchScreen.storyboard b/Audiobook Player/Base.lproj/LaunchScreen.storyboard index 2e721e183..90e200d9d 100644 --- a/Audiobook Player/Base.lproj/LaunchScreen.storyboard +++ b/Audiobook Player/Base.lproj/LaunchScreen.storyboard @@ -1,7 +1,8 @@ - + - + + @@ -15,9 +16,26 @@ - + + + + + + + + + + + + + + + + + + diff --git a/Audiobook Player/Base.lproj/Main.storyboard b/Audiobook Player/Base.lproj/Main.storyboard index b3b5a7877..ca52bbed8 100644 --- a/Audiobook Player/Base.lproj/Main.storyboard +++ b/Audiobook Player/Base.lproj/Main.storyboard @@ -1,135 +1,454 @@ - + - + + + - - + + - - + + + + + + + + + - + - + - + - - + + - + - - + + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + - - - + + + + + + + + + + + + + + + + + + + - - + + + + + + + + - + + + + + + + + - - - - - - - - - - - - - - - + - + - - + + - - + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + - - + + - + - - - + + + + + + + diff --git a/Audiobook Player/DetailViewController.swift b/Audiobook Player/DetailViewController.swift deleted file mode 100644 index 8653d2343..000000000 --- a/Audiobook Player/DetailViewController.swift +++ /dev/null @@ -1,45 +0,0 @@ -// -// DetailViewController.swift -// Audiobook Player -// -// Created by Gianni Carlo on 7/1/16. -// Copyright © 2016 Tortuga Power. All rights reserved. -// - -import UIKit - -class DetailViewController: UIViewController { - - @IBOutlet weak var detailDescriptionLabel: UILabel! - - - var detailItem: AnyObject? { - didSet { - // Update the view. - self.configureView() - } - } - - func configureView() { - // Update the user interface for the detail item. - if let detail = self.detailItem { - if let label = self.detailDescriptionLabel { - label.text = detail.description - } - } - } - - override func viewDidLoad() { - super.viewDidLoad() - // Do any additional setup after loading the view, typically from a nib. - self.configureView() - } - - override func didReceiveMemoryWarning() { - super.didReceiveMemoryWarning() - // Dispose of any resources that can be recreated. - } - - -} - diff --git a/Audiobook Player/Info.plist b/Audiobook Player/Info.plist index fd1ab7c38..0b9cd0ce7 100644 --- a/Audiobook Player/Info.plist +++ b/Audiobook Player/Info.plist @@ -11,7 +11,7 @@ CFBundleInfoDictionaryVersion 6.0 CFBundleName - $(PRODUCT_NAME) + BookPlayer CFBundlePackageType APPL CFBundleShortVersionString @@ -22,6 +22,12 @@ 1 LSRequiresIPhoneOS + UIBackgroundModes + + audio + + UIFileSharingEnabled + UILaunchStoryboardName LaunchScreen UIMainStoryboardFile diff --git a/Audiobook Player/ListBooksViewController.swift b/Audiobook Player/ListBooksViewController.swift new file mode 100644 index 000000000..e02a1db89 --- /dev/null +++ b/Audiobook Player/ListBooksViewController.swift @@ -0,0 +1,305 @@ +// +// ListBooksViewController.swift +// Audiobook Player +// +// Created by Gianni Carlo on 7/7/16. +// Copyright © 2016 Tortuga Power. All rights reserved. +// + +import UIKit +import AVFoundation +import MediaPlayer +import Chameleon + +class ListBooksViewController: UIViewController, UIGestureRecognizerDelegate { + + @IBOutlet weak var emptyListContainerView: UIView! + + @IBOutlet weak var tableView: UITableView! + @IBOutlet weak var footerView: UIView! + @IBOutlet weak var footerImageView: UIImageView! + @IBOutlet weak var footerTitleLabel: UILabel! + @IBOutlet weak var footerHeightConstraint: NSLayoutConstraint! + @IBOutlet weak var footerPlayButton: UIButton! + + let miniPlayImage = UIImage(named: "miniPlayButton") + let miniPauseButton = UIImage(named: "miniPauseButton") + + var playerViewController:PlayerViewController! + var listBooks:[String] = [] + var itemArray:[AVPlayerItem] = [] + var urlArray:[NSURL] = [] + let documentsPath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true).first! + + override func viewDidLoad() { + super.viewDidLoad() + + //enables pop gesture on pushed controller + self.navigationController!.interactivePopGestureRecognizer!.delegate = self + + //fixed tableview having strange offset + self.edgesForExtendedLayout = UIRectEdge.None + + //set colors + self.navigationController?.navigationBar.barTintColor = UIColor.flatSkyBlueColor() + self.footerView.backgroundColor = UIColor.flatSkyBlueColor() + + self.tableView.tableFooterView = UIView() + + //set external control listeners + let skipForward = MPRemoteCommandCenter.sharedCommandCenter().skipForwardCommand + skipForward.enabled = true + skipForward.addTarget(self, action: #selector(self.forwardPressed(_:))) + skipForward.preferredIntervals = [30] + + let skipRewind = MPRemoteCommandCenter.sharedCommandCenter().skipBackwardCommand + skipRewind.enabled = true + skipRewind.addTarget(self, action: #selector(self.rewindPressed(_:))) + skipRewind.preferredIntervals = [30] + + let playCommand = MPRemoteCommandCenter.sharedCommandCenter().playCommand + playCommand.enabled = true + playCommand.addTarget(self, action: #selector(self.didPressPlay(_:))) + + let pauseCommand = MPRemoteCommandCenter.sharedCommandCenter().pauseCommand + pauseCommand.enabled = true + pauseCommand.addTarget(self, action: #selector(self.didPressPlay(_:))) + + //set tap handler to show detail on tap on footer view + let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(self.didPressShowDetail(_:))) + self.footerView.addGestureRecognizer(tapRecognizer) + + //load local files + self.loadFiles() + } + + override func viewWillAppear(animated: Bool) { + super.viewWillAppear(animated) + + //show navigation bar for this controller + self.navigationController?.setNavigationBarHidden(false, animated: true) + + //check if audiobook is loaded + if self.playerViewController == nil { + self.footerHeightConstraint.constant = 0 + return + } + + //resize footer view + self.footerHeightConstraint.constant = 55 + + self.setPlayImage() + + //reload cell to show percentage label + guard let index = self.tableView.indexPathForSelectedRow else { + return + } + + self.tableView.reloadRowsAtIndexPaths([index], withRowAnimation: .Automatic) + } + + /** + Load local files and process them (rename them if necessary) + */ + func loadFiles() { + self.itemArray = [] + self.urlArray = [] + + let fileEnumerator = NSFileManager.defaultManager().enumeratorAtPath(self.documentsPath)! + + for filename in fileEnumerator { + var finalPath = self.documentsPath+"/"+(filename as! String) + + var originalURL:NSURL? + + if finalPath.containsString(" ") { + originalURL = NSURL(fileURLWithPath: finalPath) + finalPath = finalPath.stringByReplacingOccurrencesOfString(" ", withString: "_") + } + + let fileURL = NSURL(fileURLWithPath: finalPath.stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.URLQueryAllowedCharacterSet())!) + + if let original = originalURL { + try! NSFileManager.defaultManager().moveItemAtURL(original, toURL: fileURL) + } + + self.itemArray.append(AVPlayerItem(URL: fileURL)) + self.urlArray.append(fileURL) + } + + self.emptyListContainerView.hidden = self.itemArray.count > 0 ? true : false + + self.tableView.reloadData() + } + + /** + Set play or pause image on button + */ + func setPlayImage(){ + if self.playerViewController.audioPlayer == nil { + self.footerPlayButton.setImage(self.miniPlayImage, forState: .Normal) + return + } + + if self.playerViewController.audioPlayer.playing { + self.footerPlayButton.setImage(self.miniPauseButton, forState: .Normal) + }else{ + self.footerPlayButton.setImage(self.miniPlayImage, forState: .Normal) + } + } + + override func prefersStatusBarHidden() -> Bool { + return false + } + + func gestureRecognizerShouldBegin(gestureRecognizer: UIGestureRecognizer) -> Bool { + if(navigationController!.viewControllers.count > 1){ + return true + } + return false + } + @IBAction func didPressReload(sender: UIBarButtonItem) { + self.loadFiles() + } + + @IBAction func didPressPlay(sender: UIButton) { + //check if audiobook is loaded + if self.playerViewController == nil { + return + } + + self.playerViewController.playPressed(self.playerViewController.playButton) + + self.setPlayImage() + } + + func forwardPressed(sender: UIButton) { + //check if audiobook is loaded + if self.playerViewController == nil { + return + } + + self.playerViewController.forwardPressed(sender) + } + + func rewindPressed(sender: UIButton) { + //check if audiobook is loaded + if self.playerViewController == nil { + return + } + + self.playerViewController.rewindPressed(sender) + } + + @IBAction func didPressShowDetail(sender: UIButton) { + self.navigationController?.showViewController(self.playerViewController, sender: self) + } +} + +extension ListBooksViewController: UITableViewDataSource { + func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return self.itemArray.count + } + + func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { + let cell = tableView.dequeueReusableCellWithIdentifier("BookCellView", forIndexPath: indexPath) as! BookCellView + + let item = self.itemArray[indexPath.row] + + cell.titleLabel.text = AVMetadataItem.metadataItemsFromArray(item.asset.metadata, withKey: AVMetadataCommonKeyTitle, keySpace: AVMetadataKeySpaceCommon).first?.value?.copyWithZone(nil) as? String + cell.titleLabel.highlightedTextColor = UIColor.blackColor() + + cell.authorLabel.text = AVMetadataItem.metadataItemsFromArray(item.asset.metadata, withKey: AVMetadataCommonKeyArtist, keySpace: AVMetadataKeySpaceCommon).first?.value?.copyWithZone(nil) as? String + + let artwork = AVMetadataItem.metadataItemsFromArray(item.asset.metadata, withKey: AVMetadataCommonKeyArtwork, keySpace: AVMetadataKeySpaceCommon).first?.value?.copyWithZone(nil) as! NSData + + cell.artworkImageView.image = UIImage(data: artwork) ?? UIImage() + + let title = cell.titleLabel.text?.stringByReplacingOccurrencesOfString(" ", withString: "_") ?? "defaulttitle" + let author = cell.authorLabel.text?.stringByReplacingOccurrencesOfString(" ", withString: "_") ?? "defaultauthor" + print(title+author) + print(NSUserDefaults.standardUserDefaults().stringForKey(title+author+"_percentage")) + cell.completionLabel.text = NSUserDefaults.standardUserDefaults().stringForKey(title+author+"_percentage") ?? "0%" + cell.completionLabel.textColor = UIColor.flatGreenColorDark() + + return cell + } +} + +extension ListBooksViewController: UITableViewDelegate { + func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool { + return true + } + + func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? { + + let deleteAction = UITableViewRowAction(style: .Default, title: "Delete") { (action, indexPath) in + self.itemArray.removeAtIndex(indexPath.row) + let url = self.urlArray.removeAtIndex(indexPath.row) + try! NSFileManager.defaultManager().removeItemAtURL(url) + tableView.beginUpdates() + tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .None) + tableView.endUpdates() + + self.emptyListContainerView.hidden = self.itemArray.count > 0 ? true : false + } + + deleteAction.backgroundColor = UIColor.redColor() + + return [deleteAction] + } + + func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) { + } + func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat { + return 86 + } + + func tableView(tableView: UITableView, willSelectRowAtIndexPath indexPath: NSIndexPath) -> NSIndexPath? { + guard let index = tableView.indexPathForSelectedRow else { + return indexPath + } + + tableView.deselectRowAtIndexPath(index, animated: true) + + return indexPath + } + + func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { + + let item = self.itemArray[indexPath.row] + + //stop audiobook if it's playing + if self.playerViewController != nil && + self.playerViewController.playerItem != item && + self.playerViewController.audioPlayer.playing { + self.playerViewController.audioPlayer.stop() + } + + //load default player if there's not + if self.playerViewController == nil || self.playerViewController.playerItem != item{ + let cell = tableView.cellForRowAtIndexPath(indexPath) as! BookCellView + + let storyboard = UIStoryboard(name: "Main", bundle: nil) + self.playerViewController = storyboard.instantiateViewControllerWithIdentifier("PlayerViewController") as! PlayerViewController + + self.playerViewController.playerItem = item + + let url = self.urlArray[indexPath.row] + self.playerViewController.fileURL = url + + self.footerTitleLabel.text = cell.titleLabel.text! + " - " + cell.authorLabel.text! + self.footerImageView.image = cell.artworkImageView.image + } + + self.navigationController?.pushViewController(self.playerViewController, animated: true) + } +} + +class BookCellView: UITableViewCell { + @IBOutlet weak var artworkImageView: UIImageView! + @IBOutlet weak var titleLabel: UILabel! + @IBOutlet weak var authorLabel: UILabel! + @IBOutlet weak var completionLabel: UILabel! + +} \ No newline at end of file diff --git a/Audiobook Player/MasterViewController.swift b/Audiobook Player/MasterViewController.swift deleted file mode 100644 index 9d07ae04f..000000000 --- a/Audiobook Player/MasterViewController.swift +++ /dev/null @@ -1,94 +0,0 @@ -// -// MasterViewController.swift -// Audiobook Player -// -// Created by Gianni Carlo on 7/1/16. -// Copyright © 2016 Tortuga Power. All rights reserved. -// - -import UIKit - -class MasterViewController: UITableViewController { - - var detailViewController: DetailViewController? = nil - var objects = [AnyObject]() - - - override func viewDidLoad() { - super.viewDidLoad() - // Do any additional setup after loading the view, typically from a nib. - self.navigationItem.leftBarButtonItem = self.editButtonItem() - - let addButton = UIBarButtonItem(barButtonSystemItem: .Add, target: self, action: "insertNewObject:") - self.navigationItem.rightBarButtonItem = addButton - if let split = self.splitViewController { - let controllers = split.viewControllers - self.detailViewController = (controllers[controllers.count-1] as! UINavigationController).topViewController as? DetailViewController - } - } - - override func viewWillAppear(animated: Bool) { - self.clearsSelectionOnViewWillAppear = self.splitViewController!.collapsed - super.viewWillAppear(animated) - } - - override func didReceiveMemoryWarning() { - super.didReceiveMemoryWarning() - // Dispose of any resources that can be recreated. - } - - func insertNewObject(sender: AnyObject) { - objects.insert(NSDate(), atIndex: 0) - let indexPath = NSIndexPath(forRow: 0, inSection: 0) - self.tableView.insertRowsAtIndexPaths([indexPath], withRowAnimation: .Automatic) - } - - // MARK: - Segues - - override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { - if segue.identifier == "showDetail" { - if let indexPath = self.tableView.indexPathForSelectedRow { - let object = objects[indexPath.row] as! NSDate - let controller = (segue.destinationViewController as! UINavigationController).topViewController as! DetailViewController - controller.detailItem = object - controller.navigationItem.leftBarButtonItem = self.splitViewController?.displayModeButtonItem() - controller.navigationItem.leftItemsSupplementBackButton = true - } - } - } - - // MARK: - Table View - - override func numberOfSectionsInTableView(tableView: UITableView) -> Int { - return 1 - } - - override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - return objects.count - } - - override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { - let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) - - let object = objects[indexPath.row] as! NSDate - cell.textLabel!.text = object.description - return cell - } - - override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool { - // Return false if you do not want the specified item to be editable. - return true - } - - override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) { - if editingStyle == .Delete { - objects.removeAtIndex(indexPath.row) - tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade) - } else if editingStyle == .Insert { - // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view. - } - } - - -} - diff --git a/Audiobook Player/PlayerViewController.swift b/Audiobook Player/PlayerViewController.swift new file mode 100644 index 000000000..c48cfe652 --- /dev/null +++ b/Audiobook Player/PlayerViewController.swift @@ -0,0 +1,241 @@ +// +// PlayerViewController.swift +// Audiobook Player +// +// Created by Gianni Carlo on 7/5/16. +// Copyright © 2016 Tortuga Power. All rights reserved. +// + +import UIKit +import AVFoundation +import MediaPlayer +import Chameleon +import MBProgressHUD + +class PlayerViewController: UIViewController { + @IBOutlet weak var authorLabel: UILabel! + @IBOutlet weak var titleLabel: UILabel! + + @IBOutlet weak var playButton: UIButton! + @IBOutlet weak var forwardButton: UIButton! + @IBOutlet weak var rewindButton: UIButton! + + @IBOutlet weak var maxTimeLabel: UILabel! + @IBOutlet weak var currentTimeLabel: UILabel! + + @IBOutlet weak var timeSeparator: UILabel! + var audioPlayer:AVAudioPlayer! + + @IBOutlet weak var leftVerticalView: UIView! + @IBOutlet weak var sliderView: UISlider! + + @IBOutlet weak var percentageLabel: UILabel! +// var completionPercentage + + + let documentsPath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true).first! + var namesArray:[String]! + var fileURL:NSURL! + + let playImage = UIImage(named: "playButton") + let pauseImage = UIImage(named: "pauseButton") + + var playerItem:AVPlayerItem! + var timer:NSTimer! + + var identifier:String! + + override func viewDidLoad() { + super.viewDidLoad() + + //set UI colors + let colors:[UIColor] = [ + UIColor.flatGrayColorDark(), + UIColor.flatSkyBlueColorDark() + ] + self.view.backgroundColor = GradientColor(.Radial, frame: view.frame, colors: colors) + self.leftVerticalView.backgroundColor = UIColor.flatRedColor() + self.maxTimeLabel.textColor = UIColor.flatWhiteColorDark() + self.authorLabel.textColor = UIColor.flatWhiteColorDark() + self.timeSeparator.textColor = UIColor.flatWhiteColorDark() + + self.setStatusBarStyle(UIStatusBarStyleContrast) + + //load book metadata + self.titleLabel.text = AVMetadataItem.metadataItemsFromArray(self.playerItem.asset.metadata, withKey: AVMetadataCommonKeyTitle, keySpace: AVMetadataKeySpaceCommon).first?.value?.copyWithZone(nil) as? String + + self.authorLabel.text = AVMetadataItem.metadataItemsFromArray(self.playerItem.asset.metadata, withKey: AVMetadataCommonKeyArtist, keySpace: AVMetadataKeySpaceCommon).first?.value?.copyWithZone(nil) as? String + + let artwork = AVMetadataItem.metadataItemsFromArray(self.playerItem.asset.metadata, withKey: AVMetadataCommonKeyArtwork, keySpace: AVMetadataKeySpaceCommon).first?.value?.copyWithZone(nil) as! NSData + + let title = self.titleLabel.text?.stringByReplacingOccurrencesOfString(" ", withString: "_") ?? "defaulttitle" + let author = self.authorLabel.text?.stringByReplacingOccurrencesOfString(" ", withString: "_") ?? "defaultauthor" + + self.identifier = title+author + + //set initial state for slider + self.sliderView.setThumbImage(UIImage(), forState: .Normal) + self.sliderView.tintColor = UIColor.flatLimeColorDark() + self.sliderView.maximumValue = 100 + self.sliderView.value = 0 + + let currentPercentage = NSUserDefaults.standardUserDefaults().stringForKey(self.identifier+"_percentage") ?? "0%" + self.percentageLabel.text = currentPercentage + + MBProgressHUD.showHUDAddedTo(self.view, animated: true) + + //load data on background thread + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) { + + let mediaArtwork = MPMediaItemArtwork(image: UIImage(data: artwork) ?? UIImage()) + + //try fetching the data of the book + guard let data = NSFileManager.defaultManager().contentsAtPath(self.fileURL.path!) else { + //do something + dispatch_async(dispatch_get_main_queue(), { + MBProgressHUD.hideHUDForView(self.view, animated: true) + self.showAlert(nil, message: "Problem loading mp3 data", style: .Alert) + }) + + return + } + + //try loading the player + do{ + try self.audioPlayer = AVAudioPlayer(data: data) + } catch { + //do something + dispatch_async(dispatch_get_main_queue(), { + MBProgressHUD.hideHUDForView(self.view, animated: true) + self.showAlert(nil, message: "Problem loading player", style: .Alert) + }) + return + } + + //update ui on main queue + dispatch_async(dispatch_get_main_queue(), { + + MPNowPlayingInfoCenter.defaultCenter().nowPlayingInfo = [ + MPMediaItemPropertyTitle: self.titleLabel.text!, + MPMediaItemPropertyArtist: self.authorLabel.text!, + MPMediaItemPropertyPlaybackDuration: self.audioPlayer.duration, + MPMediaItemPropertyArtwork: mediaArtwork + ] + + let currentTime = NSUserDefaults.standardUserDefaults().integerForKey(self.identifier) + + if currentTime > 0 { + let formattedCurrentTime = self.formatTime(currentTime) + self.currentTimeLabel.text = formattedCurrentTime + + self.audioPlayer.currentTime = NSTimeInterval(currentTime) + } + + let maxDuration = Int(self.audioPlayer.duration) + self.maxTimeLabel.text = self.formatTime(maxDuration) + + //play audio automatically + if let rootVC = self.navigationController?.viewControllers.first as? ListBooksViewController { + rootVC.didPressPlay(self.playButton) + } + + MBProgressHUD.hideHUDForView(self.view, animated: true) + }) + } + } + + override func viewWillAppear(animated: Bool) { + super.viewWillAppear(animated) + self.navigationController?.setNavigationBarHidden(true, animated: true) + } + + override func prefersStatusBarHidden() -> Bool { + return true + } + + override func preferredStatusBarUpdateAnimation() -> UIStatusBarAnimation { + return .Slide + } +} + +extension PlayerViewController { + + @IBAction func forwardPressed(sender: UIButton) { + let time = self.audioPlayer.currentTime + self.audioPlayer.currentTime = time + 30 + MPNowPlayingInfoCenter.defaultCenter().nowPlayingInfo![MPNowPlayingInfoPropertyElapsedPlaybackTime] = self.audioPlayer.currentTime + self.updateTimer() + } + + @IBAction func rewindPressed(sender: UIButton) { + let time = self.audioPlayer.currentTime + self.audioPlayer.currentTime = time - 30 + MPNowPlayingInfoCenter.defaultCenter().nowPlayingInfo![MPNowPlayingInfoPropertyElapsedPlaybackTime] = self.audioPlayer.currentTime + self.updateTimer() + } + + @IBAction func playPressed(sender: UIButton) { + if self.audioPlayer.playing { + if self.timer != nil { + self.timer.invalidate() + } + + self.audioPlayer.stop() + MPNowPlayingInfoCenter.defaultCenter().nowPlayingInfo![MPNowPlayingInfoPropertyPlaybackRate] = 0 + MPNowPlayingInfoCenter.defaultCenter().nowPlayingInfo![MPNowPlayingInfoPropertyElapsedPlaybackTime] = self.audioPlayer.currentTime + + try! AVAudioSession.sharedInstance().setActive(false) + self.playButton.setImage(self.playImage, forState: .Normal) + return + } + + try! AVAudioSession.sharedInstance().setActive(true) + + if self.timer == nil || (self.timer != nil && !self.timer.valid) { + self.timer = NSTimer.scheduledTimerWithTimeInterval(1.0, target: self, selector: #selector(updateTimer), userInfo: nil, repeats: true) + NSRunLoop.mainRunLoop().addTimer(self.timer, forMode: NSRunLoopCommonModes) + } + self.audioPlayer.play() + MPNowPlayingInfoCenter.defaultCenter().nowPlayingInfo![MPNowPlayingInfoPropertyElapsedPlaybackTime] = self.audioPlayer.currentTime + MPNowPlayingInfoCenter.defaultCenter().nowPlayingInfo![MPNowPlayingInfoPropertyPlaybackRate] = 1 + self.playButton.setImage(self.pauseImage, forState: .Normal) + } + + func updateTimer() { + let currentTime = Int(self.audioPlayer.currentTime) + + if currentTime % 2 == 0 { + NSUserDefaults.standardUserDefaults().setInteger(currentTime, forKey: self.identifier) + } + + let timeText = self.formatTime(currentTime) + + self.currentTimeLabel.text = timeText + + let percentage = (Float(currentTime) / Float(self.audioPlayer.duration)) * 100 + self.sliderView.value = percentage + + let percentageString = String(Int(percentage))+"%" + self.percentageLabel.text = percentageString + + NSUserDefaults.standardUserDefaults().setObject(percentageString, forKey: self.identifier+"_percentage") + + } + + func formatTime(time:Int) -> String { + let hours = Int(time / 3600) + + let remaining = Float(time - (hours * 3600)) + + let minutes = Int(remaining / 60) + + let seconds = Int(remaining - Float(minutes * 60)) + + var formattedTime = String(format:"%02d:%02d", minutes, seconds) + if hours > 0 { + formattedTime = String(format:"%02d:"+formattedTime, hours) + } + + return formattedTime + } +} \ No newline at end of file diff --git a/Cartfile b/Cartfile new file mode 100644 index 000000000..86009c088 --- /dev/null +++ b/Cartfile @@ -0,0 +1,2 @@ +github "ViccAlexander/Chameleon" +github "jdg/MBProgressHUD" ~> 0.9.2 diff --git a/Cartfile.resolved b/Cartfile.resolved new file mode 100644 index 000000000..39ea317bd --- /dev/null +++ b/Cartfile.resolved @@ -0,0 +1,2 @@ +github "ViccAlexander/Chameleon" "2.1.0" +github "jdg/MBProgressHUD" "0.9.2" diff --git a/Carthage/Checkouts/MBProgressHUD/.gitignore b/Carthage/Checkouts/MBProgressHUD/.gitignore new file mode 100644 index 000000000..7aee0c65a --- /dev/null +++ b/Carthage/Checkouts/MBProgressHUD/.gitignore @@ -0,0 +1,22 @@ +# xcode noise +build/ +*.pbxuser +*.mode1v3 +*.mode2v3 +*.perspectivev3 +xcuserdata/ +*.xccheckout + +# old skool +.svn + +# osx noise +.DS_Store +profile + +# vim noise +*~ +*.swp + +# AppCode noise +.idea/ diff --git a/Carthage/Checkouts/MBProgressHUD/.travis.yml b/Carthage/Checkouts/MBProgressHUD/.travis.yml new file mode 100644 index 000000000..3a4a9281b --- /dev/null +++ b/Carthage/Checkouts/MBProgressHUD/.travis.yml @@ -0,0 +1,4 @@ +language: objective-c +xcode_workspace: MBProgressHUD.xcworkspace +xcode_scheme: HudDemo +xcode_sdk: iphonesimulator diff --git a/Carthage/Checkouts/MBProgressHUD/Carthage/Build b/Carthage/Checkouts/MBProgressHUD/Carthage/Build new file mode 120000 index 000000000..76f9ba240 --- /dev/null +++ b/Carthage/Checkouts/MBProgressHUD/Carthage/Build @@ -0,0 +1 @@ +../../../../Carthage/Build \ No newline at end of file diff --git a/Carthage/Checkouts/MBProgressHUD/Demo/Classes/HudDemoAppDelegate.h b/Carthage/Checkouts/MBProgressHUD/Demo/Classes/HudDemoAppDelegate.h new file mode 100644 index 000000000..1b144a05a --- /dev/null +++ b/Carthage/Checkouts/MBProgressHUD/Demo/Classes/HudDemoAppDelegate.h @@ -0,0 +1,23 @@ +// +// HudDemoAppDelegate.h +// HudDemo +// +// Created by Matej Bukovinski on 2.4.09. +// Copyright bukovinski.com 2009. All rights reserved. +// + +#import + +@class HudDemoViewController; + + +@interface HudDemoAppDelegate : NSObject { + UIWindow *window; + UINavigationController *navController; +} + +@property (nonatomic, retain) IBOutlet UIWindow *window; +@property (nonatomic, retain) IBOutlet UINavigationController *navController; + +@end + diff --git a/Carthage/Checkouts/MBProgressHUD/Demo/Classes/HudDemoAppDelegate.m b/Carthage/Checkouts/MBProgressHUD/Demo/Classes/HudDemoAppDelegate.m new file mode 100644 index 000000000..e4488fe77 --- /dev/null +++ b/Carthage/Checkouts/MBProgressHUD/Demo/Classes/HudDemoAppDelegate.m @@ -0,0 +1,29 @@ +// +// HudDemoAppDelegate.m +// HudDemo +// +// Created by Matej Bukovinski on 2.4.09. +// Copyright bukovinski.com 2009. All rights reserved. +// + +#import "HudDemoAppDelegate.h" +#import "HudDemoViewController.h" + + +@implementation HudDemoAppDelegate + +@synthesize window; +@synthesize navController; + +- (void)applicationDidFinishLaunching:(UIApplication *)application { + window.rootViewController = navController; + [window makeKeyAndVisible]; +} + +- (void)dealloc { + [navController release]; + [window release]; + [super dealloc]; +} + +@end diff --git a/Carthage/Checkouts/MBProgressHUD/Demo/Classes/HudDemoViewController.h b/Carthage/Checkouts/MBProgressHUD/Demo/Classes/HudDemoViewController.h new file mode 100644 index 000000000..6b4013430 --- /dev/null +++ b/Carthage/Checkouts/MBProgressHUD/Demo/Classes/HudDemoViewController.h @@ -0,0 +1,14 @@ +// +// HudDemoViewController.h +// HudDemo +// +// Created by Matej Bukovinski on 30.9.09. +// Copyright bukovinski.com 2009. All rights reserved. +// + +#import + + +@interface HudDemoViewController : UIViewController + +@end diff --git a/Carthage/Checkouts/MBProgressHUD/Demo/Classes/HudDemoViewController.m b/Carthage/Checkouts/MBProgressHUD/Demo/Classes/HudDemoViewController.m new file mode 100644 index 000000000..e87580a90 --- /dev/null +++ b/Carthage/Checkouts/MBProgressHUD/Demo/Classes/HudDemoViewController.m @@ -0,0 +1,334 @@ +// +// HudDemoViewController.m +// HudDemo +// +// Created by Matej Bukovinski on 30.9.09. +// Copyright bukovinski.com 2009. All rights reserved. +// + +#import "HudDemoViewController.h" +#import "MBProgressHUD.h" +#import + + +#define SCREENSHOT_MODE 0 + +#ifndef kCFCoreFoundationVersionNumber_iOS_8_0 + #define kCFCoreFoundationVersionNumber_iOS_7_0 847.20 +#endif + + +@interface HudDemoViewController () { + MBProgressHUD *HUD; + long long expectedLength; + long long currentLength; +} + +@property (retain, nonatomic) IBOutletCollection(UIButton) NSArray *buttons; + +@end + + +@implementation HudDemoViewController + +#pragma mark - Lifecycle methods + +- (void)viewDidLoad { + UIView *content = [[self.view subviews] objectAtIndex:0]; +#if SCREENSHOT_MODE + [content.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)]; +#endif + if (kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber_iOS_7_0) { + [self.buttons setValue:@5.f forKeyPath:@"layer.cornerRadius"]; + } else { + [self.buttons setValue:nil forKey:@"backgroundColor"]; + } + ((UIScrollView *)self.view).contentSize = content.bounds.size; +} + +- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { + return YES; +} + +- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { + UIView *content = [[self.view subviews] objectAtIndex:0]; + ((UIScrollView *)self.view).contentSize = content.bounds.size; +} + +- (void)dealloc { + [_buttons release]; + [super dealloc]; +} + +#pragma mark - Actions + +- (IBAction)showSimple:(id)sender { + // The hud will dispable all input on the view (use the higest view possible in the view hierarchy) + HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view]; + [self.navigationController.view addSubview:HUD]; + + // Regiser for HUD callbacks so we can remove it from the window at the right time + HUD.delegate = self; + + // Show the HUD while the provided method executes in a new thread + [HUD showWhileExecuting:@selector(myTask) onTarget:self withObject:nil animated:YES]; +} + +- (IBAction)showWithLabel:(id)sender { + + HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view]; + [self.navigationController.view addSubview:HUD]; + + HUD.delegate = self; + HUD.labelText = @"Loading"; + + [HUD showWhileExecuting:@selector(myTask) onTarget:self withObject:nil animated:YES]; +} + +- (IBAction)showWithDetailsLabel:(id)sender { + + HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view]; + [self.navigationController.view addSubview:HUD]; + + HUD.delegate = self; + HUD.labelText = @"Loading"; + HUD.detailsLabelText = @"updating data"; + HUD.square = YES; + + [HUD showWhileExecuting:@selector(myTask) onTarget:self withObject:nil animated:YES]; +} + +- (IBAction)showWithLabelDeterminate:(id)sender { + + HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view]; + [self.navigationController.view addSubview:HUD]; + + // Set determinate mode + HUD.mode = MBProgressHUDModeDeterminate; + + HUD.delegate = self; + HUD.labelText = @"Loading"; + + // myProgressTask uses the HUD instance to update progress + [HUD showWhileExecuting:@selector(myProgressTask) onTarget:self withObject:nil animated:YES]; +} + +- (IBAction)showWIthLabelAnnularDeterminate:(id)sender { + HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view]; + [self.navigationController.view addSubview:HUD]; + + // Set determinate mode + HUD.mode = MBProgressHUDModeAnnularDeterminate; + + HUD.delegate = self; + HUD.labelText = @"Loading"; + + // myProgressTask uses the HUD instance to update progress + [HUD showWhileExecuting:@selector(myProgressTask) onTarget:self withObject:nil animated:YES]; +} + +- (IBAction)showWithLabelDeterminateHorizontalBar:(id)sender { + + HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view]; + [self.navigationController.view addSubview:HUD]; + + // Set determinate bar mode + HUD.mode = MBProgressHUDModeDeterminateHorizontalBar; + + HUD.delegate = self; + + // myProgressTask uses the HUD instance to update progress + [HUD showWhileExecuting:@selector(myProgressTask) onTarget:self withObject:nil animated:YES]; +} + +- (IBAction)showWithCustomView:(id)sender { + + HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view]; + [self.navigationController.view addSubview:HUD]; + + // The sample image is based on the work by http://www.pixelpressicons.com, http://creativecommons.org/licenses/by/2.5/ca/ + // Make the customViews 37 by 37 pixels for best results (those are the bounds of the build-in progress indicators) + HUD.customView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"37x-Checkmark.png"]] autorelease]; + + // Set custom view mode + HUD.mode = MBProgressHUDModeCustomView; + + HUD.delegate = self; + HUD.labelText = @"Completed"; + + [HUD show:YES]; + [HUD hide:YES afterDelay:3]; +} + +- (IBAction)showWithLabelMixed:(id)sender { + + HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view]; + [self.navigationController.view addSubview:HUD]; + + HUD.delegate = self; + HUD.labelText = @"Connecting"; + HUD.minSize = CGSizeMake(135.f, 135.f); + + [HUD showWhileExecuting:@selector(myMixedTask) onTarget:self withObject:nil animated:YES]; +} + +- (IBAction)showUsingBlocks:(id)sender { +#if NS_BLOCKS_AVAILABLE + MBProgressHUD *hud = [[MBProgressHUD alloc] initWithView:self.navigationController.view]; + [self.navigationController.view addSubview:hud]; + hud.labelText = @"With a block"; + + [hud showAnimated:YES whileExecutingBlock:^{ + [self myTask]; + } completionBlock:^{ + [hud removeFromSuperview]; + [hud release]; + }]; +#endif +} + +- (IBAction)showOnWindow:(id)sender { + // The hud will dispable all input on the window + HUD = [[MBProgressHUD alloc] initWithView:self.view.window]; + [self.view.window addSubview:HUD]; + + HUD.delegate = self; + HUD.labelText = @"Loading"; + + [HUD showWhileExecuting:@selector(myTask) onTarget:self withObject:nil animated:YES]; +} + +- (IBAction)showURL:(id)sender { + NSURL *URL = [NSURL URLWithString:@"http://a1408.g.akamai.net/5/1408/1388/2005110403/1a1a1ad948be278cff2d96046ad90768d848b41947aa1986/sample_iPod.m4v.zip"]; + NSURLRequest *request = [NSURLRequest requestWithURL:URL]; + + NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self]; + [connection start]; + [connection release]; + + HUD = [[MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES] retain]; + HUD.delegate = self; +} + + +- (IBAction)showWithGradient:(id)sender { + + HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view]; + [self.navigationController.view addSubview:HUD]; + + HUD.dimBackground = YES; + + // Regiser for HUD callbacks so we can remove it from the window at the right time + HUD.delegate = self; + + // Show the HUD while the provided method executes in a new thread + [HUD showWhileExecuting:@selector(myTask) onTarget:self withObject:nil animated:YES]; +} + +- (IBAction)showTextOnly:(id)sender { + + MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES]; + + // Configure for text only and offset down + hud.mode = MBProgressHUDModeText; + hud.labelText = @"Some message..."; + hud.margin = 10.f; + hud.removeFromSuperViewOnHide = YES; + + [hud hide:YES afterDelay:3]; +} + +- (IBAction)showWithColor:(id)sender{ + HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view]; + [self.navigationController.view addSubview:HUD]; + + // Set the hud to display with a color + HUD.color = [UIColor colorWithRed:0.23 green:0.50 blue:0.82 alpha:0.90]; + + HUD.delegate = self; + [HUD showWhileExecuting:@selector(myTask) onTarget:self withObject:nil animated:YES]; +} + +#pragma mark - Execution code + +- (void)myTask { + // Do something usefull in here instead of sleeping ... + sleep(3); +} + +- (void)myProgressTask { + // This just increases the progress indicator in a loop + float progress = 0.0f; + while (progress < 1.0f) { + progress += 0.01f; + HUD.progress = progress; + usleep(50000); + } +} + +- (void)myMixedTask { + // Indeterminate mode + sleep(2); + // Switch to determinate mode + HUD.mode = MBProgressHUDModeDeterminate; + HUD.labelText = @"Progress"; + float progress = 0.0f; + while (progress < 1.0f) + { + progress += 0.01f; + HUD.progress = progress; + usleep(50000); + } + // Back to indeterminate mode + HUD.mode = MBProgressHUDModeIndeterminate; + HUD.labelText = @"Cleaning up"; + sleep(2); + // UIImageView is a UIKit class, we have to initialize it on the main thread + __block UIImageView *imageView; + dispatch_sync(dispatch_get_main_queue(), ^{ + UIImage *image = [UIImage imageNamed:@"37x-Checkmark.png"]; + imageView = [[UIImageView alloc] initWithImage:image]; + }); + HUD.customView = [imageView autorelease]; + HUD.mode = MBProgressHUDModeCustomView; + HUD.labelText = @"Completed"; + sleep(2); +} + +#pragma mark - NSURLConnectionDelegete + +- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { + expectedLength = MAX([response expectedContentLength], 1); + currentLength = 0; + HUD.mode = MBProgressHUDModeDeterminate; +} + +- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { + currentLength += [data length]; + HUD.progress = currentLength / (float)expectedLength; +} + +- (void)connectionDidFinishLoading:(NSURLConnection *)connection { + HUD.customView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"37x-Checkmark.png"]] autorelease]; + HUD.mode = MBProgressHUDModeCustomView; + [HUD hide:YES afterDelay:2]; +} + +- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { + [HUD hide:YES]; +} + +#pragma mark - MBProgressHUDDelegate + +- (void)hudWasHidden:(MBProgressHUD *)hud { + // Remove HUD from screen when the HUD was hidded + [HUD removeFromSuperview]; + [HUD release]; + HUD = nil; +} + +- (void)viewDidUnload { + [self setButtons:nil]; + [super viewDidUnload]; +} +@end diff --git a/Carthage/Checkouts/MBProgressHUD/Demo/HudDemo.xcodeproj/project.pbxproj b/Carthage/Checkouts/MBProgressHUD/Demo/HudDemo.xcodeproj/project.pbxproj new file mode 100644 index 000000000..cda9aaf88 --- /dev/null +++ b/Carthage/Checkouts/MBProgressHUD/Demo/HudDemo.xcodeproj/project.pbxproj @@ -0,0 +1,560 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 1D3623260D0F684500981E51 /* HudDemoAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D3623250D0F684500981E51 /* HudDemoAppDelegate.m */; }; + 1D60589B0D05DD56006BFB54 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; }; + 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; }; + 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; }; + 28D7ACF80DDB3853001CB0EB /* HudDemoViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 28D7ACF70DDB3853001CB0EB /* HudDemoViewController.m */; }; + D21D40801611CF6C005FCE55 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D21D407F1611CF6C005FCE55 /* Default-568h@2x.png */; }; + D22F7D810F85241C00550BB3 /* MBProgressHUD.m in Sources */ = {isa = PBXBuildFile; fileRef = D22F7D800F85241C00550BB3 /* MBProgressHUD.m */; }; + D24A23051780ADCD0020310A /* Icon-Small.png in Resources */ = {isa = PBXBuildFile; fileRef = D22568E61780AA77008D5939 /* Icon-Small.png */; }; + D24A23061780ADD10020310A /* Icon-Small@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D22568E71780AA77008D5939 /* Icon-Small@2x.png */; }; + D24A23071780ADDA0020310A /* Icon-iOS7@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D22568E51780A9C6008D5939 /* Icon-iOS7@2x.png */; }; + D24A23081780ADE60020310A /* Default-iOS7-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D22568E31780A913008D5939 /* Default-iOS7-568h@2x.png */; }; + D24A23091780ADE90020310A /* Default-iOS7@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D22568E41780A913008D5939 /* Default-iOS7@2x.png */; }; + D277FDB311FC834200304321 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = D277FDB211FC834200304321 /* Default.png */; }; + D277FDB911FC877E00304321 /* Icon.png in Resources */ = {isa = PBXBuildFile; fileRef = D277FDB711FC877E00304321 /* Icon.png */; }; + D277FDBA11FC877E00304321 /* Icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D277FDB811FC877E00304321 /* Icon@2x.png */; }; + D286A6801518736B00E13FB8 /* 37x-Checkmark@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D286A67F1518736B00E13FB8 /* 37x-Checkmark@2x.png */; }; + D286A7321518C53500E13FB8 /* HudDemoViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = D286A7341518C53500E13FB8 /* HudDemoViewController.xib */; }; + D286A7361518C53C00E13FB8 /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = D286A7381518C53C00E13FB8 /* MainWindow.xib */; }; + D286A76D1518CA9F00E13FB8 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D286A76C1518CA9F00E13FB8 /* CoreGraphics.framework */; }; + D28CBB321A87A45A0052DCEC /* HudTests.m in Sources */ = {isa = PBXBuildFile; fileRef = D28CBB311A87A45A0052DCEC /* HudTests.m */; }; + D28CBB381A87A4A10052DCEC /* MBProgressHUD.m in Sources */ = {isa = PBXBuildFile; fileRef = D22F7D800F85241C00550BB3 /* MBProgressHUD.m */; }; + D2A6FD1D13ABC5A200BFE4C9 /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D2A6FD1C13ABC5A200BFE4C9 /* Default@2x.png */; }; + D2F88CD6115E9F7F00E6DB82 /* 37x-Checkmark.png in Resources */ = {isa = PBXBuildFile; fileRef = D2F88CD5115E9F7F00E6DB82 /* 37x-Checkmark.png */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + D28CBB331A87A45A0052DCEC /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 29B97313FDCFA39411CA2CEA /* Project object */; + proxyType = 1; + remoteGlobalIDString = 1D6058900D05DD3D006BFB54; + remoteInfo = HudDemo; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + 1D3623240D0F684500981E51 /* HudDemoAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HudDemoAppDelegate.h; sourceTree = ""; }; + 1D3623250D0F684500981E51 /* HudDemoAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HudDemoAppDelegate.m; sourceTree = ""; }; + 1D6058910D05DD3D006BFB54 /* HudDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HudDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; + 28D7ACF60DDB3853001CB0EB /* HudDemoViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HudDemoViewController.h; sourceTree = ""; }; + 28D7ACF70DDB3853001CB0EB /* HudDemoViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HudDemoViewController.m; sourceTree = ""; usesTabs = 1; }; + 29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 32CA4F630368D1EE00C91783 /* HudDemo_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HudDemo_Prefix.pch; sourceTree = ""; }; + 8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + D21D407F1611CF6C005FCE55 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-568h@2x.png"; path = "Images/Default-568h@2x.png"; sourceTree = ""; }; + D22568E31780A913008D5939 /* Default-iOS7-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-iOS7-568h@2x.png"; path = "Images/Default-iOS7-568h@2x.png"; sourceTree = ""; }; + D22568E41780A913008D5939 /* Default-iOS7@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-iOS7@2x.png"; path = "Images/Default-iOS7@2x.png"; sourceTree = ""; }; + D22568E51780A9C6008D5939 /* Icon-iOS7@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-iOS7@2x.png"; path = "Images/Icon-iOS7@2x.png"; sourceTree = ""; }; + D22568E61780AA77008D5939 /* Icon-Small.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-Small.png"; path = "Images/Icon-Small.png"; sourceTree = ""; }; + D22568E71780AA77008D5939 /* Icon-Small@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-Small@2x.png"; path = "Images/Icon-Small@2x.png"; sourceTree = ""; }; + D22F7D7F0F85241C00550BB3 /* MBProgressHUD.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MBProgressHUD.h; path = ../MBProgressHUD.h; sourceTree = SOURCE_ROOT; }; + D22F7D800F85241C00550BB3 /* MBProgressHUD.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MBProgressHUD.m; path = ../MBProgressHUD.m; sourceTree = ""; }; + D277FDB211FC834200304321 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Default.png; path = Images/Default.png; sourceTree = ""; }; + D277FDB711FC877E00304321 /* Icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Icon.png; path = Images/Icon.png; sourceTree = ""; }; + D277FDB811FC877E00304321 /* Icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon@2x.png"; path = "Images/Icon@2x.png"; sourceTree = ""; }; + D286A67F1518736B00E13FB8 /* 37x-Checkmark@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "37x-Checkmark@2x.png"; path = "Images/37x-Checkmark@2x.png"; sourceTree = ""; }; + D286A7331518C53500E13FB8 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/HudDemoViewController.xib; sourceTree = ""; }; + D286A7371518C53C00E13FB8 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/MainWindow.xib; sourceTree = ""; }; + D286A76C1518CA9F00E13FB8 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; + D28CBB2D1A87A45A0052DCEC /* HudTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = HudTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + D28CBB301A87A45A0052DCEC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + D28CBB311A87A45A0052DCEC /* HudTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HudTests.m; sourceTree = ""; }; + D2A6FD1C13ABC5A200BFE4C9 /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default@2x.png"; path = "Images/Default@2x.png"; sourceTree = ""; }; + D2F88CD5115E9F7F00E6DB82 /* 37x-Checkmark.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "37x-Checkmark.png"; path = "Images/37x-Checkmark.png"; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 1D60588F0D05DD3D006BFB54 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + D286A76D1518CA9F00E13FB8 /* CoreGraphics.framework in Frameworks */, + 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */, + 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + D28CBB2A1A87A45A0052DCEC /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 080E96DDFE201D6D7F000001 /* HudDemo */ = { + isa = PBXGroup; + children = ( + 1D3623240D0F684500981E51 /* HudDemoAppDelegate.h */, + 1D3623250D0F684500981E51 /* HudDemoAppDelegate.m */, + 28D7ACF60DDB3853001CB0EB /* HudDemoViewController.h */, + 28D7ACF70DDB3853001CB0EB /* HudDemoViewController.m */, + 29B97315FDCFA39411CA2CEA /* Other Sources */, + 29B97317FDCFA39411CA2CEA /* Resources */, + ); + name = HudDemo; + path = Classes; + sourceTree = ""; + }; + 19C28FACFE9D520D11CA2CBB /* Products */ = { + isa = PBXGroup; + children = ( + 1D6058910D05DD3D006BFB54 /* HudDemo.app */, + D28CBB2D1A87A45A0052DCEC /* HudTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 29B97314FDCFA39411CA2CEA /* CustomTemplate */ = { + isa = PBXGroup; + children = ( + 080E96DDFE201D6D7F000001 /* HudDemo */, + D28CBB2E1A87A45A0052DCEC /* HudTests */, + D28CBB391A87A6B00052DCEC /* MBProgressHUD */, + 29B97323FDCFA39411CA2CEA /* Frameworks */, + 19C28FACFE9D520D11CA2CBB /* Products */, + ); + name = CustomTemplate; + sourceTree = ""; + }; + 29B97315FDCFA39411CA2CEA /* Other Sources */ = { + isa = PBXGroup; + children = ( + 32CA4F630368D1EE00C91783 /* HudDemo_Prefix.pch */, + 29B97316FDCFA39411CA2CEA /* main.m */, + ); + name = "Other Sources"; + path = ..; + sourceTree = ""; + }; + 29B97317FDCFA39411CA2CEA /* Resources */ = { + isa = PBXGroup; + children = ( + D277FDBF11FC880100304321 /* UI */, + D277FDBD11FC879500304321 /* Images */, + 8D1107310486CEB800E47090 /* Info.plist */, + ); + name = Resources; + path = ..; + sourceTree = ""; + }; + 29B97323FDCFA39411CA2CEA /* Frameworks */ = { + isa = PBXGroup; + children = ( + D286A76C1518CA9F00E13FB8 /* CoreGraphics.framework */, + 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */, + 1D30AB110D05D00D00671497 /* Foundation.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + D277FDBD11FC879500304321 /* Images */ = { + isa = PBXGroup; + children = ( + D277FDB711FC877E00304321 /* Icon.png */, + D277FDB811FC877E00304321 /* Icon@2x.png */, + D22568E61780AA77008D5939 /* Icon-Small.png */, + D22568E71780AA77008D5939 /* Icon-Small@2x.png */, + D22568E51780A9C6008D5939 /* Icon-iOS7@2x.png */, + D277FDB211FC834200304321 /* Default.png */, + D2A6FD1C13ABC5A200BFE4C9 /* Default@2x.png */, + D21D407F1611CF6C005FCE55 /* Default-568h@2x.png */, + D22568E31780A913008D5939 /* Default-iOS7-568h@2x.png */, + D22568E41780A913008D5939 /* Default-iOS7@2x.png */, + D2F88CD5115E9F7F00E6DB82 /* 37x-Checkmark.png */, + D286A67F1518736B00E13FB8 /* 37x-Checkmark@2x.png */, + ); + name = Images; + sourceTree = ""; + }; + D277FDBF11FC880100304321 /* UI */ = { + isa = PBXGroup; + children = ( + D286A7341518C53500E13FB8 /* HudDemoViewController.xib */, + D286A7381518C53C00E13FB8 /* MainWindow.xib */, + ); + name = UI; + sourceTree = ""; + }; + D28CBB2E1A87A45A0052DCEC /* HudTests */ = { + isa = PBXGroup; + children = ( + D28CBB311A87A45A0052DCEC /* HudTests.m */, + D28CBB2F1A87A45A0052DCEC /* Supporting Files */, + ); + path = HudTests; + sourceTree = ""; + }; + D28CBB2F1A87A45A0052DCEC /* Supporting Files */ = { + isa = PBXGroup; + children = ( + D28CBB301A87A45A0052DCEC /* Info.plist */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + D28CBB391A87A6B00052DCEC /* MBProgressHUD */ = { + isa = PBXGroup; + children = ( + D22F7D7F0F85241C00550BB3 /* MBProgressHUD.h */, + D22F7D800F85241C00550BB3 /* MBProgressHUD.m */, + ); + name = MBProgressHUD; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 1D6058900D05DD3D006BFB54 /* HudDemo */ = { + isa = PBXNativeTarget; + buildConfigurationList = 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "HudDemo" */; + buildPhases = ( + 1D60588D0D05DD3D006BFB54 /* Resources */, + 1D60588E0D05DD3D006BFB54 /* Sources */, + 1D60588F0D05DD3D006BFB54 /* Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = HudDemo; + productName = HudDemo; + productReference = 1D6058910D05DD3D006BFB54 /* HudDemo.app */; + productType = "com.apple.product-type.application"; + }; + D28CBB2C1A87A45A0052DCEC /* HudTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = D28CBB351A87A45A0052DCEC /* Build configuration list for PBXNativeTarget "HudTests" */; + buildPhases = ( + D28CBB291A87A45A0052DCEC /* Sources */, + D28CBB2A1A87A45A0052DCEC /* Frameworks */, + D28CBB2B1A87A45A0052DCEC /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + D28CBB341A87A45A0052DCEC /* PBXTargetDependency */, + ); + name = HudTests; + productName = HudTests; + productReference = D28CBB2D1A87A45A0052DCEC /* HudTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 29B97313FDCFA39411CA2CEA /* Project object */ = { + isa = PBXProject; + attributes = { + CLASSPREFIX = MB; + LastUpgradeCheck = 0720; + ORGANIZATIONNAME = "Matej Bukovinski"; + TargetAttributes = { + D28CBB2C1A87A45A0052DCEC = { + CreatedOnToolsVersion = 6.1.1; + TestTargetID = 1D6058900D05DD3D006BFB54; + }; + }; + }; + buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "HudDemo" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 1; + knownRegions = ( + English, + Japanese, + French, + German, + ); + mainGroup = 29B97314FDCFA39411CA2CEA /* CustomTemplate */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 1D6058900D05DD3D006BFB54 /* HudDemo */, + D28CBB2C1A87A45A0052DCEC /* HudTests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 1D60588D0D05DD3D006BFB54 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + D286A7361518C53C00E13FB8 /* MainWindow.xib in Resources */, + D286A7321518C53500E13FB8 /* HudDemoViewController.xib in Resources */, + D2F88CD6115E9F7F00E6DB82 /* 37x-Checkmark.png in Resources */, + D277FDB311FC834200304321 /* Default.png in Resources */, + D277FDB911FC877E00304321 /* Icon.png in Resources */, + D277FDBA11FC877E00304321 /* Icon@2x.png in Resources */, + D2A6FD1D13ABC5A200BFE4C9 /* Default@2x.png in Resources */, + D286A6801518736B00E13FB8 /* 37x-Checkmark@2x.png in Resources */, + D24A23081780ADE60020310A /* Default-iOS7-568h@2x.png in Resources */, + D24A23051780ADCD0020310A /* Icon-Small.png in Resources */, + D24A23071780ADDA0020310A /* Icon-iOS7@2x.png in Resources */, + D21D40801611CF6C005FCE55 /* Default-568h@2x.png in Resources */, + D24A23061780ADD10020310A /* Icon-Small@2x.png in Resources */, + D24A23091780ADE90020310A /* Default-iOS7@2x.png in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + D28CBB2B1A87A45A0052DCEC /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 1D60588E0D05DD3D006BFB54 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 1D60589B0D05DD56006BFB54 /* main.m in Sources */, + 1D3623260D0F684500981E51 /* HudDemoAppDelegate.m in Sources */, + 28D7ACF80DDB3853001CB0EB /* HudDemoViewController.m in Sources */, + D22F7D810F85241C00550BB3 /* MBProgressHUD.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + D28CBB291A87A45A0052DCEC /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + D28CBB321A87A45A0052DCEC /* HudTests.m in Sources */, + D28CBB381A87A4A10052DCEC /* MBProgressHUD.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + D28CBB341A87A45A0052DCEC /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 1D6058900D05DD3D006BFB54 /* HudDemo */; + targetProxy = D28CBB331A87A45A0052DCEC /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + D286A7341518C53500E13FB8 /* HudDemoViewController.xib */ = { + isa = PBXVariantGroup; + children = ( + D286A7331518C53500E13FB8 /* en */, + ); + name = HudDemoViewController.xib; + sourceTree = ""; + }; + D286A7381518C53C00E13FB8 /* MainWindow.xib */ = { + isa = PBXVariantGroup; + children = ( + D286A7371518C53C00E13FB8 /* en */, + ); + name = MainWindow.xib; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 1D6058940D05DD3E006BFB54 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + COPY_PHASE_STRIP = NO; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = HudDemo_Prefix.pch; + INFOPLIST_FILE = Info.plist; + PRODUCT_BUNDLE_IDENTIFIER = "com.bukovinski.${PRODUCT_NAME:identifier}"; + PRODUCT_NAME = HudDemo; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 1D6058950D05DD3E006BFB54 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + COPY_PHASE_STRIP = YES; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = HudDemo_Prefix.pch; + INFOPLIST_FILE = Info.plist; + PRODUCT_BUNDLE_IDENTIFIER = "com.bukovinski.${PRODUCT_NAME:identifier}"; + PRODUCT_NAME = HudDemo; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; + C01FCF4F08A954540054247B /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = c99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 4.3; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + }; + name = Debug; + }; + C01FCF5008A954540054247B /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = c99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 4.3; + SDKROOT = iphoneos; + }; + name = Release; + }; + D28CBB361A87A45A0052DCEC /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + BUNDLE_LOADER = "$(TEST_HOST)"; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + COPY_PHASE_STRIP = NO; + FRAMEWORK_SEARCH_PATHS = ( + "$(SDKROOT)/Developer/Library/Frameworks", + "$(inherited)", + ); + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + INFOPLIST_FILE = HudTests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 8.1; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_ENABLE_DEBUG_INFO = YES; + PRODUCT_BUNDLE_IDENTIFIER = "com.bukovinski.$(PRODUCT_NAME:rfc1034identifier)"; + PRODUCT_NAME = "$(TARGET_NAME)"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/HudDemo.app/HudDemo"; + }; + name = Debug; + }; + D28CBB371A87A45A0052DCEC /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + BUNDLE_LOADER = "$(TEST_HOST)"; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + COPY_PHASE_STRIP = YES; + ENABLE_NS_ASSERTIONS = NO; + FRAMEWORK_SEARCH_PATHS = ( + "$(SDKROOT)/Developer/Library/Frameworks", + "$(inherited)", + ); + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + INFOPLIST_FILE = HudTests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 8.1; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_ENABLE_DEBUG_INFO = NO; + PRODUCT_BUNDLE_IDENTIFIER = "com.bukovinski.$(PRODUCT_NAME:rfc1034identifier)"; + PRODUCT_NAME = "$(TARGET_NAME)"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/HudDemo.app/HudDemo"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "HudDemo" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1D6058940D05DD3E006BFB54 /* Debug */, + 1D6058950D05DD3E006BFB54 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + C01FCF4E08A954540054247B /* Build configuration list for PBXProject "HudDemo" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C01FCF4F08A954540054247B /* Debug */, + C01FCF5008A954540054247B /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + D28CBB351A87A45A0052DCEC /* Build configuration list for PBXNativeTarget "HudTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + D28CBB361A87A45A0052DCEC /* Debug */, + D28CBB371A87A45A0052DCEC /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 29B97313FDCFA39411CA2CEA /* Project object */; +} diff --git a/Carthage/Checkouts/MBProgressHUD/Demo/HudDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Carthage/Checkouts/MBProgressHUD/Demo/HudDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 000000000..9410801df --- /dev/null +++ b/Carthage/Checkouts/MBProgressHUD/Demo/HudDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,6 @@ + + + + + diff --git a/Carthage/Checkouts/MBProgressHUD/Demo/HudDemo.xcodeproj/xcshareddata/xcschemes/HudDemo.xcscheme b/Carthage/Checkouts/MBProgressHUD/Demo/HudDemo.xcodeproj/xcshareddata/xcschemes/HudDemo.xcscheme new file mode 100644 index 000000000..5e5c0b4cf --- /dev/null +++ b/Carthage/Checkouts/MBProgressHUD/Demo/HudDemo.xcodeproj/xcshareddata/xcschemes/HudDemo.xcscheme @@ -0,0 +1,119 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Carthage/Checkouts/MBProgressHUD/Demo/HudDemo_Prefix.pch b/Carthage/Checkouts/MBProgressHUD/Demo/HudDemo_Prefix.pch new file mode 100644 index 000000000..5f902d0b5 --- /dev/null +++ b/Carthage/Checkouts/MBProgressHUD/Demo/HudDemo_Prefix.pch @@ -0,0 +1,8 @@ +// +// Prefix header for all source files of the 'HudDemo' target in the 'HudDemo' project +// + +#ifdef __OBJC__ + #import + #import +#endif diff --git a/Carthage/Checkouts/MBProgressHUD/Demo/HudTests/HudTests.m b/Carthage/Checkouts/MBProgressHUD/Demo/HudTests/HudTests.m new file mode 100644 index 000000000..04cd00655 --- /dev/null +++ b/Carthage/Checkouts/MBProgressHUD/Demo/HudTests/HudTests.m @@ -0,0 +1,42 @@ +// +// HudTests.m +// HudTests +// +// Created by Matej Bukovinski on 8. 02. 15. +// Copyright (c) 2015 Matej Bukovinski. All rights reserved. +// + +#import +#import +#import "MBProgressHUD.h" + + +@interface HudTests : XCTestCase + +@property (nonatomic, strong) MBProgressHUD *hud; +@property (nonatomic, strong) UIView *view; + +@end + +@implementation HudTests + +- (void)setUp { + [super setUp]; + + self.view = [[UIView alloc] init]; + self.view.bounds = [[UIScreen mainScreen] bounds]; + self.hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES]; +} + +- (void)tearDown { + self.hud = nil; + self.view = nil; + + [super tearDown]; +} + +- (void)testThatHUDExists { + XCTAssertNotNil(self.hud, @"Should be able to create a new HUD instance"); +} + +@end diff --git a/Carthage/Checkouts/MBProgressHUD/Demo/HudTests/Info.plist b/Carthage/Checkouts/MBProgressHUD/Demo/HudTests/Info.plist new file mode 100644 index 000000000..ba72822e8 --- /dev/null +++ b/Carthage/Checkouts/MBProgressHUD/Demo/HudTests/Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + + diff --git a/Carthage/Checkouts/MBProgressHUD/Demo/Images/37x-Checkmark.png b/Carthage/Checkouts/MBProgressHUD/Demo/Images/37x-Checkmark.png new file mode 100644 index 000000000..f330b70ad Binary files /dev/null and b/Carthage/Checkouts/MBProgressHUD/Demo/Images/37x-Checkmark.png differ diff --git a/Carthage/Checkouts/MBProgressHUD/Demo/Images/37x-Checkmark@2x.png b/Carthage/Checkouts/MBProgressHUD/Demo/Images/37x-Checkmark@2x.png new file mode 100644 index 000000000..2cb680b53 Binary files /dev/null and b/Carthage/Checkouts/MBProgressHUD/Demo/Images/37x-Checkmark@2x.png differ diff --git a/Carthage/Checkouts/MBProgressHUD/Demo/Images/Default-568h@2x.png b/Carthage/Checkouts/MBProgressHUD/Demo/Images/Default-568h@2x.png new file mode 100644 index 000000000..d2d6399aa Binary files /dev/null and b/Carthage/Checkouts/MBProgressHUD/Demo/Images/Default-568h@2x.png differ diff --git a/Carthage/Checkouts/MBProgressHUD/Demo/Images/Default-iOS7-568h@2x.png b/Carthage/Checkouts/MBProgressHUD/Demo/Images/Default-iOS7-568h@2x.png new file mode 100644 index 000000000..c1e1623b7 Binary files /dev/null and b/Carthage/Checkouts/MBProgressHUD/Demo/Images/Default-iOS7-568h@2x.png differ diff --git a/Carthage/Checkouts/MBProgressHUD/Demo/Images/Default-iOS7@2x.png b/Carthage/Checkouts/MBProgressHUD/Demo/Images/Default-iOS7@2x.png new file mode 100644 index 000000000..0284c8174 Binary files /dev/null and b/Carthage/Checkouts/MBProgressHUD/Demo/Images/Default-iOS7@2x.png differ diff --git a/Carthage/Checkouts/MBProgressHUD/Demo/Images/Default.png b/Carthage/Checkouts/MBProgressHUD/Demo/Images/Default.png new file mode 100644 index 000000000..4c28122ac Binary files /dev/null and b/Carthage/Checkouts/MBProgressHUD/Demo/Images/Default.png differ diff --git a/Carthage/Checkouts/MBProgressHUD/Demo/Images/Default@2x.png b/Carthage/Checkouts/MBProgressHUD/Demo/Images/Default@2x.png new file mode 100644 index 000000000..78c7125c5 Binary files /dev/null and b/Carthage/Checkouts/MBProgressHUD/Demo/Images/Default@2x.png differ diff --git a/Carthage/Checkouts/MBProgressHUD/Demo/Images/Icon-Small.png b/Carthage/Checkouts/MBProgressHUD/Demo/Images/Icon-Small.png new file mode 100644 index 000000000..d840cc5ff Binary files /dev/null and b/Carthage/Checkouts/MBProgressHUD/Demo/Images/Icon-Small.png differ diff --git a/Carthage/Checkouts/MBProgressHUD/Demo/Images/Icon-Small@2x.png b/Carthage/Checkouts/MBProgressHUD/Demo/Images/Icon-Small@2x.png new file mode 100644 index 000000000..c6de46def Binary files /dev/null and b/Carthage/Checkouts/MBProgressHUD/Demo/Images/Icon-Small@2x.png differ diff --git a/Carthage/Checkouts/MBProgressHUD/Demo/Images/Icon-iOS7@2x.png b/Carthage/Checkouts/MBProgressHUD/Demo/Images/Icon-iOS7@2x.png new file mode 100644 index 000000000..07040fca4 Binary files /dev/null and b/Carthage/Checkouts/MBProgressHUD/Demo/Images/Icon-iOS7@2x.png differ diff --git a/Carthage/Checkouts/MBProgressHUD/Demo/Images/Icon.png b/Carthage/Checkouts/MBProgressHUD/Demo/Images/Icon.png new file mode 100644 index 000000000..430cb6c27 Binary files /dev/null and b/Carthage/Checkouts/MBProgressHUD/Demo/Images/Icon.png differ diff --git a/Carthage/Checkouts/MBProgressHUD/Demo/Images/Icon@2x.png b/Carthage/Checkouts/MBProgressHUD/Demo/Images/Icon@2x.png new file mode 100644 index 000000000..68d2e0bef Binary files /dev/null and b/Carthage/Checkouts/MBProgressHUD/Demo/Images/Icon@2x.png differ diff --git a/Carthage/Checkouts/MBProgressHUD/Demo/Info.plist b/Carthage/Checkouts/MBProgressHUD/Demo/Info.plist new file mode 100644 index 000000000..2ae77bf5d --- /dev/null +++ b/Carthage/Checkouts/MBProgressHUD/Demo/Info.plist @@ -0,0 +1,71 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleDisplayName + ${PRODUCT_NAME} + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIconFile + + CFBundleIconFiles + + Icon-Small + Icon-iOS7 + Icon.png + Icon@2x.png + + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + LSRequiresIPhoneOS + + NSMainNibFile + MainWindow + UILaunchImages + + + UILaunchImageMinimumOSVersion + 7.0 + UILaunchImageName + Default-iOS7 + UILaunchImageOrientation + Portrait + UILaunchImageSize + {320, 568} + + + UILaunchImageMinimumOSVersion + 7.0 + UILaunchImageName + Default-iOS7 + UILaunchImageOrientation + Portrait + UILaunchImageSize + {320, 480} + + + UILaunchStoryboardName + MainWindow + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/Carthage/Checkouts/MBProgressHUD/Demo/en.lproj/HudDemoViewController.xib b/Carthage/Checkouts/MBProgressHUD/Demo/en.lproj/HudDemoViewController.xib new file mode 100644 index 000000000..6a4d1a365 --- /dev/null +++ b/Carthage/Checkouts/MBProgressHUD/Demo/en.lproj/HudDemoViewController.xib @@ -0,0 +1,269 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Carthage/Checkouts/MBProgressHUD/Demo/en.lproj/MainWindow.xib b/Carthage/Checkouts/MBProgressHUD/Demo/en.lproj/MainWindow.xib new file mode 100644 index 000000000..dffe5065e --- /dev/null +++ b/Carthage/Checkouts/MBProgressHUD/Demo/en.lproj/MainWindow.xib @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Carthage/Checkouts/MBProgressHUD/Demo/main.m b/Carthage/Checkouts/MBProgressHUD/Demo/main.m new file mode 100644 index 000000000..3e4915ce8 --- /dev/null +++ b/Carthage/Checkouts/MBProgressHUD/Demo/main.m @@ -0,0 +1,17 @@ +// +// main.m +// HudDemo +// +// Created by Matej Bukovinski on 2.4.09. +// Copyright bukovinski.com 2009. All rights reserved. +// + +#import + +int main(int argc, char *argv[]) { + + NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; + int retVal = UIApplicationMain(argc, argv, nil, nil); + [pool release]; + return retVal; +} diff --git a/Carthage/Checkouts/MBProgressHUD/Framework-Info.plist b/Carthage/Checkouts/MBProgressHUD/Framework-Info.plist new file mode 100644 index 000000000..10090c084 --- /dev/null +++ b/Carthage/Checkouts/MBProgressHUD/Framework-Info.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + com.matej.$(PRODUCT_NAME:rfc1034identifier) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + $(CURRENT_PROJECT_VERSION) + NSPrincipalClass + + + diff --git a/Carthage/Checkouts/MBProgressHUD/LICENSE b/Carthage/Checkouts/MBProgressHUD/LICENSE new file mode 100644 index 000000000..0e357d1bf --- /dev/null +++ b/Carthage/Checkouts/MBProgressHUD/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2009-2015 Matej Bukovinski + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/Carthage/Checkouts/MBProgressHUD/MBProgressHUD-Prefix.pch b/Carthage/Checkouts/MBProgressHUD/MBProgressHUD-Prefix.pch new file mode 100644 index 000000000..e81c6697b --- /dev/null +++ b/Carthage/Checkouts/MBProgressHUD/MBProgressHUD-Prefix.pch @@ -0,0 +1,15 @@ +// +// Prefix header for all source files of the 'MBProgressHUD' target in the 'MBProgressHUD' project +// + +#import + +#ifndef __IPHONE_3_0 +#warning "This project uses features only available in iOS SDK 3.0 and later." +#endif + +#ifdef __OBJC__ + #import + #import + #import +#endif diff --git a/Carthage/Checkouts/MBProgressHUD/MBProgressHUD.h b/Carthage/Checkouts/MBProgressHUD/MBProgressHUD.h new file mode 100644 index 000000000..40e71a9b2 --- /dev/null +++ b/Carthage/Checkouts/MBProgressHUD/MBProgressHUD.h @@ -0,0 +1,521 @@ +// +// MBProgressHUD.h +// Version 0.9.2 +// Created by Matej Bukovinski on 2.4.09. +// + +// This code is distributed under the terms and conditions of the MIT license. + +// Copyright (c) 2009-2015 Matej Bukovinski +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import +#import +#import + +@protocol MBProgressHUDDelegate; + + +typedef NS_ENUM(NSInteger, MBProgressHUDMode) { + /** Progress is shown using an UIActivityIndicatorView. This is the default. */ + MBProgressHUDModeIndeterminate, + /** Progress is shown using a round, pie-chart like, progress view. */ + MBProgressHUDModeDeterminate, + /** Progress is shown using a horizontal progress bar */ + MBProgressHUDModeDeterminateHorizontalBar, + /** Progress is shown using a ring-shaped progress view. */ + MBProgressHUDModeAnnularDeterminate, + /** Shows a custom view */ + MBProgressHUDModeCustomView, + /** Shows only labels */ + MBProgressHUDModeText +}; + +typedef NS_ENUM(NSInteger, MBProgressHUDAnimation) { + /** Opacity animation */ + MBProgressHUDAnimationFade, + /** Opacity + scale animation */ + MBProgressHUDAnimationZoom, + MBProgressHUDAnimationZoomOut = MBProgressHUDAnimationZoom, + MBProgressHUDAnimationZoomIn +}; + + +#ifndef MB_INSTANCETYPE +#if __has_feature(objc_instancetype) + #define MB_INSTANCETYPE instancetype +#else + #define MB_INSTANCETYPE id +#endif +#endif + +#ifndef MB_STRONG +#if __has_feature(objc_arc) + #define MB_STRONG strong +#else + #define MB_STRONG retain +#endif +#endif + +#ifndef MB_WEAK +#if __has_feature(objc_arc_weak) + #define MB_WEAK weak +#elif __has_feature(objc_arc) + #define MB_WEAK unsafe_unretained +#else + #define MB_WEAK assign +#endif +#endif + +#if NS_BLOCKS_AVAILABLE +typedef void (^MBProgressHUDCompletionBlock)(); +#endif + + +/** + * Displays a simple HUD window containing a progress indicator and two optional labels for short messages. + * + * This is a simple drop-in class for displaying a progress HUD view similar to Apple's private UIProgressHUD class. + * The MBProgressHUD window spans over the entire space given to it by the initWithFrame constructor and catches all + * user input on this region, thereby preventing the user operations on components below the view. The HUD itself is + * drawn centered as a rounded semi-transparent view which resizes depending on the user specified content. + * + * This view supports four modes of operation: + * - MBProgressHUDModeIndeterminate - shows a UIActivityIndicatorView + * - MBProgressHUDModeDeterminate - shows a custom round progress indicator + * - MBProgressHUDModeAnnularDeterminate - shows a custom annular progress indicator + * - MBProgressHUDModeCustomView - shows an arbitrary, user specified view (see `customView`) + * + * All three modes can have optional labels assigned: + * - If the labelText property is set and non-empty then a label containing the provided content is placed below the + * indicator view. + * - If also the detailsLabelText property is set then another label is placed below the first label. + */ +@interface MBProgressHUD : UIView + +/** + * Creates a new HUD, adds it to provided view and shows it. The counterpart to this method is hideHUDForView:animated:. + * + * @note This method sets `removeFromSuperViewOnHide`. The HUD will automatically be removed from the view hierarchy when hidden. + * + * @param view The view that the HUD will be added to + * @param animated If set to YES the HUD will appear using the current animationType. If set to NO the HUD will not use + * animations while appearing. + * @return A reference to the created HUD. + * + * @see hideHUDForView:animated: + * @see animationType + */ ++ (MB_INSTANCETYPE)showHUDAddedTo:(UIView *)view animated:(BOOL)animated; + +/** + * Finds the top-most HUD subview and hides it. The counterpart to this method is showHUDAddedTo:animated:. + * + * @note This method sets `removeFromSuperViewOnHide`. The HUD will automatically be removed from the view hierarchy when hidden. + * + * @param view The view that is going to be searched for a HUD subview. + * @param animated If set to YES the HUD will disappear using the current animationType. If set to NO the HUD will not use + * animations while disappearing. + * @return YES if a HUD was found and removed, NO otherwise. + * + * @see showHUDAddedTo:animated: + * @see animationType + */ ++ (BOOL)hideHUDForView:(UIView *)view animated:(BOOL)animated; + +/** + * Finds all the HUD subviews and hides them. + * + * @note This method sets `removeFromSuperViewOnHide`. The HUDs will automatically be removed from the view hierarchy when hidden. + * + * @param view The view that is going to be searched for HUD subviews. + * @param animated If set to YES the HUDs will disappear using the current animationType. If set to NO the HUDs will not use + * animations while disappearing. + * @return the number of HUDs found and removed. + * + * @see hideHUDForView:animated: + * @see animationType + */ ++ (NSUInteger)hideAllHUDsForView:(UIView *)view animated:(BOOL)animated; + +/** + * Finds the top-most HUD subview and returns it. + * + * @param view The view that is going to be searched. + * @return A reference to the last HUD subview discovered. + */ ++ (MB_INSTANCETYPE)HUDForView:(UIView *)view; + +/** + * Finds all HUD subviews and returns them. + * + * @param view The view that is going to be searched. + * @return All found HUD views (array of MBProgressHUD objects). + */ ++ (NSArray *)allHUDsForView:(UIView *)view; + +/** + * A convenience constructor that initializes the HUD with the window's bounds. Calls the designated constructor with + * window.bounds as the parameter. + * + * @param window The window instance that will provide the bounds for the HUD. Should be the same instance as + * the HUD's superview (i.e., the window that the HUD will be added to). + */ +- (id)initWithWindow:(UIWindow *)window; + +/** + * A convenience constructor that initializes the HUD with the view's bounds. Calls the designated constructor with + * view.bounds as the parameter + * + * @param view The view instance that will provide the bounds for the HUD. Should be the same instance as + * the HUD's superview (i.e., the view that the HUD will be added to). + */ +- (id)initWithView:(UIView *)view; + +/** + * Display the HUD. You need to make sure that the main thread completes its run loop soon after this method call so + * the user interface can be updated. Call this method when your task is already set-up to be executed in a new thread + * (e.g., when using something like NSOperation or calling an asynchronous call like NSURLRequest). + * + * @param animated If set to YES the HUD will appear using the current animationType. If set to NO the HUD will not use + * animations while appearing. + * + * @see animationType + */ +- (void)show:(BOOL)animated; + +/** + * Hide the HUD. This still calls the hudWasHidden: delegate. This is the counterpart of the show: method. Use it to + * hide the HUD when your task completes. + * + * @param animated If set to YES the HUD will disappear using the current animationType. If set to NO the HUD will not use + * animations while disappearing. + * + * @see animationType + */ +- (void)hide:(BOOL)animated; + +/** + * Hide the HUD after a delay. This still calls the hudWasHidden: delegate. This is the counterpart of the show: method. Use it to + * hide the HUD when your task completes. + * + * @param animated If set to YES the HUD will disappear using the current animationType. If set to NO the HUD will not use + * animations while disappearing. + * @param delay Delay in seconds until the HUD is hidden. + * + * @see animationType + */ +- (void)hide:(BOOL)animated afterDelay:(NSTimeInterval)delay; + +/** + * Shows the HUD while a background task is executing in a new thread, then hides the HUD. + * + * This method also takes care of autorelease pools so your method does not have to be concerned with setting up a + * pool. + * + * @param method The method to be executed while the HUD is shown. This method will be executed in a new thread. + * @param target The object that the target method belongs to. + * @param object An optional object to be passed to the method. + * @param animated If set to YES the HUD will (dis)appear using the current animationType. If set to NO the HUD will not use + * animations while (dis)appearing. + */ +- (void)showWhileExecuting:(SEL)method onTarget:(id)target withObject:(id)object animated:(BOOL)animated; + +#if NS_BLOCKS_AVAILABLE + +/** + * Shows the HUD while a block is executing on a background queue, then hides the HUD. + * + * @see showAnimated:whileExecutingBlock:onQueue:completionBlock: + */ +- (void)showAnimated:(BOOL)animated whileExecutingBlock:(dispatch_block_t)block; + +/** + * Shows the HUD while a block is executing on a background queue, then hides the HUD. + * + * @see showAnimated:whileExecutingBlock:onQueue:completionBlock: + */ +- (void)showAnimated:(BOOL)animated whileExecutingBlock:(dispatch_block_t)block completionBlock:(MBProgressHUDCompletionBlock)completion; + +/** + * Shows the HUD while a block is executing on the specified dispatch queue, then hides the HUD. + * + * @see showAnimated:whileExecutingBlock:onQueue:completionBlock: + */ +- (void)showAnimated:(BOOL)animated whileExecutingBlock:(dispatch_block_t)block onQueue:(dispatch_queue_t)queue; + +/** + * Shows the HUD while a block is executing on the specified dispatch queue, executes completion block on the main queue, and then hides the HUD. + * + * @param animated If set to YES the HUD will (dis)appear using the current animationType. If set to NO the HUD will + * not use animations while (dis)appearing. + * @param block The block to be executed while the HUD is shown. + * @param queue The dispatch queue on which the block should be executed. + * @param completion The block to be executed on completion. + * + * @see completionBlock + */ +- (void)showAnimated:(BOOL)animated whileExecutingBlock:(dispatch_block_t)block onQueue:(dispatch_queue_t)queue + completionBlock:(MBProgressHUDCompletionBlock)completion; + +/** + * A block that gets called after the HUD was completely hidden. + */ +@property (copy) MBProgressHUDCompletionBlock completionBlock; + +#endif + +/** + * MBProgressHUD operation mode. The default is MBProgressHUDModeIndeterminate. + * + * @see MBProgressHUDMode + */ +@property (assign) MBProgressHUDMode mode; + +/** + * The animation type that should be used when the HUD is shown and hidden. + * + * @see MBProgressHUDAnimation + */ +@property (assign) MBProgressHUDAnimation animationType; + +/** + * The UIView (e.g., a UIImageView) to be shown when the HUD is in MBProgressHUDModeCustomView. + * For best results use a 37 by 37 pixel view (so the bounds match the built in indicator bounds). + */ +@property (MB_STRONG) UIView *customView; + +/** + * The HUD delegate object. + * + * @see MBProgressHUDDelegate + */ +@property (MB_WEAK) id delegate; + +/** + * An optional short message to be displayed below the activity indicator. The HUD is automatically resized to fit + * the entire text. If the text is too long it will get clipped by displaying "..." at the end. If left unchanged or + * set to @"", then no message is displayed. + */ +@property (copy) NSString *labelText; + +/** + * An optional details message displayed below the labelText message. This message is displayed only if the labelText + * property is also set and is different from an empty string (@""). The details text can span multiple lines. + */ +@property (copy) NSString *detailsLabelText; + +/** + * The opacity of the HUD window. Defaults to 0.8 (80% opacity). + */ +@property (assign) float opacity; + +/** + * The color of the HUD window. Defaults to black. If this property is set, color is set using + * this UIColor and the opacity property is not used. using retain because performing copy on + * UIColor base colors (like [UIColor greenColor]) cause problems with the copyZone. + */ +@property (MB_STRONG) UIColor *color; + +/** + * The x-axis offset of the HUD relative to the centre of the superview. + */ +@property (assign) float xOffset; + +/** + * The y-axis offset of the HUD relative to the centre of the superview. + */ +@property (assign) float yOffset; + +/** + * The amount of space between the HUD edge and the HUD elements (labels, indicators or custom views). + * Defaults to 20.0 + */ +@property (assign) float margin; + +/** + * The corner radius for the HUD + * Defaults to 10.0 + */ +@property (assign) float cornerRadius; + +/** + * Cover the HUD background view with a radial gradient. + */ +@property (assign) BOOL dimBackground; + +/* + * Grace period is the time (in seconds) that the invoked method may be run without + * showing the HUD. If the task finishes before the grace time runs out, the HUD will + * not be shown at all. + * This may be used to prevent HUD display for very short tasks. + * Defaults to 0 (no grace time). + * Grace time functionality is only supported when the task status is known! + * @see taskInProgress + */ +@property (assign) float graceTime; + +/** + * The minimum time (in seconds) that the HUD is shown. + * This avoids the problem of the HUD being shown and than instantly hidden. + * Defaults to 0 (no minimum show time). + */ +@property (assign) float minShowTime; + +/** + * Indicates that the executed operation is in progress. Needed for correct graceTime operation. + * If you don't set a graceTime (different than 0.0) this does nothing. + * This property is automatically set when using showWhileExecuting:onTarget:withObject:animated:. + * When threading is done outside of the HUD (i.e., when the show: and hide: methods are used directly), + * you need to set this property when your task starts and completes in order to have normal graceTime + * functionality. + */ +@property (assign) BOOL taskInProgress; + +/** + * Removes the HUD from its parent view when hidden. + * Defaults to NO. + */ +@property (assign) BOOL removeFromSuperViewOnHide; + +/** + * Font to be used for the main label. Set this property if the default is not adequate. + */ +@property (MB_STRONG) UIFont* labelFont; + +/** + * Color to be used for the main label. Set this property if the default is not adequate. + */ +@property (MB_STRONG) UIColor* labelColor; + +/** + * Font to be used for the details label. Set this property if the default is not adequate. + */ +@property (MB_STRONG) UIFont* detailsLabelFont; + +/** + * Color to be used for the details label. Set this property if the default is not adequate. + */ +@property (MB_STRONG) UIColor* detailsLabelColor; + +/** + * The color of the activity indicator. Defaults to [UIColor whiteColor] + * Does nothing on pre iOS 5. + */ +@property (MB_STRONG) UIColor *activityIndicatorColor; + +/** + * The progress of the progress indicator, from 0.0 to 1.0. Defaults to 0.0. + */ +@property (assign) float progress; + +/** + * The minimum size of the HUD bezel. Defaults to CGSizeZero (no minimum size). + */ +@property (assign) CGSize minSize; + + +/** + * The actual size of the HUD bezel. + * You can use this to limit touch handling on the bezel area only. + * @see https://github.com/jdg/MBProgressHUD/pull/200 + */ +@property (atomic, assign, readonly) CGSize size; + + +/** + * Force the HUD dimensions to be equal if possible. + */ +@property (assign, getter = isSquare) BOOL square; + +@end + + +@protocol MBProgressHUDDelegate + +@optional + +/** + * Called after the HUD was fully hidden from the screen. + */ +- (void)hudWasHidden:(MBProgressHUD *)hud; + +@end + + +/** + * A progress view for showing definite progress by filling up a circle (pie chart). + */ +@interface MBRoundProgressView : UIView + +/** + * Progress (0.0 to 1.0) + */ +@property (nonatomic, assign) float progress; + +/** + * Indicator progress color. + * Defaults to white [UIColor whiteColor] + */ +@property (nonatomic, MB_STRONG) UIColor *progressTintColor; + +/** + * Indicator background (non-progress) color. + * Defaults to translucent white (alpha 0.1) + */ +@property (nonatomic, MB_STRONG) UIColor *backgroundTintColor; + +/* + * Display mode - NO = round or YES = annular. Defaults to round. + */ +@property (nonatomic, assign, getter = isAnnular) BOOL annular; + +@end + + +/** + * A flat bar progress view. + */ +@interface MBBarProgressView : UIView + +/** + * Progress (0.0 to 1.0) + */ +@property (nonatomic, assign) float progress; + +/** + * Bar border line color. + * Defaults to white [UIColor whiteColor]. + */ +@property (nonatomic, MB_STRONG) UIColor *lineColor; + +/** + * Bar background color. + * Defaults to clear [UIColor clearColor]; + */ +@property (nonatomic, MB_STRONG) UIColor *progressRemainingColor; + +/** + * Bar progress color. + * Defaults to white [UIColor whiteColor]. + */ +@property (nonatomic, MB_STRONG) UIColor *progressColor; + +@end diff --git a/Carthage/Checkouts/MBProgressHUD/MBProgressHUD.m b/Carthage/Checkouts/MBProgressHUD/MBProgressHUD.m new file mode 100644 index 000000000..bf5f7fff1 --- /dev/null +++ b/Carthage/Checkouts/MBProgressHUD/MBProgressHUD.m @@ -0,0 +1,1033 @@ +// +// MBProgressHUD.m +// Version 0.9.2 +// Created by Matej Bukovinski on 2.4.09. +// + +#import "MBProgressHUD.h" +#import + + +#if __has_feature(objc_arc) + #define MB_AUTORELEASE(exp) exp + #define MB_RELEASE(exp) exp + #define MB_RETAIN(exp) exp +#else + #define MB_AUTORELEASE(exp) [exp autorelease] + #define MB_RELEASE(exp) [exp release] + #define MB_RETAIN(exp) [exp retain] +#endif + +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000 + #define MBLabelAlignmentCenter NSTextAlignmentCenter +#else + #define MBLabelAlignmentCenter UITextAlignmentCenter +#endif + +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 + #define MB_TEXTSIZE(text, font) [text length] > 0 ? [text \ + sizeWithAttributes:@{NSFontAttributeName:font}] : CGSizeZero; +#else + #define MB_TEXTSIZE(text, font) [text length] > 0 ? [text sizeWithFont:font] : CGSizeZero; +#endif + +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 + #define MB_MULTILINE_TEXTSIZE(text, font, maxSize, mode) [text length] > 0 ? [text \ + boundingRectWithSize:maxSize options:(NSStringDrawingUsesLineFragmentOrigin) \ + attributes:@{NSFontAttributeName:font} context:nil].size : CGSizeZero; +#else + #define MB_MULTILINE_TEXTSIZE(text, font, maxSize, mode) [text length] > 0 ? [text \ + sizeWithFont:font constrainedToSize:maxSize lineBreakMode:mode] : CGSizeZero; +#endif + +#ifndef kCFCoreFoundationVersionNumber_iOS_7_0 + #define kCFCoreFoundationVersionNumber_iOS_7_0 847.20 +#endif + +#ifndef kCFCoreFoundationVersionNumber_iOS_8_0 + #define kCFCoreFoundationVersionNumber_iOS_8_0 1129.15 +#endif + + +static const CGFloat kPadding = 4.f; +static const CGFloat kLabelFontSize = 16.f; +static const CGFloat kDetailsLabelFontSize = 12.f; + + +@interface MBProgressHUD () { + BOOL useAnimation; + SEL methodForExecution; + id targetForExecution; + id objectForExecution; + UILabel *label; + UILabel *detailsLabel; + BOOL isFinished; + CGAffineTransform rotationTransform; +} + +@property (atomic, MB_STRONG) UIView *indicator; +@property (atomic, MB_STRONG) NSTimer *graceTimer; +@property (atomic, MB_STRONG) NSTimer *minShowTimer; +@property (atomic, MB_STRONG) NSDate *showStarted; + +@end + + +@implementation MBProgressHUD + +#pragma mark - Properties + +@synthesize animationType; +@synthesize delegate; +@synthesize opacity; +@synthesize color; +@synthesize labelFont; +@synthesize labelColor; +@synthesize detailsLabelFont; +@synthesize detailsLabelColor; +@synthesize indicator; +@synthesize xOffset; +@synthesize yOffset; +@synthesize minSize; +@synthesize square; +@synthesize margin; +@synthesize dimBackground; +@synthesize graceTime; +@synthesize minShowTime; +@synthesize graceTimer; +@synthesize minShowTimer; +@synthesize taskInProgress; +@synthesize removeFromSuperViewOnHide; +@synthesize customView; +@synthesize showStarted; +@synthesize mode; +@synthesize labelText; +@synthesize detailsLabelText; +@synthesize progress; +@synthesize size; +@synthesize activityIndicatorColor; +#if NS_BLOCKS_AVAILABLE +@synthesize completionBlock; +#endif + +#pragma mark - Class methods + ++ (MB_INSTANCETYPE)showHUDAddedTo:(UIView *)view animated:(BOOL)animated { + MBProgressHUD *hud = [[self alloc] initWithView:view]; + hud.removeFromSuperViewOnHide = YES; + [view addSubview:hud]; + [hud show:animated]; + return MB_AUTORELEASE(hud); +} + ++ (BOOL)hideHUDForView:(UIView *)view animated:(BOOL)animated { + MBProgressHUD *hud = [self HUDForView:view]; + if (hud != nil) { + hud.removeFromSuperViewOnHide = YES; + [hud hide:animated]; + return YES; + } + return NO; +} + ++ (NSUInteger)hideAllHUDsForView:(UIView *)view animated:(BOOL)animated { + NSArray *huds = [MBProgressHUD allHUDsForView:view]; + for (MBProgressHUD *hud in huds) { + hud.removeFromSuperViewOnHide = YES; + [hud hide:animated]; + } + return [huds count]; +} + ++ (MB_INSTANCETYPE)HUDForView:(UIView *)view { + NSEnumerator *subviewsEnum = [view.subviews reverseObjectEnumerator]; + for (UIView *subview in subviewsEnum) { + if ([subview isKindOfClass:self]) { + return (MBProgressHUD *)subview; + } + } + return nil; +} + ++ (NSArray *)allHUDsForView:(UIView *)view { + NSMutableArray *huds = [NSMutableArray array]; + NSArray *subviews = view.subviews; + for (UIView *aView in subviews) { + if ([aView isKindOfClass:self]) { + [huds addObject:aView]; + } + } + return [NSArray arrayWithArray:huds]; +} + +#pragma mark - Lifecycle + +- (id)initWithFrame:(CGRect)frame { + self = [super initWithFrame:frame]; + if (self) { + // Set default values for properties + self.animationType = MBProgressHUDAnimationFade; + self.mode = MBProgressHUDModeIndeterminate; + self.labelText = nil; + self.detailsLabelText = nil; + self.opacity = 0.8f; + self.color = nil; + self.labelFont = [UIFont boldSystemFontOfSize:kLabelFontSize]; + self.labelColor = [UIColor whiteColor]; + self.detailsLabelFont = [UIFont boldSystemFontOfSize:kDetailsLabelFontSize]; + self.detailsLabelColor = [UIColor whiteColor]; + self.activityIndicatorColor = [UIColor whiteColor]; + self.xOffset = 0.0f; + self.yOffset = 0.0f; + self.dimBackground = NO; + self.margin = 20.0f; + self.cornerRadius = 10.0f; + self.graceTime = 0.0f; + self.minShowTime = 0.0f; + self.removeFromSuperViewOnHide = NO; + self.minSize = CGSizeZero; + self.square = NO; + self.contentMode = UIViewContentModeCenter; + self.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin + | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; + + // Transparent background + self.opaque = NO; + self.backgroundColor = [UIColor clearColor]; + // Make it invisible for now + self.alpha = 0.0f; + + taskInProgress = NO; + rotationTransform = CGAffineTransformIdentity; + + [self setupLabels]; + [self updateIndicators]; + [self registerForKVO]; + [self registerForNotifications]; + } + return self; +} + +- (id)initWithView:(UIView *)view { + NSAssert(view, @"View must not be nil."); + return [self initWithFrame:view.bounds]; +} + +- (id)initWithWindow:(UIWindow *)window { + return [self initWithView:window]; +} + +- (void)dealloc { + [self unregisterFromNotifications]; + [self unregisterFromKVO]; +#if !__has_feature(objc_arc) + [color release]; + [indicator release]; + [label release]; + [detailsLabel release]; + [labelText release]; + [detailsLabelText release]; + [graceTimer release]; + [minShowTimer release]; + [showStarted release]; + [customView release]; + [labelFont release]; + [labelColor release]; + [detailsLabelFont release]; + [detailsLabelColor release]; +#if NS_BLOCKS_AVAILABLE + [completionBlock release]; +#endif + [super dealloc]; +#endif +} + +#pragma mark - Show & hide + +- (void)show:(BOOL)animated { + NSAssert([NSThread isMainThread], @"MBProgressHUD needs to be accessed on the main thread."); + useAnimation = animated; + // If the grace time is set postpone the HUD display + if (self.graceTime > 0.0) { + NSTimer *newGraceTimer = [NSTimer timerWithTimeInterval:self.graceTime target:self selector:@selector(handleGraceTimer:) userInfo:nil repeats:NO]; + [[NSRunLoop currentRunLoop] addTimer:newGraceTimer forMode:NSRunLoopCommonModes]; + self.graceTimer = newGraceTimer; + } + // ... otherwise show the HUD imediately + else { + [self showUsingAnimation:useAnimation]; + } +} + +- (void)hide:(BOOL)animated { + NSAssert([NSThread isMainThread], @"MBProgressHUD needs to be accessed on the main thread."); + useAnimation = animated; + // If the minShow time is set, calculate how long the hud was shown, + // and pospone the hiding operation if necessary + if (self.minShowTime > 0.0 && showStarted) { + NSTimeInterval interv = [[NSDate date] timeIntervalSinceDate:showStarted]; + if (interv < self.minShowTime) { + self.minShowTimer = [NSTimer scheduledTimerWithTimeInterval:(self.minShowTime - interv) target:self + selector:@selector(handleMinShowTimer:) userInfo:nil repeats:NO]; + return; + } + } + // ... otherwise hide the HUD immediately + [self hideUsingAnimation:useAnimation]; +} + +- (void)hide:(BOOL)animated afterDelay:(NSTimeInterval)delay { + [self performSelector:@selector(hideDelayed:) withObject:[NSNumber numberWithBool:animated] afterDelay:delay]; +} + +- (void)hideDelayed:(NSNumber *)animated { + [self hide:[animated boolValue]]; +} + +#pragma mark - Timer callbacks + +- (void)handleGraceTimer:(NSTimer *)theTimer { + // Show the HUD only if the task is still running + if (taskInProgress) { + [self showUsingAnimation:useAnimation]; + } +} + +- (void)handleMinShowTimer:(NSTimer *)theTimer { + [self hideUsingAnimation:useAnimation]; +} + +#pragma mark - View Hierrarchy + +- (void)didMoveToSuperview { + [self updateForCurrentOrientationAnimated:NO]; +} + +#pragma mark - Internal show & hide operations + +- (void)showUsingAnimation:(BOOL)animated { + // Cancel any scheduled hideDelayed: calls + [NSObject cancelPreviousPerformRequestsWithTarget:self]; + [self setNeedsDisplay]; + + if (animated && animationType == MBProgressHUDAnimationZoomIn) { + self.transform = CGAffineTransformConcat(rotationTransform, CGAffineTransformMakeScale(0.5f, 0.5f)); + } else if (animated && animationType == MBProgressHUDAnimationZoomOut) { + self.transform = CGAffineTransformConcat(rotationTransform, CGAffineTransformMakeScale(1.5f, 1.5f)); + } + self.showStarted = [NSDate date]; + // Fade in + if (animated) { + [UIView beginAnimations:nil context:NULL]; + [UIView setAnimationDuration:0.30]; + self.alpha = 1.0f; + if (animationType == MBProgressHUDAnimationZoomIn || animationType == MBProgressHUDAnimationZoomOut) { + self.transform = rotationTransform; + } + [UIView commitAnimations]; + } + else { + self.alpha = 1.0f; + } +} + +- (void)hideUsingAnimation:(BOOL)animated { + // Fade out + if (animated && showStarted) { + [UIView beginAnimations:nil context:NULL]; + [UIView setAnimationDuration:0.30]; + [UIView setAnimationDelegate:self]; + [UIView setAnimationDidStopSelector:@selector(animationFinished:finished:context:)]; + // 0.02 prevents the hud from passing through touches during the animation the hud will get completely hidden + // in the done method + if (animationType == MBProgressHUDAnimationZoomIn) { + self.transform = CGAffineTransformConcat(rotationTransform, CGAffineTransformMakeScale(1.5f, 1.5f)); + } else if (animationType == MBProgressHUDAnimationZoomOut) { + self.transform = CGAffineTransformConcat(rotationTransform, CGAffineTransformMakeScale(0.5f, 0.5f)); + } + + self.alpha = 0.02f; + [UIView commitAnimations]; + } + else { + self.alpha = 0.0f; + [self done]; + } + self.showStarted = nil; +} + +- (void)animationFinished:(NSString *)animationID finished:(BOOL)finished context:(void*)context { + [self done]; +} + +- (void)done { + [NSObject cancelPreviousPerformRequestsWithTarget:self]; + isFinished = YES; + self.alpha = 0.0f; + if (removeFromSuperViewOnHide) { + [self removeFromSuperview]; + } +#if NS_BLOCKS_AVAILABLE + if (self.completionBlock) { + self.completionBlock(); + self.completionBlock = NULL; + } +#endif + if ([delegate respondsToSelector:@selector(hudWasHidden:)]) { + [delegate performSelector:@selector(hudWasHidden:) withObject:self]; + } +} + +#pragma mark - Threading + +- (void)showWhileExecuting:(SEL)method onTarget:(id)target withObject:(id)object animated:(BOOL)animated { + methodForExecution = method; + targetForExecution = MB_RETAIN(target); + objectForExecution = MB_RETAIN(object); + // Launch execution in new thread + self.taskInProgress = YES; + [NSThread detachNewThreadSelector:@selector(launchExecution) toTarget:self withObject:nil]; + // Show HUD view + [self show:animated]; +} + +#if NS_BLOCKS_AVAILABLE + +- (void)showAnimated:(BOOL)animated whileExecutingBlock:(dispatch_block_t)block { + dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); + [self showAnimated:animated whileExecutingBlock:block onQueue:queue completionBlock:NULL]; +} + +- (void)showAnimated:(BOOL)animated whileExecutingBlock:(dispatch_block_t)block completionBlock:(void (^)())completion { + dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); + [self showAnimated:animated whileExecutingBlock:block onQueue:queue completionBlock:completion]; +} + +- (void)showAnimated:(BOOL)animated whileExecutingBlock:(dispatch_block_t)block onQueue:(dispatch_queue_t)queue { + [self showAnimated:animated whileExecutingBlock:block onQueue:queue completionBlock:NULL]; +} + +- (void)showAnimated:(BOOL)animated whileExecutingBlock:(dispatch_block_t)block onQueue:(dispatch_queue_t)queue + completionBlock:(MBProgressHUDCompletionBlock)completion { + self.taskInProgress = YES; + self.completionBlock = completion; + dispatch_async(queue, ^(void) { + block(); + dispatch_async(dispatch_get_main_queue(), ^(void) { + [self cleanUp]; + }); + }); + [self show:animated]; +} + +#endif + +- (void)launchExecution { + @autoreleasepool { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Warc-performSelector-leaks" + // Start executing the requested task + [targetForExecution performSelector:methodForExecution withObject:objectForExecution]; +#pragma clang diagnostic pop + // Task completed, update view in main thread (note: view operations should + // be done only in the main thread) + [self performSelectorOnMainThread:@selector(cleanUp) withObject:nil waitUntilDone:NO]; + } +} + +- (void)cleanUp { + taskInProgress = NO; +#if !__has_feature(objc_arc) + [targetForExecution release]; + [objectForExecution release]; +#else + targetForExecution = nil; + objectForExecution = nil; +#endif + [self hide:useAnimation]; +} + +#pragma mark - UI + +- (void)setupLabels { + label = [[UILabel alloc] initWithFrame:self.bounds]; + label.adjustsFontSizeToFitWidth = NO; + label.textAlignment = MBLabelAlignmentCenter; + label.opaque = NO; + label.backgroundColor = [UIColor clearColor]; + label.textColor = self.labelColor; + label.font = self.labelFont; + label.text = self.labelText; + [self addSubview:label]; + + detailsLabel = [[UILabel alloc] initWithFrame:self.bounds]; + detailsLabel.font = self.detailsLabelFont; + detailsLabel.adjustsFontSizeToFitWidth = NO; + detailsLabel.textAlignment = MBLabelAlignmentCenter; + detailsLabel.opaque = NO; + detailsLabel.backgroundColor = [UIColor clearColor]; + detailsLabel.textColor = self.detailsLabelColor; + detailsLabel.numberOfLines = 0; + detailsLabel.font = self.detailsLabelFont; + detailsLabel.text = self.detailsLabelText; + [self addSubview:detailsLabel]; +} + +- (void)updateIndicators { + + BOOL isActivityIndicator = [indicator isKindOfClass:[UIActivityIndicatorView class]]; + BOOL isRoundIndicator = [indicator isKindOfClass:[MBRoundProgressView class]]; + + if (mode == MBProgressHUDModeIndeterminate) { + if (!isActivityIndicator) { + // Update to indeterminate indicator + [indicator removeFromSuperview]; + self.indicator = MB_AUTORELEASE([[UIActivityIndicatorView alloc] + initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]); + [(UIActivityIndicatorView *)indicator startAnimating]; + [self addSubview:indicator]; + } +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 50000 + [(UIActivityIndicatorView *)indicator setColor:self.activityIndicatorColor]; +#endif + } + else if (mode == MBProgressHUDModeDeterminateHorizontalBar) { + // Update to bar determinate indicator + [indicator removeFromSuperview]; + self.indicator = MB_AUTORELEASE([[MBBarProgressView alloc] init]); + [self addSubview:indicator]; + } + else if (mode == MBProgressHUDModeDeterminate || mode == MBProgressHUDModeAnnularDeterminate) { + if (!isRoundIndicator) { + // Update to determinante indicator + [indicator removeFromSuperview]; + self.indicator = MB_AUTORELEASE([[MBRoundProgressView alloc] init]); + [self addSubview:indicator]; + } + if (mode == MBProgressHUDModeAnnularDeterminate) { + [(MBRoundProgressView *)indicator setAnnular:YES]; + } + [(MBRoundProgressView *)indicator setProgressTintColor:self.activityIndicatorColor]; + [(MBRoundProgressView *)indicator setBackgroundTintColor:[self.activityIndicatorColor colorWithAlphaComponent:0.1f]]; + } + else if (mode == MBProgressHUDModeCustomView && customView != indicator) { + // Update custom view indicator + [indicator removeFromSuperview]; + self.indicator = customView; + [self addSubview:indicator]; + } else if (mode == MBProgressHUDModeText) { + [indicator removeFromSuperview]; + self.indicator = nil; + } +} + +#pragma mark - Layout + +- (void)layoutSubviews { + [super layoutSubviews]; + + // Entirely cover the parent view + UIView *parent = self.superview; + if (parent) { + self.frame = parent.bounds; + } + CGRect bounds = self.bounds; + + // Determine the total width and height needed + CGFloat maxWidth = bounds.size.width - 4 * margin; + CGSize totalSize = CGSizeZero; + + CGRect indicatorF = indicator.bounds; + indicatorF.size.width = MIN(indicatorF.size.width, maxWidth); + totalSize.width = MAX(totalSize.width, indicatorF.size.width); + totalSize.height += indicatorF.size.height; + + CGSize labelSize = MB_TEXTSIZE(label.text, label.font); + labelSize.width = MIN(labelSize.width, maxWidth); + totalSize.width = MAX(totalSize.width, labelSize.width); + totalSize.height += labelSize.height; + if (labelSize.height > 0.f && indicatorF.size.height > 0.f) { + totalSize.height += kPadding; + } + + CGFloat remainingHeight = bounds.size.height - totalSize.height - kPadding - 4 * margin; + CGSize maxSize = CGSizeMake(maxWidth, remainingHeight); + CGSize detailsLabelSize = MB_MULTILINE_TEXTSIZE(detailsLabel.text, detailsLabel.font, maxSize, detailsLabel.lineBreakMode); + totalSize.width = MAX(totalSize.width, detailsLabelSize.width); + totalSize.height += detailsLabelSize.height; + if (detailsLabelSize.height > 0.f && (indicatorF.size.height > 0.f || labelSize.height > 0.f)) { + totalSize.height += kPadding; + } + + totalSize.width += 2 * margin; + totalSize.height += 2 * margin; + + // Position elements + CGFloat yPos = round(((bounds.size.height - totalSize.height) / 2)) + margin + yOffset; + CGFloat xPos = xOffset; + indicatorF.origin.y = yPos; + indicatorF.origin.x = round((bounds.size.width - indicatorF.size.width) / 2) + xPos; + indicator.frame = indicatorF; + yPos += indicatorF.size.height; + + if (labelSize.height > 0.f && indicatorF.size.height > 0.f) { + yPos += kPadding; + } + CGRect labelF; + labelF.origin.y = yPos; + labelF.origin.x = round((bounds.size.width - labelSize.width) / 2) + xPos; + labelF.size = labelSize; + label.frame = labelF; + yPos += labelF.size.height; + + if (detailsLabelSize.height > 0.f && (indicatorF.size.height > 0.f || labelSize.height > 0.f)) { + yPos += kPadding; + } + CGRect detailsLabelF; + detailsLabelF.origin.y = yPos; + detailsLabelF.origin.x = round((bounds.size.width - detailsLabelSize.width) / 2) + xPos; + detailsLabelF.size = detailsLabelSize; + detailsLabel.frame = detailsLabelF; + + // Enforce minsize and quare rules + if (square) { + CGFloat max = MAX(totalSize.width, totalSize.height); + if (max <= bounds.size.width - 2 * margin) { + totalSize.width = max; + } + if (max <= bounds.size.height - 2 * margin) { + totalSize.height = max; + } + } + if (totalSize.width < minSize.width) { + totalSize.width = minSize.width; + } + if (totalSize.height < minSize.height) { + totalSize.height = minSize.height; + } + + size = totalSize; +} + +#pragma mark BG Drawing + +- (void)drawRect:(CGRect)rect { + + CGContextRef context = UIGraphicsGetCurrentContext(); + UIGraphicsPushContext(context); + + if (self.dimBackground) { + //Gradient colours + size_t gradLocationsNum = 2; + CGFloat gradLocations[2] = {0.0f, 1.0f}; + CGFloat gradColors[8] = {0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.75f}; + CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); + CGGradientRef gradient = CGGradientCreateWithColorComponents(colorSpace, gradColors, gradLocations, gradLocationsNum); + CGColorSpaceRelease(colorSpace); + //Gradient center + CGPoint gradCenter= CGPointMake(self.bounds.size.width/2, self.bounds.size.height/2); + //Gradient radius + float gradRadius = MIN(self.bounds.size.width , self.bounds.size.height) ; + //Gradient draw + CGContextDrawRadialGradient (context, gradient, gradCenter, + 0, gradCenter, gradRadius, + kCGGradientDrawsAfterEndLocation); + CGGradientRelease(gradient); + } + + // Set background rect color + if (self.color) { + CGContextSetFillColorWithColor(context, self.color.CGColor); + } else { + CGContextSetGrayFillColor(context, 0.0f, self.opacity); + } + + + // Center HUD + CGRect allRect = self.bounds; + // Draw rounded HUD backgroud rect + CGRect boxRect = CGRectMake(round((allRect.size.width - size.width) / 2) + self.xOffset, + round((allRect.size.height - size.height) / 2) + self.yOffset, size.width, size.height); + float radius = self.cornerRadius; + CGContextBeginPath(context); + CGContextMoveToPoint(context, CGRectGetMinX(boxRect) + radius, CGRectGetMinY(boxRect)); + CGContextAddArc(context, CGRectGetMaxX(boxRect) - radius, CGRectGetMinY(boxRect) + radius, radius, 3 * (float)M_PI / 2, 0, 0); + CGContextAddArc(context, CGRectGetMaxX(boxRect) - radius, CGRectGetMaxY(boxRect) - radius, radius, 0, (float)M_PI / 2, 0); + CGContextAddArc(context, CGRectGetMinX(boxRect) + radius, CGRectGetMaxY(boxRect) - radius, radius, (float)M_PI / 2, (float)M_PI, 0); + CGContextAddArc(context, CGRectGetMinX(boxRect) + radius, CGRectGetMinY(boxRect) + radius, radius, (float)M_PI, 3 * (float)M_PI / 2, 0); + CGContextClosePath(context); + CGContextFillPath(context); + + UIGraphicsPopContext(); +} + +#pragma mark - KVO + +- (void)registerForKVO { + for (NSString *keyPath in [self observableKeypaths]) { + [self addObserver:self forKeyPath:keyPath options:NSKeyValueObservingOptionNew context:NULL]; + } +} + +- (void)unregisterFromKVO { + for (NSString *keyPath in [self observableKeypaths]) { + [self removeObserver:self forKeyPath:keyPath]; + } +} + +- (NSArray *)observableKeypaths { + return [NSArray arrayWithObjects:@"mode", @"customView", @"labelText", @"labelFont", @"labelColor", + @"detailsLabelText", @"detailsLabelFont", @"detailsLabelColor", @"progress", @"activityIndicatorColor", nil]; +} + +- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { + if (![NSThread isMainThread]) { + [self performSelectorOnMainThread:@selector(updateUIForKeypath:) withObject:keyPath waitUntilDone:NO]; + } else { + [self updateUIForKeypath:keyPath]; + } +} + +- (void)updateUIForKeypath:(NSString *)keyPath { + if ([keyPath isEqualToString:@"mode"] || [keyPath isEqualToString:@"customView"] || + [keyPath isEqualToString:@"activityIndicatorColor"]) { + [self updateIndicators]; + } else if ([keyPath isEqualToString:@"labelText"]) { + label.text = self.labelText; + } else if ([keyPath isEqualToString:@"labelFont"]) { + label.font = self.labelFont; + } else if ([keyPath isEqualToString:@"labelColor"]) { + label.textColor = self.labelColor; + } else if ([keyPath isEqualToString:@"detailsLabelText"]) { + detailsLabel.text = self.detailsLabelText; + } else if ([keyPath isEqualToString:@"detailsLabelFont"]) { + detailsLabel.font = self.detailsLabelFont; + } else if ([keyPath isEqualToString:@"detailsLabelColor"]) { + detailsLabel.textColor = self.detailsLabelColor; + } else if ([keyPath isEqualToString:@"progress"]) { + if ([indicator respondsToSelector:@selector(setProgress:)]) { + [(id)indicator setValue:@(progress) forKey:@"progress"]; + } + return; + } + [self setNeedsLayout]; + [self setNeedsDisplay]; +} + +#pragma mark - Notifications + +- (void)registerForNotifications { +#if !TARGET_OS_TV + NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; + + [nc addObserver:self selector:@selector(statusBarOrientationDidChange:) + name:UIApplicationDidChangeStatusBarOrientationNotification object:nil]; +#endif +} + +- (void)unregisterFromNotifications { +#if !TARGET_OS_TV + NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; + [nc removeObserver:self name:UIApplicationDidChangeStatusBarOrientationNotification object:nil]; +#endif +} + +#if !TARGET_OS_TV +- (void)statusBarOrientationDidChange:(NSNotification *)notification { + UIView *superview = self.superview; + if (!superview) { + return; + } else { + [self updateForCurrentOrientationAnimated:YES]; + } +} +#endif + +- (void)updateForCurrentOrientationAnimated:(BOOL)animated { + // Stay in sync with the superview in any case + if (self.superview) { + self.bounds = self.superview.bounds; + [self setNeedsDisplay]; + } + + // Not needed on iOS 8+, compile out when the deployment target allows, + // to avoid sharedApplication problems on extension targets +#if __IPHONE_OS_VERSION_MIN_REQUIRED < 80000 + // Only needed pre iOS 7 when added to a window + BOOL iOS8OrLater = kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber_iOS_8_0; + if (iOS8OrLater || ![self.superview isKindOfClass:[UIWindow class]]) return; + + UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation; + CGFloat radians = 0; + if (UIInterfaceOrientationIsLandscape(orientation)) { + if (orientation == UIInterfaceOrientationLandscapeLeft) { radians = -(CGFloat)M_PI_2; } + else { radians = (CGFloat)M_PI_2; } + // Window coordinates differ! + self.bounds = CGRectMake(0, 0, self.bounds.size.height, self.bounds.size.width); + } else { + if (orientation == UIInterfaceOrientationPortraitUpsideDown) { radians = (CGFloat)M_PI; } + else { radians = 0; } + } + rotationTransform = CGAffineTransformMakeRotation(radians); + + if (animated) { + [UIView beginAnimations:nil context:nil]; + [UIView setAnimationDuration:0.3]; + } + [self setTransform:rotationTransform]; + if (animated) { + [UIView commitAnimations]; + } +#endif +} + +@end + + +@implementation MBRoundProgressView + +#pragma mark - Lifecycle + +- (id)init { + return [self initWithFrame:CGRectMake(0.f, 0.f, 37.f, 37.f)]; +} + +- (id)initWithFrame:(CGRect)frame { + self = [super initWithFrame:frame]; + if (self) { + self.backgroundColor = [UIColor clearColor]; + self.opaque = NO; + _progress = 0.f; + _annular = NO; + _progressTintColor = [[UIColor alloc] initWithWhite:1.f alpha:1.f]; + _backgroundTintColor = [[UIColor alloc] initWithWhite:1.f alpha:.1f]; + [self registerForKVO]; + } + return self; +} + +- (void)dealloc { + [self unregisterFromKVO]; +#if !__has_feature(objc_arc) + [_progressTintColor release]; + [_backgroundTintColor release]; + [super dealloc]; +#endif +} + +#pragma mark - Drawing + +- (void)drawRect:(CGRect)rect { + + CGRect allRect = self.bounds; + CGRect circleRect = CGRectInset(allRect, 2.0f, 2.0f); + CGContextRef context = UIGraphicsGetCurrentContext(); + + if (_annular) { + // Draw background + BOOL isPreiOS7 = kCFCoreFoundationVersionNumber < kCFCoreFoundationVersionNumber_iOS_7_0; + CGFloat lineWidth = isPreiOS7 ? 5.f : 2.f; + UIBezierPath *processBackgroundPath = [UIBezierPath bezierPath]; + processBackgroundPath.lineWidth = lineWidth; + processBackgroundPath.lineCapStyle = kCGLineCapButt; + CGPoint center = CGPointMake(self.bounds.size.width/2, self.bounds.size.height/2); + CGFloat radius = (self.bounds.size.width - lineWidth)/2; + CGFloat startAngle = - ((float)M_PI / 2); // 90 degrees + CGFloat endAngle = (2 * (float)M_PI) + startAngle; + [processBackgroundPath addArcWithCenter:center radius:radius startAngle:startAngle endAngle:endAngle clockwise:YES]; + [_backgroundTintColor set]; + [processBackgroundPath stroke]; + // Draw progress + UIBezierPath *processPath = [UIBezierPath bezierPath]; + processPath.lineCapStyle = isPreiOS7 ? kCGLineCapRound : kCGLineCapSquare; + processPath.lineWidth = lineWidth; + endAngle = (self.progress * 2 * (float)M_PI) + startAngle; + [processPath addArcWithCenter:center radius:radius startAngle:startAngle endAngle:endAngle clockwise:YES]; + [_progressTintColor set]; + [processPath stroke]; + } else { + // Draw background + [_progressTintColor setStroke]; + [_backgroundTintColor setFill]; + CGContextSetLineWidth(context, 2.0f); + CGContextFillEllipseInRect(context, circleRect); + CGContextStrokeEllipseInRect(context, circleRect); + // Draw progress + CGPoint center = CGPointMake(allRect.size.width / 2, allRect.size.height / 2); + CGFloat radius = (allRect.size.width - 4) / 2; + CGFloat startAngle = - ((float)M_PI / 2); // 90 degrees + CGFloat endAngle = (self.progress * 2 * (float)M_PI) + startAngle; + [_progressTintColor setFill]; + CGContextMoveToPoint(context, center.x, center.y); + CGContextAddArc(context, center.x, center.y, radius, startAngle, endAngle, 0); + CGContextClosePath(context); + CGContextFillPath(context); + } +} + +#pragma mark - KVO + +- (void)registerForKVO { + for (NSString *keyPath in [self observableKeypaths]) { + [self addObserver:self forKeyPath:keyPath options:NSKeyValueObservingOptionNew context:NULL]; + } +} + +- (void)unregisterFromKVO { + for (NSString *keyPath in [self observableKeypaths]) { + [self removeObserver:self forKeyPath:keyPath]; + } +} + +- (NSArray *)observableKeypaths { + return [NSArray arrayWithObjects:@"progressTintColor", @"backgroundTintColor", @"progress", @"annular", nil]; +} + +- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { + [self setNeedsDisplay]; +} + +@end + + +@implementation MBBarProgressView + +#pragma mark - Lifecycle + +- (id)init { + return [self initWithFrame:CGRectMake(.0f, .0f, 120.0f, 20.0f)]; +} + +- (id)initWithFrame:(CGRect)frame { + self = [super initWithFrame:frame]; + if (self) { + _progress = 0.f; + _lineColor = [UIColor whiteColor]; + _progressColor = [UIColor whiteColor]; + _progressRemainingColor = [UIColor clearColor]; + self.backgroundColor = [UIColor clearColor]; + self.opaque = NO; + [self registerForKVO]; + } + return self; +} + +- (void)dealloc { + [self unregisterFromKVO]; +#if !__has_feature(objc_arc) + [_lineColor release]; + [_progressColor release]; + [_progressRemainingColor release]; + [super dealloc]; +#endif +} + +#pragma mark - Drawing + +- (void)drawRect:(CGRect)rect { + CGContextRef context = UIGraphicsGetCurrentContext(); + + CGContextSetLineWidth(context, 2); + CGContextSetStrokeColorWithColor(context,[_lineColor CGColor]); + CGContextSetFillColorWithColor(context, [_progressRemainingColor CGColor]); + + // Draw background + float radius = (rect.size.height / 2) - 2; + CGContextMoveToPoint(context, 2, rect.size.height/2); + CGContextAddArcToPoint(context, 2, 2, radius + 2, 2, radius); + CGContextAddLineToPoint(context, rect.size.width - radius - 2, 2); + CGContextAddArcToPoint(context, rect.size.width - 2, 2, rect.size.width - 2, rect.size.height / 2, radius); + CGContextAddArcToPoint(context, rect.size.width - 2, rect.size.height - 2, rect.size.width - radius - 2, rect.size.height - 2, radius); + CGContextAddLineToPoint(context, radius + 2, rect.size.height - 2); + CGContextAddArcToPoint(context, 2, rect.size.height - 2, 2, rect.size.height/2, radius); + CGContextFillPath(context); + + // Draw border + CGContextMoveToPoint(context, 2, rect.size.height/2); + CGContextAddArcToPoint(context, 2, 2, radius + 2, 2, radius); + CGContextAddLineToPoint(context, rect.size.width - radius - 2, 2); + CGContextAddArcToPoint(context, rect.size.width - 2, 2, rect.size.width - 2, rect.size.height / 2, radius); + CGContextAddArcToPoint(context, rect.size.width - 2, rect.size.height - 2, rect.size.width - radius - 2, rect.size.height - 2, radius); + CGContextAddLineToPoint(context, radius + 2, rect.size.height - 2); + CGContextAddArcToPoint(context, 2, rect.size.height - 2, 2, rect.size.height/2, radius); + CGContextStrokePath(context); + + CGContextSetFillColorWithColor(context, [_progressColor CGColor]); + radius = radius - 2; + float amount = self.progress * rect.size.width; + + // Progress in the middle area + if (amount >= radius + 4 && amount <= (rect.size.width - radius - 4)) { + CGContextMoveToPoint(context, 4, rect.size.height/2); + CGContextAddArcToPoint(context, 4, 4, radius + 4, 4, radius); + CGContextAddLineToPoint(context, amount, 4); + CGContextAddLineToPoint(context, amount, radius + 4); + + CGContextMoveToPoint(context, 4, rect.size.height/2); + CGContextAddArcToPoint(context, 4, rect.size.height - 4, radius + 4, rect.size.height - 4, radius); + CGContextAddLineToPoint(context, amount, rect.size.height - 4); + CGContextAddLineToPoint(context, amount, radius + 4); + + CGContextFillPath(context); + } + + // Progress in the right arc + else if (amount > radius + 4) { + float x = amount - (rect.size.width - radius - 4); + + CGContextMoveToPoint(context, 4, rect.size.height/2); + CGContextAddArcToPoint(context, 4, 4, radius + 4, 4, radius); + CGContextAddLineToPoint(context, rect.size.width - radius - 4, 4); + float angle = -acos(x/radius); + if (isnan(angle)) angle = 0; + CGContextAddArc(context, rect.size.width - radius - 4, rect.size.height/2, radius, M_PI, angle, 0); + CGContextAddLineToPoint(context, amount, rect.size.height/2); + + CGContextMoveToPoint(context, 4, rect.size.height/2); + CGContextAddArcToPoint(context, 4, rect.size.height - 4, radius + 4, rect.size.height - 4, radius); + CGContextAddLineToPoint(context, rect.size.width - radius - 4, rect.size.height - 4); + angle = acos(x/radius); + if (isnan(angle)) angle = 0; + CGContextAddArc(context, rect.size.width - radius - 4, rect.size.height/2, radius, -M_PI, angle, 1); + CGContextAddLineToPoint(context, amount, rect.size.height/2); + + CGContextFillPath(context); + } + + // Progress is in the left arc + else if (amount < radius + 4 && amount > 0) { + CGContextMoveToPoint(context, 4, rect.size.height/2); + CGContextAddArcToPoint(context, 4, 4, radius + 4, 4, radius); + CGContextAddLineToPoint(context, radius + 4, rect.size.height/2); + + CGContextMoveToPoint(context, 4, rect.size.height/2); + CGContextAddArcToPoint(context, 4, rect.size.height - 4, radius + 4, rect.size.height - 4, radius); + CGContextAddLineToPoint(context, radius + 4, rect.size.height/2); + + CGContextFillPath(context); + } +} + +#pragma mark - KVO + +- (void)registerForKVO { + for (NSString *keyPath in [self observableKeypaths]) { + [self addObserver:self forKeyPath:keyPath options:NSKeyValueObservingOptionNew context:NULL]; + } +} + +- (void)unregisterFromKVO { + for (NSString *keyPath in [self observableKeypaths]) { + [self removeObserver:self forKeyPath:keyPath]; + } +} + +- (NSArray *)observableKeypaths { + return [NSArray arrayWithObjects:@"lineColor", @"progressRemainingColor", @"progressColor", @"progress", nil]; +} + +- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { + [self setNeedsDisplay]; +} + +@end diff --git a/Carthage/Checkouts/MBProgressHUD/MBProgressHUD.podspec b/Carthage/Checkouts/MBProgressHUD/MBProgressHUD.podspec new file mode 100644 index 000000000..afbd61087 --- /dev/null +++ b/Carthage/Checkouts/MBProgressHUD/MBProgressHUD.podspec @@ -0,0 +1,19 @@ +Pod::Spec.new do |s| + s.name = "MBProgressHUD" + s.version = "0.9.2" + s.summary = "An iOS activity indicator view." + s.description = <<-DESC + MBProgressHUD is an iOS drop-in class that displays a translucent HUD + with an indicator and/or labels while work is being done in a background thread. + The HUD is meant as a replacement for the undocumented, private UIKit UIProgressHUD + with some additional features. + DESC + s.homepage = "http://www.bukovinski.com" + s.license = { :type => 'MIT', :file => 'LICENSE' } + s.author = { 'Matej Bukovinski' => 'matej@bukovinski.com' } + s.source = { :git => "https://github.com/matej/MBProgressHUD.git", :tag => s.version.to_s } + s.platform = :ios + s.source_files = '*.{h,m}' + s.framework = "CoreGraphics" + s.requires_arc = true +end diff --git a/Carthage/Checkouts/MBProgressHUD/MBProgressHUD.xcodeproj/project.pbxproj b/Carthage/Checkouts/MBProgressHUD/MBProgressHUD.xcodeproj/project.pbxproj new file mode 100644 index 000000000..de6ce7448 --- /dev/null +++ b/Carthage/Checkouts/MBProgressHUD/MBProgressHUD.xcodeproj/project.pbxproj @@ -0,0 +1,412 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 1315DD7617804CBC0032507D /* MBProgressHUD.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = D286A7511518C70F00E13FB8 /* MBProgressHUD.h */; }; + 1D104D931ACA371400973364 /* MBProgressHUD.m in Sources */ = {isa = PBXBuildFile; fileRef = D286A7521518C70F00E13FB8 /* MBProgressHUD.m */; }; + 1D104D941ACA373100973364 /* MBProgressHUD.h in Headers */ = {isa = PBXBuildFile; fileRef = D286A7511518C70F00E13FB8 /* MBProgressHUD.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D286A74D1518C70F00E13FB8 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D286A74C1518C70F00E13FB8 /* Foundation.framework */; }; + D286A7531518C70F00E13FB8 /* MBProgressHUD.m in Sources */ = {isa = PBXBuildFile; fileRef = D286A7521518C70F00E13FB8 /* MBProgressHUD.m */; }; + D286A75E1518C89600E13FB8 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D286A75D1518C89600E13FB8 /* UIKit.framework */; }; + D286A76F1518CAAD00E13FB8 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D286A76E1518CAAD00E13FB8 /* CoreGraphics.framework */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 1315DD7517804C970032507D /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = "include/${PRODUCT_NAME}"; + dstSubfolderSpec = 16; + files = ( + 1315DD7617804CBC0032507D /* MBProgressHUD.h in CopyFiles */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 1315DD73178045000032507D /* MBProgressHUD-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MBProgressHUD-Prefix.pch"; sourceTree = SOURCE_ROOT; }; + 1D104D7A1ACA36CC00973364 /* MBProgressHUD.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MBProgressHUD.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 1D104D951ACA376200973364 /* Framework-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Framework-Info.plist"; sourceTree = SOURCE_ROOT; }; + D286A7491518C70F00E13FB8 /* libMBProgressHUD.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libMBProgressHUD.a; sourceTree = BUILT_PRODUCTS_DIR; }; + D286A74C1518C70F00E13FB8 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + D286A7511518C70F00E13FB8 /* MBProgressHUD.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MBProgressHUD.h; sourceTree = SOURCE_ROOT; }; + D286A7521518C70F00E13FB8 /* MBProgressHUD.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MBProgressHUD.m; sourceTree = SOURCE_ROOT; }; + D286A75D1518C89600E13FB8 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; + D286A76E1518CAAD00E13FB8 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 1D104D761ACA36CC00973364 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + D286A7461518C70F00E13FB8 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + D286A75E1518C89600E13FB8 /* UIKit.framework in Frameworks */, + D286A74D1518C70F00E13FB8 /* Foundation.framework in Frameworks */, + D286A76F1518CAAD00E13FB8 /* CoreGraphics.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 1315DD72178044770032507D /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 1D104D951ACA376200973364 /* Framework-Info.plist */, + 1315DD73178045000032507D /* MBProgressHUD-Prefix.pch */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + D286A73E1518C70E00E13FB8 = { + isa = PBXGroup; + children = ( + D286A74E1518C70F00E13FB8 /* MBProgressHUD */, + D286A74B1518C70F00E13FB8 /* Frameworks */, + D286A74A1518C70F00E13FB8 /* Products */, + ); + sourceTree = ""; + }; + D286A74A1518C70F00E13FB8 /* Products */ = { + isa = PBXGroup; + children = ( + D286A7491518C70F00E13FB8 /* libMBProgressHUD.a */, + 1D104D7A1ACA36CC00973364 /* MBProgressHUD.framework */, + ); + name = Products; + sourceTree = ""; + }; + D286A74B1518C70F00E13FB8 /* Frameworks */ = { + isa = PBXGroup; + children = ( + D286A75D1518C89600E13FB8 /* UIKit.framework */, + D286A74C1518C70F00E13FB8 /* Foundation.framework */, + D286A76E1518CAAD00E13FB8 /* CoreGraphics.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + D286A74E1518C70F00E13FB8 /* MBProgressHUD */ = { + isa = PBXGroup; + children = ( + D286A7511518C70F00E13FB8 /* MBProgressHUD.h */, + D286A7521518C70F00E13FB8 /* MBProgressHUD.m */, + 1315DD72178044770032507D /* Supporting Files */, + ); + path = MBProgressHUD; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + 1D104D771ACA36CC00973364 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 1D104D941ACA373100973364 /* MBProgressHUD.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + 1D104D791ACA36CC00973364 /* MBProgressHUD Framework */ = { + isa = PBXNativeTarget; + buildConfigurationList = 1D104D8D1ACA36CC00973364 /* Build configuration list for PBXNativeTarget "MBProgressHUD Framework" */; + buildPhases = ( + 1D104D751ACA36CC00973364 /* Sources */, + 1D104D761ACA36CC00973364 /* Frameworks */, + 1D104D771ACA36CC00973364 /* Headers */, + 1D104D781ACA36CC00973364 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "MBProgressHUD Framework"; + productName = "MBProgressHUD Framework"; + productReference = 1D104D7A1ACA36CC00973364 /* MBProgressHUD.framework */; + productType = "com.apple.product-type.framework"; + }; + D286A7481518C70F00E13FB8 /* MBProgressHUD Static Library */ = { + isa = PBXNativeTarget; + buildConfigurationList = D286A7561518C70F00E13FB8 /* Build configuration list for PBXNativeTarget "MBProgressHUD Static Library" */; + buildPhases = ( + D286A7451518C70F00E13FB8 /* Sources */, + D286A7461518C70F00E13FB8 /* Frameworks */, + 1315DD7517804C970032507D /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "MBProgressHUD Static Library"; + productName = MBProgressHUD; + productReference = D286A7491518C70F00E13FB8 /* libMBProgressHUD.a */; + productType = "com.apple.product-type.library.static"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + D286A7401518C70E00E13FB8 /* Project object */ = { + isa = PBXProject; + attributes = { + CLASSPREFIX = MB; + LastUpgradeCheck = 0630; + ORGANIZATIONNAME = "Matej Bukovinski"; + TargetAttributes = { + 1D104D791ACA36CC00973364 = { + CreatedOnToolsVersion = 6.2; + }; + }; + }; + buildConfigurationList = D286A7431518C70E00E13FB8 /* Build configuration list for PBXProject "MBProgressHUD" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = D286A73E1518C70E00E13FB8; + productRefGroup = D286A74A1518C70F00E13FB8 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + D286A7481518C70F00E13FB8 /* MBProgressHUD Static Library */, + 1D104D791ACA36CC00973364 /* MBProgressHUD Framework */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 1D104D781ACA36CC00973364 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 1D104D751ACA36CC00973364 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 1D104D931ACA371400973364 /* MBProgressHUD.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + D286A7451518C70F00E13FB8 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + D286A7531518C70F00E13FB8 /* MBProgressHUD.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 1D104D8E1ACA36CC00973364 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + CURRENT_PROJECT_VERSION = 1; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + INFOPLIST_FILE = "Framework-Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 8.2; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_ENABLE_DEBUG_INFO = YES; + PRODUCT_NAME = MBProgressHUD; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; + 1D104D8F1ACA36CC00973364 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 1; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_NS_ASSERTIONS = NO; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + INFOPLIST_FILE = "Framework-Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 8.2; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_ENABLE_DEBUG_INFO = NO; + PRODUCT_NAME = MBProgressHUD; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; + D286A7541518C70F00E13FB8 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 4.3; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + }; + name = Debug; + }; + D286A7551518C70F00E13FB8 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = YES; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 4.3; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + D286A7571518C70F00E13FB8 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + DSTROOT = /tmp/MBProgressHUD.dst; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "MBProgressHUD-Prefix.pch"; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = MBProgressHUD; + SKIP_INSTALL = YES; + }; + name = Debug; + }; + D286A7581518C70F00E13FB8 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + DSTROOT = /tmp/MBProgressHUD.dst; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "MBProgressHUD-Prefix.pch"; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = MBProgressHUD; + SKIP_INSTALL = YES; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 1D104D8D1ACA36CC00973364 /* Build configuration list for PBXNativeTarget "MBProgressHUD Framework" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1D104D8E1ACA36CC00973364 /* Debug */, + 1D104D8F1ACA36CC00973364 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + D286A7431518C70E00E13FB8 /* Build configuration list for PBXProject "MBProgressHUD" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + D286A7541518C70F00E13FB8 /* Debug */, + D286A7551518C70F00E13FB8 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + D286A7561518C70F00E13FB8 /* Build configuration list for PBXNativeTarget "MBProgressHUD Static Library" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + D286A7571518C70F00E13FB8 /* Debug */, + D286A7581518C70F00E13FB8 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = D286A7401518C70E00E13FB8 /* Project object */; +} diff --git a/Carthage/Checkouts/MBProgressHUD/MBProgressHUD.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Carthage/Checkouts/MBProgressHUD/MBProgressHUD.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 000000000..f137270bd --- /dev/null +++ b/Carthage/Checkouts/MBProgressHUD/MBProgressHUD.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Carthage/Checkouts/MBProgressHUD/MBProgressHUD.xcodeproj/xcshareddata/xcschemes/MBProgressHUD Framework.xcscheme b/Carthage/Checkouts/MBProgressHUD/MBProgressHUD.xcodeproj/xcshareddata/xcschemes/MBProgressHUD Framework.xcscheme new file mode 100644 index 000000000..4820e0310 --- /dev/null +++ b/Carthage/Checkouts/MBProgressHUD/MBProgressHUD.xcodeproj/xcshareddata/xcschemes/MBProgressHUD Framework.xcscheme @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Carthage/Checkouts/MBProgressHUD/MBProgressHUD.xcodeproj/xcshareddata/xcschemes/MBProgressHUD.xcscheme b/Carthage/Checkouts/MBProgressHUD/MBProgressHUD.xcodeproj/xcshareddata/xcschemes/MBProgressHUD.xcscheme new file mode 100644 index 000000000..e22b7ad4a --- /dev/null +++ b/Carthage/Checkouts/MBProgressHUD/MBProgressHUD.xcodeproj/xcshareddata/xcschemes/MBProgressHUD.xcscheme @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Carthage/Checkouts/MBProgressHUD/MBProgressHUD.xcworkspace/contents.xcworkspacedata b/Carthage/Checkouts/MBProgressHUD/MBProgressHUD.xcworkspace/contents.xcworkspacedata new file mode 100644 index 000000000..8356c0655 --- /dev/null +++ b/Carthage/Checkouts/MBProgressHUD/MBProgressHUD.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,19 @@ + + + + + + + + + + + + + diff --git a/Carthage/Checkouts/MBProgressHUD/README.mdown b/Carthage/Checkouts/MBProgressHUD/README.mdown new file mode 100644 index 000000000..df9675675 --- /dev/null +++ b/Carthage/Checkouts/MBProgressHUD/README.mdown @@ -0,0 +1,101 @@ +# MBProgressHUD [![Build Status](https://travis-ci.org/matej/MBProgressHUD.svg?branch=master)](https://travis-ci.org/matej/MBProgressHUD) + +MBProgressHUD is an iOS drop-in class that displays a translucent HUD with an indicator and/or labels while work is being done in a background thread. The HUD is meant as a replacement for the undocumented, private UIKit UIProgressHUD with some additional features. + +[![](http://dl.dropbox.com/u/378729/MBProgressHUD/1-thumb.png)](http://dl.dropbox.com/u/378729/MBProgressHUD/1.png) +[![](http://dl.dropbox.com/u/378729/MBProgressHUD/2-thumb.png)](http://dl.dropbox.com/u/378729/MBProgressHUD/2.png) +[![](http://dl.dropbox.com/u/378729/MBProgressHUD/3-thumb.png)](http://dl.dropbox.com/u/378729/MBProgressHUD/3.png) +[![](http://dl.dropbox.com/u/378729/MBProgressHUD/4-thumb.png)](http://dl.dropbox.com/u/378729/MBProgressHUD/4.png) +[![](http://dl.dropbox.com/u/378729/MBProgressHUD/5-thumb.png)](http://dl.dropbox.com/u/378729/MBProgressHUD/5.png) +[![](http://dl.dropbox.com/u/378729/MBProgressHUD/6-thumb.png)](http://dl.dropbox.com/u/378729/MBProgressHUD/6.png) +[![](http://dl.dropbox.com/u/378729/MBProgressHUD/7-thumb.png)](http://dl.dropbox.com/u/378729/MBProgressHUD/7.png) + +## Requirements + +MBProgressHUD works on any iOS version and is compatible with both ARC and non-ARC projects. It depends on the following Apple frameworks, which should already be included with most Xcode templates: + +* Foundation.framework +* UIKit.framework +* CoreGraphics.framework + +You will need the latest developer tools in order to build MBProgressHUD. Old Xcode versions might work, but compatibility will not be explicitly maintained. + +## Adding MBProgressHUD to your project + +### Cocoapods + +[CocoaPods](http://cocoapods.org) is the recommended way to add MBProgressHUD to your project. + +1. Add a pod entry for MBProgressHUD to your Podfile `pod 'MBProgressHUD', '~> 0.9.2'` +2. Install the pod(s) by running `pod install`. +3. Include MBProgressHUD wherever you need it with `#import "MBProgressHUD.h"`. + +### Source files + +Alternatively you can directly add the `MBProgressHUD.h` and `MBProgressHUD.m` source files to your project. + +1. Download the [latest code version](https://github.com/matej/MBProgressHUD/archive/master.zip) or add the repository as a git submodule to your git-tracked project. +2. Open your project in Xcode, then drag and drop `MBProgressHUD.h` and `MBProgressHUD.m` onto your project (use the "Product Navigator view"). Make sure to select Copy items when asked if you extracted the code archive outside of your project. +3. Include MBProgressHUD wherever you need it with `#import "MBProgressHUD.h"`. + +### Static library + +You can also add MBProgressHUD as a static library to your project or workspace. + +1. Download the [latest code version](https://github.com/matej/MBProgressHUD/downloads) or add the repository as a git submodule to your git-tracked project. +2. Open your project in Xcode, then drag and drop `MBProgressHUD.xcodeproj` onto your project or workspace (use the "Product Navigator view"). +3. Select your target and go to the Build phases tab. In the Link Binary With Libraries section select the add button. On the sheet find and add `libMBProgressHUD.a`. You might also need to add `MBProgressHUD` to the Target Dependencies list. +4. Include MBProgressHUD wherever you need it with `#import `. + +## Usage + +The main guideline you need to follow when dealing with MBProgressHUD while running long-running tasks is keeping the main thread work-free, so the UI can be updated promptly. The recommended way of using MBProgressHUD is therefore to set it up on the main thread and then spinning the task, that you want to perform, off onto a new thread. + +```objective-c +[MBProgressHUD showHUDAddedTo:self.view animated:YES]; +dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{ + // Do something... + dispatch_async(dispatch_get_main_queue(), ^{ + [MBProgressHUD hideHUDForView:self.view animated:YES]; + }); +}); +``` + +If you need to configure the HUD you can do this by using the MBProgressHUD reference that showHUDAddedTo:animated: returns. + +```objective-c +MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES]; +hud.mode = MBProgressHUDModeAnnularDeterminate; +hud.labelText = @"Loading"; +[self doSomethingInBackgroundWithProgressCallback:^(float progress) { + hud.progress = progress; +} completionCallback:^{ + [hud hide:YES]; +}]; +``` + +UI updates should always be done on the main thread. Some MBProgressHUD setters are however considered "thread safe" and can be called from background threads. Those also include `setMode:`, `setCustomView:`, `setLabelText:`, `setLabelFont:`, `setDetailsLabelText:`, `setDetailsLabelFont:` and `setProgress:`. + +If you need to run your long-running task in the main thread, you should perform it with a slight delay, so UIKit will have enough time to update the UI (i.e., draw the HUD) before you block the main thread with your task. + +```objective-c +[MBProgressHUD showHUDAddedTo:self.view animated:YES]; +dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, 0.01 * NSEC_PER_SEC); +dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ + // Do something... + [MBProgressHUD hideHUDForView:self.view animated:YES]; +}); +``` + +You should be aware that any HUD updates issued inside the above block won't be displayed until the block completes. + +For more examples, including how to use MBProgressHUD with asynchronous operations such as NSURLConnection, take a look at the bundled demo project. Extensive API documentation is provided in the header file (MBProgressHUD.h). + + +## License + +This code is distributed under the terms and conditions of the [MIT license](LICENSE). + +## Change-log + +A brief summary of each MBProgressHUD release can be found on the [wiki](https://github.com/matej/MBProgressHUD/wiki/Change-log). diff --git a/LICENSE b/LICENSE new file mode 100644 index 000000000..94a9ed024 --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/README.md b/README.md new file mode 100644 index 000000000..a9d332d76 --- /dev/null +++ b/README.md @@ -0,0 +1,37 @@ +# Audiobook-Player +Player made in Swift for your DRM-free audiobooks. + + + + +# Features +- Upload your DRM-free audiobooks to your phone via file sharing in iTunes +- Control audio playback from the lock screen or the control center +- Maintain progress of your audiobooks +- Delete uploaded books from the app + +# Upcoming features +- Jump to start of book button +- Mark book as finished button +- Load books from online services like Dropbox + +# Contributing +Pull requests regarding upcoming features (or bugs) are welcomed. Any suggestion or bug please open up an issue 👍 + +# Dependencies +Managed with [Carthage](https://github.com/Carthage/Carthage) +- [Chameleon](https://github.com/ViccAlexander/Chameleon) for colors +- [MBProgressHUD](https://github.com/jdg/MBProgressHUD) for loading wheels + +# Credits +- Large Play image made by [Vectors Market](http://www.flaticon.com/authors/vectors-market) from [www.flaticon.com](www.flaticon.com) +- Large Pause image made by [Vectors Market](http://www.flaticon.com/authors/vectors-market) from [www.flaticon.com](www.flaticon.com) +- Skip time image made by [Vaadin](http://www.flaticon.com/authors/vaadin) from [www.flaticon.com](www.flaticon.com) +- Small Play image made by [Madebyoliver](http://www.flaticon.com/authors/madebyoliver) from [www.flaticon.com](www.flaticon.com) +- Small Pause image made by [Hanan](http://www.flaticon.com/authors/hanan) from [www.flaticon.com](www.flaticon.com) +- Small Double right arrows image made by [Freepik](http://www.flaticon.com/authors/freepik) from [www.flaticon.com](www.flaticon.com) +- Book image (part of app icon) made by [Freepik](http://www.flaticon.com/authors/freepik) from [www.flaticon.com](www.flaticon.com) +- Speaker image (part of app icon) made by [Madebyoliver](http://www.flaticon.com/authors/madebyoliver) from [www.flaticon.com](www.flaticon.com) + +# License +Licensed under [GNU GPL v. 3.0](https://opensource.org/licenses/GPL-3.0). See `LICENSE` for details.