public class

ObjectHeader

extends ObjectCell
java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ com.sap.cloud.mobile.fiori.object.AbstractEntityCell
         ↳ com.sap.cloud.mobile.fiori.object.ObjectCell
           ↳ com.sap.cloud.mobile.fiori.object.ObjectHeader

Class Overview

The object header provides a quick view of the most important or most frequently-used information about one instance of an object. It is visually separated from the content area below. As the object header provides the first glimpse of the object on the screen, the information it contains should be clear and concise.

Structure

The object header is comprised of several pieces of information about the object:

Sample XML:


 <com.sap.cloud.mobile.fiori.object.ObjectHeader
      android:id="@+id/objectHeader"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_marginTop="0dp"
      android:paddingBottom="@dimen/md_keylines"
      android:paddingTop="@dimen/md_keylines"
      android:scrollbars="vertical"
      app:body="@string/object_header_body"
      app:description="@string/object_header_description"
      app:detailImage="@drawable/ic_android_black_24dp"
      app:footnote="@string/object_header_footnote"
      app:headline="@string/object_header_headline"
      app:subheadline="@string/object_header_subheadline"
      tools:layout_editor_absoluteY="8dp">

  <com.sap.cloud.mobile.fiori.common.TextChip
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="@string/object_header_tag1"
      app:layout_header_group="TAG" />

  <com.sap.cloud.mobile.fiori.common.TextChip
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="@string/object_header_tag2"
      app:layout_header_group="TAG" />

  <ImageView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:src="@drawable/ic_error_black_24dp"
      android:tint="@color/red"
      android:contentDescription="@string/error"
      app:layout_header_group="STATUS" />

  <TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="@string/object_header_status"
      android:textColor="@color/grey_300"
      app:layout_header_group="STATUS" />

  <include layout="@layout/temperature_analytics" />

 </com.sap.cloud.mobile.fiori.object.ObjectHeader>
 
Limitation: The above child xml views cannot be used together with data binding, because the ObjectHeader uses ViewPager2 on phone or tablet portrait mode to layout child views, which in turn uses a RecyclerView to manage pages. RecyclerView does not add child views until it is laid out. While the data binding library tries to access the TextView right after ObjectHeader is constructed, which hasn't been laid out yet, therefore NullPointerException is thrown.

Summary

