module BubbleWrap::Device
Public Instance Methods
Use this to make a DSL-style call for picking images @example Device.camera
.front @return [Device::Camera::CameraWrapper]
# File motion/core/ios/device.rb, line 26 def camera BubbleWrap::Device::CameraWrapper end
# File motion/core/ios/device.rb, line 56 def force_touch? if defined?(UIForceTouchCapabilityAvailable) && defined?(UIScreen.mainScreen.traitCollection) && defined?(UIScreen.mainScreen.traitCollection.forceTouchCapability) UIScreen.mainScreen.traitCollection.forceTouchCapability == UIForceTouchCapabilityAvailable else false end end
Verifies that the device running has a front facing camera. @return [TrueClass, FalseClass] true will be returned if the device has a front facing camera, false otherwise.
# File motion/core/ios/device.rb, line 32 def front_camera?(picker=UIImagePickerController) p "This method (front_camera?) is DEPRECATED. Transition to using Device.camera.front?" picker.isCameraDeviceAvailable(UIImagePickerControllerCameraDeviceFront) end
Delegates to BubbleWrap::Screen.interface_orientation
# File motion/core/ios/device.rb, line 82 def interface_orientation screen.interface_orientation end
Returns the IOS SDK version currently running (i.e. “5.1” or “6.0” etc) @return [String] the IOS SDK version currently running
# File motion/core/ios/device.rb, line 66 def ios_version UIDevice.currentDevice.systemVersion end
Verifies that the device running the app is an iPad. @return [TrueClass, FalseClass] true will be returned if the device is an iPad, false otherwise.
# File motion/core/ios/device.rb, line 13 def ipad?(idiom=UIDevice.currentDevice.userInterfaceIdiom) idiom == UIUserInterfaceIdiomPad end
Verifies that the device running the app is an iPhone. @return [TrueClass, FalseClass] true will be returned if the device is an iPhone, false otherwise.
# File motion/core/ios/device.rb, line 7 def iphone?(idiom=UIDevice.currentDevice.userInterfaceIdiom) idiom == UIUserInterfaceIdiomPhone end
Verifies that the device having a long screen (4 inch iPhone/iPod) @return [TrueClass, FalseClass] true will be returned if the device is an iPhone/iPod with 4 inche screen, false otherwise.
# File motion/core/ios/device.rb, line 19 def long_screen?(idiom=UIDevice.currentDevice.userInterfaceIdiom, screen_height=UIScreen.mainScreen.bounds.size.height) iphone?(idiom) && screen_height == 568.0 end
Delegates to BubbleWrap::Screen.orientation
# File motion/core/ios/device.rb, line 77 def orientation screen.orientation end
Verifies that the device running has a rear facing camera. @return [TrueClass, FalseClass] true will be returned if the device has a rear facing camera, false otherwise.
# File motion/core/ios/device.rb, line 39 def rear_camera?(picker=UIImagePickerController) p "This method (rear_camera?) is DEPRECATED. Transition to using Device.camera.rear?" picker.isCameraDeviceAvailable(UIImagePickerControllerCameraDeviceRear) end
Delegates to BubbleWrap::Screen.retina?
# File motion/core/device.rb, line 11 def retina? screen.retina? end
Shameless shorthand for accessing BubbleWrap::Screen
# File motion/core/device.rb, line 6 def screen BubbleWrap::Device::Screen end
Return whether app is being run in simulator @return [TrueClass, FalseClass] true will be returned if simulator, false otherwise.
# File motion/core/ios/device.rb, line 46 def simulator? @simulator_state ||= begin if ios_version.to_i >= 9 NSBundle.mainBundle.bundlePath !~ /^(\/private)?\/var/ else !(UIDevice.currentDevice.model =~ /simulator/i).nil? end end end
Returns an identifier unique to the vendor across the vendors app. @return [NSUUID]
# File motion/core/ios/device.rb, line 72 def vendor_identifier UIDevice.currentDevice.identifierForVendor end