GuidedStepFragment

Added in 1.1.0
Deprecated in 1.1.0

class GuidedStepFragment : Fragment


A GuidedStepFragment is used to guide the user through a decision or series of decisions. It is composed of a guidance view on the left and a view on the right containing a list of possible actions.

Basic Usage

Clients of GuidedStepFragment must create a custom subclass to attach to their Activities. This custom subclass provides the information necessary to construct the user interface and respond to user actions. At a minimum, subclasses should override:

Clients use following helper functions to add GuidedStepFragment to Activity or FragmentManager:

  • addAsRoot, to be called during Activity onCreate, adds GuidedStepFragment as the first Fragment in activity.
  • add or add, to add GuidedStepFragment on top of existing Fragments or replacing existing GuidedStepFragment when moving forward to next step.
  • finishGuidedStepFragments can either finish the activity or pop all GuidedStepFragment from stack.
  • If app chooses not to use the helper function, it is the app's responsibility to call setUiStyle to select fragment transition and remember the stack entry where it need pops to.

Theming and Stylists

GuidedStepFragment delegates its visual styling to classes called stylists. The is responsible for the left guidance view, while the is responsible for the right actions view. The stylists use theme attributes to derive values associated with the presentation, such as colors, animations, etc. Most simple visual aspects of GuidanceStylist and GuidedActionsStylist can be customized via theming; see their documentation for more information.

GuidedStepFragments must have access to an appropriate theme in order for the stylists to function properly. Specifically, the fragment must receive Theme_Leanback_GuidedStep, or a theme whose parent is is set to that theme. Themes can be provided in one of three ways:

  • The simplest way is to set the theme for the host Activity to the GuidedStep theme or a theme that derives from it.
  • If the Activity already has a theme and setting its parent theme is inconvenient, the existing Activity theme can have an entry added for the attribute LeanbackGuidedStepTheme_guidedStepTheme. If present, this theme will be used by GuidedStepFragment as an overlay to the Activity's theme.
  • Finally, custom subclasses of GuidedStepFragment may provide a theme through the onProvideTheme method. This can be useful if a subclass is used across multiple Activities.

If the theme is provided in multiple ways, the onProvideTheme override has priority, followed by the Activity's theme. (Themes whose parent theme is already set to the guided step theme do not need to set the guidedStepTheme attribute; if set, it will be ignored.)

If themes do not provide enough customizability, the stylists themselves may be subclassed and provided to the GuidedStepFragment through the onCreateGuidanceStylist and onCreateActionsStylist methods. The stylists have simple hooks so that subclasses may override layout files; subclasses may also have more complex logic to determine styling.

Guided sequences

GuidedStepFragments can be grouped together to provide a guided sequence. GuidedStepFragments grouped as a sequence use custom animations provided by GuidanceStylist and GuidedActionsStylist (or subclasses) during transitions between steps. Clients should use add to place subsequent GuidedFragments onto the fragment stack so that custom animations are properly configured. (Custom animations are triggered automatically when the fragment stack is subsequently popped by any normal mechanism.)

Note: Currently GuidedStepFragments grouped in this way must all be defined programmatically, rather than in XML. This restriction may be removed in the future.guidedStepThemeguidedStepBackgroundguidedActionContentWidthWeightguidedActionContentWidthWeightTwoPanelsguidedActionsBackgroundguidedActionsBackgroundDarkguidedActionsElevation

Summary

Constants

const String!
EXTRA_UI_STYLE = "uiStyle"

Fragment argument name for UI style.

const Int

One possible value of argument EXTRA_UI_STYLE.

const Int

This property is deprecated.

Same value as UI_STYLE_REPLACE.

const Int

Default value for argument EXTRA_UI_STYLE.

const Int

This is the case that we use GuidedStepFragment to replace another existing GuidedStepFragment when moving forward to next step.

Public constructors

Public functions

java-static Int
add(fragmentManager: FragmentManager, fragment: GuidedStepFragment)

Adds the specified GuidedStepFragment to the fragment stack, replacing any existing GuidedStepFragments in the stack, and configuring the fragment-to-fragment custom transitions.

java-static Int
add(
    fragmentManager: FragmentManager,
    fragment: GuidedStepFragment,
    id: Int
)

Adds the specified GuidedStepFragment to the fragment stack, replacing any existing GuidedStepFragments in the stack, and configuring the fragment-to-fragment custom transitions.

java-static Int
addAsRoot(activity: Activity, fragment: GuidedStepFragment, id: Int)

Adds the specified GuidedStepFragment as content of Activity; no backstack entry is added so the activity will be dismissed when BACK key is pressed.

Unit
collapseAction(withTransition: Boolean)

Collapse action which either has a sub actions list or action with hasEditableActivatorView is true.

Unit

Collapse sub actions list.

