public class

AttachmentFormCell

extends LinearLayout
implements FormCell<T> SupportsKey
java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.widget.LinearLayout
         ↳ com.sap.cloud.mobile.fiori.attachment.AttachmentFormCell

Class Overview

A custom control having a linear layout of TextView and RecyclerView.Recycler for selecting and demonstrating attachments. By default Recycler view with LinearLayoutManager with vertical orientation will be used will be used.

Structure of the control is:

  • TextView : showing the text to be displayed for label of the control. See also: setKey(CharSequence)
  • Recycler View : Developer using the AttachmentFormCell needs to provide the selected attachment to the AttachmentFormCell by either making a call to onReceiveSelection(int, int, Intent, Context) from onReceiveSelection(int,int, Intent) method of the activity containing the attachment form cell or by calling setValue(List) method on attachment form cell.
     <Providing the selection results to attachment form cell
    
     protected void onActivityResult(int requestCode, int resultCode, Intent data) {
       super.onActivityResult(requestCode, resultCode, data);
       mAttachmentFormCell.onReceiveSelection(requestCode, resultCode, data);
     }
     
  • Summary

    Nested Classes
    class AttachmentFormCell.AttachmentBroadcastReceiver  
    XML Attributes
    Attribute Name Related Method Description
    AttachmentFormCell_addButtonStyle setAddButtonTextAppearance(int)  
    AttachmentFormCell_addButtonText setAddButtonText(int)  
    AttachmentFormCell_attachmentDetailAppearance  
    AttachmentFormCell_attachmentDetailEditAppearance  
    AttachmentFormCell_key setGridLayoutSpanCount(int)  
    AttachmentFormCell_keyTextAppearance setKeyNameAppearance(int)  
    AttachmentFormCell_removeAttachmentIcon  
    AttachmentFormCell_showGridIcon setShowListIcon(int)  
    AttachmentFormCell_showListIcon  
    AttachmentFormCell_spanCount  
    Constants
    String ATTACHMENT_ITEMS_SELECTED Action name for which the formcell has registered the broad cast receiver.
    [Expand]
    Inherited Constants
    From class android.widget.LinearLayout
    From class android.view.ViewGroup
    From class android.view.View
    Fields
    public static short REQUEST_CODE Request code to be used when the permissions are requested or selection activity is triggered.
    [Expand]
    Inherited Fields
    From class android.view.View
    Public Constructors
    AttachmentFormCell(Activity activity)
    Construct a new AttachmentFormCell with default styling, overriding the attributes for the control as requested, sets the CellType to WidgetType .ATTACHMENT
    AttachmentFormCell(Context context, AttributeSet attrs)
    Construct a new AttachmentFormCell with default styling, overriding the attributes for the control as requested, sets the CellType to WidgetType.ATTACHMENT
    Public Methods
    void addAttachmentActions(List<AttachmentAction> actionList)
    Add all the attachment menu options
    void addAttachmentTouchListener(AttachmentItemClickListener listener)
    Override the behavior of Touch events on the Attachments
    void addValue(List<Attachment> value)
    Sets the list of selected items in the Attachment
    void clear()
    Drop all the attachments from the cell without invoking the listeners.
    void clearAttachmentActions()
    List<AttachmentAction> getAttachmentActions()
    Get the attachment actions
    List<AttachmentItemClickListener> getAttachmentItemClickListeners()
    int getCellType()
    Return the enum value for AttachmentFormCell
    CellValueChangeListener<List<Attachment>> getCellValueChangeListener()
    Return the value change handler of the control
    CharSequence getKey()
    Return the label of the property of control
    short getRequestCode()
    int getSeparatorPosition()
    Get the position of the separator in the attachment action bottom sheet
    int getSpanCount()
    Set the span count if the layout manager is GridLayout.
    List<Attachment> getValue()
    Returns the index list of selected items in the Attachment
    boolean isEditable()
    Returns if the control is enabled or not to modify values.
    static void onReceiveSelection(int requestCode, int resultCode, Intent data, Context context)
    Check if the data is correctly received by the activity and setValue the data to AttachmentFormCell
    static void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults, Context context)
    Handle the result from requesting permissions.
    void removeAttachmentTouchListener(AttachmentItemClickListener listener)
    Remove the AttachmentTouchListener
    void selectAttachments(Intent intent)
    Start attaching the code
    void setAddButtonText(String text)
    Set the text of the add button shown in edit mode
    void setAddButtonText(int text)
    Set the text of the add button shown in edit mode
    void setAddButtonTextAppearance(int resId)
    Set the text Appearance on the Add button shown in edit mode.
    void setAttachmentDetailedAppearance(int resId)
    Set the text appearance style resource for the attachment detail text view
    void setAttachmentDetailedEditAppearance(int resId)
    Set the text appearance style resource for the attachment detail text view
    void setAttachmentIconDecoration(RecyclerView.ItemDecoration decoration)
    Set the ItemDecorator for attachment item.
    void setAttachmentRemoveIconDrawable(int resId)
    Set the drawable image for the remove button
    void setCellValueChangeListener(CellValueChangeListener<List<Attachment>> listener)
    void setEditable(boolean isEditable)
    Set if the control is enabled or not to modify value of the control.
    void setGridLayoutSpanCount(int spanCount)
    Set the attachmentSpanCount on the GridLayoutManger.
    void setKey(CharSequence keyName)
    Set the label for property of the control
    void setKeyNameAppearance(int resId)
    Set the text appearance style resource for the attachment form cell label text
    void setKeyTextAppearance(int resId)
    void setOpenAttachmentOnTouch(boolean openAttachmentOnTouch)
    Open the attached files on touch.
    void setRequestCode(short requestCode)
    void setSeparatorPosition(int separatorPosition)
    Set the position of the separator in attachment action bottom sheet
    void setShowGridIcon(int res)
    Set the Show to grid icon, icon is displayed when attachments are shown in list view
    void setShowListIcon(int res)
    Set the Show to list icon, icon is displayed when attachments are shown in grid view
    void setValue(List<Attachment> value)
    Sets the list of selected items in the Attachment
    void setValue(Intent data)
    Set the received intent from onActivityResult(int, int, Intent)
    Protected Methods
    void onRestoreInstanceState(Parcelable state)
    Hook allowing a view to re-apply a representation of its internal state that had previously been generated by onSaveInstanceState().
    Parcelable onSaveInstanceState()
    Hook allowing a view to generate a representation of its internal state that can later be used to create a new instance with that same state.
    [Expand]
    Inherited Methods
    From class android.widget.LinearLayout
    From class android.view.ViewGroup
    From class android.view.View
    From class java.lang.Object
    From interface android.graphics.drawable.Drawable.Callback
    From interface android.view.KeyEvent.Callback
    From interface android.view.ViewManager
    From interface android.view.ViewParent
    From interface android.view.accessibility.AccessibilityEventSource
    From interface com.sap.cloud.mobile.fiori.formcell.FormCell
    From interface com.sap.cloud.mobile.fiori.formcell.SupportsKey

    XML Attributes

    AttachmentFormCell_addButtonStyle

    AttachmentFormCell_addButtonText

    Related Methods

    AttachmentFormCell_attachmentDetailAppearance

    Related Methods

    AttachmentFormCell_attachmentDetailEditAppearance

    Related Methods

    AttachmentFormCell_key

    Related Methods

    AttachmentFormCell_keyTextAppearance

    Related Methods

    AttachmentFormCell_removeAttachmentIcon

    Related Methods

    AttachmentFormCell_showGridIcon

    Related Methods

    AttachmentFormCell_showListIcon

    Related Methods

    AttachmentFormCell_spanCount

    Related Methods

    Constants

    public static final String ATTACHMENT_ITEMS_SELECTED

    Action name for which the formcell has registered the broad cast receiver.

    Constant Value: "fiori.attachments.items_selected"

    Fields

    public static short REQUEST_CODE

    Request code to be used when the permissions are requested or selection activity is triggered. Activity containing the Attachment FormCell will receive this request code in onActivityResult callbacks.

    Public Constructors

    public AttachmentFormCell (Activity activity)

    Construct a new AttachmentFormCell with default styling, overriding the attributes for the control as requested, sets the CellType to WidgetType .ATTACHMENT

    Parameters
    activity Activity

    public AttachmentFormCell (Context context, AttributeSet attrs)

    Construct a new AttachmentFormCell with default styling, overriding the attributes for the control as requested, sets the CellType to WidgetType.ATTACHMENT

    Parameters
    context context
    attrs attribute set

    Public Methods

    public void addAttachmentActions (List<AttachmentAction> actionList)

    Add all the attachment menu options

    Parameters
    actionList List of AttachmentActions

    public void addAttachmentTouchListener (AttachmentItemClickListener listener)

    Override the behavior of Touch events on the Attachments

    Parameters
    listener AttachmentTouchListener

    public void addValue (List<Attachment> value)

    Sets the list of selected items in the Attachment

    Parameters
    value array of ChosenFile

    public void clear ()

    Drop all the attachments from the cell without invoking the listeners.

    public void clearAttachmentActions ()

    public List<AttachmentAction> getAttachmentActions ()

    Get the attachment actions

    Returns

    public List<AttachmentItemClickListener> getAttachmentItemClickListeners ()

    public int getCellType ()

    Return the enum value for AttachmentFormCell

    Returns
    • WidgetType type of the control which has implemented FormCell

    public CellValueChangeListener<List<Attachment>> getCellValueChangeListener ()

    Return the value change handler of the control

    Returns
    • OnCellChangeListener - value change listener of the control

    public CharSequence getKey ()

    Return the label of the property of control

    Returns
    • CharSequence keyName

    public short getRequestCode ()

    public int getSeparatorPosition ()

    Get the position of the separator in the attachment action bottom sheet

    Returns
    • int

    public int getSpanCount ()

    Set the span count if the layout manager is GridLayout.

    Returns
    • int

    public List<Attachment> getValue ()

    Returns the index list of selected items in the Attachment

    Returns
    • List of selected items

    public boolean isEditable ()

    Returns if the control is enabled or not to modify values.

    Returns
    • Boolean user is allowed to modify the value of the control

    public static void onReceiveSelection (int requestCode, int resultCode, Intent data, Context context)

    Check if the data is correctly received by the activity and setValue the data to AttachmentFormCell

    Parameters
    resultCode int
    data Intent

    public static void onRequestPermissionsResult (int requestCode, String[] permissions, int[] grantResults, Context context)

    Handle the result from requesting permissions. This method should be invoked for every call on requestPermissions(String[], int).

    Parameters
    requestCode The request code received in requestPermissions(String[], int).
    permissions The requested permissions. Never null.
    grantResults The grant results for the corresponding permissions which is either PERMISSION_GRANTED or PERMISSION_DENIED. Never null.

    public void removeAttachmentTouchListener (AttachmentItemClickListener listener)

    Remove the AttachmentTouchListener

    Parameters
    listener AttachmentTouchListener

    public void selectAttachments (Intent intent)

    Start attaching the code

    Parameters
    intent Intent

    public void setAddButtonText (String text)

    Set the text of the add button shown in edit mode

    Related XML Attributes
    Parameters
    text String

    public void setAddButtonText (int text)

    Set the text of the add button shown in edit mode

    Related XML Attributes
    Parameters
    text int

    public void setAddButtonTextAppearance (int resId)

    Set the text Appearance on the Add button shown in edit mode.

    Related XML Attributes

    public void setAttachmentDetailedAppearance (int resId)

    Set the text appearance style resource for the attachment detail text view

    Parameters
    resId int

    public void setAttachmentDetailedEditAppearance (int resId)

    Set the text appearance style resource for the attachment detail text view

    Parameters
    resId int

    public void setAttachmentIconDecoration (RecyclerView.ItemDecoration decoration)

    Set the ItemDecorator for attachment item. Attachment form cell uses Size of thumbnail along with vertical and horizontal spacing between elements for correctly measuring the span count.

    Parameters
    decoration ItemDecorator

    public void setAttachmentRemoveIconDrawable (int resId)

    Set the drawable image for the remove button

    Parameters
    resId Drawable resource id

    public void setCellValueChangeListener (CellValueChangeListener<List<Attachment>> listener)

    public void setEditable (boolean isEditable)

    Set if the control is enabled or not to modify value of the control. In readOnly mode, however, the text labels and text values will be selectable. By default, the control will be editable( user can modify value of the control)

    Parameters
    isEditable Boolean

    public void setGridLayoutSpanCount (int spanCount)

    Set the attachmentSpanCount on the GridLayoutManger.

    Overriding the span count will provide no guarantee about layout of the attachment. See setSpanCount(int) for details. Calling setGridLayoutSpanCount(int) with negative values resets the span count calculations to automatic.

    This api has been marked deprecated for avoiding inconsistency. AttachmentFormCell will automatically calculate the span count. This API will have no effects.

    Related XML Attributes
    Parameters
    spanCount int

    public void setKey (CharSequence keyName)

    Set the label for property of the control

    Parameters
    keyName label of the property

    public void setKeyNameAppearance (int resId)

    Set the text appearance style resource for the attachment form cell label text

    Related XML Attributes
    Parameters
    resId int

    public void setKeyTextAppearance (int resId)

    public void setOpenAttachmentOnTouch (boolean openAttachmentOnTouch)

    Open the attached files on touch. By default this is true

    Parameters
    openAttachmentOnTouch true: automatically opens the attachments on touch false: application needs to override the touch behavior (@see #addAttachmentTouchListener(AttachmentItemClickListener)

    public void setRequestCode (short requestCode)

    public void setSeparatorPosition (int separatorPosition)

    Set the position of the separator in attachment action bottom sheet

    Parameters
    separatorPosition int

    public void setShowGridIcon (int res)

    Set the Show to grid icon, icon is displayed when attachments are shown in list view

    Related XML Attributes
    Parameters
    res Drawable

    public void setShowListIcon (int res)

    Set the Show to list icon, icon is displayed when attachments are shown in grid view

    Related XML Attributes
    Parameters
    res drawable resource

    public void setValue (List<Attachment> value)

    Sets the list of selected items in the Attachment

    Parameters
    value array of ChosenFile

    public void setValue (Intent data)

    Set the received intent from onActivityResult(int, int, Intent)

    Parameters
    data Intent

    Protected Methods

    protected void onRestoreInstanceState (Parcelable state)

    Hook allowing a view to re-apply a representation of its internal state that had previously been generated by onSaveInstanceState(). This function will never be called with a null state.

    Parameters
    state The frozen state that had previously been returned by onSaveInstanceState().

    protected Parcelable onSaveInstanceState ()

    Hook allowing a view to generate a representation of its internal state that can later be used to create a new instance with that same state. This state should only contain information that is not persistent or can not be reconstructed later. For example, you will never store your current position on screen because that will be computed again when a new instance of the view is placed in its view hierarchy.

    Some examples of things you may store here: the current cursor position in a text view (but usually not the text itself since that is stored in a content provider or other persistent storage), the currently selected item in a list view.

    Returns
    • Returns a Parcelable object containing the view's current dynamic state, or null if there is nothing interesting to save.