public class

ProfileHeader

extends ContactCell
java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ com.sap.cloud.mobile.fiori.object.AbstractEntityCell
         ↳ com.sap.cloud.mobile.fiori.contact.ContactCell
           ↳ com.sap.cloud.mobile.fiori.contact.ProfileHeader

Class Overview

The profile header helps the user recognize and learn more about a person. It may also allow the user to quickly contact that person without needing to drill down into his/her contact details.

Structure

In regular width, the profile header may include an image, the profile name and title, a description, and two or more action icons. Including an image is not required but is highly recommended, as this helps the user recognize the person in question.

Sample code:

 ProfileHeader ph = new ProfileHeader(mActivity);
 ph.setDetailImage(R.drawable.ic_account_circle_black_24dp);
 ph.setDetailImageDescription(R.string.profile_header_detail_image_desc);
 ph.setHeadline(R.string.profile_header_headline);
 ph.setSubheadline(R.string.profile_header_subheadline);
 ph.setDescription(R.string.profile_header_description);
 ToggleButton button = new ToggleButton(this);
 button.setTextOn(getResources().getString(R.string.pref_profile_header_action_button_on));
 button.setTextOff(getResources().getString(R.string.pref_profile_header_action_button_off));
 button.setText(getResources().getString(R.string.pref_profile_header_action_button_off));
 button.setContentDescription(getResources().getString(R.string.profile_header_action_desc));
 ph.setProfileActionView(button);
 

Summary

Nested Classes
class ProfileHeader.LayoutParams Layout information for child views of an ProfileHeader

Child view added in XML could optionally have a layout_profile_group parameter to tell the parent ProfileHeader how to layout this child view. 

XML Attributes
Attribute Name Related Method Description
com.sap.cloud.mobile.fiori:contactActions The actions that can be applied to the current ContactCell. 
com.sap.cloud.mobile.fiori:description The description associated with the AbstractEntityCell. 
com.sap.cloud.mobile.fiori:descriptionTextAppearance Text color, typeface, size, and style for footnote. 
com.sap.cloud.mobile.fiori:descriptionWidthPercent The width percentage of description of the total width shared by headline and description

May be a floating point value, such as "1.2". 

com.sap.cloud.mobile.fiori:detailImage The detail image. 
com.sap.cloud.mobile.fiori:detailImageCharacter The placeholder character for the detail image. 
com.sap.cloud.mobile.fiori:detailImageDescription A content description string to describe the appearance of the associated detail image. 
com.sap.cloud.mobile.fiori:headline The headline associated with the AbstractEntityCell. 
com.sap.cloud.mobile.fiori:headlineLines Makes the headline be exactly this many lines tall. 
com.sap.cloud.mobile.fiori:headlineTextAppearance Text color, typeface, size, and style for headline. 
com.sap.cloud.mobile.fiori:layout_profile_group setProfileActionView(View) Specifies which layout group the child view should belong. 
com.sap.cloud.mobile.fiori:lines Total number of lines. 
com.sap.cloud.mobile.fiori:preserveDetailImageSpacing Whether to preserve detail image space when image is null

May be a boolean value, such as "true" or "false". 