Unit
expandAction(action: GuidedAction, withTransition: Boolean)

Expand a given action with sub actions list or hasEditableActivatorView is true.

Unit

Expand a given action's sub actions list.

GuidedAction?

Find GuidedAction by Id.

Int

Find GuidedAction position in array by Id.

GuidedAction?

Find button GuidedAction by Id.

Int

Find button GuidedAction position in array by Id.

Unit

Convenient method to close GuidedStepFragments on top of other content or finish Activity if GuidedStepFragments were started in a separate activity.

View?

Returns the view corresponding to the action at the indicated position in the list of actions for this fragment.

(Mutable)List<GuidedAction!>

Returns the list of GuidedActions that the user may take in this fragment.

View?

Returns the view corresponding to the button action at the indicated position in the list of actions for this fragment.

(Mutable)List<GuidedAction!>

Returns the list of button GuidedActions that the user may take in this fragment.

java-static GuidedStepFragment?

Returns the current GuidedStepFragment on the fragment transaction stack.

GuidanceStylist

Returns the GuidanceStylist that displays guidance information for the user.

GuidedActionsStylist

Returns the GuidedActionsStylist that displays the actions the user may take.

GuidedActionsStylist

Returns the GuidedActionsStylist that displays the button actions the user may take.

Int

Returns the position if the currently selected GuidedAction.

Int

Returns the position if the currently selected button GuidedAction.

Int

Read UI style from fragment arguments.

Boolean
Boolean

Returns true if allows focus out of end edge of GuidedStepFragment, false otherwise.

Boolean

Returns true if allows focus out of start edge of GuidedStepFragment, false otherwise.

Boolean
Unit

Notify an action has changed and update its UI.

Unit

Notify an button action has changed and update its UI.

Unit
onCreate(savedInstanceState: Bundle?)
Unit
onCreateActions(
    actions: (Mutable)List<GuidedAction!>,
    savedInstanceState: Bundle?
)

Fills out the set of actions available to the user.

GuidedActionsStylist

Creates the presenter used to style the guided actions panel.

View?
onCreateBackgroundView(
    inflater: LayoutInflater,
    container: ViewGroup?,
    savedInstanceState: Bundle?
)

Called by onCreateView to inflate background view.

Unit
onCreateButtonActions(
    actions: (Mutable)List<GuidedAction!>,
    savedInstanceState: Bundle?
)

Fills out the set of actions shown at right available to the user.

GuidedActionsStylist

Creates the presenter used to style a sided actions panel for button only.

GuidanceStylist.Guidance
onCreateGuidance(savedInstanceState: Bundle?)

Returns the information required to provide guidance to the user.

GuidanceStylist

Creates the presenter used to style the guidance panel.

View?
onCreateView(
    inflater: LayoutInflater!,
    container: ViewGroup?,
    savedInstanceState: Bundle!
)
Unit
Unit

Callback invoked when an action is taken by the user.

Unit

Callback invoked when an action has been canceled editing, for example when user closes IME window by BACK key.

Unit

This function is deprecated.

Override onGuidedActionEditedAndProceed and/or onGuidedActionEditCanceled.

Long

Callback invoked when an action has been edited, for example when user clicks confirm button in IME window.

Unit

Callback invoked when an action is focused (made to be the current selection) by the user.

Int

Returns the theme used for styling the fragment.

Unit

This function is deprecated.

Unit
Boolean

Callback invoked when an action in sub actions is taken by the user.

Unit

Opens the provided action in edit mode and raises ime.

Unit
popBackStackToGuidedStepFragment(
    guidedStepFragmentClass: Class<Any!>,
    flags: Int
)

Convenient method to pop to fragment with Given class.

Unit

Sets the list of GuidedActions that the user may take in this fragment.

Unit

Sets the RecyclerView DiffCallback used when setActions is called.

Unit

Sets the list of button GuidedActions that the user may take in this fragment.

Unit

Scrolls the action list to the position indicated, selecting that action's view.

Unit

Scrolls the action list to the position indicated, selecting that button action's view.

Unit
setUiStyle(style: Int)

Set UI style to fragment arguments.

Protected functions

Unit

Called when this fragment is added to FragmentTransaction with UI_STYLE_REPLACE (aka when the GuidedStepFragment replacing an existing GuidedStepFragment).

Unit

Called by Constructor to provide fragment transitions.

Inherited functions

From android.app.Fragment
Unit
dump(
    prefix: String!,
    fd: FileDescriptor!,
    writer: PrintWriter!,
    args: Array<String!>!
)

This function is deprecated.

Boolean
equals(o: Any!)

This function is deprecated.

Activity!

This function is deprecated.

Boolean

This function is deprecated.

Boolean

This function is deprecated.

Bundle!

This function is deprecated.

FragmentManager!

