1

According the the API docs, all peek cards will only be "a single line tall" when PEEK_MODE_SHORT is set. So this means every peek card will occupy a constant of screen real estate for a particular device.

I plan to leverage this on my watch face by placing the most important info in the area that's guaranteed not to be covered by a card (and the non-critial info in the space which could be covered by a card).

The problem is I don't know how to determine how much space the peek cards take until onPeekCardPositionUpdate(), which is too late, because I want the rest of the layout to take into consideration where the peek cards will go.

TL;DR - Any ideas on how to get the peek card positions before onPeekCardPosition() is called?

EDIT: The reason I need the peek card height is because I'm looking to ensure that something will be fully covered when the peek card is displayed. Like #1 below: dotted line is where the peek card would be

YasharBahman
  • 289
  • 3
  • 14

1 Answers1

3

No, we didn't provide any API to determine the height of the peek card. You should use onPeekCardPositionUpdate() and make your watch face adjust, when it receives the notification.

I understand that you would like to always put your content above the peek card and be done with it. However, this is not a good idea - you will be wasting real estate available to you on the screen. The user might decide to disable the peeking (there are options available for this) after which you will be left with empty space at the bottom of the screen. Or the user might not have cards in the stream, in which case again, you will be left with empty space at the bottom.

This callback is provided for a reason, so you can dynamically adjust your watch face both when a card is peeking and when it's not and allow users to have best experience in either case.

EDIT:

In your specific case, I would recommend doing this: in your drawing code check the current bounds of the peek card (getPeekCardPosition()). If they are (0-0, 0-0), this means there is no peek card and you can draw the optional piece of content. If the bounds are different, don't draw it. It should be as easy as that. You also want to trigger redraw when the callback about the card bounds comes.

gruszczy
  • 40,948
  • 31
  • 128
  • 181
  • 1
    Thanks for the info. Actually, it's not that I want to just place my content above the peek card and be done with it. I have 4 pieces of info I want to display. 3 of them are critical and 1 is a "nice to have". However, there isn't enough room to display all 4 when the peek card is displayed. So Instead of attempt to cram it all together, I just ensure the least important line of info is statically placed at the bottom. This ensures that when the peek card is displayed, it's covered entirely, which is much cleaner than only cutting off a portion of it. – YasharBahman Mar 05 '15 at 03:36
  • I suppose I can just _not_ show the last line until a peek card has been displayed for the first time. Then, when onPeekCardPositionUpdate() is called, I can save the value and adjust my spacing afterwards. Doesn't make for a great first run experience but it has the tremendous value add of consistency. E.g. if the user wants to see what time it is, they just look at the center of their wrist (as opposed to _sometimes_ looking in the center and others looking elsewhere due to a layout shift) – YasharBahman Mar 05 '15 at 03:48
  • Thanks for the suggestion @gruszczy! I actually do that today :) However, that still has the potential issue where the optional info would not have been fully covered by the peek card. It's aesthetically displeasing if the optional info simply "disappears" because a peek card occludes it partially. It doesn't follow the material design DL the rest of the OS uses. I added an image to my original post to show highlight what I'm talking about. -- I really don't think there's a way for me to accomplish this without knowing the height beforehand though. – YasharBahman Mar 06 '15 at 05:03
  • 1
    I understand. I will file a bug on our side and discuss if we could add some additional API for this, to cover this situation. In the meantime: you don't have to disappear the optional info instantly. Instead, consider animating the disappearance (say, fading out). This should be more material (things don't just disappear, but instead the transition is clear to the user). – gruszczy Mar 06 '15 at 18:40
  • Wow, @gruszczy! I'm very impressed with that level of agility! The idea of fading it in/out is a good idea. I'll look into that and see if there're any libraries I can use for that. Thanks for all the help. – YasharBahman Mar 09 '15 at 03:16