--[[----------------------------------------------------------------------------

WFAppState.lua

--------------------------------------------------------------------------------

ADOBE CONFIDENTIAL
------------------
Copyright 2014 Adobe Systems Incorporated
All Rights Reserved.

NOTICE: All information contained herein is, and remain the property of
Adobe Systems Incorporated and its suppliers, if any. The intellectual and
technical concepts contained herein are proprietary to Adobe Systems
Incorporated and its suppliers and may be covered by U.S. and Foreign
Patents, patents in process, and are protected by trade secret or copyright
law.  Dissemination of this information or reproduction of this material is
strictly forbidden unless prior written permission is obtained from
Adobe Systems Incorporated.

------------------------------------------------------------------------------]]

local WFPlatformInfo = require "WFPlatformInfo"

local WFAppStateImp = nil
if WFPlatformInfo.isiOS then
	 WFAppStateImp = require "WFAppStateImp"
end

--------------------------------------------------------------------------------

--[[!
	\brief Returns whether the app is the foreground, active app
	
	On iOS, this returns true when [ UIApplication applicationState ]
	is equal to UIApplicationStateActive.  On other platforms,
	this simply returns true.
	
	\return backgroundState (boolean)
--]]
local function applicationIsActive( )
	if WFPlatformInfo.isiOS then
		return WFAppStateImp.applicationIsActive()
	else
		return true
	end
end

--------------------------------------------------------------------------------

--[[!
	\brief Returns whether the app is in the background
	
	On iOS, this returns true when [ UIApplication applicationState ]
	is equal to UIApplicationStateBackground.  On other platforms,
	this simply returns false.  Note that both applicationIsActive and
	applicationIsInBackground can return false (if the application
	is inactive.  See UIApplicationStateInactive in Apple documentation
	for iOS.)
	
	\return backgroundState (boolean)
--]]
local function applicationIsInBackground( )
	if WFPlatformInfo.isiOS then
		return WFAppStateImp.applicationIsInBackground()
	else
		return false
	end
end

--------------------------------------------------------------------------------

--[[!
	\brief The amount of time the app has to run in the background, in
	seconds
	
	On iOS this returns the value from UIApplication.  On other
	platforms it returns 3600 (one hour).
	
	\return time (number) Time remaining, in seconds.
--]]
local function backgroundTimeRemaining( )
	if WFPlatformInfo.isiOS then
		return WFAppStateImp.backgroundTimeRemaining()
	else
		return 3600
	end
end

--==============================================================================

return {
	applicationIsActive = applicationIsActive,
	applicationIsInBackground = applicationIsInBackground,
	backgroundTimeRemaining = backgroundTimeRemaining
}
