Skip to content

Commit

Permalink
Merge pull request #424 from rubymotion/ios7-min
Browse files Browse the repository at this point in the history
Bump the required version of iOS to >= 7
  • Loading branch information
markrickert committed Jul 10, 2015
2 parents 81070df + b09ac97 commit 889e428
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 25 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Expand Up @@ -12,4 +12,6 @@ script:
- bundle exec rake clean
- bundle exec rake spec
- bundle exec rake clean
- bundle exec rake spec target=7.1
- bundle exec rake clean
- bundle exec rake spec osx=true
5 changes: 5 additions & 0 deletions Rakefile
Expand Up @@ -32,8 +32,13 @@ Motion::Project::App.setup do |app|
app.spec_files -= Dir.glob("./spec/motion/#{package}/**/*.rb")
end
else
app.deployment_target = '7.1'
app.info_plist['NSLocationAlwaysUsageDescription'] = 'Description'
app.info_plist['NSLocationWhenInUseUsageDescription'] = 'Description'

app.spec_files -= Dir.glob("./spec/motion/**/osx/**.rb")
end

app.version = '1.2.3'
app.short_version = '3.2.1'
end
Expand Down
8 changes: 4 additions & 4 deletions lib/bubble-wrap/loader.rb
Expand Up @@ -48,13 +48,13 @@ def before_config(app)

def after_config(config)
BubbleWrap.require_ios do
ios7_files = 'motion/ios/7/uiactivity_view_controller_constants.rb'
if config.send(:deployment_target).to_f >= 7.0
::BubbleWrap.require(ios7_files)
ios8_files = 'motion/ios/8/location_constants.rb'
if config.send(:deployment_target).to_f >= 8.0
::BubbleWrap.require(ios8_files)
before_config(config)
else
config.files = config.files.reject {|s|
s.include?(ios7_files)
s.include?(ios8_files)
}
end
end
Expand Down
10 changes: 0 additions & 10 deletions motion/ios/7/uiactivity_view_controller_constants.rb

This file was deleted.

21 changes: 21 additions & 0 deletions motion/ios/8/location_constants.rb
@@ -0,0 +1,21 @@
module BW
# New additions to CLAuthorizationStatus in ios8
# see: https://developer.apple.com/library/prerelease/ios/documentation/CoreLocation/Reference/CLLocationManager_Class/index.html#//apple_ref/c/tdef/CLAuthorizationStatus
Constants.register(
KCLAuthorizationStatusAuthorized,
KCLAuthorizationStatusAuthorizedWhenInUse,
KCLAuthorizationStatusAuthorizedAlways
)

module Location
module_function

def authorized?
[
BW::Constants.get("KCLAuthorizationStatus", :authorized),
BW::Constants.get("KCLAuthorizationStatus", :authorized_always),
BW::Constants.get("KCLAuthorizationStatus", :authorized_when_in_use)
].include?(CLLocationManager.authorizationStatus)
end
end
end
8 changes: 3 additions & 5 deletions motion/location/location.rb
Expand Up @@ -25,10 +25,6 @@ module Error
KCLLocationAccuracyNearestTenMeters, KCLLocationAccuracyHundredMeters,
KCLLocationAccuracyKilometer, KCLLocationAccuracyThreeKilometers

# New additions to CLAuthorizationStatus in ios8
# see: https://developer.apple.com/library/prerelease/ios/documentation/CoreLocation/Reference/CLLocationManager_Class/index.html#//apple_ref/c/tdef/CLAuthorizationStatus
Constants.register KCLAuthorizationStatusAuthorizedWhenInUse, KCLAuthorizationStatusAuthorizedAlways

module_function
# Start getting locations
# @param [Hash] options = {
Expand Down Expand Up @@ -161,7 +157,9 @@ def enabled?

# returns true/false whether services are enabled for the _app_
def authorized?
[KCLAuthorizationStatusAuthorized, KCLAuthorizationStatusAuthorizedAlways, KCLAuthorizationStatusAuthorizedWhenInUse].include?(CLLocationManager.authorizationStatus)
[
BW::Constants.get("KCLAuthorizationStatus", :authorized)
].include?(CLLocationManager.authorizationStatus)
end

def error(type)
Expand Down
7 changes: 6 additions & 1 deletion motion/ui/ui_activity_view_controller_wrapper.rb
Expand Up @@ -41,6 +41,11 @@ def new(options = {}, presenting_controller = nil, &block)
UIActivityTypePrint,
UIActivityTypeCopyToPasteboard,
UIActivityTypeAssignToContact,
UIActivityTypeSaveToCameraRoll
UIActivityTypeSaveToCameraRoll,
UIActivityTypeAddToReadingList,
UIActivityTypePostToFlickr,
UIActivityTypePostToVimeo,
UIActivityTypePostToTencentWeibo,
UIActivityTypeAirDrop
)
end
12 changes: 7 additions & 5 deletions spec/motion/location/location_spec.rb
Expand Up @@ -93,11 +93,13 @@ def reset
CLLocationManager.authorize(KCLAuthorizationStatusAuthorized)
BW::Location.authorized?.should == true

CLLocationManager.authorize(KCLAuthorizationStatusAuthorizedWhenInUse)
BW::Location.authorized?.should == true

CLLocationManager.authorize(KCLAuthorizationStatusAuthorizedAlways)
BW::Location.authorized?.should == true
# if Device.ios_version.to_f >= 8.0
# CLLocationManager.authorize(KCLAuthorizationStatusAuthorizedWhenInUse)
# BW::Location.authorized?.should == true
#
# CLLocationManager.authorize(KCLAuthorizationStatusAuthorizedAlways)
# BW::Location.authorized?.should == true
# end
end

it "should throw error if not enabled" do
Expand Down

0 comments on commit 889e428

Please sign in to comment.