Nested Classes
class ObjectHeader.KpiItemView A smaller Kpi view intended for the first page of the ObjectHeader. 
class ObjectHeader.LayoutParams Layout information for child views of an ObjectHeader. 
XML Attributes
Attribute Name Related Method Description
AbstractEntityCell_description  
AbstractEntityCell_descriptionTextAppearance  
AbstractEntityCell_descriptionWidthPercent setDescriptionWidthPercent(float)  
AbstractEntityCell_detailImage  
AbstractEntityCell_detailImageCharacter  
AbstractEntityCell_detailImageDescription  
AbstractEntityCell_headline  
AbstractEntityCell_headlineLines  
AbstractEntityCell_headlineTextAppearance  
AbstractEntityCell_preserveDetailImageSpacing  
AbstractEntityCell_subheadline  
AbstractEntityCell_subheadlineTextAppearance  
ObjectCell_footnote  
ObjectCell_footnoteTextAppearance  
ObjectCell_statusWidth  
ObjectHeader_Layout_layout_header_group  
ObjectHeader_body setBody(int)  
ObjectHeader_bodyTextAppearance setBodyTextAppearance(int)  
ObjectHeader_descriptionLines setLines(int)  
[Expand]
Inherited XML Attributes
From class com.sap.cloud.mobile.fiori.object.ObjectCell
From class com.sap.cloud.mobile.fiori.object.AbstractEntityCell
[Expand]
Inherited Constants
From class com.sap.cloud.mobile.fiori.object.ObjectCell
From class com.sap.cloud.mobile.fiori.object.AbstractEntityCell
From class android.view.ViewGroup
From class android.view.View
Fields
protected List<Integer> mLabelItemBackgroundColors
protected List<Integer> mLabelItemTextColors
protected List<View> mLabelItemViews
protected int mTextKeyline
[Expand]
Inherited Fields
From class com.sap.cloud.mobile.fiori.object.ObjectCell
From class com.sap.cloud.mobile.fiori.object.AbstractEntityCell
From class android.view.View
Public Constructors
ObjectHeader(Context context)
ObjectHeader(Context context, AttributeSet attrs)
ObjectHeader(Context context, AttributeSet attrs, int defStyle)
ObjectHeader(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)
Public Methods
void addView(View child, int index, ViewGroup.LayoutParams params)
void clearKpiStatusView()
Removes the KPI status view from the ObjectHeader.
void clearLabelItems()
Removes all label item views.
void clearStatuses()
Clears all status views.
void dispatchConfigurationChanged(Configuration newConfig)
ObjectHeader.LayoutParams generateLayoutParams(AttributeSet attrs)
CharSequence getBody()
Gets the body of the object header.
View getDetailView()
Returns the detail view which can be used to show analytics information.
ObjectHeader.KpiItemView getKpiStatusView()
int getLabelItemBackground(int index)
Returns the background color for the LabelItem specified by index.
int getLabelItemTextColor(int index)
Returns the text color for the LabelItem specified by index.
int getTagTextColor(int index)
Returns the text color for the tag specified by index.
int getTagTint(int index)
Returns the tint color for the tag specified by index.
void hideDetailImageView()
Hide the detail image view (and the detail image text view).
boolean isStatusInlineLayout()
boolean isStatusStackedLayout()
boolean isTabletLandscape()
void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info)
boolean onRequestSendAccessibilityEvent(View child, AccessibilityEvent event)
void removeView(View view)
void setAsyncRendering(boolean asyncRendering)
Sets whether the description content will be rendered asynchronously.
void setBody(CharSequence body)
Sets the body of the object header.
void setBody(int resId)
Sets the body text of this object header.
void setBodyColor(int color)
Sets the text color for body text.
void setBodyFont(int fontId)
Sets the text font for body text.
void setBodyFont(Typeface font)
Sets the text font for body text.
void setBodySize(float size)
Sets the text size for body text.
void setBodyTextAppearance(int resId)
Sets the text color, size, style, hint color, and highlight color for body text from the specified TextAppearance resource.
void setDescription(CharSequence description)
Sets the description field for both phone and tablet.
void setDescriptionWidthPercent(float descriptionWidthPercent)
Sets the description width percentage in the space shared by headline and description.
void setDetailView(View detailView)
Sets the detail view which can be used to show analytics information.
void setIsAdjustingPages(boolean isAdjusting)
Checks to see if there are currently any views in process of being added/adjusted to the ObjectHeader pages.
void setIsTest(boolean isTest)
Used in test activities to enable test-specific functions.
void setKpiStatusView(CharSequence metric, CharSequence rightUnit, CharSequence leftMetric, CharSequence leftUnit, CharSequence label)
Creates a KPI status view for the top corner of the screen.
void setKpiStatusView(ObjectHeader.KpiItemView kpiView)
Creates a KPI status view for the top corner of the screen with the provided ObjectHeader.KpiItemView.
void setLabelDrawable(TextView label, Drawable drawable, boolean insertAtStart)
Attaches an icon to the label item.
void setLabelDrawable(TextView label, int drawableResId, boolean insertAtStart)
Attaches an icon to the label item.
void setLabelItem(CharSequence labelText, int index, Drawable drawable, boolean insertAtStart)
Sets a label item.
void setLabelItem(int labelResId, int index, Drawable drawable, boolean insertAtStart)
Sets a label item.
void setLabelItem(CharSequence labelText, int index, int drawableResId, boolean insertAtStart)
Sets a label item.
void setLabelItem(int labelResId, int index, int drawableResId, boolean insertAtStart)
Sets a label item.
void setLabelItemBackground(int color, int index)
Sets the background color for the LabelItem text specified by index.
void setLabelItemTextColor(int color, int index)
Sets the text color for the LabelItem specified by index.
void setLabelTextAppearance(int resId)
Sets the text color, size, style, hint color, and highlight color for label item text from the specified TextAppearance resource.
void setLines(int lines)
Overrides ObjectCell#setLines to allow for more than 3 lines.
void setPreserveDetailImageSpacing(boolean preserveDetailImageSpacing)
ObjectHeader detail image spacing no longer mandatory to preserve.
void setSecondaryActionIcon(Drawable drawable)
Overrides to turn off secondary action
void setShouldAttachOrientationListener(boolean shouldAttach)
Determines if an OrientationEventListener should be attached.
void setStatusInlineLayout(boolean isInline)
Sets the statuses to be laid out inline under the headline/subheadline/tags.
void setStatusStackedLayout(boolean isStacked)
Sets the statuses to be at the top corner of the screen.
void setTagTextColor(int color, int index)
Sets the text color for the tag specified by index.
void setTagTint(int color, int index)
Sets the tint color for the tag specified by index.
boolean shouldAllocateDescriptionViewInFirstPage()
void showDetailImageView()
Show the detail image view (and the detail image text view).
Protected Methods
void addStatusLabelView(View view)
void addViewToGroup(View v, int group)
Adds the view into specified group.
boolean checkLayoutParams(ViewGroup.LayoutParams p)
void checkTagIndexInOrder(int index)
void checkTextWidth(int textWidth, int descriptionWidth)
Calculates title and description width.
void checkTextWidthOnPhone(int textWidth, int fullWidth, boolean updateDescription)
Adjusts text width and configures text layouts when width is changed.
void configureBodyLayout()
void configureDescriptionLayout()
Configures the description layout without using async rendering.
void configureFootnoteLayout()
Configures footnote layout
void configureHeadlineLayout()
Configures headline layout
void configureSubheadlineLayout()
Configures sub headline layout
ObjectHeader.LayoutParams generateDefaultLayoutParams()
ObjectHeader.LayoutParams generateLayoutParams(ViewGroup.LayoutParams p)
int getDefaultLines()
Returns the default lines supported by this cell.
int getFootnoteWidth()
Returns the footnote/additional info width for tablet
int getMaxLines()
Returns the max number of lines supported by this cell.
boolean hasRoomUnderHeadline(int lines)
Checks whether there is room under headline to layout additional text fields
boolean isChild(View child)
Returns true is the view is child of this ObjectHeader or header pages.
boolean isReusingGroupItems()
Overrides to return false since ObjectHeader is not going to be recycled.
int layoutKpiStatus(boolean isRtl, int height, int statusLeft, int statusRight, int statusTop)
Layout status Kpi status view.
int layoutStatusInline(boolean isRtl, int height, boolean centerAligned, int statusLeft, int statusRight, int statusTop, int statusLimit, int baseline, List<View> primaryList, List<View> secondaryList)
StaticLayout obtainStaticLayout(CharSequence text, TextPaint paint, int width, int lines, float lineHeight)
Creates a new StaticLayout based on the parameters
void onAttachedToWindow()
void onLayout(boolean changed, int l, int t, int r, int b)
void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
int retrieveLines()
Returns number of lines based on content.
[Expand]
Inherited Methods
From class com.sap.cloud.mobile.fiori.object.ObjectCell
From class com.sap.cloud.mobile.fiori.object.AbstractEntityCell
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.object.KeylineProvider

