Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.

public class PaywallView

  1. Object
  2. Component
  3. Container
  4. PaywallView

ImplementsAnimation, Editable, Iterable<Component>, StyleListener

A paywall built from a paywall document and the offering it sells.

The document is a tree of nodes, each a JSON object with a type: stack, text, image, icon, features, packages, purchaseButton, restoreButton, closeButton, carousel, footer and spacer. A node of any other type is skipped, so a document made for a newer client still shows. Sizes in the document are millimetres.

A text is first looked up in the document’s strings, by the device’s locale and then the document’s default locale, and used as written when it is not a key there. Then {{price}}, {{period}}, {{trialPeriod}}, {{introPrice}}, {{productName}} and {{packageId}} are replaced from the selected package, again whenever the selection changes. The price is the store’s localized one when the store listed the product.

Styling

Every element has a UIID, so a theme can restyle the paywall. The colors the document names – its dark set when the device is in dark mode, its light set otherwise – are applied on top of the theme.

  • Paywall: the view itself
  • PaywallStack: a stack node
  • PaywallTitle, PaywallHeadline, PaywallBody, PaywallCaption: the text of a text node, by its style
  • PaywallImage, PaywallIcon: an image and an icon node
  • PaywallFeatures, PaywallFeature, PaywallFeatureIcon, PaywallFeatureText: a features node, one of its rows and the row’s parts
  • PaywallPackages: a packages node
  • PaywallPackage, PaywallPackageTitle, PaywallPackagePrice: a package and its two lines
  • PaywallPackageSelected, PaywallPackageTitleSelected, PaywallPackagePriceSelected: the same for the selected package
  • PaywallPurchaseButton, PaywallRestoreButton, PaywallCloseButton
  • PaywallCloseBar: the row holding the close button
  • PaywallCarousel: a carousel node
  • PaywallFooter, PaywallFooterLink: a footer node and its links
  • PaywallSpacer: a spacer node, and the gap between a stack’s children

Events

The view reports IMPRESSION when it is first shown, PURCHASE_START, PURCHASE and CLOSE through CommerceManager.logEvent(String, String, String, String).

Constructors

public PaywallView(Offering offering)Builds the paywall of an offering from the offering’s own document, or from the built-in one when it has none.
public PaywallView(Offering offering, Map paywallDocument)Builds a paywall from a document.

Methods

public void setPaywallListener(PaywallListener listener)Sets the listener that is told what happens on this paywall.
public Offering getOffering()The offering this paywall sells.
public String getPaywallId()The id of the paywall document, or null when it has none.
public CommercePackage getSelectedPackage()The package that is selected, which the purchase button buys.
public void selectPackage(String packageId)Selects a package, as tapping it does.
public void purchase()Buys the selected package, as the purchase button does.
public void restore()Restores the purchases of the store account, as the restore button does.
public void close()Closes the paywall, as the close button does.
public void setCloseHandler(Runnable closeHandler)Sets what closing the paywall does to the screen, after the listener was told.
protected void initComponent()Allows subclasses to bind functionality that relies on fully initialized and “ready for action” component state

Inherited fields

Inherited methods

From Container

encloseIn, encloseIn, initLaf, getUIManager, setUIManager, isSurface, add, addAll, add, add, add, add, add, getLeadComponent, setLeadComponent, getLeadParent, keyPressed, keyReleased, getLayout, setLayout, invalidate, setShouldLayout, setShouldCalcPreferredSize, getLayoutWidth, getLayoutHeight, applyRTL, constrainWidthWhenScrollable, constrainHeightWhenScrollable, addComponent, addComponent, addComponent, addComponent, replaceAndWait, replaceAndWait, replace, replaceAndWait, replace, createReplaceTransition, isEnabled, setEnabled, removeComponent, cancelRepaints, flushReplace, removeAll, revalidateWithAnimationSafety, revalidate, revalidateLater, forceRevalidate, clearClientProperties, paint, paintGlass, layoutContainer, isSafeArea, setSafeArea, isSafeAreaRoot, getSafeAreaRoot, setSafeAreaRoot, getComponentCount, getComponentAt, getComponentIndex, contains, scrollComponentToVisible, getClosestComponentTo, getResponderAt, getComponentAt, findDropTargetAt, pointerPressed, calcPreferredSize, paramString, refreshTheme, isScrollableX, setScrollableX, isScrollableY, setScrollableY, getSideGap, getBottomGap, setScrollable, setCellRenderer, getScrollIncrement, setScrollIncrement, findFirstFocusable, dragInitiated, fireClicked, isSelectableInteraction, getGridPosY, paintComponentBackground, getGridPosX, animateHierarchyAndWait, createAnimateHierarchy, animateHierarchy, animateHierarchyFadeAndWait, createAnimateHierarchyFade, animateHierarchyFade, animateLayoutFadeAndWait, createAnimateLayoutFadeAndWait, animateLayoutFade, createAnimateLayoutFade, animateLayoutAndWait, animateLayout, updateTabIndices, createAnimateLayout, drop, createAnimateMotion, morph, morphAndWait, animateUnlayout, animateUnlayoutAndWait, createAnimateUnlayout, getChildrenAsList, iterator, iterator

