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 one 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
AbstractEntityCell_description  
AbstractEntityCell_descriptionTextAppearance  
AbstractEntityCell_descriptionWidthPercent  
AbstractEntityCell_detailImage  
AbstractEntityCell_detailImageCharacter  
AbstractEntityCell_detailImageDescription  
AbstractEntityCell_headline  
AbstractEntityCell_headlineLines  
AbstractEntityCell_headlineTextAppearance  
AbstractEntityCell_lines  
AbstractEntityCell_preserveDetailImageSpacing  
AbstractEntityCell_subheadline  
AbstractEntityCell_subheadlineTextAppearance  
ContactCell_contactActions  
ProfileHeader_Layout_layout_profile_group setProfileActionView(View)  
[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

AbstractEntityCell_description

Related Methods

AbstractEntityCell_descriptionTextAppearance

Related Methods

AbstractEntityCell_descriptionWidthPercent

Related Methods

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_lines

Related Methods

AbstractEntityCell_preserveDetailImageSpacing

Related Methods

AbstractEntityCell_subheadline

Related Methods

AbstractEntityCell_subheadlineTextAppearance

Related Methods

ContactCell_contactActions

Related Methods

ProfileHeader_Layout_layout_profile_group

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