<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Lauren Yew on Medium]]></title>
        <description><![CDATA[Stories by Lauren Yew on Medium]]></description>
        <link>https://medium.com/@laurenyew?source=rss-2e7a92038d8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*32AClEb_M6nNgY0cMvPDoA.jpeg</url>
            <title>Stories by Lauren Yew on Medium</title>
            <link>https://medium.com/@laurenyew?source=rss-2e7a92038d8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 14:14:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@laurenyew/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Impressions of Google I/O 2019: Kotlin Coroutines]]></title>
            <link>https://medium.com/ua-makers/impressions-of-google-i-o-2019-kotlin-coroutines-19b6af1e0e3?source=rss-2e7a92038d8------2</link>
            <guid isPermaLink="false">https://medium.com/p/19b6af1e0e3</guid>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[jetpack]]></category>
            <category><![CDATA[kotlin-coroutines]]></category>
            <dc:creator><![CDATA[Lauren Yew]]></dc:creator>
            <pubDate>Thu, 30 May 2019 17:06:01 GMT</pubDate>
            <atom:updated>2019-05-30T17:06:01.280Z</atom:updated>
            <content:encoded><![CDATA[<p>Google I/O 2019 announced that Google is officially giving first class support to Kotlin and Kotlin Coroutines! This means that the new Android libraries will be written for Kotlin first (in fact, Jetpack Compose — used for Declarative UI Patterns — will be Kotlin only), and that the Jetpack libraries also include Kotlin Coroutines support. Google developers highly recommend using Kotlin Coroutines for doing asynchronous work and when integrating Jetpack.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FBOHK_w09pVA%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DBOHK_w09pVA&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FBOHK_w09pVA%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/4ddbbcd37cd61292bacb688060cf1881/href">https://medium.com/media/4ddbbcd37cd61292bacb688060cf1881/href</a></iframe><h3><strong>What are Kotlin Coroutines?</strong></h3><p><a href="https://kotlinlang.org/docs/reference/coroutines/coroutines-guide.html">Kotlin Coroutines is a stable JetBrains library for coroutines</a> that makes it easy to do asynchronous programming and threading. Coroutines use <a href="https://kotlinlang.org/docs/reference/coroutines/composing-suspending-functions.html">suspend</a> functions to encapsulate some amount of work that can be run on an asynchronous pool of threads. The Kotlin Coroutines library handles the async threading work for you, so you can do your async calls without callbacks, extra subscribers, or observers to get the results back.</p><h3><strong>Kotlin Coroutines in Jetpack</strong></h3><p>Jetpack has several libraries you can use today that include coroutine support.</p><p><a href="https://code.luasoftware.com/tutorials/android/coroutineworker-use-kotlin-coroutines-in-work-manager/">WorkManager</a> supports coroutines in its stable release. You can use WorkManager with coroutines to handle long background jobs, such as syncing local data with the web-server and handling cancellations.</p><p><a href="https://medium.com/androiddevelopers/room-coroutines-422b786dc4c5">Room 2.1 also includes coroutine support</a>. Simply:</p><blockquote>“update your DAO (query) methods to use suspension functions..(and) the (Room) generated code will make sure that your data gets inserted but also that this happens off of the UI thread” <a href="https://medium.com/androiddevelopers/room-coroutines-422b786dc4c5">https://medium.com/androiddevelopers/room-coroutines-422b786dc4c5</a></blockquote><p>Not only does Room handle doing transactions on a background thread for you, but it handles cancellations for you as well.</p><p>Worried about doing parallel database calls and hitting concurrency problems? According to the Jetpack devs at Google I/O, Room will handle database concurrency for you as well.</p><p>You can use LiveData with Kotlin Coroutines to create <a href="https://developer.android.com/topic/libraries/architecture/coroutines">“lifecycle aware coroutine scopes”</a>. For more on coroutine scope check out the <a href="https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-scope/">Kotlin Coroutines Github page</a>. Basically, using ViewModels, you can associate your coroutine scope to the view model lifecycle, and when you no longer need your ViewModel, all the associated coroutines running with that ViewModel can be automatically cancelled, so their encapsulated by that ViewModel’s lifecycle. You can also use LifecycleScope to associate your coroutine set to any view lifecycle.</p><p>LiveData also has another added benefit of being reactive and allowing you to use Kotlin Coroutines in an <a href="https://en.wikipedia.org/wiki/Observer_pattern">Observer Pattern</a>. It was suggested by some of the Google developers to use LiveData and Kotlin Coroutines over RxJava since LiveData is a smaller library than RxJava and had less overhead. The LiveData vs. RxJava debate <a href="https://stackoverflow.com/questions/46312937/when-to-use-rxjava-in-android-and-when-to-use-livedata-from-android-architectura">is still ongoing,</a> so it’s up to you which you prefer to use. Kotlin Coroutines <a href="https://github.com/Kotlin/kotlinx.coroutines/tree/master/reactive/kotlinx-coroutines-rx-example">can work with both.</a></p><h3><strong>Kotlin Coroutines in Third Party Libraries</strong></h3><p>Retrofit supports doing suspend functions. You can use <a href="https://github.com/JakeWharton/retrofit2-kotlin-coroutines-adapter">Jake Wharton’s Retrofit Kotlin Coroutines adapter</a>, or use use regular Retrofit with your Kotlin Coroutines. Check out <a href="https://android.jlelse.eu/kotlin-coroutines-and-retrofit-e0702d0b8e8f">this article</a> for more on Kotlin Coroutines and Retrofit.</p><h3><strong>Testing with Kotlin Coroutines</strong></h3><p>Google I/O announced the launch of a new library to help test Kotlin Coroutines, <a href="https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-test/">kotlinx-coroutines-test</a>. This library should allow developers to get around having to wait for threads to run by controlling the ‘time’ in a test, handling coroutine scope, and cleaning up state between tests. Apparently it can also be used to test coroutines with Live Data. The test API is still experimental, but hopefully it will be in a stable form soon so we can unit test with it!</p><h3><strong>Summary</strong></h3><p>Kotlin Coroutines is a simple, powerful library to handle asynchronous programming with Android. Now that it has first-class Android support and has been integrated with Jetpack, there is even more reason to pick it up! Have fun!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zXd9YnnpN__x3bPB.png" /></figure><p><em>“The Google IO logo, names, images, and all goodwill therein are the property of Google, Inc.”</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=19b6af1e0e3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ua-makers/impressions-of-google-i-o-2019-kotlin-coroutines-19b6af1e0e3">Impressions of Google I/O 2019: Kotlin Coroutines</a> was originally published in <a href="https://medium.com/ua-makers">Under Armour Makers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Impressions from Google I/O 2019: Flutter]]></title>
            <link>https://medium.com/ua-makers/impressions-from-google-i-o-2019-flutter-9cd4b72edefb?source=rss-2e7a92038d8------2</link>
            <guid isPermaLink="false">https://medium.com/p/9cd4b72edefb</guid>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Lauren Yew]]></dc:creator>
            <pubDate>Wed, 29 May 2019 19:45:06 GMT</pubDate>
            <atom:updated>2019-05-30T12:27:39.728Z</atom:updated>
            <content:encoded><![CDATA[<p>Google I/O ’19 was a whirlwind conference, but one key element stood out: Flutter. Flutter is Google’s new solution “building beautiful, native applications for mobile, web, and desktop from a single codebase” <a href="https://flutter.dev/">https://flutter.dev/</a>. Google is pushing hard for developers to adopt their new technology. There were 5 full sessions about Flutter, extolling its ease of use and powerful development potential.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/974/0*IevMBlImkEevUbXy.png" /></figure><h3><strong>What is it?</strong></h3><p>Flutter is a UI Toolkit, and uses the <a href="https://dart.dev/">Dart programming language</a> (which looks like a mix of Kotlin/Swift and JavaScript) to develop apps in a <a href="https://developer.android.com/jetpack/compose">Declarative UI Patterns</a> fashion. This means that you’ll be building up your UI programmatically, using composition with <a href="https://api.flutter.dev/flutter/widgets/Widget-class.html">Widgets</a> to set up the properties of your layouts. Flutter also uses <a href="https://flutter.dev/docs/development/data-and-backend/state-mgmt/intro">reactive state management</a>, which means your UI will automatically update for your variable updates — making async development a breeze. Flutter development is also helped by the <a href="https://flutter.dev/docs/development/tools/hot-reload">Dart runtime’s Stateful Hot Reload</a>, which makes any changes to the code instantly show up on the emulator you are testing on, without the need for a redeploy. Thus, Stateful Hot Reload is available whether you use <a href="https://stackoverflow.com/questions/50025217/flutter-hot-reload-in-android-studio">Android Studio</a>, <a href="https://stackoverflow.com/questions/49210769/vscode-hot-reload-for-flutter">Visual Studio Code</a>, or <a href="https://medium.com/@kikap/how-to-automatically-hot-reload-flutter-when-dart-source-files-change-6e8fdb523004">run your app from command line</a>. Flutter is also unit testable — both the UI and the business logic can be unit tested. Flutter allows you to build new apps or to add Flutter modules and features to existing apps.</p><h3><strong>Performance</strong></h3><p>Flutter is a high-performance solution. Unlike React Native, which runs as JavaScript and must communicate across a bridge to the native OS, Flutter compiles down to binary and gives you an executable. This Flutter executable already includes the native assets, and can run directly on your platform’s hardware, so you get faster runtimes in comparison to React Native. For more on Flutter vs. React, I suggest you read <a href="https://medium.com/asos-techblog/flutter-vs-react-native-for-ios-android-app-development-c41b4e038db9">this article</a>.</p><p>Dart can also communicate back and forth between Kotlin, Java, Swift, and Objective C code, which opens up the possibility for a Flutter module to include code from other languages and communicate between existing apps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/704/0*3iQkmyfyjhkVSRS1.png" /></figure><h3><strong>Writing Android vs. iOS</strong></h3><p>One of Flutter’s biggest draws is the ability to quickly write features for Android &amp; iOS with a native feel and assets that match Material Design / iOS design. But how does it do that? When you set up a Flutter project, you can choose to set it up for both Android and iOS. Flutter has the <a href="https://flutter.dev/docs/development/ui/widgets/material">Material Components library for Material Design native Android widgets</a>, and the <a href="https://flutter.dev/docs/development/ui/widgets/cupertino">Cupertino library for iOS native widgets</a>.</p><p>Some features of native Android / iOS behavior are handled for you, <a href="https://youtu.be/ZBJa-xjZl3w?t=98">such as scrolling</a>. For others, you need to decide which widget component you want to use. Fortunately, Flutter has a helpful check built in for you: when you build with a target platform, Flutter will give you</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/974/0*QflKMBILucPzpSMx.png" /></figure><p>You can use this target platform to decide which component you’d like to build. Because Flutter requires you to develop your widgets with composition, it’s easy to pull out the common code both Android and iOS use, and wrap them in whatever native platform component you’d like to use.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/631/0*_lAYzMHAyKo5R8cV.png" /></figure><h3><strong>Potential of Flutter with Existing apps</strong></h3><p>Flutter has a lot of potential for quick new app development, but where it really shines is in the ability to write quick features or screens and <a href="https://github.com/flutter/flutter/wiki/Add-Flutter-to-existing-apps">add them into existing apps</a>, perhaps for A/B testing or small, short lived features. You can do this by creating a Flutter library module in your Flutter project with Android &amp; iOS targets. Your Flutter module can be built as a gradle project for Android that you can add to your existing Android project (this is still in Beta, but should be in Stable form around July), and your Flutter module can be built as an iOS framework and added to an existing iOS project (still in Alpha).</p><h3><strong>Concerns about Flutter</strong></h3><p>There are still a few remaining concerns about developing with Flutter. <a href="https://github.com/flutter/flutter/wiki/Add-Flutter-to-existing-apps">Add-to-App is still in Beta for Android and Alpha for iOS</a>, so the ability to use Flutter with existing apps in production isn’t there yet. Developers using Flutter will need to learn the system and also pick up the Dart language, and since the Declarative UI patterns are made through composition, there are concerns about readability, scalability, and maintenance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/764/0*67MyrjfXjyKspbOa.png" /><figcaption>Flutter automatically does the commenting for you when you nest a new property or widget, but this much nesting can become difficult to read.</figcaption></figure><p>Speaking to other developers who have worked directly in Flutter, it seems like it’s easy to create simpler layouts, such as view pagers, recycler views, etc. but when it comes to more complex layouts, with inclusions such as Google Maps, Flutter doesn’t appear to have an easy solution yet. Since Flutter must be built in with all its native Android &amp; iOS assets, it remains to be seen if Flutter will be able to keep up with UI changes (although its development team assured us at Google IO that they will) and be able to create more complex UI elements. We’ll have to see how the tool matures.</p><p>Finally, Flutter lifecycle is something to keep in mind when developing. Although Flutter doesn’t have to adhere to the lifecycle of Android or of iOS, being an executable, developers still need to consider the lifecycle of widgets and of the executable itself, especially when inserting into an existing app.</p><h3><strong>Summary</strong></h3><p>All in all, Flutter has a lot of potential as another solution for native-like Android / iOS development. It has the potential to grow into other areas such as desktop, web, and even watch development from the same code base, while keeping a native feel for all areas. “Some big companies are using it, such as Alibaba (Android, iOS), Tencent (Android, iOS), and Google Ads (Android, iOS)” <a href="https://medium.com/asos-techblog/flutter-vs-react-native-for-ios-android-app-development-c41b4e038db9">https://medium.com/asos-techblog/flutter-vs-react-native-for-ios-android-app-development-c41b4e038db9</a>. It’s a new UI Toolkit that warrants looking into. Hope to see you there!</p><h3><strong>Google IO 2019 Flutter Videos</strong></h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FIyFZznAk69U%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DIyFZznAk69U&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FIyFZznAk69U%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/c370e676078694c4303313646167d627/href">https://medium.com/media/c370e676078694c4303313646167d627/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FZBJa-xjZl3w%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DZBJa-xjZl3w&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FZBJa-xjZl3w%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/5dabf79a7482e6d31dfc9f664911095e/href">https://medium.com/media/5dabf79a7482e6d31dfc9f664911095e/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fd_m5csmrf7I%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dd_m5csmrf7I&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fd_m5csmrf7I%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/7a3c70439dd3c91251d7f9ccf879d114/href">https://medium.com/media/7a3c70439dd3c91251d7f9ccf879d114/href</a></iframe><p><em>“All screenshots / pictures in this article were taken from the Google IO 2019 Flutter sessions, available from the Flutter videos sourced above.”</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9cd4b72edefb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ua-makers/impressions-from-google-i-o-2019-flutter-9cd4b72edefb">Impressions from Google I/O 2019: Flutter</a> was originally published in <a href="https://medium.com/ua-makers">Under Armour Makers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Impressions from Google I/O 2019: Android Q — Gesture Navigation]]></title>
            <link>https://medium.com/ua-makers/impressions-from-google-i-o-2019-android-q-gesture-navigation-80c28ce45b1a?source=rss-2e7a92038d8------2</link>
            <guid isPermaLink="false">https://medium.com/p/80c28ce45b1a</guid>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[gestures]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[google]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Lauren Yew]]></dc:creator>
            <pubDate>Tue, 28 May 2019 13:25:11 GMT</pubDate>
            <atom:updated>2019-05-28T13:57:44.893Z</atom:updated>
            <content:encoded><![CDATA[<h3>Impressions from Google I/O 2019: Android Q — Gesture Navigation</h3><p>Gesture Navigation has come to Android Q and it has large impacts on Android app layouts.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FOCHEjeLC_UY%3Fstart%3D1396%26feature%3Doembed%26start%3D1396&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DOCHEjeLC_UY&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FOCHEjeLC_UY%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/77ba322cea39bb3820ca34a759c67e9d/href">https://medium.com/media/77ba322cea39bb3820ca34a759c67e9d/href</a></iframe><h3><strong>What is it?</strong></h3><p>Google has decided to include <a href="https://developer.android.com/preview/features/gesturalnav">Gesture Navigation</a> as an alternative to the usual 3 button mode that Android users have become accustomed to. Gestures are often used by Android power users. Gesture Navigation was introduced to unify gestures used across all Android phones (apparently third party phones were making too many different and confusing gesture sets). There are 3 main gesture areas: left, right, and bottom.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/424/0*O_JzLfdxNZAZ4DRD.png" /><figcaption>Gesture Navigation Areas</figcaption></figure><p>Users can swipe up from the bottom to return home, see recent apps, or kill the app. Users can also swipe from the left or right gesture areas to go back.</p><h3><strong>Drawing Full Screen</strong></h3><p>Gesture Navigation mode means that the app should be rendered across the full screen. <a href="https://developer.android.com/preview/features/gesturalnav">The status bar should be set to be transparent in this mode, and the navigation bar should also be made more transparent</a>. Android has already taken care of automatically changing the navigation bar’s transparency depending on what content is behind it in this mode. This means that the best practice is to render content behind the status bar and navigation bar, taking up the full screen.</p><h3><strong>Staying out of System Gesture Areas</strong></h3><p>The system gesture areas now belong to the OS and will not register touches to send to the app. This means that anything that is clickable, swipe-able, etc. needs to be moved out of the gesture areas.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/743/0*jB333uWvPp7FQOlR.png" /><figcaption>Floating Action Button Pre-adjustment for system Window Insets</figcaption></figure><p>Fortunately, Android has provided us with some system <a href="https://developer.android.com/reference/android/view/WindowInsets">Window Insets</a> that can be used to adjust your layouts to be away from the gesture areas.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/743/0*k_moQ3BxNSVGiOD6.png" /><figcaption>Floating Action Button post-adjustment for system Window Insets</figcaption></figure><p>Some issue areas include:</p><ul><li>Floating Action Buttons</li><li>Recycler view clickable content at the bottom of the screen</li><li>Sliders, Seek bars, etc. at bottom of the screen</li><li>Navigation Drawers (left)</li><li>Bottom sheets (peek content below the gesture area)</li><li>View Pagers (left &amp; right)</li><li>Landscape mode</li></ul><p>Google strongly suggests that developers test every screen in their app for the button vs. gesture mode and for landscape mode as well. Unfortunately, most of the suggestions on how to fix these layout issues were just to add padding or margins for these gesture areas and move clickable content closer to the center of the screen.</p><h3><strong>Workaround: Opt out of Gesture Areas</strong></h3><p>If fixing the layout on your screen for left and right gesture areas is too daunting a task, there is a workaround. Developers can have their layout opt out of the gesture navigation zones on the left and right with <a href="https://developer.android.com/reference/android/view/View#setSystemGestureExclusionRects(java.util.List%3Candroid.graphics.Rect%3E)">View.setSystemGestureExclusionRects(..)</a>. It was suggested at Google I/O that app developers try to stay away from using this as common practice, as it defies the user’s expectation of being able to use the left and right gesture navigation, but it is an option. Unfortunately, apps <a href="https://developer.android.com/preview/features/gesturalnav#home-gestures">cannot opt out of the home gestures</a>.</p><h3><strong>Summary</strong></h3><p>Gesture Navigation mode has opened up some new pain points that developers will need to handle. On one hand, the new mode should allow users to use the whole of their screen to see content. On the other, this is likely to require fixes in every layout of every screen in every app — and moving content closer to the center may cause issues viewing content on smaller phones. Window insets will help keep clickable areas where they can be used, and if all else fails, developers can try to opt out of gesture navigation on a layout (left and right at least). Hopefully new solutions and developer feedback will help make this a smoother transition.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wBepNmlWz1XuxQQrRBb5NQ.png" /></figure><p><em>“All screenshots were taken from the Google IO 2019 Dark Theme &amp; Gesture Navigation session, available from the Google IO video sourced above.”</em></p><p><em>“The Google IO logo, names, images, and all goodwill therein are the property of Google, Inc.”</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=80c28ce45b1a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ua-makers/impressions-from-google-i-o-2019-android-q-gesture-navigation-80c28ce45b1a">Impressions from Google I/O 2019: Android Q — Gesture Navigation</a> was originally published in <a href="https://medium.com/ua-makers">Under Armour Makers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Impressions from Google I/O 2019: Android Q — Dark Theme]]></title>
            <link>https://medium.com/ua-makers/impressions-from-google-i-o-2019-android-q-dark-theme-5af500f87161?source=rss-2e7a92038d8------2</link>
            <guid isPermaLink="false">https://medium.com/p/5af500f87161</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[dark-theme]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[material-design]]></category>
            <dc:creator><![CDATA[Lauren Yew]]></dc:creator>
            <pubDate>Mon, 27 May 2019 16:56:00 GMT</pubDate>
            <atom:updated>2019-05-27T16:56:00.034Z</atom:updated>
            <content:encoded><![CDATA[<h3>Impressions from Google I/O 2019: Android Q — Dark Theme</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XVhdHBiog6_oACFFoof-IQ.png" /></figure><p>One of the big changes coming in Android Q is <a href="https://developer.android.com/preview/features/darktheme">Dark Theme</a>. Not only is Dark Theme a long-requested feature by those who don’t like looking at the bright screen all the time, especially during the night or early morning hours, using Dark theme has been shown to save up to 60% of the phone’s battery. Thus, Android Q will automatically switch to using dark theme in low battery situations to save battery and can also be chosen in the user’s settings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/408/0*i6DZBsoxJ5CzakFI.png" /></figure><h3><strong>Updating your app for Dark Theme</strong></h3><p>Google strongly recommends that apps are updated to support system Dark Theme. In fact, there was a suggestion to have a Dark Theme setting in your own app — useful if your app is used mostly in early morning or at night, so the app can be set on dark theme without a system wide dark setting. In the meantime, to test how your app will look in dark mode, there is a developer option to force the system into Dark Mode.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/0*iCX83ySVzMfr3P05.png" /></figure><p>For Android Q only, you can have the system automatically convert the app to a Dark Theme with Force Dark (android:forceDarkAllowed=&quot;true&quot; <a href="https://developer.android.com/preview/features/darktheme">https://developer.android.com/preview/features/darktheme</a>).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/891/0*VTxFxEys1LyT55Zl.png" /><figcaption>Force Dark theme vs. Custom theme</figcaption></figure><p>This makes it easy to pick out where your app needs work and what it could potentially look like converted to Dark Theme. However, since this change would only apply to Android Q phones, it’s suggested that you use the <a href="https://developer.android.com/preview/features/darktheme">DayNight (dark) theme</a> in your app to apply to all versions of Android, or customize your own DayNight dark theme. With a custom theme, you would be able to adjust the contrast of colors or make the dark theme closer to your brand’s chosen color scheme.</p><h3><strong>Design Considerations</strong></h3><p>Google has updated the <a href="https://material.io/design/color/dark-theme.html">Material Design Guidelines for Dark Theme</a>. When converting your app, you need to consider the alternate colors for buttons, selectors, and fonts. Maps also can be updated to include a JSON styling for dark theming. Drawables can be tinted to dark theme colors, and vector colors can be swapped out for dark theme versions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/525/0*OnyDi4keq5fuiN8j.png" /><figcaption>Notice button / font / graph colors have changed.</figcaption></figure><p>It was suggested in the <a href="https://www.youtube.com/watch?v=OCHEjeLC_UY">Dark Theme Google I/O talk</a> that developers consider converting SVGs and Drawables into vectors since it’s easier to just provide alternative dark theme colors in vectors rather than trying to re-tint or provide new Dark Theme assets. Since the upcoming version of <a href="https://www.youtube.com/watch?v=oWTG5g5rT4s">Android Studio should be able to handle changing SVGs into vectors automatically</a> for you, this should be a relatively easy transition.</p><p>Webviews are automatically converted to Dark Theme based on system settings. This may cause more of a product drive for your team to convert your app to Dark Theme (having a webview in Dark Theme for an app that is not Dark Themed would look strange).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/433/0*gd0AKdn9NeHN-Cyf.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/433/0*sHVqShfhL0h0K3pG.png" /></figure><h3><strong>Summary</strong></h3><p>Dark Theming has its own design considerations but promises a beautiful new look for any app. Take a look at Google I/O’s 2019’s talk on Dark Theme and decide for yourself: do you want to join the dark side?</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FOCHEjeLC_UY%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DOCHEjeLC_UY&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FOCHEjeLC_UY%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/7e9d44728903f771d3e7c212af4b47c1/href">https://medium.com/media/7e9d44728903f771d3e7c212af4b47c1/href</a></iframe><p><em>“All screenshots were taken from the Google IO 2019 Dark Theme &amp; Gesture Navigation session, available from the Google IO video sourced above.”</em></p><p><em>“The Android robot is reproduced or modified from work created and shared by Google and used according to terms described in the </em><a href="https://creativecommons.org/licenses/by/3.0/"><em>Creative Commons 3.0 Attribution License</em></a><em>.”</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5af500f87161" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ua-makers/impressions-from-google-i-o-2019-android-q-dark-theme-5af500f87161">Impressions from Google I/O 2019: Android Q — Dark Theme</a> was originally published in <a href="https://medium.com/ua-makers">Under Armour Makers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[12 steps to convert your Java class to Kotlin the right way]]></title>
            <link>https://medium.com/swlh/12-steps-to-convert-your-java-class-to-kotlin-the-right-way-9a718cfb498d?source=rss-2e7a92038d8------2</link>
            <guid isPermaLink="false">https://medium.com/p/9a718cfb498d</guid>
            <category><![CDATA[kotlin-beginners]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[androiddev]]></category>
            <dc:creator><![CDATA[Lauren Yew]]></dc:creator>
            <pubDate>Mon, 08 Apr 2019 13:58:08 GMT</pubDate>
            <atom:updated>2019-07-10T15:13:51.360Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*B42NYfscsIDzA5Xd.png" /></figure><p>Sure, it’s easy to have Android Studio convert your Kotlin class for you, but the results are rather messy! Like any automated tool, Android Studio does its best for an automatic conversion, but it leaves a bit for developers to clean up. Your class probably won’t compile, you’ve got null exceptions everywhere, and even after you’ve cleaned it up, how do you even tell if your class still works like it should?! Read on!</p><p>Here are 12 steps to take that solve the automated Kotlin conversion mess.</p><h3><strong>Step 1: Black Box unit test before you convert</strong></h3><p>How do you make sure you don’t break a class with the Kotlin conversion? You unit test it before you make the change. Yay <a href="https://en.wikipedia.org/wiki/Test-driven_development">Test Driven Development</a>!</p><p>You probably won’t get any gain by testing nulls because Kotlin changes nullability, but it’s a good idea to black box test the class for its main features / happy path at least. Once you’ve gotten your tests to pass, you know that if they pass for the Kotlin version, your class still has the functionality it did before.</p><h3><strong>Step 2: Git Shenanigans for cleaner PRs</strong></h3><p>Does your team do code reviews? Do this step to help your reviewers understand what changed in your code! If you just change the Java file to Kotlin, git will see that as you deleting the whole Java file, and creating a new Kotlin file. 1) That’s not helpful for figuring out what changed and 2) you will lose all your previous file git history!</p><p>Here’s how to fix that issue:</p><p>1) Rename your .java file to have a .kt extension. Commit that change.</p><p>2) Rename your .kt file back to .java. Commit that change.</p><p>3) Now after you’ve made the actual conversions and committed, rebase and squash those commits into your .kt file back to .java commit, and your git will just show the changes you made within the Kotlin file code.</p><h3><strong>Step 3: Auto Convert with Android Studio</strong></h3><p>Now, you can use Android Studio to convert your Java class to Kotlin. Just go to <strong>Code &gt; Convert Java File To Kotlin</strong>. I usually also allow Android Studio to automatically convert any Java references to my file to the appropriate code to deal with Kotlin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*v_HXdh5nu3k4Noqb.gif" /></figure><h3><strong>Step 4: Get Rid of the !! Not Null Assertion Operators</strong></h3><p>When you automatically convert your Java class to Kotlin, Android Studio will stick a bunch of !! operators into your code to handle nullability. This is the <a href="https://kotlinlang.org/docs/reference/null-safety.html#the--operator">Not Null Assertion</a> operator, which will check if the object is null and throw an exception if it is. This is generally not what we want — for example, you wouldn’t want to crash the app on a null view or a null context. Remove the !!’s and use the nullable operator instead (?), or look into your code and see if you needed that value to be nullable.</p><h3><strong>Step 5: Companion objects and </strong><strong>@JvmStatic</strong></h3><p>Kotlin conversion will move your static objects/methods into Companion objects if you have a regular class, and you might notice that all your Java uses of those objects/methods now have a .Companion reference to them. If you like, you can reference them just as before if you add @JvmStatic to those objects/methods, and this will tell the compiler to generate them as additional static objects/methods.</p><h3><strong>Step 6: Revisit your APIs</strong></h3><p>Since you’ve converted your class to Kotlin, you may have noticed that your APIs look a little different. @NonNull arguments now enforce the non-null, and if you didn’t specify non-null, the arguments are marked as nullable. You may want to revisit these APIs to see if they’re meant to be non-null or nullable, and if they’re being used properly across the app. It’s best to bring in your team and communicate changes, especially if your API is being used outside of your code’s scope.</p><h3><strong>Step 7: Lambdas</strong></h3><p>One of my favorite parts of the Kotlin language are lambdas. They’re so easy to use and they make developing callbacks, listeners, and functions a cinch! Go through your code, look for click listeners, callbacks, and methods that can be converted to lambdas. Android Studio will often help you out here by highlighting or graying areas that can be fixed to be more performant. You might even consider updating your APIs to use lambdas. (Warning: Using the lambdas in your APIs in Java code may result in some strange looking code. <a href="https://www.geeksforgeeks.org/lambda-expressions-java-8/">Java 8 does have the concept of lambdas</a>, and Java 7 has functions, but their syntax handling of Kotlin lambdas can be a bit strange).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/00f38cb762b8047dc2e0b25da0313f8f/href">https://medium.com/media/00f38cb762b8047dc2e0b25da0313f8f/href</a></iframe><h3><strong>Step 8: Fixing for loops, inline returns, and using when</strong></h3><p>Kotlin can replace for loops with a .forEach or a .forEachIndexed:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2d21e3285f051efd58b6c8206666b495/href">https://medium.com/media/2d21e3285f051efd58b6c8206666b495/href</a></iframe><p>You can also go through all of your single line return methods and make them inline. Take a look at all your uses of return. Android Studio often has suggestions on how Kotlin can make returns or assignments inline.</p><p>One of the most powerful keywords in Kotlin is when. It can replace switch-statements and if-statements and can execute logic to determine the control flow.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d39edea6517e2767a785cacfa3d7909b/href">https://medium.com/media/d39edea6517e2767a785cacfa3d7909b/href</a></iframe><h3><strong>Step 9: Document, Document, Document!</strong></h3><p>Just as with any code change, you should understand the code you are dealing with, and use that time to add method / class comments to your code. Yes, we want to write clean code that is self-explanatory, but having a quick comment about purpose of the code or how its used can be invaluable for debugging, reading, or even re-architecting later. Do your future-self and your team a huge favor — document!</p><h3><strong>Step 10: Unit test again</strong></h3><p>Make sure that your code passes your black box unit tests. If not, fix the code. If so, write more unit tests! Unit testing can help you catch edge cases and make sure the code works as you think it should. Bonus: you can up those code coverage numbers while you convert your code to Kotlin.</p><h3><strong>Step 11: Visual QA (If possible)</strong></h3><p>Save your QA team a cycle! Before you send your work on to code review, if you’ve updated a UI class, or touched logic that affects that UI, you should run your app and make sure that screen looks right, just in case.</p><h3><strong>Step 12: Rebase your commits for clean Git Diff</strong></h3><p>As mentioned in the Git step, you should rebase your commits back into your .kt → .java commit so that you can get a clean git diff for your code reviewers to read. This will help immensely to figure out what actually was changed in the code, rather than having to re-review the whole (potentially huge) file.</p><h3><strong>DONE!</strong></h3><p>Congratulations! You’re done converting your Java file to Kotlin! You now have a beautiful new Kotlin class that’s been well-unit-tested and verified. Give yourself a pat on the back and send your work off to be reviewed! You did it!</p><p><em>“The Android robot is reproduced or modified from work created and shared by Google and used according to terms described in the </em><a href="https://creativecommons.org/licenses/by/3.0/"><em>Creative Commons </em></a><em>3.0 Attribution License.”</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9a718cfb498d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/12-steps-to-convert-your-java-class-to-kotlin-the-right-way-9a718cfb498d">12 steps to convert your Java class to Kotlin the right way</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to advocate for Kotlin migration + sample migration process]]></title>
            <link>https://medium.com/@laurenyew/how-to-advocate-for-kotlin-migration-sample-migration-process-3d178d8b638?source=rss-2e7a92038d8------2</link>
            <guid isPermaLink="false">https://medium.com/p/3d178d8b638</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[kotlin-beginners]]></category>
            <dc:creator><![CDATA[Lauren Yew]]></dc:creator>
            <pubDate>Fri, 29 Mar 2019 17:39:11 GMT</pubDate>
            <atom:updated>2019-03-29T17:39:11.702Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bXsEbU74-rfCzPnH.png" /></figure><p>So, you’ve decided you want to convert your app to Kotlin! If you still haven’t decided, I suggest you take a look at my previous article, <a href="https://medium.com/@laurenyew/why-migrate-your-android-app-to-kotlin-2220218952a9">Why migrate your Android app to Kotlin</a>. Now let’s discuss the next step: how to convince your team and your company to do a Kotlin Migration?</p><p>In this article, we will discuss the questions that may come up when you propose Kotlin Migration to your team, how to answer them, and a step by step migration process that may help your team convert your app in a smooth, bug-free way.</p><h3><strong>Questions to Consider</strong></h3><h4><strong>1.</strong> <strong>How will converting / writing in Kotlin affect developer velocity?</strong></h4><p>This is a valid concern for developers, product, and project managers. If you’re working in Kotlin, will you be able to release features on time? You could advocate for tech debt time to do the migration, but not every team has a lot of time allocated for technical debt.</p><p>As with any language, there is a learning curve. But in my experience, the more exposure developer has to Kotlin, the faster they will become at developing in Kotlin. Kotlin is a more efficient language to use. According to the Kotlin FAQ, on average, developing in Kotlin means having to write <a href="https://kotlinlang.org/docs/reference/faq.html">40% less code</a> to do the same feature! Be more efficient and effective!</p><p>If you need to figure out how long it will take to convert a class to Kotlin, adjust per the developer’s strength in Kotlin. For a small class and an experienced Android developer that’s new to Kotlin, the conversion of the class should take about 2 days, with an extra day allowed to write a unit test in Kotlin. Speed increases exponentially from there. For a small class an an Android developer experienced in Kotlin, conversion can take a couple hours, including adding unit tests.</p><h4><strong>2.</strong> <strong>How will this improve the product?</strong></h4><p>As developers, we don’t want to be adding new languages just for kicks — we want to show some real improvement! There are many ways Kotlin can improve your product. Consider the number of null pointer exceptions your app runs into. Kotlin’s null safety and robust APIs can get rid of those bugs entirely. Imagine how much better your product could be without that whole class of pesky bugs! Even if you just improve your developer velocity with the cleaner, more concise language Kotlin provides, you’re still improving your product. You can use that saved time to write more features, tackle technical debt, or look into new Kotlin libraries that can make your product even better!</p><h4><strong>3.</strong> <strong>How can we spread information about Kotlin throughout the team?</strong></h4><p>Perhaps not all of your team is experienced in Kotlin as a language. How do you get everyone up to speed? Taking a phased approach to migration to Kotlin can help with this, and allow team members time to dip their toes into the language. I would also suggest creating a series of brown bag sessions for developers to better understand the benefits of the language and its features. An internal Slack channel can also be helpful for spreading knowledge about the language, talking through issues, and getting help from your community.</p><h4><strong>4.</strong> <strong>How can we prevent bugs?</strong></h4><p>A developer’s worst nightmare is adding a new language, and then having it cause crashes in production because of what you changed. You can mitigate this by making your Kotlin migration changes on feature branches, and then having your QA team acceptance test your app off of those branches before you merge them in. It is also highly recommended that you try to unit test those classes that you do convert as much as possible.</p><h3><strong>Process of Kotlin Migration</strong></h3><p>Not everyone has the luxury of doing a total refactor of their code. If you want to do a phased approach, you can do the migration changes in smaller steps: allowing your team time to increase their confidence in Kotlin, while allowing you to migrate without affecting team velocity, continuing regular feature work as you do the migration.</p><h4>The goal of this process is 100% Kotlin migration.</h4><h4>Starting at Phase 1, the requirements to complete each phase are:</h4><ul><li><strong>Unit tests written for each class converted to Kotlin (if possible)</strong></li></ul><p>This will not only help bug-proof your code in case the Kotlin migration broke something, but it will also improve your code coverage. (Yay!)</p><ul><li><strong>Team buy-in (developer confidence in Kotlin)</strong></li></ul><p>Your team must agree to move onto the next phase. This helps the entire team to gain confidence in the whole migration since you won’t be moving to the next phase until the whole team agrees to do so.</p><ul><li><strong>% Kotlin conversion</strong></li></ul><p>This is for tracking your progress and is helpful for a demo of your progress. I suggest you create a script that can count the number of Kotlin files vs. the number of Java files.</p><ul><li><strong>Number of null pointer bugs</strong></li></ul><p>This metric is helpful for tracking Kotlin’s improvement for your app in terms of stamping out production bugs</p><ul><li><strong>Number of bugs created by conversion</strong></li></ul><p>This metric will help you track if you’re doing your due-diligence in unit testing or writing good APIs. You should try to keep this number to a minimum to improve confidence in the migration process.</p><ul><li><strong>Communicate w/ product / project / associated teams if changing APIs on changes to be made</strong></li></ul><p>Communication with all parties will help prevent unexpected API changes and will put everyone on alert to catch possible bugs before they hit production.</p><h4><strong>Phase 0: Kotlin Migration POC</strong></h4><p>Before starting any migration effort, it’s a good idea to do a quick 1–3 day Proof of Concept (POC). In this POC, you will introduce Kotlin into your app and implement a small migration. (This is a perfect Hack-Day project). This POC can help: 1) prove that introducing Kotlin to your app will not break it, 2) prove that a converted Kotlin file will work with Java, 3) help you and your team get a layout of how the conversion will work and how you want to proceed, and 4) give you time to consider any third party libraries you’d like to use with Kotlin.</p><p><strong>Suggested POC:</strong></p><ol><li>Pick a fragment to convert to Kotlin</li><li>Pick an activity to convert to Kotlin</li><li>If you do MVP, MVVM, MVC Patterns: Pick a presenter/view model/controller to convert to Kotlin</li><li>Pick a service to convert to Kotlin</li><li>Pick a unit test to convert to Kotlin</li></ol><p><strong>POC Results:</strong></p><ol><li>List classes converted to Kotlin</li><li>Demo of working app features (Prove it works!)</li><li>Compare Kotlin to Java in lines of code saved (Show the improvements)</li><li>Dev velocity to convert to Kotlin (how long did it take?)</li><li>Make a plan of action (going forward, what’s next?)</li></ol><h4><strong>Phase 1: Unit tests in Kotlin</strong></h4><p>For the first phase, you’ll focus on unit tests: converting all of your unit tests to Kotlin. From here, you will write any future unit tests in Kotlin.</p><p>Why is this the first phase?</p><p>Unit tests do not touch your production code, so you won’t have to worry about breaking your production app. Developers not used to Kotlin can use this time to get their feet wet with the language, how Kotlin interacts with Java classes, and bonus: your team can also use this time to improve your code coverage!</p><p>I highly suggest you look into using <a href="https://github.com/nhaarman/mockito-kotlin">MockitoKotlin</a> with your unit tests if you are using Mockito. It greatly improves the ease of mocking objects and dealing with argument captors.</p><h4><strong>Phase 2: Convert small utilities, classes, or UI to Kotlin</strong></h4><p>Work with your team to pick out some small, very well unit-tested, utilities, classes, fragments, or activities to convert to Kotlin. Any code you write should be tested by QA on a feature branch to ensure nothing broke before you merge the class in.</p><p>By making sure you’re working with well unit-tested areas of code, you’re mitigating the chance that you’ll do the conversion and run into bugs in production. You can also migrate UI classes because any bugs in these classes are more likely to be found by a visual QA than more business-logic based classes. You can use this phase to prove that converting small utilities or classes improves the code and does not hurt the product, and again, it gives developers time to improve their ability to code in Kotlin.</p><h4><strong>Phase 3: Create a new feature in Kotlin</strong></h4><p>This is the real test of a developer’s familiarity with Kotlin. A developer should be able to create a new feature in Kotlin without greatly affecting their velocity. Again, that feature should be thoroughly unit tested.</p><p>This phase will prove that developer velocity is not adversely affected by including Kotlin since it should not vastly slow down feature creation. It will allow your team to get a feel for developing in Kotlin from the ground up, rather than converting existing code. This step should also improve developer confidence in Kotlin.</p><h4><strong>Phase 4: Open Conversion to Kotlin</strong></h4><p>At this point, the team should be very confident in developing and converting to Kotlin. The team members are free to convert any class they touch into Kotlin. If any APIs are changed or large features are to be converted, the developer should alert the team and any interested parties about the changes, and possibly create tech debt tickets to do the migration. In and after Phase 4, any new features should be written in Kotlin (unless the team agrees that a class must be in Java). This open conversion can be tracked through the change in percent of Kotlin conversion for each sprint and will help the team get to 100% conversion.</p><h3><strong>Conclusion</strong></h3><p>Whew! You made it! With this phased Kotlin Migration approach, you can take convert your app piece by piece — taking a safer, smoother path to a 100% Kotlin product. You can do this. Go for it!</p><p><em>“The Android robot is reproduced or modified from work created and shared by Google and used according to terms described in the </em><a href="https://creativecommons.org/licenses/by/3.0/"><em>Creative Commons </em></a><em>3.0 Attribution License.”</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3d178d8b638" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why migrate your Android app to Kotlin?]]></title>
            <link>https://medium.com/@laurenyew/why-migrate-your-android-app-to-kotlin-2220218952a9?source=rss-2e7a92038d8------2</link>
            <guid isPermaLink="false">https://medium.com/p/2220218952a9</guid>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[kotlin-beginners]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Lauren Yew]]></dc:creator>
            <pubDate>Sat, 23 Mar 2019 00:11:42 GMT</pubDate>
            <atom:updated>2019-03-25T15:39:19.865Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OwxEkE8OoHDidAgTwL8eNA.png" /></figure><p>Why bother making the effort? Kotlin is an amazing language that has a ton of benefits for fast, easy, Android development. It’s quickly becoming the preferred Android development language. In this article we will discuss the pros and cons of migrating to Kotlin, and point out some next steps to make your transition super easy.</p><p><strong>Benefit 1: First Class Android Support + Android moving away from Java</strong></p><p>Android is actively promoting developing in Kotlin. All of Google’s samples are in Kotlin, with a Java equivalent option for some examples. Many of the new Android libraries are being written in Kotlin — for Kotlin, such as the<a href="https://developer.android.com/kotlin"> Android 9 libraries, AndroidX libraries</a>, and the<a href="https://developer.android.com/kotlin/ktx"> Android KTX library</a>. Android Studio itself has first-class support for the language — meaning Kotlin support is built in with the IDE.</p><p>Unfortunately for Java-only developers, continued Android first-class support for Java is no longer guaranteed. Due to the<a href="https://en.wikipedia.org/wiki/Oracle_America,_Inc._v._Google,_Inc"> recent Oracle vs. Google lawsuit about Android’s use of Java</a>,<a href="https://in.pcmag.com/google-io/114595/google-is-moving-android-away-from-its-oracle-java-problems"> Google has announced that they will drop support for the Android Java APIs and will instead use the open source OpenJDK</a>. Most likely, Java will continue to stick around for previous app version support, but if you want to stay current, learning Kotlin will keep you in the game with the latest and greatest Android libraries and techniques!</p><p>Furthermore, Android Studio provides <em>many</em> helpful tools to help you learn and work with Kotlin, so it’s easy to pick up the new language as you develop. The IDE even has a tool to automatically convert your Java code into Kotlin! The IDE includes inline code suggestions on how to make your Kotlin code perform better, and will pop up helpful tips as you develop. This is very helpful!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*M4N7S3E9VkO_mM2v4Zfo9A.gif" /><figcaption>Android Studio automatic Kotlin conversion</figcaption></figure><p><strong>Benefit 2: Compatible with Java code = Smooth Step by Step Migration Possible</strong></p><p>When used with Android,<a href="https://kotlinlang.org/docs/reference/faq.html"> Kotlin decompiles into Java compatible byte code</a> — you can run Kotlin code from Java code and vice-versa. This allows you to piece-meal convert parts of your app or library instead of having to do the entire conversion in one giant refactor. If doing a large migration seems too daunting a task, a phased migration is an excellent option — you can make headway on Kotlin migration, but do so in a slower, more protected approach.</p><p><strong>Benefit 3: Null safety with Kotlin + Build better APIs</strong></p><p>Are you tired of those pesky if-null checks? Tired of getting runtime null pointer exceptions? Unlike Java, Kotlin enforces null safety. So, if you’ve specified an API or value as non-null, Kotlin enforce that non-null. Unlike Java — you can count on your arguments coming through as specified. Think of all the time you could save on null checks with more robust APIs!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/168ed2342e238ea3794181f6a40ccb24/href">https://medium.com/media/168ed2342e238ea3794181f6a40ccb24/href</a></iframe><p>If you’re dealing with a null in code, Kotlin allows you to use safe call operator ? to run methods/access attributes on a nullable value. Methods being run on a null object won’t execute, and attributes from a null objects will return null. Want to provide a default value instead of null? No problem! Just use Kotlin’s operator ?: to provide a default value if object is null. Cool, huh?</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/06fd45e5d98c23be4982c3e6bd9a23da/href">https://medium.com/media/06fd45e5d98c23be4982c3e6bd9a23da/href</a></iframe><p>Still not satisfied? Want more time-savers? Kotlin also includes helper methods like let and apply to allow developers to use and make changes to objects without having to worry about re-referencing objects or nullability issues. Now that you’re dealing with nulls in a more null-safe manner, say goodbye to all of those NullPtrException crashes!</p><p><strong>Benefit 4: Named Constructors w/ Default values</strong></p><p>Want to write a class constructor, but don’t want to have to remember the order of your parameters? Kotlin’s classes have named variable constructors, which means you can specify the name you’ve given to the variable, and can thus create a constructor with parameters provided in any order. You can also provide default values in case you don’t want to have to specify each value.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6fe0cf41c57369731595aceb029c8bb8/href">https://medium.com/media/6fe0cf41c57369731595aceb029c8bb8/href</a></iframe><p><strong>Benefit 5: Write faster code!</strong></p><p>Be a super star, write faster code! According to the Kotlin website, a class written in Kotlin uses<a href="https://kotlinlang.org/docs/reference/faq.html"> 40% less code than a class written in Java</a><em> </em>on average. Kotlin has faster replacements for many of the main Java staples like the for-loop, map, and filters with its own helper methods such as forEach, forEachIndexed, map, and filter. Creating basic data structures is made fast and easy with arrayListOf and hashMapOf. Kotlin even has a helper method firstOrNull where you can give it a filter and it will automatically find an item for you! Awesome! These methods help take out much of the boiler-plate code we have to write and will improve your velocity!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2d21e3285f051efd58b6c8206666b495/href">https://medium.com/media/2d21e3285f051efd58b6c8206666b495/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/95249273f457c63e2a188096a045313f/href">https://medium.com/media/95249273f457c63e2a188096a045313f/href</a></iframe><p><strong>Benefit 6: Lambdas to the rescue!</strong></p><p>Java 8 now includes the ability to pass<a href="https://docs.oracle.com/javase/8/docs/api/java/util/function/package-summary.html"> single or double argument functions</a> into a method parameter or change certain listeners into lambdas, but Kotlin takes this concept to a whole new level! You are no longer limited to single or double argument lambdas, you can pass whatever lambda you’d like. Kotlin even static checks the types of the arguments of its lambdas for you. Kotlin also provides the ability to create closures on the fly, which makes it much easier to include a small set of logic for callbacks and click listeners — inline! All of this makes life much easier when it comes to callbacks, exceptions, and listeners.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/00f38cb762b8047dc2e0b25da0313f8f/href">https://medium.com/media/00f38cb762b8047dc2e0b25da0313f8f/href</a></iframe><p><strong>Benefit 7: Swift Crossover</strong></p><p>Ever been curious on what it’s like to develop in Swift? Kotlin is here to help! Kotlin and Swift are very similar in language syntax. Both include optionals in their syntax for null safety and both handle lambdas in a similar fashion. On the bright side for Android developers, Kotlin is not as strict as Swift with unwrapping null checks, so development in Kotlin is easier and more dev-friendly than developing in Swift. If you want to make your code easier to read and pick up when switching between platforms, Kotlin is for you!</p><p><strong>Benefit 8: Fun new libraries</strong></p><p>Many new libraries are being written for Kotlin, including the<a href="https://developer.android.com/kotlin/ktx"> Kotlin Extensions library</a>, which includes helper methods such as the synthesized findViewById where you can avoid having to create View variables and just use the layout id synthesized value.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/74cfb4e4d5fb6ee9703356e044ba6b14/href">https://medium.com/media/74cfb4e4d5fb6ee9703356e044ba6b14/href</a></iframe><p>If you’re concerned about style / lint errors, there’s a<a href="https://github.com/shyiko/ktlint"> ktlint gradle tool</a> you can easily integrate into your code to catch and fix those errors. There’s also the<a href="https://github.com/nhaarman/mockito-kotlin"> MockitoKotlin</a> library for those of you who like writing unit tests with Mockito but (like many) don’t enjoy writing those argument captors.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/35cfc46077abb7add763bbac45b568bb/href">https://medium.com/media/35cfc46077abb7add763bbac45b568bb/href</a></iframe><p>There are very few cons to migrating to Kotlin, but let’s go ahead and address these minor issues.</p><p><strong>Issue 1: Getting your team up to speed</strong></p><p>Like learning any new language, picking up Kotlin will take some time. Before you start, it’s a good idea for your team to get some familiarity programming with Kotlin. Fortunately, there are many<a href="https://try.kotlinlang.org/#/Examples/Hello,%20world!/Simplest%20version/Simplest%20version.kt"> Try-Kotlin</a> courses you can use to learn the language. Once you have a handle of Kotlin’s syntax, the best way to learn to develop in Kotlin is to dive in and convert or write some small classes. I’ll include a strategy to migrate to Kotlin step by step and get your team up to speed at the same time in the next Kotlin migration article.</p><p><strong>Issue 2: APIs with NonNull parameters are now enforced</strong></p><p>With Kotlin, you can now enforce APIs on NonNull parameters. Kotlin will not compile if you specifically try to put a null into a non-null API and the IDE will also warn you of the mistake. However, keep in mind when re-writing APIs that: if you have a runtime null going into a non-null API, Kotlin will force a crash with a null argument exception. This is not a big deal if you are diligent in rewriting your APIs and communicating any changes to your team.</p><p><strong>Issue 3: Generics</strong></p><p>If you have lots of generics in use in your Java code, Kotlin typing with Generics can sometimes be<a href="https://kotlinlang.org/docs/reference/generics.html"> more difficult</a>. Kotlin will work with generics at runtime, but may not statically verify your typecast of a generic at compile time, so Android Studio will show a warning. Also be aware that Java and Kotlin use generics in different ways. If your APIs include uses of generics and those APIs are used in Java classes, you may need to do some extra work around those APIs when you migrate them to Kotlin. When I work with generics in Kotlin, I try to make sure to use strong typing, extending my generics from a base type instead of using a * operator.</p><p><strong>Issue 4: Checking git changes after a migration</strong></p><p>One occasional headache that teams can run into when migrating to Kotlin is code reviewing converted files. This is not a big deal, when you’re done with your changes, just take these few extra steps to clean your commits and it will be easier to code review your file.</p><p>When you convert a class to Kotlin, you are renaming the file with .kt extension, so when you first view it in git, it can look like you removed the java file, and created a new .kt file. This can make it difficult to tell what you actually changed.</p><p>Fortunately, there’s an easy fix for this, when you’re done with your migration:</p><ol><li>Create a new branch, switch to the new branch.</li><li>Rename the files you’ve converted to Kotlin in the original branch to have a .kt extension instead of the .java extension. Commit.</li><li>Reset those files back to the .java extension and commit again.</li><li>Cherry-pick the changes from your migration branch over to your new branch. You will now have the .kt rename commit, the .java reset commit, and your cherry picked changes on your new branch.</li><li>Rebase your new branch, squashing the .java commit with the cherry picked changes</li><li>DONE! Now your git commit history will show just the changes within the Kotlin file, which is much easier to read.</li></ol><p>As you can see, there are plenty of benefits and advantages in converting to Kotlin. On the whole, migrating to Kotlin is a process that has great benefits to your team’s velocity, your code’s health, and your app’s performance. In the next article, we will discuss how to be an advocate for your team’s migration to Kotlin — proposing a phased migration approach that should help mitigate bugs and increase your team’s strength in Kotlin. See you soon!</p><p><em>“The Android robot is reproduced or modified from work created and shared by Google and used according to terms described in the </em><a href="https://creativecommons.org/licenses/by/3.0/"><em>Creative Commons </em></a><em>3.0 Attribution License.”</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2220218952a9" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>