bubble-wrap 1.6.0 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/GETTING_STARTED.md +1 -1
- data/Gemfile.lock +3 -3
- data/README.md +48 -6
- data/bubble-wrap.gemspec +1 -1
- data/lib/bubble-wrap/ui.rb +1 -0
- data/lib/bubble-wrap/version.rb +1 -1
- data/motion/core/device/ios/camera.rb +20 -11
- data/motion/core/persistence.rb +9 -0
- data/motion/core/string.rb +19 -4
- data/motion/ios/7/uiactivity_view_controller_constants.rb +10 -0
- data/motion/location/location.rb +37 -5
- data/motion/mail/mail.rb +22 -14
- data/motion/media/player.rb +5 -2
- data/motion/sms/sms.rb +7 -7
- data/motion/ui/ui_activity_view_controller_wrapper.rb +1 -6
- data/motion/ui/ui_control_wrapper.rb +1 -1
- data/motion/ui/ui_view_wrapper.rb +7 -1
- data/samples/camera/README.md +2 -2
- data/spec/motion/core/persistence_spec.rb +15 -1
- data/spec/motion/core/string_spec.rb +28 -5
- data/spec/motion/location/location_spec.rb +25 -0
- data/spec/motion/rss_parser_spec.rb +1 -1
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c36af1404df9fe25d9bb32a34940b0877bf9eacd
|
4
|
+
data.tar.gz: c1d13206fbdff5651321d7ef362d7695ae8e2b7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03a94c71a69d7d27c68a7713f53f78db2daf10fe90561c03839f851ba0c2e65a1397ea0fe407432d1f4fcae9c317fe7265a06862ed66bbe81246121aab2667ab
|
7
|
+
data.tar.gz: f37b7ffddccd80b6716ea18efbdd11e217c66a3a15261e439e3b82caa048bb9ab0e4dc4a277c6dd89a66a27ff0c868eb2e7d13564d4d9e34f3ba2eb89913155e
|
data/GETTING_STARTED.md
CHANGED
@@ -98,7 +98,7 @@ BW.require '/path/to/some/files/**/*.rb'
|
|
98
98
|
```
|
99
99
|
|
100
100
|
For more information in using `BW.require` take a look at
|
101
|
-
[the bubblewrap hacking guide](
|
101
|
+
[the bubblewrap hacking guide](hacking.html).
|
102
102
|
|
103
103
|
## Go forth and conquer!
|
104
104
|
|
data/Gemfile.lock
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
bubble-wrap (1.
|
5
|
-
bubble-wrap-http (= 1.
|
4
|
+
bubble-wrap (1.7.0)
|
5
|
+
bubble-wrap-http (= 1.7.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
10
|
bacon (1.1.0)
|
11
|
-
bubble-wrap-http (1.
|
11
|
+
bubble-wrap-http (1.7.0)
|
12
12
|
metaclass (0.0.1)
|
13
13
|
mocha (0.11.4)
|
14
14
|
metaclass (~> 0.0.1)
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
A collection of (tested) helpers and wrappers used to wrap Cocoa Touch and AppKit code and provide more Ruby like APIs.
|
4
4
|
|
5
|
-
[BubbleWrap website](http://
|
5
|
+
[BubbleWrap website](http://rubymotion.github.io/BubbleWrap/)
|
6
6
|
[BubbleWrap mailing list](https://groups.google.com/forum/#!forum/bubblewrap)
|
7
7
|
|
8
8
|
[![Code Climate](https://codeclimate.com/github/rubymotion/BubbleWrap.png)](https://codeclimate.com/github/rubymotion/BubbleWrap)
|
@@ -267,8 +267,22 @@ end
|
|
267
267
|
BW::Device.camera.any.picture(media_types: [:movie, :image]) do |result|
|
268
268
|
image_view = UIImageView.alloc.initWithImage(result[:original_image])
|
269
269
|
end
|
270
|
+
|
271
|
+
# Lets the user edit the photo (with access to the edited and original photos)
|
272
|
+
BW::Device.camera.any.picture(allows_editing: true, media_types: [:image]) do |result|
|
273
|
+
edited_image_view = UIImageView.alloc.initWithImage(result[:edited_image])
|
274
|
+
original_image_view = UIImageView.alloc.initWithImage(result[:original_image])
|
275
|
+
end
|
270
276
|
```
|
271
277
|
|
278
|
+
|
279
|
+
Options include:
|
280
|
+
|
281
|
+
- `:allows_editing` - Boolean; whether a user can edit the photo/video before picking
|
282
|
+
- `:animated` - Boolean; whether to display the camera with an animation (default true)
|
283
|
+
- `:on_dismiss` - Lambda; called instead of the default dismissal logic
|
284
|
+
- `:media_types` - Array; containing any of `[:movie, :image]`
|
285
|
+
|
272
286
|
### JSON
|
273
287
|
|
274
288
|
`BW::JSON` wraps `NSJSONSerialization` available in iOS5 and offers the same API as Ruby's JSON std lib. For apps building for iOS4, we suggest a different JSON alternative, like [AnyJSON](https://github.com/mattt/AnyJSON).
|
@@ -331,6 +345,8 @@ simple interface:
|
|
331
345
|
# ['TF1', 'France 2', 'France 3']
|
332
346
|
> App::Persistence['something__new'] # something previously never stored
|
333
347
|
# nil
|
348
|
+
> App::Persistence.all
|
349
|
+
# {'all':'values', 'stored':'by', 'bubblewrap':'as a hash!'}
|
334
350
|
```
|
335
351
|
|
336
352
|
### Observers
|
@@ -389,7 +405,14 @@ iso8601 formatted string into a Time instance.
|
|
389
405
|
Added interface for Ruby-like GPS and compass access:
|
390
406
|
|
391
407
|
```ruby
|
392
|
-
BW::Location.
|
408
|
+
> BW::Location.enabled? # Whether location services are enabled on the device
|
409
|
+
=> true
|
410
|
+
> BW::Location.authorized? # If your app is authorized to use location services
|
411
|
+
=> false
|
412
|
+
```
|
413
|
+
|
414
|
+
```ruby
|
415
|
+
BW::Location.get(purpose: 'We need to use your GPS because...') do |result|
|
393
416
|
p "From Lat #{result[:from].latitude}, Long #{result[:from].longitude}"
|
394
417
|
p "To Lat #{result[:to].latitude}, Long #{result[:to].longitude}"
|
395
418
|
end
|
@@ -404,7 +427,27 @@ BW::Location.get_compass do |result|
|
|
404
427
|
end
|
405
428
|
```
|
406
429
|
|
407
|
-
|
430
|
+
`BW::Location.get_significant` is also available, for monitoring significant location changes.
|
431
|
+
|
432
|
+
`BW::Location` also supports `get_once`-style methods, which will return the first result before ending the search:
|
433
|
+
|
434
|
+
```ruby
|
435
|
+
BW::Location.get_once(desired_accuracy: :three_kilometers, ...) do |result|
|
436
|
+
if result.is_a?(CLLocation)
|
437
|
+
p result.coordinate.latitude
|
438
|
+
p result.coordinate.longitude
|
439
|
+
else
|
440
|
+
p "ERROR: #{result[:error]}"
|
441
|
+
end
|
442
|
+
end
|
443
|
+
|
444
|
+
BW::Location.get_compass_once do |heading|
|
445
|
+
p result[:magnetic_heading]
|
446
|
+
p result[:true_heading]
|
447
|
+
p result[:accuracy]
|
448
|
+
p result[:timestamp]
|
449
|
+
end
|
450
|
+
```
|
408
451
|
|
409
452
|
## Media
|
410
453
|
|
@@ -428,7 +471,7 @@ Wrapper for showing an in-app mail composer view.
|
|
428
471
|
|
429
472
|
```ruby
|
430
473
|
# Opens as a modal in the current UIViewController
|
431
|
-
BW::Mail.compose
|
474
|
+
BW::Mail.compose(
|
432
475
|
delegate: self, # optional, defaults to rootViewController
|
433
476
|
to: [ "tom@example.com" ],
|
434
477
|
cc: [ "itchy@example.com", "scratchy@example.com" ],
|
@@ -437,7 +480,7 @@ BW::Mail.compose {
|
|
437
480
|
subject: "My Subject",
|
438
481
|
message: "This is my message. It isn't very long.",
|
439
482
|
animated: false
|
440
|
-
|
483
|
+
) do |result, error|
|
441
484
|
result.sent? # => boolean
|
442
485
|
result.canceled? # => boolean
|
443
486
|
result.saved? # => boolean
|
@@ -1029,4 +1072,3 @@ Do you have a suggestion for a specific wrapper? Feel free to open an
|
|
1029
1072
|
issue/ticket and tell us about what you are after. If you have a
|
1030
1073
|
wrapper/helper you are using and are thinking that others might enjoy,
|
1031
1074
|
please send a pull request (with tests if possible).
|
1032
|
-
|
data/bubble-wrap.gemspec
CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |gem|
|
|
6
6
|
gem.email = ['mattaimonetti@gmail.com', 'francis@ignition.hk', 'james@sociable.co.nz', 'clay.allsopp@gmail.com', 'dylan@dylanmarkow.com', 'jan@dreimannzelt.de', 'mneorr@gmail.com']
|
7
7
|
gem.description = 'RubyMotion wrappers and helpers (Ruby for iOS) - Making Cocoa APIs more Ruby like, one API at a time. Fork away and send your pull request.'
|
8
8
|
gem.summary = 'RubyMotion wrappers and helpers (Ruby for iOS) - Making Cocoa APIs more Ruby like, one API at a time. Fork away and send your pull request.'
|
9
|
-
gem.homepage = 'http://
|
9
|
+
gem.homepage = 'http://rubymotion.github.io/BubbleWrap/'
|
10
10
|
|
11
11
|
gem.files = `git ls-files`.split($\)
|
12
12
|
gem.test_files = gem.files.grep(%r{^(test|spec|lib_spec|features)/})
|
data/lib/bubble-wrap/ui.rb
CHANGED
@@ -2,6 +2,7 @@ require 'bubble-wrap/loader'
|
|
2
2
|
|
3
3
|
BubbleWrap.require_ios("ui") do
|
4
4
|
BubbleWrap.require('motion/util/constants.rb')
|
5
|
+
BubbleWrap.require('motion/ios/7/uiactivity_view_controller_constants.rb') if App.config.send(:deployment_target).to_f >= 7.0
|
5
6
|
BubbleWrap.require('motion/ui/**/*.rb') do
|
6
7
|
file('motion/ui/pollute.rb').depends_on %w(
|
7
8
|
motion/ui/ui_control_wrapper.rb
|
data/lib/bubble-wrap/version.rb
CHANGED
@@ -45,7 +45,7 @@ module BubbleWrap
|
|
45
45
|
end
|
46
46
|
alias_method "photo_library", "any"
|
47
47
|
end
|
48
|
-
|
48
|
+
|
49
49
|
def popover_from(view)
|
50
50
|
@popover_in_view = view
|
51
51
|
self
|
@@ -67,17 +67,18 @@ module BubbleWrap
|
|
67
67
|
UIImagePickerController.isFlashAvailableForCameraDevice(camera_device)
|
68
68
|
end
|
69
69
|
|
70
|
-
# @param [Hash] options to open the UIImagePickerController with
|
70
|
+
# @param [Hash] options to open the UIImagePickerController with
|
71
71
|
# the form {
|
72
72
|
# source_type: :photo_library, :camera, or :saved_photos_album; default :photo_library
|
73
73
|
# media_types: [] containing :image and/or :movie; default [:image]
|
74
74
|
# allows_editing: true/false; default false
|
75
75
|
# animated: true/false; default true
|
76
|
+
# on_dismiss: lambda; default nil
|
76
77
|
# }
|
77
|
-
#
|
78
|
+
#
|
78
79
|
# @param [UIViewController] view controller from which to present the image picker;
|
79
80
|
# if nil, uses the keyWindow's rootViewController.
|
80
|
-
#
|
81
|
+
#
|
81
82
|
# @block for callback. takes one argument.
|
82
83
|
# - On error or cancelled, is called with a hash {error: BW::Camera::Error::<Type>}
|
83
84
|
# - On success, is called with a hash with a possible set of keys
|
@@ -92,10 +93,13 @@ module BubbleWrap
|
|
92
93
|
@callback = block
|
93
94
|
@callback.weak! if @callback && BubbleWrap.use_weak_callbacks?
|
94
95
|
|
95
|
-
@options =
|
96
|
-
|
97
|
-
|
98
|
-
|
96
|
+
@options = {
|
97
|
+
allows_editing: false,
|
98
|
+
animated: true,
|
99
|
+
on_dismiss: false,
|
100
|
+
media_types: [:image],
|
101
|
+
dismiss_completed: nil
|
102
|
+
}.merge(options)
|
99
103
|
|
100
104
|
# If we're using Camera.any, by default use photo library
|
101
105
|
if !@options.has_key?(:source_type) and self.location == :none
|
@@ -137,7 +141,7 @@ module BubbleWrap
|
|
137
141
|
|
138
142
|
presenting_controller ||= App.window.rootViewController.presentedViewController # May be nil, but handles use case of container views
|
139
143
|
presenting_controller ||= App.window.rootViewController
|
140
|
-
|
144
|
+
|
141
145
|
# use popover for iPad (ignore on iPhone)
|
142
146
|
if Device.ipad? and source_type==UIImagePickerControllerSourceTypePhotoLibrary and @popover_in_view
|
143
147
|
@popover = UIPopoverController.alloc.initWithContentViewController(picker)
|
@@ -146,7 +150,7 @@ module BubbleWrap
|
|
146
150
|
presenting_controller.presentViewController(self.picker, animated:@options[:animated], completion: lambda {})
|
147
151
|
end
|
148
152
|
end
|
149
|
-
|
153
|
+
|
150
154
|
# iPad popover is dismissed
|
151
155
|
def popoverControllerDidDismissPopover(popoverController)
|
152
156
|
@popover = nil
|
@@ -194,7 +198,12 @@ module BubbleWrap
|
|
194
198
|
end
|
195
199
|
|
196
200
|
def dismiss
|
197
|
-
|
201
|
+
if @options[:on_dismiss]
|
202
|
+
@options[:on_dismiss].call(self.picker)
|
203
|
+
return
|
204
|
+
end
|
205
|
+
|
206
|
+
self.picker.dismissViewControllerAnimated(@options[:animated], completion: @options[:dismiss_completed])
|
198
207
|
end
|
199
208
|
|
200
209
|
# @param [UIImagePickerControllerSourceType] source_type to check
|
data/motion/core/persistence.rb
CHANGED
@@ -43,6 +43,15 @@ module BubbleWrap
|
|
43
43
|
def storage_key(key)
|
44
44
|
"#{app_key}_#{key}"
|
45
45
|
end
|
46
|
+
|
47
|
+
def all
|
48
|
+
hash = storage.dictionaryRepresentation.select{|k,v| k.start_with?(app_key) }
|
49
|
+
new_hash = {}
|
50
|
+
hash.each do |k,v|
|
51
|
+
new_hash[k.sub("#{app_key}_", '')] = v
|
52
|
+
end
|
53
|
+
new_hash
|
54
|
+
end
|
46
55
|
end
|
47
56
|
|
48
57
|
end
|
data/motion/core/string.rb
CHANGED
@@ -33,12 +33,27 @@ module BubbleWrap
|
|
33
33
|
word
|
34
34
|
end
|
35
35
|
|
36
|
-
def to_url_encoded(encoding =
|
37
|
-
|
36
|
+
def to_url_encoded(encoding = nil, legacy = false)
|
37
|
+
if legacy
|
38
|
+
stringByAddingPercentEscapesUsingEncoding(encoding || NSUTF8StringEncoding)
|
39
|
+
else
|
40
|
+
encoding ||= KCFStringEncodingUTF8
|
41
|
+
encoding = CFStringConvertNSStringEncodingToEncoding(encoding) unless CFStringIsEncodingAvailable(encoding)
|
42
|
+
CFURLCreateStringByAddingPercentEscapes(nil, self, nil, "!*'();:@&=+$,/?%#[]", encoding)
|
43
|
+
end
|
38
44
|
end
|
39
45
|
|
40
|
-
def to_url_decoded(encoding =
|
41
|
-
|
46
|
+
def to_url_decoded(encoding = nil, legacy = false)
|
47
|
+
if legacy
|
48
|
+
stringByReplacingPercentEscapesUsingEncoding(encoding || NSUTF8StringEncoding)
|
49
|
+
else
|
50
|
+
if encoding
|
51
|
+
encoding = CFStringConvertNSStringEncodingToEncoding(encoding) unless CFStringIsEncodingAvailable(encoding)
|
52
|
+
CFURLCreateStringByReplacingPercentEscapesUsingEncoding(nil, self, nil, encoding)
|
53
|
+
else
|
54
|
+
CFURLCreateStringByReplacingPercentEscapes(nil, self, nil)
|
55
|
+
end
|
56
|
+
end
|
42
57
|
end
|
43
58
|
|
44
59
|
def to_encoded_data(encoding = NSUTF8StringEncoding)
|
data/motion/location/location.rb
CHANGED
@@ -51,13 +51,15 @@ module BubbleWrap
|
|
51
51
|
def get(options = {}, &block)
|
52
52
|
@callback = block
|
53
53
|
@callback.weak! if @callback && BubbleWrap.use_weak_callbacks?
|
54
|
-
@options =
|
54
|
+
@options = {
|
55
|
+
significant: false,
|
56
|
+
distance_filter: KCLDistanceFilterNone,
|
57
|
+
desired_accuracy: KCLLocationAccuracyBest,
|
58
|
+
retries: 5,
|
59
|
+
once: false
|
60
|
+
}.merge(options)
|
55
61
|
|
56
62
|
@options[:significant] = false if @options[:significant].nil?
|
57
|
-
@options[:distance_filter] ||= KCLDistanceFilterNone
|
58
|
-
@options[:desired_accuracy] ||= KCLLocationAccuracyBest
|
59
|
-
@options[:retries] ||= 5
|
60
|
-
@options[:once] ||= false
|
61
63
|
@retries = 0
|
62
64
|
|
63
65
|
if not enabled?
|
@@ -81,6 +83,31 @@ module BubbleWrap
|
|
81
83
|
get(options.merge(significant: true), &block)
|
82
84
|
end
|
83
85
|
|
86
|
+
# Get the first returned location based on your options
|
87
|
+
# @param [Hash] options = {
|
88
|
+
# significant: true/false; whether to listen for significant location changes or
|
89
|
+
# all location changes (see Apple docs for info); default == false
|
90
|
+
# distance_filter: minimum change in distance to be updated about, in meters;
|
91
|
+
# default == uses KCLDistanceFilterNone,
|
92
|
+
# desired_accuracy: minimum accuracy for updates to arrive;
|
93
|
+
# any of :best_for_navigation, :best, :nearest_ten_meters,
|
94
|
+
# :hundred_meters, :kilometer, or :three_kilometers; default == :best
|
95
|
+
# purpose: string to display when the system asks user for location,
|
96
|
+
# retries: if location cant be found. how many errors do we retry; default == 5
|
97
|
+
# }
|
98
|
+
# @block for callback. takes one argument, `result`.
|
99
|
+
# - On error or cancelled, is called with a hash {error: BW::Location::Error::<Type>}
|
100
|
+
# - On success, it returns a CLLocation
|
101
|
+
#
|
102
|
+
#
|
103
|
+
# Example
|
104
|
+
# BW::Location.get_once(desired_accuracy: :three_kilometers, purpose: 'We need to use your GPS to show you how fun RM is') do |result|
|
105
|
+
# if result.is_a?(CLLocation)
|
106
|
+
# p "Lat #{result.latitude}, Long #{result.longitude}"
|
107
|
+
# else
|
108
|
+
# p "ERROR: #{result[:error]"
|
109
|
+
# end
|
110
|
+
# end
|
84
111
|
def get_once(options = {}, &block)
|
85
112
|
get(options.merge(once: true), &block)
|
86
113
|
end
|
@@ -116,6 +143,11 @@ module BubbleWrap
|
|
116
143
|
CLLocationManager.locationServicesEnabled
|
117
144
|
end
|
118
145
|
|
146
|
+
# returns true/false whether services are enabled for the _app_
|
147
|
+
def authorized?
|
148
|
+
CLLocationManager.authorizationStatus == KCLAuthorizationStatusAuthorized
|
149
|
+
end
|
150
|
+
|
119
151
|
def error(type)
|
120
152
|
@callback && @callback.call({ error: type })
|
121
153
|
@callback = nil
|
data/motion/mail/mail.rb
CHANGED
@@ -6,7 +6,7 @@ module BubbleWrap
|
|
6
6
|
# Base method to create your in-app mail
|
7
7
|
# ---------------------------------------
|
8
8
|
# EX
|
9
|
-
# BW::Mail.compose
|
9
|
+
# BW::Mail.compose(
|
10
10
|
# delegate: self, # optional, will use root view controller by default
|
11
11
|
# to: [ "tom@example.com" ],
|
12
12
|
# cc: [ "itchy@example.com", "scratchy@example.com" ],
|
@@ -15,36 +15,44 @@ module BubbleWrap
|
|
15
15
|
# subject: "My Subject",
|
16
16
|
# message: "This is my message. It isn't very long.",
|
17
17
|
# animated: false
|
18
|
-
#
|
18
|
+
# ) do |result, error|
|
19
19
|
# result.sent? # => boolean
|
20
20
|
# result.canceled? # => boolean
|
21
21
|
# result.saved? # => boolean
|
22
22
|
# result.failed? # => boolean
|
23
23
|
# error # => NSError
|
24
24
|
# end
|
25
|
-
def compose(options={}, &callback)
|
26
|
-
|
25
|
+
def compose(options = {}, &callback)
|
26
|
+
options = {
|
27
|
+
delegate: App.window.rootViewController,
|
28
|
+
animated: true,
|
29
|
+
html: false,
|
30
|
+
to: [],
|
31
|
+
cc: [],
|
32
|
+
bcc: [],
|
33
|
+
subject: 'Contact'
|
34
|
+
}.merge(options)
|
27
35
|
|
36
|
+
@delegate = options[:delegate]
|
37
|
+
@mailer_is_animated = options[:animated]
|
28
38
|
@callback = callback
|
29
39
|
@callback.weak! if @callback && BubbleWrap.use_weak_callbacks?
|
30
|
-
|
40
|
+
|
31
41
|
@mail_controller = create_mail_controller(options)
|
32
|
-
|
33
|
-
@mailer_is_animated = options[:animated] == false ? false : true
|
42
|
+
|
34
43
|
@delegate.presentViewController(@mail_controller, animated: @mailer_is_animated, completion: options[:completion])
|
35
44
|
end
|
36
|
-
|
37
|
-
def create_mail_controller(options={})
|
45
|
+
|
46
|
+
def create_mail_controller(options = {})
|
38
47
|
mail_controller = MFMailComposeViewController.alloc.init
|
39
|
-
|
48
|
+
|
40
49
|
mail_controller.mailComposeDelegate = self
|
41
50
|
mail_controller.setToRecipients(Array(options[:to]))
|
42
51
|
mail_controller.setCcRecipients(Array(options[:cc]))
|
43
52
|
mail_controller.setBccRecipients(Array(options[:bcc]))
|
44
|
-
mail_controller.setSubject(options[:subject]
|
45
|
-
|
46
|
-
|
47
|
-
|
53
|
+
mail_controller.setSubject(options[:subject])
|
54
|
+
mail_controller.setMessageBody(options[:message], isHTML: !!options[:html])
|
55
|
+
|
48
56
|
mail_controller
|
49
57
|
end
|
50
58
|
|
data/motion/media/player.rb
CHANGED
@@ -64,6 +64,10 @@ module BubbleWrap
|
|
64
64
|
# self.view.addSubview media_player.view
|
65
65
|
# end
|
66
66
|
def play(content_url, options = {}, &block)
|
67
|
+
options = {
|
68
|
+
delay_play: false
|
69
|
+
}.merge(options)
|
70
|
+
|
67
71
|
display_modal = !!options[:modal]
|
68
72
|
|
69
73
|
klass = display_modal ? MPMoviePlayerViewController : MPMoviePlayerController
|
@@ -73,7 +77,6 @@ module BubbleWrap
|
|
73
77
|
|
74
78
|
self.media_player.prepareToPlay if not display_modal
|
75
79
|
|
76
|
-
options[:delay_play] = false if not options.has_key? :delay_play
|
77
80
|
set_player_options(options)
|
78
81
|
|
79
82
|
NSNotificationCenter.defaultCenter.observe MPMoviePlayerPlaybackDidFinishNotification do |notification|
|
@@ -144,4 +147,4 @@ module BubbleWrap
|
|
144
147
|
end
|
145
148
|
end
|
146
149
|
end
|
147
|
-
end
|
150
|
+
end
|
data/motion/sms/sms.rb
CHANGED
@@ -17,9 +17,9 @@ module BubbleWrap
|
|
17
17
|
# result.canceled? # => boolean
|
18
18
|
# result.failed? # => boolean
|
19
19
|
# error # => NSError
|
20
|
-
# }
|
21
|
-
|
22
|
-
def compose(options={}, &callback)
|
20
|
+
# }
|
21
|
+
|
22
|
+
def compose(options = {}, &callback)
|
23
23
|
@delegate = options[:delegate] || App.window.rootViewController
|
24
24
|
@callback = callback
|
25
25
|
@callback.weak! if @callback && BubbleWrap.use_weak_callbacks?
|
@@ -28,12 +28,12 @@ module BubbleWrap
|
|
28
28
|
@message_is_animated = options[:animated] == false ? false : true
|
29
29
|
@delegate.presentModalViewController(@message_controller, animated: @message_is_animated)
|
30
30
|
end
|
31
|
-
|
32
|
-
def create_message_controller(options={})
|
31
|
+
|
32
|
+
def create_message_controller(options = {})
|
33
33
|
message_controller = MFMessageComposeViewController.alloc.init
|
34
34
|
message_controller.messageComposeDelegate = self
|
35
|
-
message_controller.body = options[:message]
|
36
|
-
message_controller.recipients = Array(options[:to])
|
35
|
+
message_controller.body = options[:message]
|
36
|
+
message_controller.recipients = Array(options[:to])
|
37
37
|
message_controller
|
38
38
|
end
|
39
39
|
|
@@ -41,11 +41,6 @@ module BW
|
|
41
41
|
UIActivityTypePrint,
|
42
42
|
UIActivityTypeCopyToPasteboard,
|
43
43
|
UIActivityTypeAssignToContact,
|
44
|
-
UIActivityTypeSaveToCameraRoll
|
45
|
-
UIActivityTypeAddToReadingList,
|
46
|
-
UIActivityTypePostToFlickr,
|
47
|
-
UIActivityTypePostToVimeo,
|
48
|
-
UIActivityTypePostToTencentWeibo,
|
49
|
-
UIActivityTypeAirDrop
|
44
|
+
UIActivityTypeSaveToCameraRoll
|
50
45
|
)
|
51
46
|
end
|
@@ -25,7 +25,7 @@ module BubbleWrap
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def when_pressed(enableInteraction=true, &proc)
|
28
|
-
add_gesture_recognizer_helper(UILongPressGestureRecognizer.alloc.initWithTarget(self, action:'
|
28
|
+
add_gesture_recognizer_helper(UILongPressGestureRecognizer.alloc.initWithTarget(self, action:'handle_gesture_pressed_on_begin:'), enableInteraction, proc)
|
29
29
|
end
|
30
30
|
|
31
31
|
def self.deprecated_methods
|
@@ -45,6 +45,12 @@ module BubbleWrap
|
|
45
45
|
@recognizers[recognizer].call(recognizer)
|
46
46
|
end
|
47
47
|
|
48
|
+
def handle_gesture_pressed_on_begin(recognizer)
|
49
|
+
if recognizer.state==UIGestureRecognizerStateBegan
|
50
|
+
@recognizers[recognizer].call(recognizer)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
48
54
|
# Adds the recognizer and keeps a strong reference to the Proc object.
|
49
55
|
def add_gesture_recognizer_helper(recognizer, enableInteraction, proc)
|
50
56
|
setUserInteractionEnabled true if enableInteraction && !isUserInteractionEnabled
|
data/samples/camera/README.md
CHANGED
@@ -66,6 +66,20 @@ describe BubbleWrap::Persistence do
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
+
describe "retrieving all objects" do
|
70
|
+
it 'can retrieve a dictionary of all objects' do
|
71
|
+
all = BubbleWrap::Persistence.all
|
72
|
+
all.is_a?(Hash).should == true
|
73
|
+
|
74
|
+
compare_to = {}
|
75
|
+
compare_to["anotherArbitraryNumber"] = 9001
|
76
|
+
compare_to["arbitraryNumber"] = 42
|
77
|
+
compare_to["arbitraryString"] = "test string"
|
78
|
+
|
79
|
+
all.should == compare_to
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
69
83
|
describe "deleting object" do
|
70
84
|
before do
|
71
85
|
BubbleWrap::Persistence['arbitraryString'] = 'foobarbaz'
|
@@ -85,7 +99,7 @@ describe BubbleWrap::Persistence do
|
|
85
99
|
def storage.synchronize; @sync_was_called = true; end
|
86
100
|
|
87
101
|
BubbleWrap::Persistence.delete(:arbitraryString)
|
88
|
-
|
102
|
+
|
89
103
|
storage.instance_variable_get(:@sync_was_called).should.equal true
|
90
104
|
end
|
91
105
|
|
@@ -164,26 +164,49 @@ describe BubbleWrap::String do
|
|
164
164
|
describe "encoding" do
|
165
165
|
|
166
166
|
before do
|
167
|
-
@raw_string = "hey ho let's {go}"
|
167
|
+
@raw_string = "hey ho let's {go} http://bubblewrap.io&rocks!"
|
168
168
|
end
|
169
169
|
|
170
170
|
it "to_url_encoded" do
|
171
|
-
real_encoded = @raw_string
|
171
|
+
real_encoded = CFURLCreateStringByAddingPercentEscapes(nil, @raw_string, nil, "!*'();:@&=+$,/?%#[]", KCFStringEncodingUTF8)
|
172
172
|
@raw_string.to_url_encoded.should.equal real_encoded
|
173
173
|
end
|
174
174
|
|
175
175
|
it "handles other encodings" do
|
176
|
-
utf16 = @raw_string
|
176
|
+
utf16 = CFURLCreateStringByAddingPercentEscapes(nil, @raw_string, nil, "!*'();:@&=+$,/?%#[]", KCFStringEncodingUTF16)
|
177
|
+
@raw_string.to_url_encoded(KCFStringEncodingUTF16).should.equal utf16
|
178
|
+
end
|
179
|
+
|
180
|
+
it "automatically selects available encodings" do
|
181
|
+
encoding = if CFStringIsEncodingAvailable(NSUTF16StringEncoding)
|
182
|
+
NSUTF16StringEncoding
|
183
|
+
else
|
184
|
+
KCFStringEncodingUTF16
|
185
|
+
end
|
186
|
+
|
187
|
+
utf16 = CFURLCreateStringByAddingPercentEscapes(nil, @raw_string, nil, "!*'();:@&=+$,/?%#[]", encoding)
|
177
188
|
@raw_string.to_url_encoded(NSUTF16StringEncoding).should.equal utf16
|
178
189
|
end
|
179
190
|
|
180
191
|
it "to_url_decoded" do
|
181
192
|
encoded_string = "hey%20ho%20let's%20%7Bgo%7D"
|
182
|
-
real_decoded = encoded_string
|
183
|
-
|
193
|
+
real_decoded = CFURLCreateStringByReplacingPercentEscapes(nil, encoded_string, nil)
|
184
194
|
encoded_string.to_url_decoded.should.equal real_decoded
|
185
195
|
end
|
186
196
|
|
197
|
+
it "to_url_decoded with encoding" do
|
198
|
+
real_encoded = @raw_string.to_url_encoded(KCFStringEncodingUTF16)
|
199
|
+
real_decoded = CFURLCreateStringByReplacingPercentEscapes(nil, real_encoded, nil, KCFStringEncodingUTF16)
|
200
|
+
real_encoded.to_url_decoded.should.equal real_decoded
|
201
|
+
end
|
202
|
+
|
203
|
+
it "should not contain disallowed characters" do
|
204
|
+
encoded_string = @raw_string.to_url_encoded
|
205
|
+
encoded_string.should.not.match(/\//)
|
206
|
+
encoded_string.should.not.match(/:/)
|
207
|
+
encoded_string.should.not.match(/!/)
|
208
|
+
encoded_string.should.not.match(/&/)
|
209
|
+
end
|
187
210
|
|
188
211
|
describe "dataUsingEncoding" do
|
189
212
|
|
@@ -16,11 +16,20 @@ class CLLocationManager
|
|
16
16
|
@enabled = enable
|
17
17
|
end
|
18
18
|
|
19
|
+
def self.authorize(authorize)
|
20
|
+
@authorized = authorize
|
21
|
+
end
|
22
|
+
|
19
23
|
def self.locationServicesEnabled
|
20
24
|
return true if @enabled.nil?
|
21
25
|
@enabled
|
22
26
|
end
|
23
27
|
|
28
|
+
def self.authorizationStatus
|
29
|
+
return KCLAuthorizationStatusNotDetermined if @authorized.nil?
|
30
|
+
@authorized
|
31
|
+
end
|
32
|
+
|
24
33
|
def startUpdatingLocation
|
25
34
|
@startUpdatingLocation = true
|
26
35
|
end
|
@@ -69,6 +78,22 @@ describe BubbleWrap::Location do
|
|
69
78
|
location_manager.purpose.should == "test"
|
70
79
|
end
|
71
80
|
|
81
|
+
it "should return false when not available" do
|
82
|
+
CLLocationManager.authorize(KCLAuthorizationStatusNotDetermined)
|
83
|
+
BW::Location.authorized?.should == false
|
84
|
+
|
85
|
+
CLLocationManager.authorize(KCLAuthorizationStatusRestricted)
|
86
|
+
BW::Location.authorized?.should == false
|
87
|
+
|
88
|
+
CLLocationManager.authorize(KCLAuthorizationStatusDenied)
|
89
|
+
BW::Location.authorized?.should == false
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should return true when available" do
|
93
|
+
CLLocationManager.authorize(KCLAuthorizationStatusAuthorized)
|
94
|
+
BW::Location.authorized?.should == true
|
95
|
+
end
|
96
|
+
|
72
97
|
it "should throw error if not enabled" do
|
73
98
|
CLLocationManager.enable(false)
|
74
99
|
|
@@ -51,7 +51,7 @@ describe "RSSParser" do
|
|
51
51
|
# To avoid interfering the http_spec's mocking, we only want to override HTTP.get if it's
|
52
52
|
# for the RSSParser spec.
|
53
53
|
alias_method :original_get, :get
|
54
|
-
def get(url, options={}, &block)
|
54
|
+
def get(url, options = {}, &block)
|
55
55
|
if url == 'https://raw.github.com/gist/2952427/9f1522cbe5d77a72c7c96c4fdb4b77bd58d7681e/atom.xml'
|
56
56
|
string = File.read(File.join(App.resources_path, 'atom.xml'))
|
57
57
|
yield BW::HTTP::Response.new(body: string.to_data, status_code: 200)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bubble-wrap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Aimonetti
|
@@ -14,7 +14,7 @@ authors:
|
|
14
14
|
autorequire:
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
|
-
date: 2014-
|
17
|
+
date: 2014-07-11 00:00:00.000000000 Z
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: bubble-wrap-http
|
@@ -22,14 +22,14 @@ dependencies:
|
|
22
22
|
requirements:
|
23
23
|
- - '='
|
24
24
|
- !ruby/object:Gem::Version
|
25
|
-
version: 1.
|
25
|
+
version: 1.7.0
|
26
26
|
type: :runtime
|
27
27
|
prerelease: false
|
28
28
|
version_requirements: !ruby/object:Gem::Requirement
|
29
29
|
requirements:
|
30
30
|
- - '='
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 1.
|
32
|
+
version: 1.7.0
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: mocha
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -123,6 +123,7 @@ extra_rdoc_files:
|
|
123
123
|
- motion/core/string.rb
|
124
124
|
- motion/core/time.rb
|
125
125
|
- motion/font/font.rb
|
126
|
+
- motion/ios/7/uiactivity_view_controller_constants.rb
|
126
127
|
- motion/location/location.rb
|
127
128
|
- motion/location/pollute.rb
|
128
129
|
- motion/mail/mail.rb
|
@@ -250,6 +251,7 @@ files:
|
|
250
251
|
- motion/core/string.rb
|
251
252
|
- motion/core/time.rb
|
252
253
|
- motion/font/font.rb
|
254
|
+
- motion/ios/7/uiactivity_view_controller_constants.rb
|
253
255
|
- motion/location/location.rb
|
254
256
|
- motion/location/pollute.rb
|
255
257
|
- motion/mail/mail.rb
|
@@ -371,7 +373,7 @@ files:
|
|
371
373
|
- spec/motion/ui/ui_view_wrapper_spec.rb
|
372
374
|
- spec/motion/util/constants_spec.rb
|
373
375
|
- spec/motion/util/deprecated_spec.rb
|
374
|
-
homepage: http://
|
376
|
+
homepage: http://rubymotion.github.io/BubbleWrap/
|
375
377
|
licenses: []
|
376
378
|
metadata: {}
|
377
379
|
post_install_message:
|