Manza
Manza

Reputation: 3527

Google Glass: Select "Cancel" or "OK" from Dialog Box

How can I move from the options of a system dialog box like this for example with Google Glass XE16?

enter image description here

With XE12 I was able to move from the options swiping forward and back. but after the update to XE16 it doesn't work anymore.

I'm only able to select the first option that is focused (in this case Cancel).

UPDATE: XE17 - Still the same issue

Upvotes: 4

Views: 652

Answers (1)

Jeff Tang
Jeff Tang

Reputation: 1804

If this is your own app, whether it's in native GDK code or code ported from some Android app, you can follow the steps below to support the navigation of listview, buttons, etc and non-GDK UI components:

  1. Add GestureDetector mGestureDetector;
  2. Add mGestureDetector = createGestureDetector(this); in onCreate;
  3. Define two methods:

List item

private GestureDetector createGestureDetector(Context context) {
    GestureDetector gestureDetector = new GestureDetector(context);

    gestureDetector.setBaseListener( new GestureDetector.BaseListener() {
        @Override
        public boolean onGesture(Gesture gesture) {
            if (gesture == Gesture.TAP) { 
                process(mListView.getSelectedItem());
                return true;
            } else if (gesture == Gesture.SWIPE_RIGHT) {
                mListView.setSelection(mListView.getSelectedItemPosition()+1);
                return true;
            } else if (gesture == Gesture.SWIPE_LEFT) {
                mListView.setSelection(mListView.getSelectedItemPosition()-1);
                return true;
            }
            return false;
        }
    });

    return gestureDetector;
}

// this method is required for tap on touchpad to work!
public boolean onGenericMotionEvent(MotionEvent event) {
    if (mGestureDetector != null) {
        return mGestureDetector.onMotionEvent(event);
    }
    return false;
}           

A complete working sample is available at https://github.com/xjefftang/launchy/commit/66f17bd5bf920800ce277df5eeb6ea912b877692

Upvotes: 2

Related Questions