{"id":2082,"date":"2021-12-16T12:00:39","date_gmt":"2021-12-16T20:00:39","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/surface-duo\/?p=2082"},"modified":"2021-12-16T15:46:21","modified_gmt":"2021-12-16T23:46:21","slug":"dual-screen-reference-app","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/surface-duo\/dual-screen-reference-app\/","title":{"rendered":"Dual-screen reference app"},"content":{"rendered":"<p>\n  Hello Android developers!\n<\/p>\n<p>\n  We\u2019re excited to announce the release of our latest sample application, <i>Dual Screen Experience Example<\/i>, both as <a href=\"https:\/\/github.com\/microsoft\/surface-duo-dual-screen-experience-example\">open-source code on GitHub<\/a> and also available for <a href=\"https:\/\/aka.ms\/DualScreenExperiencePlayStore\">download from Google Play<\/a>. \n<\/p>\n<p><strong>What is the sample about?<\/strong>\n<\/p>\n<p>\n  The sample application provides developers and designers with the possibility to explore the dual screen form factor value for productivity on the go. \n<\/p>\n<p>\n  As a user you are going to play the role of a travelling salesperson that is searching to supply super cool guitars to a couple of guitar stores in Redmond. Each store is marked on the map using an orange pin and there will be a summary of its activity to help you in your journey.\n<\/p>\n<p>\n  <img decoding=\"async\" width=\"1199\" height=\"957\" src=\"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2021\/12\/word-image.png\" class=\"wp-image-2083\" alt=\"\" srcset=\"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2021\/12\/word-image.png 1199w, https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2021\/12\/word-image-300x239.png 300w, https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2021\/12\/word-image-1024x817.png 1024w, https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2021\/12\/word-image-768x613.png 768w\" sizes=\"(max-width: 1199px) 100vw, 1199px\" \/>\n<\/p>\n<p>\n  As you arrive at the chosen store, leverage your device by using the <b>Catalog<\/b> screen to explore the story for each guitar and present them to the store owner. You can also navigate through the Catalog using the Table of Contents by tapping on each item from the list.\n<\/p>\n<p>\n  <img decoding=\"async\" width=\"1199\" height=\"957\" src=\"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2021\/12\/word-image-1.png\" class=\"wp-image-2084\" srcset=\"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2021\/12\/word-image-1.png 1199w, https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2021\/12\/word-image-1-300x239.png 300w, https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2021\/12\/word-image-1-1024x817.png 1024w, https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2021\/12\/word-image-1-768x613.png 768w\" sizes=\"(max-width: 1199px) 100vw, 1199px\" \/>\n<\/p>\n<p>\n  The discussion continues, and the owner decides on some interesting product designs from the list. Thus, you will move to customizing them by trying out different shapes and colors. When the perfect combination is achieved, you can add the products to the order.\n<\/p>\n<p>\n  <img decoding=\"async\" width=\"1199\" height=\"957\" src=\"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2021\/12\/word-image-2.png\" class=\"wp-image-2085\" srcset=\"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2021\/12\/word-image-2.png 1199w, https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2021\/12\/word-image-2-300x239.png 300w, https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2021\/12\/word-image-2-1024x817.png 1024w, https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2021\/12\/word-image-2-768x613.png 768w\" sizes=\"(max-width: 1199px) 100vw, 1199px\" \/>\n<\/p>\n<p>\n  Finally, both of you will check the <b>Orders<\/b> screen where you can change the quantity for each guitar, understand the total price, remove items, or add another guitar from the recommendations. When everything looks good, the next step is to submit the order and move to another store.\n<\/p>\n<p>\n  (Please keep in mind that the application is just a sample, and it works with fictitious data for informative purposes only.)\n<\/p>\n<p><strong>What is the \u201cDeveloper Mode\u201d?<\/strong>\n<\/p>\n<p>\n  Each flow in the application was created to showcase how a specific UI pattern might be used to display more content for a more immersive experience. You can find the name of the pattern right next to the <b>Dev Mode<\/b> button in the toolbar, when the application is spanned across the folding feature.\n<\/p>\n<p>\n  <img decoding=\"async\" width=\"1199\" height=\"957\" src=\"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2021\/12\/word-image-3.png\" class=\"wp-image-2086\" srcset=\"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2021\/12\/word-image-3.png 1199w, https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2021\/12\/word-image-3-300x239.png 300w, https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2021\/12\/word-image-3-1024x817.png 1024w, https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2021\/12\/word-image-3-768x613.png 768w\" sizes=\"(max-width: 1199px) 100vw, 1199px\" \/>\n<\/p>\n<p>\n  As a developer or designer, you can check each screen\u2019s resources by tapping the <b>Dev Mode<\/b> button. Here you can explore the UI pattern that was used in that screen, the specific code we used directly from our Github repository or dive in the SDK documentation for even more details.\n<\/p>\n<p><strong>Is the application compatible with other devices?<\/strong>\n<\/p>\n<p>\n  Yes. The application can also be installed on other emulators or devices.\n<\/p>\n<p>\n  It is compatible with multiple screen sizes, following the <a href=\"https:\/\/developer.android.com\/guide\/topics\/large-screens\/support-different-screen-sizes\">official guidance for responsive UI<\/a> and using ConstraintLayout helpers such as Flow, Guideline, Barrier, and Group, to decide the appropriate size of the components. In the case of TextViews, that is further improved by the <a href=\"https:\/\/developer.android.com\/guide\/topics\/ui\/look-and-feel\/autosizing-textview\">autosizing feature<\/a> for best look on the content.\n<\/p>\n<p>\n  It also supports multi-window mode and takes advantage of the entire large screen on other foldables with the help of the Jetpack Window Manager library and our SDK components. For example, for the Catalog section we are considering both the Activity size (when deciding how many pages to display), and the bounds of the folding feature (which changes some view constraints for a better UI layout). \n<\/p>\n<p><strong>Which components were used from the SDK?<\/strong>\n<\/p>\n<p>\n  To handle the navigation both in single screen and spanned mode we used our new <a href=\"https:\/\/docs.microsoft.com\/en-us\/dual-screen\/android\/api-reference\/dualscreen-library\/navigation-component\/?tabs=kotlin\">Foldable Navigation<\/a> component with <a href=\"https:\/\/docs.microsoft.com\/en-us\/dual-screen\/android\/api-reference\/dualscreen-library\/layouts\/surfaceduo-layout?tabs=kotlin\">FoldableLayout<\/a> as the container of the fragments and foldable <a href=\"https:\/\/docs.microsoft.com\/en-us\/dual-screen\/android\/api-reference\/dualscreen-library\/bottomnavigation\/surfaceduo-bottomnavigationview?tabs=kotlin\">BottomNavigationView<\/a> to change the main navigation nodes. The Foldable Navigation sets by default the first fragment on the first side of the fold when the application is rendered across a folding feature. Therefore, by setting the <code>launchScreen<\/code> attribute from the Navigation Graph, we managed to have the fragments spanned on both screens (for example for the Extended Canvas UI pattern) or moved to the end screen, as shown in the code below:\n<\/p>\n<pre>&lt;fragment\r\n    android:id=\"@+id\/fragment_store_map\"\r\nandroid:name=\"com.microsoft.device.samples.dualscreenexperience.presentation.store.map.StoreMapFragment\"\r\n    android:label=\"StoreMapFragment\"\r\n    tools:layout=\"@layout\/fragment_store_map\"\r\n    app:launchScreen=\"both\">\r\n\r\n    &lt;action android:id=\"@+id\/action_store_map_to_list\"\r\n        app:destination=\"@id\/fragment_store_list\"\r\n        app:launchScreen=\"end\" \/>\r\n\r\n    &lt;action android:id=\"@+id\/action_store_map_to_details\"\r\n        app:destination=\"@id\/fragment_store_details\"\r\n        app:launchScreen=\"end\" \/>\r\n\r\n&lt;\/fragment><\/pre>\n<p>\n  In the <b>Orders<\/b> screen, we included the foldable RecyclerView component from the SDK, through the <a href=\"https:\/\/docs.microsoft.com\/en-us\/dual-screen\/android\/api-reference\/dualscreen-library\/recyclerview\/?tabs=kotlin#foldablestaggeredlayoutmanager-and-foldablestaggereditemdecoration\">FoldableStaggeredLayoutManager and FoldableStaggeredItemDecoration<\/a>, to prevent having the items of different sizes from being rendered behind the folding feature. The following method is being called for every <code>WindowLayoutInfo<\/code> change, so the UI can adapt to it:\n  \n<\/p>\n<pre>private fun setupRecyclerView(windowLayoutInfo: WindowLayoutInfo) {\r\n    binding?.orderItems?.apply {\r\n        layoutManager = FoldableStaggeredLayoutManager(context, windowLayoutInfo).get()\r\n        replaceItemDecorationAt(FoldableStaggeredItemDecoration(windowLayoutInfo))\r\n    }\r\n}<\/pre>\n<h2>Available on Google Play<\/h2>\n<p>\n  To install the application, access the link below on your preferred device. For the best experience, try it out on a foldable\/dual-screen device. Enjoy the journey and don\u2019t forget to tell us what you think!\n<\/p>\n<p>\n  <a href=\"https:\/\/aka.ms\/DualScreenExperiencePlayStore\"><img decoding=\"async\" width=\"215\" height=\"83\" src=\"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2021\/12\/google-play-badge.png\" class=\"wp-image-2087\" alt=\"Google Play Badge\" \/><\/a>\n<\/p>\n<h2>Feedback and resources<\/h2>\n<p>\n  Check out the <a href=\"https:\/\/docs.microsoft.com\/dual-screen\/\">Surface Duo developer documentation<\/a> and <a href=\"https:\/\/devblogs.microsoft.com\/surface-duo\/\">past blog posts<\/a> for links and details on all our samples. You can find this sample on <a href=\"https:\/\/github.com\/microsoft\/surface-duo-dual-screen-experience-example\">GitHub<\/a>.\n<\/p>\n<p>\n  If you have any questions, or would like to tell us about your apps, use the <a href=\"http:\/\/aka.ms\/SurfaceDuoSDK-Feedback\">feedback forum<\/a> or message us on Twitter <a href=\"https:\/\/twitter.com\/surfaceduodev\">@surfaceduodev<\/a>.\n<\/p>\n<p>This week the <a href=\"https:\/\/www.twitch.tv\/surfaceduodev\">Twitch stream<\/a> will be live at the Europe-friendly time of 13:00h CET (12 noon GMT) &#8211; join the team to chat live about this sample app. The stream will be replayed at our usual time of 11am Pacific time for those in the Americas.<\/p>\n<p\/>\n","protected":false},"excerpt":{"rendered":"<p>Hello Android developers! We\u2019re excited to announce the release of our latest sample application, Dual Screen Experience Example, both as open-source code on GitHub and also available for download from Google Play. What is the sample about? The sample application provides developers and designers with the possibility to explore the dual screen form factor value [&hellip;]<\/p>\n","protected":false},"author":79072,"featured_media":2084,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[31,473,45],"class_list":["post-2082","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-surface-duo-sdk","tag-dual-screen-development","tag-kotlin","tag-surface-duo-sdk"],"acf":[],"blog_post_summary":"<p>Hello Android developers! We\u2019re excited to announce the release of our latest sample application, Dual Screen Experience Example, both as open-source code on GitHub and also available for download from Google Play. What is the sample about? The sample application provides developers and designers with the possibility to explore the dual screen form factor value [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-json\/wp\/v2\/posts\/2082","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\/79072"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-json\/wp\/v2\/comments?post=2082"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-json\/wp\/v2\/posts\/2082\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-json\/wp\/v2\/media\/2084"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-json\/wp\/v2\/media?parent=2082"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-json\/wp\/v2\/categories?post=2082"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-json\/wp\/v2\/tags?post=2082"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}