From Component

setSameSize, isSetCursorSupported, parsePreferredSize, getDefaultDragTransparency, setDefaultDragTransparency, getEditingDelegate, setEditingDelegate, getCursor, setCursor, showNativeOverlay, hideNativeOverlay, updateNativeOverlay, getNativeOverlay, getAllStyles, getSameWidth, setSameWidth, getSameHeight, setSameHeight, getX, setX, getOuterX, getInnerX, getY, setY, getOuterY, getInnerY, isVisible, setVisible, getClientProperty, stripMarginAndPadding, putClientProperty, getDirtyRegion, setDirtyRegion, isOpaque, setOpaque, getWidth, setWidth, getOuterWidth, getInnerWidth, getHeight, setHeight, getOuterHeight, getInnerHeight, isDragRegion, getDragRegionStatus, getBaseline, getBaselineResizeBehavior, getPreferredSizeStr, setPreferredSizeStr, getPreferredSize, setPreferredSize, getScrollDimension, calcScrollSize, setScrollSize, getPreferredW, setPreferredW, getPreferredH, setPreferredH, getOuterPreferredH, getInnerPreferredH, getOuterPreferredW, getInnerPreferredW, setSize, getUIID, setUIID, setUIIDFinal, setUIID, getInlineAllStyles, setInlineAllStyles, getInlineSelectedStyles, setInlineSelectedStyles, getInlineUnselectedStyles, setInlineUnselectedStyles, getInlineDisabledStyles, setInlineDisabledStyles, getInlinePressedStyles, setInlinePressedStyles, remove, getParent, getOwner, setOwner, isOwnedBy, containsOrOwns, addFocusListener, removeFocusListener, addScrollListener, removeScrollListener, getSelectCommandText, setSelectCommandText, getLabelForComponent, setLabelForComponent, focusGained, focusLost, paintBackgrounds, paintShadows, getAbsoluteX, getAbsoluteY, isInClippingRegion, paintIntersectingComponentsAbove, paintScrollbars, paintScrollbarX, getScrollOpacity, getSelectedRect, paintScrollbarY, paintComponent, paintComponent, getBorder, getScrollable, paintBackground, isScrollable, getScrollX, setScrollX, getScrollY, setScrollY, onScrollX, onScrollY, getDraggedx, getDraggedy, contains, visibleBoundsContains, hasFixedPreferredSize, getBounds, getBounds, getVisibleBounds, getVisibleBounds, isFocusable, setFocusable, onSetFocusable, resetFocusable, getTabIndex, setTabIndex, getPreferredTabIndex, setPreferredTabIndex, isTraversable, setTraversable, handlesInput, setHandlesInput, consumesRawTextInput, hasFocus, setFocus, getComponentForm, getTopLevelContainer, repaint, repaint, longKeyPress, keyRepeated, registerForAnimation, deregisterFromAnimation, getAnimationManager, getScrollAnimationSpeed, setScrollAnimationSpeed, isBlockLead, setBlockLead, isIgnorePointerEvents, setIgnorePointerEvents, isRippleEffect, setRippleEffect, getInlineStylesTheme, setInlineStylesTheme, shouldRenderComponentSelection, isHideInLandscape, setHideInLandscape, createStyleAnimation, isSmoothScrolling, setSmoothScrolling, pointerHover, stopScrollMomentum, pointerHoverReleased, pointerHoverPressed, pinch, pinchReleased, pinch, rotation, isPinchBlocksDragAndDrop, setPinchBlocksDragAndDrop, pointerDragged, getDragImage, getDragTransparency, setDragTransparency, toImage, drawDraggedImage, draggingOver, dragEnter, dragExit, addPullToRefresh, setPullToRefresh, respondsToPointerEvents, pointerDragged, isStickyDrag, pointerPressed, isDragAndDropOperation, pointerReleased, longPointerPress, pointerReleased, setVerticalScrollBounds, setHorizontalScrollBounds, isVScrollThumbGrabbed, isHScrollThumbGrabbed, isVScrollThumbHover, isHScrollThumbHover, isTensileDragEnabled, setTensileDragEnabled, getTextSelectionSupport, addDropListener, removeDropListener, addDragOverListener, removeDragOverListener, isNativeDragSource, setNativeDragSource, getNativeDragOperation, setNativeDragOperation, createNativeDragOperation, isNativeDropTarget, setNativeDropTarget, getAcceptedDropMimeTypes, setAcceptedDropMimeTypes, getAcceptedDropActions, setAcceptedDropActions, canAcceptNativeDrop, nativeDragEnter, nativeDragOver, nativeDragExit, nativeDrop, addNativeDropListener, removeNativeDropListener, addNativeDragOverListener, removeNativeDragOverListener, dragFinished, addDragFinishedListener, addStateChangeListener, removeStateChangeListener, addPointerPressedListener, addLongPressListener, addContextMenuListener, removeContextMenuListener, addMouseWheelListener, removeMouseWheelListener, addStylusListener, removeStylusListener, getContextMenuCommands, setContextMenuCommands, mouseWheel, paintRippleOverlay, removePointerPressedListener, removeLongPressListener, removeDragFinishedListener, addPointerReleasedListener, removePointerReleasedListener, addPointerDraggedListener, removePointerDraggedListener, getDragSpeed, getStyle, getPressedStyle, getHoverStyle, setHoverStyle, isHovered, setHovered, setPressedStyle, initUnselectedStyle, initPressedStyle, initDisabledStyle, initSelectedStyle, getUnselectedStyle, setUnselectedStyle, getSelectedStyle, setSelectedStyle, getDisabledStyle, setDisabledStyle, installDefaultPainter, requestFocus, toString, refreshTheme, refreshTheme, isDragActivated, animate, scrollRectToVisible, scrollRectToVisible, paintBorder, paintBorderBackground, isCellRenderer, isScrollVisible, setScrollVisible, setIsScrollVisible, startEditingAsync, stopEditing, isEditing, isEditable, laidOut, deinitialize, isInitialized, setInitialized, styleChanged, getNextFocusDown, setNextFocusDown, getNextFocusUp, setNextFocusUp, getNextFocusLeft, setNextFocusLeft, getNextFocusRight, setNextFocusRight, getName, setName, initCustomStyle, deinitializeCustomStyle, isRTL, setRTL, isTactileTouch, isTactileTouch, setTactileTouch, getPropertyNames, getPropertyTypes, getPropertyTypeNames, getPropertyValue, setPropertyValue, paintLockRelease, paintLock, isSnapToGrid, setSnapToGrid, shouldBlockSideSwipe, shouldBlockSideSwipeLeft, shouldBlockSideSwipeRight, blocksSideSwipe, isFlatten, setFlatten, getTensileLength, setTensileLength, isGrabsPointerEvents, setGrabsPointerEvents, getScrollOpacityChangeSpeed, setScrollOpacityChangeSpeed, growShrink, isAlwaysTensile, setAlwaysTensile, isDraggable, setDraggable, isDropTarget, setDropTarget, isChildOf, isHideInPortrait, setHideInPortrait, getBindablePropertyNames, getBindablePropertyTypes, bindProperty, unbindProperty, getBoundPropertyValue, setBoundPropertyValue, getCloudBoundProperty, setCloudBoundProperty, getCloudDestinationProperty, setCloudDestinationProperty, getComponentState, setComponentState, setHidden, isHidden, setHidden, isHidden, announceForAccessibility, getAccessibilityText, setAccessibilityText, getSemantics, getAccessibilityNode, accessibilityChanged, accessibilityChanged, getTooltip, setTooltip

