Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Unfolding the mystery

Unfolding the mystery

Foldable devices made quite a buzz from the start. In the beginning, because they were not very robust. Now, because they ARE robust enough for daily usage. And they make large screens pocketable. This talk shows you how to make beautiful user interfaces that work well on smartphones, tablets, and foldables using Jetpack Compose and Jetpack WindowManager. We'll look at relevant APIs, cover important interaction patterns, and learn how to glue all together.

Thomas Künneth

August 17, 2022
Tweet

More Decks by Thomas Künneth

Other Decks in Programming

Transcript

  1. Unfolding the
    mystery
    Thomas Künneth

    View full-size slide

  2. Sony Tablet P, 2011 (Honeycomb)
    https://www.tabletblog.de/sony-tablet-p-bald-in-deutschland-fur-599-euro-erhaltlich/
    Once upon a time

    View full-size slide

  3. • Very compact
    • Must be opened for full usage
    • Screen essentially is Smartphone-sized
    • Book-like experience
    • Typically, 360-degree hinge
    • Various postures depending on intended use
    • Feels like a smartphone when closed
    • Essentially becomes a tablet when opened

    View full-size slide

  4. • Foldables may have one, two, or possibly more 😎 display areas
    • Biggest area may be provided by more than one physical screen
    • If so, they are connected by a hinge

    View full-size slide

  5. • Even with one screen there may be a hinge (or fold)
    • It may block or obstruct parts of the display

    View full-size slide

  6. • A blocking hinge may cause no problems at all
    • May make the UX a little less pleasing
    • May require changes to the user interface

    View full-size slide

  7. 🤔So what?
    • Ignore devices with obstructing hinges
    • Make our apps first class citizens on as many devices as possible
    • Either way we need to deal with the large screen real estate

    View full-size slide

  8. So, why not learn from them?
    Opened foldables resemble tablets

    View full-size slide

  9. https://de.wikipedia.org/wiki/Android_Honeycomb#/media/Datei:Android3.0.png

    View full-size slide

  10. Two columns
    33 : 66

    View full-size slide

  11. 🤔Listen, I‘ve been thinking
    • Creating two column layouts is
    easy using classic Views
    • And it certainly is easy using
    Jetpack Compose
    • But …
    • what about the fold / hinge…
    • and how do we get information
    about the screen(s)?

    View full-size slide

  12. Introducing Jetpack
    WindowManager

    View full-size slide

  13. • Window metrics for an activity
    • Features of a foldable device
    • Position and size of the hinge
    • Orientation (vertical, horizontal)
    • Occlusion type (none, full)
    • State (flat, half opened)

    View full-size slide

  14. Hinge width: 66 pixel
    Hinge height: 1892 pixel
    1344 – 0 = 1344 pixel
    2754 – 1410 = 1344 pixel
    1892 pixel
    2754 pixel

    View full-size slide

  15. Hinge width: 1 pixel
    Hinge height: 2208 pixel

    View full-size slide

  16. NavigationRail / NavigationRailItem
    • NavigationRail() is used to move between
    primary app destinations
    • Displays three to seven destinations; optionally:
    • FloatingActionButton()
    • logo inside a header
    • NavigationRailItem() represents primary
    destinations

    View full-size slide

  17. • Two columns work great for tablets and foldables
    • Jetpack WindowManager helps determining size and location

    View full-size slide

  18. • Sometimes the hinge obstructs top-level UI elements
    • Material Design interaction patterns help minimizing the impact

    View full-size slide

  19. https://lehtimaeki.medium.com/why-i-will-never-by-another-samsung-device-2237a40002a6

    View full-size slide

  20. Resources
    • https://github.com/PacktPublishing/Android-UI-Development-with-Jetpack-
    Compose/tree/compose_1.2/chapter_11/NavigationRailDemo
    • https://github.com/tkuenneth/android-
    demos/tree/master/compose/FoldableDemo
    • https://github.com/tkuenneth/android-
    demos/tree/master/misc/WindowManagerDemo2

    View full-size slide

  21. https://speakerdeck.com/tkuenneth
    Thank you!
    @tkuenneth
    @tkuenneth
    @tkuenneth

    View full-size slide