XML Attributes

AbstractEntityCell_description

Related Methods

AbstractEntityCell_descriptionTextAppearance

Related Methods

AbstractEntityCell_descriptionWidthPercent

AbstractEntityCell_detailImage

Related Methods

AbstractEntityCell_detailImageCharacter

Related Methods

AbstractEntityCell_detailImageDescription

Related Methods

AbstractEntityCell_headline

Related Methods

AbstractEntityCell_headlineLines

Related Methods

AbstractEntityCell_headlineTextAppearance

Related Methods

AbstractEntityCell_preserveDetailImageSpacing

Related Methods

AbstractEntityCell_subheadline

Related Methods

AbstractEntityCell_subheadlineTextAppearance

Related Methods

ObjectCell_footnote

Related Methods

ObjectCell_footnoteTextAppearance

Related Methods

ObjectCell_statusWidth

Related Methods

ObjectHeader_Layout_layout_header_group

Related Methods

ObjectHeader_body

Related Methods

ObjectHeader_bodyTextAppearance

Related Methods

ObjectHeader_descriptionLines

Related Methods

Fields

protected List<Integer> mLabelItemBackgroundColors

protected List<Integer> mLabelItemTextColors

protected List<View> mLabelItemViews

protected int mTextKeyline

Public Constructors

