Package com.iizix.device.flash
Interface IFlashlight
- All Known Implementing Classes:
- Flash
public interface IFlashlight
The flashlight/torch interface when supported, currently only in iiziRun using Cordova. The flashlight intensity only works under iOS.
See cordova-plugin-flashlight of the implementation in Cordova for more information.
- Author:
- Christopher Mindus
- Nested Class SummaryNested Classes
- Field SummaryFieldsModifier and TypeFieldDescription- static final IFlashlightDefault instance that always returns unsupported and not Android nor iOS client, and throws IllegalArgumentException when attempting to open a setting.
- Method SummaryModifier and TypeMethodDescription- boolean- addListener- (IFlashlightListener listener) Adds a listener to the flashlight that receives notifications of the flashlight state and return code of operations.- booleanGets the current availability and state of the flashlight, if successful, it will cause the registered listener(s) to be invoked asynchronously.Gets the client session associated with this flashlight instance.- doubleGets the current flashlight intensity, initially set to 1.0, but also set at the last flashlight- switchOn(double).- booleanVerifies if the flashlight has been verified as available by a previous call to- getAsyncState().- booleanChecks if the flashlight supports intensity levels.- booleanVerifies if the flashlight is supported for the client session.- booleanGets the flashlight switched on state, initially set to- false.- boolean- removeListener- (IFlashlightListener listener) Removes a listener from the flashlight.- boolean- setIntensity- (double intensity) Gets the current flashlight intensity, initially set to 1.0, but also set at the last flashlight- switchOn(double).- booleanSwitches off the flashlight.- default boolean- switchOn()Switches on the flashlight (with maximum intensity = 1.0, for iOS).- boolean- switchOn- (double intensity) Switches on the flashlight with the requested intensity, a value between 0.0 (darkest) and 1.0 (brightest).
- Field Details- DEFAULT_IMPLDefault instance that always returns unsupported and not Android nor iOS client, and throws IllegalArgumentException when attempting to open a setting.
 
- Method Details- isSupportedboolean isSupported()Verifies if the flashlight is supported for the client session.- Returns:
- The flashlight support flag. If trueit only means that the flashlight could potentially be controlled programmatically, not that the user has allowed or enabled access to it.
 
- isIntensitySupportedboolean isIntensitySupported()Checks if the flashlight supports intensity levels.- Returns:
- trueif intensity is supported, currently only iOS using iiziRun,- falseotherwise.
 
- getClientSessionIClientSessionGyro getClientSession()Gets the client session associated with this flashlight instance.- Returns:
- The client session, or nullif it is disposed of already. Please note that the client session might be returned as non-null but that it is currently in dispose operation.
 
- addListenerAdds a listener to the flashlight that receives notifications of the flashlight state and return code of operations.- Parameters:
- listener- The listener instance for notifications.
- Returns:
- truefor success,- falseif- listeneris already registered.
 
- removeListenerRemoves a listener from the flashlight. When the last listener is removed, the flashlight will automatically be switched off (using- IFlashlight.Operation.SWITCH_OFF, not- IFlashlight.Operation.AUTO_SWITCH_OFF). This is also valid when the client session is disposed of, but then with the operation- IFlashlight.Operation.AUTO_SWITCH_OFF.- Parameters:
- listener- The listener instance for notifications.
- Returns:
- truefor success,- falseif- listeneris not registered.
 
- getAsyncStateboolean getAsyncState()Gets the current availability and state of the flashlight, if successful, it will cause the registered listener(s) to be invoked asynchronously. The first time this method is invoked for a client session and the iiziRun instance, the user may be asked to allow programmatic operational control of the flashlight. Please note that the flashlight is generally "connected" to the camera, so some devices may use the front camera rather than the back. The user might also be asked to allow camera operational control (instead of just the flashlight).- Returns:
- Boolean.TRUEif flashlight is switched on,- Boolean.FALSEif the flashlight is switched off, or- nullif state is undetermined.
- See Also:
 
- isAvailableboolean isAvailable()Verifies if the flashlight has been verified as available by a previous call to- getAsyncState().- Returns:
- trueif the flashlight has been made available for programmatic use,- falseif such a request has been denied by the user or not requested before using- getAsyncState().
 
- isSwitchedOnboolean isSwitchedOn()Gets the flashlight switched on state, initially set to- false.- Returns:
- The flashlight switched on state. Please note that this value may not be accurate if getAsyncState()not yet has invoked its listeners, or thatgetAsyncState()not has been called.
 
- getIntensitydouble getIntensity()Gets the current flashlight intensity, initially set to 1.0, but also set at the last flashlight- switchOn(double).- Returns:
- The intensity with a value range of 0.0 to 1.0, only working for iOS.
 
- setIntensityGets the current flashlight intensity, initially set to 1.0, but also set at the last flashlight- switchOn(double).- Returns:
- trueif changed,- falsefor no change.
- Throws:
- IllegalArgumentException- If the- intensityis not in the range of 0.0 to 1.0.
 
- switchOndefault boolean switchOn()Switches on the flashlight (with maximum intensity = 1.0, for iOS).- Returns:
- trueif the operation is going to issue a later callback using the function registered using- addListener(IFlashlightListener), or- falseif the flashlight is not present or the client session is disposed of.
 
- switchOnSwitches on the flashlight with the requested intensity, a value between 0.0 (darkest) and 1.0 (brightest). The value is only processed for iOS.- Returns:
- trueif the operation is going to issue a later callback using the function registered using- addListener(IFlashlightListener), or- falseif the flashlight is not present or the client session is disposed of.
- Throws:
- IllegalArgumentException- If the- intensityis not in the range of 0.0 to 1.0.
 
- switchOffboolean switchOff()Switches off the flashlight.- Returns:
- trueif the operation is going to issue a later callback using the function registered using- addListener(IFlashlightListener), or- falseif the flashlight is not present or the client session is disposed of.