SingleMimeTypeClipDataHelper

public class SingleMimeTypeClipDataHelper extends Object
implements BlockClipDataHelper

Implements ClipDataTransformer with a single supported MIME type. Uses intent extras as the in-transit storage format.

Constant Summary

String EXTRA_BLOCKLY_XML

Field Summary

protected final String mClipLabel
protected final String mMimeType

Public Constructor Summary

SingleMimeTypeClipDataHelper(String mimeType, String clipLabel)
Constructs a new SingleMimeTypeClipDataHelper with the provided MIME string and user visible (accessibility, etc.) clip label string.

Public Method Summary

ClipData
buildDragClipData(PendingDrag drag)
Constructs a new populated ClipData using the information from a PendingDrag.
static BlockClipDataHelper
getDefault(Context context)
This constructs a SingleMimeTypeClipDataHelper with a MIME type derived from the application's package name.
PendingDrag
getPendingDrag(DragEvent event)
Extracts a PendingDrag from a DragEvent.
boolean
isBlockData(ClipDescription descript)
This determines whether an incoming ClipData is a representation of Blockly Blocks that can be handled by this BlockClipDataHelper.

Inherited Method Summary

Constants

public static final String EXTRA_BLOCKLY_XML

Constant Value: "BLOCKLY_XML"

Fields

protected final String mClipLabel

protected final String mMimeType

Public Constructors

public SingleMimeTypeClipDataHelper (String mimeType, String clipLabel)

Constructs a new SingleMimeTypeClipDataHelper with the provided MIME string and user visible (accessibility, etc.) clip label string.

Parameters
mimeType The MIME type the new instance use for encoding and decoding.
clipLabel The human readable label to apply to ClipDatas.

Public Methods

public ClipData buildDragClipData (PendingDrag drag)

Constructs a new populated ClipData using the information from a PendingDrag.

Parameters
drag The source of clip
Returns
Throws
IOException

public static BlockClipDataHelper getDefault (Context context)

This constructs a SingleMimeTypeClipDataHelper with a MIME type derived from the application's package name. This assumes all Blockly workspaces in an app use with a shared set of blocks, and blocks can be dragged/copied/pasted them, even if they are in different Activities. It also ensures blocks from other applications will be rejected.

public PendingDrag getPendingDrag (DragEvent event)

Extracts a PendingDrag from a DragEvent. Assumes that isBlockData(ClipDescription) has been called and returned ERROR(/true).

Parameters
event The DragEvent containing the PendingDrag.
Returns
  • The PendingDrag containing the dragged blocks.

public boolean isBlockData (ClipDescription descript)

This determines whether an incoming ClipData is a representation of Blockly Blocks that can be handled by this BlockClipDataHelper.

Parameters
descript A description of the incoming clipboard data.
Returns
  • True if the MIME type is found.