This function is deprecated.

Context!

This function is deprecated.

Transition!

This function is deprecated.

Transition!

This function is deprecated.

FragmentManager!

This function is deprecated.

Any!

This function is deprecated.

Int

This function is deprecated.

LayoutInflater!

This function is deprecated.

LoaderManager!

This function is deprecated.

Fragment!

This function is deprecated.

Transition!

This function is deprecated.

Resources!

This function is deprecated.

Boolean

This function is deprecated.

Transition!

This function is deprecated.

Transition!

This function is deprecated.

Transition!

This function is deprecated.

String!
getString(resId: Int)

This function is deprecated.

String!

This function is deprecated.

Fragment!

This function is deprecated.

Int

This function is deprecated.

CharSequence!
getText(resId: Int)

This function is deprecated.

Boolean

This function is deprecated.

View!

This function is deprecated.

Int

This function is deprecated.

java-static Fragment!
instantiate(context: Context!, fname: String!)

This function is deprecated.

Boolean

This function is deprecated.

Boolean

This function is deprecated.

Boolean

This function is deprecated.

Boolean

This function is deprecated.

Boolean

This function is deprecated.

Boolean

This function is deprecated.

Boolean

This function is deprecated.

Boolean

This function is deprecated.

Unit
onActivityCreated(savedInstanceState: Bundle!)

This function is deprecated.

Unit
onActivityResult(requestCode: Int, resultCode: Int, data: Intent!)

This function is deprecated.

Unit
onAttach(context: Context!)

This function is deprecated.

Unit
onAttachFragment(childFragment: Fragment!)

This function is deprecated.

Unit

This function is deprecated.

Boolean

This function is deprecated.

Animator!
onCreateAnimator(transit: Int, enter: Boolean, nextAnim: Int)

This function is deprecated.

Unit
onCreateContextMenu(
    menu: ContextMenu!,
    v: View!,
    menuInfo: ContextMenu.ContextMenuInfo!
)

This function is deprecated.

Unit
onCreateOptionsMenu(menu: Menu!, inflater: MenuInflater!)

This function is deprecated.

Unit

This function is deprecated.

Unit

This function is deprecated.

Unit

This function is deprecated.

LayoutInflater!
onGetLayoutInflater(savedInstanceState: Bundle!)

This function is deprecated.

Unit

This function is deprecated.

Unit
onInflate(attrs: AttributeSet!, savedInstanceState: Bundle!)

This function is deprecated.

Unit

This function is deprecated.

Unit
onMultiWindowModeChanged(
    isInMultiWindowMode: Boolean,
    newConfig: Configuration!
)

This function is deprecated.

Boolean

This function is deprecated.

Unit

This function is deprecated.

Unit

This function is deprecated.

Unit
onPictureInPictureModeChanged(
    isInPictureInPictureMode: Boolean,
    newConfig: Configuration!
)

This function is deprecated.

Unit

This function is deprecated.

Unit
onRequestPermissionsResult(
    requestCode: Int,
    permissions: Array<String!>!,
    grantResults: IntArray!
)

This function is deprecated.

Unit

This function is deprecated.

Unit

This function is deprecated.

Unit
onTrimMemory(level: Int)

This function is deprecated.

Unit
onViewCreated(view: View!, savedInstanceState: Bundle!)

This function is deprecated.

Unit
onViewStateRestored(savedInstanceState: Bundle!)

This function is deprecated.

Unit

This function is deprecated.

Unit

This function is deprecated.

Unit
requestPermissions(permissions: Array<String!>!, requestCode: Int)

This function is deprecated.

Unit

This function is deprecated.

Unit

This function is deprecated.

Unit

This function is deprecated.

Unit

This function is deprecated.

Unit

This function is deprecated.

Unit

This function is deprecated.

Unit

This function is deprecated.

Unit

This function is deprecated.

Unit

This function is deprecated.

Unit
setMenuVisibility(menuVisible: Boolean)

This function is deprecated.

Unit

This function is deprecated.

Unit

This function is deprecated.

Unit

This function is deprecated.

Unit

This function is deprecated.

Unit

This function is deprecated.

Unit
setTargetFragment(fragment: Fragment!, requestCode: Int)

This function is deprecated.

Unit
setUserVisibleHint(isVisibleToUser: Boolean)

This function is deprecated.

Boolean

This function is deprecated.

Unit

This function is deprecated.

Unit
startActivityForResult(intent: Intent!, requestCode: Int)

This function is deprecated.

Unit
startIntentSenderForResult(
    intent: IntentSender!,
    requestCode: Int,
    fillInIntent: Intent!,
    flagsMask: Int,
    flagsValues: Int,
    extraFlags: Int,
    options: Bundle!
)

This function is deprecated.

Unit

This function is deprecated.

String!