public ObjectHeader (Context context)

public ObjectHeader (Context context, AttributeSet attrs)

public ObjectHeader (Context context, AttributeSet attrs, int defStyle)

public ObjectHeader (Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)

Public Methods

public void addView (View child, int index, ViewGroup.LayoutParams params)

public void clearKpiStatusView ()

Removes the KPI status view from the ObjectHeader.

public void clearLabelItems ()

Removes all label item views.

public void clearStatuses ()

Clears all status views. It should be called before it's reused in list if there are items with no or fewer status field than other items. Status colors will also be cleared.

public void dispatchConfigurationChanged (Configuration newConfig)

public ObjectHeader.LayoutParams generateLayoutParams (AttributeSet attrs)

public CharSequence getBody ()

Gets the body of the object header.

Related XML Attributes
Returns
  • The body.

public View getDetailView ()

Returns the detail view which can be used to show analytics information.

public ObjectHeader.KpiItemView getKpiStatusView ()

Returns
  • the KPI status view or null if it does not exist.

public int getLabelItemBackground (int index)

Returns the background color for the LabelItem specified by index.

public int getLabelItemTextColor (int index)

Returns the text color for the LabelItem specified by index.

public int getTagTextColor (int index)

Returns the text color for the tag specified by index.

public int getTagTint (int index)

Returns the tint color for the tag specified by index.

public void hideDetailImageView ()

Hide the detail image view (and the detail image text view). Use case includes: while the detail progress bar is displayed.

public boolean isStatusInlineLayout ()

Returns
  • true if inline statuses are enabled, false otherwise.

public boolean isStatusStackedLayout ()

Returns
  • true if at least one status is at the top corner of the screen, false otherwise.

public boolean isTabletLandscape ()

Returns
  • true if device is currently a tablet in landscape mode.

public void onInitializeAccessibilityNodeInfo (AccessibilityNodeInfo info)

public boolean onRequestSendAccessibilityEvent (View child, AccessibilityEvent event)

public void removeView (View view)

public void setAsyncRendering (boolean asyncRendering)

Sets whether the description content will be rendered asynchronously. Long text rendering is expensive, so for a smooth scroll this mode should be set to true.

Parameters
asyncRendering only false is accepted for ObjectHeader

public void setBody (CharSequence body)

Sets the body of the object header.

Body can be used in addition to subheadline.

Related XML Attributes
Parameters
body The body.

public void setBody (int resId)

Sets the body text of this object header.

Body can be used as additional information.

Related XML Attributes
Parameters
resId String resource ID

public void setBodyColor (int color)

Sets the text color for body text.

public void setBodyFont (int fontId)

Sets the text font for body text.

public void setBodyFont (Typeface font)

Sets the text font for body text.

public void setBodySize (float size)

Sets the text size for body text.

public void setBodyTextAppearance (int resId)

Sets the text color, size, style, hint color, and highlight color for body text from the specified TextAppearance resource.

Related XML Attributes

public void setDescription (CharSequence description)

Sets the description field for both phone and tablet.

Parameters
description The description.

public void setDescriptionWidthPercent (float descriptionWidthPercent)

