Class CodenameOneImplementation

java.lang.Object
com.codename1.impl.CodenameOneImplementation

public abstract class CodenameOneImplementation extends Object

Represents a vendor extension mechanizm for Codename One, WARNING: this class is for internal use only and is subject to change in future API revisions. To replace the way in which Codename One performs its task this class can be extended and its functionality replaced or enhanced.

It is the responsibility of the implementation class to grab and fire all events to the Display specifically for key, pointer events and screen resolution.

  • Constructor Details

    • CodenameOneImplementation

      public CodenameOneImplementation()
  • Method Details

    • setOnExit

      public static void setOnExit(Runnable on)
      Set a task to be executed once the implementation is being destroyed
    • setPushCallback

      public static void setPushCallback(PushCallback push)

      Allows the system to register to receive push callbacks

      Parameters
      • push: the callback object
    • getPurchaseCallback

      public static PurchaseCallback getPurchaseCallback()
      Returns the purchase callback instance
    • setPurchaseCallback

      public static void setPurchaseCallback(PurchaseCallback pc)

      Allows the system to register the purchase callback instance

      Parameters
      • pc: the pc callback
    • getStringArrayClass

      public static Class getStringArrayClass()
      This is a temporary workaround for an XMLVM Bug!
    • getStringArray2DClass

      public static Class getStringArray2DClass()
      This is a temporary workaround for an XMLVM Bug!
    • getImageArrayClass

      public static Class getImageArrayClass()
      This is a temporary workaround for an XMLVM Bug!
    • getObjectArrayClass

      public static Class getObjectArrayClass()
      This is a temporary workaround for an XMLVM Bug!
    • stopPolling

      protected static void stopPolling()
      Stops the polling push loop
    • getApplicationKey

      protected static String getApplicationKey()

      Returns the key for the application comprised of the builders email coupled with the package name. It should uniquely identify the application across different builds which allows interaction with the cloud.

      Returns

      a unique string with the format builders_email/packagename

    • registerServerPush

      public static boolean registerServerPush(String id, String applicationKey, byte pushType, String udid, String packageName)

      Sends a server request to register push support. This is a method for use by implementations.

      Parameters
      • id: the platform specific push ID

      • applicationKey: the unique id of the application

      • pushType: for server side type

      • packageName: the application package name used by the push service

      Returns

      true for success, false otherwise

    • registerPushOnServer

      public static void registerPushOnServer(String id, String applicationKey, byte pushType, String udid, String packageName)

      Sends a server request to register push support. This is a method for use by implementations.

      Parameters
      • id: the platform specific push ID

      • applicationKey: the unique id of the application

      • pushType: for server side type

      • packageName: the application package name used by the push service

    • deregisterPushFromServer

      public static void deregisterPushFromServer()
      For use by implementations, stop receiving push notifications from the server
    • registerPollingFallback

      protected static void registerPollingFallback()

      Registers a polling thread to simulate push notification

      Deprecated

      this functionality is no longer supported

    • initImpl

      public final void initImpl(Object m)

      Invoked by the display init method allowing the implementation to "bind"

      Parameters
      • m: the object passed to the Display init method
    • isInitialized

      public boolean isInitialized()
      Returns true if the implementation is initialized.
    • sendPushRegistrationError

      protected void sendPushRegistrationError(String message, int errorCode)

      Allows implementations to send an error to the push callback

      Parameters
      • message: the error message

      • errorCode: the error code

    • init

      public abstract void init(Object m)

      Invoked by the display init method allowing the implementation to "bind"

      Parameters
      • m: the object passed to the Display init method
    • initEDT

      public void initEDT()
      Some implementations might need to perform initializations of the EDT thread
    • deinitialize

      public void deinitialize()
      Allows subclasses to cleanup if necessary
    • playDialogSound

      public void playDialogSound(int type)

      Invoked when a dialog is shown, this method allows a dialog to play a sound

      Parameters
      • type: the type of the dialog matching the dialog classes defined types
    • vibrate

      public void vibrate(int duration)

      Vibrates the device for the given length of time

      Parameters
      • duration: length of time to vibrate
    • flashBacklight

      public void flashBacklight(int duration)

      Flash the backlight of the device for the given length of time

      Parameters
      • duration: length of time to flash the backlight
    • getDisplayWidth

      public abstract int getDisplayWidth()

      Returns the width dimension of the display controlled by this implementation

      Returns

      the width

    • getDisplayHeight

      public abstract int getDisplayHeight()

      Returns the height dimension of the display controlled by this implementation

      Returns

      the height

    • getActualDisplayHeight

      public int getActualDisplayHeight()

      Returns the display height ignoring manipulations performed by the VKB

      Returns

      the height

    • getDesktopSize

      public Dimension getDesktopSize()

      Returns the size of the desktop area hosting the application window when running on a desktop platform. Implementations that do not support windows may return null.

      Returns

      the desktop size or null

    • getWindowBounds

      public Rectangle getWindowBounds()

      Returns the bounds of the application window when running on a desktop platform.

      Returns

      the window bounds, defaults to the current display size

    • setWindowSize

      public void setWindowSize(int width, int height)

      Requests a resize of the application window when supported by the platform.

      Parameters
      • width: the desired window width in pixels

      • height: the desired window height in pixels

    • getInitialWindowSizeHintPercent

      public Dimension getInitialWindowSizeHintPercent()

      Returns the optional desktop window size hint provided by the first form.

      Returns

      the stored hint or null

    • setInitialWindowSizeHintPercent

      public void setInitialWindowSizeHintPercent(Dimension hint)

      Stores an optional window size hint (in percent values) for desktop environments. Implementations that do not support windows may ignore this value.

      Parameters
      • hint: @param hint a Dimension whose width/height represent percentages of the desktop to use for the initial window size, or null to clear a previously stored hint
    • handleEDTException

      public boolean handleEDTException(Throwable err)

      Invoked when an exception occurs on the EDT, allows the implementation to take control of the device to produce testing information.

      Parameters
      • err: the exception that was caught in the EDT loop
      Returns
      Returns:
      false by default, true if the exception shouldn't be handled further by the EDT
    • editStringImpl

      public final void editStringImpl(Component cmp, int maxSize, int constraint, String text, int initiatingKeycode)

      Encapsulates the editing code which is specific to the platform, some platforms would allow "in place editing" MIDP does not.

      Parameters
      • cmp: the TextArea component

      • maxSize: the maximum size from the text area

      • constraint: the constraints of the text area

      • text: the string to edit

      • initiatingKeycode: the keycode used to initiate the edit.

    • setFocusedEditingText

      public void setFocusedEditingText(Component cmp)
      Sets current editingText value and sets it focused. NB! it not call editString, that is it should be called only internally and actually the methdo should not be added :)
    • stopTextEditing

      public void stopTextEditing()
      Invoked for special cases to stop text editing and clear native editing state
    • stopTextEditing

      public void stopTextEditing(Runnable onFinish)
      Invoked for special cases to stop text editing and clear native editing state
    • usesInvokeAndBlockForEditString

      public boolean usesInvokeAndBlockForEditString()
      Using invokeAndBlock inside EditString creates peculiar behaviour that needs to be worked around. Ideally no port should use invokeAndBlock for this but currently JavaSE and UWP both do. Need to be able to detect this for workarounds.
    • editString

      public abstract void editString(Component cmp, int maxSize, int constraint, String text, int initiatingKeycode)

      Encapsulates the editing code which is specific to the platform, some platforms would allow "in place editing" MIDP does not.

      Parameters
      • cmp: the TextArea component

      • maxSize: the maximum size from the text area

      • constraint: the constraints of the text area

      • text: the string to edit

      • initiatingKeycode: the keycode used to initiate the edit.

    • nativeEditorPaintsHint

      public boolean nativeEditorPaintsHint()
    • isEditingText

      public boolean isEditingText()

      Returns true if we are currently editing a component

      Returns

      whether a component is being edited

    • platformUsesInputMode

      public boolean platformUsesInputMode()
      Checks to see if this is a platform that uses the TextField#setInputMode(java.lang.String).
    • isNativeEditorVisible

      public boolean isNativeEditorVisible(Component c)

      Checks whether the native text editor is currently visible over top of the given component (usually a TextArea

      Parameters
      • c: The textarea/component we are checking
      Returns

      True if the native editor is visible.

    • updateNativeEditorText

      public void updateNativeEditorText(Component c, String text)

      Called when TextArea text is changed. Can be used by the native implementation to trigger an update to the native editor if in async edit mode.

      Parameters
      • c: The TextArea that is being edited.

      • text

    • hideTextEditor

      public void hideTextEditor()
      In case of scrolling we can hide the text editor unless the user starts typing again, this is only relevant for the async mode...
    • getAppArg

      public String getAppArg()
    • setAppArg

      public void setAppArg(String arg)
    • repaintTextEditor

      protected final void repaintTextEditor(boolean focus)
      Allows the implementation to refresh the text field
    • isEditingText

      public boolean isEditingText(Component c)

      Returns true if we are currently editing this component

      Returns

      whether a component is being edited

    • getEditingText

      public Component getEditingText()
      Gets the component that is currently editing text
    • isAsyncEditMode

      public boolean isAsyncEditMode()

      Returns true if edit string will return immediately and broadcast editing events directly to the text field

      Returns

      false by default

    • getInvisibleAreaUnderVKB

      public int getInvisibleAreaUnderVKB()

      Returns the height of the VKB when it is open for an implementation that requires us to allow scrolling further

      Returns

      height in pixels

    • saveTextEditingState

      public void saveTextEditingState()
      Invoked if Codename One needs to dispose the native text editing but would like the editor to store its state.
    • hasPendingPaints

      public boolean hasPendingPaints()

      Returns true if the implementation still has elements to paint.

      Returns

      false by default

    • numAlphaLevels

      public int numAlphaLevels()

      Return the number of alpha levels supported by the implementation.

      Returns

      the number of alpha levels supported by the implementation

      Deprecated

      this method isn't implemented in most modern devices

    • numColors

      public int numColors()

      Returns the number of colors applicable on the device, note that the API does not support gray scale devices.

      Returns

      the number of colors applicable on the device

      Deprecated

      this method isn't implemented in most modern devices

    • getComponentScreenGraphics

      public Graphics getComponentScreenGraphics(Component cmp, Graphics currentContext)

      This method allows customizing/creating a graphics context per component which is useful for some elaborate implementations of Codename One. This method is only relevant for elborate components such as container which render their own components rather than invoke repaint()

      Parameters
      • cmp: component being rendered

      • currentContext: the current graphics context

      Returns

      a graphics object thats appropriate for the given component.

    • paintOverlay

      protected void paintOverlay(Graphics g)

      Allows for painting an overlay on top of the implementation for notices during testing etc.

      Parameters
      • g: graphics context on which to draw the overlay
    • paintDirty

      public void paintDirty()
      Invoked by the EDT to paint the dirty regions
    • edtIdle

      public void edtIdle(boolean enter)

      This method is a callback from the edt before the edt enters to an idle state

      Parameters
      • enter: @param enter true before the edt sleeps and false when exits from the idle state
    • flushGraphics

      public abstract void flushGraphics(int x, int y, int width, int height)

      Flush the currently painted drawing onto the screen if using a double buffer

      Parameters
      • x: position of the dirty region

      • y: position of the dirty region

      • width: width of the dirty region

      • height: height of the dirty region

    • flushGraphics

      public abstract void flushGraphics()
      Flush the currently painted drawing onto the screen if using a double buffer
    • getCodenameOneGraphics

      protected Graphics getCodenameOneGraphics()

      Returns a graphics object for use by the painting

      Returns
      Returns:
      a graphics object, either recycled or new, this object will be used on the EDT
    • setCodenameOneGraphics

      public void setCodenameOneGraphics(Graphics g)

      Installs the Codename One graphics object into the implementation

      Parameters
      • g: graphics object for use by the implementation
    • paintNativePeersBehind

      public boolean paintNativePeersBehind()
      A flag that can be overridden by a platform to indicate that native peers are rendered behind the main codename one graphics layer. The main effect of this is that Graphics will call clearRect() any time a native component is "painted" to poke a hole through the CN1 layer.
    • setDisplayLock

      public void setDisplayLock(Object lock)

      Installs the display lock allowing implementors to synchronize against the Display mutex, this method is invoked internally and should not be used.

      Parameters
      • lock: the mutex from display
    • cancelRepaint

      public void cancelRepaint(Animation cmp)

      Removes an entry from the paint queue if it exists, this is important for cases in which a component was repainted and immediately removed from its parent container afterwards. This happens sometimes in cases where a replace() operation changes a component to a new component that has an animation() the animation might have triggered a repaint before the removeComponent method was invoked

      Parameters
      • cmp: the component to
    • repaint

      public void repaint(Animation cmp)

      Invoked to add an element to the paintQueue

      Parameters
      • cmp: component or animation to push into the paint queue
    • getRGB

      public abstract void getRGB(Object nativeImage, int[] arr, int offset, int x, int y, int width, int height)

      Extracts RGB data from the given native image and places it in the given array

      Parameters
      • nativeImage: native platform image object

      • arr: int array to store RGB data

      • offset: position within the array to start

      • x: x position within the image

      • y: y position within the image

      • width: width to extract

      • height: height to extract

    • createImage

      public abstract Object createImage(int[] rgb, int width, int height)

      Create a platform native image object from the given RGB data

      Parameters
      • rgb: ARGB data from which to create a platform image

      • width: width for the resulting image

      • height: height for the resulting image

      Returns

      platform image object

    • createImage

      public abstract Object createImage(String path) throws IOException

      Creates a native image from a file in the system jar or file system storage.

      Parameters
      • path: If path begins with file: this will load a file from FileSystemStorage. Otherwise it will load from jar.
      Returns

      native system image

      Throws
      • java.io.IOException: if thrown by loading
      Throws:
      IOException
    • createImage

      public abstract Object createImage(InputStream i) throws IOException

      Creates a native image from a given input stream

      Parameters
      • i: input stream from which to load the image
      Returns

      native system image

      Throws
      • java.io.IOException: if thrown by loading
      Throws:
      IOException
    • createMutableImage

      public abstract Object createMutableImage(int width, int height, int fillColor)

      Creates a modifable native image that can return a graphics object

      Parameters
      • width: the width of the mutable image

      • height: the height of the mutable image

      • fillColor: @param fillColor the ARGB fill color, alpha may be ignored based on the value of isAlphaMutableImageSupported

      Returns

      the native image

    • isAlphaMutableImageSupported

      public boolean isAlphaMutableImageSupported()

      Indicates whether mutable images respect alpha values when constructed

      Returns

      true if mutable images can have an alpha value when initially created

    • createImage

      public abstract Object createImage(byte[] bytes, int offset, int len)

      Create a nativate image from its compressed byte data

      Parameters
      • bytes: the byte array representing the image data

      • offset: offset within the byte array

      • len: the length for the image within the byte array

      Returns

      a native image

    • getImageWidth

      public abstract int getImageWidth(Object i)

      Returns the width of a native image

      Parameters
      • i: the native image
      Returns

      the width of the native image

    • getImageHeight

      public abstract int getImageHeight(Object i)

      Returns the height of a native image

      Parameters
      • i: the native image
      Returns

      the height of the native image

    • scale

      public abstract Object scale(Object nativeImage, int width, int height)

      Scales a native image and returns the scaled version

      Parameters
      • nativeImage: image to scale

      • width: width of the resulting image

      • height: height of the resulting image

      Returns

      scaled image instance

    • rotate

      public Object rotate(Object image, int degrees)

      Returns an instance of this image rotated by the given number of degrees. By default 90 degree angle divisions are supported, anything else is implementation dependent. This method assumes a square image. Notice that it is inefficient in the current implementation to rotate to non-square angles,

      E.g. rotating an image to 45, 90 and 135 degrees is inefficient. Use rotatate to 45, 90 and then rotate the 45 to another 90 degrees to achieve the same effect with less memory.

      Parameters
      • degrees: A degree in right angle must be larger than 0 and up to 359 degrees
      Returns

      new image instance with the closest possible rotation

    • rotate90Degrees

      public Image rotate90Degrees(Image image, boolean maintainOpacity)

      Rotates the given image by 90 degrees while changing the ratio of the picture

      Parameters
      • image: the image

      • maintainOpacity: whether the opacity in the image should be maintained

      Returns

      a new image rotated by 90 degrees

    • rotate180Degrees

      public Image rotate180Degrees(Image image, boolean maintainOpacity)

      Rotates the given image by 180 degrees

      Parameters
      • image: the image

      • maintainOpacity: whether the opacity in the image should be maintained

      Returns

      a new image rotated by 180 degrees

    • rotate270Degrees

      public Image rotate270Degrees(Image image, boolean maintainOpacity)

      Rotates the given image by 270 degrees while changing the ratio of the picture

      Parameters
      • image: the image

      • maintainOpacity: whether the opacity in the image should be maintained

      Returns

      a new image rotated by 270 degrees

    • flipImageHorizontally

      public Image flipImageHorizontally(Image image, boolean maintainOpacity)

      Flips the given image on the horizontal axis

      Parameters
      • image: the image

      • maintainOpacity: whether the opacity in the image should be maintained

      Returns

      a new image flipped

    • flipImageVertically

      public Image flipImageVertically(Image image, boolean maintainOpacity)

      Flips the given image on the vertical axis

      Parameters
      • image: the image

      • maintainOpacity: whether the opacity in the image should be maintained

      Returns

      a new image flipped

    • screenshot

      public void screenshot(SuccessCallback<Image> callback)

      Tries to grab an OS native screenshot which would include peer components etc. On fallback draws the current Form object.

      Parameters
      • callback: invoked with the screenshot
    • notifyPushCompletion

      public void notifyPushCompletion()
      Notifies the platform that push notification processing is complete.
    • supportsNativeImageCache

      public boolean supportsNativeImageCache()

      Returns true if the platform supports a native image cache. The native image cache is different than just FileSystemStorage#hasCachesDir(). A native image cache is an image cache that the platform provides that is full transparent to Codename One with respect to how images are stored, and whether they are cached. Currently only the Javascript port supprts a native image cache.

      This is used by java.lang.String, com.codename1.ui.Image, int) to determine if it should use a cached image, or to defer to its storage and filesystem methods.

      Returns

      True on platforms that support a native image cache. Currently only Javascript.

      See also
      • Display#supportsNativeImageCache()
    • downloadImageToCache

      public void downloadImageToCache(String url, SuccessCallback<Image> onSuccess, FailureCallback<Image> onFail)

      Downloads an image from a URL to the cache. Platforms that support a native image cache #supportsNativeImageCache() (e.g. Javascript) override this method to defer to the platform's handling of cached images. Platforms that have a caches directory (FileSystemStorage#hasCachesDir() will use that directory to cache the image. Other platforms will just download to storage.

      Parameters
      • url: The URL of the image to download.

      • onSuccess: Callback on success.

      • onFail: Callback on fail.

      See also
      • URLImage#createToCache(com.codename1.ui.EncodedImage, java.lang.String, com.codename1.ui.URLImage.ImageAdapter)
    • downloadImageToStorage

      public void downloadImageToStorage(String url, String fileName, SuccessCallback<Image> onSuccess, FailureCallback<Image> onFail)

      Downloads an image to storage. This will not first check to see if the image is located in storage already. It will download and overwrite any existing image at the provided location.

      Some platforms may override this method to use platform-level caching. E.g. Javascript will use the browser cache for downloading the image.

      Parameters
      • url: The URL of the image to download.

      • fileName: The storage key to be used to store the image.

      • onSuccess: Callback on success. Will be executed on EDT.

      • onFail: Callback on failure. Will be executed on EDT.

    • downloadImageToFileSystem

      public void downloadImageToFileSystem(String url, String fileName, SuccessCallback<Image> onSuccess, FailureCallback<Image> onFail)

      Downloads an image to file system. This will not first check to see if the file exists already. It will download and overwrite any existing image at the provided location.

      Some platforms may override this method to use platform-level caching. E.g. Javascript will use the browser cache for downloading the image.

      Parameters
      • url: The URL of the image to download.

      • fileName: The storage key to be used to store the image.

      • onSuccess: Callback on success. Will be executed on EDT.

      • onFail: Callback on failure. Will be executed on EDT.

    • getSoftkeyCount

      public abstract int getSoftkeyCount()

      Returns the number of softkeys on the device

      Returns

      the number of softkey buttons on the device

    • getSoftkeyCode

      public abstract int[] getSoftkeyCode(int index)

      Returns the softkey keycode for the given softkey index

      Parameters
      • index: the index of the softkey
      Returns
      Returns:
      the set of keycodes which can indicate the softkey, multiple keycodes might apply to the same functionality
    • getClearKeyCode

      public abstract int getClearKeyCode()

      Returns the keycode for the clear key

      Returns

      the system key code for this device

    • getBackspaceKeyCode

      public abstract int getBackspaceKeyCode()

      Returns the keycode for the backspace key

      Returns

      the system key code for this device

    • getBackKeyCode

      public abstract int getBackKeyCode()

      Returns the keycode for the back key

      Returns

      the system key code for this device

    • getGameAction

      public abstract int getGameAction(int keyCode)

      Returns the display game action for the given keyCode if applicable to match the contrct of Codename One for the game action behavior

      Parameters
      • keyCode: the device keycode
      Returns

      a game action or 0

    • getKeyCode

      public abstract int getKeyCode(int gameAction)

      Returns a keycode which can be sent to getGameAction

      Parameters
      • gameAction: the game action
      Returns

      key code matching the given game action

    • isTouchDevice

      public abstract boolean isTouchDevice()

      Returns true if the device will send touch events

      Returns

      true if the device will send touch events

    • onShow

      public void onShow(Form f)

      Callback before showing a specific form

      Parameters
      • f: the form shown
    • confirmControlView

      public void confirmControlView()
      Callback method allowing the implementation to confirm that it controls the view just before a new form is installed.
    • getCurrentForm

      public Form getCurrentForm()

      Returns the current form, this method is for internal use only and does not take transitions/menus into consideration

      Returns

      The internal current form

    • setCurrentForm

      public void setCurrentForm(Form f)

      This method is used internally to determine the actual current form it doesn't perform the logic of transitions etc. and shouldn't be invoked by developers

      Parameters
      • f: the current form
    • isTranslationSupported

      public boolean isTranslationSupported()

      Codename One can translate all coordinates and never requires a call to translate this works well for some devices which have hairy issues with translate. However for some platforms where translate can be leveraged with affine transforms this can be a problem. These platforms can choose to translate on their own

      Returns
      Returns:
      true if the implementation is interested in receiving translate calls and handling them.
    • translate

      public void translate(Object graphics, int x, int y)

      Translates the X/Y location for drawing on the underlying surface. Translation is incremental so the new value will be added to the current translation and in order to reset translation we have to invoke translate(-getTranslateX(), -getTranslateY())

      Parameters
      • graphics: the graphics context

      • x: the x coordinate

      • y: the y coordinate

    • getTranslateX

      public int getTranslateX(Object graphics)

      Returns the current x translate value

      Parameters
      • graphics: the graphics context
      Returns

      the current x translate value

    • getTranslateY

      public int getTranslateY(Object graphics)

      Returns the current y translate value

      Parameters
      • graphics: the graphics context
      Returns

      the current y translate value

    • getColor

      public abstract int getColor(Object graphics)

      Returns the current color

      Parameters
      • graphics: the graphics context
      Returns

      the RGB graphics color

    • setColor

      public abstract void setColor(Object graphics, int rgb)

      Sets the current rgb color while ignoring any potential alpha component within said color value.

      Parameters
      • graphics: the graphics context

      • rgb: the RGB value for the color.

    • setAlpha

      public abstract void setAlpha(Object graphics, int alpha)

      Alpha value from 0-255 can be ignored for some operations

      Parameters
      • graphics: the graphics context

      • alpha: the alpha channel

    • concatenateAlpha

      public final int concatenateAlpha(Object graphics, int alpha)

      Concatenates alpha value to current alpha.

      Parameters
      • graphics: The graphics context

      • alpha: The alpha to concatenate.

      Returns

      The previous alpha value.

    • getAlpha

      public abstract int getAlpha(Object graphics)

      Alpha value from 0-255 can be ignored for some operations

      Parameters
      • graphics: the graphics context
      Returns

      the alpha channel

    • isAlphaGlobal

      public boolean isAlphaGlobal()

      Returns true if alpha can be applied for all elements globally and efficiently otherwise alpha should be ignored. Notice that fillRect MUST always support alpha regardless of the value of this variable!

      Returns

      true if alpha support is natively implemented

    • isAntiAliasingSupported

      public boolean isAntiAliasingSupported()

      Indicates whether the underlying implementation allows for anti-aliasing in regular drawing operations

      Returns

      false by default

    • isAntiAliasingSupported

      public boolean isAntiAliasingSupported(Object graphics)
    • isAntiAliasedTextSupported

      public boolean isAntiAliasedTextSupported()

      Indicates whether the underlying implementation allows for anti-aliased fonts

      Returns

      false by default

    • isAntiAliasedTextSupported

      public boolean isAntiAliasedTextSupported(Object graphics)
    • setAntiAliased

      public void setAntiAliased(Object graphics, boolean a)

      Toggles anti-aliasing mode for regular rendering operations

      Parameters
      • graphics: the graphics context

      • a: true to activate Anti-aliasing, false to disable it

    • isAntiAliased

      public boolean isAntiAliased(Object graphics)

      Returns anti-aliasing mode for regular rendering operations

      Parameters
      • graphics: the graphics context
      Returns

      true if Anti-aliasing is active, false otherwise

    • setAntiAliasedText

      public void setAntiAliasedText(Object graphics, boolean a)

      Toggles anti-aliasing mode for font rendering operations

      Parameters
      • graphics: the graphics context

      • a: true to activate Anti-aliasing, false to disable it

    • isAntiAliasedText

      public boolean isAntiAliasedText(Object graphics)

      Returns anti-aliasing mode for font rendering operations

      Parameters
      • graphics: the graphics context
      Returns

      true if Anti-aliasing is active, false otherwise

    • setNativeFont

      public abstract void setNativeFont(Object graphics, Object font)

      Installs a native font object

      Parameters
      • graphics: the graphics context

      • font: the native font object

    • getClipRect

      public Rectangle getClipRect(Object graphics)

      Returns the internal clipping rectangle. This method must create a new rectangle object to prevent corruption by modification.

      Parameters
      • graphics: the graphics context
      Returns

      the clipping rectangle.

    • getClipX

      public abstract int getClipX(Object graphics)

      Returns the clipping coordinate

      Parameters
      • graphics: the graphics context
      Returns

      the clipping coordinate

    • getClipY

      public abstract int getClipY(Object graphics)

      Returns the clipping coordinate

      Parameters
      • graphics: the graphics context
      Returns

      the clipping coordinate

    • getClipWidth

      public abstract int getClipWidth(Object graphics)

      Returns the clipping coordinate

      Parameters
      • graphics: the graphics context
      Returns

      the clipping coordinate

    • getClipHeight

      public abstract int getClipHeight(Object graphics)

      Returns the clipping coordinate

      Parameters
      • graphics: the graphics context
      Returns

      the clipping coordinate

    • setClipRect

      public void setClipRect(Object graphics, Rectangle rect)

      Installs a new clipping rectangle

      Parameters
      • graphics: the graphics context

      • rect: rectangle representing the new clipping area

    • setClip

      public abstract void setClip(Object graphics, int x, int y, int width, int height)

      Installs a new clipping rectangle

      Parameters
      • graphics: the graphics context

      • x: coordinate

      • y: coordinate

      • width: size

      • height: size

      • rect: rectangle representing the new clipping area

    • setClip

      public void setClip(Object graphics, Shape shape)

      Clips the Graphics context to the Shape.

      Parameters
      • graphics: the graphics context

      • shape: The shape to clip.

    • clipRect

      public void clipRect(Object graphics, Rectangle rect)

      Changes the current clipping rectangle to subset the current clipping with the given clipping.

      Parameters
      • graphics: the graphics context

      • rect: rectangle representing the new clipping area

    • clipRect

      public abstract void clipRect(Object graphics, int x, int y, int width, int height)

      Changes the current clipping rectangle to subset the current clipping with the given clipping.

      Parameters
      • graphics: the graphics context

      • x: coordinate

      • y: coordinate

      • width: size

      • height: size

      • rect: rectangle representing the new clipping area

    • pushClip

      public void pushClip(Object graphics)

      Pushes the current clip onto the clip stack so that it can be retrieved later by #popClip.

      Parameters
      • graphics: The native graphics context.
    • disposeGraphics

      public void disposeGraphics(Object graphics)

      Cleans up resources used by graphics object

      Parameters
      • graphics
    • popClip

      public void popClip(Object graphics)

      Pops the clip from the top of the clip stack and sets it as the current clip.

      Parameters
      • graphics: The native graphics context.
      Returns

      The clip that was popped off the top of the clip stack.

    • drawLine

      public abstract void drawLine(Object graphics, int x1, int y1, int x2, int y2)

      Draws a line between the 2 X/Y coordinates

      Parameters
      • graphics: the graphics context

      • x1: first x position

      • y1: first y position

      • x2: second x position

      • y2: second y position

    • fillRect

      public abstract void fillRect(Object graphics, int x, int y, int width, int height)

      Fills the rectangle from the given position according to the width/height minus 1 pixel according to the convention in Java.

      Parameters
      • graphics: the graphics context

      • x: the x coordinate of the rectangle to be filled.

      • y: the y coordinate of the rectangle to be filled.

      • width: the width of the rectangle to be filled.

      • height: the height of the rectangle to be filled.

    • clearRect

      public void clearRect(Object graphics, int x, int y, int width, int height)
    • drawRect

      public abstract void drawRect(Object graphics, int x, int y, int width, int height)

      Draws a rectangle in the given coordinates

      Parameters
      • graphics: the graphics context

      • x: the x coordinate of the rectangle to be drawn.

      • y: the y coordinate of the rectangle to be drawn.

      • width: the width of the rectangle to be drawn.

      • height: the height of the rectangle to be drawn.

    • drawRect

      public void drawRect(Object graphics, int x, int y, int width, int height, int thickness)

      Draws a rectangle in the given coordinates

      Parameters
      • graphics: the graphics context

      • x: the x coordinate of the rectangle to be drawn.

      • y: the y coordinate of the rectangle to be drawn.

      • width: the width of the rectangle to be drawn.

      • height: the height of the rectangle to be drawn.

      • thickness: the thickness in pixels

    • drawRoundRect

      public abstract void drawRoundRect(Object graphics, int x, int y, int width, int height, int arcWidth, int arcHeight)

      Draws a rounded corner rectangle in the given coordinates with the arcWidth/height matching the last two arguments respectively.

      Parameters
      • graphics: the graphics context

      • x: the x coordinate of the rectangle to be drawn.

      • y: the y coordinate of the rectangle to be drawn.

      • width: the width of the rectangle to be drawn.

      • height: the height of the rectangle to be drawn.

      • arcWidth: the horizontal diameter of the arc at the four corners.

      • arcHeight: the vertical diameter of the arc at the four corners.

    • fillRoundRect

      public abstract void fillRoundRect(Object graphics, int x, int y, int width, int height, int arcWidth, int arcHeight)

      Fills a rounded rectangle in the same way as drawRoundRect

      Parameters
      • graphics: the graphics context

      • x: the x coordinate of the rectangle to be filled.

      • y: the y coordinate of the rectangle to be filled.

      • width: the width of the rectangle to be filled.

      • height: the height of the rectangle to be filled.

      • arcWidth: the horizontal diameter of the arc at the four corners.

      • arcHeight: the vertical diameter of the arc at the four corners.

      See also
      • #drawRoundRect
    • fillArc

      public abstract void fillArc(Object graphics, int x, int y, int width, int height, int startAngle, int arcAngle)

      Fills a circular or elliptical arc based on the given angles and bounding box. The resulting arc begins at startAngle and extends for arcAngle degrees.

      Parameters
      • graphics: the graphics context

      • x: the x coordinate of the upper-left corner of the arc to be filled.

      • y: the y coordinate of the upper-left corner of the arc to be filled.

      • width: the width of the arc to be filled.

      • height: the height of the arc to be filled.

      • startAngle: the beginning angle.

      • arcAngle: the angular extent of the arc, relative to the start angle.

    • drawArc

      public abstract void drawArc(Object graphics, int x, int y, int width, int height, int startAngle, int arcAngle)

      Draws a circular or elliptical arc based on the given angles and bounding box

      Parameters
      • graphics: the graphics context

      • x: the x coordinate of the upper-left corner of the arc to be drawn.

      • y: the y coordinate of the upper-left corner of the arc to be drawn.

      • width: the width of the arc to be drawn.

      • height: the height of the arc to be drawn.

      • startAngle: the beginning angle.

      • arcAngle: the angular extent of the arc, relative to the start angle.

    • drawString

      public abstract void drawString(Object graphics, String str, int x, int y)

      Draw a string using the current font and color in the x,y coordinates. The font is drawn from the top position and not the baseline.

      Parameters
      • graphics: the graphics context

      • str: the string to be drawn.

      • x: the x coordinate.

      • y: the y coordinate.

    • drawImage

      public abstract void drawImage(Object graphics, Object img, int x, int y)

      Draws the image so its top left coordinate corresponds to x/y

      Parameters
      • graphics: the graphics context

      • img: the specified native image to be drawn

      • x: the x coordinate.

      • y: the y coordinate.

    • drawImage

      public void drawImage(Object graphics, Object img, int x, int y, int w, int h)

      Draws the image so its top left coordinate corresponds to x/y

      Parameters
      • graphics: the graphics context

      • img: the specified native image to be drawn

      • x: the x coordinate.

      • y: the y coordinate.

      • w: the width

      • h: the height

    • createImage

      public Image createImage(Shape shape, Stroke stroke, int color)
    • drawShape

      public void drawShape(Object graphics, Shape shape, Stroke stroke)

      Draws outline of shape on the given graphics context.

      The last 4 parameters specify a bounding box for drawing the Shape. The shape's bounds will be made to fit this box exactly for drawing. This allows for resizing the shape on the GPU if graphics acceleration is supported.

      Parameters
      • graphics: the graphics context

      • shape: the shape to draw.

      • stroke: The stroke to use for drawing the contour.

      See also
      See Also:
      • invalid reference
        to determine of the graphics context supports drawing
        shapes.
    • fillShape

      public void fillShape(Object graphics, Shape shape)

      Fills the given shape in the specified graphics context using the graphics context's currently selected color and alpha.

      Parameters
      • graphics

      • shape

      See also
      • drawShape To learn what x, y, w, and h do.
    • drawShadow

      public void drawShadow(Object graphics, Object image, int x, int y, int offsetX, int offsetY, int blurRadius, int spreadRadius, int color, float opacity)

      Draws a drop shadow for an image onto the given graphics context.

      This is used for the elevation feature.

      Note: This operation is expensive on most platforms as it is not hardware accelerated. Codename One's elevation functionality uses this method to generate shadow images which it reuses as much as possible for maximum performance.

      Note: Currently this is not supported on all platforms. Use #isDrawShadowSupported() to check for platform support at runtime. Use #isDrawShadowFast() to check for hardware acceleration.

      Note: On iOS, this is only supported for drawing to mutable images - not the global graphics context.

      Parameters
      • graphics: The graphics context.

      • image: @param image The image whose raster should be used to generate the shadow. The alpha channel of this image is used as the bases for the shadow projection.

      • x: x-coordinate of the graphics context where shadow should be painted.

      • y: y-coordinate of the graphics context where shadow should be painted.

      • offsetX: The shadow offset X in pixels.

      • offsetY: The shadow offset Y in pixels.

      • blurRadius: The blur radius in pixels.

      • spreadRadius: The shadow spread in pixels.

      • color: The shadow color.

      • opacity: The shadow opacity.

      Since

      8.0

      See also
      • Component#paintShadows(Graphics, int, int)

      • Container#paintSurfaceShadows(Graphics)

      • #isDrawShadowSupported()

      • #isDrawShadowFast()

    • isDrawShadowSupported

      public boolean isDrawShadowSupported()

      Checks to see if drawing shadows is supported on this platform.

      Returns

      True if the platform supports drawing shadows.

      Since

      8.0

      See also
      • #drawShadow(Object, Object, int, int, int, int, int, int, int, float)
    • isDrawShadowFast

      public boolean isDrawShadowFast()

      Checks to see if drawing shadows on this platform is hardware accelerated.

      Returns

      True if drawing shadows is hardware accelerated.

      Since

      8.0

    • setTransform

      public void setTransform(Object graphics, Transform transform)

      Sets the transformation matrix to be applied to all drawing operations. If originX, originY are non-zero, then the the transformation will first be translated to the origin, then applied, and then translated back.

      If isTransformSupported() returns false, then this method won't do anything.

      If isPerspectiveTransformSupported() returns false, then this method will only deal with 2D transformation matrices (i.e. the upper left 3x3 matrix of the provided transformation matrix.

      Parameters
      • graphics

      • m: The transformation matrix. Can be 3x3 or 4x4.

      See also
      • isTransformSupported() To check if this graphics context supports transformations.
      See Also:
    • getTransform

      public Transform getTransform(Object graphics)

      Gets the current transformation matrix. This will populate the provided matrix with the data of the current transformation.

      Parameters
      • graphics
      Deprecated

      Use com.codename1.ui.Transform) instead.

      See also
      • isTransformSupported()

      • isPerspectiveTransformSupported()

    • isTransformSupported

      public boolean isTransformSupported(Object graphics)

      Checks if matrix transformations are supported in the provided graphics context.

      Parameters
      • graphics
      Returns

      True if matrix transformations are supported by this graphics context.

      See also
      • setTransform()

      • getTransform()

      • isPerspectiveTransformSupported()

    • isPerspectiveTransformSupported

      public boolean isPerspectiveTransformSupported(Object graphics)

      Checks if 3d/perspective transformations are supported in the provided graphics context.

      Parameters
      • graphics
      See also
      • setTransform()

      • getTransform()

      • isTransformSupported()

    • isShapeSupported

      public boolean isShapeSupported(Object graphics)

      Checks if drawing shapes is supported by the provided graphics context.

      Parameters
      • graphics
    • isShapeClipSupported

      public boolean isShapeClipSupported(Object graphics)

      Checks if clipping shapes is supported by the provided graphics context.

      Parameters
      • graphics
    • tileImage

      public void tileImage(Object graphics, Object img, int x, int y, int w, int h)

      Allows an implementation to optimize image tiling rendering logic

      Parameters
      • graphics: the graphics object

      • img: the image

      • x: coordinate to tile the image along

      • y: coordinate to tile the image along

      • w: coordinate to tile the image along

      • h: coordinate to tile the image along

    • isNativeVideoPlayerControlsIncluded

      public boolean isNativeVideoPlayerControlsIncluded()

      Indicates if the native video player includes its own play/pause etc. controls so the movie player component doesn't need to include them

      Returns

      true if the movie player component doesn't need to include such controls

    • isScaledImageDrawingSupported

      public boolean isScaledImageDrawingSupported()
      Indicates if image scaling on the fly is supported by the platform, if not Codename One will just scale the images on its own before drawing
    • drawImageArea

      public void drawImageArea(Object nativeGraphics, Object img, int x, int y, int imageX, int imageY, int imageWidth, int imageHeight)

      Draws a portion of the image

      Parameters
      • nativeGraphics: the graphics context

      • img: the specified native image to be drawn

      • x: the x coordinate.

      • y: the y coordinate.

      • imageX: location within the image to draw

      • imageY: location within the image to draw

      • imageWidth: size of the location within the image to draw

      • imageHeight: size of the location within the image to draw

    • drawImageRotated

      public void drawImageRotated(Object graphics, Object img, int x, int y, int degrees)

      Draws the image so its top left coordinate corresponds to x/y with a fast native rotation in a square angle which must be one of 0, 90, 180 or 270

      Parameters
      • graphics: the graphics context

      • img: the specified native image to be drawn

      • x: the x coordinate.

      • y: the y coordinate.

      • degrees: either 0, 90, 180 or 270 degree rotation for the image drawing

    • isRotationDrawingSupported

      public boolean isRotationDrawingSupported()

      Indicates whether drawImageRotated is supported by the platform for FAST drawing, if not then its not worth calling the method which will be unimplemented!

      Returns

      true if drawImageRotated will draw an image

    • fillTriangle

      public void fillTriangle(Object graphics, int x1, int y1, int x2, int y2, int x3, int y3)

      Draws a filled triangle with the given coordinates

      Parameters
      • graphics: the graphics context

      • x1: the x coordinate of the first vertex of the triangle

      • y1: the y coordinate of the first vertex of the triangle

      • x2: the x coordinate of the second vertex of the triangle

      • y2: the y coordinate of the second vertex of the triangle

      • x3: the x coordinate of the third vertex of the triangle

      • y3: the y coordinate of the third vertex of the triangle

    • drawRGB

      public abstract void drawRGB(Object graphics, int[] rgbData, int offset, int x, int y, int w, int h, boolean processAlpha)

      Draws the RGB values based on the MIDP API of a similar name. Renders a series of device-independent RGB+transparency values in a specified region. The values are stored in rgbData in a format with 24 bits of RGB and an eight-bit alpha value (0xAARRGGBB), with the first value stored at the specified offset. The scanlength specifies the relative offset within the array between the corresponding pixels of consecutive rows. Any value for scanlength is acceptable (even negative values) provided that all resulting references are within the bounds of the rgbData array. The ARGB data is rasterized horizontally from left to right within each row. The ARGB values are rendered in the region specified by x, y, width and height, and the operation is subject to the current clip region and translation for this Graphics object.

      Parameters
      • graphics: the graphics context

      • rgbData: an array of ARGB values in the format 0xAARRGGBB

      • offset: the array index of the first ARGB value

      • x: the horizontal location of the region to be rendered

      • y: the vertical location of the region to be rendered

      • w: the width of the region to be rendered

      • h: the height of the region to be rendered

      • processAlpha: @param processAlpha true if rgbData has an alpha channel, false if all pixels are fully opaque

    • getNativeGraphics

      public abstract Object getNativeGraphics()

      Returns the native graphics object on which all rendering operations occur

      Returns

      a native graphics context

    • getNativeGraphics

      public abstract Object getNativeGraphics(Object image)

      Returns the native graphics object on the given native image occur

      Parameters
      • image: the native image on which the graphics will draw
      Returns

      a native graphics context

    • charsWidth

      public abstract int charsWidth(Object nativeFont, char[] ch, int offset, int length)

      Return the width of the given characters in the given native font instance

      Parameters
      • nativeFont: the font for which the string width should be calculated

      • ch: array of characters

      • offset: characters offsets

      • length: characters length

      Returns

      the width of the given characters in this font instance

    • getFontAscent

      public int getFontAscent(Object nativeFont)

      Returns the ascent of the specified native font instance. Should always return a non-negative value.

      Parameters
      • nativeFont
      Returns

      The ascent of the native font instance

    • getFontDescent

      public int getFontDescent(Object nativeFont)

      Returns the descent below the baseline that a font can span. Should always be non-negative.

      Parameters
      • nativeFont
    • isBaselineTextSupported

      public boolean isBaselineTextSupported()
      Checks whether the implementation supports drawing text on the baseline.
    • stringWidth

      public abstract int stringWidth(Object nativeFont, String str)

      Return the width of the given string in this font instance

      Parameters
      • nativeFont: the font for which the string width should be calculated

      • str: the given string *

      Returns

      the width of the given string in this font instance

    • charWidth

      public abstract int charWidth(Object nativeFont, char ch)

      Return the width of the specific character when rendered alone

      Parameters
      • nativeFont: the font for which the string width should be calculated

      • ch: the specific character

      Returns

      the width of the specific character when rendered alone

    • getHeight

      public abstract int getHeight(Object nativeFont)

      Return the total height of the font

      Parameters
      • nativeFont: the font for which the string width should be calculated
      Returns

      the total height of the font

    • getDefaultFont

      public abstract Object getDefaultFont()

      Return the global default font instance, if font is passed as null this font should be used

      Returns

      the global default font instance

    • getFace

      public int getFace(Object nativeFont)

      Optional operation returning the font face for the font

      Parameters
      • nativeFont: the font for which the string width should be calculated
      Returns

      Optional operation returning the font face for system fonts

    • getSize

      public int getSize(Object nativeFont)

      Optional operation returning the font size for system fonts

      Parameters
      • nativeFont: the font for which the string width should be calculated
      Returns

      Optional operation returning the font size for system fonts

    • getStyle

      public int getStyle(Object nativeFont)

      Optional operation returning the font style for system fonts

      Parameters
      • nativeFont: the font for which the string width should be calculated
      Returns

      Optional operation returning the font style for system fonts

    • createFont

      public abstract Object createFont(int face, int style, int size)

      Creates a new instance of a native font

      Parameters
      • face: @param face the face of the font, can be one of FACE_SYSTEM, FACE_PROPORTIONAL, FACE_MONOSPACE.

      • style: @param style the style of the font. The value is an OR'ed combination of STYLE_BOLD, STYLE_ITALIC, and STYLE_UNDERLINED; or the value is zero (STYLE_PLAIN).

      • size: @param size the size of the font, can be one of SIZE_SMALL, SIZE_MEDIUM, SIZE_LARGE

      Returns

      a native font object

    • keyPressed

      protected void keyPressed(int keyCode)

      Subclasses should invoke this method, it delegates the event to the display and into Codename One.

      Parameters
      • keyCode: the key for the event
    • keyReleased

      protected void keyReleased(int keyCode)

      Subclasses should invoke this method, it delegates the event to the display and into Codename One.

      Parameters
      • keyCode: the key for the event
    • isRightMouseButtonDown

      public boolean isRightMouseButtonDown()

      Checks if last mouse press was a right click.

      Returns

      True if last mouse press was a right click.

      Since

      7.0

    • isAltKeyDown

      public boolean isAltKeyDown()
      Checks whether the alt key is currently down. Only relevant on desktop ports.
    • isShiftKeyDown

      public boolean isShiftKeyDown()
      Checks whether the shift key is currently down. Only relevant on desktop ports.
    • isAltGraphKeyDown

      public boolean isAltGraphKeyDown()
      Checks whether the altgraph key is currently down. Only relevant on desktop ports.
    • isControlKeyDown

      public boolean isControlKeyDown()
      Checks whether the control key is currently down. Only relevant on desktop ports.
    • isMetaKeyDown

      public boolean isMetaKeyDown()
      Checks whether the meta key is currently down. Only relevant on desktop ports.
    • pointerDragged

      protected void pointerDragged(int x, int y)

      Subclasses should invoke this method, it delegates the event to the display and into Codename One.

      Parameters
      • x: the position of the event

      • y: the position of the event

    • pointerPressed

      protected void pointerPressed(int x, int y)

      Subclasses should invoke this method, it delegates the event to the display and into Codename One.

      Parameters
      • x: the position of the event

      • y: the position of the event

    • pointerReleased

      protected void pointerReleased(int x, int y)

      Subclasses should invoke this method, it delegates the event to the display and into Codename One.

      Parameters
      • x: the position of the event

      • y: the position of the event

    • pointerHover

      protected void pointerHover(int[] x, int[] y)

      Subclasses should invoke this method, it delegates the event to the display and into Codename One.

      Parameters
      • x: the position of the event

      • y: the position of the event

    • pointerHoverReleased

      protected void pointerHoverReleased(int[] x, int[] y)

      Subclasses should invoke this method, it delegates the event to the display and into Codename One.

      Parameters
      • x: the position of the event

      • y: the position of the event

    • pointerHoverReleased

      protected void pointerHoverReleased(int x, int y)

      Subclasses should invoke this method, it delegates the event to the display and into Codename One.

      Parameters
      • x: the position of the event

      • y: the position of the event

    • pointerHoverPressed

      protected void pointerHoverPressed(int[] x, int[] y)

      Subclasses should invoke this method, it delegates the event to the display and into Codename One.

      Parameters
      • x: the position of the event

      • y: the position of the event

    • pointerHoverPressed

      protected void pointerHoverPressed(int x, int y)

      Subclasses should invoke this method, it delegates the event to the display and into Codename One.

      Parameters
      • x: the position of the event

      • y: the position of the event

    • pointerHover

      protected void pointerHover(int x, int y)

      Subclasses should invoke this method, it delegates the event to the display and into Codename One.

      Parameters
      • x: the position of the event

      • y: the position of the event

    • pointerDragged

      protected void pointerDragged(int[] x, int[] y)

      Subclasses should invoke this method, it delegates the event to the display and into Codename One.

      Parameters
      • x: the position of the event

      • y: the position of the event

    • hasDragStarted

      protected boolean hasDragStarted(int[] x, int[] y)

      This method can be overriden by subclasses to indicate whether a drag event has started or whether the device is just sending out "noise". This method is invoked by pointer dragged to determine whether to propogate the actual pointer drag event to Codename One.

      Parameters
      • x: the position of the current drag event

      • y: the position of the current drag event

      Returns

      true if the drag should propagate into Codename One

    • hasDragStarted

      protected boolean hasDragStarted(int x, int y)

      This method can be overriden by subclasses to indicate whether a drag event has started or whether the device is just sending out "noise". This method is invoked by pointer dragged to determine whether to propagate the actual pointer drag event to Codename One.

      Parameters
      • x: the position of the current drag event

      • y: the position of the current drag event

      Returns

      true if the drag should propagate into Codename One

    • getDragStartPercentage

      public int getDragStartPercentage()

      This method allows us to manipulate the drag started detection logic. If the pointer was dragged for more than this percentage of the display size it is safe to assume that a drag is in progress.

      Returns

      motion percentage

    • setDragStartPercentage

      public void setDragStartPercentage(int dragStartPercentage)

      This method allows us to manipulate the drag started detection logic. If the pointer was dragged for more than this percentage of the display size it is safe to assume that a drag is in progress.

      Parameters
      • dragStartPercentage: percentage of the screen required to initiate drag
    • getDragAutoActivationThreshold

      protected int getDragAutoActivationThreshold()

      This method allows subclasses to manipulate the drag started detection logic. If more than this number of drag events were delivered it is safe to assume a drag has started This number must be bigger than 0!

      Returns

      number representing a minimum number of motion events to start a drag operation

    • pointerPressed

      protected void pointerPressed(int[] x, int[] y)

      Subclasses should invoke this method, it delegates the event to the display and into Codename One.

      Parameters
      • x: the position of the event

      • y: the position of the event

    • pointerReleased

      protected void pointerReleased(int[] x, int[] y)

      Subclasses should invoke this method, it delegates the event to the display and into Codename One.

      Parameters
      • x: the position of the event

      • y: the position of the event

    • sizeChanged

      protected void sizeChanged(int w, int h)

      Subclasses should invoke this method, it delegates the event to the display and into Codename One.

      Parameters
      • w: the size of the screen

      • h: the size of the screen

    • hideNotify

      protected void hideNotify()
      Subclasses should invoke this method, it delegates the event to the display and into Codename One.
    • showNotify

      protected void showNotify()
      Subclasses should invoke this method, it delegates the event to the display and into Codename One.
    • fillRectRadialGradient

      public void fillRectRadialGradient(Object graphics, int startColor, int endColor, int x, int y, int width, int height, float relativeX, float relativeY, float relativeSize)

      Draws a radial gradient in the given coordinates with the given colors, doesn't take alpha into consideration when drawing the gradient. Notice that a radial gradient will result in a circular shape, to create a square use fillRect or draw a larger shape and clip to the appropriate size.

      Parameters
      • graphics: the graphics context

      • startColor: the starting RGB color

      • endColor: the ending RGB color

      • x: the x coordinate

      • y: the y coordinate

      • width: the width of the region to be filled

      • height: the height of the region to be filled

      • relativeX: indicates the relative position of the gradient within the drawing region

      • relativeY: indicates the relative position of the gradient within the drawing region

      • relativeSize: indicates the relative size of the gradient within the drawing region

    • fillRadialGradient

      public void fillRadialGradient(Object graphics, int startColor, int endColor, int x, int y, int width, int height)

      Draws a radial gradient in the given coordinates with the given colors, doesn't take alpha into consideration when drawing the gradient. Notice that a radial gradient will result in a circular shape, to create a square use fillRect or draw a larger shape and clip to the appropriate size.

      Parameters
      • graphics: the graphics context

      • startColor: the starting RGB color

      • endColor: the ending RGB color

      • x: the x coordinate

      • y: the y coordinate

      • width: the width of the region to be filled

      • height: the height of the region to be filled

    • fillRadialGradient

      public void fillRadialGradient(Object graphics, int startColor, int endColor, int x, int y, int width, int height, int startAngle, int arcAngle)

      Draws a radial gradient in the given coordinates with the given colors, doesn't take alpha into consideration when drawing the gradient. Notice that a radial gradient will result in a circular shape, to create a square use fillRect or draw a larger shape and clip to the appropriate size.

      Parameters
      • graphics: the graphics context

      • startColor: the starting RGB color

      • endColor: the ending RGB color

      • x: the x coordinate

      • y: the y coordinate

      • width: the width of the region to be filled

      • height: the height of the region to be filled

      • startAngle: the beginning angle. Zero is at 3 o'clock. Positive angles are counter-clockwise.

      • arcAngle: the angular extent of the arc, relative to the start angle. Positive angles are counter-clockwise.

    • fillLinearGradient

      public void fillLinearGradient(Object graphics, int startColor, int endColor, int x, int y, int width, int height, boolean horizontal)

      Draws a linear gradient in the given coordinates with the given colors, doesn't take alpha into consideration when drawing the gradient

      Parameters
      • graphics: the graphics context

      • startColor: the starting RGB color

      • endColor: the ending RGB color

      • x: the x coordinate

      • y: the y coordinate

      • width: the width of the region to be filled

      • height: the height of the region to be filled

      • horizontal: indicating wheter it is a horizontal fill or vertical

    • fillPolygon

      public void fillPolygon(Object graphics, int[] xPoints, int[] yPoints, int nPoints)

      Fills a closed polygon defined by arrays of x and y coordinates. Each pair of (x, y) coordinates defines a point.

      Parameters
      • graphics: the graphics context

      • xPoints: - a an array of x coordinates.

      • yPoints: - a an array of y coordinates.

      • nPoints: - a the total number of points.

    • drawPolygon

      public void drawPolygon(Object graphics, int[] xPoints, int[] yPoints, int nPoints)

      Draws a closed polygon defined by arrays of x and y coordinates. Each pair of (x, y) coordinates defines a point.

      Parameters
      • graphics: the graphics context

      • xPoints: - a an array of x coordinates.

      • yPoints: - a an array of y coordinates.

      • nPoints: - a the total number of points.

    • getKeyboardType

      public int getKeyboardType()

      Returns the type of the input device one of: KEYBOARD_TYPE_UNKNOWN, KEYBOARD_TYPE_NUMERIC, KEYBOARD_TYPE_QWERTY, KEYBOARD_TYPE_VIRTUAL, KEYBOARD_TYPE_HALF_QWERTY

      Returns

      KEYBOARD_TYPE_UNKNOWN

    • isNativeInputSupported

      public boolean isNativeInputSupported()

      Indicates whether the device supports native in place editing in which case lightweight input logic shouldn't be used for input.

      Returns

      false by default

    • isNativeInputImmediate

      public boolean isNativeInputImmediate()

      Indicates whether the device should switch to native input immediately on first touch

      Returns

      false by default

    • isMultiTouch

      public boolean isMultiTouch()

      Indicates whether the device supports multi-touch events, this is only relevant when touch events are supported

      Returns

      false by default

    • isClickTouchScreen

      public boolean isClickTouchScreen()

      Indicates whether the device has a double layer screen thus allowing two stages to touch events: click and hover. This is true for devices such as the storm but can also be true for a PC with a mouse pointer floating on top.

      A click touch screen will also send pointer hover events to the underlying software and will only send the standard pointer events on click.

      Returns

      false by default

    • isNativeIndexed

      public boolean isNativeIndexed()

      Returns true if indexed images should be used natively

      Returns

      true if a native image should be used for indexed images

    • createNativeIndexed

      public Object createNativeIndexed(Image image)

      Creates a native image representing the indexed image

      Parameters
      • image: the indexed image
      Returns

      a native version of the indexed image

    • isOpaque

      public boolean isOpaque(Image codenameOneImage, Object nativeImage)

      Returns true if the image was opaque

      Parameters
      • codenameOneImage: the Codename One image

      • nativeImage: the image object to test

      Returns

      true if the image is opaque

    • isAffineSupported

      public boolean isAffineSupported()

      Indicates whether the underlying implementation can draw using an affine transform hence methods such as rotate, scale and shear would work

      Returns

      true if an affine transformation matrix is present

    • resetAffine

      public void resetAffine(Object nativeGraphics)

      Resets the affine transform to the default value

      Parameters
      • nativeGraphics: the native graphics object
    • scale

      public void scale(Object nativeGraphics, float x, float y)

      Scales the coordinate system using the affine transform

      Parameters
      • nativeGraphics: the native graphics object

      • x: factor for x

      • y: factor for y

    • rotate

      public void rotate(Object nativeGraphics, float angle)

      Rotates the coordinate system around a radian angle using the affine transform

      Parameters
      • angle: the rotation angle in radians

      • nativeGraphics: the native graphics object

    • rotate

      public void rotate(Object nativeGraphics, float angle, int pivotX, int pivotY)

      Rotates the coordinate system around a radian angle using the affine transform

      Parameters
      • angle: the rotation angle in radians

      • pivotX: the pivot location

      • pivotY: the pivot location

      • nativeGraphics: the native graphics object

    • shear

      public void shear(Object nativeGraphics, float x, float y)

      Shear the graphics coordinate system using the affine transform

      Parameters
      • x: factor for x

      • y: factor for y

      • nativeGraphics: the native graphics object

    • isSVGSupported

      public boolean isSVGSupported()

      Indicates whether the underlying platform supports creating an SVG Image

      Returns
      Returns:
      true if the method create SVG image would return a valid image object from an SVG Input stream
    • createSVGImage

      public Object createSVGImage(String baseURL, byte[] data) throws IOException

      Creates an SVG Image from the given byte array data and the base URL

      Parameters
      • baseURL: URL which is used to resolve relative references within the SVG file

      • data: the content of the SVG file

      Returns

      a native image that can be used within the image object

      Throws
      • IOException: if resource lookup fail SVG is unsupported
      Throws:
      IOException
    • getSVGDocument

      public Object getSVGDocument(Object svgImage)

      Returns a platform specific DOM object that can be manipulated by the user to change the SVG Image

      Parameters
      • svgImage: the underlying image object
      Returns
      Returns:
      Platform dependent object, when JSR 226 is supported an SVGSVGElement might be returned.
    • animateImage

      public boolean animateImage(Object nativeImage, long lastFrame)

      Callback to allow images animated by the underlying system to change their state e.g. for SVG or animated gif support. This method returns true if an animation state has changed requiring a repaint.

      Parameters
      • nativeImage: a native image used within the image object

      • lastFrame: the time the last frame of animation was shown

      Returns

      true if a repaint is required since the image state changed, false otherwise

    • getFontPlatformNames

      public String[] getFontPlatformNames()

      Returns a list of the platform names ordered by priority, platform names are used to choose a font based on platform. Since a platform might support several layers for choice in narrowing platform font selection

      Returns

      the platform names ordered according to priority.

    • loadTrueTypeFont

      public Object loadTrueTypeFont(String fontName, String fileName)

      Creates a true type font with the given name/filename (font name might be different from the file name and is required by some devices e.g. iOS). The font file must reside in the src root of the project in order to be detectable. The file name should contain no slashes or any such value.

      Parameters
      • fontName: the name of the font

      • fileName: the file name of the font as it appears in the src directory of the project

      Returns

      the native font created from the stream

    • isNativeFontSchemeSupported

      public boolean isNativeFontSchemeSupported()

      Indicates whether the implementation supports loading a font "natively" to handle one of the common native prefixes

      Returns

      true if the "native:" prefix is supported by loadTrueTypeFont

    • deriveTrueTypeFont

      public Object deriveTrueTypeFont(Object font, float size, int weight)

      Creates a font based on this truetype font with the given pixel, WARNING! This method will only work in the case of truetype fonts!

      Parameters
      • font: the native font instance

      • size: the size of the font in pixels

      • weight: PLAIN, BOLD or ITALIC weight based on the constants in this class

      Returns

      scaled font instance

    • isTrueTypeSupported

      public boolean isTrueTypeSupported()

      Returns true if the system supports dynamically loading truetype fonts from a file.

      Returns
      Returns:
      true if the system supports dynamically loading truetype fonts from a file.
    • loadNativeFont

      public Object loadNativeFont(String lookup)

      Loads a native font based on a lookup for a font name and attributes. Font lookup values can be separated by commas and thus allow fallback if the primary font isn't supported by the platform.

      Parameters
      • lookup: string describing the font
      Returns

      the native font object

    • isLookupFontSupported

      public boolean isLookupFontSupported()

      Indicates whether loading a font by a string is supported by the platform

      Returns

      true if the platform supports font lookup

    • minimizeApplication

      public boolean minimizeApplication()

      Minimizes the current application if minimization is supported by the platform (may fail). Returns false if minimization failed.

      Returns

      false if minimization failed true if it succeeded or seems to be successful

    • restoreMinimizedApplication

      public void restoreMinimizedApplication()
      Restore the minimized application if minimization is supported by the platform
    • isMinimized

      public boolean isMinimized()

      Indicates whether an application is minimized

      Returns

      true if the application is minimized

    • cacheRadialGradients

      protected boolean cacheRadialGradients()

      Indicates whether the implementation is interested in caching radial gradients for drawing.

      Returns

      true to activate radial gradient caching

    • cacheLinearGradients

      protected boolean cacheLinearGradients()

      Indicates whether the implementation is interested in caching linear gradients for drawing.

      Returns

      true to activate linear gradient caching

    • isThirdSoftButton

      public boolean isThirdSoftButton()

      Indicates the default status to apply to the 3rd softbutton variable

      Returns

      true if the 3rd softbutton should be set as true

      See also
      • com.codename1.ui.Display#isThirdSoftButton()

      • com.codename1.ui.Display#setThirdSoftButton()

    • getDragPathLength

      public int getDragPathLength()

      Indicates how many drag points are used to calculate dragging speed

      Returns

      the size of points to calculate the speed

    • getDragPathTime

      public int getDragPathTime()

      Indicates what drag points are valid for the drag speed calculation. Points that are older then the current time - the path time are ignored

      Returns

      the relevance time per point

    • getDragSpeed

      public float getDragSpeed(float[] points, long[] dragPathTime, int dragPathOffset, int dragPathLength)

      This method returns the dragging speed based on the latest dragged events

      Parameters
      • points: array of locations

      • dragPathTime: the time difference between each point

      • dragPathOffset: the offset in the arrays

      • dragPathLength

    • isBidiAlgorithm

      public boolean isBidiAlgorithm()

      Indicates whether Codename One should consider the bidi RTL algorithm when drawing text or navigating with the text field cursor.

      Returns

      true if the bidi algorithm should be considered

    • setBidiAlgorithm

      public void setBidiAlgorithm(boolean activate)

      Indicates whether Codename One should consider the bidi RTL algorithm when drawing text or navigating with the text field cursor.

      Parameters
      • activate: @param activate set to true to activate the bidi algorithm, false to disable it
    • convertBidiLogicalToVisual

      public String convertBidiLogicalToVisual(String s)

      Converts the given string from logical bidi layout to visual bidi layout so it can be rendered properly on the screen. This method is only necessary for devices/platforms that don't have "built in" bidi support such as Sony Ericsson devices. See this for more on visual vs. logical ordering.

      Parameters
      • s: a "logical" string with RTL characters
      Returns

      a "visual" renderable string

    • getCharLocation

      public int getCharLocation(String source, int index)

      Returns the index of the given char within the source string, the actual index isn't necessarily the same when bidi is involved See this for more on visual vs. logical ordering.

      Parameters
      • source: the string in which we are looking for the position

      • index: the "logical" location of the cursor

      Returns

      the "visual" location of the cursor

    • isRTLOrWhitespace

      public boolean isRTLOrWhitespace(char c)

      Returns true if the given character is an RTL character or a space character

      Parameters
      • c: character to test
      Returns

      true if bidi is active and this is a

    • isRTL

      public boolean isRTL(char c)

      Returns true if the given character is an RTL character

      Parameters
      • c: character to test
      Returns

      true if the charcter is an RTL character

    • getResourceAsStream

      public InputStream getResourceAsStream(Class cls, String resource)

      This method is essentially equivalent to cls.getResourceAsStream(String) however some platforms might define unique ways in which to load resources within the implementation.

      Parameters
      • cls: class to load the resource from

      • resource: relative/absolute URL based on the Java convention

      Returns

      input stream for the resource or null if not found

    • isAnimation

      public boolean isAnimation(Object nativeImage)

      Animations should return true to allow the native image animation to update

      Parameters
      • nativeImage: underlying native imae
      Returns

      true if this is an animation

    • createNativePeer

      public PeerComponent createNativePeer(Object nativeComponent)

      Creates a peer component for the given lightweight component

      Parameters
      • nativeComponent: a platform specific "native component"
      Returns
      Returns:
      a Codename One peer component that can be manipulated just like any other Codename One component but would internally encapsulate the given native peer
    • showNativeScreen

      public void showNativeScreen(Object nativeFullScreenPeer)

      Shows a native Form/Canvas or some other heavyweight native screen

      Parameters
      • nativeFullScreenPeer: the native screen peer
    • setNativeCommands

      public void setNativeCommands(Vector commands)

      Places the following commands on the native menu system

      Parameters
      • commands: the Codename One commands to use
    • exitApplication

      public void exitApplication()
      Exits the application...
    • exit

      public void exit()
      Exits the application...
    • getProperty

      public String getProperty(String key, String defaultValue)

      Returns the property from the underlying platform deployment or the default value if no deployment values are supported. This is equivalent to the getAppProperty from the jad file.

      The implementation should be responsible for the following keys to return reasonable valid values for the application:

      • AppName

      • User-Agent - ideally although not required

      • AppVersion

      • Platform - Similar to microedition.platform

      Parameters
      • key: the key of the property

      • defaultValue: a default return value

      Returns

      the value of the property

    • canExecute

      public Boolean canExecute(String url)

      Returns true if executing this URL should work, returns false if it will not and null if this is unknown.

      Parameters
      • url: the url that would be executed
      Returns
      Returns:
      true if executing this URL should work, returns false if it will not and null if this is unknown
    • execute

      public void execute(String url)

      Executes the given URL on the native platform

      Parameters
      • url: the url to execute
    • execute

      public void execute(String url, ActionListener response)

      Executes the given URL on the native platform, this method is useful if the platform has the ability to send an event to the app when the execution has ended, currently this works only for Android platform to invoke other intents.

      Parameters
      • url: the url to execute

      • response: @param response a callback from the platform when this execution returned to the application

    • getDeviceDensity

      public int getDeviceDensity()

      Returns one of the density variables appropriate for this device, notice that density doesn't always correspond to resolution and an implementation might decide to change the density based on DPI constraints.

      Returns

      one of the DENSITY constants of Display

    • getDisplaySafeArea

      public Rectangle getDisplaySafeArea(Rectangle rect)

      This method returns a rectangle defining the "safe" area of the display, which excludes areas on the screen that are covered by notches, task bars, rounded corners, etc.

      This feature was primarily added to deal with the task bar on the iPhone X, which is displayed on the screen near the bottom edge, and can interfere with components that are laid out at the bottom of the screen.

      Most platforms will simply return a Rectangle with bounds (0, 0, displayWidth, displayHeight). iPhone X will return a rectangle that excludes the notch, and task bar regions.

      Parameters
      • rect: Out parameter where safe bounds are set.
      Returns

      The same rectangle that was passed as a parameter.

      Since

      7.0

      See also
      • Form#getSafeArea()
    • playBuiltinSound

      public void playBuiltinSound(String soundIdentifier)

      Plays a builtin device sound matching the given identifier, implementations and themes can offer additional identifiers to the ones that are already built in.

      Parameters
      • soundIdentifier: @param soundIdentifier the sound identifier which can match one of the common constants in this class or be a user/implementation defined sound
    • playUserSound

      protected void playUserSound(String soundIdentifier)

      Plays a sound defined by the user

      Parameters
      • soundIdentifier: @param soundIdentifier the sound identifier which can match one of the common constants in this class or be a user/implementation defined sound
    • playNativeBuiltinSound

      protected void playNativeBuiltinSound(Object data)

      This method allows implementations to store sound objects natively e.g. in files, byte arrays whatever

      Parameters
      • data: native data object
    • convertBuiltinSound

      protected Object convertBuiltinSound(InputStream i) throws IOException

      Converts a sound object to a form which will be easy for the implementation to play later on. E.g. a byte array or a file/file name and return an object that will allow playNativeBuiltinSound() to use

      Parameters
      • i: stream containing a sound file
      Returns

      native playback object

      Throws
      • java.io.IOException: thrown by the stream
      Throws:
      IOException
    • installBuiltinSound

      public void installBuiltinSound(String soundIdentifier, InputStream data) throws IOException

      Installs a replacement sound as the builtin sound responsible for the given sound identifier (this will override the system sound if such a sound exists).

      Parameters
      • soundIdentifier: the sound string passed to playBuiltinSound

      • data: @param data an input stream containing platform specific audio file, its usually safe to assume that wav/mp3 would be supported.

      Throws
      • IOException: if the stream throws an exception
      Throws:
      IOException
    • isBuiltinSoundAvailable

      public boolean isBuiltinSoundAvailable(String soundIdentifier)

      Indicates whether a user installed or system sound is available

      Parameters
      • soundIdentifier: the sound string passed to playBuiltinSound
      Returns

      true if a sound of this given type is avilable

    • isBuiltinSoundsEnabled

      public boolean isBuiltinSoundsEnabled()

      Allows muting/unmuting the builtin sounds easily

      Returns

      true if the sound is not muted

    • setBuiltinSoundsEnabled

      public void setBuiltinSoundsEnabled(boolean enabled)

      Allows muting/unmuting the builtin sounds easily

      Parameters
      • enabled: indicates whether the sound is muted
    • createMedia

      public Media createMedia(String uri, boolean isVideo, Runnable onCompletion) throws IOException

      Plays the sound in the given URI which is partially platform specific.

      Parameters
      • uri: the platform specific location for the sound

      • onCompletion: invoked when the audio file finishes playing, may be null

      Returns

      a handle that can be used to control the playback of the audio

      Throws
      • java.io.IOException: if the URI access fails
      Throws:
      IOException
    • createMediaAsync

      public AsyncResource<Media> createMediaAsync(String uri, boolean video, Runnable onCompletion)

      Creates media asynchronously.

      Parameters
      • uri: the platform specific location for the sound

      • onCompletion: invoked when the audio file finishes playing, may be null

      Returns

      a handle that can be used to control the playback of the audio

      See also
      • #createMedia(java.lang.String, boolean, java.lang.Runnable)
    • addCompletionHandler

      public void addCompletionHandler(Media media, Runnable onCompletion)

      Adds a callback to a Media element that will be called when the media finishes playing.

      Parameters
      • media: The media to add the callback to.

      • onCompletion: The callback that will run on the EDT when the playback completes.

      See also
      • #removeCompletionHandler(com.codename1.media.Media, java.lang.Runnable)

      • Display#addCompletionHandler(com.codename1.media.Media, java.lang.Runnable)

    • removeCompletionHandler

      public void removeCompletionHandler(Media media, Runnable onCompletion)

      Removes onComplete callback from Media element.

      Parameters
      • media: The media element.

      • onCompletion: The callback.

      See also
      • #addCompletionHandler(com.codename1.media.Media, java.lang.Runnable)

      • Display#removeCompletionHandler(com.codename1.media.Media, java.lang.Runnable)

    • createMedia

      public Media createMedia(InputStream stream, String mimeType, Runnable onCompletion) throws IOException

      Plays the sound in the given stream

      Parameters
      • stream: the stream containing the media data

      • mimeType: the type of the data in the stream

      • onCompletion: invoked when the audio file finishes playing, may be null

      Returns

      a handle that can be used to control the playback of the audio

      Throws
      • java.io.IOException: if the URI access fails
      See also
      • #createMediaAsync(java.io.InputStream, java.lang.String, java.lang.Runnable)
      Throws:
      IOException
    • createMediaAsync

      public AsyncResource<Media> createMediaAsync(InputStream stream, String mimeType, Runnable onCompletion)

      Creates media asynchronously.

      Parameters
      • stream: the stream containing the media data

      • mimeType: the type of the data in the stream

      • onCompletion: invoked when the audio file finishes playing, may be null

      Returns

      a handle that can be used to control the playback of the audio

      Since

      7.0

      See also
      • #createMedia(java.io.InputStream, java.lang.String, java.lang.Runnable)
    • createBackgroundMedia

      public Media createBackgroundMedia(String uri) throws IOException

      Creates an audio media that can be played in the background.

      Parameters
      • uri: @param uri the uri of the media can start with jar://, file://, http:// (can also use rtsp:// if supported on the platform)
      Returns
      Returns:

      Media a Media Object that can be used to control the playback of the media

      Throws
      • IOException: if creation of media from the given URI has failed
      Throws:
      IOException
    • createBackgroundMediaAsync

      public AsyncResource<Media> createBackgroundMediaAsync(String uri)

      Creates an audio media that can be played in the background.

      This is run asynchronously so that this call does not block.

      Parameters
      • uri: @param uri the uri of the media can start with jar://, file://, http:// (can also use rtsp:// if supported on the platform)
      Returns
      Returns:

      Media a Media Object that can be used to control the playback of the media

      Throws
      • IOException: if creation of media from the given URI has failed
    • createSoftWeakRef

      public Object createSoftWeakRef(Object o)

      Creates a soft/weak reference to an object that allows it to be collected yet caches it. This method is in the porting layer since CLDC only includes weak references while some platforms include nothing at all and some include the superior soft references.

      Parameters
      • o: object to cache
      Returns

      a caching object or null if caching isn't supported

    • extractHardRef

      public Object extractHardRef(Object o)

      Extracts the hard reference from the soft/weak reference given

      Parameters
      • o: the reference returned by createSoftWeakRef
      Returns

      the original object submitted or null

    • notifyCommandBehavior

      public void notifyCommandBehavior(int commandBehavior)

      This method notifies the implementation about the chosen commands behavior

      Parameters
      • commandBehavior: see Display.COMMAND_BEHAVIOR...
    • hasNativeTheme

      public boolean hasNativeTheme()

      Indicates if the implemenetation has a native underlying theme

      Returns

      true if the implementation has a native theme available

    • installNativeTheme

      public void installNativeTheme()
      Installs the native theme, this is only applicable if hasNativeTheme() returned true. Notice that this method might replace the DefaultLookAndFeel instance and the default transitions.
    • copyToClipboard

      public void copyToClipboard(Object obj)

      Performs a clipboard copy operation, if the native clipboard is supported by the implementation it would be used

      Parameters
      • obj: @param obj object to copy, while this can be any arbitrary object it is recommended that only Strings or Codename One image objects be used to copy
    • getPasteDataFromClipboard

      public Object getPasteDataFromClipboard()

      Returns the current content of the clipboard

      Returns

      can be any object or null see copyToClipboard

    • isPortrait

      public boolean isPortrait()

      Returns true if the device is currently in portrait mode

      Returns

      true if the device is in portrait mode

    • canForceOrientation

      public boolean canForceOrientation()

      Returns true if the device allows forcing the orientation via code, feature phones do not allow this although some include a jad property allowing for this feature

      Returns

      true if lockOrientation would work

    • lockOrientation

      public void lockOrientation(boolean portrait)

      On devices that return true for canForceOrientation() this method can lock the device orientation either to portrait or landscape mode

      Parameters
      • portrait: true to lock to portrait mode, false to lock to landscape mode
    • unlockOrientation

      public void unlockOrientation()
      This is the reverse method for lock orientation allowing orientation lock to be disabled
    • isNativeBrowserComponentSupported

      public boolean isNativeBrowserComponentSupported()

      An implementation can return true if it supports embedding a native browser widget

      Returns

      true if the implementation supports embedding a native browser widget

    • setPinchToZoomEnabled

      public void setPinchToZoomEnabled(PeerComponent browserPeer, boolean e)

      Some platforms require that you enable pinch to zoom explicitly. This method has no effect if pinch to zoom isn't supported by the platform

      Parameters
      • browserPeer: browser instance

      • e: true to enable pinch to zoom, false to disable it

    • setNativeBrowserScrollingEnabled

      public void setNativeBrowserScrollingEnabled(PeerComponent browserPeer, boolean e)

      Allows disabling the browsers native scrolling on devices that support it

      Parameters
      • browserPeer: browser instance

      • e: true to enables scrolling and false disables it

    • createBrowserComponent

      public PeerComponent createBrowserComponent(Object browserComponent)

      If the implementation supports the creation of a browser component it should be returned in this method

      Parameters
      • browserComponent: instance of the browser component thru which events should be fired
      Returns

      an instance of the native browser peer or null

    • postMessage

      public boolean postMessage(Object browserComponent, String message, String targetOrigin)

      Posts a message to the window in a BrowserComponent. This is intended to be an abstraction of the Javascript postMessage() API.

      This is only overridden by the Javascript port to provide proper CORS handling. Other ports use the implementation in BrowserComponent.

      Web pages wishing to receive messages via this mechanism should register a "message" event listener. See Javascript postMessage() docs for more details about this.

      Parameters
      • browserComponent: The browser component peer.

      • message: The message to send

      • targetOrigin: The target origin for the message.

      Returns

      True if the implementation handled the message. False to let BrowserComponent handle it in its default way.

      Since

      7.0

      See also
      • BrowserComponent#postMessage(java.lang.String, java.lang.String)

      • #installMessageListener(java.lang.Object)

      • #uninstallMessageListener(java.lang.Object)

    • installMessageListener

      public boolean installMessageListener(Object browserComponent)

      Installs a message listener to allow webpages inside a browser component to send messages to CN1 cross-domain.

      This will be overridden by the Javascript port only to handle CORS. Other ports use the default implementation in BrowserComponent.

      Parameters
      • browserComponent: The browser component peer.
      Returns

      True if a message listener was installed. False otherwise.

      See also
      • #postMessage(java.lang.Object, java.lang.String, java.lang.String)

      • BrowserComponent#onMessage

      • BrowserComponent#postMessage(java.lang.String, java.lang.String)

    • uninstallMessageListener

      public boolean uninstallMessageListener(Object browserComponent)

      Uninstalls a message listener to allow webpages inside a browser component to send messages to CN1 cross-domain.

      This will be overridden by the Javascript port only to handle CORS. Other ports use the default implementation in BrowserComponent.

      Parameters
      • browserComponent: The browser component peer.
      Returns

      True if a message listener was installed. False otherwise.

      See also
      • #postMessage(java.lang.Object, java.lang.String, java.lang.String)

      • BrowserComponent#onMessage

      • BrowserComponent#postMessage(java.lang.String, java.lang.String)

    • createNativeOverlay

      public Object createNativeOverlay(Component cmp)

      Creates a native overlay for the given component. A native overlay is a native component that is always present over the given component. It can be used to help processing user events in a more native way. In the Javascript port, native overlays are used on TextFields, for example, so that users can tap on the text field and activate the keyboard. This was necessary because iOS doesn't allow us to programmatically activate the keyboard. Without a native overlay, the user would first have to tap the lightweight keyboard - upon which we create a native text field, and then the user would have to tap again to activate the keyboard. Using native overlays in that case yields better UX.

      When using native overlays, you will need to implement #createNativeOverlay(com.codename1.ui.Component), java.lang.Object), and java.lang.Object). #createNativeOverlay(com.codename1.ui.Component) is called in Component#initComponent() (i.e. when the component is added to the form). This is where you would create the native view and add it to the native view hierarchy above the CN1 canvas. java.lang.Object) is called in Component#laidOut() (i.e. when the component is resized/positioned). This is where you can reposition the native view or change its properties to be appropriate for the "occasion". java.lang.Object) is called in Component#deinitialize() (i.e. when the component is removed from the form). You should destroy the native view and remove it from the native view hierarchy here.

      Parameters
      • cmp: The component to create the overlay for.
      Returns

      A native object. The object type/format is decided by the implementation.

      See also
      • #hideNativeOverlay(com.codename1.ui.Component, java.lang.Object)

      • #updateNativeOverlay(com.codename1.ui.Component, java.lang.Object)

      • Component#showNativeOverlay()

    • hideNativeOverlay

      public void hideNativeOverlay(Component cmp, Object nativeOverlay)

      Hides the native overlay for a component.

      Parameters
      • cmp: The component

      • nativeOverlay: The native overlay.

      See also
      • #createNativeOverlay(com.codename1.ui.Component)

      • #updateNativeOverlay(com.codename1.ui.Component, java.lang.Object)

      • Component#hideNativeOverlay()

    • updateNativeOverlay

      public void updateNativeOverlay(Component cmp, Object nativeOverlay)

      Updates the native overlay after the component has been repositioned.

      Parameters
      • cmp: The component

      • nativeOverlay: The native overlay

      See also
      • #createNativeOverlay(com.codename1.ui.Component)

      • #hideNativeOverlay(com.codename1.ui.Component, java.lang.Object)

      • Component#updateNativeOverlay()

    • setBrowserProperty

      public void setBrowserProperty(PeerComponent browserPeer, String key, Object value)

      This method allows customizing the properties of a web view in various ways including platform specific settings. When a property isn't supported by a specific platform it is just ignored.

      Parameters
      • browserPeer: browser instance

      • key: see the documentation with the Codename One Implementation for further details

      • value: see the documentation with the Codename One Implementation for further details

    • getBrowserTitle

      public String getBrowserTitle(PeerComponent browserPeer)

      The page title

      Parameters
      • browserPeer: browser instance
      Returns

      the title

    • getBrowserURL

      public String getBrowserURL(PeerComponent browserPeer)

      The page URL

      Parameters
      • browserPeer: browser instance
      Returns

      the URL

    • captureBrowserScreenshot

      public AsyncResource<Image> captureBrowserScreenshot(PeerComponent browserPeer)

      Captures a screenshot from a browser component asynchronously.

      Parameters
      • browserPeer: The browser instance
      Returns
      Returns:

      AsyncResource resolving to an image of the snapshot. If this returns null, then BrowserComponent#captureScreenshot() will just use Component#toImage() for screenshots.

      Since

      7.0

    • setBrowserPageInHierarchy

      public void setBrowserPageInHierarchy(PeerComponent browserPeer, String url) throws IOException

      Sets a relative URL from the html hierarchy

      Parameters
      • browserPeer: the peer component

      • url: the url relative to the HTML directory

      Throws:
      IOException
    • setBrowserURL

      public void setBrowserURL(PeerComponent browserPeer, String url, Map<String,String> headers)

      Sets the page URL, jar: URL's must be supported by the implementation

      Parameters
      • browserPeer: browser instance

      • url: the URL

      • headers: custom headers for the request URL

    • isURLWithCustomHeadersSupported

      public boolean isURLWithCustomHeadersSupported()

      Returns true if setBrowserURL with custom headers is supported

      Returns

      returns false by default

    • setBrowserURL

      public void setBrowserURL(PeerComponent browserPeer, String url)

      Sets the page URL, jar: URL's must be supported by the implementation

      Parameters
      • browserPeer: browser instance

      • url: the URL

    • browserReload

      public void browserReload(PeerComponent browserPeer)

      Reload the current page

      Parameters
      • browserPeer: browser instance
    • browserHasBack

      public boolean browserHasBack(PeerComponent browserPeer)

      Indicates whether back is currently available

      Parameters
      • browserPeer: browser instance
      Returns

      true if back should work

    • browserHasForward

      public boolean browserHasForward(PeerComponent browserPeer)

      Indicates whether forward is currently available

      Parameters
      • browserPeer: browser instance
      Returns

      true if forward should work

    • browserBack

      public void browserBack(PeerComponent browserPeer)

      Navigates back in the history

      Parameters
      • browserPeer: browser instance
    • browserStop

      public void browserStop(PeerComponent browserPeer)

      Stops loading the current page

      Parameters
      • browserPeer: browser instance
    • browserDestroy

      public void browserDestroy(PeerComponent internal)

      Release browser native resources

      Parameters
      • internal: browser instance
    • browserForward

      public void browserForward(PeerComponent browserPeer)

      Navigates forward in the history

      Parameters
      • browserPeer: browser instance
    • browserClearHistory

      public void browserClearHistory(PeerComponent browserPeer)

      Clears navigation history

      Parameters
      • browserPeer: browser instance
    • setBrowserPage

      public void setBrowserPage(PeerComponent browserPeer, String html, String baseUrl)

      Shows the given HTML in the native viewer

      Parameters
      • browserPeer: browser instance

      • html: HTML web page

      • baseUrl: base URL to associate with the HTML

    • browserExecute

      public void browserExecute(PeerComponent browserPeer, String javaScript)

      Executes the given JavaScript string within the current context

      Parameters
      • browserPeer: browser instance

      • javaScript: the JavaScript string

    • browserExecuteAndReturnString

      public String browserExecuteAndReturnString(PeerComponent internal, String javaScript)

      Executes javascript and returns string. The default implementation just wraps the browserExecute() method that doesn't return anything. It will return null always. You need to override this in the native implementation to return meaningful values.

      Parameters
      • internal: The peer browser component.

      • javaScript: The javascript to execute.

      Returns

      String result of the javascript expression.

    • supportsBrowserExecuteAndReturnString

      public boolean supportsBrowserExecuteAndReturnString(PeerComponent internal)
    • browserExposeInJavaScript

      public void browserExposeInJavaScript(PeerComponent browserPeer, Object o, String name)

      Allows exposing the given object to JavaScript code so the JavaScript code can invoke methods and access fields on the given object. Notice that on RIM devices which don't support reflection this object must implement the propriatery Scriptable interface http://www.blackberry.com/developers/docs/5.0.0api/net/rim/device/api/script/Scriptable.html

      Parameters
      • browserPeer: browser instance

      • o: the object to invoke, notice all public fields and methods would be exposed to JavaScript

      • name: the name to expose within JavaScript

      Deprecated
    • convertToPixels

      public int convertToPixels(int dipCount, boolean horizontal)

      Converts the dips count to pixels, dips are roughly 1mm in length. This is a very rough estimate and not to be relied upon

      Parameters
      • dipCount: the dips that we will convert to pixels

      • horizontal: indicates pixels in the horizontal plane

      Returns

      value in pixels

    • isTablet

      public boolean isTablet()

      Indicates whether the device is a tablet, notice that this is often a guess

      Returns

      true if the device is assumed to be a tablet

    • isDesktop

      public boolean isDesktop()

      Returns true if this is a desktop application

      Returns

      true if this is a desktop application

    • canDial

      public boolean canDial()

      Returns true if the device has dialing capabilities

      Returns

      false if it cannot dial

    • setThreadPriority

      public void setThreadPriority(Thread t, int p)

      Allows an implementation to modify setting thread priority, some implementations don't handle thread priorities well

      Parameters
      • t: the thread

      • p: the priority

    • postInit

      public void postInit()
      Callback allowing the implementation to perform an operation on the init thread after initialization was completed
    • initDefaultUserAgent

      protected void initDefaultUserAgent()
      Some old platforms might need this but for modern platforms the user agent should "just work".
    • setImageName

      public void setImageName(Object nativeImage, String name)

      Allows for easier debugging of native implementations by setting the image name to the native image object

      Parameters
      • nativeImage: the native image

      • name: the name/file name identifying the image

    • areMutableImagesFast

      public boolean areMutableImagesFast()

      On most platforms it is quite fast to draw on a mutable image and then render that image, however some platforms have much slower mutable images in comparison to just drawing on the screen. These platforms should return false here and Codename One will try to use less mutable image related optimizations in transitions and other operations.

      Returns

      true if mutable images are fast on this platform

    • removeCookiesForDomain

      protected final void removeCookiesForDomain(String domain)
    • addCookie

      public void addCookie(Cookie[] cookiesArray)
    • isNativeCookieSharingSupported

      public boolean isNativeCookieSharingSupported()

      Checks if this platform supports sharing cookies between Native components (e.g. BrowserComponent) and ConnectionRequests. Currently only Android and iOS ports support this.

      Returns

      True if platform supports native cookie sharing.

      Since

      8.0

    • addCookie

      public void addCookie(Cookie c)

      Adds/replaces a cookie to be sent to the given domain

      Parameters
      • c: cookie to add
    • getURLDomain

      public String getURLDomain(String url)

      Returns the domain for the given URL

      Parameters
      • url: a url
      Returns

      the domain

    • getURLPath

      public String getURLPath(String url)
    • getCookiesForURL

      public Vector getCookiesForURL(String url)

      Returns the cookies for this URL

      Parameters
      • url: the url on which we are checking for cookies
      Returns

      the cookies to submit to the given URL

    • clearNativeCookies

      public void clearNativeCookies()
    • connect

      public abstract Object connect(String url, boolean read, boolean write) throws IOException

      Connects to a given URL, returns a connection object to be used with the implementation later

      Parameters
      • url: the URL to connect to

      • read: indicates whether the connection will be read from

      • write: indicates whether writing will occur into the connection

      Returns

      a URL instance

      Throws:
      IOException
    • getSSLCertificates

      public String[] getSSLCertificates(Object connection, String url) throws IOException

      Gets the SSL certificates for a connection

      Parameters
      • connection: The connection.

      • url: The url of the connection.

      Returns

      String array where each certificate is in form :

      Throws
      • IOException
      Throws:
      IOException
    • canGetSSLCertificates

      public boolean canGetSSLCertificates()

      Checks if the platform supports getting SSL certificates.

      Returns

      True if the platform supports SSL certificates.

    • checkSSLCertificatesRequiresCallbackFromNative

      public boolean checkSSLCertificatesRequiresCallbackFromNative()

      SSL certificate checks must be performed via a callback from the native side, rather than explicitly checking as part of NetworkManager's connection flow. This is mainly for iOS POST requests. If we try to get the SSL certs explicitly, it forces the connection to be sent without a POST body. Hence we need to let iOS do the check on the native side, and callback into Java to run the checkSSLCertificates method of the request.

      Returns

      True if the platform requires a native callback fo check SSL certificates

    • setConnectionId

      public void setConnectionId(Object connection, int id)
    • addConnectionToQueue

      public void addConnectionToQueue(ConnectionRequest req)

      This method is called by the NetworkManager when a request is added to the queue. This allows the implementation to track the time that the request was queued for diagnostics purposes. The Simulator's Network monitor uses this information to display stats about each network connection.

      Parameters
      • req: The ConnectionRequest that is queued.
    • connect

      public Object connect(String url, boolean read, boolean write, int timeout) throws IOException

      Connects to a given URL, returns a connection object to be used with the implementation later

      Parameters
      • url: the URL to connect to

      • read: indicates whether the connection will be read from

      • write: indicates whether writing will occur into the connection

      • timeout: the timeout version of this method

      Returns

      a URL instance

      Throws:
      IOException
    • setHttpMethod

      public void setHttpMethod(Object connection, String method) throws IOException

      Requests special http method such as put or delete

      Parameters
      • connection: the connection object

      • method: the method string

      Throws:
      IOException
    • setHeader

      public abstract void setHeader(Object connection, String key, String val)

      Indicates the HTTP header value for an HTTP connection

      Parameters
      • connection: the connection object

      • key: the key for the header

      • val: the value for the header

    • setChunkedStreamingMode

      public void setChunkedStreamingMode(Object connection, int bufferLen)

      This method is used to enable streaming of a HTTP request body without internal buffering, when the content length is not known in advance. In this mode, chunked transfer encoding is used to send the request body. Note, not all HTTP servers support this mode. This mode is supported on Android and the Desktop ports.

      Parameters
      • connection: the connection object

      • bufferLen: @param bufferLen The number of bytes to write in each chunk. If chunklen is less than or equal to zero, a default value will be used.

    • cleanup

      public void cleanup(Object o)

      Closes the object (connection, stream etc.) without throwing any exception, even if the object is null

      Parameters
      • o: Connection, Stream or other closeable object
    • isSetCursorSupported

      public boolean isSetCursorSupported()

      Checks if this platform supports custom cursors.

      Returns

      True if the platform supports custom cursors.

      See also
      • Form#setEnableCursors(boolean)

      • Component#setCursor(int)

      • ComponentSelector#setCursor(int)

    • getContentLength

      public abstract int getContentLength(Object connection)

      Returns the content length for this connection

      Parameters
      • connection: the connection
      Returns

      the content length

    • openOutputStream

      public abstract OutputStream openOutputStream(Object connection) throws IOException

      Returns an output stream for the given connection

      Parameters
      • connection: the connection to open an output stream on
      Returns

      the created output stream

      Throws
      • IOException: thrown by underlying implemnetation
      Throws:
      IOException
    • openOutputStream

      public abstract OutputStream openOutputStream(Object connection, int offset) throws IOException

      Returns an output stream for the given connection

      Parameters
      • connection: the connection to open an output stream on

      • offset: position in the file

      Returns

      the created output stream

      Throws
      • IOException: thrown by underlying implemnetation
      Throws:
      IOException
    • openInputStream

      public abstract InputStream openInputStream(Object connection) throws IOException

      Returns an input stream for the given connection

      Parameters
      • connection: the connection to open an input stream on
      Returns

      the created input stream

      Throws
      • IOException: thrown by underlying implemnetation
      Throws:
      IOException
    • openFileOutputStream

      public OutputStream openFileOutputStream(String file) throws IOException

      Returns an output stream for the given file

      Parameters
      • file: the file to which we should open a stream
      Returns

      the created output stream

      Throws
      • IOException: thrown by underlying implemnetation
      Throws:
      IOException
    • openFileInputStream

      public InputStream openFileInputStream(String file) throws IOException

      Returns an input stream for the given connection

      Parameters
      • file: the file to which we should open a stream
      Returns

      the created input stream

      Throws
      • IOException: thrown by underlying implemnetation
      Throws:
      IOException
    • setPostRequest

      public abstract void setPostRequest(Object connection, boolean p)

      Indicates the whether the request method is GET or POST

      Parameters
      • connection: the connection object

      • p: true for post false for get

    • getResponseCode

      public abstract int getResponseCode(Object connection) throws IOException

      Returns the server response code for the request

      Parameters
      • connection: the connection object
      Returns

      a numeric HTTP response code

      Throws
      • IOException: if the request failed
      Throws:
      IOException
    • getResponseMessage

      public abstract String getResponseMessage(Object connection) throws IOException

      Returns the server response message for the request

      Parameters
      • connection: the connection object
      Returns

      a text message to go along with the response code

      Throws
      • IOException: if the request failed
      Throws:
      IOException
    • getHeaderField

      public abstract String getHeaderField(String name, Object connection) throws IOException

      Returns the HTTP response header field

      Parameters
      • name: field name for http header

      • connection: the connection object

      Returns

      the value of the header field

      Throws
      • IOException: if the request failed
      Throws:
      IOException
    • getHeaderFieldNames

      public abstract String[] getHeaderFieldNames(Object connection) throws IOException

      Returns the HTTP response header field

      Parameters
      • connection: the connection object
      Returns

      the value of the header field

      Throws
      • IOException: if the request failed
      Throws:
      IOException
    • getHeaderFields

      public abstract String[] getHeaderFields(String name, Object connection) throws IOException

      Returns the HTTP response header fields, returns optionally more than one result or null if no field is present.

      Parameters
      • name: field name for http header

      • connection: the connection object

      Returns

      the values of the header fields

      Throws
      • IOException: if the request failed
      Throws:
      IOException
    • isTimeoutSupported

      public boolean isTimeoutSupported()

      Indicates whether the underlying implementation supports the notion of a network operation timeout. If not timeout is "faked"

      Returns

      true if HTTP timeout can be configured for this IO implementation

    • setTimeout

      public void setTimeout(int t)

      This will work only if http timeout is supported

      Parameters
      • t: time in milliseconds
    • flushStorageCache

      public void flushStorageCache()
      Flush the storage cache allowing implementations that cache storage objects to store
    • getStorageData

      public Object getStorageData()

      The storage data is used by some storage implementations (e.g. CDC) to place the storage object in a "proper" location matching the application name. This needs to be set by the user, the name might be ignored in platforms (such as MIDP) where storage is mapped to a native application specific storage.

      Returns

      the name for the storage

    • setStorageData

      public void setStorageData(Object storageData)

      The storage data is used by some storage implementations (e.g. CDC) to place the storage object in a "proper" location matching the application name. This needs to be set by the user, the name might be ignored in platforms (such as MIDP) where storage is mapped to a native application specific storage.

      Parameters
      • storageData: the name for the storage or its context
    • deleteStorageFile

      public abstract void deleteStorageFile(String name)

      Deletes the given file name from the storage

      Parameters
      • name: the name of the storage file
    • clearStorage

      public void clearStorage()
      Deletes all the files in the application storage
    • createStorageOutputStream

      public abstract OutputStream createStorageOutputStream(String name) throws IOException

      Creates an output stream to the storage with the given name

      Parameters
      • name: the storage file name
      Returns

      an output stream of limited capcity

      Throws:
      IOException
    • createStorageInputStream

      public abstract InputStream createStorageInputStream(String name) throws IOException

      Creates an input stream to the given storage source file

      Parameters
      • name: the name of the source file
      Returns

      the input stream

      Throws:
      IOException
    • storageFileExists

      public abstract boolean storageFileExists(String name)

      Returns true if the given storage file exists

      Parameters
      • name: the storage file name
      Returns

      true if it exists

    • listStorageEntries

      public abstract String[] listStorageEntries()

      Lists the names of the storage files

      Returns

      the names of all the storage files

    • getStorageEntrySize

      public int getStorageEntrySize(String name)

      Returns the size of the entry in bytes

      Parameters
      • name: the entry name
      Returns

      the size

    • listFilesystemRoots

      public abstract String[] listFilesystemRoots()

      Returns the filesystem roots from which the structure of the file system can be traversed

      Returns

      the roots of the filesystem

    • listFiles

      public abstract String[] listFiles(String directory) throws IOException

      Lists the files within the given directory, returns relative file names and not full file names.

      Parameters
      • directory: the directory in which files should be listed
      Returns

      array of file names

      Throws:
      IOException
    • getRootSizeBytes

      public abstract long getRootSizeBytes(String root)

      Returns the size of the given root directory

      Parameters
      • root: the root directory in the filesystem
      Returns

      the byte size of the directory

    • getRootAvailableSpace

      public abstract long getRootAvailableSpace(String root)

      Returns the available space in the given root directory

      Parameters
      • root: the root directory in the filesystem
      Returns

      the bytes available in the directory

    • mkdir

      public abstract void mkdir(String directory)

      Creates the given directory

      Parameters
      • directory: the directory name to create
    • deleteFile

      public abstract void deleteFile(String file)

      Deletes the specific file or empty directory.

      Parameters
      • file: file or empty directory to delete
    • isHidden

      public abstract boolean isHidden(String file)

      Indicates the hidden state of the file

      Parameters
      • file: file
      Returns

      true for a hidden file

    • setHidden

      public abstract void setHidden(String file, boolean h)

      Toggles the hidden state of the file

      Parameters
      • file: file

      • h: hidden state

    • getFileLength

      public abstract long getFileLength(String file)

      Returns the length of the file

      Parameters
      • file: file
      Returns

      length of said file

    • getFileLastModified

      public long getFileLastModified(String file)

      Returns the time that the file denoted by this abstract pathname was last modified.

      Returns
      Returns:
      A long value representing the time the file was last modified, measured in milliseconds
    • isDirectory

      public abstract boolean isDirectory(String file)

      Indicates whether the given file is a directory

      Parameters
      • file: file
      Returns

      true if its a directory

    • exists

      public abstract boolean exists(String file)

      Indicates whether the given file exists

      Parameters
      • file: file
      Returns

      true if it exists

    • rename

      public abstract void rename(String file, String newName)

      Renames a file to the given name, expects the new name to be relative to the current directory

      Parameters
      • file: absolute file name

      • newName: relative new name

    • getFileSystemSeparator

      public abstract char getFileSystemSeparator()

      Returns the file system separator char normally '/'

      Returns

      the separator char

    • getLineSeparator

      public String getLineSeparator()
    • isAPSupported

      public boolean isAPSupported()

      Indicates whether looking up an access point is supported by this device

      Returns

      true if access point lookup is supported

    • getAPIds

      public String[] getAPIds()

      Returns the ids of the access points available if supported

      Returns

      ids of access points

    • getAPType

      public int getAPType(String id)

      Returns the type of the access point

      Parameters
      • id: access point id
      Returns

      one of the supported access point types from network manager

    • getAPName

      public String getAPName(String id)

      Returns the user displayable name for the given access point

      Parameters
      • id: the id of the access point
      Returns

      the name of the access point

    • getCurrentAccessPoint

      public String getCurrentAccessPoint()

      Returns the id of the current access point

      Returns

      id of the current access point

    • setCurrentAccessPoint

      public void setCurrentAccessPoint(String id)

      Returns the id of the current access point

      Parameters
      • id: id of the current access point
    • isVPNDetectionSupported

      public boolean isVPNDetectionSupported()

      Indicates whether this platform can attempt to detect active VPN usage.

      The default implementation returns false. Platforms that provide a best-effort VPN heuristic should override this method and #isVPNActive().

      Returns

      true if VPN detection is implemented on this platform.

    • isVPNActive

      public boolean isVPNActive()

      Best-effort check for whether a VPN appears to be active.

      This API is intentionally heuristic and should not be used as a security boundary. False positives and false negatives are both possible, and some VPN products may avoid detection completely.

      Returns

      true if the platform believes a VPN may be active.

    • shouldWriteUTFAsGetBytes

      public boolean shouldWriteUTFAsGetBytes()

      For some reason the standard code for writing UTF8 output in a server request doesn't work as expected on SE/CDC stacks.

      Returns

      true if the getBytes() approach should be used

    • startThread

      public void startThread(String name, Runnable r)

      Some devices need more elaborate thread creation logic e.g. to increase the default stack size or might use a pooling strategy

      Parameters
      • name: the name of the thread

      • r: the runnable

    • closingOutput

      public void closingOutput(OutputStream s)

      Allows binding logic to occur before closing the output stream such as syncing

      Parameters
      • s: the closing stream
    • printStackTraceToStream

      public void printStackTraceToStream(Throwable t, Writer o)

      Allows the logger to print the stack trace into the log when the native platform supports that

      Parameters
      • t: the exception

      • o: the writer

    • setLogListener

      public void setLogListener(ActionListener al)

      This method is useful strictly for debugging, the logger can use it to track file opening/closing thus detecting potential file resource leaks that can cause serious problems in some OS's.

      Parameters
      • al: action listener to receive the callback
    • isLogged

      protected boolean isLogged()

      Indicates whether logging is turned on

      Returns

      true or false

    • log

      protected void log(String content)

      Dispatch the message to the logger

      Parameters
      • content: content of the message
    • systemOut

      public void systemOut(String content)

      System print

      Parameters
      • content
    • logStreamCreate

      public void logStreamCreate(String name, boolean isInput, int count)

      Logs the creation of a stream

      Parameters
      • name: the name of the stream

      • isInput: whether the stream is an input or output stream

      • count: the number of streams of this type

    • logStreamClose

      public void logStreamClose(String name, boolean isInput, int count)

      Logs the closing of a stream

      Parameters
      • name: the name of the stream

      • isInput: whether the stream is an input or output stream

      • count: the number of streams of this type

    • logStreamDoubleClose

      public void logStreamDoubleClose(String name, boolean isInput)

      Logs the closing of a stream

      Parameters
      • name: the name of the stream

      • isInput: whether the stream is an input or output stream

    • getRootType

      public int getRootType(String root)

      Returns the type of the root often by guessing

      Parameters
      • root: the root whose type we are checking
      Returns

      one of the type constants above

    • getLocationManager

      public LocationManager getLocationManager()

      This method returns the platform Location Control

      Returns

      LocationManager Object

    • releaseImage

      public void releaseImage(Object image)

      Allows buggy implementations (Android) to release image objects

      Parameters
      • image: native image object
    • capturePhoto

      public void capturePhoto(ActionListener response)

      Captures a photo and notifies with the image data when available

      Parameters
      • response: callback for the resulting image
    • captureScreen

      public Image captureScreen()

      Captures a screenshot of the screen.

      Returns

      An image of the screen, or null if it failed.

      Since

      7.0

      Deprecated

      replaced by screenshot()

    • captureAudio

      public void captureAudio(ActionListener<ActionEvent> response)
    • getSharedJavscriptContext

      public final BrowserComponent getSharedJavscriptContext()

      Gets a reference to an application-wide shared Javascript context that can be used for running Javascript commands. When running in the Javascript port, this Javascript context will be the same context in which the application itself is running, so it gives you the ability to interact with the browser and DOM directly using the familiar BrowserComponent API.

      When running on other platforms, this shared context will be an off-screen browser component.

      Returns

      A shared BrowserComponent

      Since

      7.0

    • createSharedJavascriptContext

      protected BrowserComponent createSharedJavascriptContext()

      Creates a shared javascript context. This can be overridden by ports to return a special browser component. On the Javascript port it returns a special component that encapsulates the browser environment that the application is running in.

      Returns

      A shared BrowserComponent

      Since

      7.0

    • captureAudio

      public void captureAudio(MediaRecorderBuilder recordingOptions, ActionListener<ActionEvent> response)

      Captures a audio and notifies with the raw data when available

      Parameters
      • response: callback for the resulting data
    • captureVideo

      public void captureVideo(ActionListener response)

      Captures a video and notifies with the data when available

      Parameters
      • response: callback for the resulting video
    • captureVideo

      public void captureVideo(VideoCaptureConstraints constraints, ActionListener response)

      Captures a video, and notifies with the data when available. This version accepts capture constraints which may be used if the platform supports them.

      Parameters
      • constraints: Constraints for the capture.

      • response: Callback for the resulting video.

      Since

      7.0

      See also
      • com.codename1.capture.Capture#captureVideo(com.codename1.capture.VideoCaptureConstraints, com.codename1.ui.events.ActionListener)
    • isGalleryTypeSupported

      public boolean isGalleryTypeSupported(int type)

      Checks if the given gallery type is supported on this platform.

      Parameters
      • type: A gallery type constant. E.g. CN1Constants#GALLERY_IMAGE, CN1Constants#GALLERY_VIDEO, CN1Constants#GALLERY_ALL, CN1Constants#GALLERY_IMAGE_MULTI, CN1Constants#GALLERY_VIDEO_MULTI, CN1Constants#GALLERY_ALL_MULTI
      Returns

      True if the gallery type is supported on this platform.

    • openGallery

      public void openGallery(ActionListener response, int type)

      Opens the device gallery The method returns immediately and the response will be sent asynchronously to the given ActionListener Object

      use this in the actionPerformed to retrieve the file path String path = (String) evt.getSource();

      Parameters
      • response: a callback Object to retrieve the file path

      • type: one of the following GALLERY_IMAGE, GALLERY_VIDEO, GALLERY_ALL

      Throws
      • RuntimeException: if this feature failed or unsupported on the platform
    • openImageGallery

      public void openImageGallery(ActionListener response)

      Opens the device image gallery

      Parameters
      • response: callback for the resulting image
    • getPlatformName

      public abstract String getPlatformName()

      Returns a 2-3 letter code representing the platform name for the platform override

      Returns

      the name of the platform e.g. ios, rim, win, and, me

    • getPlatformOverrides

      public String[] getPlatformOverrides()

      Returns the suffixes for ovr files that should be used when loading a layered resource file on this platform

      Returns

      a string array with the proper order of resource override layers

    • shouldAutoDetectAccessPoint

      public boolean shouldAutoDetectAccessPoint()
      This callback allows highly broken devices like the blackberry to automatically detect the network type
    • sendMessage

      public void sendMessage(String[] recipients, String subject, Message msg)

      Send an email using the platform mail client

      Parameters
      • recipients: array of e-mail addresses

      • subject: e-mail subject

      • msg: the Message to send

    • dial

      public void dial(String phoneNumber)

      Opens the device Dialer application with the given phone number

      Parameters
      • phoneNumber
    • isCallDetectionSupported

      public boolean isCallDetectionSupported()

      Indicates whether this platform can attempt to detect when an active phone call is interrupting the app.

      The default implementation returns false. Platforms with a best-effort call interruption heuristic should override this method and #isInCall().

      Returns

      true if call detection is implemented on this platform.

    • isInCall

      public boolean isInCall()

      Best-effort check for whether the platform believes a phone call is active.

      This API is intentionally heuristic and should not be treated as a reliable telephony state machine. Depending on platform restrictions it may report false positives (e.g. other interruptions that temporarily move the app out of the foreground) and false negatives (e.g. calls that are never surfaced to the app lifecycle).

      Returns

      true if the platform currently believes a phone call interruption is active.

    • sendSMS

      public void sendSMS(String phoneNumber, String message, boolean interactive) throws IOException

      Sends a SMS message to the given phone number

      Parameters
      • phoneNumber: to send the sms

      • message: the content of the sms

      Throws
      • IOException: if for some reason sending failed
      Throws:
      IOException
    • getSMSSupport

      public int getSMSSupport()

      Indicates the level of SMS support in the platform as one of: SMS_NOT_SUPPORTED (for desktop, tablet etc.), SMS_SEAMLESS (no UI interaction), SMS_INTERACTIVE (with compose UI), SMS_BOTH.

      Returns

      one of the SMS_* values

    • getApplicationIconImage

      public Image getApplicationIconImage()
      Returns an image representing the application icon, or null if not supported. This is used on Android to support the title bar icon
    • getAllContacts

      public String[] getAllContacts(boolean withNumbers)

      Gets all contacts from the address book of the device

      Parameters
      • withNumbers: if true returns only contacts that has a number
      Returns

      array of contacts unique ids

    • getLinkedContactIds

      public String[] getLinkedContactIds(Contact c)

      Gets the IDs of all contacts that are linked to the provided contact.

      Parameters
      • c: The contact
      Returns

      Array of IDs for contacts that are linked to c.

    • getContactById

      public Contact getContactById(String id)

      Get a Contact according to it's contact id.

      Parameters
      • id: unique id of the Contact
      Returns

      a Contact Object

    • getAllContacts

      public Contact[] getAllContacts(boolean withNumbers, boolean includesFullName, boolean includesPicture, boolean includesNumbers, boolean includesEmail, boolean includeAddress)

      Notice: this method might be very slow and should be invoked on a separate thread! It might have platform specific optimizations over getAllContacts followed by looping over individual contacts but that isn't guaranteed. See isGetAllContactsFast for information.

      Parameters
      • withNumbers: if true returns only contacts that has a number

      • includesFullName: if true try to fetch the full name of the Contact(not just display name)

      • includesPicture: if true try to fetch the Contact Picture if exists

      • includesNumbers: if true try to fetch all Contact numbers

      • includesEmail: if true try to fetch all Contact Emails

      • includeAddress: if true try to fetch all Contact Addresses

      Returns

      array of the contacts

    • isGetAllContactsFast

      public boolean isGetAllContactsFast()

      Indicates if the getAllContacts is platform optimized, notice that the method might still take seconds or more to run so you should still use a separate thread!

      Returns

      true if getAllContacts will perform faster that just getting each contact

    • getContactById

      public Contact getContactById(String id, boolean includesFullName, boolean includesPicture, boolean includesNumbers, boolean includesEmail, boolean includeAddress)

      This method returns a Contact by the contact id and fills it's data according to the given flags

      Parameters
      • id: of the Contact

      • includesFullName: if true try to fetch the full name of the Contact(not just display name)

      • includesPicture: if true try to fetch the Contact Picture if exists

      • includesNumbers: if true try to fetch all Contact numbers

      • includesEmail: if ture try to fetch all Contact Emails

      • includeAddress: if ture try to fetch all Contact Addresses

      Returns

      a Contact Object

    • createContact

      public String createContact(String firstName, String surname, String officePhone, String homePhone, String cellPhone, String email)

      Create a contact to the device contacts book

      Parameters
      • firstName: the Contact firstName

      • surname: the Contact familyName

      • officePhone: the Contact work phone or null

      • homePhone: the Contact home phone or null

      • cellPhone: the Contact mobile phone or null

      • email: the Contact email or null

      Returns

      the contact id if creation succeeded or null if failed

    • isContactsPermissionGranted

      public boolean isContactsPermissionGranted()

      Some platforms allow the user to block contacts access on a per application basis (specifically iOS).

      Returns

      true if contacts access is allowed or globally available, false otherwise

    • deleteContact

      public boolean deleteContact(String id)

      removed a contact from the device contacts book

      Parameters
      • id: the contact id to remove
      Returns

      true if deletion succeeded false otherwise

    • isNativeShareSupported

      public boolean isNativeShareSupported()

      Indicates if the underlying platform supports sharing capabilities

      Returns

      true if the underlying platform handles share.

    • share

      public void share(String text, String image, String mimeType)

      Share the required information using the platform sharing services. a Sharing service can be: mail, sms, facebook, twitter,... This method is implemented if isNativeShareSupported() returned true for a specific platform.

      Parameters
      • text: String to share.

      • image: file path to the image or null

      • mimeType: type of the image or null if no image to share

    • share

      public void share(String text, String image, String mimeType, Rectangle sourceRect)

      Share the required information using the platform sharing services. a Sharing service can be: mail, sms, facebook, twitter,... This method is implemented if isNativeShareSupported() returned true for a specific platform.

      Parameters
      • text: String to share.

      • image: file path to the image or null

      • mimeType: type of the image or null if no image to share

      • sourceRect: @param sourceRect The bounds of the button that was clicked to initiate the share. This is used by some platforms (e.g. iPad2 on iOS 8 or higher) to dictate where the popover dialog should be placed.

    • beforeComponentPaint

      public void beforeComponentPaint(Component c, Graphics g)

      Called before internal paint of component starts

      Parameters
      • c: the component about to be painted
    • afterComponentPaint

      public void afterComponentPaint(Component c, Graphics g)

      Called after internal paint of component finishes

      Parameters
      • c: the component that was painted
    • nothingWithinComponentPaint

      public void nothingWithinComponentPaint(Component c)

      Indicates to the port that the component won't be painted due to clipping

      Parameters
      • c: the component that won't be painted
    • componentRemoved

      public void componentRemoved(Component c)

      Indicates to the port that the component was removed from the view and its UI should be removed in the next flush operation.

      Parameters
      • c: the removed component.
    • getLocalizationManager

      public abstract L10NManager getLocalizationManager()
    • getPackageName

      protected String getPackageName()
      Returns the package name for the application
    • isTransformSupported

      public boolean isTransformSupported()

      Checks if the Transform class can be used on this platform. This is similar to #isTransformSupported(java.lang.Object) but it is more general as it only verifies that transforms can be performed, but not necessarily that they will be respected by any particular graphics context.

      Returns

      True if this platform supports transforms.

      See also
      • #isTransformSupported(java.lang.Object)
    • isPerspectiveTransformSupported

      public boolean isPerspectiveTransformSupported()

      Checks of the Transform class can be used on this platform to perform perspective transforms. This is similar to #isPerspectiveTransformSupported(java.lang.Object) but it is more general as it only verifies that transforms can be performed, but not necessarily that they will be respected by any particular graphics context.

      Returns

      True if this platform supports perspective transforms.

    • transformEqualsImpl

      public boolean transformEqualsImpl(Transform t1, Transform t2)
    • transformNativeEqualsImpl

      public boolean transformNativeEqualsImpl(Object t1, Object t2)
    • makeTransformTranslation

      public Object makeTransformTranslation(float translateX, float translateY, float translateZ)

      Makes a new native translation transform. Each implementation can decide the format to use internally for transforms. This should return a transform in that internal format. This is used by the com.codename1.ui.Transform class.

      This can only be used if #isTransformSupported() returns true.

      Parameters
      • translateX: The x-coordinate of the translation.

      • translateY: The y-coordinate of the translation.

      • translateZ: The z-coordinate of the translation.

      Returns

      A native transform object encapsulating the specified translation.

      See also
      • #isTransformSupported()
    • setTransformTranslation

      public void setTransformTranslation(Object nativeTransform, float translateX, float translateY, float translateZ)
    • makeTransformScale

      public Object makeTransformScale(float scaleX, float scaleY, float scaleZ)

      Makes a new native scale transform. Each implementation can decide the format to use internally for transforms. This should return a transform in that internal format. This is used by the com.codename1.ui.Transform class.

      This can only be used if #isTransformSupported() returns true.

      Parameters
      • scaleX: The x-scale factor of the transform.

      • scaleY: The y-scale factor of the transform.

      • scaleZ: The z-scale factor of the transform.

      Returns

      A native transform object encapsulating the specified scale.

      See also
      • #isTransformSupported()
    • makeTransformAffine

      public Object makeTransformAffine(double m00, double m10, double m01, double m11, double m02, double m12)

      Makes a transform given the specified AffineTransform values.

      Parameters
      • m00: the X coordinate scaling element of the 3x3 matrix

      • m10: the Y coordinate shearing element of the 3x3 matrix

      • m01: the X coordinate shearing element of the 3x3 matrix

      • m11: the Y coordinate scaling element of the 3x3 matrix

      • m02: the X coordinate translation element of the 3x3 matrix

      • m12: the Y coordinate translation element of the 3x3 matrix

      Since

      7.0

    • setTransformAffine

      public void setTransformAffine(Object nativeTransform, double m00, double m10, double m01, double m11, double m02, double m12)

      Sets transform to the given specified AffineTransform values.

      Parameters
      • nativeTransform: Platform-specific native transform.

      • m00: the X coordinate scaling element of the 3x3 matrix

      • m10: the Y coordinate shearing element of the 3x3 matrix

      • m01: the X coordinate shearing element of the 3x3 matrix

      • m11: the Y coordinate scaling element of the 3x3 matrix

      • m02: the X coordinate translation element of the 3x3 matrix

      • m12: the Y coordinate translation element of the 3x3 matrix

      Since

      7.0

    • setTransformScale

      public void setTransformScale(Object nativeTransform, float scaleX, float scaleY, float scaleZ)
    • makeTransformRotation

      public Object makeTransformRotation(float angle, float x, float y, float z)

      Makes a new native rotation transform. Each implementation can decide the format to use internally for transforms. This should return a transform in that internal format. This is used by the com.codename1.ui.Transform class.

      This can only be used if #isTransformSupported() returns true.

      Parameters
      • angle: The angle to rotate.

      • x: The x-component of the vector around which to rotate.

      • y: The y-component of the vector around which to rotate.

      • z: The z-component of the vector around which to rotate.

      Returns

      A native transform object encapsulating the specified rotation.

      See also
      • #isTransformSupported()
    • setTransformRotation

      public void setTransformRotation(Object nativeTransform, float angle, float x, float y, float z)
    • makeTransformPerspective

      public Object makeTransformPerspective(float fovy, float aspect, float zNear, float zFar)

      Makes a new perspective transform. Each implementation can decide the format to use internally for transforms. This should return a transform in that internal format. This is used by the com.codename1.ui.Transform class.

      This can only be used if #isPerspectiveTransformSupported() returns true.

      Parameters
      • fovy: The y field of view angle.

      • aspect: The aspect ratio.

      • zNear: The nearest visible z coordinate.

      • zFar: The farthest z coordinate.

      Returns

      A native transform object encapsulating the given perspective.

      See also
      • #isPerspectiveTransformSupported()
    • setTransformPerspective

      public void setTransformPerspective(Object nativeTransform, float fovy, float aspect, float zNear, float zFar)
    • makeTransformOrtho

      public Object makeTransformOrtho(float left, float right, float bottom, float top, float near, float far)

      Makes a new orthographic projection transform. Each implementation can decide the format to use internally for transforms. This should return a transform in that internal format. This is used by the com.codename1.ui.Transform class.

      This can only be used if #isPerspectiveTransformSupported() returns true.

      Parameters
      • left: x-coordinate that is the left edge of the view.

      • right: The x-coordinate that is the right edge of the view.

      • bottom: The y-coordinate that is the bottom edge of the view.

      • top: The y-coordinate that is the top edge of the view.

      • near: The nearest visible z-coordinate.

      • far: The farthest visible z-coordinate.

      Returns

      A native transform with the provided orthographic projection.

      See also
      • #isPerspectiveTransformSupported()
    • setTransformOrtho

      public void setTransformOrtho(Object nativeTransform, float left, float right, float bottom, float top, float near, float far)
    • makeTransformCamera

      public Object makeTransformCamera(float eyeX, float eyeY, float eyeZ, float centerX, float centerY, float centerZ, float upX, float upY, float upZ)

      Makes a transform to simulate a camera's perspective at a given location. Each implementation can decide the format to use internally for transforms. This should return a transform in that internal format. This is used by the com.codename1.ui.Transform class.

      This can only be used if #isTransformSupported() returns true.

      Parameters
      • eyeX: The x-coordinate of the camera's eye.

      • eyeY: The y-coordinate of the camera's eye.

      • eyeZ: The z-coordinate of the camera's eye.

      • centerX: The center x coordinate of the view.

      • centerY: The center y coordinate of the view.

      • centerZ: The center z coordinate of the view.

      • upX: The x-coordinate of the up vector for the camera.

      • upY: The y-coordinate of the up vector for the camera.

      • upZ: The z-coordinate of the up vector for the camera.

      Returns

      A native transform with the provided camera's view perspective.

      See also
      • #isPerspectiveTransformSupported()
    • setTransformCamera

      public void setTransformCamera(Object nativeTransform, float eyeX, float eyeY, float eyeZ, float centerX, float centerY, float centerZ, float upX, float upY, float upZ)
    • transformRotate

      public void transformRotate(Object nativeTransform, float angle, float x, float y, float z)

      Rotates the provided transform.

      Parameters
      • nativeTransform: @param nativeTransform The transform to rotate. Each implementation can decide the format to use internally for transforms. This should return a transform in that internal format. This is used by the com.codename1.ui.Transform class.

      This can only be used if #isTransformSupported() returns true.

      • angle: The angle to rotate.

      • x: The x-coordinate of the vector around which to rotate.

      • y: The y-coordinate of the vector around which to rotate.

      • z: The z-coordinate of the vector around which to rotate.

      See also
      • #isTransformSupported()
    • transformTranslate

      public void transformTranslate(Object nativeTransform, float x, float y, float z)

      Translates the transform by the specified amounts. with the specified translation.

      Parameters
      • nativeTransform: @param nativeTransform The native transform to translate. Each implementation can decide the format to use internally for transforms. This should return a transform in that internal format. This is used by the com.codename1.ui.Transform class.

      This can only be used if #isTransformSupported() returns true.

      • x: The x translation.

      • y: The y translation.

      • z: The z translation.

      See also
      • #isTransformSupported()
    • transformScale

      public void transformScale(Object nativeTransform, float x, float y, float z)

      Scales the provided transform by the provide scale factors.

      Parameters
      • nativeTransform: @param nativeTransform Each implementation can decide the format to use internally for transforms. This should return a transform in that internal format. This is used by the com.codename1.ui.Transform class.

      This can only be used if #isTransformSupported() returns true.

      • x: The x-scale factor

      • y: The y-scale factor

      • z: The z-scale factor

      See also
      • #isTransformSupported()
    • makeTransformInverse

      public Object makeTransformInverse(Object nativeTransform)

      Gets the inverse transformation for the provided transform.

      Parameters
      • nativeTransform: @param nativeTransform The native transform of which to make the inverse. Each implementation can decide the format to use internally for transforms. This should return a transform in that internal format. This is used by the com.codename1.ui.Transform class.

      This can only be used if #isTransformSupported() returns true.

      Returns
      Returns:

      The inverse transform as a native transform object. Each implementation can decide the format to use internally for transforms. This should return a transform in that internal format. This is used by the com.codename1.ui.Transform class.

      See also
      • #isTransformSupported()
    • setTransformInverse

      public void setTransformInverse(Object nativeTransform) throws Transform.NotInvertibleException
      Throws:
      Transform.NotInvertibleException
    • makeTransformIdentity

      public Object makeTransformIdentity()

      Makes a new identity native transform. Each implementation can decide the format to use internally for transforms. This should return a transform in that internal format. This is used by the com.codename1.ui.Transform class.

      This can only be used if #isTransformSupported() returns true.

      Returns

      An identity native transform.

      See also
      • #isTransformSupported()
    • setTransformIdentity

      public void setTransformIdentity(Object transform)

      Sets the given native transform to the identiy transform

      Parameters
      • transform
    • copyTransform

      public void copyTransform(Object src, Object dest)

      Copies the setting of one transform into another. Each implementation can decide the format to use internally for transforms. This should return a transform in that internal format. This is used by the com.codename1.ui.Transform class.

      This can only be used if #isTransformSupported() returns true.

      Parameters
      • src: The source native transform.

      • dest: The destination native transform.

      See also
      • #isTransformSupported()
    • concatenateTransform

      public void concatenateTransform(Object t1, Object t2)

      Concatenates two transforms and sets the first transform to be the result of the concatenation.

      This can only be used if #isTransformSupported() returns true.

      Parameters
      • t1: The left native transform. The result will also be stored in this transform.

      • t2: The right native transform.

      See also
      • #isTransformSupported()
    • transformPoint

      public void transformPoint(Object nativeTransform, float[] in, float[] out)

      Transforms a point and stores the result in a provided array.

      Parameters
      • nativeTransform: @param nativeTransform The native transform to use for the transformation. Each implementation can decide the format to use internally for transforms. This should return a transform in that internal format.

      This can only be used if #isTransformSupported() returns true.

      This is used by the com.codename1.ui.Transform class.

      • in: A 2 or 3 element array representing either an (x,y) or (x,y,z) tuple to be transformed.

      • out: A 2 or 3 element array (length should match ) to store the result of the transformation.

      See also
      • #isTransformSupported()
    • transformPoints

      public void transformPoints(Object nativeTransform, int pointSize, float[] in, int srcPos, float[] out, int destPos, int numPoints)

      Transforms a set of points using the provided transform.

      Parameters
      • nativeTransform: The transform to use for transforming the points

      • pointSize: The size of the points (either 2 or 3)

      • in: Input array of points.

      • srcPos: The start position of the input array

      • out: The output array of points

      • destPos: The start position of the output array.

      • numPoints: The number of points to transform.

    • translatePoints

      public void translatePoints(int pointSize, float tX, float tY, float tZ, float[] in, int srcPos, float[] out, int destPos, int numPoints)

      Translates a set of points.

      Parameters
      • pointSize: The size of each point (2 or 3)

      • tX: Size of translation along x-axis

      • tY: Size of translation along y-axis

      • tZ: Size of translation along z-axis (only used if pointSize == 3)

      • in: Input array of points.

      • srcPos: Start position in input array

      • out: Output array of points

      • destPos: Start position in output array

      • numPoints: Number of points to translate.

    • scalePoints

      public void scalePoints(int pointSize, float sX, float sY, float sZ, float[] in, int srcPos, float[] out, int destPos, int numPoints)

      Scales a set of points.

      Parameters
      • pointSize: The size of each point (2 or 3)

      • sX: Scale factor along x-axis

      • sY: Scale factor along y-axis

      • sZ: Scale factor along z-axis (only used if pointSize == 3)

      • in: Input array of points.

      • srcPos: Start position in input array

      • out: Output array of points

      • destPos: Start position in output array

      • numPoints: Number of points to translate.

    • refreshContacts

      public void refreshContacts()
      Clears the addressbook cache. This is only necessary on iOS since its AddressBookRef is transactional.
    • getTransform

      public void getTransform(Object nativeGraphics, Transform t)

      Sets the given transform to the current transform in the given graphics object.

      Parameters
      • nativeGraphics

      • t

    • isScrollWheeling

      public boolean isScrollWheeling()
    • blockCopyPaste

      public void blockCopyPaste(boolean blockCopyPaste)

      Blocks or enables copy and paste in the entire app.

      Parameters
      • blockCopyPaste: True to block copy and paste. False to enable it.
    • isDatabaseCustomPathSupported

      public boolean isDatabaseCustomPathSupported()

      Checks if this platform supports custom database paths. On platforms where this returns true, #openOrCreateDB(java.lang.String) will accept a file path (starting with "file://"

      Returns

      True if platform supports custom paths.

    • requestFullScreen

      public boolean requestFullScreen()

      Attempt to enter full-screen mode. Should be overridden by the platform implementation.

      Returns

      True if already in full-screen mode, or successfully entered full-screen mode.

    • exitFullScreen

      public boolean exitFullScreen()

      Exit full-screen mode.

      Returns

      True if already not in full-screen mode or successfully exited full-screen mode.

    • isInFullScreenMode

      public boolean isInFullScreenMode()

      Checks to see if the app is currently running in full-screen mode.

      Returns

      True if the app is currently running in full-screen mode.

    • isFullScreenSupported

      public boolean isFullScreenSupported()
      Checks if the platform supports full-screen mode. If this returns true then a call to #requestFullScreen() should enter full-screen mode.
    • initializeTextSelection

      public void initializeTextSelection(TextSelection aThis)

      Initializes text selection. This provides an opportunity for the native platform to register listeners on text selection to ensure that it works.

      Implementations that implement this method should also implement #deinitializeTextSelection(com.codename1.ui.TextSelection)

      Parameters
      • aThis
      Since

      7.0

      See also
      • #deinitializeTextSelection(com.codename1.ui.TextSelection)
    • deinitializeTextSelection

      public void deinitializeTextSelection(TextSelection aThis)

      Deinitializes text selection.

      Parameters
      • aThis
      Since

      7.0

      See also
      • #initializeTextSelection(com.codename1.ui.TextSelection)
    • createHeavyButton

      public Object createHeavyButton(Button aThis)

      Creates the native side of a com.codename1.ui.HeavyButton. A HeavyButton is a button that has a native button displayed over top of it. It is primarily used in the Javascript port where some functions can only be executed as a direct result of user interaction.

      Parameters
      • aThis: The lightweight button for which a heavy peer is created
      Returns

      Native peer. Format chosen by implementation.

      Since

      7.0

      See also
      • #addHeavyActionListener(java.lang.Object, com.codename1.ui.events.ActionListener)
    • addHeavyActionListener

      public void addHeavyActionListener(Object peer, ActionListener l)

      Adds an action listener which will be run in response to the native button's click event. ActionListener#actionPerformed(com.codename1.ui.events.ActionEvent) will be executed on the native UI thread, not the EDT.

      Parameters
      • peer: The peer.

      • l: The action listener.

      Since

      7.0

      See also
      • #createHeavyButton(com.codename1.ui.Button)

      • #removeHeavyActionListener(java.lang.Object, com.codename1.ui.events.ActionListener)

    • removeHeavyActionListener

      public void removeHeavyActionListener(Object peer, ActionListener l)

      Removes a heavy action listener from a heavy button.

      Parameters
      • peer: THe heavy button peer.

      • l: The action listener.

      Since

      7.0

      See also
      • #addHeavyActionListener(java.lang.Object, com.codename1.ui.events.ActionListener)

      • #createHeavyButton(com.codename1.ui.Button)

    • updateHeavyButtonBounds

      public void updateHeavyButtonBounds(Object peer, int x, int y, int width, int height)

      Updates the bounds of the native heavy button to match the bounds of the lightweight button.

      Parameters
      • peer: The heavy peer.

      • x: The absolute X coordinate of the light peer.

      • y: The absolute Y coordinate of the light peer.

      • width: The width of the light peer.

      • height: The height of the light peer.

      Since

      7.0

    • initHeavyButton

      public void initHeavyButton(Object peer)

      Initializes a heavy button. This is called whenever the light peer's initComponent() method is called. It should add the heavy button to the native UI hierarchy.

      Parameters
      • peer: The heavy peer.
      Since

      7.0

      See also
      • #createHeavyButton(com.codename1.ui.Button)
    • deinitializeHeavyButton

      public void deinitializeHeavyButton(Object peer)

      Deinitializes a heavy button. This is called whenever the light peer's deinitialize() method is called. It should remove the heavy button from the native UI hierarchy.

      Parameters
      • peer: The heavy peer.
      Since

      7.0

      See also
      • #initHeavyButton(java.lang.Object)

      • #createHeavyButton(com.codename1.ui.Button)

    • requiresHeavyButtonForCopyToClipboard

      public boolean requiresHeavyButtonForCopyToClipboard()

      Checks whether the current platform requires a heavy button for copy to clipboard functionality to work. This will be true on the Javascript port.

      Since

      7.0

      See also
      • #createHeavyButton(com.codename1.ui.Button)
    • copySelectionToClipboard

      public void copySelectionToClipboard(TextSelection sel)

      Copies the current text selection to the clipboard.

      Parameters
      • sel: The current TextSelection instance for the current form.
      Since

      7.0

    • setRenderingHints

      public void setRenderingHints(Object nativeGraphics, int hints)

      Sets the rendering hints for a graphics context.

      Parameters
      • nativeGraphics: The native graphics context

      • hints: Hints

      Since

      7.0

      See also
      • Graphics#RENDERING_HINT_FAST
    • getRenderingHints

      public int getRenderingHints(Object nativeGraphics)

      Gets the rendering hints for this graphics context

      Parameters
      • nativeGraphics: The native graphics context.
      Returns

      The current rendering hints.

      Since

      7.0

      See also
      • Graphics#RENDERING_HINT_FAST
    • startRemoteControl

      public void startRemoteControl()

      Starts the remote control service. This should be implemented in the platform to handle binding the RemoteControlListener with the platform's remote control.

      This is executed when the user registers a new listener using MediaManager#setRemoteControlListener(com.codename1.media.RemoteControlListener)

      Since

      7.0

    • stopRemoteControl

      public void stopRemoteControl()

      Stops the remote control service. This should be implemented in the platform to handle unbinding the RemoteControlListener with the platform's remote control.

      This is executed when a new listener is registered using MediaManager#setRemoteControlListener(com.codename1.media.RemoteControlListener)

      Since

      7.0

    • setReadTimeout

      public void setReadTimeout(Object connection, int readTimeout)

      Sets the read timeout of a connection.

      Parameters
      • connection

      • readTimeout

      Since

      7.0

    • setInsecure

      public void setInsecure(Object connection, boolean insecure)

      Sets connection to be insecure. If platform supports it, this will turn off SSL cerficate checks for validity.

      Parameters
      • connection

      • insecure: True to make connection insecure.

      Since

      7.0

      See also
      • ConnectionRequest#setInsecure(boolean)

      • ConnectionRequest#isInsecure()

    • isReadTimeoutSupported

      public boolean isReadTimeoutSupported()

      Checks if this platform supports read timeout in network connections.

      Returns

      True if the platform supports read timeouts.

      Since

      7.0

    • createNativeBrowserWindow

      public Object createNativeBrowserWindow(String startURL)

      Creates a native web browser window object. Default implementation returns null. Platform may override this to return its own browser window.

      Parameters
      • startURL: The Start URL to open in the browser window.
      Returns

      The browser window object, or null.

      Since

      7.0

      See also
      • com.codename1.ui.BrowserWindow

      • #addNativeBrowserWindowOnLoadListener(java.lang.Object, com.codename1.ui.events.ActionListener)

      • #removeNativeBrowserWindowOnLoadListener(java.lang.Object, com.codename1.ui.events.ActionListener)

      • #nativeBrowserWindowAddCloseListener(java.lang.Object, com.codename1.ui.events.ActionListener)

      • #nativeBrowserWindowRemoveCloseListener(java.lang.Object, com.codename1.ui.events.ActionListener)

      • #nativeBrowserWindowCleanup(java.lang.Object)

      • #nativeBrowserWindowHide(java.lang.Object)

      • #nativeBrowserWindowShow(java.lang.Object)

      • #nativeBrowserWindowSetTitle(java.lang.Object, java.lang.String)

      • #nativeBrowserWindowSetSize(java.lang.Object, int, int)

      • #nativeBrowserWindowEval(java.lang.Object, com.codename1.ui.BrowserWindow.EvalRequest)

    • addNativeBrowserWindowOnLoadListener

      public void addNativeBrowserWindowOnLoadListener(Object window, ActionListener l)

      Adds a load listener to a native browser window.

      Parameters
      • window: The window to add the listener to.

      • l: The listener

      Since

      7.0

      See also
      • #createNativeBrowserWindow(java.lang.String)
    • removeNativeBrowserWindowOnLoadListener

      public void removeNativeBrowserWindowOnLoadListener(Object window, ActionListener l)

      Removes a load listener from a native browser window.

      Parameters
      • window: The window from which to remove the listener.

      • l: The listener

      Since

      7.0

      See also
      • #createNativeBrowserWindow(java.lang.String)
    • nativeBrowserWindowSetSize

      public void nativeBrowserWindowSetSize(Object window, int width, int height)

      Sets the size of a native browser window.

      Parameters
      • window: The window

      • width: The width in pixels.

      • height: The height in pixels.

      Since

      7.0

      See also
      • #createNativeBrowserWindow(java.lang.String)
    • nativeBrowserWindowSetTitle

      public void nativeBrowserWindowSetTitle(Object window, String title)

      Sets the window title of a native browser window.

      Parameters
      • window: The window

      • title: The title

      Since

      7.0

      See also
      • #createNativeBrowserWindow(java.lang.String)
    • nativeBrowserWindowShow

      public void nativeBrowserWindowShow(Object window)

      Shows a native browser window.

      Parameters
      • window: The window
      Since

      7.0

      See also
      • #createNativeBrowserWindow(java.lang.String)
    • nativeBrowserWindowHide

      public void nativeBrowserWindowHide(Object window)

      Hides a native browser window.

      Parameters
      • window: The window
      Since

      7.0

      See also
      • #createNativeBrowserWindow(java.lang.String)
    • nativeBrowserWindowCleanup

      public void nativeBrowserWindowCleanup(Object window)

      Cleans up and disposes of a native browser window.

      Parameters
      • window: The window
      Since

      7.0

      See also
      • #createNativeBrowserWindow(java.lang.String)
    • nativeBrowserWindowEval

      public void nativeBrowserWindowEval(Object window, BrowserWindow.EvalRequest req)

      Evaluates javascript on native browser window.

      Parameters
      • window: The window

      • req: The javascript eval request.

      Since

      7.0

      See also
      • #createNativeBrowserWindow(java.lang.String)
    • nativeBrowserWindowAddCloseListener

      public void nativeBrowserWindowAddCloseListener(Object window, ActionListener l)

      Adds close listener to native browser window.

      Parameters
      • window: The window.

      • l: The listener

      Since

      7.0

      See also
      • #createNativeBrowserWindow(java.lang.String)
    • nativeBrowserWindowRemoveCloseListener

      public void nativeBrowserWindowRemoveCloseListener(Object window, ActionListener l)

      Removes close listener from native browser window.

      Parameters
      • window: The window.

      • l: The listener

      Since

      7.0

      See also
      • #createNativeBrowserWindow(java.lang.String)
    • registerPush

      public void registerPush(Hashtable metaData, boolean noFallback)

      User register to receive push notification

      Parameters
      • noFallback: @param noFallback some devices don't support an efficient push API and will resort to polling to provide push like functionality. If this flag is set to true no polling will occur and the error PushCallback.REGISTRATION_ERROR_SERVICE_NOT_AVAILABLE will be sent to the push interface.
    • deregisterPush

      public void deregisterPush()
      Stop receiving push notifications to this client application
    • createMediaRecorder

      public Media createMediaRecorder(String path, String mimeType) throws IOException

      Creates a Media recorder Object which will record from the device mic to a file in the given path.

      Parameters
      • path: @param path a file path to where to store the recording, if the file does not exists it will be created.

      • mimeType: @param mimeType the output mime type that is supported see getAvailableRecordingMimeTypes()

      Throws:
      IOException
    • createMediaRecorder

      public Media createMediaRecorder(MediaRecorderBuilder builder) throws IOException

      Creates a Media recorder Object which will record from the device mic to a file in the given path.

      Parameters
      • builder: @param builder THe media builder with settings for the recorder. getAvailableRecordingMimeTypes()
      Since

      7.0

      Throws:
      IOException
    • sendRegisteredForPush

      protected final void sendRegisteredForPush(String id)
    • pushReceived

      protected final void pushReceived(String data)
    • setPollingFrequency

      public void setPollingFrequency(int freq)

      Sets the frequency for polling the server in case of polling based push notification

      Parameters
      • freq: the frequency in milliseconds
      Deprecated

      we no longer support push polling

    • getImageIO

      public ImageIO getImageIO()

      Returns the image IO instance that allows scaling image files.

      Returns

      the image IO instance

    • instanceofObjArray

      public boolean instanceofObjArray(Object o)
      Workaround for XMLVM bug
    • instanceofByteArray

      public boolean instanceofByteArray(Object o)
      Workaround for XMLVM bug
    • instanceofShortArray

      public boolean instanceofShortArray(Object o)
      Workaround for XMLVM bug
    • instanceofLongArray

      public boolean instanceofLongArray(Object o)
      Workaround for XMLVM bug
    • instanceofIntArray

      public boolean instanceofIntArray(Object o)
      Workaround for XMLVM bug
    • instanceofFloatArray

      public boolean instanceofFloatArray(Object o)
      Workaround for XMLVM bug
    • instanceofDoubleArray

      public boolean instanceofDoubleArray(Object o)
      Workaround for XMLVM bug
    • getAvailableRecordingMimeTypes

      public String[] getAvailableRecordingMimeTypes()
      Gets the available recording MimeTypes
    • openOrCreateDB

      public Database openOrCreateDB(String databaseName) throws IOException

      Opens a database or create one if not exists

      Parameters
      • databaseName: the name of the database
      Returns

      Database Object or null if not supported on the platform

      Throws
      • IOException: if database cannot be created
      Throws:
      IOException
    • deleteDB

      public void deleteDB(String databaseName) throws IOException

      Deletes database

      Parameters
      • databaseName: the name of the database
      Throws
      • IOException: if database cannot be deleted
      Throws:
      IOException
    • existsDB

      public boolean existsDB(String databaseName)

      Indicates weather a database exists

      Parameters
      • databaseName: the name of the database
      Returns

      true if database exists

    • getDatabasePath

      public String getDatabasePath(String databaseName)

      Returns the file path of the Database if exists and if supported on the platform.

      Returns

      the file path of the database or null if not exists

    • isNativeTitle

      public boolean isNativeTitle()

      Indicates if the title of the Form is native title(in android ICS devices if the command behavior is native the ActionBar is used to display the title and the menu)

      Returns

      true if platform would like to show the Form title

    • refreshNativeTitle

      public void refreshNativeTitle()
      if the title is native(e.g the android action bar), notify the native title that is needs to be refreshed
    • getCommandBehavior

      public int getCommandBehavior()

      Indicates the way commands should be added to a form as one of the ocmmand constants defined in this class

      Returns

      the commandBehavior

    • setCommandBehavior

      public void setCommandBehavior(int commandBehavior)

      Indicates the way commands should be added to a form as one of the ocmmand constants defined in this class

      Parameters
      • commandBehavior: the commandBehavior to set
    • notifyStatusBar

      public Object notifyStatusBar(String tickerText, String contentTitle, String contentBody, boolean vibrate, boolean flashLights, Hashtable args)

      Place a notification on the device status bar (if device has this functionality). The notification will re-start the Application.

      Parameters
      • tickerText: the ticker text of the Notification

      • contentTitle: the title of the Notification

      • contentBody: the content of the Notification

      • vibrate: enable/disable notification alert

      • flashLights: enable/disable notification flashing

      • args: additional arguments to the notification

      Returns

      a platform native object that allows modifying notification state

      Deprecated

      use scheduleLocalNotification instead

    • isNotificationSupported

      public boolean isNotificationSupported()

      Indicates whether the notify status bar method will present a notification to the user

      Returns

      true if the notify status bar method will present a notification to the user

    • dismissNotification

      public void dismissNotification(Object o)

      Removes the notification previously posted with the notify status bar method

      Parameters
      • o: the object returned from the notifyStatusBar method
    • isBadgingSupported

      public boolean isBadgingSupported()

      Returns true if the underlying OS supports numeric badges on icons. Notice this is only available on iOS and only when push notification is enabled

      Returns

      true if the underlying OS supports numeric badges

    • setBadgeNumber

      public void setBadgeNumber(int number)

      Sets the number that appears on the application icon in iOS

      Parameters
      • number: number to show on the icon
    • isOpenNativeNavigationAppSupported

      public boolean isOpenNativeNavigationAppSupported()

      Returns true if the underlying OS supports opening the native navigation application

      Returns

      true if the underlying OS supports launch of native navigation app

    • openNativeNavigationApp

      public void openNativeNavigationApp(double latitude, double longitude)

      Opens the native navigation app in the given coordinate.

      Parameters
      • latitude

      • longitude

    • openNativeNavigationApp

      public void openNativeNavigationApp(String location)

      Opens the native navigation app with the given search location

      Parameters
      • location: the location to search for in the native navigation map
    • getUdid

      public String getUdid()

      Returns the UDID for devices that support it

      Returns

      the UDID or null

    • getMsisdn

      public String getMsisdn()

      Returns the MSISDN for devices that expose it

      Returns

      the msisdn or null

    • getInAppPurchase

      public Purchase getInAppPurchase()

      Returns the native OS purchase implementation if applicable, if not this method will fallback to a cross platform purchase manager.

      Returns

      instance of the purchase class

    • getCodeScanner

      public CodeScanner getCodeScanner()

      Returns the native implementation of the code scanner or null

      Returns

      code scanner instance

      Deprecated

      Use cn1-codescan cn1lib instead.

    • toNativePath

      public String toNativePath(String path)

      Converts a FileSystemStorage path to a native path.

      Parameters
      • path: The file system storage path.
      Returns

      The native path.

    • getAppHomePath

      public String getAppHomePath()

      This will return the application home directory.

      Returns

      a writable directory that represent the application home directory

    • hasCachesDir

      public boolean hasCachesDir()

      Returns true if the device has a directory dedicated for "cache" files

      Returns

      true if a caches style directory exists in this device type

    • getCachesDir

      public String getCachesDir()

      Returns a device specific directory designed for cache style files, or null if #hasCachesDir() is false

      Returns

      file URL or null

    • isUseNativeCookieStore

      public boolean isUseNativeCookieStore()

      Uses the native cookie store if applicable, this might break simulator compatibility

      Returns

      the useNativeCookieStore

    • setUseNativeCookieStore

      public void setUseNativeCookieStore(boolean useNativeCookieStore)

      Uses the native cookie store if applicable, this might break simulator compatibility

      Parameters
      • useNativeCookieStore: the useNativeCookieStore to set
    • shouldPaintBackground

      public boolean shouldPaintBackground()

      Indicates the implementation is capable of keeping the background painted by being non-destructive.

      Returns

      whether to paint the background

    • getNativeTransition

      public Transition getNativeTransition(Transition t)

      This method allows a native implementation to implement a native version of a given transition that can be faster

      Parameters
      • t: the transition that is about to execute
      Returns

      the given transition or a native version of that transition

    • isScreenLockSupported

      public boolean isScreenLockSupported()
      Checks if the device supports locking the screen display from dimming, allowing the developer to keep the screen display on.
    • lockScreen

      public void lockScreen()
      If Locking isScreenLockSupported() returns true calling this method will lock the screen display on
    • unlockScreen

      public void unlockScreen()
      Unlock the screen display allowing the screen to dim.
    • hasCamera

      public boolean hasCamera()
      Returns true if the device has camera false otherwise.
    • getEDTThreadPriority

      public int getEDTThreadPriority()
      Returns the platform EDT thread priority
    • drawingEncodedImage

      public void drawingEncodedImage(EncodedImage img)

      This method is used by the JavaSE implementation for performance logging

      Parameters
      • img: the image being drawn
    • isNativePickerTypeSupported

      public boolean isNativePickerTypeSupported(int pickerType)

      Indicates whether the native picker dialog is supported for the given type which can include one of PICKER_TYPE_DATE_AND_TIME, PICKER_TYPE_TIME, PICKER_TYPE_DATE

      Parameters
      • pickerType: the picker type constant
      Returns

      true if the native platform supports this picker type

    • showNativePicker

      public Object showNativePicker(int type, Component source, Object currentValue, Object data)

      Shows a native modal dialog allowing us to perform the picking for the given type which can include one of PICKER_TYPE_DATE_AND_TIME, PICKER_TYPE_TIME, PICKER_TYPE_DATE

      Parameters
      • type: the picker type constant

      • source: @param source the source component (optional) the native dialog will be placed in relation to this component if applicable

      • currentValue: the currently selected value

      • data: additional meta data specific to the picker type when applicable

      Returns

      the value from the picker or null if the operation was canceled.

    • connectSocket

      public Object connectSocket(String host, int port)

      Creates a socket to connect to the given host on the given port

      Parameters
      • host: the host

      • port: the port

      Returns

      the socket object to use

    • connectSocket

      public Object connectSocket(String host, int port, int connectTimeout)

      Creates a socket to connect to the given host on the given port

      Parameters
      • host: the host

      • port: the port

      • connectTimeout: connect timeout. 0 for infinite timeout.

      Returns

      the socket object to use

      Since

      7.0

    • listenSocket

      public Object listenSocket(int port)

      Listens on the given port similar to the accept method of server socket in Java. This method will only work if isServerSocketAvailable() is true.

      Parameters
      • port: the port to listen on
      Returns

      server socket instance

    • getHostOrIP

      public String getHostOrIP()

      Returns the device host or ip address if available

      Returns

      device host or ip

    • disconnectSocket

      public void disconnectSocket(Object socket)

      Disconnects the current socket from the server/client on the other side

      Parameters
      • socket: the socket instance
    • isSocketConnected

      public boolean isSocketConnected(Object socket)

      Indicates whether the socket is currently connected

      Parameters
      • socket: is the socket we are connected to
      Returns

      true if the socket is connected

    • isServerSocketAvailable

      public boolean isServerSocketAvailable()

      Indicates whether the underlying implementation supports server sockets

      Returns

      false by default

    • isSocketAvailable

      public boolean isSocketAvailable()

      Indicates whether the underlying implementation supports sockets

      Returns

      false by default

    • getSocketErrorMessage

      public String getSocketErrorMessage(Object socket)

      Return the pending error message on the given socket

      Parameters
      • socket: the socket instance
      Returns

      the error message if available

    • getSocketErrorCode

      public int getSocketErrorCode(Object socket)

      Returns the pending error code on the given socket

      Parameters
      • socket: the socket instance
      Returns

      the error code

    • getSocketAvailableInput

      public int getSocketAvailableInput(Object socket)

      Returns whether data is available for input on the socket

      Parameters
      • socket: the socket instance
      Returns

      a none zero value if data is available for input

    • readFromSocketStream

      public byte[] readFromSocketStream(Object socket)

      Read pending bytes from the socket

      Parameters
      • socket: the socket object
      Returns

      byte array with data read from the socket

    • writeToSocketStream

      public void writeToSocketStream(Object socket, byte[] data)

      Write the following byte array to the socket

      Parameters
      • socket: the socket instance

      • data: the data written

    • installTar

      public void installTar() throws IOException
      Installs a tar file from the build server into the file system storage so it can be used with respect for hierarchy
      Throws:
      IOException
    • splitString

      public void splitString(String source, char separator, ArrayList<String> out)
    • isSimulator

      public boolean isSimulator()

      Allows detecting development mode so debugging code and special cases can be used to simplify flow

      Returns

      true if we are running in the simulator, false otherwise

    • paintComponentBackground

      public void paintComponentBackground(Object nativeGraphics, int x, int y, int width, int height, Style s)

      Paints the background of a component based on the style values on the given graphics context, the style could be accessed from the drawing thread in read only capacity to make the code slightly more efficient

      Parameters
      • nativeGraphics: the graphics context

      • x: coordinate to draw

      • y: coordinate to draw

      • width: coordinate to draw

      • height: coordinate to draw

      • s: the style object to draw

    • fillRect

      public void fillRect(Object nativeGraphics, int x, int y, int w, int h, byte alpha)

      Fills a rectangle with an optionally translucent fill color

      Parameters
      • nativeGraphics: the underlying native graphics object

      • x: the x coordinate of the rectangle to be filled

      • y: the y coordinate of the rectangle to be filled

      • w: the width of the rectangle to be filled

      • h: the height of the rectangle to be filled

      • alpha: the alpha values specify semitransparency

    • drawLabelComponent

      public void drawLabelComponent(Object nativeGraphics, int cmpX, int cmpY, int cmpHeight, int cmpWidth, Style style, String text, Object icon, Object stateIcon, int preserveSpaceForState, int gap, boolean rtl, boolean isOppositeSide, int textPosition, int stringWidth, boolean isTickerRunning, int tickerShiftText, boolean endsWith3Points, int valign)
      Draws a label on the given graphics context, this method allows optimizing the very common drawing operation using platform native code
    • drawLabelText

      protected int drawLabelText(Object nativeGraphics, int textDecoration, boolean rtl, boolean isTickerRunning, boolean endsWith3Points, Object nativeFont, int txtW, int textSpaceW, int shiftText, String text, int x, int y, int fontHeight)

      Draws the text of a label

      Parameters
      • nativeGraphics: graphics context

      • textDecoration: decoration information for the text

      • text: the text for the label

      • x: position for the label

      • y: position for the label

      • txtW: @param txtW stringWidth(text) equivalent which is faster than just invoking string width all the time

      • textSpaceW: the width available for the component

      Returns

      the space used by the drawing

    • drawString

      public void drawString(Object nativeGraphics, Object nativeFont, String str, int x, int y, int textDecoration)

      Draw a string using the current font and color in the x,y coordinates. The font is drawn from the top position and not the baseline.

      Parameters
      • nativeGraphics: the graphics context

      • nativeFont: the font used

      • str: the string to be drawn.

      • x: the x coordinate.

      • y: the y coordinate.

      • textDecoration: @param textDecoration Text decoration bitmask (See Style's TEXT_DECORATION_* constants)

    • setPlatformHint

      public void setPlatformHint(String key, String value)

      Makes it easier to pass hints to the underlying implementation for quicker hacks/pipelines

      Parameters
      • key: the key

      • value: the value

    • scheduleLocalNotification

      public void scheduleLocalNotification(LocalNotification notif, long firstTime, int repeat)
    • cancelLocalNotification

      public void cancelLocalNotification(String notificationId)
    • getPreferredBackgroundFetchInterval

      public int getPreferredBackgroundFetchInterval()

      Gets the preferred time (in seconds) between background fetches.

      Returns

      The time interval in seconds.

      See also
      • #isBackgroundFetchSupported()

      • #setPreferredBackgroundFetchInterval(int)

      • com.codename1.background.BackgroundFetch

      • com.codename1.ui.Display.setPreferredBackgroundFetchInterval(int)

    • setPreferredBackgroundFetchInterval

      public void setPreferredBackgroundFetchInterval(int seconds)

      Sets the preferred time interval between background fetches. This is only a preferred interval and is not guaranteed. Some platforms, like iOS, maintain sovereign control over when and if background fetches will be allowed. This number is used only as a guideline.

      This method must be called in order to activate background fetch.>

      Note: If the platform doesn't support background fetch (i.e. #isBackgroundFetchSupported() returns false, then this method does nothing.

      Parameters
      • seconds: The time interval in seconds.
      See also
      • #isBackgroundFetchSupported()

      • #getPreferredBackgroundFetchInterval()

      • com.codename1.background.BackgroundFetch

      • com.codename1.ui.Display.setPreferredBackgroundFetchInterval(int)

    • isBackgroundFetchSupported

      public boolean isBackgroundFetchSupported()

      Checks to see if the current platform supports background fetch.

      Returns

      True if the current platform supports background fetch.

      See also
      • #setPreferredBackgroundFetchInterval(int)

      • #getPreferredBackgroundFetchInterval()

      • com.codename1.background.BackgroundFetch

      • com.codename1.ui.Display.setPreferredBackgroundFetchInterval(int)

    • gaussianBlurImage

      public Image gaussianBlurImage(Image image, float radius)
    • isGaussianBlurSupported

      public boolean isGaussianBlurSupported()
    • isJailbrokenDevice

      public boolean isJailbrokenDevice()

      Returns true if this device is jailbroken or rooted, false if not or unknown. Notice that this method isn't accurate and can't detect all jailbreak/rooting cases

      Returns

      true if this device is jailbroken or rooted, false if not or unknown.

    • getProjectBuildHints

      public Map<String,String> getProjectBuildHints()

      Returns the build hints for the simulator, this will only work in the debug environment and it's designed to allow extensions/API's to verify user settings/build hints exist

      Returns

      map of the build hints that isn't modified without the codename1.arg. prefix

    • setProjectBuildHint

      public void setProjectBuildHint(String key, String value)

      Sets a build hint into the settings while overwriting any previous value. This will only work in the debug environment and it's designed to allow extensions/API's to verify user settings/build hints exist. Important: this will throw an exception outside of the simulator!

      Parameters
      • key: the build hint without the codename1.arg. prefix

      • value: the value for the hint

    • canInstallOnHomescreen

      public boolean canInstallOnHomescreen()

      Checks to see if you can prompt the user to install the app on their homescreen. This is only relevant for the Javascript port with PWAs. This is not a "static" property, as it only returns true if the app is in a state that allows you to prompt the user. E.g. if you have previously prompted the user and they have declined, then this will return false.

      Best practice is to use #onCanInstallOnHomescreen(java.lang.Runnable) to be notified when you are allowed to prompt the user for installation. Then call #promptInstallOnHomescreen() inside that method - or sometime after.

      Example

      `onCanInstallOnHomescreen(()->{
           if (canInstallOnHomescreen()) {
                if (promptInstallOnHomescreen()) {
                    // User accepted installation` else {
                    // user rejected installation
                }
           }
      });
      }
      

      https://developers.google.com/web/fundamentals/app-install-banners/

      Returns

      True if you are able to prompt the user to install the app on their homescreen.

      See also
      • #promptInstallOnHomescreen()

      • #onCanInstallOnHomescreen(java.lang.Runnable)

    • promptInstallOnHomescreen

      public boolean promptInstallOnHomescreen()

      Prompts the user to install this app on their homescreen. This is only relevant in the javascript port.

      Returns
      Returns:

      The result of the user prompt. true if the user accepts the installation, false if they reject it.

      See also
      • #canInstallOnHomescreen()

      • #onCanInstallOnHomescreen(java.lang.Runnable)

    • onCanInstallOnHomescreen

      public void onCanInstallOnHomescreen(Runnable r)

      A callback fired when you are allowed to prompt the user to install the app on their homescreen. Only relevant in the javascript port.

      Parameters
      • r: @param r Runnable that will be run when/if you are permitted to prompt the user to install the app on their homescreen.
    • supportsNativeTextAreaVerticalAlignment

      public boolean supportsNativeTextAreaVerticalAlignment()
      Checks whether the platform's native text areas support vertical alignment.
    • postMessage

      public void postMessage(MessageEvent message)

      Posts a message to the native platform.

      Parameters
      • message: The message.
      Since

      7.0

    • isDarkMode

      public Boolean isDarkMode()

      Returns true if the platform is in dark mode, null is returned for unknown status

      Returns

      true in case of dark mode

    • announceForAccessibility

      public void announceForAccessibility(Component cmp, String text)

      Manually announces text to native accessibility services, associating the announcement with a specific component when possible. Components are typically announced automatically when focused; this hook allows platforms to expose announcements triggered outside the normal focus lifecycle. The default implementation is a no-op.

      Parameters
      • cmp: the component related to this announcement or null for the root context

      • text: the message to announce

    • isLargerTextEnabled

      public boolean isLargerTextEnabled()

      Returns true if the user has selected larger type fonts in the system settings. Default implementation returns false.

      Returns

      true when the platform indicates a larger text preference.

      Since

      7.1

    • getLargerTextScale

      public float getLargerTextScale()

      Returns a scale factor representing how much larger system fonts should be. A value of 1.0 indicates the default system font size.

      Returns

      scale factor for larger system fonts.

      Since

      7.1

    • getStackTrace

      public String getStackTrace(Thread parentThread, Throwable t)

      Returns the stack trace from the exception on the given thread. This API isn't supported on all platforms and may return a blank string when unavailable.

      Parameters
      • parentThread: the thread in which the exception was thrown

      • t: the exception

      Returns

      a stack trace string that might be blank