<?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 Rohit Gupta on Medium]]></title>
        <description><![CDATA[Stories by Rohit Gupta on Medium]]></description>
        <link>https://medium.com/@thatrohit?source=rss-c6ed44ee8393------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*qsP5rAIr3pOQ4l7ad_FWMg.jpeg</url>
            <title>Stories by Rohit Gupta on Medium</title>
            <link>https://medium.com/@thatrohit?source=rss-c6ed44ee8393------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 13:21:01 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@thatrohit/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[Windows Powertoys Command Palette Extensions]]></title>
            <link>https://thatrohit.medium.com/windows-powertoys-command-palette-extensions-3b4dcd6e03ca?source=rss-c6ed44ee8393------2</link>
            <guid isPermaLink="false">https://medium.com/p/3b4dcd6e03ca</guid>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[windows]]></category>
            <category><![CDATA[powertoys]]></category>
            <category><![CDATA[commandpalette]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Rohit Gupta]]></dc:creator>
            <pubDate>Mon, 07 Apr 2025 18:30:28 GMT</pubDate>
            <atom:updated>2025-04-07T18:30:28.196Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q0mM-OWnYQ0B8e4XPhJ8vw.png" /><figcaption>Powertoys</figcaption></figure><p>If you’re a windows power-user you must have heard of <a href="https://learn.microsoft.com/en-us/windows/powertoys/">Powertoys</a>. With the latest update, powertoys introduced a new plugin called Command Palette.</p><blockquote>PowerToys Command Palette allows you to easily access all of your most frequently used commands, apps, and development tools — all from a single solution that is fast, customizable to your unique preferences, and extensible to include your favorite apps.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mZvWCbcAltBfYAWuzM8jaw.jpeg" /></figure><p>Command Palette (<em>cmdplt</em>) is the successor of Powertoys Run utility. The best thing about cmdplt is the ability to write your own custom extensions. These extensions aren’t simple scripts but full blown projects which you can leverage to perform complex tasks.</p><p>The easiest way to write your extensions is from the cmdplt itself, just open the cmdplt (Win + Alt + Space) and type in “create a new extension” and then enter the project name and location, it’ll create the VS project for you.</p><figure><img alt="Creating a new extension" src="https://cdn-images-1.medium.com/max/1007/1*dB-oIZoOVBpji5ON-xDRuA.png" /></figure><p>Next, if you don’t already have Visual Studio installed, you can download the <a href="https://visualstudio.microsoft.com/vs/community/">Visual Studio Community Edition</a> which is free. Once downloaded, open the project you just created from the cmdplt. It’ll be nice if you know some basic C# else you can use the in-built copliot extension to write most of the code for you 😉</p><p>For this example, I’ll showcase the extension I created to display the current time in from four different cities. I’ve got friends living all across the globe and it gets hard to keep track of time. This extension helps me quickly get the current time no matter which window I’m on. You can view my extension project <a href="https://github.com/thatrohit/WorldTimeExtension">repository here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*3Gph5dB_IAhVMwJvtAGZ-g.gif" /><figcaption>World Time Extension</figcaption></figure><p>Once you open the project in Visual Studio, navigate to your &lt;ExtensionName&gt;Page.cs file. In this case, it’s WorldTimeExtensionPage.cs. Your page extends a ListPage class which is fine for our use case. You can have different parent classes for different use cases, you can view them all in the <a href="https://learn.microsoft.com/en-us/windows/powertoys/command-palette/creating-an-extension">detailed docs here</a>.</p><p>The first step would be to define some basics like the Icon and Name which you can do in the constructor of your class.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/980/1*wJYTMXjLwOS5l_W7fhI2Ag.png" /><figcaption>Extension Page Constructor</figcaption></figure><p>You should also define the extension’s author and other metadata in the Package.appxmanifest file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GnuxudivAcepxIeayAjzGA.png" /><figcaption>Manifest file</figcaption></figure><p>Now you have to write a basic logic to get the current date time and use TimeZoneInfo to convert them to your desired time. Once you have the result, override the GetItems() function and return a list of IListItem. In my example, I’ve used a detailed list view with a hero image to show a time and date in more detail.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/901/1*HkeP60VxCE3PdsskoQivXA.png" /><figcaption>GetItems()</figcaption></figure><p>Notice I’ve used NoOpCommand() as the click action for the list items as I do not need to perform any action on their click. The information presented when I open the extension is enough for this use case. You can write your own commands to perform more complex tasks, such as executing a script, making an API call and presenting network response, executing any program, etc. You can view more in the <a href="https://learn.microsoft.com/en-us/windows/powertoys/command-palette/adding-commands">command docs</a>.</p><p>Finally, when you have the list ready, you need to build and deploy the project. Keep in mind, just building won’t make your new extension show up in the cmdplt, you have to deploy it too. Once you’ve done that it should show up when you search it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*MZ2FrOnp6aeEN5UfJc4dgQ.gif" /><figcaption>Searching extension in cmdplt</figcaption></figure><p>Pretty cool right? You can also set a custom shortcut to bring up your extension without searching for it. In my case I’ve set it to Win + Alt + Space. Have fun! 🪟</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3b4dcd6e03ca" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using SimpleTemplateEngine to generate files during compilation]]></title>
            <link>https://thatrohit.medium.com/using-simpletemplateengine-to-generate-files-during-compilation-965d15d59478?source=rss-c6ed44ee8393------2</link>
            <guid isPermaLink="false">https://medium.com/p/965d15d59478</guid>
            <category><![CDATA[build]]></category>
            <category><![CDATA[simpletemplateengine]]></category>
            <category><![CDATA[gradle]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[template]]></category>
            <dc:creator><![CDATA[Rohit Gupta]]></dc:creator>
            <pubDate>Sat, 24 Feb 2024 20:40:17 GMT</pubDate>
            <atom:updated>2024-02-24T20:40:17.786Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2n0-3yr683i_-Roh5jhQkQ.png" /><figcaption>Gradle logo</figcaption></figure><p>I want to share two very interesting use cases I’ve come across throughout my journey as an Android engineer.</p><p>The first was where I automated the process of generating several project’s readme files. We had to maintain around twenty different libraries with releases going out each month. With that came the task of bumping the version in the project’s readme and update any new dependencies if added. It was tedious and it desperately needed automation.</p><p>The second was where we had to generate a class out of a json file. The json file had some key design variables which is not something you’d want to keep in your <em>BuildConfig</em> class as it would be semantically incorrect. The json had to be parsed into a class and had to be packaged during compilation.</p><p>Both these use cases were solved by using Groovy’s <strong>SimpleTemplateEngine</strong>.</p><p>Using <strong>SimpleTemplateEngine</strong> you can create files from a defined template through gradle tasks. I’ve created a sample project which lets you create a new config class similar to Android’s <em>BuildConfig</em> using <strong>SimpleTemplateEngine</strong> and a little gradle magic. You can find it here</p><p><a href="https://github.com/thatrohit/TemplateEngineExample">GitHub - thatrohit/TemplateEngineExample: A project demonstrating class creation during compilation using SimpleTemplateEngine</a></p><p>Below you can find the crux of the implementation.</p><ol><li>Create a template for your class which you want to generate. You can pass properties such as strings, arrays and maps to this template. You can learn more about the syntax here</li></ol><p><a href="https://docs.groovy-lang.org/docs/next/html/documentation/template-engines.html#_simpletemplateengine">Template engines</a></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/420d51d512dfce324d2752d985022c81/href">https://medium.com/media/420d51d512dfce324d2752d985022c81/href</a></iframe><p>2. Create a new gradle task which will create the java file out of this template. The properties which the template will use are passed through <em>expand</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/793708ac659c1ac3bd0a45bc366559ae/href">https://medium.com/media/793708ac659c1ac3bd0a45bc366559ae/href</a></iframe><p>Here out_dir is the directory where you’ll create your file. I’m setting the output directory to <em>build/generated/source</em>.</p><p>3. You also have to tell the compiler to look for your autogenerated class to compile and package into your apk. You can do that by the following code in your build.gradle</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8e55a34ca8470cb560f7ff3b3b7a4cae/href">https://medium.com/media/8e55a34ca8470cb560f7ff3b3b7a4cae/href</a></iframe><p>Once you’ve got these steps covered, all that remains is to execute your task. You can mark this task dependent on any other task before the application is packaged. For convenience, I’ve marked this task dependent on preBuild as there isn’t any dependencies my task need and I’d like it to get executed during the start of the build process.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0fb8e8dcc9723e42a539097f5a3057ca/href">https://medium.com/media/0fb8e8dcc9723e42a539097f5a3057ca/href</a></iframe><p>Voila! You just leveraged SimpleTemplateEngine to autogenerate a java class! All that remains is to build your project. Once done, this is what the autogenerated class looks like</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f32d6759d0b54a72fce63dd12ccc855d/href">https://medium.com/media/f32d6759d0b54a72fce63dd12ccc855d/href</a></iframe><p>You can use the same logic to create a readme file or any other use cases that you might come across. Have fun! 👋</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=965d15d59478" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Power up your Android Development with GitHub Copilot]]></title>
            <link>https://thatrohit.medium.com/power-up-your-android-development-with-github-copilot-957829eadf0f?source=rss-c6ed44ee8393------2</link>
            <guid isPermaLink="false">https://medium.com/p/957829eadf0f</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[github-copilot]]></category>
            <category><![CDATA[android-studio]]></category>
            <dc:creator><![CDATA[Rohit Gupta]]></dc:creator>
            <pubDate>Sun, 05 Mar 2023 12:52:09 GMT</pubDate>
            <atom:updated>2023-03-05T12:52:09.941Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qNJyPRRVuuliVG2Neh2HaQ.png" /><figcaption>GitHub Copilot</figcaption></figure><blockquote>“The advance of technology is based on making it fit in so that you don’t really even notice it, so it’s part of everyday life.” — Bill Gates</blockquote><p>This is exactly what GitHub Copilot aims to do for developers.</p><p>By now, you are probably already working with an AI assistant. Be it composing emails using ChatGPT, creating your own art using Stable Diffusion or the countless other tools available for image processing. With Copilot, you can have an assistant integrated right in Android Studio to supercharge your programming.</p><p>GitHub’s Copilot is not a new feature. They have release it out of preview on June, 2022. It is powered by OpenAI Codex, a generative pretrained language model created by OpenAI. Codex in turn is a descendent of GPT-3 model, which is used by ChatGPT.</p><p>To integrate Copilot in your Android Studio, you need a GitHub account and purchase a subscription for Copilot, 10$ monthly. You can search for the Copilot plugin for Android Studio and install it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/983/1*KQLIp-Z34dhHp3X85xPiJg.png" /><figcaption>Searcing for Copilot in the Android Studio plugin marketplace</figcaption></figure><p>Once installed, you need to log in to your GitHub account to authorize the plugin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/910/1*GBVsx8jJnAfgba1anSASOQ.png" /><figcaption>Log in to authorize Copilot</figcaption></figure><p>Now all that is done, the fun part begins. To invoke Copilot, all you have to do is type a comment and Copilot will write the code for you. It can infer function bodies from the function name and from a summary comment, as well as take cues from other code in the file you’re editing and from variable names. Let me show you some examples.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*4efMJaP9P9jQUqq2jAXQqQ.gif" /><figcaption>Generating XML layouts</figcaption></figure><p>In the above gif you can see how I only described what I wanted in plain English and Copilot generated the block of code for me. Imagine a scenario where you want to generate a quick prototype and want to save time on writing the verbose XML layouts, Copilot can help with that.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*GhlHAERVlEKmKvdHv2oJzA.gif" /><figcaption>Generating test cases</figcaption></figure><p>Copilot can help with generating test cases as well. In the above gif I have my class opened on the right pane and the test class on the left pane. All I had to do was tell Copilot that I want to generate a test case for one of the functions and it does that effortlessly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*TLSLnOjLJOk32vbrT2eCAA.gif" /><figcaption>Context awareness</figcaption></figure><p>Copilot is context aware too. It knows I have a model class called Plans in my project. In the above gif you can see I asked it to generate me a list of random Plant instances and it does that even though there’s no reference of Plant in the opened file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*psteAfHepPteUpHA6N9jkA.gif" /><figcaption>Follow up command in natural English</figcaption></figure><p>You can follow up on your function calls with more commands as you can see in the gif above.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*uubMdpqg60x6bweRVVcZMg.gif" /><figcaption>Android specific code</figcaption></figure><p>It can do Android specific stuff too, like creating intents and passing extras as you can see in the gif above, add permissions in manifest, etc.</p><p>It’s quite a powerful tool and can help in increasing your productivity, however there are some caveats.</p><ol><li>It might suggest you old or deprecated uses of libraries which may result in bugs. If you try adding a dependency in your build.gradle’s dependency block using Copilot, it can give you a older version of the library.</li><li>Copilot is only accessible as a GitHub platform add-on, which may not be suitable for your work if your company blocks access to GitHub (like mine)</li><li>It can be a bad choice for new developers to pick up Copilot, while it can help them produce output faster, it can also lead to a slow learning process.</li><li>There’s always a risk of accuracy. You will always need to proof read the generated code. There’s the problem of plagiarism as well, such is with most AI generated content.</li><li>It might take our jobs in the near future😋</li></ol><p>As I mentioned in the introduction, GitHub Copilot is based on making technology fit in so that we don’t really notice it. However, we should not forget that technology is not a substitute for human creativity and intelligence. It is a powerful tool, I suggest that developers use GitHub Copilot with caution and responsibility, and always check the quality and originality of their code before publishing it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=957829eadf0f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Applying Rules for Network Inspector in Android Studio Flamingo]]></title>
            <link>https://thatrohit.medium.com/applying-rules-for-network-inspector-in-android-studio-flamingo-144fc8a5a929?source=rss-c6ed44ee8393------2</link>
            <guid isPermaLink="false">https://medium.com/p/144fc8a5a929</guid>
            <category><![CDATA[proxy]]></category>
            <category><![CDATA[network-inspector]]></category>
            <category><![CDATA[network-debugging]]></category>
            <category><![CDATA[charle]]></category>
            <category><![CDATA[android-studio]]></category>
            <dc:creator><![CDATA[Rohit Gupta]]></dc:creator>
            <pubDate>Sat, 05 Nov 2022 15:59:46 GMT</pubDate>
            <atom:updated>2022-11-05T15:59:46.708Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9-tmExKFTXiQcdDEPRK3Tw.jpeg" /><figcaption>twitter <a href="https://twitter.com/joreilly">@joreilly</a></figcaption></figure><p>The latest canary for Android Studio brings in a really handy new feature to inspect and debug network connections on your android application.</p><blockquote>The Network Inspector displays realtime network activity on a timeline, showing data sent and received. This lets you examine how and when your app transfers data, and optimize the underlying code appropriately.</blockquote><p>Now, this might not sound exciting if you’re already using some sort of network logging interceptor for your okhttp client, however, the feature which makes this stand out is setting custom ‘rules’ for incoming connections.</p><p>With rules, you can change network response / headers at realtime which can help you to validate your app against different scenarios. For example, I can set a rule to return me a different body for a REST API endpoint</p><pre>{</pre><pre>&quot;titleResourceId&quot;: &quot;my_id_1&quot;,</pre><pre>&quot;descriptionResourceId&quot;: &quot;my_id_1_desc&quot;,</pre><pre>&quot;value&quot;: &quot;true&quot;,</pre><pre>&quot;extra&quot;: null</pre><pre>}</pre><p>to</p><pre>{</pre><pre>&quot;titleResourceId&quot;: &quot;my_id_1&quot;,</pre><pre>&quot;descriptionResourceId&quot;: &quot;my_id_1_desc&quot;,</pre><pre>&quot;value&quot;: &quot;false&quot;,</pre><pre>&quot;extra&quot;: {}</pre><pre>}</pre><p>If you’ve used any network proxy before to alter API responses at run time (ex. Charles), you can think of this as its lite edition 😁</p><p>To set rules, all you have to do is open up the App Inspection tool. You can find it at the bottom bar of Android Studio Flamingo, else you can just press double shift and type in ‘App Inspection’. For the sake of this demo, I’m just going to clone the first sample app I see on github, the dice roll goes to <a href="https://github.com/ragvax/Pictrr">Pictrr</a></p><figure><img alt="App Inspection" src="https://cdn-images-1.medium.com/max/1024/1*JsEZYPNdLTEK6EDYl6bpQQ.png" /></figure><p>Inside App Inspection, navigate to the Network Inspection tab. Once there, you’ll have to attach your inspector to the app you want to inspect..</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F54wN7Zp-rusO4FHie6uLQ.png" /></figure><p>Now, see the running app above? I’m going to change the response of one of the tabs. Let’s pick ‘3D Renders’ to return me an empty JSON object. This way I can validate how this app handles an empty body. To do this, I’ll identify the network request that is made when I tap on 3D Renders. Let’s do that now.</p><figure><img alt="API Call identified for 3D Renders" src="https://cdn-images-1.medium.com/max/1024/1*UbKI4Hw2jVYlzP1k1eRYlA.png" /></figure><p>In the above picture, we can see the URL that is invoked to get the response for 3D Renders. Let’s copy the URL, we’ll use it to set our rule.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wFeT5U_9CQsx-W0EowoFzg.png" /></figure><p>You can check the above photo to see how I broke down the URL to set the rule. We do not need to worry about the query. I’ve set the rule to return me a 500 instead of a 200 status code. In the body section, I’ve also asked it to return me an empty json object. Now let’s see what happens when we try to invoke the API call for 3D Renders again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*n6_jLEum0sCMVY7k3gkgog.gif" /></figure><p>As you can see in the above video, our app does not handle empty bodies well.</p><p>There are some caveats that you need to keep in mind with Network Inspector however,</p><ol><li>The feature is still in development, so expect a few things to change.</li><li>Rules are not persistent, once you kill your app, the rule is lost.</li><li>Rules are not very friendly with GraphQL (as of now), I could not find a way to make it work with GraphQL requests as all of them have the same endpoint. If you have something then please let me know in the comments :)</li><li>Rules only work with OkHttp and HttpURLConnection.</li></ol><p>Thanks for taking the time to read my article. I hope if helps you!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=144fc8a5a929" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dev blog: Creating a companion application to launch a target application]]></title>
            <link>https://thatrohit.medium.com/dev-blog-creating-a-companion-application-to-launch-a-target-application-ff9f112f6e51?source=rss-c6ed44ee8393------2</link>
            <guid isPermaLink="false">https://medium.com/p/ff9f112f6e51</guid>
            <category><![CDATA[devblog]]></category>
            <category><![CDATA[enterprise]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[intent]]></category>
            <category><![CDATA[activity]]></category>
            <dc:creator><![CDATA[Rohit Gupta]]></dc:creator>
            <pubDate>Sun, 16 Oct 2022 15:21:55 GMT</pubDate>
            <atom:updated>2022-10-16T15:21:55.684Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/666/1*a1D0FEM_zUTZD-e4WVVFIQ.png" /></figure><p>If you are working on an enterprise level application, chances are you would have several configuration constants. Ideally, you’d keep these constants in your gradle’s flavor variables or a global static class.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/740/1*VIrTviIBZXGMRj3EQE4yfg.png" /><figcaption>It might look something like this</figcaption></figure><p>The most common issue with this approach is that if you want to validate your app against a different set of configuration constants, you’ll have to create another flavored build. For example, in the above image, if you want to share a build with your QA for validating both the endpoints, you’d have to share two different builds with them. One with demo flavor, the other with full flavor.</p><p>Wouldn’t it be easier if you can share just one build with your QA and they could set the constants themselves before launching? This is where the configuration initializer app comes in.</p><p>Now that I’ve managed to explain the problem 🤞, here’s how we can tackle it. We will create an application which launches our target application’s intent, passing the constants as a bundle. We can achieve this by explicitly providing our target application’s package and its launcher activity’s name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/755/1*mZITnTfwsuOAGTrb70U2qQ.png" /><figcaption>If you wanted to open SplashActivity of a target application</figcaption></figure><p>In our target application, we’ll keep a singleton class which will hold our configuration values. Once our target activity is opened, we’ll capture the incoming bundle and populate our singleton class. This way our constants will be available throughout the app, similar to how gradle generates a BuildConfig class.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/719/1*-AtBe78OHDt66Rw88kSG4Q.png" /><figcaption>Your constants singleton could look similar</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/763/1*Jk0vlGxmGXpmGTKzYcTK2w.png" /><figcaption>Inside your SplashActivity</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/762/1*J7rXgm3_YNlF2bhAMX_RkA.png" /><figcaption>Populating your constants</figcaption></figure><p>Now, you will have to create a different configuration launcher application for every application you create as they might have different configuration constants. To streamline this process, I’ve created a customizable launcher application. This launcher application is going to read a local json file and render UI based on the elements provided in the json file. The app is fully localized, uses clean architecture with DI using Hilt, is build on compose, uses material 3 components. I’ll stop here or you’ll say I’m just throwing jargons 😁</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z9L0ZsfRsYpKb7IZ1Kvp_w.png" /><figcaption>For the json in the left, the rendered UI is on the right</figcaption></figure><p>You can find the configuration launcher app <a href="https://github.com/thatrohit/ConfigInitializer">here</a>. Please feel free to fork or submit MRs if you feel there’s any room for improvement. I wrote this over a weekend because I was brimming with motivation 😅</p><p>Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ff9f112f6e51" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Gradle Basics for Android Developers]]></title>
            <link>https://medium.com/android-dev-corner/gradle-basics-for-android-developers-9d7a3bf062bb?source=rss-c6ed44ee8393------2</link>
            <guid isPermaLink="false">https://medium.com/p/9d7a3bf062bb</guid>
            <category><![CDATA[gradle]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[groovy]]></category>
            <category><![CDATA[android-development]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[Rohit Gupta]]></dc:creator>
            <pubDate>Sun, 04 Jul 2021 07:55:44 GMT</pubDate>
            <atom:updated>2021-07-05T08:20:22.018Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*qrhDjcK_E_q9RNyGnoMUpA.png" /><figcaption>Image from <a href="https://dribbble.com/shots/3357695-Gradle-Magic">Gradle Magic by Anna Langiewicz for Tooploox on Dribbble</a></figcaption></figure><h4>What is Gradle</h4><p>Gradle is a build automation tool which runs on Groovy DSL (domain specific language) and most recently, Kotlin DSL. Android Studio uses Gradle to build, generate and deploy APKs. An advantage of using Gradle is that it can run independently of Android Studio. You do not need Android Studio at all to generate APKs. It provides flexibility to create builds with custom configuration without modifying source code.</p><h4>Gradle From Android’s Context</h4><p>Whenever you create an Android project. You’ll see there are three gradle files added by default.</p><ul><li>settings.gradle</li><li>build.gradle</li><li>app/build.gradle</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-FkEjRCvcrkYaXUk5AYFow.png" /><figcaption>The three default gradle files</figcaption></figure><p>Whenever a project is built, the gradle files are executed in the following sequence:</p><ol><li><strong>settings.gradle</strong> — All the required modules for the project is defined here. Any sort of configuration which might be required prior to initialization can be done here.</li><li><strong>build.gradle </strong>— This is the root project’s build.gradle file. The buildscript is defined here along with the repositories. Any configuration options added here will be common to all modules.</li><li><strong>app/build.gradle</strong> — This is exclusive to the app where you will find implementations for local/remote repositories, the android configurations such as minSdk, compileSdk etc</li></ol><h4>Android Configurations</h4><p>Gradle allows the following configurations for Android. You can find their usage in the demo project below.</p><ul><li><strong>Build Types</strong> — We can define build types under the buildType block, eg. debug, release, staging etc. We can configurations specific to build types here such as signingConfigs, proguard file etc.</li><li><strong>Product Flavors</strong> — They’re defined under the productFlavor block, eg dev, prod etc. We can define configuration specific to flavor here such as flavor specific manifest placeholders, build config fields etc</li><li><strong>Build Variants</strong> — These are created implicitly by gradle and is a combination of build types and flavor. Ex: the above configurations will yeild devDebug, devProd, devStaging, prodDebug, prodRelease and prodStaging.</li><li><strong>Manifest Injection</strong> — We can assign values to the AndroidManifest.xml file from gradle using manifestPlaceholder array.</li><li><strong>Build Config</strong> — We can also declare certain values in a module’s gradle file which will be present as a static reference to the module after the build is done. A BuildConfig java class would be created which will hold all the build config files.</li><li><strong>Dependencies</strong> — You must be familiar with this. We can declare dependencies to local / remote repositories here using api or implementation keyword. They can be specific to build variants as well, ex devImplementation or prodImplementation.</li><li><strong>Signing</strong> — Gradle can help automatically sign the apk during build process based on the defined configuration.</li><li><strong>Code Shrinking </strong>— Gradle uses R8 to shrink and obfuscate code based on the rules specified in the proguard file.</li><li><strong>Multiple APK Support</strong> — We can leverage gradle to create multiple APK for specific screen density etc.</li></ul><p>As an android developer, these are things you would normally do in any project. However there are several under the hood feature which you might not know about. I’m hoping to share some of that knowledge with this article.</p><p>Normally the configurations defined above are enough for most android apps. However, for apps with multi module architecture, we can leverage some other gradle feature to simplify and ease work flow.</p><h4>Import Other Gradle Scripts</h4><p>When you’re working on a multi module project, you’re bound to run into duplicate scripts. Let’s assume you have added five modules to your project and each have their own build.gradle defined with their own minSdk, compileSdk etc. Let’s say you have to upgrade the minSdk of your project. Now you’ll have to change the the variable in all the modules manually. Sure, it’s a find/replace job but it’s not elegant. In such a situation, it’s best to extract out the common code and keep them in a separate gradle file and then import that file into each of our build.gradle. You can see this has been done in the demo app’s first and second module. The common code has been extracted out to root.gradle and then applied to their build.gradle using the apply from keyword.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/934/1*zu2kiQY2dDZMOtJDJKbnLA.png" /><figcaption>That’s the entirety of the build.gradle for module `first`</figcaption></figure><h4>ExtraPropertiesExtension</h4><p>You might know this better as the ext block. Each gradle project has its own ext block and we can declare variables here which can be referenced by any other gradle script used in that project. Think of this as a very rudimentary form of SharedPreferences for gradle. In the demo project, you can see that the ext block has been declared in a separate version.gradle file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/704/1*UF61COOTOryJ1IjfAjlLrQ.png" /></figure><p>and then imported to the root.gradle file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1iFWPX6ALpMrhHV8kNVXgA.png" /><figcaption>Notice how the values for compileSdk etc are fetched from the ext value</figcaption></figure><h4>Tasks</h4><p>The most defining feature of Gradle is Tasks. A task can be thought of as a single atomic piece of work where each task belongs to a project. These can’t be thought of as functions or classes which can be invoked whenever required, rather they are invoked implicitly by the task name argument passed to the ./gradlew command or if a task defined as a dependency for another task. Tasks are declared as dependent using either dependsOn or finalizedBy keyword. You can see this example in the demo app’s move-apk.gradle file where the custom task is made dependent on the in-build assemble task.</p><h4>Lifecycle of a Build Process</h4><p>Whenever a gradle command is run, the following three steps are executed in order</p><ol><li><strong>Initialization</strong> — Here the instance of the gradle project is created.</li><li><strong>Configuration</strong> — Here the project’s objects are configured. All the tasks declared in all the projects are executed. Executing all tasks can turn out to be a bit problematic if we have custom tasks, to overcome this we can declare them lazily, example <br>tasks.register(‘myTask’) {…}<br>instead of how you’d declare them normally<br>task myTask {…}</li><li><strong>Execution</strong> — Execution determines subset of task, which was created and configured during the configuration phase, to be executed. The subset is identified by the task name argument passed to ./gradlew. Once identified, it then executes them.</li></ol><h4>Writing Custom Tasks</h4><p>For specific use cases, we can write custom tasks. For example, if we have a requirement to copy the generated APK to a specific folder after a build is completed, we can write a custom gradle task for that. First we’ll define a task to copy an APK file from one path to another, then we will make it depend on the assemble task. An example for this can be seen in the move-apk.gradle file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1xgWMoKT8w2QyOUF5mYxeQ.png" /><figcaption>move-apk.gradle</figcaption></figure><p>Or another use case where you’d want to zip all the AARs and APK for easy distribution. This can be seen in ouput-archive.gradle file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f9ckSfZpsSK5q6p_6stm5A.png" /><figcaption>output-archive.gradle</figcaption></figure><h4>Invoking Bash Commands From Task</h4><p>This is a really cool trick you can do with gradle tasks which can make it really power. We can leverage the exec block in a task to execute commands which you would normally run in your terminal or powershell. You can find an example for this in the email-commit.gradle file. Here the task gets the url for the last commit and then sends an email to a specified email id.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WDEKAjiyjJrh9C3eCarJMw.png" /><figcaption>email-commit.gradle</figcaption></figure><h4>Passing Arguments</h4><p>You can pass arguments to gradle command which will be accessible to all projects which would get executed. You can pass arguments using this command -P&lt;argumentName&gt; and then get them in your task using project.getProperty(‘&lt;argumentName’). You can see the example in line number 9 in email-commit.gradle.</p><h4>Writing Initialization Scripts</h4><p>We can specify initialization scripts to our ./gradlew commands. One example can be seen in the demo project’s my-logger.gradle file. Here I’m overriding the log behavior to print the name of each task getting executed along with the time taken for each task. Something like this can be particularly helpful if you are experiencing slow builds and not sure which task is causing it.</p><p>You can find the repository here</p><p><a href="https://github.com/thatrohit/gradleplayground">thatrohit/gradleplayground</a></p><p>Here are the commands you can use to execute the scripts</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BmENQ24l5ygLOA8pNArSPg.png" /></figure><p>There is so much more you can do with custom tasks and it all depends on your use case. To learn more you can look up the official documentation for gradle here: <a href="https://docs.gradle.org/current/userguide/userguide.html">Gradle User Manual</a>. Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9d7a3bf062bb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/android-dev-corner/gradle-basics-for-android-developers-9d7a3bf062bb">Gradle Basics for Android Developers</a> was originally published in <a href="https://medium.com/android-dev-corner">Android Developers Corner</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Git Hooks for Beginners]]></title>
            <link>https://medium.com/android-dev-corner/git-hooks-for-beginners-4eb17e25bcc2?source=rss-c6ed44ee8393------2</link>
            <guid isPermaLink="false">https://medium.com/p/4eb17e25bcc2</guid>
            <category><![CDATA[git-hooks]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[code-quality]]></category>
            <category><![CDATA[development-tools]]></category>
            <dc:creator><![CDATA[Rohit Gupta]]></dc:creator>
            <pubDate>Sat, 13 Mar 2021 17:16:25 GMT</pubDate>
            <atom:updated>2021-03-13T17:59:51.848Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SyPt7ZJcU5eLyibiEeMvYQ.png" /></figure><h4>What are git-hooks?</h4><p>Imagine a situation where you have to commit some code which will be strictly reviewed by your senior or you’re pushing your branch to an open source repository. You’re confident about your logic but you don’t want to mess up with minor issues such as unused variables or linting issues. You manage to push your branch just in the nick of time but forget to lint your code. Now what? You have to push another commit with those lint fixes. Do you reckon it would have been better if that second commit with lint fixes was avoided altogether? Well, that’s where git-hooks comes in.</p><p>According to <a href="https://www.atlassian.com/">Atlassian</a>,</p><blockquote>Git hooks are scripts that run automatically every time a particular event occurs in a Git repository</blockquote><p>This definition is clear and concise in itself. You can imagine git-hooks as script files which attach themselves to git commands and get triggered automatically where you run specific git command. Git hooks can be set both for server and client. I’m focusing on the client hooks in this article.</p><h4>Why use git-hooks?</h4><p>Writing formatted and clean code is the telltale sign of an experienced developer. It’s not unusual to make mistakes, but when you do, having an automated system to alert you is handy. Git-hooks can be particularly useful to enforce naming conventions for commit messages, performing lint checks and fixes, displaying custom messages on events such as checkout etc.</p><h4>Types of git-hooks</h4><p>Every git repository has a folder called hooks located inside the .git/ folder. If you navigate to it, you can see a bunch of files with extension .sample. These are your hooks. Git creates them for each repository. These hooks are inactive by default, if you remove the extension they are activated. Let me give a brief explanation of the most frequently used hooks</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5725039f13443297c5482a56ff2ef06d/href">https://medium.com/media/5725039f13443297c5482a56ff2ef06d/href</a></iframe><h4>How to use git-hooks</h4><p>We can use any scripting language for writing git-hooks like Windows Batch, Python, Shell,Ruby etc. I’ll be using plain and simple Shellhere. Let me give you a low-down about scripts first before diving into git-hooks. If your scripts returns an exit value 0 then your git command will execute, anything other than 0 and it fails. This is how your git-hook will know if it needs to pass or fail your git command.</p><p>Let’s start by creating a simple hook which gets triggered when you’re trying to commit your code.</p><p>1.Navigate to your repository’s .git/hooks/ folder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/870/1*BN7GdDVBhaYCjmIKzwC4pg.png" /><figcaption>The hooks folder</figcaption></figure><p>2. Locate the commit-msg.sample file, rename it to commit-msg. We have just activated our commit-msg hook.</p><p>3. Sometimes you might have to make these executable, it works on Windows but you might need to do it for MAC or Linux. You can do that by the chmod command in your terminal or git bash (won’t work on Window’s cmd)<br>chmod +x .git/hooks/commit-msg</p><p>4. Open commit-msg in your favorite text editor.</p><p>5. Replace everything with the following code and save your file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f0f235ade1273f1ffd90c75416f1b7d3/href">https://medium.com/media/f0f235ade1273f1ffd90c75416f1b7d3/href</a></iframe><p>6. We’re all set to test our hook. Make any change in your repo and try to commit. You’ll see the commit fails, it should look similar to what I have here</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/868/1*58cmKO_dYYIxciBS78rHgg.png" /><figcaption>The commit fails and we cannot see it in git log</figcaption></figure><p>7. Let’s replace our hook with the following code</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c6ee3a2a0ca99fcbfa293391f8f46567/href">https://medium.com/media/c6ee3a2a0ca99fcbfa293391f8f46567/href</a></iframe><p>8. You can see that your commit passes now, it should look similar to below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/868/1*12D2kJhLkI9tffHWYWc58g.png" /><figcaption>The commit is successful and we can see its entry in our git log</figcaption></figure><p>You now know how to make git hooks work. Let’s try creating a meaningful hook to verify and lint our code when we try to commit. We will use <a href="https://github.com/pinterest/ktlint">Pinterest’s ktlint</a> library to do so. Follow the steps below to integrate ktlint in your Android project.</p><p>1.In the root directory of your project, create a gradle file called ktlint.gradle. You can set the name to anything you desire.</p><p>2. Copy the below content to ktlint.gradle. Here we have added dependency for ktlint and added two gradle tasks. verifyFormatting only checks and alerts you where the formatting issues are and applyFormatting rectifies them.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/75f864b05ef3f761a51091a05b698bc8/href">https://medium.com/media/75f864b05ef3f761a51091a05b698bc8/href</a></iframe><p>3. Apply ktlint.gradle file to your app/build.gradle file as shown in line number 5 below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WVNofx7Jc_g0BDfc6GvbSw.png" /></figure><p>4. Edit your commit-msg hook with the follow. We’ll be using ktlint’s suppport to verify our formatting</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/daa4000bd0495950dec74268593af067/href">https://medium.com/media/daa4000bd0495950dec74268593af067/href</a></iframe><p>5. We’re all set with our hook. Test it out and you should see the following</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_h30AMRpVnHBWLdcpzYfDg.png" /><figcaption>this is bad</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EUqS03EgtRpjf_LB1tWKDg.png" /><figcaption>as you can see, I’m a rock-star developer</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-axSiqzl5ETUEGYUzDXmfQ.png" /><figcaption>phew, I thought this list wouldn’t end</figcaption></figure><p>See how handy that was! Git-hooks can be leveraged as a powerful tool to enforce quality code across your team. There are many other sample scripts you can find online, get creative!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4eb17e25bcc2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/android-dev-corner/git-hooks-for-beginners-4eb17e25bcc2">Git Hooks for Beginners</a> was originally published in <a href="https://medium.com/android-dev-corner">Android Developers Corner</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[10 Git Tricks Every Developer Should Know]]></title>
            <link>https://medium.com/android-dev-corner/10-git-tricks-every-developer-should-know-76d967360de8?source=rss-c6ed44ee8393------2</link>
            <guid isPermaLink="false">https://medium.com/p/76d967360de8</guid>
            <category><![CDATA[android-development-tools]]></category>
            <category><![CDATA[git-tip-and-tricks]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[development-tools]]></category>
            <dc:creator><![CDATA[Rohit Gupta]]></dc:creator>
            <pubDate>Mon, 08 Mar 2021 08:12:56 GMT</pubDate>
            <atom:updated>2021-03-08T08:43:44.275Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="10 Git Tricks Every Developer Should Know" src="https://cdn-images-1.medium.com/max/1024/1*vpNVy6J8bYyxrL6AmSAPIA.png" /></figure><p>Here’s ten tricks you can use in git to supercharge collaborative coding.</p><h4>Access The In-Built Cheat-Sheet</h4><p>Did you know git had its own in built quick reference guide that comes along with the installation package? Here’s how you can access it</p><pre>git help everyday</pre><p>This will open an html page in your default browser, you can use this as a quick reference guide to brush up on your git skills.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ix7cQGeWMbwyQPUD-fObHQ.jpeg" /><figcaption>access the in-built cheat-sheet</figcaption></figure><h4>Commit Message With Summary And Description</h4><p>Here’s how you can (should) format your commit messages for extensive readability. Keep in mind to follow the 50/72 rule to follow standards, i.e. summary should be no more than 50 characters and 72 for description.</p><pre>git commit -m &quot;&lt;summary&gt;&quot; -m &quot;&lt;description&gt;&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/971/1*iDBQFw8IdvTwPBkIEjPXVQ.jpeg" /><figcaption>You can see how they appear in the commit logs</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sUBEqCgI9gXe_fWe2oyWyA.jpeg" /><figcaption>This is how they look in github commits</figcaption></figure><h4>Search Older Commits By Commit Message</h4><p>You can search for older commits using the following command. This can be particularly useful if you name your commit message with your JIRA ticket number.</p><pre>git log --grep=&quot;&lt;commit_message&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/994/1*j-Slow9trewyu-A7bI9YGg.jpeg" /></figure><h4>Find Who Edited What</h4><p>If you feel like blaming someone else for some line of code which stopped working, there’s a git command for that</p><pre>git blame &lt;file_name&gt;</pre><p>This will print the current file with the commit id along with the developer’s name on the left side of each line of code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/911/1*cFGzG7fXlRubb6R85nYC5w.jpeg" /><figcaption>git blame</figcaption></figure><p>For a better UX you can use the annotate command in Android Studio for the same result</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/924/1*rqKAItggrYbywautnxLKgg.png" /><figcaption>annotate sounds less threatening than blame</figcaption></figure><h4>Set aliases for git commands</h4><p>You can also set aliases for git commands if you don’t feel like typing too much</p><pre>git config --global alias.&lt;alias_name&gt; &lt;command_name&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/911/1*uSX0Ic8sBWjtnHI51h5lQA.jpeg" /><figcaption>An example showing an alias set for status to st</figcaption></figure><h4>Switch To Last Working Branch</h4><p>Let’s say you’re working on your development branch and your manager asks you to quickly get a build ready from the master branch. You take your stash, switch to master and build your apk, now to switch back you have to type in that long branch name again, worse if you don’t remember the name and you have to look it up. Here’s a shortcut you can use to ease your life</p><pre>git checkout -</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/911/1*Od7D49QrBA_tFkAzJzJ-4Q.jpeg" /><figcaption>Here you can see me switching from dev to master using the shortcut</figcaption></figure><h4>Auto Correct Typos</h4><p>If you’re feeling brave, you can set git to autocorrect your typos. For example, stats would get auto-corrected to status. Bear in mind, some auto-corrects can be ambiguous and git uses its own algorithm to determine what would be the correct command for your typo.</p><pre>git config --global help.autocorrect 1</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/911/1*FwMzcApeBf3iCo939xTv5Q.jpeg" /><figcaption>git autocorrecting ‘brnch’ to branch</figcaption></figure><h4>Show File From Another Branch</h4><p>Let’s say you’re working in your dev branch and you quickly need to refer some change which you did in another branch. Instead of switching branches, you can use this shortcut to see your file from the other branch</p><pre>git show &lt;branch&gt;:&lt;file_name&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/911/1*zIS5Dsbb5KAKbgBMgwm58g.jpeg" /></figure><h4>Fix Typo In Last Commit Message</h4><p>How many times has it happened to you that you made a typo in your commit message. Git allows you to easily fix that with the amend command</p><pre>git commit -v --amend -m &quot;&lt;updated_mesage&gt;&quot;</pre><p>-v is completely optional but I like the verbosity</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/911/1*pFOGDNfpMa4a0BmPYiK8aw.jpeg" /><figcaption>Watch me fix my typo</figcaption></figure><h4>Undo Last Local Commit And Keep Changes</h4><p>Let’s say you made your commit after a day’s long work but you commited your code in another branch. Of course you wouldn’t want to lose all that work, here’s how you can revert that last commit while keeping your changes</p><pre>git reset HEAD^</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/911/1*KtR5zEMSxpGrfSv-gOFotQ.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=76d967360de8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/android-dev-corner/10-git-tricks-every-developer-should-know-76d967360de8">10 Git Tricks Every Developer Should Know</a> was originally published in <a href="https://medium.com/android-dev-corner">Android Developers Corner</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Thoughts on The Medium]]></title>
            <link>https://thatrohit.medium.com/thoughts-on-the-medium-354f345901cd?source=rss-c6ed44ee8393------2</link>
            <guid isPermaLink="false">https://medium.com/p/354f345901cd</guid>
            <category><![CDATA[the-media]]></category>
            <category><![CDATA[psychological-horror]]></category>
            <category><![CDATA[videogames]]></category>
            <dc:creator><![CDATA[Rohit Gupta]]></dc:creator>
            <pubDate>Thu, 25 Feb 2021 05:45:42 GMT</pubDate>
            <atom:updated>2021-02-25T05:45:42.135Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oodHlzAJl71X_1wjpiqnHQ.jpeg" /></figure><p><em>It all ends in me</em></p><p>I played a lot of games during the pandemic, but nothing left a lasting impression apart from three; Amnesia: Rebirth, Katana Zero and finally, The Medium, which was so good that it made me write my thoughts here, after almost a year. The story is convoluting at best and you have put the pieces together using various notes and echoes found throughout the game.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DHvD8GThcfoC6vxXsdw1qA.png" /></figure><p><em>Impressions</em></p><p>The Medium satisfied a deep craving in me for something which had been suppressed for so long that I had long forgotten about. Early 2000s psychological horror. Games with rudimentary camera angles which focus more on exploration and surreal environments to drive the horror rather than monsters or body horror. Games that don’t simply narrate you their stories, rather lets you unearth them by introspecting as you play. Games with symbolism which subconsciously define what’s going on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cUVoVoxrppoR6MXCm8t_AA.jpeg" /></figure><p><em>Premise</em></p><p>We play as Marianne, an orphan who has been moving from one foster home to another. This is because she has a supernatural ability to speak with dead spirits who’re lost in purgatory, or as the game calls it, the spirit world. She finally finds a foster parent who accepts her for what she is, Jack. The game starts with Marianne performing the last rites for Jack, when she receives a phone call from an unknown number saying she’s the only one who can help. Marianne, though reluctant but curious, travels to where the caller asked her to come and progresses to uncover truth about herself.</p><p><em>Symbolism</em></p><p>The inspiration from Silent Hill can be seen in a lot of place, although this game lacks combat, the similarities can be seen in the symbolism it uses with monsters, the soundtrack and the art style. The game shows us that beyond our realm is a spirit world, where souls lost in purgatory are trapped eternally. Marianne has the ability to travel to this spirit world to free lost souls and to talk to them. The spirit world is heavily inspired from the art style of Polish painter Beksinski and is rendered beautifully. It is nothing like I have ever seen in any other form of media before. I have to travel into spoiler territory if I want to write about this, this part can be skipped if you want to experience it for yourself.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qm6wJ8Ncn7sVxGZBg-esHg.jpeg" /></figure><p>The titular demon hunting you, The Maw, is born from the years of sexual torment endured by ~10 year old Lilianne. Her spirit has split into two, the first one is an innocent little playful girl but the other one is demon who feeds on the souls of living beings and is powerful enough to project himself into the real world. The player does not know this fact at the start of the game but the hints are there. The Maw has wings on his back which resembles that of a butterfly or a moth, this can be related to Lilianne being interested in butterflies when she was young. When The Maw hunts Marianne, it threatens hear sexually with threats such as it wants to wear her skin, pretty little skin suit, this can be related to Lilianne’s sexual torment. The Maw is hunting for the perfect host to enter the real world and it has found that in Marianne.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/1*ESGFV3pRH00WiL7N3cqs4g.jpeg" /></figure><p>Another beast we get to see in the game is The Hound, which is the spirit representation of Henry. Henry was a cold and heartless KGB agent and his spirit self was a beast which resembled half human and half dog. Just like a guard dog, it guarded the innocent child self of Henry as a watch dog, threating any invader.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vzrT531yIBaKDLmvchMR8g.jpeg" /></figure><p>Lastly, I wanted to bring up the symbolism with Richard’s spirit self. Richard’s spirit self is a towering creature with long tentacles like appendages which slithers around. The tentacles depicts phallic symbolism associated with Richard molesting Lilianne when she was a child and his huge gargantuan self must be what Lilianne perceived when she was a child. She must have seen Richard towering over her when he did his heinous acts.</p><p><em>Conclusion</em></p><p>I don’t want to write the entire story of the game here because I believe it is best experienced when played. The story is narrated piece by piece and it is satisfying to reveal it by putting the pieces together. The Medium was a fantastic game to experience and is very well going to be one of the most memorable games I will ever play.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=354f345901cd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Git + Batch Files = ☺]]></title>
            <link>https://thatrohit.medium.com/git-batch-files-8e21d7c0961f?source=rss-c6ed44ee8393------2</link>
            <guid isPermaLink="false">https://medium.com/p/8e21d7c0961f</guid>
            <category><![CDATA[git]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[batch-file]]></category>
            <dc:creator><![CDATA[Rohit Gupta]]></dc:creator>
            <pubDate>Mon, 30 Nov 2020 08:24:54 GMT</pubDate>
            <atom:updated>2020-11-30T08:24:54.595Z</atom:updated>
            <content:encoded><![CDATA[<p>If you’re one of those unfortunate souls who have to work on a lego architecture project, then you’re probably as tired as I was when the time came to update all your repositories from git.</p><p>I know, it is tedious to go to each and every repository one by one and run your git command every time then wait for it to complete.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/356/1*52z5RuBGqIxroZjZDJ-lbg.gif" /><figcaption>tell me this is not how you feel</figcaption></figure><p>However, there’s a simple way of ‘automating’ this if you’re familiar with batch scripts in Windows. All you have to do is write a script which navigates to each and every repository of your project and runs a git command.</p><p>Let me explain, so this is what my project structure looks like</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/445/1*N1HQT_Jugj37JM-6qKZOfA.png" /><figcaption>Project Structure</figcaption></figure><p>All the sub-folders inside modules folder is a repository in itself. You can see there are 22 repository inside modules and the parent folder is a repository in itself.</p><p>I’ve written a script which navigates to the modules folder first and runs the command in all the repository, then it goes back to the parent folder and runs the same command.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ba653e2302e184b9a6995357d94970ef/href">https://medium.com/media/ba653e2302e184b9a6995357d94970ef/href</a></iframe><p>This enabled me to save a lot of time as it does not require my manual intervention, just one execute and it’s ready to go</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/482/1*B7eWzLtd9gwSoRflxVL5cQ.jpeg" /></figure><p>This can not only be used for git, it can also be used to run gradle commands in multiple repositories. Let’s say you need to run a clean command on all repos, you could simply enter</p><pre>gradlew clean</pre><p>as an argument to your batch file and execute it in all your repos. Hope you find this helpful!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8e21d7c0961f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>