nicolas2k / google-glass-api

Automatically exported from code.google.com/p/google-glass-api
1 stars 0 forks source link

Trying to open a Context Menu instead of an Options Menu via GDK #398

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. As per https://developers.google.com/glass/develop/gdk/ui/immersion-menus 
create and inflate a menu.
2. call openOptionsMenu(). Menu shows.
3. Trying to perform the same via onCreateContextMenu() and 
(registerForContextMenu) and openContextMenu() yields in a black screen popping 
up with no menu rendered.

What is the expected output? What do you see instead?
I need to use a different context menu for specific gestures inside the 
immersion view than the options menu already configured, so would expect the 
rendering to occur just like the options menu, instead we get a black screen.

What version of the product are you using? On what operating system?
XE12.

Please provide any additional information below.

Original issue reported on code.google.com by roberto.andrade on 7 Feb 2014 at 12:33

GoogleCodeExporter commented 8 years ago
Hello,

Thanks for the report! Could you explain your use-case? Context menu are not 
supported by the GDK and this is by design.
If you want to modify the options menu according to some internal state, you 
should use the onPrepareOptionsMenu callback to modify the displayed menu.

You can take a look at the Timer sample that displays different options menu 
depending on the state of the Timer.

Best,
Alain

Original comment by ala...@google.com on 10 Feb 2014 at 4:59

GoogleCodeExporter commented 8 years ago
I have two different menu XMLs that I use for different purposes and
wouldn't want to merge them into a single one and toggle their visibility
according to the context of my activity.

I'm using the Options menu in a similar way to the Spinner Navigation
pattern in standard ActionBar android apps with especial gesture to pull it
in and using the tap gesture to get into the detail of the card. Then using
tap+hold for a contextual menu related to that card (and not the menu of
the whole activity) and onCreateOptionsMenu can't be used to inflate
different menus given its only called once on the activity life cycle. So
traditionally one would use a Context menu instead of Options menu if the
actions are being performed against a particular view/item in an
AdapterView.

That's why I was experimenting with Context menus and noticed the black
screen that is shown when inflating and displaying the menu in relation to
the view.

Original comment by roberto.andrade on 10 Feb 2014 at 5:37

GoogleCodeExporter commented 8 years ago
Hello,

Unfortunately, this is not something the GDK might support unless Glass has a 
different UI/UX for context menu.
For your use-case I would use a flag to track how the options menu got opened 
and use menu groups to easily toggle visibility and availability.

Setting as "RevisitLater" for when a new UI/UX is available for context menu.

Best,
Alain

Original comment by ala...@google.com on 10 Feb 2014 at 11:32

GoogleCodeExporter commented 8 years ago
That's ok, in my particular case, I'm actually resorting to doing this one the 
case where the menus are at least somewhat related to the point I can just 
group them and switch visibility based on it.

in case it interests anyone else looking for a solution to this, an alternative 
I follow as well is to launch another transparent activity like the samples 
suggest: https://developers.google.com/glass/develop/gdk/ui/live-card-menus 
with the appropriate alternative menu layout inflated.

This way I can have the proper context menu on the activity I'm on and when in 
need for the alternative item "context menu", I start the new activity with the 
appropriate intents to open the alternative "options menu" as an overlaid menu 
on the previous activity. So I get both menus, isolated without having to 
switch visibility on and off by inflating from the same resource.

Original comment by roberto.andrade on 10 Feb 2014 at 11:47