com.sap.cloud.mobile.fiori:subheadline The subheadline associated with the AbstractEntityCell. 
com.sap.cloud.mobile.fiori:subheadlineTextAppearance Text color, typeface, size, and style for subheadline. 
[Expand]
Inherited XML Attributes
From class com.sap.cloud.mobile.fiori.contact.ContactCell
From class com.sap.cloud.mobile.fiori.object.AbstractEntityCell
[Expand]
Inherited Constants
From class com.sap.cloud.mobile.fiori.object.AbstractEntityCell
From class android.view.ViewGroup
From class android.view.View
[Expand]
Inherited Fields
From class com.sap.cloud.mobile.fiori.contact.ContactCell
From class com.sap.cloud.mobile.fiori.object.AbstractEntityCell
From class android.view.View
Public Constructors
ProfileHeader(Context context)
ProfileHeader(Context context, AttributeSet attrs)
ProfileHeader(Context context, AttributeSet attrs, int defStyle)
ProfileHeader(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)
Public Methods
void addView(View child, int index, ViewGroup.LayoutParams params)
ProfileHeader.LayoutParams generateLayoutParams(AttributeSet attrs)
int getHeadlineMaxWidth()
Returns the maximum width for headline/name when description also exists.
int getHeadlineMinWidth()
Returns the minimum width for headline/name when description also exists.
View getProfileActionView()
Returns the profile action view.
void setContactActions(ContactAction... actions)
Creates ImageButtons according to the parameter.
void setDescription(CharSequence description)
Sets description on both tablet and phone.
void setHeadlineMaxWidth(int headlineMaxWidth)
Sets the maximum width for headline/name.
void setHeadlineMinWidth(int headlineMinWidth)
Sets the minimum width for headline/name.
void setPreserveDetailImageSpacing(boolean preserveDetailImageSpacing)
ObjectHeader always preserves detail image spacing.
void setProfileActionView(View profileActionView)
Sets the profile action view.
Protected Methods
void checkTextWidth(int textWidth, int descriptionWidth)
Updates StaticLayoutTextViews if width is changed.
ProfileHeader.LayoutParams generateDefaultLayoutParams()
ProfileHeader.LayoutParams generateLayoutParams(ViewGroup.LayoutParams p)
ColorStateList getContactActionImageTintList()
Returns the ColorStateList used to render contact action icons.
int getContactActionLimit()
Returns the maximum number of contact action icons that can be rendered.
int getRecommendedHeight()
Returns the recommended height.
void layoutActions(boolean isRtl, int top, int height, int left, int right)
Layouts either profile action or contact action icons on tablet.
ContactCell.Measurement measureActions(int parentWidthSpec, int width, int childState)
Measures either profile action or contact actions on tablet.
void onLayout(boolean changed, int l, int t, int r, int b)
void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
boolean shouldLayoutContactActions()
Returns whether contact actions should be rendered.
boolean verticalCenterAlignTitle()
Returns whether name and title should be center-aligned with image
[Expand]
Inherited Methods
From class com.sap.cloud.mobile.fiori.contact.ContactCell
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

com.sap.cloud.mobile.fiori:contactActions

The actions that can be applied to the current ContactCell. This is a comma-separated list of values, containing one or more of the following: ContactCell.ContactAction. This corresponds to setContactActions(ContactAction).

May be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character;

Related Methods

com.sap.cloud.mobile.fiori:description

The description associated with the AbstractEntityCell. Next to headline. Only appears in regular mode(tablet)

May be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character;

Related Methods

com.sap.cloud.mobile.fiori:descriptionTextAppearance

Text color, typeface, size, and style for footnote. Defaults to secondary_text_default_material_light color. Default style: TextAppearance_Fiori_ObjectCell_Description

May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".

Related Methods

com.sap.cloud.mobile.fiori:descriptionWidthPercent

The width percentage of description of the total width shared by headline and description

May be a floating point value, such as "1.2".

Related Methods

com.sap.cloud.mobile.fiori:detailImage

The detail image.

May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".

Related Methods

com.sap.cloud.mobile.fiori:detailImageCharacter

The placeholder character for the detail image. No effect if detailImage is not null.

May be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character;

Related Methods

com.sap.cloud.mobile.fiori:detailImageDescription

A content description string to describe the appearance of the associated detail image.

May be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character;

Related Methods

com.sap.cloud.mobile.fiori:headline

The headline associated with the AbstractEntityCell. Mandatory.

May be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character;

Related Methods

com.sap.cloud.mobile.fiori:headlineLines

Makes the headline be exactly this many lines tall. Default value is 1 if not specified. When it's 2, footnote will disappear; when it's 3, sub headline will also disappear. This must be equal to or less than "lines".

May be an integer value, such as "100".

Related Methods

com.sap.cloud.mobile.fiori:headlineTextAppearance

Text color, typeface, size, and style for headline. Defaults to material_grey_900 color. Default style: TextAppearance_Fiori_ObjectCell_Headline

May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".

Related Methods

com.sap.cloud.mobile.fiori:layout_profile_group

