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 |
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:
An image helps the user to visually identify the object.
SeesetDetailImage(Drawable)
.
The object name and title provide key information and are always required.
SeesetHeadline(int)
and setSubheadline(int)
.
Additional information includes tags and two short strings of relevant text.
SeesetTag(int, int)
, setTagTint(int, int)
, setTagTextColor(int, int)
, setBody(int)
and setFootnote(int)
.
Analytics/data visualization allow the user to quickly understand relevant trend or status information.
SeesetDetailView(View)
When there are no analytics to display, a description paragraph may instead be included. The paragraph should not exceed a maximum of four lines of text, and should only be used when it provides the user with valuable information.
SeesetDescription(int)
A status label/icon displays the current status of the object.
SeesetStatus(Drawable, int, CharSequence)
, setStatusColor(int, int)
and clearStatuses()
.
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.
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. |
[Expand]
Inherited XML Attributes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() |
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
protected List<Integer> | mLabelItemBackgroundColors | ||||||||||
protected List<Integer> | mLabelItemTextColors | ||||||||||
protected List<View> | mLabelItemViews | ||||||||||
protected int | mTextKeyline |
[Expand]
Inherited Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() | |||||||||||
![]() |
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 | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() |
Removes the KPI status view from the ObjectHeader.
Removes all label item views.
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.
Returns the detail view which can be used to show analytics information.
Returns the background color for the LabelItem specified by index.
Returns the text color for the LabelItem specified by index.
Returns the text color for the tag specified by index.
Returns the tint color for the tag specified by index.
Hide the detail image view (and the detail image text view). Use case includes: while the detail progress bar is displayed.
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.
asyncRendering | only false is accepted for ObjectHeader |
---|
Sets the body of the object header.
Body can be used in addition to subheadline.
body | The body. |
---|
Sets the body text of this object header.
Body can be used as additional information.
resId | String resource ID |
---|
Sets the text color for body text.
Sets the text font for body text.
Sets the text size for body text.
Sets the text color, size, style, hint color, and highlight color for body text from the specified TextAppearance resource.
Sets the description field for both phone and tablet.
description | The description. |
---|
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.
descriptionWidthPercent | The width percentage for description/additional info/detail views. |
---|
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)
Checks to see if there are currently any views in process of being added/adjusted to the ObjectHeader pages.
isAdjusting | true if the ObjectHeader is currently adjusting the pages, false otherwise. |
---|
Used in test activities to enable test-specific functions.
isTest | Whether this ObjectHeader needs test-specific functions |
---|
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.
Creates a KPI status view for the top corner of the screen with the
provided ObjectHeader.KpiItemView
.
kpiView | if null, the current KPI status view will be removed. |
---|
Attaches an icon to the label item.
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. |
Attaches an icon to the label item.
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. |
Sets a label item.
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. |
Sets a label item.
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. |
Sets a label item.
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. |
Sets a label item.
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. |
Sets the background color for the LabelItem text specified by index. The leading/trailing icon remains unaffected.
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
Sets the text color, size, style, hint color, and highlight color for label item text from the specified TextAppearance resource.
Overrides ObjectCell#setLines to allow for more than 3 lines.
lines | description lines, 2-4 |
---|
ObjectHeader
detail image spacing no longer mandatory to preserve.
preserveDetailImageSpacing | only true is accepted. |
---|
Overrides to turn off secondary action
drawable | only null is accepted |
---|
Determines if an OrientationEventListener should be attached.
shouldAttach | Whether the ObjectHeader should consider attaching an OrientationEventListener or not |
---|
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.
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).
Sets the text color for the tag specified by index. If you use customized views for tags, this method won't take effect.
Sets the tint color for the tag specified by index. If you use customized views for tags, this method won't take effect.
Show the detail image view (and the detail image text view). Use case includes: after the detail progress bar reaches its max.
Adds the view into specified group.
v | view |
---|---|
group | group |
Calculates title and description width.
textWidth | total width |
---|---|
descriptionWidth | width that COULD be used by description |
Adjusts text width and configures text layouts when width is changed.
Configures the description layout without using async rendering.
Configures footnote layout
Configures headline layout
Configures sub headline layout
Returns the default lines supported by this cell.
Returns the footnote/additional info width for tablet
Returns the max number of lines supported by this cell.
Checks whether there is room under headline to layout additional text fields
lines | used lines |
---|
Returns true is the view is child of this ObjectHeader or header pages.
Overrides to return false since ObjectHeader is not going to be recycled.
Layout status Kpi status view. Returns the bottom of the layout
Creates a new StaticLayout based on the 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 number of lines based on content. To be overwritten by subclasses.