Skip to content
com.iristick.smartglass.support.app

Class HudPresentation

All Implemented Interfaces:
DialogInterface, KeyEvent.Callback, View.OnCreateContextMenuListener, Window.Callback

public class HudPresentation
extends Presentation
Base class for custom UI to be presented on the Iristick heads-up display.

This class is meant to be subclassed. Instances should be created in HudActivity.onCreateHudPresentation(Display).

A heads-up presentation is a special kind of dialog whose purpose is to present content on the heads-up display of connected Iristick smart glasses. A HudPresentation is associated with the target Display at creation time and configures its context and resource configuration according to the display's metrics.

Notably, the Context of a heads-up presentation is different from the context of the containing activity. It is important to inflate the layout of a presentation and load other resources using the presentation's own context to ensure that assets of the correct size and density for the heads-up display are loaded. The presentation context can be obtained by calling Dialog.getContext().

A heads-up presentation is automatically cancelled (see Dialog.cancel()) when the smart glasses are disconnected, or when the containing activity is paused.

Example:

 public class MyHudPresentation extends HudPresentation {
     public MyHudPresentation(@NonNull Context outerContext, @NonNull Display display) {
         super(outerContext, display);
     }

     protected void onCreate(Bundle savedInstanceState) {
         // Be sure to call the super class.
         super.onCreate(savedInstanceState);
         // Inflate the layout.
         setContentView(R.layout.my_hud_presentation);
     }

     public boolean onTouchEvent(@NonNull TouchEvent event) {
         if (event.getGestureCode() == TouchEvent.GESTURE_TAP) {
             // Do something
             return true;
         }
         return false;
     }
 }

Since:
Android API level 19

Nested Class Summary

Nested classes/interfaces inherited from interface android.content.DialogInterface

DialogInterface.OnCancelListener, DialogInterface.OnClickListener, DialogInterface.OnDismissListener, DialogInterface.OnKeyListener, DialogInterface.OnMultiChoiceClickListener, DialogInterface.OnShowListener

Field Summary

Fields inherited from interface android.content.DialogInterface

BUTTON_NEGATIVE, BUTTON_NEUTRAL, BUTTON_POSITIVE, BUTTON1, BUTTON2, BUTTON3

Constructor Summary

Constructor and Description
HudPresentation(Context outerContext, Display display) 
HudPresentation(Context outerContext, Display display, int theme) 

Method Summary

Modifier and Type Method and Description
int getTouchpadFlags()
boolean onTouchEvent(TouchEvent event)
Called to process touchpad events.

Methods inherited from class android.app.Presentation

getDisplay, getResources, onDisplayChanged, onDisplayRemoved, show

Methods inherited from class android.app.Dialog

addContentView, cancel, closeOptionsMenu, create, dismiss, dispatchGenericMotionEvent, dispatchKeyEvent, dispatchKeyShortcutEvent, dispatchPopulateAccessibilityEvent, dispatchTouchEvent, dispatchTrackballEvent, findViewById, getActionBar, getContext, getCurrentFocus, getLayoutInflater, getOwnerActivity, getSearchEvent, getVolumeControlStream, getWindow, hide, invalidateOptionsMenu, isShowing, onActionModeFinished, onActionModeStarted, onAttachedToWindow, onBackPressed, onContentChanged, onContextItemSelected, onContextMenuClosed, onCreateContextMenu, onCreateOptionsMenu, onCreatePanelMenu, onCreatePanelView, onDetachedFromWindow, onGenericMotionEvent, onKeyDown, onKeyLongPress, onKeyMultiple, onKeyShortcut, onKeyUp, onMenuItemSelected, onMenuOpened, onOptionsItemSelected, onOptionsMenuClosed, onPanelClosed, onPrepareOptionsMenu, onPreparePanel, onRestoreInstanceState, onSaveInstanceState, onSearchRequested, onSearchRequested, onTouchEvent, onTrackballEvent, onWindowAttributesChanged, onWindowFocusChanged, onWindowStartingActionMode, onWindowStartingActionMode, openContextMenu, openOptionsMenu, registerForContextMenu, requestWindowFeature, requireViewById, setCancelable, setCanceledOnTouchOutside, setCancelMessage, setContentView, setContentView, setContentView, setDismissMessage, setFeatureDrawable, setFeatureDrawableAlpha, setFeatureDrawableResource, setFeatureDrawableUri, setOnCancelListener, setOnDismissListener, setOnKeyListener, setOnShowListener, setOwnerActivity, setTitle, setTitle, setVolumeControlStream, takeKeyEvents, unregisterForContextMenu

Methods inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Methods inherited from interface android.view.Window.Callback

onPointerCaptureChanged, onProvideKeyboardShortcuts

Constructor Detail

HudPresentation

public HudPresentation(@NonNull
                       Context outerContext,
                       @NonNull
                       Display display)

HudPresentation

public HudPresentation(@NonNull
                       Context outerContext,
                       @NonNull
                       Display display,
                       int theme)

Method Detail

getTouchpadFlags

@CheckResult
public int getTouchpadFlags()
Called to obtain the flags to pass to Headset.registerTouchEventCallback(TouchEvent.Callback, Handler, int).

Override this method to customize the behavior of the touchpad. For example, if you want to capture the "swipe down" gesture, return Headset.TOUCHPAD_FLAG_OVERRIDE_ALL here.

Returns:
Combination of flag values to modify the standard touchpad behavior.

onTouchEvent

public boolean onTouchEvent(@NonNull
                            TouchEvent event)
Called to process touchpad events. Override this method to respond to events from the touchpad on Iristick smart glasses. When this method returns false, a default action will be taken, e.g., simulate a back button press on swipe down.
Parameters:
event - The touchpad event.
Returns:
true if this event was consumed, false to perform the default action for event.