{"id":1112,"date":"2020-12-10T12:19:04","date_gmt":"2020-12-10T20:19:04","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/surface-duo\/?p=1112"},"modified":"2020-12-10T12:54:58","modified_gmt":"2020-12-10T20:54:58","slug":"dual-screen-jetpack-window-manager-update","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/surface-duo\/dual-screen-jetpack-window-manager-update\/","title":{"rendered":"Dual-screen library update with Jetpack Window Manager"},"content":{"rendered":"<p>\n  Hello Kotlin and Java developers,\n<\/p>\n<p>\n  We\u2019re excited to announce version 1.0.0-beta1 of our dual-screen libraries for Microsoft Surface Duo, which integrates Google\u2019s Jetpack Window Manager support. We\u2019ve made the underlying device interface swappable, so you can continue to use the existing Display Mask API as long as you wish and migrate to Window Manager when you\u2019re ready.\n<\/p>\n<p>\n  The main changes in this update are:\n<\/p>\n<ul>\n<li>\n    Jetpack Window Manager is an option for the core device interface layer.\n  <\/li>\n<li>\n    Refactor code so that DisplayMask can still be used by existing developers.\n  <\/li>\n<li>\n    Includes UI and unit tests for each component.\n  <\/li>\n<li>\n    New RecyclerView layout manager for Microsoft Surface Duo.\n  <\/li>\n<li>\n    Transparency and animation support added to BottomNavigation and Tabs.\n  <\/li>\n<li>\n    Updated <a href=\"https:\/\/docs.microsoft.com\/dual-screen\/android\/api-reference\/dualscreen-library\/?WT.mc_id=docs-surfaceduoblog-ancirja\">documentation<\/a> and samples.\n  <\/li>\n<\/ul>\n<p>\n  This blog post explains how to switch between Window Manager and the Display Mask API, tips for migrating from the previous version, and discusses the other new features of this release.\n<\/p>\n<h2>Jetpack Window Manager core <\/h2>\n<p>\n  Older versions of the dual-screen libraries used the <a href=\"https:\/\/docs.microsoft.com\/dual-screen\/android\/get-duo-sdk\/?WT.mc_id=docs-surfaceduoblog-ancirja#display-mask-and-hinge-angle\">Microsoft display-mask API<\/a> to provide dual-screen awareness. With this release we now provide the option to use the <a href=\"https:\/\/medium.com\/androiddevelopers\/support-new-form-factors-with-the-new-jetpack-windowmanager-library-4be98f5450da\">Jetpack Window Manager<\/a> as the device interface, which will work with foldable devices beyond the Surface Duo.\n<\/p>\n<p>\n  Dual-screen device support is encapsulated in the <strong>ScreenManager<\/strong> component \u2013 use this gradle line to add to your app:\n<\/p>\n<pre>implementation \"com.microsoft.device.dualscreen:screenmanager-windowmanager:1.0.0-beta1\"<\/pre>\n<p>\n  The rest of the modules all behave identically, regardless of which <strong>ScreenManager<\/strong> has been used, including:\n<\/p>\n<ul>\n<li><a href=\"https:\/\/docs.microsoft.com\/dual-screen\/android\/api-reference\/dualscreen-library\/bottomnavigation\/surfaceduo-bottomnavigationview\/?WT.mc_id=docs-surfaceduoblog-ancirja\">BottomNavigation<\/a>\n  <\/li>\n<li><a href=\"https:\/\/docs.microsoft.com\/dual-screen\/android\/api-reference\/dualscreen-library\/fragment-handler\/fragment-manager-state-handler\/?WT.mc_id=docs-surfaceduoblog-ancirja\">FragmentManager<\/a>\n  <\/li>\n<li><a href=\"https:\/\/docs.microsoft.com\/dual-screen\/android\/api-reference\/dualscreen-library\/layouts\/surfaceduo-layout\/?WT.mc_id=docs-surfaceduoblog-ancirja\">SurfaceDuoLayout<\/a> and <a href=\"https:\/\/docs.microsoft.com\/dual-screen\/android\/api-reference\/dualscreen-library\/layouts\/surfaceduo-frame-layout\/?WT.mc_id=docs-surfaceduoblog-ancirja\">FrameLayout<\/a>\n  <\/li>\n<li><a href=\"https:\/\/docs.microsoft.com\/dual-screen\/android\/api-reference\/dualscreen-library\/recyclerview\/?WT.mc_id=docs-surfaceduoblog-ancirja\">RecyclerView helper classes<\/a> (new)\n  <\/li>\n<li><a href=\"https:\/\/docs.microsoft.com\/dual-screen\/android\/api-reference\/dualscreen-library\/tabs\/surfaceduo-tablayout\/?WT.mc_id=docs-surfaceduoblog-ancirja\">TabLayout<\/a>\n  <\/li>\n<\/ul>\n<p>\n  The underlying Jetpack Window Manager is <a href=\"https:\/\/developer.android.com\/jetpack\/androidx\/releases\/window\">currently in alpha<\/a>. Being able to easily swap the implementation allows you to test both, and release with the version you feel most comfortable with. Over time, the Jetpack Window Manager implementation will be preferred as it provides support for other foldable devices, helping developers get the best return from their investments in dual-screen enhancements.\n<\/p>\n<h2>Display Mask core<\/h2>\n<p>\n  Existing apps built on the <a href=\"https:\/\/docs.microsoft.com\/dual-screen\/android\/get-duo-sdk\/?WT.mc_id=docs-surfaceduoblog-ancirja#display-mask-and-hinge-angle\">Display Mask API<\/a> can continue to use it. If you would like to try out the dual-screen libraries in conjunction with the Display Mask API, include the correct <strong>ScreenManager<\/strong> component with this gradle line:\n<\/p>\n<pre>implementation \"com.microsoft.device.dualscreen:screenmanager-displaymask:1.0.0-beta1\"<\/pre>\n<p>\n  When you add the other modules (BottomNavigation, etc), they will all work the same regardless of which <strong>ScreenManager<\/strong> is included. \n<\/p>\n<h2>Migrating from older releases<\/h2>\n<p>\n  To align with the lifecycle supported by Window Manager, the library code no longer accesses dual-screen properties in the <strong>onCreate<\/strong> method. Instead, the details are accessed after the activity <strong>onAttachToWindow<\/strong> callback. \n<\/p>\n<p>\n  Existing apps that used the display-mask API in the <strong>onCreate<\/strong> method (to lay out views, for example) should move that code later in the activity lifecycle. The new <strong>ScreenManager<\/strong> implementation compensates for this by refactoring the libraries with an event-driven architecture. This means that in <strong>onCreate<\/strong> you can add a listener for screen mode change events. \n<\/p>\n<p>\n  When you update to this version of the libraries, you should move any dual-screen specific code that was in <strong>onCreate <\/strong>to a listener so that your code can work with both core implementations.\n<\/p>\n<h2>Libraries available in JCenter<\/h2>\n<p>\n  Starting with this release we are publishing to the JCenter repository. JCenter is a default repository in Android Studio which means you\u2019ll no longer need to add our maven repository feed to your top-level <strong>build.gradle<\/strong> file when you include our libraries in your app.\n<\/p>\n<p>\n  Just add the implementation lines as shown above directly to your module-level <strong>build.gradle<\/strong> file (see the <a href=\"https:\/\/docs.microsoft.com\/dual-screen\/android\/api-reference\/dualscreen-library\/?WT.mc_id=docs-surfaceduoblog-ancirja#declaring-dependencies\">docs<\/a> for more info, or <a href=\"https:\/\/bintray.com\/microsoftsurfaceduo\/screenmanager\">explore the package on bintray.com<\/a>).\n<\/p>\n<p>\n  <a href=\"https:\/\/bintray.com\/microsoftsurfaceduo\/screenmanager\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2020\/12\/word-image.jpeg\" class=\"Microsoft Surface Duo maven package preview on bintray.com\" \/><\/a>\n<\/p>\n<h2>New RecyclerView layouts<\/h2>\n<p>\n  There are two new layout manager classes in <strong>RecyclerView<\/strong> library: \n<\/p>\n<ul>\n<li><a href=\"https:\/\/docs.microsoft.com\/dual-screen\/android\/api-reference\/dualscreen-library\/recyclerview\/?WT.mc_id=docs-surfaceduoblog-ancirja\">SurfaceDuoLayoutManager<\/a>\n  <\/li>\n<li><a href=\"https:\/\/docs.microsoft.com\/dual-screen\/android\/api-reference\/dualscreen-library\/recyclerview\/?WT.mc_id=docs-surfaceduoblog-ancirja\">SurfaceDuoItemDecoration<\/a>\n  <\/li>\n<\/ul>\n<p>\n  This makes <strong>RecyclerView<\/strong> automatically change its behavior depending on screen mode. \n<\/p>\n<h2>Updated samples<\/h2>\n<p>\n  The <a href=\"https:\/\/github.com\/microsoft\/surface-duo-sdk-samples-kotlin\">Kotlin samples<\/a> and <a href=\"https:\/\/github.com\/microsoft\/surface-duo-app-samples\">app samples<\/a> repos have been updated to use Jetpack Window Manager \u2013 visit GitHub to get the latest versions.\n<\/p>\n<h2>Feedback and resources<\/h2>\n<p>\n  The <a href=\"https:\/\/github.com\/microsoft\/surface-duo-sdk\">source code for the SDK<\/a> is available on GitHub if you\u2019re curious about the implementation or wish to contribute. Visit the <a href=\"https:\/\/docs.microsoft.com\/dual-screen\/android\/api-reference\/dualscreen-library\/?WT.mc_id=docs-surfaceduoblog-ancirja\">documentation<\/a> for more information on all the features in the dual-screen library for Kotlin and Java developers.\n<\/p>\n<p>\n  Thanks to the team \u2013 <a href=\"https:\/\/www.linkedin.com\/in\/bianca-miron-ro\/\">Bianca Miron<\/a>, <a href=\"https:\/\/twitter.com\/CesarValiente\">Cesar Valiente<\/a>, <a href=\"https:\/\/www.linkedin.com\/in\/cristian-verdes-3b0046135\/\">Cristian Verdes<\/a>, and <a href=\"https:\/\/www.linkedin.com\/in\/sorin-albu-62a76a27\/\">Sorin Albu<\/a> \u2013 for their work on this release.\n<\/p>\n<p>\n  We\u2019d love to hear from you and how you plan to incorporate dual-screen enhancements into your apps. Please reach to out using the\u00a0<a href=\"http:\/\/aka.ms\/SurfaceDuoSDK-Feedback\">feedback forum<\/a>\u00a0or message us <a href=\"https:\/\/twitter.com\/surfaceduodev\">@surfaceduodev<\/a> on Twitter.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello Kotlin and Java developers, We\u2019re excited to announce version 1.0.0-beta1 of our dual-screen libraries for Microsoft Surface Duo, which integrates Google\u2019s Jetpack Window Manager support. We\u2019ve made the underlying device interface swappable, so you can continue to use the existing Display Mask API as long as you wish and migrate to Window Manager when [&hellip;]<\/p>\n","protected":false},"author":47750,"featured_media":1117,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[31,705,706,473,45],"class_list":["post-1112","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-surface-duo-sdk","tag-dual-screen-development","tag-java","tag-jetpack-window-manager","tag-kotlin","tag-surface-duo-sdk"],"acf":[],"blog_post_summary":"<p>Hello Kotlin and Java developers, We\u2019re excited to announce version 1.0.0-beta1 of our dual-screen libraries for Microsoft Surface Duo, which integrates Google\u2019s Jetpack Window Manager support. We\u2019ve made the underlying device interface swappable, so you can continue to use the existing Display Mask API as long as you wish and migrate to Window Manager when [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-json\/wp\/v2\/posts\/1112","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-json\/wp\/v2\/users\/47750"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-json\/wp\/v2\/comments?post=1112"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-json\/wp\/v2\/posts\/1112\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-json\/wp\/v2\/media\/1117"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-json\/wp\/v2\/media?parent=1112"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-json\/wp\/v2\/categories?post=1112"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-json\/wp\/v2\/tags?post=1112"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}