diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..97e46c8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,61 @@ +# Xcode +# +# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore + +## Build generated +build/ +DerivedData + +## Various settings +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata + +## Other +*.xccheckout +*.moved-aside +*.xcuserstate +*.xcscmblueprint + +## Obj-C/Swift specific +*.hmap +*.ipa + +# Swift Package Manager +# +# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. +# Packages/ +.build/ + +# CocoaPods +# +# We recommend against adding the Pods directory to your .gitignore. However +# you should judge for yourself, the pros and cons are mentioned at: +# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control +# +# Pods/ + +# Carthage +# +# Add this line if you want to avoid checking in source code from Carthage dependencies. +# Carthage/Checkouts + +Carthage/Build + +# fastlane +# +# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the +# screenshots whenever they are needed. +# For more information about the recommended setup visit: +# https://github.com/fastlane/fastlane/blob/master/docs/Gitignore.md + +fastlane/report.xml +fastlane/screenshots + +.DS_Store \ No newline at end of file diff --git a/.swift-version b/.swift-version new file mode 100644 index 0000000..f398a20 --- /dev/null +++ b/.swift-version @@ -0,0 +1 @@ +3.0 \ No newline at end of file diff --git a/Demo/Demo.xcodeproj/project.pbxproj b/Demo/Demo.xcodeproj/project.pbxproj new file mode 100644 index 0000000..236f493 --- /dev/null +++ b/Demo/Demo.xcodeproj/project.pbxproj @@ -0,0 +1,456 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + CF8CA6561E7D0EE70089C627 /* Volumizer.swift in Sources */ = {isa = PBXBuildFile; fileRef = CF8CA6551E7D0EE70089C627 /* Volumizer.swift */; }; + CFAB10541E7C139F00AA334B /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CFAB10531E7C139F00AA334B /* AppDelegate.swift */; }; + CFAB10561E7C139F00AA334B /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CFAB10551E7C139F00AA334B /* ViewController.swift */; }; + CFAB10591E7C139F00AA334B /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CFAB10571E7C139F00AA334B /* Main.storyboard */; }; + CFAB105B1E7C139F00AA334B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = CFAB105A1E7C139F00AA334B /* Assets.xcassets */; }; + CFAB105E1E7C139F00AA334B /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CFAB105C1E7C139F00AA334B /* LaunchScreen.storyboard */; }; + CFAB10691E7C139F00AA334B /* DemoUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CFAB10681E7C139F00AA334B /* DemoUITests.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + CFAB10651E7C139F00AA334B /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = CFAB10481E7C139F00AA334B /* Project object */; + proxyType = 1; + remoteGlobalIDString = CFAB104F1E7C139F00AA334B; + remoteInfo = Demo; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + CF8CA6541E7D0EE70089C627 /* Volumizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Volumizer.h; sourceTree = ""; }; + CF8CA6551E7D0EE70089C627 /* Volumizer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Volumizer.swift; sourceTree = ""; }; + CFAB10501E7C139F00AA334B /* Demo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Demo.app; sourceTree = BUILT_PRODUCTS_DIR; }; + CFAB10531E7C139F00AA334B /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + CFAB10551E7C139F00AA334B /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + CFAB10581E7C139F00AA334B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + CFAB105A1E7C139F00AA334B /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + CFAB105D1E7C139F00AA334B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + CFAB105F1E7C139F00AA334B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + CFAB10641E7C139F00AA334B /* DemoUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DemoUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + CFAB10681E7C139F00AA334B /* DemoUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DemoUITests.swift; sourceTree = ""; }; + CFAB106A1E7C139F00AA334B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + CFAB104D1E7C139F00AA334B /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + CFAB10611E7C139F00AA334B /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + CF8CA6531E7D0EA80089C627 /* Volumizer */ = { + isa = PBXGroup; + children = ( + CF8CA6541E7D0EE70089C627 /* Volumizer.h */, + CF8CA6551E7D0EE70089C627 /* Volumizer.swift */, + ); + name = Volumizer; + path = ../Volumizer; + sourceTree = ""; + }; + CFAB10471E7C139F00AA334B = { + isa = PBXGroup; + children = ( + CF8CA6531E7D0EA80089C627 /* Volumizer */, + CFAB10521E7C139F00AA334B /* Demo */, + CFAB10671E7C139F00AA334B /* DemoUITests */, + CFAB10511E7C139F00AA334B /* Products */, + ); + sourceTree = ""; + }; + CFAB10511E7C139F00AA334B /* Products */ = { + isa = PBXGroup; + children = ( + CFAB10501E7C139F00AA334B /* Demo.app */, + CFAB10641E7C139F00AA334B /* DemoUITests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + CFAB10521E7C139F00AA334B /* Demo */ = { + isa = PBXGroup; + children = ( + CFAB10531E7C139F00AA334B /* AppDelegate.swift */, + CFAB10551E7C139F00AA334B /* ViewController.swift */, + CFAB10571E7C139F00AA334B /* Main.storyboard */, + CFAB105A1E7C139F00AA334B /* Assets.xcassets */, + CFAB105C1E7C139F00AA334B /* LaunchScreen.storyboard */, + CFAB105F1E7C139F00AA334B /* Info.plist */, + ); + path = Demo; + sourceTree = ""; + }; + CFAB10671E7C139F00AA334B /* DemoUITests */ = { + isa = PBXGroup; + children = ( + CFAB10681E7C139F00AA334B /* DemoUITests.swift */, + CFAB106A1E7C139F00AA334B /* Info.plist */, + ); + path = DemoUITests; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + CFAB104F1E7C139F00AA334B /* Demo */ = { + isa = PBXNativeTarget; + buildConfigurationList = CFAB106D1E7C139F00AA334B /* Build configuration list for PBXNativeTarget "Demo" */; + buildPhases = ( + CFAB104C1E7C139F00AA334B /* Sources */, + CFAB104D1E7C139F00AA334B /* Frameworks */, + CFAB104E1E7C139F00AA334B /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Demo; + productName = Demo; + productReference = CFAB10501E7C139F00AA334B /* Demo.app */; + productType = "com.apple.product-type.application"; + }; + CFAB10631E7C139F00AA334B /* DemoUITests */ = { + isa = PBXNativeTarget; + buildConfigurationList = CFAB10701E7C139F00AA334B /* Build configuration list for PBXNativeTarget "DemoUITests" */; + buildPhases = ( + CFAB10601E7C139F00AA334B /* Sources */, + CFAB10611E7C139F00AA334B /* Frameworks */, + CFAB10621E7C139F00AA334B /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + CFAB10661E7C139F00AA334B /* PBXTargetDependency */, + ); + name = DemoUITests; + productName = DemoUITests; + productReference = CFAB10641E7C139F00AA334B /* DemoUITests.xctest */; + productType = "com.apple.product-type.bundle.ui-testing"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + CFAB10481E7C139F00AA334B /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0820; + LastUpgradeCheck = 0820; + ORGANIZATIONNAME = "Fumitaka Watanabe"; + TargetAttributes = { + CFAB104F1E7C139F00AA334B = { + CreatedOnToolsVersion = 8.2.1; + DevelopmentTeam = Z28NN9BU8E; + ProvisioningStyle = Automatic; + }; + CFAB10631E7C139F00AA334B = { + CreatedOnToolsVersion = 8.2.1; + DevelopmentTeam = BX6C4637JV; + ProvisioningStyle = Automatic; + TestTargetID = CFAB104F1E7C139F00AA334B; + }; + }; + }; + buildConfigurationList = CFAB104B1E7C139F00AA334B /* Build configuration list for PBXProject "Demo" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = CFAB10471E7C139F00AA334B; + productRefGroup = CFAB10511E7C139F00AA334B /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + CFAB104F1E7C139F00AA334B /* Demo */, + CFAB10631E7C139F00AA334B /* DemoUITests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + CFAB104E1E7C139F00AA334B /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + CFAB105E1E7C139F00AA334B /* LaunchScreen.storyboard in Resources */, + CFAB105B1E7C139F00AA334B /* Assets.xcassets in Resources */, + CFAB10591E7C139F00AA334B /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + CFAB10621E7C139F00AA334B /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + CFAB104C1E7C139F00AA334B /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + CF8CA6561E7D0EE70089C627 /* Volumizer.swift in Sources */, + CFAB10561E7C139F00AA334B /* ViewController.swift in Sources */, + CFAB10541E7C139F00AA334B /* AppDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + CFAB10601E7C139F00AA334B /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + CFAB10691E7C139F00AA334B /* DemoUITests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + CFAB10661E7C139F00AA334B /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = CFAB104F1E7C139F00AA334B /* Demo */; + targetProxy = CFAB10651E7C139F00AA334B /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + CFAB10571E7C139F00AA334B /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + CFAB10581E7C139F00AA334B /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + CFAB105C1E7C139F00AA334B /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + CFAB105D1E7C139F00AA334B /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + CFAB106B1E7C139F00AA334B /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = 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_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 10.2; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + CFAB106C1E7C139F00AA334B /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 10.2; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + CFAB106E1E7C139F00AA334B /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + DEVELOPMENT_TEAM = Z28NN9BU8E; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Demo", + ); + INFOPLIST_FILE = Demo/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.fxwx23.Demo; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; + }; + name = Debug; + }; + CFAB106F1E7C139F00AA334B /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + DEVELOPMENT_TEAM = Z28NN9BU8E; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Demo", + ); + INFOPLIST_FILE = Demo/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.fxwx23.Demo; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; + }; + name = Release; + }; + CFAB10711E7C139F00AA334B /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + DEVELOPMENT_TEAM = BX6C4637JV; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Demo", + ); + INFOPLIST_FILE = DemoUITests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.fxwx23.DemoUITests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; + TEST_TARGET_NAME = Demo; + }; + name = Debug; + }; + CFAB10721E7C139F00AA334B /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + DEVELOPMENT_TEAM = BX6C4637JV; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Demo", + ); + INFOPLIST_FILE = DemoUITests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.fxwx23.DemoUITests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; + TEST_TARGET_NAME = Demo; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + CFAB104B1E7C139F00AA334B /* Build configuration list for PBXProject "Demo" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + CFAB106B1E7C139F00AA334B /* Debug */, + CFAB106C1E7C139F00AA334B /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + CFAB106D1E7C139F00AA334B /* Build configuration list for PBXNativeTarget "Demo" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + CFAB106E1E7C139F00AA334B /* Debug */, + CFAB106F1E7C139F00AA334B /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + CFAB10701E7C139F00AA334B /* Build configuration list for PBXNativeTarget "DemoUITests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + CFAB10711E7C139F00AA334B /* Debug */, + CFAB10721E7C139F00AA334B /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = CFAB10481E7C139F00AA334B /* Project object */; +} diff --git a/Demo/Demo.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Demo/Demo.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..02a6973 --- /dev/null +++ b/Demo/Demo.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Demo/Demo/AppDelegate.swift b/Demo/Demo/AppDelegate.swift new file mode 100644 index 0000000..d005e70 --- /dev/null +++ b/Demo/Demo/AppDelegate.swift @@ -0,0 +1,47 @@ +// +// AppDelegate.swift +// Demo +// +// Created by Fumitaka Watanabe on 2017/03/17. +// Copyright © 2017年 Fumitaka Watanabe. All rights reserved. +// + +import UIKit + +@UIApplicationMain +class AppDelegate: UIResponder, UIApplicationDelegate { + + var window: UIWindow? + var volumizer: Volumizer? + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { + // Override point for customization after application launch. + + return true + } + + func applicationWillResignActive(_ application: UIApplication) { + // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. + } + + func applicationDidEnterBackground(_ application: UIApplication) { + // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. + } + + func applicationWillEnterForeground(_ application: UIApplication) { + // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. + } + + func applicationDidBecomeActive(_ application: UIApplication) { + // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. + } + + func applicationWillTerminate(_ application: UIApplication) { + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. + } + + +} + diff --git a/Demo/Demo/Assets.xcassets/AppIcon.appiconset/Contents.json b/Demo/Demo/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..118c98f --- /dev/null +++ b/Demo/Demo/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,38 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Demo/Demo/Base.lproj/LaunchScreen.storyboard b/Demo/Demo/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..fdf3f97 --- /dev/null +++ b/Demo/Demo/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Demo/Demo/Base.lproj/Main.storyboard b/Demo/Demo/Base.lproj/Main.storyboard new file mode 100644 index 0000000..a3be09f --- /dev/null +++ b/Demo/Demo/Base.lproj/Main.storyboard @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Demo/Demo/Info.plist b/Demo/Demo/Info.plist new file mode 100644 index 0000000..8dcaeae --- /dev/null +++ b/Demo/Demo/Info.plist @@ -0,0 +1,40 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + NSCameraUsageDescription + Necessary for using camera function. + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/Demo/Demo/ViewController.swift b/Demo/Demo/ViewController.swift new file mode 100644 index 0000000..a6aa685 --- /dev/null +++ b/Demo/Demo/ViewController.swift @@ -0,0 +1,60 @@ +// +// ViewController.swift +// Demo +// +// Created by Fumitaka Watanabe on 2017/03/17. +// Copyright © 2017年 Fumitaka Watanabe. All rights reserved. +// + +import UIKit + +class ViewController: UIViewController{ + + @IBOutlet weak var textField: UITextField! + var imagePicler: UIImagePickerController? + var volumizer: Volumizer? + let defaultOptions: [VolumizerAppearanceOption] = [ .oberlayIsTranslucent(true), + .overlayBackgroundBlurEffectStyle( .extraLight), + .overlayBackgroundColor( .white), + .sliderProgressTintColor( .black)] + + override func viewDidLoad() { + super.viewDidLoad() + // Do any additional setup after loading the view, typically from a nib. + + let toolbar = UIToolbar(frame:CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 40)) + let space = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target:nil, action: nil) + let doneButton = UIBarButtonItem(title: "close", style: .done, target: self, action: #selector(resignKeyboard(sender:))) + toolbar.setItems([space, doneButton], animated: true) + textField?.inputAccessoryView = toolbar + + volumizer = Volumizer.configure(defaultOptions) + } + + override func viewWillAppear(_ animated: Bool) { + guard let volumizer = volumizer else { return } + volumizer.update(options: defaultOptions) + } + + override func didReceiveMemoryWarning() { + super.didReceiveMemoryWarning() + // Dispose of any resources that can be recreated. + } + + // MARK: Actions + + func resignKeyboard(sender: UIBarButtonItem) { + textField?.resignFirstResponder() + } + + // MARK: IB Actions + + @IBAction func showAnAlertButtonTapped(_ sender: Any) { + let alert = UIAlertController(title: "Title", message: "Message", preferredStyle: .alert) + let closeAction = UIAlertAction(title: "Close", style: .default, handler: nil) + alert.addAction(closeAction) + + present(alert, animated: true, completion: nil) + } +} + diff --git a/Demo/DemoUITests/DemoUITests.swift b/Demo/DemoUITests/DemoUITests.swift new file mode 100644 index 0000000..97ec363 --- /dev/null +++ b/Demo/DemoUITests/DemoUITests.swift @@ -0,0 +1,36 @@ +// +// DemoUITests.swift +// DemoUITests +// +// Created by Fumitaka Watanabe on 2017/03/17. +// Copyright © 2017年 Fumitaka Watanabe. All rights reserved. +// + +import XCTest + +class DemoUITests: XCTestCase { + + override func setUp() { + super.setUp() + + // Put setup code here. This method is called before the invocation of each test method in the class. + + // In UI tests it is usually best to stop immediately when a failure occurs. + continueAfterFailure = false + // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. + XCUIApplication().launch() + + // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. + } + + override func tearDown() { + // Put teardown code here. This method is called after the invocation of each test method in the class. + super.tearDown() + } + + func testExample() { + // Use recording to get started writing UI tests. + // Use XCTAssert and related functions to verify your tests produce the correct results. + } + +} diff --git a/Demo/DemoUITests/Info.plist b/Demo/DemoUITests/Info.plist new file mode 100644 index 0000000..6c6c23c --- /dev/null +++ b/Demo/DemoUITests/Info.plist @@ -0,0 +1,22 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + diff --git a/Readme.md b/Readme.md new file mode 100644 index 0000000..ea9318f --- /dev/null +++ b/Readme.md @@ -0,0 +1,73 @@ +# Volumizer + [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](CONTRIBUTING.md#pull-requests) [![Language](https://img.shields.io/badge/language-swift-orange.svg?style=flat)](https://developer.apple.com/swift) + +`Volumizer` replaces the system volume popup with a simple progress bar. + +### Features + +- Swift3 +- Hide the system volume HUD typically displayed on volume button presses +- Show a simple progress bar like Instagram's iOS app does +- Well easy to customize appearance +- Only support `portrait` mode. + +## Installation + +##### CocoaPods +[CocoaPods](https://cocoapods.org) 0.36 adds supports for Swift and embedded frameworks. To integrate Volumizer into your project add the following to your `Podfile`: + +```ruby +platform :ios, '8.0' +use_frameworks! + +pod 'Volumizer' +``` +##### Carthage +Add the following to your `Cartfile` and follow [these instructions](https://github.com/Carthage/Carthage#adding-frameworks-to-an-application) + +``` +github "fxwx23/Voumizer" +``` + +##### Manually +Drag the `Volumizer` folder into your project and link the `MediaPlayer` and `AVFoundation` frameworks to your project. + + +## Usage +Use of `Volumizer` is a simple way with one line. Just call `configure()` after set a window at least. + +```swift +Volumizer.configure() +``` + +You can customize the bar's appearance with `VolumizerAppearanceOption`. + +```swift +/** +public enum VolumizerAppearanceOption { + case oberlayIsTranslucent(Bool) default is `true`. + case overlayBackgroundBlurEffectStyle(UIBlurEffectStyle) default is `.extraLight`. + case overlayBackgroundColor(UIColor) default is `.white`. + case sliderProgressTintColor(UIColor) default is `.black`. + case sliderTrackTintColor(UIColor) default is `.lightGray.withAlphaComponent(0.5)` +} +*/ + +let options: [VolumizerAppearanceOption] = [ .oberlayIsTranslucent(true), + .overlayBackgroundBlurEffect( .extraLight), + .overlayBackgroundColor( .white), + .sliderProgressTintColor( .black)] + +let volumizer = Volumizer.configure(options) + +/// To change options based on view's current appearance, call `update(options:_)` . +volumizer.update(options: otherOptions) +``` +If you want to release `volumizer` 's window, please call `resign()`. Once you released, the system volume popup will be shown again. + +```swift +volumizer.resgin() +``` + +## License +This project is under the MIT license. \ No newline at end of file diff --git a/Volumizer.xcodeproj/project.pbxproj b/Volumizer.xcodeproj/project.pbxproj new file mode 100644 index 0000000..6bc58d5 --- /dev/null +++ b/Volumizer.xcodeproj/project.pbxproj @@ -0,0 +1,326 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + CF95D34C1E7ABA2E00DD75DD /* Volumizer.swift in Sources */ = {isa = PBXBuildFile; fileRef = CF95D34B1E7ABA2E00DD75DD /* Volumizer.swift */; }; + CF95D34F1E7ABA4B00DD75DD /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CF95D34E1E7ABA4B00DD75DD /* AVFoundation.framework */; }; + CF95D3511E7ABA6C00DD75DD /* MediaPlayer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CF95D3501E7ABA6C00DD75DD /* MediaPlayer.framework */; }; + CFF0C9ED1E75366C00762C9E /* Volumizer.h in Headers */ = {isa = PBXBuildFile; fileRef = CFF0C9EB1E75366C00762C9E /* Volumizer.h */; settings = {ATTRIBUTES = (Public, ); }; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + CF95D34B1E7ABA2E00DD75DD /* Volumizer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Volumizer.swift; sourceTree = ""; }; + CF95D34E1E7ABA4B00DD75DD /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; }; + CF95D3501E7ABA6C00DD75DD /* MediaPlayer.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MediaPlayer.framework; path = System/Library/Frameworks/MediaPlayer.framework; sourceTree = SDKROOT; }; + CFF0C9E81E75366C00762C9E /* Volumizer.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Volumizer.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + CFF0C9EB1E75366C00762C9E /* Volumizer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Volumizer.h; sourceTree = ""; }; + CFF0C9EC1E75366C00762C9E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + CFF0C9E41E75366C00762C9E /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + CF95D3511E7ABA6C00DD75DD /* MediaPlayer.framework in Frameworks */, + CF95D34F1E7ABA4B00DD75DD /* AVFoundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + CF95D34D1E7ABA4A00DD75DD /* Frameworks */ = { + isa = PBXGroup; + children = ( + CF95D3501E7ABA6C00DD75DD /* MediaPlayer.framework */, + CF95D34E1E7ABA4B00DD75DD /* AVFoundation.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + CFF0C9DE1E75366C00762C9E = { + isa = PBXGroup; + children = ( + CFF0C9EA1E75366C00762C9E /* Volumizer */, + CFF0C9E91E75366C00762C9E /* Products */, + CF95D34D1E7ABA4A00DD75DD /* Frameworks */, + ); + sourceTree = ""; + }; + CFF0C9E91E75366C00762C9E /* Products */ = { + isa = PBXGroup; + children = ( + CFF0C9E81E75366C00762C9E /* Volumizer.framework */, + ); + name = Products; + sourceTree = ""; + }; + CFF0C9EA1E75366C00762C9E /* Volumizer */ = { + isa = PBXGroup; + children = ( + CFF0C9EC1E75366C00762C9E /* Info.plist */, + CFF0C9EB1E75366C00762C9E /* Volumizer.h */, + CF95D34B1E7ABA2E00DD75DD /* Volumizer.swift */, + ); + path = Volumizer; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + CFF0C9E51E75366C00762C9E /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + CFF0C9ED1E75366C00762C9E /* Volumizer.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + CFF0C9E71E75366C00762C9E /* Volumizer */ = { + isa = PBXNativeTarget; + buildConfigurationList = CFF0C9F01E75366C00762C9E /* Build configuration list for PBXNativeTarget "Volumizer" */; + buildPhases = ( + CFF0C9E31E75366C00762C9E /* Sources */, + CFF0C9E41E75366C00762C9E /* Frameworks */, + CFF0C9E51E75366C00762C9E /* Headers */, + CFF0C9E61E75366C00762C9E /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Volumizer; + productName = Volumizer; + productReference = CFF0C9E81E75366C00762C9E /* Volumizer.framework */; + productType = "com.apple.product-type.framework"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + CFF0C9DF1E75366C00762C9E /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0820; + ORGANIZATIONNAME = "Fumitaka Watanabe"; + TargetAttributes = { + CFF0C9E71E75366C00762C9E = { + CreatedOnToolsVersion = 8.2.1; + DevelopmentTeam = BX6C4637JV; + LastSwiftMigration = 0820; + ProvisioningStyle = Automatic; + }; + }; + }; + buildConfigurationList = CFF0C9E21E75366C00762C9E /* Build configuration list for PBXProject "Volumizer" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = CFF0C9DE1E75366C00762C9E; + productRefGroup = CFF0C9E91E75366C00762C9E /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + CFF0C9E71E75366C00762C9E /* Volumizer */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + CFF0C9E61E75366C00762C9E /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + CFF0C9E31E75366C00762C9E /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + CF95D34C1E7ABA2E00DD75DD /* Volumizer.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + CFF0C9EE1E75366C00762C9E /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = 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_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; + CFF0C9EF1E75366C00762C9E /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; + CFF0C9F11E75366C00762C9E /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_IDENTITY = ""; + DEFINES_MODULE = YES; + DEVELOPMENT_TEAM = BX6C4637JV; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + INFOPLIST_FILE = Volumizer/Info.plist; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.fxwx23.Volumizer; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 3.0; + }; + name = Debug; + }; + CFF0C9F21E75366C00762C9E /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_IDENTITY = ""; + DEFINES_MODULE = YES; + DEVELOPMENT_TEAM = BX6C4637JV; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + INFOPLIST_FILE = Volumizer/Info.plist; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.fxwx23.Volumizer; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + SWIFT_VERSION = 3.0; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + CFF0C9E21E75366C00762C9E /* Build configuration list for PBXProject "Volumizer" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + CFF0C9EE1E75366C00762C9E /* Debug */, + CFF0C9EF1E75366C00762C9E /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + CFF0C9F01E75366C00762C9E /* Build configuration list for PBXNativeTarget "Volumizer" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + CFF0C9F11E75366C00762C9E /* Debug */, + CFF0C9F21E75366C00762C9E /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = CFF0C9DF1E75366C00762C9E /* Project object */; +} diff --git a/Volumizer.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Volumizer.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..af41820 --- /dev/null +++ b/Volumizer.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Volumizer.xcodeproj/xcshareddata/xcschemes/Volumizer.xcscheme b/Volumizer.xcodeproj/xcshareddata/xcschemes/Volumizer.xcscheme new file mode 100644 index 0000000..9baf3f3 --- /dev/null +++ b/Volumizer.xcodeproj/xcshareddata/xcschemes/Volumizer.xcscheme @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Volumizer/Info.plist b/Volumizer/Info.plist new file mode 100644 index 0000000..fbe1e6b --- /dev/null +++ b/Volumizer/Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleVersion + $(CURRENT_PROJECT_VERSION) + NSPrincipalClass + + + diff --git a/Volumizer/Volumizer.h b/Volumizer/Volumizer.h new file mode 100644 index 0000000..93991e6 --- /dev/null +++ b/Volumizer/Volumizer.h @@ -0,0 +1,19 @@ +// +// Volumizer.h +// Volumizer +// +// Created by Fumitaka Watanabe on 2017/03/12. +// Copyright © 2017年 Fumitaka Watanabe. All rights reserved. +// + +#import + +//! Project version number for Volumizer. +FOUNDATION_EXPORT double VolumizerVersionNumber; + +//! Project version string for Volumizer. +FOUNDATION_EXPORT const unsigned char VolumizerVersionString[]; + +// In this header, you should import all the public headers of your framework using statements like #import + + diff --git a/Volumizer/Volumizer.swift b/Volumizer/Volumizer.swift new file mode 100644 index 0000000..241e016 --- /dev/null +++ b/Volumizer/Volumizer.swift @@ -0,0 +1,260 @@ +// +// Volumizer.swift +// Volumizer +// +// Created by Fumitaka Watanabe on 2017/03/16. +// Copyright © 2017年 Fumitaka Watanabe. All rights reserved. +// + +import Foundation +import AVFoundation +import MediaPlayer + +fileprivate let AVAudioSessionOutputVolumeKey = "outputVolume" + +/** + Errors being thrown by `VolumizerError`. + - disableToChangeVolumeLevel: `Volumizer` was unable to change audio level + */ +public enum VolumizerError: Error { + case disableToChangeVolumeLevel +} + +/** + VolumizerAppearanceOption + */ +public enum VolumizerAppearanceOption { + case oberlayIsTranslucent(Bool) + case overlayBackgroundBlurEffectStyle(UIBlurEffectStyle) + case overlayBackgroundColor(UIColor) + case sliderProgressTintColor(UIColor) + case sliderTrackTintColor(UIColor) +} + +/** + - Volumizer + Replace default `MPVolumeView` by volumizer. + */ +open class Volumizer: UIView { + // MARK: Properties + // current volume value. + public fileprivate(set) var volume: Float = 0 + + private let session = AVAudioSession.sharedInstance() + private let volumeView = MPVolumeView(frame: CGRect.zero) + private let overlay = UIView() + private var overlayBlur = UIVisualEffectView() + private var slider = UIProgressView() + private var base: UIWindow? + private var isAppActive = false + private var isAlreadyWindowLevelAboveNormal = false + + // MARK: Initializations + + public convenience init(options: [VolumizerAppearanceOption], base: UIWindow) { + /// default width + self.init(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.height, height: 20.0)) + self.base = base + isAppActive = true + setupSession(options) + } + + override private init(frame: CGRect) { + super.init(frame: frame) + overlay.frame = frame + } + + required public init() { + fatalError("Please use the convenience initializer `init(options:_, base:_)` instead") + } + + required public init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + deinit { + session.removeObserver(self, forKeyPath: AVAudioSessionOutputVolumeKey, context: nil) + NotificationCenter.default.removeObserver(self) + } + + // MARK: Layout + + open override func layoutSubviews() { + super.layoutSubviews() + base?.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 20.0) + overlay.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 20.0) + + let side: CGFloat = 8.0 + slider.frame = CGRect(x: side, + y: (overlay.frame.height - slider.frame.height) / 2, + width: overlay.frame.width - (side * 2), + height: slider.frame.height) + + overlayBlur.frame = overlay.bounds + } + + // MARK: Convenience + + open class func configure(_ options: [VolumizerAppearanceOption]) -> Volumizer { + let base = UIWindow(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.height, height: 20.0)) + base.windowLevel = UIWindowLevelStatusBar + 1.0 + + let instance = Volumizer(options: options, base: base) + base.addSubview(instance) + base.makeKeyAndVisible() + + return instance + } + + open func update(options: [VolumizerAppearanceOption]) { + options.forEach { + switch $0 { + case .oberlayIsTranslucent(let isTranslucent): + if isTranslucent { + overlayBlur.isHidden = false + } + else { + overlayBlur.isHidden = true + } + case .overlayBackgroundBlurEffectStyle(let style): + overlayBlur.effect = UIBlurEffect(style: style) + case .overlayBackgroundColor(let color): + overlay.backgroundColor = color + case .sliderProgressTintColor(let color): + slider.progressTintColor = color + case .sliderTrackTintColor(let color): + slider.trackTintColor = color + } + } + } + + open func resign() { + base?.resignKey() + base = nil + } + + // MARK: Private + + private func setupSession(_ options: [VolumizerAppearanceOption]) { + do { + try session.setActive(true) + } catch { + NSLog("Unable to initialize AVAudioSession") + } + + update(volume: session.outputVolume, animated: false) + + backgroundColor = .white + + volumeView.setVolumeThumbImage(UIImage(), for: UIControlState()) + volumeView.isUserInteractionEnabled = false + volumeView.showsRouteButton = false + addSubview(volumeView) + + /// overlay's `backgroundColor` is white by default. + overlay.backgroundColor = .white + overlayBlur = UIVisualEffectView(effect: UIBlurEffect(style: .extraLight)) + overlayBlur.frame = overlay.bounds + addSubview(overlay) + overlay.addSubview(overlayBlur) + + /// slider's `thumbTintColor` is black by default. + slider.backgroundColor = .white + slider.progressTintColor = .black + slider.trackTintColor = UIColor.lightGray.withAlphaComponent(0.5) + + update(options: options) + addSubview(slider) + + /// add observers. + session.addObserver(self, forKeyPath: AVAudioSessionOutputVolumeKey, options: .new, context: nil) + NotificationCenter.default.addObserver(self, selector: #selector(audioSessionInterrupted(_:)), name: .AVAudioSessionInterruption, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(applicationDidChangeActive(_:)), name: .UIApplicationWillResignActive, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(applicationDidChangeActive(_:)), name: .UIApplicationDidBecomeActive, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(orientationDidChange(_:)), name: .UIDeviceOrientationDidChange, object: nil) + } + + private func update(volume value: Float, animated: Bool) { + volume = value + slider.setProgress(volume, animated: true) + + do { + try setSystem(volume: value) + } catch { + NSLog("unable to change system volume level.") + } + + UIView.animateKeyframes(withDuration: animated ? 2 : 0, delay: 0, options: .beginFromCurrentState, animations: { () -> Void in + UIView.addKeyframe(withRelativeStartTime: 0, relativeDuration: 0.1, animations: { + self.alpha = 1 + self.transform = CGAffineTransform.identity + }) + + UIView.addKeyframe(withRelativeStartTime: 0.8, relativeDuration: 0.1, animations: { () -> Void in + self.transform = CGAffineTransform(translationX: 0, y: -self.frame.height) + self.alpha = 0.0001 + }) + }) { _ in } + } + + private func setSystem(volume value: Float) throws { + guard let systemSlider = volumeView.subviews.flatMap({ $0 as? UISlider }).first else { + throw VolumizerError.disableToChangeVolumeLevel + } + + systemSlider.value = max(0, min(1, value)) + } + + // MARK: Notification + + @objc private func audioSessionInterrupted(_ notification: Notification) { + guard let interuptionInfo = notification.userInfo, + let rawValue = interuptionInfo[AVAudioSessionInterruptionTypeKey] as? UInt, + let interuptionType = AVAudioSessionInterruptionType(rawValue: rawValue) else { + return + } + + switch interuptionType { + case .began: + // NSLog("Audio Session Interruption case started.") + break + case .ended: + do { + try session.setActive(true) + } catch { + NSLog("Unable to initialize AVAudioSession") + } + } + } + + @objc private func applicationDidChangeActive(_ notification: Notification) { + isAppActive = notification.name == Notification.Name.UIApplicationDidBecomeActive + if isAppActive { + update(volume: session.outputVolume, animated: false) + } + } + + @objc private func orientationDidChange(_ notification: Notification) { + // TODO: [wip] support landscape mode. + // NSLog("orientation changed.") + let currentOrientation = UIDevice.current.orientation + switch currentOrientation { + case .landscapeLeft: + base?.transform = CGAffineTransform(rotationAngle: -CGFloat(90 * M_PI / 180.0)) + case .landscapeRight: + base?.transform = CGAffineTransform(rotationAngle: CGFloat(90 * M_PI / 180.0)) + case .portraitUpsideDown: + base?.transform = CGAffineTransform(rotationAngle: CGFloat(180.0 * M_PI / 180.0)) + default: + base?.transform = CGAffineTransform(rotationAngle: CGFloat(0.0 * M_PI / 180.0)) + } + } + + // MARK: KVO + + open override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) { + guard let change = change, let value = change[.newKey] as? Float , keyPath == AVAudioSessionOutputVolumeKey else { return } + + update(volume: value, animated: UIDeviceOrientationIsPortrait(UIDevice.current.orientation)) + } +} diff --git a/license b/license new file mode 100644 index 0000000..3aef851 --- /dev/null +++ b/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2017 Fumitaka Watanabe + +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.