This function is deprecated.

Unit

This function is deprecated.

Constants

EXTRA_UI_STYLE

Added in 1.1.0
Deprecated in 1.1.0
const val EXTRA_UI_STYLE = "uiStyle": String!

Fragment argument name for UI style. The argument value is persisted in fragment state and used to select fragment transition. The value is initially UI_STYLE_ENTRANCE and might be changed in one of the three helper functions:

Argument value can be either:

UI_STYLE_ACTIVITY_ROOT

Added in 1.1.0
Deprecated in 1.1.0
const val UI_STYLE_ACTIVITY_ROOT = 2: Int

One possible value of argument EXTRA_UI_STYLE. This is the case that we show first GuidedStepFragment in a separate activity. The default behavior of this style:

  • Enter transition is assigned null (will rely on activity transition), exit transition is same as UI_STYLE_ENTRANCE. Note: Changing exit transition by UI style is not working because fragment transition asks for exit transition before UI style is restored in Fragment.onCreate().

UI_STYLE_DEFAULT

Added in 1.1.0
Deprecated in 1.1.0
const val UI_STYLE_DEFAULT = 0: Int

UI_STYLE_ENTRANCE

Added in 1.1.0
Deprecated in 1.1.0
const val UI_STYLE_ENTRANCE = 1: Int

Default value for argument EXTRA_UI_STYLE. The default value is assigned in GuidedStepFragment constructor. This is the case that we show GuidedStepFragment on top of other content. The default behavior of this style:

  • Enter transition slides in from two sides, exit transition slide out to START(left). Background will be faded in. Note: Changing exit transition by UI style is not working because fragment transition asks for exit transition before UI style is restored in Fragment .onCreate().
When popping multiple GuidedStepFragment, finishGuidedStepFragments also changes the top GuidedStepFragment to UI_STYLE_ENTRANCE in order to run the return transition (reverse of enter transition) of UI_STYLE_ENTRANCE.

UI_STYLE_REPLACE

Added in 1.1.0
Deprecated in 1.1.0
const val UI_STYLE_REPLACE = 0: Int

This is the case that we use GuidedStepFragment to replace another existing GuidedStepFragment when moving forward to next step. Default behavior of this style is:

  • Enter transition slides in from END(right), exit transition same as UI_STYLE_ENTRANCE.

Public constructors

GuidedStepFragment

Added in 1.1.0
Deprecated in 1.1.0
GuidedStepFragment()

Public functions

add

Added in 1.1.0
Deprecated in 1.1.0
java-static fun add(fragmentManager: FragmentManager, fragment: GuidedStepFragment): Int

Adds the specified GuidedStepFragment to the fragment stack, replacing any existing GuidedStepFragments in the stack, and configuring the fragment-to-fragment custom transitions. A backstack entry is added, so the fragment will be dismissed when BACK key is pressed.

Note: currently fragments added using this method must be created programmatically rather than via XML.

Parameters
fragmentManager: FragmentManager

The FragmentManager to be used in the transaction.

fragment: GuidedStepFragment

The GuidedStepFragment to be inserted into the fragment stack.

Returns
Int

The ID returned by the call FragmentTransaction.commit.

add

Added in 1.1.0
Deprecated in 1.1.0
java-static fun add(
    fragmentManager: FragmentManager,
    fragment: GuidedStepFragment,
    id: Int
): Int

Adds the specified GuidedStepFragment to the fragment stack, replacing any existing GuidedStepFragments in the stack, and configuring the fragment-to-fragment custom transitions. A backstack entry is added, so the fragment will be dismissed when BACK key is pressed.

Note: currently fragments added using this method must be created programmatically rather than via XML.

Parameters
fragmentManager: FragmentManager

The FragmentManager to be used in the transaction.

fragment: GuidedStepFragment

The GuidedStepFragment to be inserted into the fragment stack.

id: Int

The id of container to add GuidedStepFragment, can be android.R.id.content.

Returns
Int

The ID returned by the call FragmentTransaction.commit.

addAsRoot

Added in 1.1.0
Deprecated in 1.1.0
java-static fun addAsRoot(activity: Activity, fragment: GuidedStepFragment, id: Int): Int

Adds the specified GuidedStepFragment as content of Activity; no backstack entry is added so the activity will be dismissed when BACK key is pressed. The method is typically called in Activity.onCreate() when savedInstanceState is null. When savedInstanceState is not null, the Activity is being restored, do not call addAsRoot() to duplicate the Fragment restored by FragmentManager. UI_STYLE_ACTIVITY_ROOT is assigned. Note: currently fragments added using this method must be created programmatically rather than via XML.

Parameters
activity: Activity

The Activity to be used to insert GuidedstepFragment.

fragment: GuidedStepFragment

The GuidedStepFragment to be inserted into the fragment stack.

