Package com.iizix.prop
Class Flash
- All Implemented Interfaces:
IFlashlight
,EventListener
,IGProp<GProp<?>[]>
,IPropCnr
,Cloneable
This Flashlight or torch property is a container that holds information about client devices flashlight availability, state and intensity. The flashlight is only present with the iiziRun Cordova hybrid client. The intensity is currently only working with iOS.
- Author:
- Christopher Mindus
Nested Class Summary
Nested classes/interfaces inherited from interface com.iizix.device.flash.IFlashlight
IFlashlight.Operation
Field Summary
Fields inherited from class com.iizix.prop.PropCnr
EMPTY, EMPTY_CLASSES, EMPTY_CNRS, EXTENDS_FRAMEWORK_ERROR_ID
Fields inherited from class com.iizix.prop.GProp
GPDEBUG, PROP_ATTR_STRING_EDITOR_PROP, PROP_ATTR_STRING_ERRORED_NAME, PROP_ATTR_STRING_EXTENDS, PROP_ATTR_STRING_EXTENDS_FINAL, PROP_ATTR_STRING_EXTENDS_PRIVATE, PROP_ATTR_STRING_NULLABLE, PROP_ATTR_STRING_PRIVATE, PROP_ATTR_STRING_PRIVATE_CHANGE_EVENT, PROP_ATTR_STRING_READ_ONLY, PROP_USER_1, PROP_USER_2
Fields inherited from interface com.iizix.device.flash.IFlashlight
DEFAULT_IMPL
Fields inherited from interface com.iizix.prop.IGProp
EQC_ERROR_IGNORE_ALL, EQC_ERROR_IGNORE_REFERENCES, EQC_IGNORE_ARRAY, EQC_IGNORE_VOLATILE_OR_EDITOR, EQC_INCLUDE_PRIVATE, EQC_SAVE_FILE, EXT_CONTAINER_EXTENDS, EXT_CONTAINER_EXTENDS_VALID, EXT_EXTENDED, EXT_FINAL, EXT_OVERRIDES, EXT_OVERRIDES_FINAL_ERR, EXT_PRIVATE
Constructor Summary
Method Summary
Modifier and TypeMethodDescriptionboolean
addListener
(IFlashlightListener listener) Adds a listener to the flashlight that receives notifications of the flashlight state and return code of operations.clone()
Clones the properties.boolean
Gets 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.double
Gets the current flashlight intensity, initially set to 1.0, but also set at the last flashlightswitchOn(double)
.boolean
Verifies if the flashlight has been verified as available by a previous call togetAsyncState()
.boolean
Checks if the flashlight supports intensity levels.boolean
Verifies if the flashlight is supported for the client session.boolean
Gets the flashlight switched on state, initially set tofalse
.protected void
Called when a property is disposed of by delete/remove in a container, or by the dispose method.void
onRemoteEvent
(RemoteEvent event) Called when a remote property event should be processed by this property.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 flashlightswitchOn(double)
.boolean
Switches off the flashlight.boolean
switchOn
(double intensity) Switches on the flashlight with the requested intensity, a value between 0.0 (darkest) and 1.0 (brightest).Methods inherited from class com.iizix.prop.PropCnr
__transferChildProps, addPredefinedProps, addProp, addProp, addProp2, addProp2, appendPropValue, canRequestFocus, completeVirtualize, containsProp, containsProp, convertLoadedProp, couldRequestFocusIfVirtualized, createCopyOfAtom, createUniqueAtom, createUniqueAtom, createUniqueAtom, createVSReference, doPropEqualsArrayValues, enablePropCommunication, enablePropHashMap, equalsTree, equalsTree, getAllProps, getAllProps, getAllProps, getAllProps, getAllProps, getAllProps, getAllProps, getAllProps, getBool, getBool, getBool, getBool, getChildPropError, getChildPropError, getChildPropErrorSeverity, getChildPropErrorSeverity, getErrorsProp, getExtendsContainer, getExtendsError, getExtendsName, getExtendsOverride, getExtendsPossibleClasses, getFirstProp, getFirstProp, getFocusEngine, getInt, getInt, getInt, getInt, getLong, getLong, getLong, getLong, getNumber, getNumber, getNumber, getNumber, getPossibleChildren, getPredefinedProps, getProp, getProp, getProp, getProp, getProp, getProp, getProp, getProp, getProp, getProp, getProp, getPropBaseReference, getPropCnr, getPropCount, getPropCount, getPropIndex, getPropIndex, getPropIndexes, getProps, getProps, getPropValue, getPropValue, getPropValue, getPropValue, getPropValue, getPropValue, getPropValue, getPropValue0, getRetargetedVerifyContainer, getString, getString, getString, getString, getValueClasses, getVSReference, hasFocus, hasSendData, initializeElement, initializeExtendsFramework, initializeProp, initializeValue, initPropCnr, insertProp, insertProp2, isChild, isExtendsOverriden, isExtendsPropertyValid, isExtendsRoot, isPropAddRemoveAllowed, isPropCommunicating, isPropExtended, list, list, logPropNotFound, maybeAddProp, onInsertProp, onPropRemoved, onPropTreeInitialized, onReferenceEvent, onVirtualContainerCreated, onVirtualizationCompleted, paramString, prepare, removeAllProps, removeAllProps2, removeProp, removeProp, removeProp, removeProp, removeProp, removeProp, removeProp, removeProp2, removeProp2, removeProp2, removeProp2, removeProp2, removeProp2, removeProp2, reorderProps, replaceProps, requestFocus, requestFocus, requestFocusEx, requestFocusEx, resolveReferences, resolveRuntimeReferences, setBool, setBool, setBool, setBool, setCreateRequiredProp, setExtendsName, setExtendsOverride, setInt, setInt, setInt, setLong, setLong, setLong, setLong, setNumber, setNumber, setNumber, setNumber, setProp, setProp, setProp, setProp2, setProp2, setPropValue, setPropValue, setPropValue, setPropValue, setPropValue, setPropValue, setString, setString, setString, setString, shouldCreateProps, shouldSerializeToXML, toElementString, toNativeValue0, usePropHashMap, usesPropIndex, validateChildPropInValue, validateClassInstances, validatePropType, validatePropValue, verify, verifyInternalUseOnly, verifyTree, virtualize
Methods inherited from class com.iizix.prop.GProp
addPropError, addPropListener, appendProp, convertPropError, dispose, equals, equals, equalsErrors, equalsObj, equalsPropValue, equalValues, finalize, fine, fine, finer, finer, finest, finest, fromElementString, getAliasName, getAppSessionGyro, getAppWorker, getAtomPath, getAttribute, getChildReferencePropName, getClientSessionGyro, getClientWorker, getConstraints, getEnvironment, getErroredPropItems, getErroredProps, getErrorsProp, getExtendsRootContainer, getFullPropName, getFullPropName, getFullPropNameDebug, getFullPropNameDebug, getListeners, getModuleFolder, getModuleFolder, getParent, getParent, getProjectName, getPropAtom, getPropError, getPropError, getPropErroredName, getPropErrorSeverity, getPropExtendsFlags, getPropFromPath, getPropFromPath, getPropFromReference, getPropFromReference, getPropIndex, getPropName, getPropPath, getPropPath, getPropReferenceTarget, getPropRootPropMgr, getPropTreeErrorSeverity, getPropValue, getPropValue, getPropValueObject, getReferencePropName, getReferencePropNameNoAssert, getRelativePropName, getRootFromName, getRootName, getRootParent, getRootParentNoAssert, getTreeLock, hasChanged, hasCircularReferencesError, hasPrivateChangeEventProp, hasPropError, hasPropTreeError, info, info, initializeGElement, initializeGProp, isDisposed, isPropChildOf, isPropClientCreated, isPropCreateRequired, isPropExtended, isPropExtendsFinal, isPropExtendsPrivate, isPropExtendsPrivateInRoot, isPropExtendsPrivateInRoot, isPropFile, isPropFolder, isPropForEditor, isPropNullable, isPropPrivate, isPropPrivateAtCreation, isPropReadOnly, isPropReferenceTreeValid, isPropRoot, isPropRootLoading, isPropRootTreeModificationsAllowed, isPropUSER, isPropValueTreeLockNeeded, isPropVirtualized, isPropVirtualizing, isPropVolatile, isPropVolatileOrEditorOnly, isProxied, isSibling, list, list, list, mapAliasToReference, mapAliasToReference, mapReferenceToAlias, mapReferenceToAlias, mapReferenceToProjectRelative, modifyPropValue, moveProp, moveProp, moveProp, onEvent, onEventSelf, onPrepare, onPropInvalidateCache, onPropParentChanged, onPropValueSet, paramString, paramValue, post, post, removePropError, removePropListener, removePropUSER, renameProp, renameProp2, resetChangedTree, setChanged, setConstraints, setConstraints, setParent, setPrivateChangeEventProp, setPrivateCreateRequiredProp, setPropError, setPropErroredName, setPropExtended, setPropExtendsFinal, setPropExtendsPrivate, setPropForEditor, setPropNullable, setPropPrivate, setPropReadOnly, setPropUSER, setPropValue, setPropValue, setPropValue, setPropValueIncognito, setPropVolatile, severe, severe, severe, shouldSerializeToXML, throwIfReadOnly, toNativeValue, toString, toString, triggerRemoteEvent, triggerRemoteEvent, validateProp, warning, warning, warning
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.iizix.device.flash.IFlashlight
switchOn
Methods inherited from interface com.iizix.prop.IGProp
addPropError, addPropListener, dispose, equals, fine, fine, finer, finer, finest, finest, fromElementString, getAppSessionGyro, getAtomPath, getClientSessionGyro, getConstraints, getEnvironment, getErroredPropItems, getErroredProps, getErrorsProp, getExtendsRootContainer, getFullPropName, getFullPropNameDebug, getModuleFolder, getModuleFolder, getParent, getParent, getPropAtom, getPropError, getPropError, getPropErrorSeverity, getPropExtendsFlags, getPropFromPath, getPropFromReference, getPropIndex, getPropName, getPropPath, getPropPath, getPropRootPropMgr, getPropTreeErrorSeverity, getPropValue, getPropValue, getReferencePropName, getRelativePropName, getRootParent, getTreeLock, hasChanged, hasCircularReferencesError, hasPrivateChangeEventProp, hasPropError, hasPropTreeError, info, info, initializeGElement, initializeGProp, isDisposed, isPropChildOf, isPropClientCreated, isPropCreateRequired, isPropExtended, isPropExtendsFinal, isPropExtendsPrivate, isPropExtendsPrivateInRoot, isPropExtendsPrivateInRoot, isPropFile, isPropFolder, isPropNullable, isPropPrivate, isPropReadOnly, isPropReferenceTreeValid, isPropRoot, isPropVirtualized, isSibling, list, list, list, mapAliasToReference, mapReferenceToAlias, mapReferenceToProjectRelative, moveProp, moveProp, moveProp, onEvent, onEventSelf, removePropError, removePropListener, renameProp, setChanged, setConstraints, setConstraints, setParent, setPrivateChangeEventProp, setPropError, setPropExtendsFinal, setPropExtendsPrivate, setPropNullable, setPropPrivate, setPropReadOnly, setPropValue, setPropValue, severe, severe, severe, toNativeValue, triggerRemoteEvent, triggerRemoteEvent, validateProp, warning, warning, warning
Methods inherited from interface com.iizix.prop.IPropCnr
canRequestFocus, canRequestFocus, couldRequestFocusIfVirtualized, couldRequestFocusIfVirtualized
Constructor Details
Flash
public Flash()Creates the flashlight properties without a name.Flash
Creates the flashlight properties with a name.- Parameters:
atom
- The atom name.
Method Details
onPropDispose
protected void onPropDispose()Called when a property is disposed of by delete/remove in a container, or by the dispose method.The Property Container clears the structure of unsent communication requests to clear memory.
This call is done just at the end of the delete/remove routine in the container, without synchronization.
During this call, whatever components that e.g. the client needs to disposed of is done.
Subclasses needing to perform some intelligent operations upon deletion should do it by overloading this method and always call the
super.onPropDispose()
method.- Overrides:
onPropDispose
in classPropCnr
clone
Clones the properties.onRemoteEvent
Called when a remote property event should be processed by this property.- Specified by:
onRemoteEvent
in interfaceIGProp<GProp<?>[]>
- Overrides:
onRemoteEvent
in classGProp<GProp<?>[]>
- Parameters:
event
- The remote event.
isSupported
public boolean isSupported()Verifies if the flashlight is supported for the client session.- Specified by:
isSupported
in interfaceIFlashlight
- Returns:
- The flashlight support flag. If
true
it only means that the flashlight could potentially be controlled programmatically, not that the user has allowed or enabled access to it.
isIntensitySupported
public boolean isIntensitySupported()Checks if the flashlight supports intensity levels.- Specified by:
isIntensitySupported
in interfaceIFlashlight
- Returns:
true
if intensity is supported, currently only iOS using iiziRun,false
otherwise.
getClientSession
Gets the client session associated with this flashlight instance.- Specified by:
getClientSession
in interfaceIFlashlight
- Returns:
- The client session, or
null
if 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.
addListener
Adds a listener to the flashlight that receives notifications of the flashlight state and return code of operations.- Specified by:
addListener
in interfaceIFlashlight
- Parameters:
listener
- The listener instance for notifications.- Returns:
true
for success,false
iflistener
is already registered.
removeListener
Removes a listener from the flashlight. When the last listener is removed, the flashlight will automatically be switched off (usingIFlashlight.Operation.SWITCH_OFF
, notIFlashlight.Operation.AUTO_SWITCH_OFF
). This is also valid when the client session is disposed of, but then with the operationIFlashlight.Operation.AUTO_SWITCH_OFF
.- Specified by:
removeListener
in interfaceIFlashlight
- Parameters:
listener
- The listener instance for notifications.- Returns:
true
for success,false
iflistener
is not registered.
getAsyncState
public boolean 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).- Specified by:
getAsyncState
in interfaceIFlashlight
- Returns:
true
if flashlight will be switched on,false
if the flashlight is not supported, not available, or client is disposed of.- See Also:
isAvailable
public boolean isAvailable()Verifies if the flashlight has been verified as available by a previous call togetAsyncState()
.- Specified by:
isAvailable
in interfaceIFlashlight
- Returns:
true
if the flashlight has been made available for programmatic use,false
if such a request has been denied by the user or not requested before usinggetAsyncState()
.
isSwitchedOn
public boolean isSwitchedOn()Gets the flashlight switched on state, initially set tofalse
.- Specified by:
isSwitchedOn
in interfaceIFlashlight
- 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.
getIntensity
public double getIntensity()Gets the current flashlight intensity, initially set to 1.0, but also set at the last flashlightswitchOn(double)
.- Specified by:
getIntensity
in interfaceIFlashlight
- Returns:
- The intensity with a value range of 0.0 to 1.0, only working for iOS.
setIntensity
Gets the current flashlight intensity, initially set to 1.0, but also set at the last flashlightswitchOn(double)
.- Specified by:
setIntensity
in interfaceIFlashlight
- Returns:
true
if changed,false
for no change.- Throws:
IllegalArgumentException
- If theintensity
is not in the range of 0.0 to 1.0.
switchOn
Switches on the flashlight with the requested intensity, a value between 0.0 (darkest) and 1.0 (brightest). The value is only processed for iOS.- Specified by:
switchOn
in interfaceIFlashlight
- Returns:
true
if the operation is going to issue a later callback using the function registered usingaddListener(IFlashlightListener)
, orfalse
if the flashlight is not present or the client session is disposed of.- Throws:
IllegalArgumentException
- If theintensity
is not in the range of 0.0 to 1.0.
switchOff
public boolean switchOff()Switches off the flashlight.- Specified by:
switchOff
in interfaceIFlashlight
- Returns:
true
if the operation is going to issue a later callback using the function registered usingaddListener(IFlashlightListener)
, orfalse
if the flashlight is not present or the client session is disposed of.