Specifies which layout group the child view should belong. This must be set for any child views of an ContactCell, otherwise the view will be ignored.

Must be one of the following constant values.

ConstantValueDescription
ACTION1Designates a view to show in ProfileHeader actions group. This is the default if not specified.
INTERNAL0Reserved for internal usage
PROFILE_ACTION2Designates a view to show in ProfileHeader profile action group.

Related Methods

com.sap.cloud.mobile.fiori:lines

Total number of lines.

May be an integer value, such as "100".

Related Methods

com.sap.cloud.mobile.fiori:preserveDetailImageSpacing

Whether to preserve detail image space when image is null

May be a boolean value, such as "true" or "false".

Related Methods

com.sap.cloud.mobile.fiori:subheadline

The subheadline associated with the AbstractEntityCell. Under headline.

May be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character;

Related Methods

com.sap.cloud.mobile.fiori:subheadlineTextAppearance

Text color, typeface, size, and style for subheadline. Defaults to primary_text_default_material_light color. Default style: TextAppearance_Fiori_ObjectCell_Subheadline

May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".

Related Methods

Public Constructors

public ProfileHeader (Context context)

public ProfileHeader (Context context, AttributeSet attrs)

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

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

Public Methods

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

public ProfileHeader.LayoutParams generateLayoutParams (AttributeSet attrs)

public int getHeadlineMaxWidth ()

Returns the maximum width for headline/name when description also exists.

public int getHeadlineMinWidth ()

Returns the minimum width for headline/name when description also exists.

public View getProfileActionView ()

Returns the profile action view.

public void setContactActions (ContactAction... actions)

Creates ImageButtons according to the parameter. ImageButtons can be retrieved by getContactActionView(int). If the same actions array is used to call this method again, no view removal and addition will be performed to avoid performance overhead. Caller needs to enable/disable the ImageButtons and reset View.OnClickListeners respectively.

public void setDescription (CharSequence description)

Sets description on both tablet and phone.

Parameters
description The description.

public void setHeadlineMaxWidth (int headlineMaxWidth)

Sets the maximum width for headline/name. This overrides description percentage setting.

Parameters
headlineMaxWidth width in pixels

public void setHeadlineMinWidth (int headlineMinWidth)

Sets the minimum width for headline/name. This overrides description percentage setting.

Parameters
headlineMinWidth width in pixels

public void setPreserveDetailImageSpacing (boolean preserveDetailImageSpacing)

ObjectHeader always preserves detail image spacing. This is a no-op.

public void setProfileActionView (View profileActionView)

Sets the profile action view. On a phone, contact icons and the description section should not be included when a profile action view is present; On a tablet, contact icons will be replaced by profile action view.

Parameters
profileActionView any view, usually a Button

Protected Methods

protected void checkTextWidth (int textWidth, int descriptionWidth)

Updates StaticLayoutTextViews if width is changed. Important! Don't call requestLayout() here since it's called from onMeasure. Otherwise it would cause repeated onMeasure calls and even Espresso wouldn't be able to locate the root view because of constant layout requests.

Parameters
textWidth whole text width
descriptionWidth not used by ProfileHeader

protected ProfileHeader.LayoutParams generateDefaultLayoutParams ()

protected ProfileHeader.LayoutParams generateLayoutParams (ViewGroup.LayoutParams p)

protected ColorStateList getContactActionImageTintList ()

Returns the ColorStateList used to render contact action icons.

protected int getContactActionLimit ()

Returns the maximum number of contact action icons that can be rendered.

protected int getRecommendedHeight ()

Returns the recommended height. ProfileHeader height on tablet is usually determined by the image size.

protected void layoutActions (boolean isRtl, int top, int height, int left, int right)

Layouts either profile action or contact action icons on tablet.

protected ContactCell.Measurement measureActions (int parentWidthSpec, int width, int childState)

Measures either profile action or contact actions on tablet.

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

protected void onMeasure (int widthMeasureSpec, int heightMeasureSpec)

protected boolean shouldLayoutContactActions ()

Returns whether contact actions should be rendered.

protected boolean verticalCenterAlignTitle ()

Returns whether name and title should be center-aligned with image