{"id":1694,"date":"2021-07-08T10:04:09","date_gmt":"2021-07-08T17:04:09","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/surface-duo\/?p=1694"},"modified":"2021-07-15T15:46:14","modified_gmt":"2021-07-15T22:46:14","slug":"pen-ink-sdk-hover","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/surface-duo\/pen-ink-sdk-hover\/","title":{"rendered":"Hover-ink over dual-screens"},"content":{"rendered":"<p>\n  Hello Android developers,\n<\/p>\n<p>\n  This week we\u2019re releasing the <em>alpha4<\/em> version of our pen SDK preview. The pen SDK is intended to help developers add drawing capabilities to their Android apps, accepting input using touch or pen (including pen features like the eraser tip).\n<\/p>\n<p>\n  The latest open-source SDK code and sample app are available on GitHub in the <a href=\"https:\/\/github.com\/microsoft\/surface-duo-sdk\">surface-duo-sdk<\/a> repo in <strong>inksdk<\/strong>. This post discusses the changes in this release.\n<\/p>\n<h2>New pen-hover indicator<\/h2>\n<p>\n  Microsoft Surface Duo can detect when the pen tip is near to the screen. The <strong>InkView<\/strong> now detects when the pen is close and shows visual feedback that reflects the ink color and pen size. If you flip the pen around to use the eraser, the indicator becomes a dotted grey circle.\n<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2021\/07\/graphical-user-interface-application-description.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2021\/07\/graphical-user-interface-application-description-193x300.png\" alt=\"Surface Duo ink sample with the word pen and the small circle which represents the eraser\" width=\"193\" height=\"300\" class=\"alignnone size-medium wp-image-1695\" srcset=\"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2021\/07\/graphical-user-interface-application-description-193x300.png 193w, https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2021\/07\/graphical-user-interface-application-description.png 500w\" sizes=\"(max-width: 193px) 100vw, 193px\" \/><\/a>&nbsp;&nbsp;&nbsp;<a href=\"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2021\/07\/word-image.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2021\/07\/word-image-194x300.png\" alt=\"Surface Duo ink sample with the word eraser and the small dotted circle which represents the eraser\" width=\"194\" height=\"300\" class=\"alignnone size-medium wp-image-1696\" srcset=\"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2021\/07\/word-image-194x300.png 194w, https:\/\/devblogs.microsoft.com\/surface-duo\/wp-content\/uploads\/sites\/53\/2021\/07\/word-image.png 500w\" sizes=\"(max-width: 194px) 100vw, 194px\" \/><\/a><br\/><em>Figure 1: Surface Duo ink sample showing the \u2018hovering pen\u2019 indicator when drawing and when erasing<\/em>\n<\/p>\n<h2>Smoother lines<\/h2>\n<p>\n  Another area we were able to improve is the appearance of the lines. Drawings, including using a custom pen implementation, look much smoother in this release. This is visible in Figure 1.\n<\/p>\n<h2>Other changes<\/h2>\n<p>\n  We also received feedback about supporting older versions of Android, and that developers would prefer a smaller package size. Both of these have been addressed in this release:\n<\/p>\n<ul>\n<li>\n    Now supports API level 23 and up.\n  <\/li>\n<li>\n    AAR size is reduced thanks to dependency changes and minification.\n  <\/li>\n<\/ul>\n<p>\n  The SDK remains extensible by implementing DynamicPaintHandler as discussed in a <a href=\"https:\/\/devblogs.microsoft.com\/surface-duo\/android-pen-ink-control-preview\/\">previous post<\/a>.\n<\/p>\n<h2>Try it out<\/h2>\n<p>\n  In addition to trying the included sample app, you can also incorporate the <strong>InkView<\/strong> into your test projects by getting the <a href=\"https:\/\/search.maven.org\/artifact\/com.microsoft.device\/ink\">latest version from Maven Central<\/a>:\n<\/p>\n<ol>\n<li>\n<p>Ensure your <strong>build.gradle<\/strong> file contains a reference to:<\/p>\n<pre>mavenCentral()<\/pre>\n<\/li>\n<li>\n<p>Add the dependency:<\/p>\n<pre>implementation 'com.microsoft.device:ink:1.0.0-alpha4'<\/pre>\n<\/li>\n<li>\n<p>Add a custom namespace to the root XML element:<\/p>\n<pre>xmlns:InkView=\"http:\/\/schemas.android.com\/apk\/res-auto\"<\/pre>\n<\/li>\n<li>\n<p>Place an <strong>InkView<\/strong> control in your view:<\/p>\n<pre>&lt;com.microsoft.device.ink.InkView\r\n   android:id=\"@+id\/inkView\"\r\n   android:layout_width=\"match_parent\"\r\n   android:layout_height=\"match_parent\"\r\n   InkView:enable_pressure=\"true\"\r\n   InkView:ink_color=\"@color\/black\"\r\n   InkView:max_stroke_width=\"25\"\r\n   InkView:min_stroke_width=\"10\" \/&gt;\r\n<\/pre>\n<\/li>\n<\/ol>\n<p>\n  Note that <strong>InkView<\/strong> is transparent, so make sure to host it in a view with an appropriate background color.\n<\/p>\n<h2>Resources and feedback<\/h2>\n<p>\n  The source code for InkView is\u00a0<a href=\"https:\/\/github.com\/microsoft\/surface-duo-sdk\/tree\/main\/inksdk\" target=\"_blank\" rel=\"noopener\">available on GitHub<\/a>; we\u2019d love to hear your feedback or see contributions from you to the project.\n<\/p>\n<p>\n  Check out the\u00a0<a href=\"https:\/\/docs.microsoft.com\/dual-screen\/android\/sample-code\/launch-to-second-screen\/?WT.mc_id=docs-surfaceduoblog-conceptdev\" target=\"_blank\" rel=\"noopener\">Surface Duo developer documentation<\/a>\u00a0and\u00a0<a href=\"https:\/\/devblogs.microsoft.com\/surface-duo\/dual-screen-react-web\/\">past blog posts<\/a>\u00a0for links and details on all our samples. You can also find them summarized in the\u00a0<a href=\"https:\/\/docs.microsoft.com\/samples\/browse\/?expanded=surface&amp;products=surface-duo&amp;WT.mc_id=docs-surfaceduoblog-conceptdev\" target=\"_blank\" rel=\"noopener\">Microsoft Samples Browser<\/a>, or explore on\u00a0<a href=\"https:\/\/github.com\/microsoft\/surface-duo-app-samples\" target=\"_blank\" rel=\"noopener\">GitHub<\/a>.\n<\/p>\n<p>\n  If you have any questions, or would like to tell us about your apps, use the\u00a0<a href=\"http:\/\/aka.ms\/SurfaceDuoSDK-Feedback\" target=\"_blank\" rel=\"noopener\">feedback forum<\/a>\u00a0or message us on Twitter\u00a0<a href=\"https:\/\/twitter.com\/surfaceduodev\" target=\"_blank\" rel=\"noopener\">@surfaceduodev<\/a>.\n<\/p>\n<p>\n  Finally, please join us for the\u00a0<a href=\"https:\/\/twitch.tv\/surfaceduodev\" target=\"_blank\" rel=\"noopener\">dual screen developer Twitch livestream<\/a>\u00a0at 11am (Pacific time) each Friday \u2013 mark it in your calendar and check out the\u00a0<a href=\"https:\/\/www.youtube.com\/channel\/UClGu9QLtPNz8OdddBfhZXPA\" target=\"_blank\" rel=\"noopener\">archives on YouTube<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello Android developers, This week we\u2019re releasing the alpha4 version of our pen SDK preview. The pen SDK is intended to help developers add drawing capabilities to their Android apps, accepting input using touch or pen (including pen features like the eraser tip). The latest open-source SDK code and sample app are available on GitHub [&hellip;]<\/p>\n","protected":false},"author":23662,"featured_media":1702,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[473,366,45],"class_list":["post-1694","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-surface-duo-sdk","tag-kotlin","tag-pen","tag-surface-duo-sdk"],"acf":[],"blog_post_summary":"<p>Hello Android developers, This week we\u2019re releasing the alpha4 version of our pen SDK preview. The pen SDK is intended to help developers add drawing capabilities to their Android apps, accepting input using touch or pen (including pen features like the eraser tip). The latest open-source SDK code and sample app are available on GitHub [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-json\/wp\/v2\/posts\/1694","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\/23662"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-json\/wp\/v2\/comments?post=1694"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-json\/wp\/v2\/posts\/1694\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-json\/wp\/v2\/media\/1702"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-json\/wp\/v2\/media?parent=1694"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-json\/wp\/v2\/categories?post=1694"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/surface-duo\/wp-json\/wp\/v2\/tags?post=1694"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}