Module: BubbleWrap::Device

Defined in:
motion/core/device.rb,
motion/core/osx/device.rb,
motion/core/ios/device.rb,
motion/core/device/screen.rb,
motion/core/device/osx/screen.rb,
motion/core/device/ios/camera.rb,
motion/core/device/ios/screen.rb,
motion/core/device/ios/camera_wrapper.rb

Defined Under Namespace

Modules: CameraWrapper, Screen Classes: Camera

Class Method Summary (collapse)

Class Method Details

+ (Device::Camera::CameraWrapper) camera

Use this to make a DSL-style call for picking images

Examples:

Device.camera.front



26
27
28
# File 'motion/core/ios/device.rb', line 26

def camera
  BubbleWrap::Device::CameraWrapper
end

+ (TrueClass, FalseClass) front_camera?(picker = UIImagePickerController)

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

+ (Object) interface_orientation

Delegates to BubbleWrap::Screen.interface_orientation



60
61
62
# File 'motion/core/ios/device.rb', line 60

def interface_orientation
  screen.interface_orientation
end

+ (String) ios_version

Returns the IOS SDK version currently running (i.e. “5.1” or “6.0” etc)



50
51
52
# File 'motion/core/ios/device.rb', line 50

def ios_version
  UIDevice.currentDevice.systemVersion
end

+ (TrueClass, FalseClass) ipad?(idiom = UIDevice.currentDevice.userInterfaceIdiom)

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

+ (TrueClass, FalseClass) iphone?(idiom = UIDevice.currentDevice.userInterfaceIdiom)

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

+ (TrueClass, FalseClass) long_screen?(idiom = UIDevice.currentDevice.userInterfaceIdiom, screen_height = UIScreen.mainScreen.bounds.size.height)

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

+ (Object) orientation

Delegates to BubbleWrap::Screen.orientation



55
56
57
# File 'motion/core/ios/device.rb', line 55

def orientation
  screen.orientation
end

+ (TrueClass, FalseClass) rear_camera?(picker = UIImagePickerController)

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

+ (Boolean) retina?

Delegates to BubbleWrap::Screen.retina?



11
12
13
# File 'motion/core/device.rb', line 11

def retina?
  screen.retina?
end

+ (Object) screen

Shameless shorthand for accessing BubbleWrap::Screen



6
7
8
# File 'motion/core/device.rb', line 6

def screen
  BubbleWrap::Device::Screen
end

+ (Boolean) simulator?



44
45
46
# File 'motion/core/ios/device.rb', line 44

def simulator?
  @simulator_state ||= !(UIDevice.currentDevice.model =~ /simulator/i).nil?
end