CarUiEntry

public abstract class CarUiEntry
extends Object

java.lang.Object
   ↳ android.car.app.menu.CarUiEntry


A base class for a car ui entry which is used for loading and manipulating common car app decor window (CarUi). A CarUi provider provides essential ui elements that a car app may want to use. The CarUi is loaded by apps at runtime, similar to a shared library, but via reflection through a class that extends CarUiEntry from a separate apk called CarUiProvider. Depending on the different platforms, the CarUiProvider may be different and can be customized by different car makers. However, it is required that a set of basic ui elements and functionalities exist in the CarUiProvider. This class defines the set of must have functions in a CarUiProvider.

Summary

Fields

protected final Context mAppContext

protected final Context mUiLibContext

Public constructors

CarUiEntry(Context uiLibContext, Context appContext)

Public methods

abstract void closeDrawer()

Close the car menu.

abstract View getContentView()

Return the content view.

abstract int getFragmentContainerId()

Return the id of the main container in which app can render its own content.

abstract CharSequence getSearchBoxText()

Returns the current user entered text in the search box.

abstract void hideMenuButton()

Hide the menu button.

abstract void hideTitle()

Hide the menu title.

abstract void onPause()

Called when activity's onPause is called.

abstract void onRestoreInstanceState(Bundle savedInstanceState)

Called when the activity's onRestoreInstanceState is called.

abstract void onResume()

Called when activity's onResume is called.

abstract void onSaveInstanceState(Bundle outState)

Called when the activity's onSaveInstanceState is called.

abstract void onStart()

Called when activity's onStart is called.

abstract void onStop()

Called when activity's onStop is called.

abstract void openDrawer()

Open the car menu.

abstract void restoreMenuDrawable()

Restore the menu button.

abstract void setAutoLightDarkMode()

Use automatic light/dark car theme based on ui mode.

abstract void setBackground(Bitmap bitmap)

Set the background bitmap.

abstract void setCarMenuCallbacks(CarMenuCallbacks callbacks)

Set CarMenuCallbacks from a car app for car menu interactions.

abstract void setDarkMode()

Use the dark car theme.

abstract void setLightMode()

Use the light car theme.

abstract void setMenuButtonBitmap(Bitmap bitmap)

Replace the menu button with the given bitmap.

abstract void setMenuButtonColor(int color)

Set the car menu button color.

abstract void setScrimColor(int color)

Set the color of the car menu scrim.

abstract void setSearchBoxColors(int backgroundColor, int searchLogoColor, int textColor, int hintTextColor)

Set the color of the search box.

abstract void setSearchBoxEditListener(SearchBoxEditListener listener)

Set the search box edit listener for monitoring input.

abstract void setSearchBoxEndView(View view)

Set the view in the end of the search box as the search result is loading.

abstract void setTitle(CharSequence title)

Set the title of the car menu.

abstract void showMenu(String id, String title)

Show the menu associated with the specified id, and set the car menu title.

abstract void showSearchBox(View.OnClickListener listener)

Show the search box and set the click listener for the search box.

abstract void showTitle()

Make the menu title visible.

abstract void showToast(String msg, long duration)

Show a toast message.

abstract EditText startInput(String hint, View.OnClickListener searchBoxClickListener)

Start input on the search box and show IME.

abstract void stopInput()

Called when input should be stopped.

Inherited methods

Fields

mAppContext

protected final Context mAppContext

mUiLibContext

protected final Context mUiLibContext

Public constructors

CarUiEntry

public CarUiEntry (Context uiLibContext, 
                Context appContext)

Parameters
uiLibContext Context

appContext Context

Public methods

closeDrawer

public abstract void closeDrawer ()

Close the car menu.

getContentView

public abstract View getContentView ()

Return the content view.

Returns
View

getFragmentContainerId

public abstract int getFragmentContainerId ()

Return the id of the main container in which app can render its own content.

Returns
int

getSearchBoxText

public abstract CharSequence getSearchBoxText ()

Returns the current user entered text in the search box.

Returns
CharSequence

hideMenuButton

public abstract void hideMenuButton ()

Hide the menu button.

hideTitle

public abstract void hideTitle ()

Hide the menu title.

onPause

public abstract void onPause ()

Called when activity's onPause is called.

onRestoreInstanceState

public abstract void onRestoreInstanceState (Bundle savedInstanceState)

Called when the activity's onRestoreInstanceState is called.

Parameters
savedInstanceState Bundle

onResume

public abstract void onResume ()

Called when activity's onResume is called.

onSaveInstanceState

public abstract void onSaveInstanceState (Bundle outState)

Called when the activity's onSaveInstanceState is called.

Parameters
outState Bundle

onStart

public abstract void onStart ()

Called when activity's onStart is called.

onStop

public abstract void onStop ()

Called when activity's onStop is called.

openDrawer

public abstract void openDrawer ()

Open the car menu.

restoreMenuDrawable

public abstract void restoreMenuDrawable ()

Restore the menu button.

setAutoLightDarkMode

public abstract void setAutoLightDarkMode ()

Use automatic light/dark car theme based on ui mode.

setBackground

public abstract void setBackground (Bitmap bitmap)

Set the background bitmap.

Parameters
bitmap Bitmap

setCarMenuCallbacks

public abstract void setCarMenuCallbacks (CarMenuCallbacks callbacks)

Set CarMenuCallbacks from a car app for car menu interactions.

Parameters
callbacks CarMenuCallbacks

setDarkMode

public abstract void setDarkMode ()

Use the dark car theme.

setLightMode

public abstract void setLightMode ()

Use the light car theme.

setMenuButtonBitmap

public abstract void setMenuButtonBitmap (Bitmap bitmap)

Replace the menu button with the given bitmap.

Parameters
bitmap Bitmap

setMenuButtonColor

public abstract void setMenuButtonColor (int color)

Set the car menu button color.

Parameters
color int

setScrimColor

public abstract void setScrimColor (int color)

Set the color of the car menu scrim.

Parameters
color int

setSearchBoxColors

public abstract void setSearchBoxColors (int backgroundColor, 
                int searchLogoColor, 
                int textColor, 
                int hintTextColor)

Set the color of the search box.

Parameters
backgroundColor int

searchLogoColor int

textColor int

hintTextColor int

setSearchBoxEditListener

public abstract void setSearchBoxEditListener (SearchBoxEditListener listener)

Set the search box edit listener for monitoring input.

Parameters
listener SearchBoxEditListener

setSearchBoxEndView

public abstract void setSearchBoxEndView (View view)

Set the view in the end of the search box as the search result is loading.

Parameters
view View

setTitle

public abstract void setTitle (CharSequence title)

Set the title of the car menu.

Parameters
title CharSequence

showMenu

public abstract void showMenu (String id, 
                String title)

Show the menu associated with the specified id, and set the car menu title.

Parameters
id String

title String

showSearchBox

public abstract void showSearchBox (View.OnClickListener listener)

Show the search box and set the click listener for the search box.

Parameters
listener View.OnClickListener

showTitle

public abstract void showTitle ()

Make the menu title visible.

showToast

public abstract void showToast (String msg, 
                long duration)

Show a toast message.

Parameters
msg String: text to show

duration long: toast duration in millisecond.

startInput

public abstract EditText startInput (String hint, 
                View.OnClickListener searchBoxClickListener)

Start input on the search box and show IME.

Parameters
hint String: hint text to show in the search box.

searchBoxClickListener View.OnClickListener: search box click listener.

Returns
EditText The search box EditText.

stopInput

public abstract void stopInput ()

Called when input should be stopped.