0

EDIT: After the excellent answer below by Prisoner I'm leaving the question for my humility and for search posterity, but please note I made a mistake in the formation of my question. I misunderstood one piece of background documentation - multiple menu Items per card ARE supported.

I am trying to place a fixed card in the pinned group (left of the home card) and let the user select it and submit a reply. The application thinking is that this lets the user submit commands to the web app which the web app then processes and sends response cards to the user.

I've done the research to know I can't set isPinned to true directly from my app, instead that has to be done by the user via a menuItem. I have that working. For example this works to let a user pin my card:

{
  "text": "Test pinnable card",
  "menuItems": [
    {
      "action": "TOGGLE_PINNED",
      "values": [{
        "displayName": "Pin Card",
        "iconUrl": "https://<Graphics URL>"
      }]
    }
  ]
}

That is working and arrives at my Glass just fine and I can pin and unpin it no problem.

But once I've set that menuItem to allow a user to pin the card, is there a way to let the user reply? According to this entry there can only be one menuItem per card. That would seem to imply any pinned card can't have menu items and therefore no reply functions (at least I don't know another way to do replies).

I would very much like to let the user select the card and send voice replies. I can do that in a NON-PINNED card using this menuItem:

"menuItems": [
    {
      "action": "REPLY",
      "values": [
        {
          "displayName": "Search",
          "iconUrl": "https:<Graphics URL>"
        }
      ]
    }

So the question is basically whether anybody knows a way to either load both menuItems onto a card or to somehow add or exchange to apply the second menuItem once a card is pinned. My guess would be I can't replace the menuItem after pinning or it could be abused to make cards a user couldn't unpin, but it also seems kind of useless to make any pinned card not have actions.

My apologies if there are "obvious" workarounds, I'm plumb out of ideas.

I have glass, running Glassware on AppEngine, and can test any theories people have. This seems like a pretty basic need for Glassware that would be used alot. I'm working on an enterprise document sorting and data finding application, for those who are curious.

Community
  • 1
  • 1
Ezekiel Kruglick
  • 4,496
  • 38
  • 48

1 Answers1

2

A few things.

First, the answer you referenced doesn't say that there can be only one menuItem per card. What it says is there can only be one menu per set of htmlPages, meaning that each card had to have the same menu. HtmlPages are now deprecated in favor of HTML that is split, partly because of the confusion of that question.

Second, you can absolutely have more than one item in the menuItems setting. Hence the plural and use of the array. :)

Third, it looks like you are trying to set "values" for card actions that do not take values (TOGGLE_PINNED and REPLY). Values are only needed for CUSTOM actions.

Fourth, make sure that you have a "creator" set for the REPLY type.

See https://developers.google.com/glass/v1/reference/timeline/insert for details, but in general, what you will need to do is to set the menuItems field to an array, with each element in the array having a different action. You will also need a creator field set to reply to. So something like this should work (although I haven't tested this specific one):

{
  "text": "Test pinnable card",
  "creator": {
    "id": "harold"
    "displayName": "Harold Penguin",
    "imageUrls": ["https://developers.google.com/glass/images/harold.jpg"]
  },
  "menuItems": [
    {
      "action": "TOGGLE_PINNED"
    },{
      "action": "REPLY"
    },{
      "action": "CUSTOM",
      "values": [
        {
          "displayName": "Search",
          "iconUrl": "https:"
        }
      ]
    }
  ]
}

Finally, you may wish to reconsider using a pinned card to do this. This method harkens back to a very app-centric way of doing things, which is somewhat counter to how Glass tends to work. If you would like to add voice commands, consider registering contacts that can accept commands. See https://developers.google.com/glass/v1/reference/contacts for more details.

Prisoner
  • 49,922
  • 7
  • 53
  • 105
  • Thanks! Great! As for the pinning vs contact issue the first implementation did use a contact. As an enterprise app there was concern from various stakeholders about using sharing. The issues were the flow of "make a note and share it to the corporate app" - when sometimes people would share to the wrong contact by sliding while tapping. The pinning was considered more appropriate for a corp app that should be used a lot - just "talk to the logo". I actually have both now, chosen by configuration variable so this is really for testing and comparison and we'll see what UX wins... – Ezekiel Kruglick Sep 02 '13 at 15:42