id: Int

The id of container to add GuidedStepFragment, can be android.R.id.content.

Returns
Int

The ID returned by the call FragmentTransaction.commit, or -1 there is already GuidedStepFragment.

collapseAction

Added in 1.1.0
Deprecated in 1.1.0
fun collapseAction(withTransition: Boolean): Unit

Collapse action which either has a sub actions list or action with hasEditableActivatorView is true.

Parameters
withTransition: Boolean

True to run transition animation, false otherwise.

collapseSubActions

Added in 1.1.0
Deprecated in 1.1.0
fun collapseSubActions(): Unit

Collapse sub actions list.

See also
getSubActions

expandAction

Added in 1.1.0
Deprecated in 1.1.0
fun expandAction(action: GuidedAction, withTransition: Boolean): Unit

Expand a given action with sub actions list or hasEditableActivatorView is true. The method must be called after onCreateView creates fragment view.

Parameters
action: GuidedAction

GuidedAction to expand.

withTransition: Boolean

True to run transition animation, false otherwise.

expandSubActions

Added in 1.1.0
Deprecated in 1.1.0
fun expandSubActions(action: GuidedAction): Unit

Expand a given action's sub actions list.

Parameters
action: GuidedAction

GuidedAction to expand.

See also
expandAction

findActionById

Added in 1.1.0
Deprecated in 1.1.0
fun findActionById(id: Long): GuidedAction?

Find GuidedAction by Id.

Parameters
id: Long

Id of the action to search.

Returns
GuidedAction?

GuidedAction object or null if not found.

findActionPositionById

Added in 1.1.0
Deprecated in 1.1.0
fun findActionPositionById(id: Long): Int

Find GuidedAction position in array by Id.

Parameters
id: Long

Id of the action to search.

Returns
Int

position of GuidedAction object in array or -1 if not found.

findButtonActionById

Added in 1.1.0
Deprecated in 1.1.0
fun findButtonActionById(id: Long): GuidedAction?

Find button GuidedAction by Id.

Parameters
id: Long

Id of the button action to search.

Returns
GuidedAction?

GuidedAction object or null if not found.

findButtonActionPositionById

Added in 1.1.0
Deprecated in 1.1.0
fun findButtonActionPositionById(id: Long): Int

Find button GuidedAction position in array by Id.

Parameters
id: Long

Id of the button action to search.

Returns
Int

position of GuidedAction object in array or -1 if not found.

finishGuidedStepFragments

Added in 1.1.0
Deprecated in 1.1.0
fun finishGuidedStepFragments(): Unit

Convenient method to close GuidedStepFragments on top of other content or finish Activity if GuidedStepFragments were started in a separate activity. Pops all stack entries including UI_STYLE_ENTRANCE; if UI_STYLE_ENTRANCE is not found, finish the activity. Note that this method must be paired with add which sets up the stack entry name for finding which fragment we need to pop back to.

getActionItemView

Added in 1.1.0
Deprecated in 1.1.0
fun getActionItemView(position: Int): View?

Returns the view corresponding to the action at the indicated position in the list of actions for this fragment.

Parameters
position: Int

The integer position of the action of interest.

Returns
View?

The View corresponding to the action at the indicated position, or null if that action is not currently onscreen.

getActions

Added in 1.1.0
Deprecated in 1.1.0
fun getActions(): (Mutable)List<GuidedAction!>

Returns the list of GuidedActions that the user may take in this fragment.

Returns
(Mutable)List<GuidedAction!>

The list of GuidedActions for this fragment.

getButtonActionItemView

Added in 1.1.0
Deprecated in 1.1.0
fun getButtonActionItemView(position: Int): View?

Returns the view corresponding to the button action at the indicated position in the list of actions for this fragment.

Parameters
position: Int

The integer position of the button action of interest.

Returns
View?

The View corresponding to the button action at the indicated position, or null if that action is not currently onscreen.

getButtonActions

Added in 1.1.0
Deprecated in 1.1.0
fun getButtonActions(): (Mutable)List<GuidedAction!>

Returns the list of button GuidedActions that the user may take in this fragment.

Returns
(Mutable)List<GuidedAction!>

The list of button GuidedActions for this fragment.

getCurrentGuidedStepFragment

Added in 1.1.0
Deprecated in 1.1.0
java-static fun getCurrentGuidedStepFragment(fm: FragmentManager): GuidedStepFragment?

Returns the current GuidedStepFragment on the fragment transaction stack.

Returns
GuidedStepFragment?

The current GuidedStepFragment, if any, on the fragment transaction stack.

getGuidanceStylist

Added in 1.1.0
Deprecated in 1.1.0
fun getGuidanceStylist(): GuidanceStylist

Returns the GuidanceStylist that displays guidance information for the user.

Returns
GuidanceStylist