Constructor details

PaywallView

public PaywallView(Offering offering)
Builds the paywall of an offering from the offering’s own document, or from the built-in one when it has none.

Parameters

offering Offering
the offering to sell

PaywallView

public PaywallView(Offering offering, Map paywallDocument)
Builds a paywall from a document.

Parameters

offering Offering
the offering to sell
paywallDocument Map
the parsed paywall document; null uses the built-in one

Method details

setPaywallListener

public void setPaywallListener(PaywallListener listener)
Sets the listener that is told what happens on this paywall.

Parameters

listener PaywallListener
the listener, or null for none

getOffering

public Offering getOffering()
The offering this paywall sells.

getPaywallId

public String getPaywallId()
The id of the paywall document, or null when it has none.

getSelectedPackage

public CommercePackage getSelectedPackage()
The package that is selected, which the purchase button buys.

Returns

the package, or null when the offering has no package

selectPackage

public void selectPackage(String packageId)
Selects a package, as tapping it does.

Parameters

packageId String
the id of a package of the offering; any other value is ignored

purchase

public void purchase()
Buys the selected package, as the purchase button does. The listener hears purchaseStarted now and purchaseCompleted once the cloud reports the customer as owning the product.

restore

public void restore()
Restores the purchases of the store account, as the restore button does. The listener hears restoreCompleted when the customer information changes afterwards.

close

public void close()
Closes the paywall, as the close button does. A purchase that was started and not confirmed yet is reported as cancelled.

setCloseHandler

public void setCloseHandler(Runnable closeHandler)
Sets what closing the paywall does to the screen, after the listener was told. Paywall.show(Offering, PaywallListener) sets it to return to the previous form; an application that embeds the view in a form of its own sets it to whatever removes the view.

Parameters

closeHandler Runnable
run on the EDT when the paywall closes, or null

initComponent

protected void initComponent()
Allows subclasses to bind functionality that relies on fully initialized and “ready for action” component state