Sets the description width percentage in the space shared by headline and description. This ratio is also used to determine additional info or detail/analytics view width when they are rendered horizontally with the title area.

Parameters
descriptionWidthPercent The width percentage for description/additional info/detail views.

public void setDetailView (View detailView)

Sets the detail view which can be used to show analytics information. On tablet if detail view is set, description will be hidden. The width of the detailView on tablet can be controlled by setDescriptionWidthPercent(float)

public void setIsAdjustingPages (boolean isAdjusting)

Checks to see if there are currently any views in process of being added/adjusted to the ObjectHeader pages.

Parameters
isAdjusting true if the ObjectHeader is currently adjusting the pages, false otherwise.

public void setIsTest (boolean isTest)

Used in test activities to enable test-specific functions.

Parameters
isTest Whether this ObjectHeader needs test-specific functions

public void setKpiStatusView (CharSequence metric, CharSequence rightUnit, CharSequence leftMetric, CharSequence leftUnit, CharSequence label)

Creates a KPI status view for the top corner of the screen. The parameters are all optional. However, if all parameters are null it will be the same as calling setKpiStatusView(KpiItemView)} with a null parameter which will result in the deletion of the current KPI status view if present.

public void setKpiStatusView (ObjectHeader.KpiItemView kpiView)

Creates a KPI status view for the top corner of the screen with the provided ObjectHeader.KpiItemView.

Parameters
kpiView if null, the current KPI status view will be removed.

public void setLabelDrawable (TextView label, Drawable drawable, boolean insertAtStart)

Attaches an icon to the label item.

Parameters
label Text to be shown as label.
drawable Drawable to show.
insertAtStart If true, inserts the icon before the text. Placed after the text otherwise.

public void setLabelDrawable (TextView label, int drawableResId, boolean insertAtStart)

Attaches an icon to the label item.

Parameters
label Text to be shown as label.
drawableResId Resource id of drawable to show as icon
insertAtStart If true, inserts the icon before the text. Placed after the text otherwise.

public void setLabelItem (CharSequence labelText, int index, Drawable drawable, boolean insertAtStart)

Sets a label item.

Parameters
labelText Text to be shown as label.
index Always sets label item starting from 0.
drawable Drawable to show.
insertAtStart If true, inserts the icon before the text. Placed after the text otherwise.

public void setLabelItem (int labelResId, int index, Drawable drawable, boolean insertAtStart)

Sets a label item.

Parameters
labelResId Resource id of text to show.
index Always sets label starting from 0.
drawable Drawable to show.
insertAtStart If true, inserts the icon before the text. Placed after the text otherwise.

public void setLabelItem (CharSequence labelText, int index, int drawableResId, boolean insertAtStart)

Sets a label item.

Parameters
labelText Text to be shown as label.
index Always sets label item starting from 0.
drawableResId Resource id of drawable to show.
insertAtStart If true, inserts the icon before the text. Placed after the text otherwise.

public void setLabelItem (int labelResId, int index, int drawableResId, boolean insertAtStart)

Sets a label item.

Parameters
labelResId Resource id of text to show.
index Always sets label starting from 0.
drawableResId Resource id of drawable to show.
insertAtStart If true, inserts the icon before the text. Placed after the text otherwise.

public void setLabelItemBackground (int color, int index)

Sets the background color for the LabelItem text specified by index. The leading/trailing icon remains unaffected.

public void setLabelItemTextColor (int color, int index)

Sets the text color for the LabelItem specified by index. If you use customized views for LabelItems, this method won't take effect. todo check this statement

public void setLabelTextAppearance (int resId)

Sets the text color, size, style, hint color, and highlight color for label item text from the specified TextAppearance resource.

public void setLines (int lines)

Overrides ObjectCell#setLines to allow for more than 3 lines.

Related XML Attributes
Parameters
lines description lines, 2-4

public void setPreserveDetailImageSpacing (boolean preserveDetailImageSpacing)

ObjectHeader detail image spacing no longer mandatory to preserve.

