4

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

Manza
  • 3,427
  • 4
  • 36
  • 57
  • 3
    I'm guessing its related to gesture issues in general with non-GDK UI components, which seem to be largely broken in XE16.x. Even the ListView, which supposedly is supported, is broken, and Google is saying they don't plan to fix it. See https://code.google.com/p/google-glass-api/issues/detail?id=484 – Sean Barbeau Apr 25 '14 at 22:13

1 Answers1

2

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

Jeff Tang
  • 1,804
  • 15
  • 16
  • 2
    This workaround covers the very narrow case of an immersion with a single ListView, but does not work for the original poster's use case (buttons) and does not work for anything more complicated (such as a mix of different widgets). – jimrandomh Apr 27 '14 at 02:47
  • Also, this is more of a hack for ListView - the result is the entire screen scrolling up/down one every time you swipe, so the selected item is always at the top of list (vs. the list only scrolling when the cursor reaches top/bottom of the page). Not the same as the original native experience. – Sean Barbeau Apr 28 '14 at 03:12
  • 2
    Unfortunately this doesn't solve the problem, because this is a system dialog box, not an app one – Manza Apr 28 '14 at 09:35