The GuidanceStylist for this fragment.

getGuidedActionsStylist

Added in 1.1.0
Deprecated in 1.1.0
fun getGuidedActionsStylist(): GuidedActionsStylist

Returns the GuidedActionsStylist that displays the actions the user may take.

Returns
GuidedActionsStylist

The GuidedActionsStylist for this fragment.

getGuidedButtonActionsStylist

Added in 1.1.0
Deprecated in 1.1.0
fun getGuidedButtonActionsStylist(): GuidedActionsStylist

Returns the GuidedActionsStylist that displays the button actions the user may take.

Returns
GuidedActionsStylist

The GuidedActionsStylist for this fragment.

getSelectedActionPosition

Added in 1.1.0
Deprecated in 1.1.0
fun getSelectedActionPosition(): Int

Returns the position if the currently selected GuidedAction.

Returns
Int

position The integer position of the currently selected action.

getSelectedButtonActionPosition

Added in 1.1.0
Deprecated in 1.1.0
fun getSelectedButtonActionPosition(): Int

Returns the position if the currently selected button GuidedAction.

Returns
Int

position The integer position of the currently selected button action.

getUiStyle

Added in 1.1.0
Deprecated in 1.1.0
fun getUiStyle(): Int

Read UI style from fragment arguments. Default value is UI_STYLE_ENTRANCE when fragment is first initialized. UI style is used to choose different fragment transition animations and determine if this is the first GuidedStepFragment on backstack.

isExpanded

Added in 1.1.0
Deprecated in 1.1.0
fun isExpanded(): Boolean
Returns
Boolean

True if is current expanded including subactions list or action with hasEditableActivatorView is true.

isFocusOutEndAllowed

Added in 1.1.0
Deprecated in 1.1.0
fun isFocusOutEndAllowed(): Boolean

Returns true if allows focus out of end edge of GuidedStepFragment, false otherwise. Default value is false, the reason is to disable FocusFinder to find focusable views beneath content of GuidedStepFragment. Subclass may override.

Returns
Boolean

True if allows focus out of end edge of GuidedStepFragment.

isFocusOutStartAllowed

Added in 1.1.0
Deprecated in 1.1.0
fun isFocusOutStartAllowed(): Boolean

Returns true if allows focus out of start edge of GuidedStepFragment, false otherwise. Default value is false, the reason is to disable FocusFinder to find focusable views beneath content of GuidedStepFragment. Subclass may override.

Returns
Boolean

True if allows focus out of start edge of GuidedStepFragment.

isSubActionsExpanded

Added in 1.1.0
Deprecated in 1.1.0
fun isSubActionsExpanded(): Boolean
Returns
Boolean

True if the sub actions list is expanded, false otherwise.

notifyActionChanged

Added in 1.1.0
Deprecated in 1.1.0
fun notifyActionChanged(position: Int): Unit

Notify an action has changed and update its UI.

Parameters
position: Int

Position of the GuidedAction in array.

notifyButtonActionChanged

Added in 1.1.0
Deprecated in 1.1.0
fun notifyButtonActionChanged(position: Int): Unit

Notify an button action has changed and update its UI.

Parameters
position: Int

Position of the button GuidedAction in array.

onCreate

Added in 1.1.0
Deprecated in 1.1.0
fun onCreate(savedInstanceState: Bundle?): Unit

onCreateActions

Added in 1.1.0
Deprecated in 1.1.0
fun onCreateActions(
    actions: (Mutable)List<GuidedAction!>,
    savedInstanceState: Bundle?
): Unit

Fills out the set of actions available to the user. This hook is called during onCreate. The default leaves the list of actions empty; subclasses should override.

Parameters
actions: (Mutable)List<GuidedAction!>

A non-null, empty list ready to be populated.

savedInstanceState: Bundle?

The saved instance state from onCreate.

onCreateActionsStylist

Added in 1.1.0
Deprecated in 1.1.0
fun onCreateActionsStylist(): GuidedActionsStylist

Creates the presenter used to style the guided actions panel. The default implementation returns a basic GuidedActionsStylist.

Returns
GuidedActionsStylist

The GuidedActionsStylist used in this fragment.

onCreateBackgroundView

Added in 1.1.0
Deprecated in 1.1.0
fun onCreateBackgroundView(
    inflater: LayoutInflater,
    container: ViewGroup?,
    savedInstanceState: Bundle?
): View?

Called by onCreateView to inflate background view. Default implementation loads view from lb_guidedstep_background which holds a reference to guidedStepBackground.

Parameters
inflater: LayoutInflater

LayoutInflater to load background view.

container: ViewGroup?

Parent view of background view.

savedInstanceState: Bundle?
Returns
View?

Created background view or null if no background.

onCreateButtonActions

