Module: BubbleWrap::Device
- Defined in:
- motion/core/device.rb,
motion/core/ios/device.rb,
motion/core/osx/device.rb,
motion/core/device/screen.rb,
motion/core/device/ios/camera.rb,
motion/core/device/ios/screen.rb,
motion/core/device/osx/screen.rb,
motion/core/device/ios/camera_wrapper.rb
Defined Under Namespace
Modules: CameraWrapper, Screen Classes: Camera
Class Method Summary collapse
-
.camera ⇒ Device::Camera::CameraWrapper
Use this to make a DSL-style call for picking images.
- .force_touch? ⇒ Boolean
-
.front_camera?(picker = UIImagePickerController) ⇒ TrueClass, FalseClass
Verifies that the device running has a front facing camera.
-
.interface_orientation ⇒ Object
Delegates to BubbleWrap::Screen.interface_orientation.
-
.ios_version ⇒ String
Returns the IOS SDK version currently running (i.e. “5.1” or “6.0” etc).
-
.ipad?(idiom = UIDevice.currentDevice.userInterfaceIdiom) ⇒ TrueClass, FalseClass
Verifies that the device running the app is an iPad.
-
.iphone?(idiom = UIDevice.currentDevice.userInterfaceIdiom) ⇒ TrueClass, FalseClass
Verifies that the device running the app is an iPhone.
-
.long_screen?(idiom = UIDevice.currentDevice.userInterfaceIdiom, screen_height = UIScreen.mainScreen.bounds.size.height) ⇒ TrueClass, FalseClass
Verifies that the device having a long screen (4 inch iPhone/iPod).
-
.orientation ⇒ Object
Delegates to BubbleWrap::Screen.orientation.
-
.rear_camera?(picker = UIImagePickerController) ⇒ TrueClass, FalseClass
Verifies that the device running has a rear facing camera.
-
.retina? ⇒ Boolean
Delegates to BubbleWrap::Screen.retina?.
-
.screen ⇒ Object
Shameless shorthand for accessing BubbleWrap::Screen.
-
.simulator? ⇒ TrueClass, FalseClass
Return whether app is being run in simulator.
-
.vendor_identifier ⇒ NSUUID
Returns an identifier unique to the vendor across the vendors app.
Class Method Details
.camera ⇒ Device::Camera::CameraWrapper
Use this to make a DSL-style call for picking images
26 27 28 |
# File 'motion/core/ios/device.rb', line 26 def camera BubbleWrap::Device::CameraWrapper end |
.force_touch? ⇒ Boolean
56 57 58 59 60 61 62 |
# 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 |
.front_camera?(picker = UIImagePickerController) ⇒ TrueClass, FalseClass
Verifies that the device running has a front facing camera.
32 33 34 35 |
# 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 |
.interface_orientation ⇒ Object
Delegates to BubbleWrap::Screen.interface_orientation
82 83 84 |
# File 'motion/core/ios/device.rb', line 82 def interface_orientation screen.interface_orientation end |
.ios_version ⇒ String
Returns the IOS SDK version currently running (i.e. “5.1” or “6.0” etc)
66 67 68 |
# File 'motion/core/ios/device.rb', line 66 def ios_version UIDevice.currentDevice.systemVersion end |
.ipad?(idiom = UIDevice.currentDevice.userInterfaceIdiom) ⇒ TrueClass, FalseClass
Verifies that the device running the app is an iPad.
13 14 15 |
# File 'motion/core/ios/device.rb', line 13 def ipad?(idiom=UIDevice.currentDevice.userInterfaceIdiom) idiom == UIUserInterfaceIdiomPad end |
.iphone?(idiom = UIDevice.currentDevice.userInterfaceIdiom) ⇒ TrueClass, FalseClass
Verifies that the device running the app is an iPhone.
7 8 9 |
# File 'motion/core/ios/device.rb', line 7 def iphone?(idiom=UIDevice.currentDevice.userInterfaceIdiom) idiom == UIUserInterfaceIdiomPhone end |
.long_screen?(idiom = UIDevice.currentDevice.userInterfaceIdiom, screen_height = UIScreen.mainScreen.bounds.size.height) ⇒ TrueClass, FalseClass
Verifies that the device having a long screen (4 inch iPhone/iPod)
19 20 21 |
# 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 |
.orientation ⇒ Object
Delegates to BubbleWrap::Screen.orientation
77 78 79 |
# File 'motion/core/ios/device.rb', line 77 def orientation screen.orientation end |
.rear_camera?(picker = UIImagePickerController) ⇒ TrueClass, FalseClass
Verifies that the device running has a rear facing camera.
39 40 41 42 |
# 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 |
.retina? ⇒ Boolean
Delegates to BubbleWrap::Screen.retina?
11 12 13 |
# File 'motion/core/device.rb', line 11 def retina? screen.retina? end |
.screen ⇒ Object
Shameless shorthand for accessing BubbleWrap::Screen
6 7 8 |
# File 'motion/core/device.rb', line 6 def screen BubbleWrap::Device::Screen end |
.simulator? ⇒ TrueClass, FalseClass
Return whether app is being run in simulator
46 47 48 49 50 51 52 53 54 |
# 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 |
.vendor_identifier ⇒ NSUUID
Returns an identifier unique to the vendor across the vendors app.
72 73 74 |
# File 'motion/core/ios/device.rb', line 72 def vendor_identifier UIDevice.currentDevice.identifierForVendor end |