motion/core/app.rb in bubble-wrap-1.2.0 vs motion/core/app.rb in bubble-wrap-1.3.0.osx
- old
+ new
@@ -24,38 +24,10 @@
def user_cache
NSUserDefaults.standardUserDefaults
end
- # Displays a UIAlertView.
- #
- # title - The title as a String.
- # args - The title of the cancel button as a String, or a Hash of options.
- # (Default: { cancel_button_title: 'OK' })
- # cancel_button_title - The title of the cancel button as a String.
- # message - The main message as a String.
- # block - Yields the alert object if a block is given, and does so before the alert is shown.
- def alert(title, *args, &block)
- options = { cancel_button_title: 'OK' }
- options.merge!(args.pop) if args.last.is_a?(Hash)
-
- if args.size > 0 && args.first.is_a?(String)
- options[:cancel_button_title] = args.shift
- end
-
- alert = UIAlertView.alloc.initWithTitle title,
- message: options[:message],
- delegate: nil,
- cancelButtonTitle: options[:cancel_button_title],
- otherButtonTitles: nil
-
- yield(alert) if block_given?
-
- alert.show
- alert
- end
-
# Executes a block after a certain delay
# Usage example:
# App.run_after(0.5) { p "It's #{Time.now}" }
def run_after(delay,&block)
NSTimer.scheduledTimerWithTimeInterval( delay,
@@ -63,21 +35,10 @@
selector: "call:",
userInfo: nil,
repeats: false)
end
- # Opens an url (string or instance of `NSURL`)
- # in the device's web browser.
- # Usage Example:
- # App.open_url("http://matt.aimonetti.net")
- def open_url(url)
- unless url.is_a?(NSURL)
- url = NSURL.URLWithString(url)
- end
- UIApplication.sharedApplication.openURL(url)
- end
-
@states = {}
def states
@states
end
@@ -92,35 +53,10 @@
def version
NSBundle.mainBundle.infoDictionary['CFBundleVersion']
end
- # Return application frame
- def frame
- UIScreen.mainScreen.applicationFrame
- end
-
- # Main Screen bounds. Useful when starting the app
- def bounds
- UIScreen.mainScreen.bounds
- end
-
- # Application Delegate
- def delegate
- UIApplication.sharedApplication.delegate
- end
-
- # the Application object.
- def shared
- UIApplication.sharedApplication
- end
-
- # the Application Window
- def window
- UIApplication.sharedApplication.keyWindow || UIApplication.sharedApplication.windows[0]
- end
-
# @return [NSLocale] locale of user settings
def current_locale
languages = NSLocale.preferredLanguages
if languages.count > 0
return NSLocale.alloc.initWithLocaleIdentifier(languages.first)
@@ -144,8 +80,11 @@
def release?
environment == 'release'
end
+ def osx?
+ Kernel.const_defined?(:NSApplication)
+ end
end
end
::App = BubbleWrap::App unless defined?(::App)