Added in 1.1.0
Deprecated in 1.1.0
fun onCreateButtonActions(
    actions: (Mutable)List<GuidedAction!>,
    savedInstanceState: Bundle?
): Unit

Fills out the set of actions shown at right available to the user. This hook is called during onCreate. The default leaves the list of actions empty; subclasses may override.

Parameters
actions: (Mutable)List<GuidedAction!>

A non-null, empty list ready to be populated.

savedInstanceState: Bundle?

The saved instance state from onCreate.

onCreateButtonActionsStylist

Added in 1.1.0
Deprecated in 1.1.0
fun onCreateButtonActionsStylist(): GuidedActionsStylist

Creates the presenter used to style a sided actions panel for button only. The default implementation returns a basic GuidedActionsStylist.

Returns
GuidedActionsStylist

The GuidedActionsStylist used in this fragment.

onCreateGuidance

Added in 1.1.0
Deprecated in 1.1.0
fun onCreateGuidance(savedInstanceState: Bundle?): GuidanceStylist.Guidance

Returns the information required to provide guidance to the user. This hook is called during onCreateView. May be overridden to return a custom subclass of for use in a subclass of GuidanceStylist. The default returns a Guidance object with empty fields; subclasses should override.

Parameters
savedInstanceState: Bundle?

The saved instance state from onCreateView.

Returns
GuidanceStylist.Guidance

The Guidance object representing the information used to guide the user.

onCreateGuidanceStylist

Added in 1.1.0
Deprecated in 1.1.0
fun onCreateGuidanceStylist(): GuidanceStylist

Creates the presenter used to style the guidance panel. The default implementation returns a basic GuidanceStylist.

Returns
GuidanceStylist

The GuidanceStylist used in this fragment.

onCreateView

Added in 1.1.0
Deprecated in 1.1.0
fun onCreateView(
    inflater: LayoutInflater!,
    container: ViewGroup?,
    savedInstanceState: Bundle!
): View?

onDestroyView

Added in 1.1.0
Deprecated in 1.1.0
fun onDestroyView(): Unit

onGuidedActionClicked

Added in 1.1.0
Deprecated in 1.1.0
fun onGuidedActionClicked(action: GuidedAction): Unit

Callback invoked when an action is taken by the user. Subclasses should override in order to act on the user's decisions.

Parameters
action: GuidedAction

The chosen action.

onGuidedActionEditCanceled

Added in 1.1.0
Deprecated in 1.1.0
fun onGuidedActionEditCanceled(action: GuidedAction): Unit

Callback invoked when an action has been canceled editing, for example when user closes IME window by BACK key. Default implementation calls deprecated method onGuidedActionEdited.

Parameters
action: GuidedAction

The action which has been canceled editing.

onGuidedActionEdited

Added in 1.1.0
Deprecated in 1.1.0
fun onGuidedActionEdited(action: GuidedAction!): Unit

Callback invoked when an action's title or description has been edited, this happens either when user clicks confirm button in IME or user closes IME window by BACK key.

onGuidedActionEditedAndProceed

Added in 1.1.0
Deprecated in 1.1.0
fun onGuidedActionEditedAndProceed(action: GuidedAction): Long

Callback invoked when an action has been edited, for example when user clicks confirm button in IME window. Default implementation calls deprecated method onGuidedActionEdited and returns ACTION_ID_NEXT.

Parameters
action: GuidedAction

The action that has been edited.

Returns
Long

ID of the action will be focused or ACTION_ID_NEXT, ACTION_ID_CURRENT.

onGuidedActionFocused

Added in 1.1.0
Deprecated in 1.1.0
fun onGuidedActionFocused(action: GuidedAction): Unit

Callback invoked when an action is focused (made to be the current selection) by the user.

onProvideTheme

Added in 1.1.0
Deprecated in 1.1.0
fun onProvideTheme(): Int

Returns the theme used for styling the fragment. The default returns -1, indicating that the host Activity's theme should be used.

Returns
Int

The theme resource ID of the theme to use in this fragment, or -1 to use the host Activity's theme.

onResume

Added in 1.1.0
Deprecated in 1.1.0
fun onResume(): Unit

onSaveInstanceState

Added in 1.1.0
Deprecated in 1.1.0
fun onSaveInstanceState(outState: Bundle!): Unit

onSubGuidedActionClicked

Added in 1.1.0
Deprecated in 1.1.0
fun onSubGuidedActionClicked(action: GuidedAction): Boolean

Callback invoked when an action in sub actions is taken by the user. Subclasses should override in order to act on the user's decisions. Default return value is true to close the sub actions list.

Parameters
action: GuidedAction

The chosen action.

Returns
Boolean

true to collapse the sub actions list, false to keep it expanded.

openInEditMode

Added in 1.1.0
Deprecated in 1.1.0
fun openInEditMode(action: GuidedAction?): Unit