Parameters
preserveDetailImageSpacing only true is accepted.

public void setSecondaryActionIcon (Drawable drawable)

Overrides to turn off secondary action

Parameters
drawable only null is accepted

public void setShouldAttachOrientationListener (boolean shouldAttach)

Determines if an OrientationEventListener should be attached.

Parameters
shouldAttach Whether the ObjectHeader should consider attaching an OrientationEventListener or not

public void setStatusInlineLayout (boolean isInline)

Sets the statuses to be laid out inline under the headline/subheadline/tags. This will only take effect if there is at least one status and isStatusStackedLayout() is false.

public void setStatusStackedLayout (boolean isStacked)

Sets the statuses to be at the top corner of the screen. If the KPI status is active, then this method will not work. If this is the case, the statuses will be set inline under the headline/subheadline/tags).

public void setTagTextColor (int color, int index)

Sets the text color for the tag specified by index. If you use customized views for tags, this method won't take effect.

public void setTagTint (int color, int index)

Sets the tint color for the tag specified by index. If you use customized views for tags, this method won't take effect.

public boolean shouldAllocateDescriptionViewInFirstPage ()

Returns
  • true if page one of ObjectHeader is not null, false otherwise.

public void showDetailImageView ()

Show the detail image view (and the detail image text view). Use case includes: after the detail progress bar reaches its max.

Protected Methods

protected void addStatusLabelView (View view)

protected void addViewToGroup (View v, int group)

Adds the view into specified group.

Parameters
v view
group group

protected boolean checkLayoutParams (ViewGroup.LayoutParams p)

protected void checkTagIndexInOrder (int index)

protected void checkTextWidth (int textWidth, int descriptionWidth)

Calculates title and description width.

Parameters
textWidth total width
descriptionWidth width that COULD be used by description

protected void checkTextWidthOnPhone (int textWidth, int fullWidth, boolean updateDescription)

Adjusts text width and configures text layouts when width is changed.

protected void configureBodyLayout ()

protected void configureDescriptionLayout ()

Configures the description layout without using async rendering.

protected void configureFootnoteLayout ()

Configures footnote layout

protected void configureHeadlineLayout ()

Configures headline layout

protected void configureSubheadlineLayout ()

Configures sub headline layout

protected ObjectHeader.LayoutParams generateDefaultLayoutParams ()

protected ObjectHeader.LayoutParams generateLayoutParams (ViewGroup.LayoutParams p)

protected int getDefaultLines ()

Returns the default lines supported by this cell.

protected int getFootnoteWidth ()

Returns the footnote/additional info width for tablet

protected int getMaxLines ()

Returns the max number of lines supported by this cell.

protected boolean hasRoomUnderHeadline (int lines)

Checks whether there is room under headline to layout additional text fields

Parameters
lines used lines

protected boolean isChild (View child)

Returns true is the view is child of this ObjectHeader or header pages.

protected boolean isReusingGroupItems ()

Overrides to return false since ObjectHeader is not going to be recycled.

protected int layoutKpiStatus (boolean isRtl, int height, int statusLeft, int statusRight, int statusTop)

Layout status Kpi status view. Returns the bottom of the layout

protected int layoutStatusInline (boolean isRtl, int height, boolean centerAligned, int statusLeft, int statusRight, int statusTop, int statusLimit, int baseline, List<View> primaryList, List<View> secondaryList)

protected StaticLayout obtainStaticLayout (CharSequence text, TextPaint paint, int width, int lines, float lineHeight)

Creates a new StaticLayout based on the parameters

Parameters
text text to render
paint how to render
width width of the layout
lines max lines of the layout
lineHeight the height between base lines
Returns
  • the created StaticLayout

protected void onAttachedToWindow ()

protected void onLayout (boolean changed, int l, int t, int r, int b)

protected void onMeasure (int widthMeasureSpec, int heightMeasureSpec)

protected int retrieveLines ()

Returns number of lines based on content. To be overwritten by subclasses.