<?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 Kshitij Aggarwal on Medium]]></title>
        <description><![CDATA[Stories by Kshitij Aggarwal on Medium]]></description>
        <link>https://medium.com/@funkyidol?source=rss-72e819d825d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*bKcZkCiuLAmnBVwZnuvRKQ.jpeg</url>
            <title>Stories by Kshitij Aggarwal on Medium</title>
            <link>https://medium.com/@funkyidol?source=rss-72e819d825d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 21:47:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@funkyidol/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[Exploring CameraX Beta (Part — 2): Image Analysis]]></title>
            <link>https://medium.com/@funkyidol/exploring-camerax-beta-part-2-image-analysis-4b4e18aacdb2?source=rss-72e819d825d------2</link>
            <guid isPermaLink="false">https://medium.com/p/4b4e18aacdb2</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[camerax]]></category>
            <dc:creator><![CDATA[Kshitij Aggarwal]]></dc:creator>
            <pubDate>Sat, 13 Jun 2020 14:41:52 GMT</pubDate>
            <atom:updated>2020-06-13T14:41:52.451Z</atom:updated>
            <content:encoded><![CDATA[<h3>Exploring CameraX Beta (Part — 2): Image Analysis</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TEtRGyVoreGK-BFafj2GLQ.png" /></figure><p><em>Update since the previous post</em></p><p><a href="https://medium.com/@funkyidol/exploring-camerax-beta-release-part-1-7b84f5bfa7a4">Exploring CameraX Beta Release (Part — 1)</a></p><p>Google has release a new beta update (1.0.0-beta4) to the CameraX api and one breaking change is that when setting the `createSurfaceProvider()` on the `viewFinder` we dont need to add the `cameraInfo` parameter. A very small and simple change that makes things a little more simpler.</p><pre>preview?.setSurfaceProvider(viewFinder.createSurfaceProvider(camera?.cameraInfo))<br>// changes to <br>preview?.setSurfaceProvider(viewFinder.createSurfaceProvider())</pre><p>— -</p><p>In our previous post we looked at how to setup CameraX api and create a simple camera preview screen within a fragment. In this post we will talk about how to setup an ‘Analysis’ use-case which will use the MLKit on-device text detection to read text. There are many samples available online which show this exact same thing but what I wanted to share is how to start and stop the analysis on-demand. Every sample that I have seen till now starts the analysis on camera start and does not show how you can stop it when required.</p><h3>Text Detection Implementation Steps</h3><ul><li>Include the following dependency in the module level `build.gradle`</li></ul><pre>implementation ‘com.google.android.gms:play-services-mlkit-text-recognition:16.0.0’</pre><ul><li>Add the following meta data to the AnroidManifest.xml</li></ul><pre> &lt;application …&gt;<br>    …<br>    &lt;meta-data<br>       android:name=”com.google.mlkit.vision.DEPENDENCIES”<br>       android:value=”ocr” /&gt;<br>    &lt;! — To use multiple models: android:value=”ocr,model2,model3&quot; →<br> &lt;/application&gt;</pre><ul><li>Create a new TextAnalyzer class and extend ImageAnalysis.Analyzer</li></ul><pre>class TextAnalyzer(private val result: (String) -&gt; Unit) : ImageAnalysis.Analyzer {<br> …<br> }</pre><p>We will also take a callback function parameter to send result back to the calling class</p><ul><li>Override the analyzemethod</li></ul><pre>override fun analyze(imageProxy: ImageProxy) {<br>}</pre><ul><li>Get the TextRecognizerinstance</li></ul><pre>val recognizer = TextRecognition.getClient()</pre><ul><li>Get the image from the imageProxy param</li></ul><pre>val mediaImage = imageProxy.image</pre><ul><li>If the mediaImage is not null then execute the following code</li></ul><pre>val image = InputImage.fromMediaImage(mediaImage,    imageProxy.imageInfo.rotationDegrees)<br>    recognizer.process(image)<br>      .addOnSuccessListener { text -&gt;<br>         Log.d(TAG, “Text ${text.text}”)<br>         result.invoke(text.text)<br>         imageProxy.close()<br>      }<br>     .addOnFailureListener { e -&gt;<br>         Log.e(TAG, “Mlkit processing Failed”, e)<br>         imageProxy.close()<br>      }</pre><p>Here we create the InputImage from the mediaImage and the rotationDegrees value from the imageProxy. We then send this inputImage to the recognizer for processing. In case of both success and failure we ensure that the imageProxy.close() is always called so CameraX API knows that the current frame processing is complete and it can move onto capturing the next frame.</p><ul><li>In our camera fragment (MainFragment) we now create the analysis use case and attach to the camera object. Please note that for now we are just attaching the use case and not the analyzer itself which we just created.</li></ul><pre>imageAnalysis = ImageAnalysis.Builder() <br>  .setTargetResolution(Size(1280, 720)) <br>  .setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST)<br>  .build() </pre><p>Camera binding now changes to</p><pre> camera =<br>    cameraProvider.bindToLifecycle(<br>       this as LifecycleOwner,<br>       cameraSelector,<br>       preview,<br>       imageAnalysis<br>    )</pre><ul><li>We now add a button to the UI to enable and disable the text analysis on demand</li></ul><pre>btn_analyze.setOnClickListener { <br>   if (!featureOn) {<br>      featureOn = true<br>      imageAnalysis.setAnalyzer(cameraExecutor, TextAnalyzer() { <br>          tv_result.text = it<br>      })<br>   } else {<br>      featureOn = false<br>      imageAnalysis.clearAnalyzer()<br>   }<br> }</pre><p>So now, when we have to turn on the text analysis we create a new instance of the TextAnalyzer class and set it to the imageAnalysis use-case. And on it callback result we show the text on the screen to show the detected text.<br> When we turn off the the text analysis, we just clear the imageAnalysis use-case from all the attached analyzers.</p><p>And thats it. Just by attaching and clearing the use-cases we can create on-demand analysis features using the CameraX api. You can find the complete source code for this post on the commit <a href="https://github.com/funkyidol/CameraXSample/commit/4397d1249ea49b6f2e13c10cc5be7c8adedb38f8">here</a></p><p><em>This post was originally posted here: </em><a href="https://dev.to/funkyidol/exploring-camerax-api-beta-part-2-image-analysis-1hha"><em>https://dev.to/funkyidol/exploring-camerax-api-beta-part-2-image-analysis-1hha</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4b4e18aacdb2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploring CameraX Beta Release (Part — 1)]]></title>
            <link>https://medium.com/@funkyidol/exploring-camerax-beta-release-part-1-7b84f5bfa7a4?source=rss-72e819d825d------2</link>
            <guid isPermaLink="false">https://medium.com/p/7b84f5bfa7a4</guid>
            <category><![CDATA[camerax]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Kshitij Aggarwal]]></dc:creator>
            <pubDate>Mon, 18 May 2020 06:00:43 GMT</pubDate>
            <atom:updated>2020-06-13T13:41:34.561Z</atom:updated>
            <content:encoded><![CDATA[<h3>Exploring CameraX Beta (Part — 1): Basic Setup</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FXZPRM9kSZojXFh4sXampg.png" /><figcaption>Exploring CameraX Beta</figcaption></figure><p>CameraX is probably one of the most requested API’s that most developers dealing with the Android camera API setup are looking forward to. What the team developing the CameraX API is doing is no easy feat and this also shows in the development path of the API with pretty massive changes happening throughout the Alpha development stage. (<a href="https://developer.android.com/jetpack/androidx/releases/camera">Release notes &amp; history</a>)</p><p>This blog post is first of the series on CameraX where I try and explore the API (1.0.0-beta03 at the time of writing this article) in a more in-depth manner at an implementation level with a real-use setup (read ‘fragments’) since most of the CameraX explorations I have found have been prior to the <a href="https://developer.android.com/jetpack/androidx/releases/camera#camera-core-1.0.0-alpha07">1.0.0-alpha7</a> release, which by now have been changed significantly.</p><h3><strong>Implementation Steps</strong></h3><p>The following are the implementation steps I followed to get a simple camera preview using CameraX</p><ul><li>Include the following gradle dependencies in your project level build.gradle</li></ul><pre>dependencies {<br>       // CameraX core library<br>       def camerax_version = &#39;1.0.0-beta03&#39;<br>       implementation &quot;androidx.camera:camera-core:$camerax_version&quot;</pre><pre>       // CameraX Camera2 extensions<br>       implementation &quot;androidx.camera:camera-camera2:$camerax_version&quot;</pre><pre>       // CameraX Lifecycle library<br>       implementation &quot;androidx.camera:camera-lifecycle:$camerax_version&quot;</pre><pre>       // CameraX View class<br>       implementation &#39;androidx.camera:camera-view:1.0.0-alpha10&#39;<br>       implementation &#39;androidx.fragment:fragment:1.2.4&#39;<br>   }</pre><ul><li>Add the PreviewView component in the fragment layout XML</li></ul><pre>&lt;androidx.camera.view.PreviewView<br>       android:id=&quot;@+id/view_finder&quot;<br>       android:layout_width=&quot;match_parent&quot;<br>       android:layout_height=&quot;match_parent&quot; /&gt;</pre><ul><li>Add the Camera permissions to the AndroidManifest.xml and implement the permissions provider in your fragment</li></ul><pre>&lt;uses-permission android:name=&quot;android.permission.CAMERA&quot; /&gt;</pre><ul><li>Add the following method to add the camera preview use-case to the fragment</li></ul><pre>private fun bindCameraUseCases() {</pre><pre>           // Get screen metrics used to setup camera for full screen resolution<br>           val metrics = DisplayMetrics().also { viewFinder.display.getRealMetrics(it) }<br>           Log.d(TAG, &quot;Screen metrics: ${metrics.widthPixels} x ${metrics.heightPixels}&quot;)</pre><pre>           val screenAspectRatio = aspectRatio(metrics.widthPixels, metrics.heightPixels)<br>           Log.d(TAG, &quot;Preview aspect ratio: $screenAspectRatio&quot;)</pre><pre>           val rotation = viewFinder.display.rotation</pre><pre>           // Bind the CameraProvider to the LifeCycleOwner<br>           val cameraSelector = CameraSelector.Builder().requireLensFacing(lensFacing).build()<br>           val cameraProviderFuture = ProcessCameraProvider.getInstance(requireContext())<br>           cameraProviderFuture.addListener(Runnable {</pre><pre>               // CameraProvider<br>               val cameraProvider: ProcessCameraProvider = cameraProviderFuture.get()</pre><pre>               // Preview<br>               preview = Preview.Builder()<br>                   // We request aspect ratio but no resolution<br>                   .setTargetAspectRatio(screenAspectRatio)<br>                   // Set initial target rotation<br>                   .setTargetRotation(rotation)<br>                   .build()</pre><pre>               // Must unbind the use-cases before rebinding them<br>               cameraProvider.unbindAll()</pre><pre>               try {<br>                   // A variable number of use-cases can be passed here -<br>                   // camera provides access to CameraControl &amp; CameraInfo<br>                   camera = cameraProvider.bindToLifecycle(this, cameraSelector, preview)</pre><pre>                   // Attach the viewfinder&#39;s surface provider to preview use case<br>                   preview?.setSurfaceProvider(viewFinder.createSurfaceProvider(camera?.cameraInfo))<br>               } catch (exc: Exception) {<br>                   Log.e(TAG, &quot;Use case binding failed&quot;, exc)<br>               }</pre><pre>           }, ContextCompat.getMainExecutor(requireContext()))<br>       }</pre><ul><li>Add the following helper method to find the correct aspect ratio of the device and set it to CameraX</li></ul><pre>private fun aspectRatio(width: Int, height: Int): Int {<br>       val previewRatio = max(width, height).toDouble() / min(width, height)<br>       if (abs(previewRatio - RATIO_4_3_VALUE) &lt;= abs(previewRatio - RATIO_16_9_VALUE)) {<br>           return AspectRatio.RATIO_4_3<br>       }<br>       return AspectRatio.RATIO_16_9<br>   }</pre><ul><li>Start the camera</li></ul><pre>private fun startCamera() {<br>       viewFinder.post {<br>           bindCameraUseCases()<br>       }<br>   }</pre><p>That’s all folks. You just need to handle the camera permissions in the usual manner and the above code will give you the basic camera preview setup. Now lets dig a little deeper and see what are we actually doing here.</p><h3>Explanation</h3><ul><li><strong>Find the device aspect ratio and rotation values</strong> We will use the DisplayMetrics API to find these values and use them later in both setting up CameraX as well as in future scenarios send this to MLKit.</li></ul><pre>val metrics = DisplayMetrics().also { viewFinder.display.getRealMetrics(it) }<br>   val screenAspectRatio = aspectRatio(metrics.widthPixels, metrics.heightPixels)<br>   val rotation = viewFinder.display.rotation</pre><ul><li><strong>Select which camera to use and create a </strong><strong>ListenableFuture of the </strong><strong>ProcessCameraProvider</strong></li></ul><pre>val cameraSelector = CameraSelector.Builder().requireLensFacing(lensFacing).build()<br>   val cameraProviderFuture = ProcessCameraProvider.getInstance(requireContext())</pre><p>A ListenableFuture in short allows you to register callbacks to be executed once the asynchronous computation is complete, or if the computation is already complete, immediately. You can find more details in the <a href="https://github.com/google/guava/wiki/ListenableFutureExplained">official documentation</a><br> Callback for this cameraProviderFuture contains the logic for when the ProcessCameraProvider is available to prepare it to be initialized by binding it to the lifecycle and required use cases</p><ul><li><strong>Prepare the camera preview use case</strong> Here we prepare the camera preview use case using the aspect ratio and rotation values calculated earlier.</li></ul><pre>preview = Preview.Builder()<br>       // We request aspect ratio but no resolution<br>       .setTargetAspectRatio(screenAspectRatio)<br>       // Set initial target rotation<br>       .setTargetRotation(rotation)<br>       .build()</pre><p>Use-cases provide a very clear abstraction between the three main things we generally use camera for — preview the camera feed, capture from the camera feed and analyse the captured frames. CameraX provide these three use-cases as separate classes which we can extend as per our requirement. You can find more details about the use-cases in the <a href="https://developer.android.com/training/camerax/architecture#combine-use-cases">official documentation</a> and we will explore them further in future articles in this series.</p><ul><li><strong>Bind the </strong><strong>ProcessCameraProvider to the lifecycle along with the use-cases</strong> First we have to unbind all the existing use-cases from the camera provider. If not it will throw runtime exception</li></ul><pre>cameraProvider.unbindAll()</pre><p>Binding the ProcessCameraProvider to the lifecycle is a must as this allows the CameraX API to automatically manage the camera resources bases on the provided lifecycle, reducing a lot of boilerplate code needed earlier with Camera2 API. We also attach our use-case here, Preview use-case in our sample, for the CameraX API to show the camera preview. We now take this post-binding camera instance and set it to the PreviewView object from the layout xml. This is where the preview will be rendered on the UI</p><pre>try {<br>       // A variable number of use-cases can be passed here -<br>       // camera provides access to CameraControl &amp; CameraInfo<br>       camera = cameraProvider.bindToLifecycle(this, cameraSelector, preview)</pre><pre>       // Attach the viewfinder&#39;s surface provider to preview use case<br>       preview?.setSurfaceProvider(viewFinder.createSurfaceProvider(camera?.cameraInfo))<br>   } catch (exc: Exception) {<br>       Log.e(TAG, &quot;Use case binding failed&quot;, exc)<br>   }</pre><ul><li><strong>Start the camera</strong> Calling the ‘bind’ code in post on the viewFinder ensures that the code is called on the UI thread, which is mandatory for initiating the CameraX API. Not doing this will give a run-time exception.</li></ul><pre>viewFinder.post {<br>       bindCameraUseCases()<br>   }</pre><p>And now we have a fully functional camera preview app using CameraX. You can find the complete source code here: <a href="https://github.com/funkyidol/CameraXSample">https://github.com/funkyidol/CameraXSample</a>.</p><p>Hope this helps &amp; give me a follow to receive notifications for future articles in this series.</p><p><em>This post was originally posted here: </em><a href="https://dev.to/funkyidol/exploring-camerax-beta-release-part-1-19hh"><em>https://dev.to/funkyidol/exploring-camerax-beta-release-part-1-19hh</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7b84f5bfa7a4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Regolith Linux — My descent into Mouse-less navigation]]></title>
            <link>https://medium.com/@funkyidol/regolith-linux-my-descent-into-mouse-less-navigation-f952c6e7aa17?source=rss-72e819d825d------2</link>
            <guid isPermaLink="false">https://medium.com/p/f952c6e7aa17</guid>
            <category><![CDATA[i3]]></category>
            <category><![CDATA[i3wm]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[ubuntu]]></category>
            <category><![CDATA[regolith]]></category>
            <dc:creator><![CDATA[Kshitij Aggarwal]]></dc:creator>
            <pubDate>Wed, 22 Apr 2020 06:25:33 GMT</pubDate>
            <atom:updated>2020-04-22T06:25:33.447Z</atom:updated>
            <content:encoded><![CDATA[<h3>Regolith Linux — My descent into Mouse-less navigation</h3><h3>What got me interested?</h3><p>I like to keep things simple and stick to the defaults as much as possible (as much as I would love to customize the hell out of things, sadly I don’t have that kind of time nowadays) and after distro-hopping for a while, I was happy to use stock Ubuntu.</p><p>I stuck to the non-LTS release starting from 19.04 and then upgraded to 19.10, but all this while one thing that bothered me a lot was the amount of RAM being consumed by the Gnome Window Manager. It’s always fine after a fresh start or reboot at the beginning of the day with around 500–600 MB of usage but by sunset, my usage generally climbs upwards of 1.1 GB. On a 16 GB that’s a huge amount especially when my Android IDE, Emulator, Browser and 5 other things are all fighting each other for the already vanishing sweet piece of RAM pie. And also there is this nagging feeling as a developer that there has to be some sort of a memory leak somewhere, because of which this process keeps increasing in size every few hours. At one point I was considering buying more RAM for my laptop just because this was becoming a daily nuisance for me.</p><p>I then started to look for a lightweight Window Managers (WM’s) to replace Gnome with something more stable and easy on the memory. There are a lot of excellent options like XFCE and some others, but all of them seemed very outdated in terms of their underlying technology for 2020 (though being more stable at the same time, from what people shared on forums).</p><p>A good friend of mine (and a huge Linux advocate) had suggested me to try out i3wm (a Tiling WM — more on that later) some time back and I quickly dismissed that option at that time because I wasn’t convinced about having a keyboard-driven WM. But this time around I gave it a more serious look as I was pretty pissed at Gnome and couldn’t wait for the Ubuntu 20.04 update to land.</p><h3>And I discovered Regolith Linux</h3><p>While giving i3wm a more dedicated research time I found <strong>Regolith Linux</strong> (<a href="https://regolith-linux.org/">https://regolith-linux.org/</a>), which instead of creating a new DE (Desktop Environment) chose to create a collection of open source components bundled in a way to make transition and usage of i3wm easier. Looking at there Github Page(<a href="https://github.com/regolith-linux/regolith-desktop">https://github.com/regolith-linux/regolith-desktop</a>), its just a meta package which just holds the issue tracker and release files. It very thoughtfully combines various independent components like i3-gaps WM, Rofi application launcher and notification system, i3bar etc. to create an easy to adopt package, which otherwise takes a lot of time to setup when starting with i3wm.</p><h4>Tiling Window Manager</h4><p>All this combined makes up for a fairly easy to use <strong>Tiling Window Manager</strong> (<a href="https://en.wikipedia.org/wiki/Tiling_window_manager">https://en.wikipedia.org/wiki/Tiling_window_manager</a>). A Tiling WM is a very unconventional kind of a WM where multiple applications or windows when opened together do not float or overlap each other. They only open beside each other, oriented either vertically or horizontally. No more floating windows, no hidden windows behind one another, no need for a mouse to move windows around. Everything is laid out like Tetris tiles alongside each other. And what do you do when you have too many things open at the same time or you want one of the windows to be full screen, you simply move it to a different ‘workspace’. In the following sections, I will talk in more detail about how to get more comfortable with this fundamental shift in the way we use our desktop environment all the while using <strong>just the keyboard</strong>.</p><h3>Installation</h3><p>Regolith is available as both a pre-bundled ISO and a standalone installable PPA. I chose to install it over my current setup as a PPA. (<a href="https://regolith-linux.org/download/">https://regolith-linux.org/download/</a>)</p><p>Use the following commands to install Regolith via PPA.</p><blockquote>$ sudo add-apt-repository ppa:regolith-linux/release<br>$ sudo apt install regolith-desktop</blockquote><p>And once installed, restart and Regolith will appear as a desktop session on the login screen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*likyS31skWzDWDeWsHC0tQ.png" /></figure><p>When you login, you are welcome to this screen with the quick list of keyboard shortcuts to help you start your journey on adopting Regolith. This helper overlay is what makes it so easy to start using the i3wm.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*13GlBT6x9DDZ0_FKgCvBGQ.png" /></figure><h3>Getting Familiar</h3><p>`Super` key is your best friend in this desktop environment. Everything that you wish to do all starts with the `Super` key. To show or hide this keymap overlay just press `Super + Shift + ?`<br>To launch an application, just press `Super + Space` to start the launcher app</p><p>I won’t list all the keyboard shortcuts here which are readily available in the help menu. Rather I would talk about some common usage patterns and how to quickly get into the habit of using those patterns.</p><p>But before that, let’s get a little more familiar with the environment itself.</p><h4>Workspaces</h4><p>On the bottom left is our workspace indicators. The workspaces are how we spread our windows around in this system instead of stacking them over each other. You start with only one workspace when you login but as you move windows around to the workspaces, they become active. The workspaces might be numbered but it’s not required to use them in sequential order. You can use whichever workspaces at any given point as per your comfort. The highlighted workspace indicator will tell you which workspace is currently active.</p><h4>App Launcher</h4><p>Regolith bundles the ‘Rofi Application Launcher’ which is a type-to-search type of a launcher. Just start typing what you are looking for and it will immediately filter results based on the text. And as you use this launcher more and more it starts remembering your choices and starts showing them on first like in the image below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DnCMOjgJnjw5yu_0KYK9Cg.png" /></figure><blockquote>One thing to remember here is that ‘restart’ is actually ‘reboot’ here so it might be something to look for when starting out.</blockquote><h4>Notifications</h4><p>Notifications is probably the most not-so-obvious feature in Regolith. Regolith bundles with the [Rofication Notification System](<a href="https://regolith-linux.org/docs/interface/notifications/">https://regolith-linux.org/docs/interface/notifications/</a>) which takes a very bold decision of never showing an alert for your notifications, making the setup distraction-free. All new notifications received go on to incrementing a counter near the bottom right of the i3bar. There is still a notification sound but no visible UI alerts. To see the notification you press `Super + n` to open a rofi window showing all the notifications. This is something I like a lot since it helps alleviate visual distractions while I’m doing deep work.</p><p>Now the other big thing with these notifications is that they are non-actionable. You cannot click or select this notification to open the respective app which furnished the notification. For me, this needed getting used to as with the traditional notifications system we are in the habit of taking actions directly on the notification to open the respective application. But on a personal level, I am fine with it since most of the notification I receive are from Slack or Android Studio. <br>To delete these notifications simply press `Delete` to remove individual notifications or `Shift + Delete` to delete all notifications from a particular app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jDwA6Esz6EutcxF1Qy0yoQ.png" /></figure><h4>Traditional Gnome Settings</h4><p>One good thing about Regolith, which is not available in the standard i3wm setup is the availability of the traditional gnome settings manager to allow you easy access to system settings without the need of relearning anything here. Its implemented as normal floating windows easy to interact with using a mouse.</p><h4>Navigation and Usage Patterns</h4><p><strong>Working with non-tillable windows</strong><br>There are a few applications which work well in the tiling paradigm and can lead to some weird window placements and artifacts. This happens for me notably with the Android Emulator.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nZDLtXG37ub-4_U4vPZK0g.png" /></figure><p>Luckily we do have an option to make any window a floating window. Pressing `Super + Shift + F` on the currently selected window makes if a floating one which then overlaps the rest of the environment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3LNz6vZ_B0jP8OuwmpI0xA.png" /></figure><p>But we can’t simply move this window around with the mouse. Here once again we have to take help from our friend the `Super` key and keep it pressed to enable window dragging behavior while you move the window around using the mouse.</p><p><strong>Setting up a workflow</strong><br> The AHA moment truly came to me when I created a workflow for myself and realized how easy it is to do pretty much everything with just the keyboard. To start setting up a workflow first we have to understand that all the applications that we will be using will live on separate workspaces. So basically you have to plan your workspaces depending on the **priority and frequency** of the apps which are in play. <br> For me the browser is the go-to app, so Firefox lives in the Workspace-1. Next is Android Studio which goes in Workspace-3 and next Slack which goes in Workspace-5. I chose Workspace-3&amp;5 because that way my most important apps are all on odd workspace numbers. On Workspace-2, I have my Notion app and Gitlab app in vertical split mode. All music players go on Workspace-4 and anything extra goes in Workspace-6. I have had to rarely use more than 6 workspaces at a given time. In the customization section, I will talk about how to automatically move windows to these workspaces at launch.</p><p><strong>Working parallelly in multiple apps<br></strong>As I mentioned earlier, in this tiling desktop environment, apps open along with each other.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2r__qN8hHA8OVq9t6fdb4g.png" /></figure><p>When more than one app are open, they always show up dividing the currently available space in half either vertically or horizontally. By default, the apps always open split vertically side-by-side.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ROjjHJkwNFIfXmP_Y5op_A.png" /></figure><p>So the first window shows of full screen, second split it in half, the third app will split the screen in one-thirds and so on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0Nol7JReNfjQZfggzw-fAw.png" /></figure><p>But instead, if I wish to open the third app split in the lower half of the right side split horizontally, I will just press the orientation modifier i.e. `Super + Backspace` before opening the third app. And not when I open the third app its shown like in the image below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GLVgiB0mw1GNHZ3kooVyIw.png" /></figure><p>The power of Regolith shines especially when you have multiple apps open in the same workspace aligned in the grid pattern of your choice. To move focus between the various windows, instead of moving the mouse, you can very quickly press `Super + &lt;arrow keys&gt;` to focus on the app depending on the window layout.</p><p><strong>Moving windows between workspaces</strong><br> This point is more about adopting a new habit more than anything else. To move the currently selected window to a different workspace we press `Super + Shift + &lt;workspace number&gt;`. This moves the current window to the desired workspace while keeping you on the workspace you were on. So if I wanted to move my terminal window from Workspace-1 to 2 but while remaining on Workspace-1 then I press `Super + Shift + 2`. But If I want to ‘take’ the terminal window ‘with me’ to Workspace-2 then I press `Super + Alt +2`, This moves the terminal window to Workspace-2 and also makes it the active workspace.</p><p><strong>Resizing windows</strong><br> One behavior I was not expecting to be this easy to do without a mouse was resizing windows. Pressing `Super + r` starts the window edit mode where pressing ‘left’ or ‘right’ resizes the split of horizontal windows and ‘up’ or ‘down’ resizes the split for vertical windows. You can also press ‘+’ or ‘-’ to increase or decrease margin between the windows. With a contrasting wallpaper, it looks pretty cool. Press `Esc` or `Super + r` again to exit the edit mode.</p><h3>Customization</h3><p>Though I was pretty happy with the default configuration that Regolith provides for i3, there were a few things I still wanted to change to help make things easier.</p><p>But before starting any customization we first have to setup the i3 config file to modify it. Best way to do so is to follow the steps in this link: <a href="https://regolith-linux.org/docs/howto/stage-configs/">https://regolith-linux.org/docs/howto/stage-configs/</a></p><p><strong>Auto open apps in specific workspaces</strong><br> After you have staged the i3 config files in the path `/home/&lt;user&gt;/.config/regolith/i3` modify the config file and append the following in the end.</p><blockquote>for_window [class=”Slack”] move to workspace $ws5<br> for_window [class=”jetbrains-studio”] move to workspace $ws3<br> for_window [class=”ICE-SSB-notion”] move to workspace $ws2<br> for_window [class=”ICE-SSB-gitlab”] move to workspace $ws2<br> for_window [class=”Rhythmbox”] move to workspace $ws4</blockquote><p>The above code will always move my Slack window to Workspace-5, Android Studio to Workspace-3 and so on. <br> <em>Hot Tip:</em> If you want to find the name of the window to be included in the above code, just open a terminal and type `xprop` and then click with your mouse on the desired window. It will print a lot of window-related internal details in the terminal and you can pick up the window name from there.</p><p><strong>Show RAM usage in bottom bar</strong><br> By default the bottom i3 bar shows everything except the RAM usage which is still super awesome because most desktop environments don’t show resource usage by default and you have to go hunting for an extension or app to do so. So to enable the RAM usage indicator, go to `/home/&lt;user&gt;/.config/regolith/i3xrocks` and open the config file and uncomment the following lines</p><blockquote>[memory]<br>interval=10</blockquote><p>Now just type `regolith-look refresh` in the terminal to show the small pie chart of the total RAM with the available RAM amount.</p><p><strong>Add a “Clipboard Manager”</strong><br> This was the <strong>most</strong> tricky thing to get working in Regolith. As a daily user of Gpaste, clipboard manager is part of my regular flow of working when copy-pasting code from Stack Overflow on to my project and because there is no default support for traditional pop-up window systems, Gpaste didn’t work. After a lot of Googling and hit and trials, I landed on <strong>Greenclip</strong> (<a href="https://github.com/erebe/greenclip">https://github.com/erebe/greenclip</a>). This a rofi based clipboard manager which integrates which shows the previous selections similarly to how the notifications are shown.</p><p>To install, just download the executable from the github page and add the following file to the Regolith config file</p><blockquote># Greenclip<br> set $greenclip /path/to/file/greenclip<br> bindsym $mod+Shift+v exec rofi -modi “clipboard:$greenclip print” -show clipboard<br> exec — no-startup-id $greenclip daemon</blockquote><p>You can check out the video linked in the Greenclip Github page readme for detailed step by step instructions.</p><h3>Not everything is perfect</h3><p>Frankly, I don’t have much to write in this section apart from the fact that using Regolith definitely had its own learning curve but not as much as a vanilla i3wm setup would be. It’s obviously about what clicks for whom and putting in just the little bit of effort to becoming more productive and feel like a “Hacker Man”.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FRyXVu4ZW454IM%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FRyXVu4ZW454IM%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FRyXVu4ZW454IM%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/6f3389df704816b202ba13f2cb2ab0f0/href">https://medium.com/media/6f3389df704816b202ba13f2cb2ab0f0/href</a></iframe><p>Though I’m still learning the ropes of using more keyboard shortcuts to get a better window layout, but all that I feel will come with time as its need would move up from good-to-have to must-have</p><h3>Future</h3><p>Though I’m super happy with my setup right now, I find the <strong>Pop Shell</strong> (<a href="https://www.omgubuntu.co.uk/2020/03/pop-shell-wants-to-bring-proper-tiling-window-features-to-gnome-shell">https://www.omgubuntu.co.uk/2020/03/pop-shell-wants-to-bring-proper-tiling-window-features-to-gnome-shell</a>) extension from System76 to be really interesting. This extension will bring the goodness of tiling WM to the standard Gnome setup which will make it further easier to use for first time adopters. But I still can’t shake the feeling that using Gnome will still be a lot more resource hungry compared to the minimalistic i3wm via Regolith. None the less I’m also looking forward to the new developments and releases of Regolith Linux and if possible consider a donation to the developers.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f952c6e7aa17" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Effective logging in Production with Firebase Crashlytics]]></title>
            <link>https://medium.com/letsenvision/effective-logging-in-production-with-firebase-crashlytics-9fb3af9f242d?source=rss-72e819d825d------2</link>
            <guid isPermaLink="false">https://medium.com/p/9fb3af9f242d</guid>
            <category><![CDATA[logging]]></category>
            <category><![CDATA[crashlytics]]></category>
            <category><![CDATA[mobile-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Kshitij Aggarwal]]></dc:creator>
            <pubDate>Wed, 24 Jul 2019 07:01:01 GMT</pubDate>
            <atom:updated>2019-07-24T07:01:01.066Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Firebase Crashlytics" src="https://cdn-images-1.medium.com/max/1024/1*oXc49-L319DTt3LEXr-k_w.png" /><figcaption>Firebase Crashlytics</figcaption></figure><p>Logging and specifically crash logging is a very important aspect of any app that is available beyond a developers machine. It&#39;s simply the act of getting the internal application details generated at the time of the application crash. Be it available to testers or available for public use, catching crashes and identifying errors is critically important for developers to provide a quality product. In mobile app development, Firebase Crashlytics is one of the most widely used Crash logging tools. Crashlytics was built by Fabric (Owned by Twitter) and was later bought by Google and integrated within Firebase.</p><p>At Envision, we heavily rely on Crashlytics to give us the insight into our app quality and any issues our users might be facing while using our app. With Crashlytics, we get the crashes our users face, as well as any internal issues our app might be running into which are not necessarily visible to end-users.</p><h3>Goals</h3><p>The goals we have with Crashlytics currently are:</p><ol><li>Crash Logging</li><li>Issue Identification &amp; Diagnosis</li><li>App Behavior insight</li></ol><h3>Implementation</h3><p>There are various features in Crashlytics that generally go unnoticed. We would like to highlight some of the ways we use Crashlytics to achieve the aforementioned goals.</p><p>P.S. — The following details are Android-specific but can be easily translated for iOS. All the links below also contain the steps and details of implementing Crashlytics in iOS</p><ul><li><strong>Automatic Crash Logging<br></strong> Part of the core feature set, automatic crash logging is what you get the moment you integrate Crashlytics in your project. You can find the integration steps <a href="https://firebase.google.com/docs/crashlytics/get-started?platform=android">here</a>. If you want to exclude debug builds from polluting your crash logs during active development, you can follow the steps <a href="https://firebase.google.com/docs/crashlytics/customize-crash-reports?platform=android#enable_opt-in_reporting">here</a>.</li><li><strong>Non-Fatal Logging<br></strong> Non-Fatal logging is where we start using the advanced features of Crashlytics which helps in diagnosing and fixing issues beyond the crashes logged while the app was being used. When exceptions are logged manually in Firebase, they are logged as non-fatals. The best way to use non-fatals in your app is to log all exceptions generated in the catch section of the try/catch block. Additionally, we also create exceptions and log them in situations where our app is in an undesirable state and needs to be examined for the cause and determine its effect on the app.</li></ul><pre> try {<br>     methodThatThrows()<br> } catch (e: Exception) {<br>     Crashlytics.logException(e)<br>     // handle your exception here<br> }</pre><ul><li><strong>Debug Logging<br></strong> We use Timber for managing logs on Android and it makes it very easy for us to manage our logging in debug &amp; production versions. The following configuration prints the logs to the console in the debug version, but in the production versions, it sends the debug logs along with the exception to Firebase.</li></ul><pre>override fun onCreate() {<br>      super.onCreate()<br>         if (!BuildConfig.DEBUG) {<br>             Fabric.with(this, Crashlytics())<br>             Timber.plant(CrashReportingTree())<br>         } else {<br>             Timber.plant(Timber.DebugTree())<br>         }<br>   }<br>        <br>   private inner class CrashReportingTree : Timber.Tree() {<br>      override fun log(priority: Int, tag: String?, message: String, throwable: Throwable?) {<br>         if (priority == Log.ERROR || priority == Log.DEBUG) {<br>            Crashlytics.log(priority, tag, message)<br>            if (throwable != null) {<br>               Crashlytics.logException(throwable)<br>            }<br>         } else return<br>      }<br>  }</pre><ul><li><strong>User Id/Email tagging</strong><br>Firebase has the ability to attach the logs collected from a particular user to their unique UserId. This allows us to diagnose and fix issues reported to us by our users especially during the beta test phase. In the Firebase console, we have the ability to filter crashes and non-fatal logs for a particular user. <br>Crashlytics.setUserIdentifier(userId)</li><li><strong>App Versioning</strong><br>At Envision, we try to follow proper versioning of our beta and release builds so that all the crashes and logs collected in Firebase can be quickly filtered for a specific version and fixed for the next version. This same scheme is followed for the internal test builds as well so that additional data could be logged exclusively to the test versions.</li></ul><h3>Bottlenecks</h3><p>Even with all these advanced features, Firebase still falls short is some occasions.</p><ol><li><strong>Limited log collection storage</strong><br>Debug Log storage is limited to 64KB per user in Firebase and older logs are deleted as new logs come in. This can be a big hindrance in issue diagnostic since many at times by the time we identify an issue and begin diagnostics, the logs are gone.</li><li><strong>Limited filtering options </strong><br>The number of filtering options in Firebase is limited to app versions, crashes vs. non-fatals, and User Id. All these work fine for basic crash log usage but for more complex and rare issues these filtering options are restricting. There are no ways in which logs can be filtered out based on a specific OEM, device category or device model. This is especially useful for Android apps where the number of available devices and OEM’s are huge and device-specific issues are common.</li><li><strong>No search functionality </strong><br>There is no search functionality in Firebase Crashlytics to search for a specific crash or debug log which again becomes very essential when dealing with specific issues or diagnosing rare crashes.</li><li><strong>Slow interface </strong><br>Using the Firebase console overall feels very slow and bloated with very large page loading and rendering times. And that is when you are using the Chrome browser. I become much slower when using Firefox.</li><li><strong>No custom alerts </strong><br>Firebase is very limited when it comes to issues or trend alerts. They only send email alerts for new issues, regression issues, and trending issues. There are no ways to create custom alerts for e.g. alerts for trends for a specific issue or specific device.</li><li><strong>No way to directly see debug logs </strong><br>Currently, the only way to see debug logs is to find them inside a crash log or a non-fatal crash. We understand that the way debug logs are collected and associated on a per crash/non-fatal basis but there should be ways for us to traverse through debug logs on a per User Id or device model basis as well.</li><li><strong>Limited dashboard &amp; graph statistics </strong><br>There is only one usable graph that is presented inside Firebase Crashlytics and that is the total crash count on a day, week or month basis. There should be more ways for us to visualize the crash statistics as well. Fabric had very useful graphs on their dashboards that gave a lot of value without us to dig around for that info.</li></ol><h3>Going Forward</h3><p>As our app matures and our use case, Crashlytics has come to a point where we are getting restricted on a regular basis in achieving our goals to quickly identify and resolve issues. We are now looking at some other 3rd party &amp; more advanced crash logging solutions such as <a href="http://www.bugsnag.com/">BugSnag</a> which might be paid but add value to our product in terms of reaching higher quality.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9fb3af9f242d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/letsenvision/effective-logging-in-production-with-firebase-crashlytics-9fb3af9f242d">Effective logging in Production with Firebase Crashlytics</a> was originally published in <a href="https://medium.com/letsenvision">Envision</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why becoming & staying productive in India is difficult]]></title>
            <link>https://medium.com/@funkyidol/why-becoming-staying-productive-in-india-is-difficult-d21655212e65?source=rss-72e819d825d------2</link>
            <guid isPermaLink="false">https://medium.com/p/d21655212e65</guid>
            <category><![CDATA[developer-stories]]></category>
            <category><![CDATA[developer-tools]]></category>
            <category><![CDATA[india]]></category>
            <category><![CDATA[remote-working]]></category>
            <category><![CDATA[developer-productivity]]></category>
            <dc:creator><![CDATA[Kshitij Aggarwal]]></dc:creator>
            <pubDate>Tue, 04 Jun 2019 11:23:44 GMT</pubDate>
            <atom:updated>2019-06-04T11:23:44.337Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XWCrOtVijQ8gqcEWKuWMBA.jpeg" /></figure><p>People talk a lot about developer productivity but some points that people don’t talk about are the environmental issues, available options, and pricing at which the tools are available to the developers in a particular country. Building &amp; maintaining a productive work environment as an independent developer in India is very costly. So costly that on average we pay 2 to 3 times &amp; sometimes even higher for the same hardware, software, and accessories than what people have to pay outside India.</p><p>But it’s not just the price but many other factors that I want to bring to your attention:</p><h3>Cost Issues</h3><ol><li><strong>Costly Hardware:</strong> General cost of hardware (laptops/computers) and their accessories (monitors/keyboard/mice) are much higher in India compared to the US or East Asian market. My current laptop (Dell 7570) which I procured from the US cost me 25% lesser than what was available in India. My recent research into external monitor pricing also revealed a difference of good 30% to 50% between various models. And all these differences are direct market pricing and don’t even consider the various deals that can increase the difference to approx double.</li><li><strong>Subpar Configuration:</strong> The configuration that is available in India for laptops, computers, monitors, etc, for the most part, can be categorized as aftermarket leftover. The kind of configurations that are offered specially for the pre-build machines like laptops is bare-bones at a price point which will generally fetch a medium level config in other markets. And even the configurations which are supposedly “maxed out” have limited RAM, SSD, or Display options. For e.g. the laptop I own now has a 4K display (which I got from the US) was not even an option in any of the configurations available in India. And again going back to the first point, the prices at which these machines are offered are way more than the maxed out options in other countries. Similarly, for monitors, the specs with which they are available in India are generally many generations old but we still have to pay the full price that is of the current generation one.</li><li><strong>Limited Companies &amp; options:</strong> The number of companies that are actively selling their products are just limited to very high-end brands. It’s a bit contrasting in nature when compared to the mobile industry where the devices are launched in India as soon as they are announced but for computer hardware peripherals we have to wait for months and sometimes years for products to start selling locally. Sometimes they are never even bought to the Indian market altogether. Logitech, Razer, and other such peripheral companies are another example where they don’t offer most of the range of their devices in the Indian market.</li><li><strong>Non-existent Customer Support:</strong> The idea of customer support is a joke in India. Anytime you have to deal with customer support for most of the organizations, you can very well kiss your product goodbye. Apart from the handful of companies like Logitech with which I have had good experience with, most companies just fail to deliver on the concept of customer support. Whereas in the US I have heard of easy exchange or repair policies in case the hardware faces any issue, no such policy exists in India. At max, they will offer to repair your device at prices that are close to the price of the original device and take many months to repair, that too when your product is under warranty. And even if you bought your product outside India which on paper has an International warranty, customer support will deny any help citing unavailability of the configuration in India. In the end, even if you are willing to pay money for a product, keeping it alive for a natural lifespan of the product is solely based on luck.</li><li><strong>Taxes:</strong> With the new GST (Goods &amp; Service Tax) introduced in India in 2017 coupled with the hefty and ever-increasing import duties levied on most of the products and peripherals, we end up paying upwards of 25% of the actual price in taxes. This includes both Hardware &amp; Software.</li><li><strong>No deals or discounts:</strong> Indian markets don’t offer the kind of deals the US or other countries might enjoy on a regular basis. And especially no Black Fridays here as well. This limits a lot of opportunities for Indian consumers to buy discounted peripherals. It’s not that we don’t have deals per se but when the so-called Amazon Lightning deals hover in the range of 10% discounts, it doesn’t make it the most lucrative of offers.</li></ol><h3>Environmental Issues</h3><ol><li><strong>Dust &amp; Heat:</strong> Geographically, most of India has summers or rather hot temperatures for close to 9 months in a year topping at a good 50 degrees Celsius. This makes cooling a big challenge, especially for laptops and computers. And the more we have to cool the devices artificially, the more we have to deal with DUST. Dust is one of the biggest reasons for the small lifespan of electronic products here. Laptops &amp; computers face the biggest challenge since they get clogged very frequently with dust and have to be cleaned regularly in order to keep them operational. Mice have it the worst when it comes to dust. Because when dust gets inside the mouse, it accumulates inside the small click mechanism of the buttons and then they start misfiring or getting stuck. Until the time I was using the regular Logitech Mouse I had to buy a new one every year since they wouldn’t last more than that. The latest mouse I own is a Logitech G603, which has a 3-year warranty and I have already got it exchanged once because of the dust issue.</li><li><strong>Difficult to create Home Offices:</strong> Room sizes in Indian Homes are generally very small and keeping a full desk with a complete external monitor setup in a regular bedroom is out of the question. And so is having a separate room for your home office. And that’s because Indian homes don’t have a concept of centralized cooling/heating. So every room in the house needs to be individually cooled with separate air conditioning units. And thanks to the high electricity prices, cooling multiple rooms in the house at the same time becomes financially unviable. The only option that we have is to work on our laptops and adjust between working on bed or small temporary tables.</li></ol><p>I understand that there might be business reasons for many of the points I have shared above but at the end the fact is that we are deprived of the tools which increase the quality and the quantity of the work we put out and unless these companies start selling their products and advertise them, how can they expect to grow in one of the world’s largest markets. I also understand that the government rules for entering the market and selling products in India are very difficult to work with. <br> For environmental reasons, there is obviously nothing that can be done and creating a setup that counters these factors are more a matter of sunk costs and high running costs.</p><p>I hope that companies around the world who work with India based Freelance Developers have some insight into issues we face that might not look apparent but are our reality with which we have to deal with. And if they really care about their productivity, they can help contribute to it by buying the required hardware and peripherals for them, as they would for an on-premise employee.</p><p>P.S. I am aware that there can be many counter-arguments to the points I have shared but do understand that they come from my personal experience of working remotely for the past 5 years from Delhi, in conditions that might be very personal to me.</p><p><em>This post was originally posted at </em><a href="https://dev.to/funkyidol/why-becoming-staying-productive-in-india-is-difficult-3b27"><em>https://dev.to/funkyidol/why-becoming-staying-productive-in-india-is-difficult-3b27</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d21655212e65" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Novices guide to Dependency Injection & Dagger2 — Part 1 — Introduction]]></title>
            <link>https://medium.com/@funkyidol/novices-guide-to-dependency-injection-dagger2-part-1-introduction-438533109997?source=rss-72e819d825d------2</link>
            <guid isPermaLink="false">https://medium.com/p/438533109997</guid>
            <category><![CDATA[beginners-guide]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[dagger-2]]></category>
            <category><![CDATA[dependency-injection]]></category>
            <dc:creator><![CDATA[Kshitij Aggarwal]]></dc:creator>
            <pubDate>Mon, 18 Feb 2019 08:41:25 GMT</pubDate>
            <atom:updated>2019-06-05T03:25:28.282Z</atom:updated>
            <content:encoded><![CDATA[<h3>Novices guide to Dependency Injection &amp; Dagger2 — Part 1 — Introduction</h3><p>This guide is an attempt to convert the difficult to understand concept of Dependency Injection into a language which is easier to understand and comprehend. This article draws all the wisdom from hundred’s of sources I read to wrap my head around this concept and from using it in production application.</p><h3>Defining Dependency Injection (DI)</h3><p>In very simple terms, <em>DI is trying to segregate the dependency creation and dependency calling</em>.</p><p>Let me explain.</p><p>Dependency is any class or object that is required and is not available in the current scope. It could be a platform level class like Toast, a 3rd party library like Retrofit or your own class defined somewhere else in the project. Currently, every time you require any of these &#39;dependencies&#39;, you try to create its object using the new operator. Alternatively, you may try to use some design pattern like Singleton or Factory to call upon a preexisting object of the required dependency.</p><pre>class User {<br>   private ProfessionalDetails pDetails = new ProfessionalDetails();<br>   private AcademeicDetails aDetails = new AcademicDetails();<br>}</pre><p><em>But now let me ask you to change the way you do things a little differently</em>. Instead of creating or accessing your dependencies directly, how about I tell you that all the dependencies you ever require are always provided to you via the method parameters and you never have to create a new object yourself. The above code will then look something like this:</p><pre>class User {<br>   private ProfessionalDetails pDetails;<br>   private AcademeicDetails aDetails;<br><br>   /* Example of Method (Dependency)Injection */<br>   public void userDetails(ProfessionalDetails pDetails, AcademicDetails aDetails){<br>      this.pDetails = pDetails;<br>      this.aDetails = aDetails;    <br>   }<br>}</pre><p>This is called <strong>Method (Dependency)Injection</strong>.</p><p>As we defined DI earlier as segregating the dependency creation and calling, here, you are not worried where or how the dependency is created, you are just concerned with using them. Similarly if any dependency you require at Class level is provided to you via the class constructor like shown below, it’s called <strong>Constructor Dependency Injection</strong>.</p><p>Now as a first step, I implore all of my readers to stay with this thinking of not creating new dependency objects and to get the dependencies via method or constructor injection. And to take things a little further, if I can ask you reduce the use of class variables in your methods and try to pass the requirements via method parameters. This is something which will be useful when we look at the larger picture of testable code but more on that later.</p><p><em>Originally published at </em><a href="https://dev.to/funkyidol/novices-guide-to-dependency-injection--dagger2---part-1-ga5"><em>https://dev.to</em></a><em> on February 18, 2019.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=438533109997" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>