Opens the provided action in edit mode and raises ime. This can be used to programmatically skip the extra click required to go into edit mode. This method can be invoked in onCreateView.

popBackStackToGuidedStepFragment

Added in 1.1.0
Deprecated in 1.1.0
fun popBackStackToGuidedStepFragment(
    guidedStepFragmentClass: Class<Any!>,
    flags: Int
): Unit

Convenient method to pop to fragment with Given class.

Parameters
guidedStepFragmentClass: Class<Any!>

Name of the Class of GuidedStepFragment to pop to.

flags: Int

Either 0 or POP_BACK_STACK_INCLUSIVE.

setActions

Added in 1.1.0
Deprecated in 1.1.0
fun setActions(actions: (Mutable)List<GuidedAction!>): Unit

Sets the list of GuidedActions that the user may take in this fragment. Uses DiffCallback set by setActionsDiffCallback.

Parameters
actions: (Mutable)List<GuidedAction!>

The list of GuidedActions for this fragment.

setActionsDiffCallback

Added in 1.1.0
Deprecated in 1.1.0
fun setActionsDiffCallback(diffCallback: DiffCallback<GuidedAction!>?): Unit

Sets the RecyclerView DiffCallback used when setActions is called. By default GuidedStepFragment uses androidx.leanback.widget.GuidedActionDiffCallback. Sets it to null if app wants to refresh the whole list.

Parameters
diffCallback: DiffCallback<GuidedAction!>?

DiffCallback used in setActions.

setButtonActions

Added in 1.1.0
Deprecated in 1.1.0
fun setButtonActions(actions: (Mutable)List<GuidedAction!>): Unit

Sets the list of button GuidedActions that the user may take in this fragment.

Parameters
actions: (Mutable)List<GuidedAction!>

The list of button GuidedActions for this fragment.

setSelectedActionPosition

Added in 1.1.0
Deprecated in 1.1.0
fun setSelectedActionPosition(position: Int): Unit

Scrolls the action list to the position indicated, selecting that action's view.

Parameters
position: Int

The integer position of the action of interest.

setSelectedButtonActionPosition

Added in 1.1.0
Deprecated in 1.1.0
fun setSelectedButtonActionPosition(position: Int): Unit

Scrolls the action list to the position indicated, selecting that button action's view.

Parameters
position: Int

The integer position of the button action of interest.

setUiStyle

Added in 1.1.0
Deprecated in 1.1.0
fun setUiStyle(style: Int): Unit

Set UI style to fragment arguments. Default value is UI_STYLE_ENTRANCE when fragment is first initialized. UI style is used to choose different fragment transition animations and determine if this is the first GuidedStepFragment on backstack. In most cases app does not directly call this method, app calls helper function add. However if the app creates Fragment transaction and controls backstack by itself, it would need call setUiStyle() to select the fragment transition to use.

Protected functions

onAddSharedElementTransition

Added in 1.1.0
Deprecated in 1.1.0
protected fun onAddSharedElementTransition(
    ft: FragmentTransaction,
    disappearing: GuidedStepFragment
): Unit

Called when this fragment is added to FragmentTransaction with UI_STYLE_REPLACE (aka when the GuidedStepFragment replacing an existing GuidedStepFragment). Default implementation establishes connections between action background views to morph action background bounds change from disappearing GuidedStepFragment into this GuidedStepFragment. The default implementation heavily relies on GuidedActionsStylist's layout, app may override this method when modifying the default layout of GuidedActionsStylist.

Parameters
ft: FragmentTransaction

The FragmentTransaction to add shared element.

disappearing: GuidedStepFragment

The disappearing fragment.

onProvideFragmentTransitions

Added in 1.1.0
Deprecated in 1.1.0
protected fun onProvideFragmentTransitions(): Unit

Called by Constructor to provide fragment transitions. The default implementation assigns transitions based on getUiStyle:

  • UI_STYLE_REPLACE Slide from/to end(right) for enter transition, slide from/to start(left) for exit transition, shared element enter transition is set to ChangeBounds.
  • UI_STYLE_ENTRANCE Enter transition is set to slide from both sides, exit transition is same as UI_STYLE_REPLACE, no shared element enter transition.
  • UI_STYLE_ACTIVITY_ROOT Enter transition is set to null and app should rely on activity transition, exit transition is same as UI_STYLE_REPLACE, no shared element enter transition.

The default implementation heavily relies on GuidedActionsStylist and GuidanceStylist layout, app may override this method when modifying the default layout of GuidedActionsStylist or GuidanceStylist.

TIP: because the fragment view is removed during fragment transition, in general app cannot use two Visibility transition together. Workaround is to create your own Visibility transition that controls multiple animators (e.g. slide and fade animation in one Transition class).