<?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 Ankit Kumar on Medium]]></title>
        <description><![CDATA[Stories by Ankit Kumar on Medium]]></description>
        <link>https://medium.com/@ankitk77?source=rss-747f6e5d0c6c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*sj9gZ-hl7V2hZWorI6tZzQ.jpeg</url>
            <title>Stories by Ankit Kumar on Medium</title>
            <link>https://medium.com/@ankitk77?source=rss-747f6e5d0c6c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 04:31:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ankitk77/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[CMP/Android Library Publication to Maven Central]]></title>
            <link>https://ankitk77.medium.com/cmp-android-library-publication-to-maven-central-0a33595fa0ef?source=rss-747f6e5d0c6c------2</link>
            <guid isPermaLink="false">https://medium.com/p/0a33595fa0ef</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[libraries]]></category>
            <category><![CDATA[compose-multiplatform]]></category>
            <category><![CDATA[maven-central]]></category>
            <dc:creator><![CDATA[Ankit Kumar]]></dc:creator>
            <pubDate>Wed, 24 Jun 2026 21:27:33 GMT</pubDate>
            <atom:updated>2026-06-24T21:28:13.437Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article, we’ll explore the process of publishing an Android/CMP/KMP library to Maven Central.</p><p><a href="https://github.com/ankitk77/coachmark">Working Demo</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a-RidMx8ZaBA9O24Mbgs-A.png" /></figure><h3>Phase 1: Machine &amp; Keyservers Setup (One-Time)</h3><h3>1. Setup Your GPG Key</h3><p>If you don’t have a clean, single-line GPG private key ready, run this on your terminal:</p><pre>gpg --full-generate-key<br># Choose RSA and RSA, keysize = 4096 bits, expiration = 0(for no expiration).<br># Set a Passphrase <strong>[signing.password]</strong> you never forget.</pre><h3>2. Get your short Key ID — [signing.keyId]</h3><pre>gpg --list-secret-keys --keyid-format SHORT<br>#Look at the output line beginning with sec. <br>#It will resemble something like this: rsa4096/2B906A2C. <br>#Here, 2B906A2C is your Key ID.</pre><h3>3. Upload your key to the servers</h3><p>Sonatype verifies the metadata signature of your uploaded artifacts against global keyservers. If your public key isn’t indexed, your deployment will be rejected instantly:</p><pre>gpg --keyserver keyserver.ubuntu.com --send-keys YOUR_KEY_ID</pre><h3>4. Export your secret key — [signing.secretKey]</h3><p>We need to export your private key into a single, continuous line where string breaks are explicitly formatted as literal \n character combinations.</p><pre># On macOS:<br>gpg --export-secret-keys --armor YOUR_KEY_ID | awk &#39;ORS=&quot;\\n&quot;&#39;<br># On Linux:<br>gpg --export-secret-keys --armor YOUR_KEY_ID | awk &#39;{printf &quot;%s\\n&quot;, $0}&#39;</pre><p>Copy the full text output safely to your clipboard.</p><h3>Phase 2: Configure Global Credentials File</h3><p>To ensure your keys apply to all projects safely without risking credential leakage into GitHub repos, store your properites in local.properties and whenever you are publishing copy it to gradle.properties <a href="https://github.com/ankitk77/coachmark/blob/master/gradle.properties">[Reference]</a></p><pre><strong>gradle.properties</strong></pre><pre># Sonatype User Token (Do NOT use your portal account password here. <br># Generate an Token via <a href="https://central.sonatype.com/">https://central.sonatype.com</a>/-&gt; Account -&gt; User Tokens -&gt; Generate User Token)</pre><pre>mavenCentralUsername=token_keyid<br>mavenCentralPassword=token_password</pre><pre>[You can find keys mapping above in the steps]<br>signing.keyId=YOUR_KEY_ID<br>signing.password=YOUR_GPG_PASSPHRASE<br>signing.secretKey=-----BEGIN PGP PRIVATE KEY BLOCK-----\n...\n-----END PGP PRIVATE KEY BLOCK-----\n</pre><h3>Phase 3: The Project Configuration Script</h3><p>With your machine prepared, let’s wire up your build system.</p><h3>1. Root build.gradle.kts <a href="https://github.com/ankitk77/coachmark/blob/master/build.gradle.kts#L8">[Reference]</a></h3><pre>plugins {<br>    id(&quot;com.vanniktech.maven.publish&quot;) version &quot;0.28.0&quot; apply false<br>    ...<br>}</pre><h3>2. Module-Level build.gradle.kts <a href="https://github.com/ankitk77/coachmark/blob/master/coachmark/build.gradle.kts">[Reference]</a></h3><p>Open the subproject module containing your shared library architecture components and configure the publishing plugin:</p><pre>import com.vanniktech.maven.publish.SonatypeHost<br>import com.vanniktech.maven.publish.KotlinMultiplatform<br><br>plugins {<br>    ..<br>    id(&quot;com.vanniktech.maven.publish&quot;) // Apply the publishing engine here<br>    signing // Enables conditional signing guards below<br>}<br><br><br>mavenPublishing {<br>    coordinates(<br>        groupId = &quot;io.github.yourusername&quot;, <br>        artifactId = &quot;your-library-name&quot;, <br>        version = &quot;1.0.0&quot; // Use &quot;1.0.0-SNAPSHOT&quot; if testing staging snapshots<br>    )<br><br>    pom {<br>        name.set(&quot;Your Library Title&quot;)<br>        description.set(&quot;A concise declaration outlining your framework&#39;s utility.&quot;)<br>        inceptionYear.set(&quot;2026&quot;)<br>        url.set(&quot;https://github.com/yourusername/repo&quot;)<br>        licenses {<br>            license {<br>                name.set(&quot;The Apache License, Version 2.0&quot;)<br>                url.set(&quot;http://www.apache.org/licenses/LICENSE-2.0.txt&quot;)<br>            }<br>        }<br>        developers {<br>            developer {<br>                id.set(&quot;yourusername&quot;)<br>                name.set(&quot;Your Name&quot;)<br>            }<br>        }<br>        scm {<br>            url.set(&quot;https://github.com/yourusername/repo&quot;)<br>            connection.set(&quot;scm:git:git://github.com/yourusername/repo.git&quot;)<br>            developerConnection.set(&quot;scm:git:ssh://github.com/yourusername/repo.git&quot;)<br>        }<br>    }<br><br>    configure(KotlinMultiplatform(javadocJar = com.vanniktech.maven.publish.JavadocJar.Empty()))<br>    publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL, automaticRelease = true)<br>    signAllPublications()<br>}<br><br><br>val properties = Properties().apply {<br>    val file = rootProject.file(&quot;gradle.properties&quot;)<br>    if (file.exists()) {<br>        file.inputStream().use { load(it) }<br>    }<br>}<br><br>signing {<br>    val keyId = properties.getProperty(&quot;signing.keyId&quot;)<br>    val password = properties.getProperty(&quot;signing.password&quot;)<br>    val secretKey = properties.getProperty(&quot;signing.secretKey&quot;)<br><br>    if (!keyId.isNullOrEmpty() &amp;&amp; !secretKey.isNullOrEmpty()) {<br>        useInMemoryPgpKeys(keyId, secretKey, password)<br>    }<br>}</pre><h3>Phase 4: The Command Execution Runbook</h3><h3>Local Testing Environments</h3><p>Bash</p><pre>./gradlew publishAllPublicationsToMavenLocal</pre><h3>Production Distribution</h3><p>When code is verified and ready for public ingestion, run the primary target repository task.</p><pre>./gradlew publishAllPublicationsToMavenCentralRepository</pre><p>Because automaticRelease = true is declared in our script configuration, as soon as Sonatype completes its automated structural and signature integrity scanning, your library variants will drop directly into production!</p><p>Happy coding! 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0a33595fa0ef" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automate Android Library Publication to Maven Central via Github Actions]]></title>
            <link>https://ankitk77.medium.com/automate-android-library-publication-to-maven-central-via-github-actions-c14416382c5f?source=rss-747f6e5d0c6c------2</link>
            <guid isPermaLink="false">https://medium.com/p/c14416382c5f</guid>
            <category><![CDATA[maven-central]]></category>
            <category><![CDATA[publish-library]]></category>
            <category><![CDATA[sonatype]]></category>
            <category><![CDATA[android-libraries]]></category>
            <category><![CDATA[git-action]]></category>
            <dc:creator><![CDATA[Ankit Kumar]]></dc:creator>
            <pubDate>Fri, 09 Feb 2024 21:36:14 GMT</pubDate>
            <atom:updated>2025-09-22T17:57:40.929Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article, we’ll explore the process of publishing an Android library to Maven Central using both local command-line tools and GitHub Actions.</p><p>By following these steps, you’ll set up a seamless workflow where each GitHub release triggers the automatic publication of your library to Maven Central, ensuring that your latest updates are readily available to the wider developer community.</p><blockquote>You can find the complete source code here : <a href="http://github.com/ankitk77">github.com</a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*BMiZSqGbMrXADGIyoc9LRA.jpeg" /></figure><h4>Steps to Publish Android Libraries</h4><ol><li>Register Group ID on Maven by raising a Jira Ticket</li><li>Generate GPG Keys | OSS_SIGNING_KEY_ID</li><li>Get staging profile Id | OSS_STAGING_PROFILE_ID</li><li>Generating base64 file for gpg key | OSS_SIGNING_KEY</li><li>Configure root level build.gradle of project</li><li>Create publish-package.gradle</li><li>Configure the build.gradle file of each module</li><li>Setting up environment variables</li><li>Publish to Local Maven</li><li>Publish SNAPSHOT to Maven</li><li>Publish the Final Release to Maven</li><li>Automating release via Github Action</li><li>Wohoo! You just published your library 🚀</li></ol><h4>Register Group ID on Maven by raising a Jira Ticket</h4><ul><li>Go to <a href="https://issues.sonatype.org/">Maven Jira issues</a> and login/register.</li><li>Click on create button from header menu and fill the required details 👇</li></ul><pre>Project - Open Source Project Hosting<br>Issue Type - New Project<br>Summary - Create repository for io.github.foo:coachmark<br>Description - A light weight compose library to create onboaring experience <br>Group id - io.github.foo (unique identifier)<br>Project URL - https://github.com/ankitk77/coachmark (github repo url)<br>SCM URL - https://github.com/ankitk77/coachmark.git (github repo -&gt; code -&gt; copy url in https section)<br>Already Synced to Central - No</pre><ul><li>Click on create, You will recieve a email to prove your identity (just follow whatever asked, Generally they ask to create a github repo)</li><li>Once your request is approved, your group ID is registered which can be used in your Android project.</li></ul><blockquote>Your username and password will be `OSS_USERNAME` and OSS_PASSWORD respectively at later stage.</blockquote><h4>Generate GPG Keys | OSS_SIGNING_KEY_ID</h4><p>GPG Keys are used to sign final artifacts before publishing them to Maven. To create a new GPG Key, run the following command and follow the instructions:</p><blockquote>Note : -When creating you will set a password that will be `OSS_SIGNING_PASSWORD` at later stage</blockquote><pre>gpg --gen-key</pre><p>After that, get the short format of GPG Key, which will be required in the next step:</p><pre>gpg --list-keys --keyid-format short</pre><p>The output may look like below, which contains one or more GPG keys:</p><pre>// pub &lt;encryption algorithm&gt;/&lt;gpg-short-id&gt; &lt;date&gt; [SC]<br><br>pub   rsa3072/87E39614 2024-01-22 [SC]<br>      DD28C4154EB791431BFE515AF3B24FB387E39614<br>uid         [ultimate] Ankit Kumar (..) &lt;example@gmail.com&gt;<br>sub   rsa3072/9FFEC7CE 2024-01-22 [E]<br><br>pub   ed25519/2BF3E5DA 2023-10-02 [SC] [expires: 2026-10-01]<br>      DF0A28897E1A532A6BF5C4B9B9EDCC712BF3E5DA<br>uid         [ unknown] Ankit &lt;example@gmail.com&gt;<br>sub   cv25519/5CD8CFFB 2023-10-02 [E] [expires: 2026-10-01]</pre><p>Pick one. Look carefully at the format (in the first line of the above output): “pub &lt;encryption algorithm&gt;/&lt;gpg-short-id&gt; &lt;date&gt; [SC]”</p><blockquote>&lt;gpg-short-id&gt; will be OSS_SIGNING_KEY_ID at later stage</blockquote><h4>Get staging profile Id | OSS_STAGING_PROFILE_ID</h4><ul><li>Go to <a href="https://s01.oss.sonatype.org/#stagingProfiles">Sonatype -&gt; Staging Repository</a></li><li>Click on 1st row and check the web url you will find a alphanumeric at the end, that’s our staging profile id</li></ul><pre>https://s01.oss.sonatype.org/#stagingProfiles;&lt;OSS_STAGING_PROFILE_ID&gt;</pre><h4>Generating base64 file for gpg key | OSS_SIGNING_KEY</h4><p>Run the below command a base 64 string will be generated and password is what you set while creating gpg key</p><pre>gpg --export-secret-keys &lt;gpg-short-id&gt; | base64</pre><p><strong>Generate Access Token</strong> — <a href="https://central.sonatype.org/publish/generate-token/">follow this link</a> | OSS_PASSWORD</p><h3><strong>Code Changes</strong></h3><h4>Configure root level build.gradle of your project [<a href="https://github.com/pseudoankit/ratingbar-compose/blob/master/build.gradle">reference</a>]</h4><pre>plugins {<br>   ....<br>   id &#39;io.github.gradle-nexus.publish-plugin&#39; version &#39;1.1.0&#39;<br>}<br><br>// only for users registered in Sonatype after 24 February 2021 <br>nexusPublishing {<br>    repositories {<br>        sonatype {<br>            username = System.getenv(&quot;OSS_USERNAME&quot;)<br>            password = System.getenv(&quot;OSS_PASSWORD&quot;)<br>            stagingProfileId = System.getenv(&quot;OSS_STAGING_PROFILE_ID&quot;)<br><br>            nexusUrl.set(uri(&quot;https://s01.oss.sonatype.org/service/local/&quot;))<br>            snapshotRepositoryUrl.set(uri(&quot;https://s01.oss.sonatype.org/content/repositories/snapshots/&quot;))<br>        }<br>    }<br>}</pre><h4>Create publish-package.gradle [<a href="https://github.com/pseudoankit/ratingbar-compose/blob/master/gradle/publish-package.gradle">reference</a>]</h4><p>Creating a separate file will help to easily reuse in multimodular project or any other project</p><blockquote>Note : You can configure version for each individual module also, to do so remove VERSION from below and add it at module level gradle</blockquote><pre>// Please go through the file and do the needful change<br>apply plugin: &#39;maven-publish&#39;<br>apply plugin: &#39;signing&#39;<br><br>ext {<br>    GROUP_ID = &quot;io.github.foo&quot;<br>    VERSION = (System.getenv(&quot;RELEASE_TAG_NAME&quot;) ?: &quot;SNAPSHOT&quot;).replace(&quot;v&quot;, &quot;&quot;)<br><br>    SITE_URL = &#39;https://github.com/ankitk77/coachmark&#39;<br>    GIT_URL = /coachmark.git&#39;<br><br>    POM_DESCRIPTION = &quot;Compose library to add coachmark&quot;<br>    POM_URL = SITE_URL<br>}<br><br>signing {<br>    useInMemoryPgpKeys(<br>            System.getenv(&quot;OSS_SIGNING_KEY_ID&quot;),<br>            System.getenv(&quot;OSS_SIGNING_KEY&quot;),<br>            System.getenv(&quot;OSS_SIGNING_PASSWORD&quot;),<br>    )<br>    sign publishing.publications<br>}<br><br>// If you want to publish your sources as well<br>task androidSourcesJar(type: Jar) {<br>    archiveClassifier.set(&#39;sources&#39;)<br>    from android.sourceSets.main.java.srcDirs<br>    from android.sourceSets.main.kotlin.srcDirs<br>}<br><br>artifacts {<br>    archives androidSourcesJar<br>}<br><br>afterEvaluate {<br>    publishing {<br>        publications {<br>            release(MavenPublication) {<br><br>                groupId GROUP_ID<br>                artifactId ARTIFACT_ID<br>                version VERSION<br><br>                from components.release<br>                artifact androidSourcesJar<br><br>                pom {<br>                    name = ARTIFACT_ID<br>                    description = POM_DESCRIPTION<br>                    url = POM_URL<br>                    licenses {<br>                        license {<br>                            name = &quot;The Apache Software License, Version 2.0&quot;<br>                            url = &quot;https://www.apache.org/licenses/LICENSE-2.0.txt&quot;<br>                        }<br>                    }<br><br>                    developers {<br>                        developer {<br>                            id = &#39;ankit&#39;<br>                            name = &#39;Ankit Kumar&#39;<br>                            email = &#39;foo@gmail.com&#39;<br>                        }<br>                    }<br><br>                    scm {<br>                        connection = GIT_URL<br>                        developerConnection = GIT_URL<br>                        url = SITE_URL<br>                    }<br>                }<br>            }<br>        }<br>    }<br>}<br><br></pre><h4>Configure the build.gradle file of each module [<a href="https://github.com/pseudoankit/ratingbar-compose/blob/master/rating-bar/build.gradle">reference</a>]</h4><pre>....<br>apply from: &#39;../gradle/publish-package.gradle&#39;<br>ext {<br>    ARTIFACT_ID = &quot;coachmark&quot;  <br>}</pre><h4>Setting up environment variables</h4><p>Below are steps to do in mac you can check for other OS</p><pre>Open Terminal<br>run vim ~/.zshrc<br>press space <br>press e<br>press i<br><br>now add these lines <br><br>export RELEASE_TAG_NAME=&lt;dummy version anyways we will get it from github release&gt;<br>export OSS_STAGING_PROFILE_ID=&lt;steps above&gt;<br>export OSS_USERNAME=&lt;oss jira user name / mentioned above&gt;<br>export OSS_PASSWORD=&lt;check steps above to generate this&gt;<br>export OSS_SIGNING_KEY_ID=&lt;&lt;gpg-short-id&gt; steps mentioned above&gt;<br>export OSS_SIGNING_PASSWORD=&lt;password which you entered while creating gpg / mentioned above&gt;<br>export OSS_SIGNING_KEY=&lt;steps mentioned above&gt;<br><br>press esc<br>type :qw -&gt; enter<br>source ~/.zshrc</pre><h3>Publish Libraries</h3><h4>Publish to Local Maven</h4><p>Before publishing to Maven, first try to publish the packages into local Maven.</p><pre>./gradlew publishToMavenLocal</pre><p>This will publish all your modules that are configured for Maven into local Maven.</p><p>You can test your libraries, by importing them into different projects. For that, you first need to add <strong>mavenLocal()</strong> as one of the lists of repositories and then import the library as dependencies in the gradle file as usual:</p><pre>implementation &#39;io.github.foo:coachmark:1.7.0&#39;</pre><h4>Publish SNAPSHOT to Maven</h4><p>Snapshot libraries are useful when you are not formally releasing the libraries, but want your audience/testers to test it by using it. For that, you first need to append ‘-SNAPSHOT’ to your version and run</p><pre>./gradlew publishReleasePublicationToSonatypeSnapshotRepository</pre><p>Once published, you should be able to see your libraries on location:</p><p><a href="https://s01.oss.sonatype.org/content/repositories/snapshots/io/github/geofriendtech/">https://s01.oss.sonatype.org/content/repositories/snapshots/io/github/&lt;foo&gt;/</a></p><h4>Publish the Final Release to Maven</h4><pre>./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository</pre><p>Once published you should be able to see your libraries on location:</p><p><a href="https://s01.oss.sonatype.org/content/repositories/releases/io/github/pseudoankit/">https://s01.oss.sonatype.org/content/repositories/releases/io/github/foo/</a></p><h4>Automating release via Github Action <a href="https://github.com/pseudoankit/coachmark/blob/master/.github/workflows/publish.yml">[reference]</a></h4><p>Create a file publish.yml under project/.github/workflows/...</p><pre>name: Publish<br><br># This block defines that action will be triggered when we do a github release<br>on:<br>  release:<br>    types: [ created ]<br><br>jobs:<br>  deploy:<br>    runs-on: ubuntu-latest<br>    steps:<br>      - name: Checkout<br>        uses: actions/checkout@v2<br><br>      - name: Setup JDK<br>        uses: actions/setup-java@v1<br>        with:<br>          java-version: 17<br><br>      - name: Publish Artifact<br>        env:<br>          # fetching the release version tag<br>          RELEASE_TAG_NAME: ${{ github.event.release.tag_name }}<br>          OSS_USERNAME: ${{ secrets.OSS_USERNAME }}<br>          OSS_PASSWORD: ${{ secrets.OSS_PASSWORD }}<br>          OSS_STAGING_PROFILE_ID: ${{ secrets.OSS_STAGING_PROFILE_ID }}<br>          OSS_SIGNING_KEY_ID: ${{ secrets.OSS_SIGNING_KEY_ID }}<br>          OSS_SIGNING_PASSWORD: ${{ secrets.OSS_SIGNING_PASSWORD }}<br>          OSS_SIGNING_KEY: ${{ secrets.OSS_SIGNING_KEY }}<br>        run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository</pre><h4>Setting up environment variables in github project</h4><ul><li>Navigate to your repository</li><li>Go to Settings</li><li>Under Secrets And Variables section, navigate to Actions tab</li><li>New repository secret, add all key-values we added in terminal 🔝</li></ul><h4>Release library via action</h4><ul><li>Navigate to your repository</li><li>Some where on right, click on Releases</li><li>Draft a new release</li><li>Choose tag &lt;version&gt; (eg: v1.0.0)</li><li>Publish release</li></ul><h4>Wohoo! You just published your library 🚀</h4><p>I didn’t face this problem, but we might have to do the following as recommended in <a href="https://medium.com/@scottyab/how-to-publish-your-open-source-library-to-maven-central-5178d9579c5">this</a> article.:</p><blockquote><em>If you are releasing for the first time, do not forget to comment on the Jira tracker ticket, letting Sonatype know that you have completed a release. This is for them to activate some kind of sync process.</em></blockquote><p>Thank you for reading the article, hope you found it informative and helpful for streamlining your development workflow.</p><p>Here’s the complete changelist : <a href="https://github.com/pseudoankit/ratingbar-compose/pull/3/files">github.com</a></p><p>If you have any questions or need further assistance, please don’t hesitate to reach out on <a href="https://www.linkedin.com/in/pseudoankit/">linkedin</a></p><p>Additionally, I invite you to explore my <a href="https://github.com/pseudoankit/coachmark">Coachmark library — A Jetpack Compose library</a> to provide seamless onboarding experience to users. <br>Feel free to check out my <a href="https://github.com/pseudoankit">GitHub profile</a> for more projects and contributions.</p><p>Happy coding!</p><p>Few References taken from :-<br><a href="https://thsaravana.github.io/blog/publish-android-library-maven-central/">https://thsaravana.github.io/blog/publish-android-library-maven-central/</a><br><a href="https://medium.com/@vivekvashistha/how-to-publish-android-libraries-on-maven-central-in-2023-a96e3c327008">https://medium.com/@vivekvashistha/how-to-publish-android-libraries-on-maven-central-in-2023-a96e3c327008</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c14416382c5f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Widgets in compose]]></title>
            <link>https://ankitk77.medium.com/widgets-in-compose-3647b17c9b32?source=rss-747f6e5d0c6c------2</link>
            <guid isPermaLink="false">https://medium.com/p/3647b17c9b32</guid>
            <category><![CDATA[widget]]></category>
            <category><![CDATA[compose]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Ankit Kumar]]></dc:creator>
            <pubDate>Wed, 31 May 2023 15:52:30 GMT</pubDate>
            <atom:updated>2023-06-01T05:00:28.946Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NX8fNxLTvPTznX2X9M2daw.png" /></figure><p>We will be using Glance api to create widgets<br><a href="https://github.com/pseudoankit/Tasky/tree/master/core/app-shortcuts-n-widgets">You can refer the GitHub repo to get the implementation</a></p><p>Table of Content</p><ul><li>Getting started with creating a widgets</li><li>Overviews on frequently used components</li><li>Read and write with datastore provided via glance api</li><li>Reading value from local db</li></ul><pre>// Add these dependencies in you module&#39;s build.gradle<br><br>dependencies {<br>    implementation(&quot;androidx.glance:glance:1.0.0-beta01&quot;)<br>    implementation(&quot;androidx.glance:glance-appwidget:1.0.0-beta01&quot;)<br>}<br><br>android {<br>    buildFeatures {<br>        compose = true<br>    }<br>    composeOptions {<br>        kotlinCompilerExtensionVersion = &quot;1.1.0-beta03&quot;<br>    }<br>    kotlinOptions {<br>        jvmTarget = &quot;1.8&quot;<br>    }<br>}</pre><p>Create a file under res/xml directory to provide basic info about the widget (e.g., widget_info.xml):</p><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;<br>&lt;appwidget-provider xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;<br>    android:description=&quot;@string/app_name&quot;<br>    android:minWidth=&quot;200dp&quot;<br>    android:minHeight=&quot;200dp&quot;<br>    android:previewImage=&quot;@mipmap/ic_launcher&quot;<br>    android:resizeMode=&quot;horizontal|vertical&quot;<br>    android:widgetCategory=&quot;home_screen&quot; /&gt;</pre><p>Create a GlanceAppWidgetReceiver that will recieve callbacks to render widget</p><pre>class AgendaItemAppWidgetReceiver : GlanceAppWidgetReceiver() {<br><br>    override val glanceAppWidget: GlanceAppWidget<br>        get() = AgendaItemsAppWidget  // name of widget file we will create below<br><br>    override fun onReceive(context: Context, intent: Intent) {<br>        super.onReceive(context, intent)<br><br>        val appWidgetManager = AppWidgetManager.getInstance(context)<br>        val componentName =<br>            ComponentName(context.packageName, checkNotNull(javaClass.canonicalName))<br>        onUpdate(<br>            context,<br>            appWidgetManager,<br>            appWidgetManager.getAppWidgetIds(componentName),<br>        )<br>    }<br><br>    companion object {<br>        fun sendAppsUpdatedBroadcast(context: Context) {<br>            context.sendBroadcast(<br>                Intent(context, AgendaItemAppWidgetReceiver::class.java)<br>            )<br>        }<br>    }<br>}</pre><p>Register the receiver in the manifest file (AndroidManifest.xml):</p><pre>&lt;receiver<br>    android:name=&quot;pseudoankit.droid.app_widgets.agenda_items.AgendaItemAppWidgetReceiver&quot;<br>    android:exported=&quot;false&quot;&gt;<br>    &lt;intent-filter&gt;<br>        &lt;action android:name=&quot;android.appwidget.action.APPWIDGET_UPDATE&quot; /&gt;<br>    &lt;/intent-filter&gt;<br><br>    // xml file we created above<br>    &lt;meta-data<br>        android:name=&quot;android.appwidget.provider&quot;<br>        android:resource=&quot;@xml/tasky_widget_info&quot; /&gt;<br>&lt;/receiver&gt;</pre><p>Now, create your widget class by subclassing GlanceAppWidget:</p><pre>internal object AgendaItemsAppWidget : GlanceAppWidget() {<br>    @Composable<br>    override<br>    fun Content() {<br>        // render your composable here<br>    }<br>}</pre><p>Note: Instead of using normal Compose components, Glance provides a set of components that you can use. <a href="https://developer.android.com/jetpack/androidx/releases/glance">More info</a></p><p>Here are some examples of using the Glance components:</p><pre>Button(<br>    text = &quot;Click Me&quot;,<br>    onClick = actionStartActivity(<br>        intent = Intent(Intent.ACTION_VIEW).apply {<br>            data = Uri.parse(&quot;app deep link&quot;)<br>        }<br>    )<br>)<br><br>Image(<br>    provider = ImageProvider(resId = R.drawable.ic_add),<br>    modifier = GlanceModifier.clickable(onClick = actionSendBroadcast(Intent()...)),<br>    contentDescription = &quot;&quot;<br>)<br><br>LazyColumn(modifier = GlanceModifier.fillMaxSize()) {<br>    items(items) { item -&gt;<br>        // Render the view for each item<br>    }<br>}</pre><p>To create a local variable and update it, you can use the dataStore:</p><pre>val countKey = intPreferencesKey(&quot;count&quot;)<br><br>Button(<br>    text = &quot;Increment&quot;,<br>    onClick = actionRunCallback(IncrementActionCallback::class.java)<br>)<br><br>class IncrementActionCallback: ActionCallback {<br>    override suspend fun onAction(<br>        context: Context,<br>        glanceId: GlanceId,<br>        parameters: ActionParameters<br>    ) {<br>        updateAppWidgetState(context, glanceId) { prefs -&gt;<br>            val currentCount = prefs[countKey]<br>            prefs[countKey] = currentCount + 1<br>        }<br>        CounterWidget.update(context, glanceId)<br>    }<br>}</pre><p>To read values from the `local database` , you can use a worker thread:<br> <a href="https://github.com/pseudoankit/Tasky/blob/master/core/app-shortcuts-n-widgets/src/main/java/pseudoankit/droid/app_widgets/agenda_items/AgendaItemsAppWidget.kt">Check sample code here</a></p><pre>class Repository () {<br>  function dataFromLocalDb() : List&lt;&gt;{<br>    // ...<br>  }<br>}<br><br><br>// UI Layer<br>object MyWidget : GlanceAppWidget() {<br>  private val repository : Repository<br><br>  @WorkerThread<br>  fun dataFromLocalDb() = repository.dataFromLocalDb()<br><br>  @Composable<br>  override<br>  fun Content() {<br>    LazyColumn {<br>      items(dataFromLocalDb()) {<br>        // read the values<br>      }<br>    }<br>  }<br>}</pre><p>Please note that you need to replace your.package.name with the actual package name in the manifest receiver declaration. Additionally, make sure to replace widget_info with the actual name of your XML file providing widget info.</p><p>Remember to customize the code according to your specific requirements and adjust any missing or incomplete parts that are specific to your implementation.</p><blockquote>If you want to learn more about recomposition and its concepts, <a href="https://medium.com/@pseudoankit/track-compose-recomposition-1-8ce30e8f6847?source=your_stories_page-------------------------------------">you can visit the following link for further information</a>”</blockquote><blockquote>Certainly! If you’re interested in learning about MVI (Model-View-Intent) architecture, Clean Architecture with multi-module setup, and Jetpack Compose best practices, you can explore the GitHub repository at <a href="https://github.com/pseudoankit/Tasky">https://github.com/pseudoankit/Tasky</a>.</blockquote><blockquote>Feel free to explore the repository, review the code, and leverage it as a learning resource to enhance your understanding</blockquote><p>Please add a comment if you would like to share any feedback</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3647b17c9b32" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Track Compose Recomposition Part-2]]></title>
            <link>https://ankitk77.medium.com/track-compose-recomposition-part-2-22856ce2b5cc?source=rss-747f6e5d0c6c------2</link>
            <guid isPermaLink="false">https://medium.com/p/22856ce2b5cc</guid>
            <category><![CDATA[recomposition]]></category>
            <category><![CDATA[android-optimisation]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[compose]]></category>
            <dc:creator><![CDATA[Ankit Kumar]]></dc:creator>
            <pubDate>Wed, 18 Jan 2023 17:09:45 GMT</pubDate>
            <atom:updated>2023-01-18T17:13:27.148Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><a href="https://pseudoankit.medium.com/track-compose-recomposition-1-8ce30e8f6847"><em>Track Recomposition Part-1 : Navigate</em></a><em><br>Track Recomposition Part-2 : You are here<br></em><a href="https://github.com/pseudoankit/Tasky"><em>Check out sample project : Github</em></a></blockquote><h4><strong>Avoid using value classes in composable</strong></h4><p>Value classes are considered unstable even if we annotate with @Stable 👇🏻</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d7qBo9sMm5ZNQ1bBIkvEjA.png" /><figcaption>value class compose</figcaption></figure><blockquote>If you see in above image, TaskyDate is marked stable by compose compiler, but TaskyTime is unstable, the only difference b/w them is <strong>TaskyDate is data class</strong> and <strong>TaskyTime is value class</strong></blockquote><h4><strong>Optimisation in multi modular project</strong></h4><p>Let’s suppose we have a class in a non-compose module containing just a integer value, So ideally it should be stable 👇🏻</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B7dfKq7bjzt2lXic9o95ag.png" /><figcaption>class in non-compose module</figcaption></figure><p>Wondering Why? -</p><ul><li>When analysing any non-compose module, compiler can’t check the stability of a class as compose compiler is not enabled for that module, so it will mark the class unstable</li></ul><p>Think of a fix -</p><ul><li>1st solution — You can enable compose and compose compiler for all modules, so now compose can check for stability of your class</li></ul><pre>buildFeatures.compose = true<br>composeOptions {<br>    kotlinCompilerExtensionVersion = Versions.Compose.Compiler<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*36gqxi98kHFsDsQjkSOrXA.png" /><figcaption>compose report when enabled compose</figcaption></figure><ul><li>2nd solution — mark all the classes as @Stable, basically you guarantee for the stability of the class and compose will mark it stable</li></ul><pre>// non-compose module <br>@Stable<br>data class ModelFromCore(val value: Int)<br><br>To use @Stable annotation add the dependency<br>| androidx.compose.runtime:runtime:1.1.0 |</pre><ul><li>3rd solution — create a wrapper for the classes using from any non-compose module</li></ul><pre>// class from non-compose module<br>data class ModelFromCore(val value: Int)<br><br>// when using in your composable<br>@Stable<br>fun StableModelFromCore(val value: ModelFromCore)</pre><p>Or can create a generic wrapper 👇🏻</p><pre>@Stable<br>class StableHolder&lt;T&gt;(val item: T)<br><br>@Immutable<br>class ImmutableHolder&lt;T&gt;(val item: T)<br><br>usage: <br>fun nonComposeModuleClassUsage(model: StableHolder&lt;ModelFromCore&gt;) {<br>    val value = model.item<br>}<br></pre><blockquote><a href="https://pseudoankit.medium.com/track-compose-recomposition-1-8ce30e8f6847"><em>Track Recomposition Part-1 : Navigate</em></a><em><br></em><a href="https://github.com/pseudoankit/Tasky"><em>Check out sample project : Github</em></a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=22856ce2b5cc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Track Compose Recomposition Part-1]]></title>
            <link>https://ankitk77.medium.com/track-compose-recomposition-1-8ce30e8f6847?source=rss-747f6e5d0c6c------2</link>
            <guid isPermaLink="false">https://medium.com/p/8ce30e8f6847</guid>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[android-optimisation]]></category>
            <category><![CDATA[recomposition]]></category>
            <dc:creator><![CDATA[Ankit Kumar]]></dc:creator>
            <pubDate>Sat, 24 Dec 2022 17:26:43 GMT</pubDate>
            <atom:updated>2023-01-18T17:16:10.483Z</atom:updated>
            <content:encoded><![CDATA[<p>In this post will be looking into how to optimise compose code to avoid recomposition</p><blockquote>Track Recomposition Part-1 : You are here<br><a href="https://pseudoankit.medium.com/track-compose-recomposition-part-2-22856ce2b5cc">Track Recomposition Part-2 : Navigate</a><br><a href="https://github.com/pseudoankit/Tasky">Check out sample project : Github</a></blockquote><blockquote>Composition is the process of calling your composable functions again when the function’s inputs change. When Compose recomposes based on new inputs, it only calls the functions or lambdas that might have changed, and skips the rest.</blockquote><p>Before looking to tips let also look into two major concepts</p><blockquote><strong>Skippable </strong>— when called during recomposition, compose is able to skip the function if all of the parameters are equal with their previous values.</blockquote><blockquote><strong>Restartable </strong>— this function serves as a “scope” where recomposition can start (i.e., function can start re-executing code for recomposition after state changes)</blockquote><p>But we cannot get benefit of above functionality if we do not follow below rules</p><h4>Stability</h4><p>Stability is defined by parameters of the compose method passed<br>By default any <strong>immutable</strong> <strong>primitive</strong><em> types</em> or any <em>class with all immutable primitives fields</em> are considered stable</p><pre>// stable since params are primitive<br>@Composable fun Demo(p1: Int, p2: Boolean)  <br><br>/* stable since all fields are primitive and immutable `val` */<br>data class Payload(val p1: Int, val p2: Int) <br>// stable as p1 and p2 are stable<br>@Composable fun Demo(p1: Paylaod, p2: Boolean) <br><br>/*------------------ Unstable ones -----------------*/<br>// unstable 🫥 p1 is primitive but it&#39;s mutable `var`<br>data class Payload(var p1: Int) <br>// unstable as payload is unstable<br>@Composable fun Demo(p1: Paylaod, p2: Boolean) <br><br>// unstable 🫥 [reasons below]<br>@Composable fun Demo(p1: Int, p2: List&lt;Int&gt;) </pre><p>Let’s discuss the unstable ones one by one 🔝</p><pre>data class Payload(var p1: Int) <br>@Composable fun Demo(p1: Paylaod, p2: Boolean)<br><br>val payload = Payload(2)<br>payload.p1 = 5  // can change the value<br><br>// mutable<br>data class Payload(val p1: Int) <br>val payload = Payload(2)<br>payload.copy(6) // refrence changes</pre><blockquote><strong>Why var unstable?</strong><br>Let’s take the above scenario, we have provide payload to a compose and it’s fine and now for any reason recomposition happens, then how will compiler validate if `p1` has been changed or not from last time? as it’s mutable so to avoid any bugs it recomposes the block</blockquote><blockquote><strong>Why val stable?</strong><br>So for the above scenario only if p1 was mutable(val) then to change the value of p1 we will be creating a copy of the object with updated value, so now compiler can easily verify by checking if this object is different from previous one it will recompose else skip</blockquote><pre>@Composable fun Demo(p1: Int, p2: List&lt;Int&gt;)<br><br>val mutableList = mutableListOf(1)<br>Demo(2, mutableList)<br>mutableList.add(3) // sometime later</pre><blockquote><strong>Why List unstable?<br></strong>So take the above scenario, so if you see we can pass a mutable list as list, so again the same question what if you have modified the list how will compiler know in next recomposition if list has been modified or not</blockquote><blockquote>Wondering then how we will deal with list, Below are the two solution’s</blockquote><p><strong>Solution 1 , Wrap the list in a class and annotate with @Immutable</strong></p><pre>// unstable as list is unstable<br>data class ImmutableList&lt;T&gt;(val value: List&lt;T&gt;) <br><br>/* annotate with @Immutable i.e, we are explicitly telling compiler to <br> * mark the class stable and we will ensure that we will update the value<br> * only by creating a new instance of the class */<br>@Immutable<br>data class ImmutableList&lt;T&gt;(val value: List&lt;T&gt;) <br><br>eg :- <br>var state by mutableStateOf(ImmutableList(listOf(1)))<br>fun addItem(item: Int) {<br>    val updatedList = state.value.toMutableList().apply { add(item) }<br>    state = state.copy(updatedList)<br>}<br><br>// We could have also done it like below, but we should not as we have <br>// ensured to change list only by creating a new reference<br>fun addItem(item: Int) {<br>  state.value.toMutableList().add(item)<br>}</pre><p><strong>Solution 2, Using Kotlin Immutable Collection</strong></p><pre>implementation(&quot;org.jetbrains.kotlinx:kotlinx-collections-immutable:0.3.5&quot;)<br>@Composable fun Demo(val items: ImmutableList&lt;Int&gt;) {}  // stable<br><br>// Compose Compiler treats immutable collection as stable</pre><blockquote><a href="https://pseudoankit.medium.com/track-compose-recomposition-part-2-22856ce2b5cc">Track Recomposition Part-2 : Navigate</a><br><a href="https://github.com/pseudoankit/Tasky">Check out sample project : Github</a><br><a href="https://chris.banes.me/posts/composable-metrics/#enabling-the-metrics">Article to enable compose compiler report</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8ce30e8f6847" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Visitable Pattern in Recycler View]]></title>
            <link>https://ankitk77.medium.com/visitable-patter-in-recycler-view-bec12e1d26a8?source=rss-747f6e5d0c6c------2</link>
            <guid isPermaLink="false">https://medium.com/p/bec12e1d26a8</guid>
            <category><![CDATA[adapter-recyclerview]]></category>
            <category><![CDATA[multipleviewtype]]></category>
            <category><![CDATA[adapter-pattern]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Ankit Kumar]]></dc:creator>
            <pubDate>Sun, 24 Jul 2022 02:12:18 GMT</pubDate>
            <atom:updated>2022-09-18T13:52:20.266Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Inflating multiple views in recycler view</blockquote><p>Since in normal approach we have all our logics in the adapter only which makes it quite difficult to add or manipulate viewHolders later on</p><p>So we will be looking on visitable pattern to achieve the same to make our adapter quite generic and make it extensible and easy to manipulate</p><blockquote>Every model which needs to added in our adapter will be inheriting from BaseItemModel</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ddabc77b602113c07b8f74ca5d528496/href">https://medium.com/media/ddabc77b602113c07b8f74ca5d528496/href</a></iframe><blockquote>ItemTypeFactory responsible for returning the layout for specific model class</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/98ebf1373566f01c0a26c8adf3e8b100/href">https://medium.com/media/98ebf1373566f01c0a26c8adf3e8b100/href</a></iframe><blockquote>For each model class we need a view holder so will be inheriting from AbstractViewHolder</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1d881e811ec23cc5711ad01bb09b8f82/href">https://medium.com/media/1d881e811ec23cc5711ad01bb09b8f82/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/314124237a8c486c8ee968ab5df06c5a/href">https://medium.com/media/314124237a8c486c8ee968ab5df06c5a/href</a></iframe><pre>private val adapter = ContactAdapter(ItemTypeFactoryImp(),listOf())</pre><p>So as you know how to create adapter, so whenever we want to add a new type of item in recycler view we will</p><ul><li>Inherit our model class with BaseItemModel</li><li>Inherit our ViewHolder from AbstractViewHolder</li><li>Add the new type in our ItemTypeFactory</li></ul><p>Can refer to this <a href="https://github.com/pseudoankit/vistablePatternRecyclerView">github project</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bec12e1d26a8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android Jetpack Navigation in multi modular apps]]></title>
            <link>https://ankitk77.medium.com/android-jetpack-navigation-in-multi-modular-apps-50b240a00dff?source=rss-747f6e5d0c6c------2</link>
            <guid isPermaLink="false">https://medium.com/p/50b240a00dff</guid>
            <category><![CDATA[multi-module-project]]></category>
            <category><![CDATA[fragments]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[jetpack-navigation]]></category>
            <dc:creator><![CDATA[Ankit Kumar]]></dc:creator>
            <pubDate>Mon, 23 May 2022 16:42:24 GMT</pubDate>
            <atom:updated>2022-08-29T18:10:20.910Z</atom:updated>
            <content:encoded><![CDATA[<p>I will be demonstrating about the following topic in Jetpack Navigation</p><ul><li>Using navigation in <em>multi-modular</em> apps</li><li>Using<strong> <em>nested fragments</em> </strong>in jetpack navigation<br>helpful when creating bottom navigation view, or having common action bar in some section of app or many more</li><li><a href="https://github.com/pseudoankit/MoodTracker">Source code</a> for the demonstrated project ,<br>This is a <strong><em>multi-modular</em></strong> <strong><em>single activity</em></strong> project that uses <strong><em>dagger2</em></strong><em>, clean architecture, room db, Jetpack Navigation</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/190/1*FBVllFiuP2SAHDBadapdvQ.gif" /><figcaption>Demo</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KKda8znWhXCukFnJ3bLTfg.png" /><figcaption>Nested graph Preview</figcaption></figure><blockquote>nav_graph_app_module is the app module’s graph<br>We will reference this graph in our activity_main.xml , fragment container<br>We include nav_graph_home_host here as it is another module and to navigate to that module we simply navigate to <em>nav_graph_home_host</em> graph</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/36a7845904c410a9baf24aa0d01d9c2e/href">https://medium.com/media/36a7845904c410a9baf24aa0d01d9c2e/href</a></iframe><pre>Navigate from splash to home</pre><pre>findNavController().navigate(R.id.<em>nav_graph_home_host</em>)</pre><blockquote>From splash we will navigate to <em>nav_graph_home_host</em> graph, <br>this graph contains a fragment <em>HomeHostFragment</em> <br><em>HomeHostFragment</em> contains an bottom nav view and a fragment container <br>as we are dealing with nested fragment so to avoid stack overflow issue <br>and also to keep things simple <br>we will create another graph <em>nav_graph_home</em> containing all other fragments we need in this module</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/95150439bae695788493a65ea9c26220/href">https://medium.com/media/95150439bae695788493a65ea9c26220/href</a></iframe><blockquote><em>nav_graph_home</em> includes multiple graph from different modules <br>Each graph is associated with menu click of bottom nav view<br>To achieve navigation we will keep bottom navigation id same as graph’s id<br> check the Github source code for complete insight</blockquote><p>Code to set up bottom navigation with navigation graph</p><pre><em>bottonNavView.setupWithNavController</em>(navController)</pre><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/62b3c66edc5f046b1353f34fe389f3ee/href">https://medium.com/media/62b3c66edc5f046b1353f34fe389f3ee/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ef2acb6aa099538e99dd08da05c2330b/href">https://medium.com/media/ef2acb6aa099538e99dd08da05c2330b/href</a></iframe><blockquote>Now stack is like :: <br> splash → home <br>(home will not maintain any stack as navHost is set to default i.e., false)</blockquote><blockquote>Now if we want to navigate from home to other fragment <br>but wanted to host from our root nav controller, then can use the below function</blockquote><pre>/*<br>  `R.id.<em>fragment_container_root` is id of our root fragment <br>   which we inflated in Main Activity<br>*/</em></pre><pre>val Fragment.<em>findRootNavHost</em>: NavController?<br>get() = this.<em>activity</em>?.<em>let </em><strong>{ <br>    </strong>Navigation.findNavController(<strong>it</strong>, R.id.<em>fragment_container_root</em>) <br><strong>}</strong></pre><blockquote>In fragment from where we want to navigate</blockquote><pre><em>findRootNavHost</em>?.navigate(`your_destination_fragment`)</pre><blockquote><em>I’d like to end this post by saying thank you 🙏 for reading<br></em>If have any query we can connect, links in my profile or you can comment it down</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=50b240a00dff" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Jetpack compose and xml combined]]></title>
            <link>https://ankitk77.medium.com/using-jetpack-compose-and-xml-combined-b314e58df589?source=rss-747f6e5d0c6c------2</link>
            <guid isPermaLink="false">https://medium.com/p/b314e58df589</guid>
            <category><![CDATA[compose-ui]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <dc:creator><![CDATA[Ankit Kumar]]></dc:creator>
            <pubDate>Thu, 05 May 2022 11:52:53 GMT</pubDate>
            <atom:updated>2022-08-29T18:09:15.577Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Hi folks, this article is all about how to use jetpack compose and xml together , so that compose can be used in old xml projects <br>Also there are few things which is not being supported in Jetpack compose so far eg: Maps , and to use that in compose we need to use xml views<br>Credits : <a href="https://www.youtube.com/watch?v=Pur_0KroFR8&amp;list=PLQkwcJG4YTCSpJ2NLhDTHhi6XBNfk9WiC&amp;index=24&amp;ab_channel=PhilippLackner">Youtube</a><br>So let’s get started</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rErUblqVMZZoKCsLFxrm1w.jpeg" /></figure><blockquote>Modify your existing build.gradle to use compose in it</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f003ebc54d56a67ad60cf273d3f3f0a4/href">https://medium.com/media/f003ebc54d56a67ad60cf273d3f3f0a4/href</a></iframe><blockquote>Below is layout file of activity / fragment, we have a simple TextView used in xml and a composeView which gives a compose view where we will inflate layout with compose</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a2e93b90abf88ed16b7011ee980e003f/href">https://medium.com/media/a2e93b90abf88ed16b7011ee980e003f/href</a></iframe><blockquote>In your activity / fragment class</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/24f875a0d7d2ea03f5b84b307cc39075/href">https://medium.com/media/24f875a0d7d2ea03f5b84b307cc39075/href</a></iframe><p>Thanks for reading the post 👏</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b314e58df589" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using resources values in viewmodel safely]]></title>
            <link>https://ankitk77.medium.com/using-resources-values-in-viewmodel-safely-e2d710c868b1?source=rss-747f6e5d0c6c------2</link>
            <guid isPermaLink="false">https://medium.com/p/e2d710c868b1</guid>
            <category><![CDATA[viewmodel]]></category>
            <category><![CDATA[string]]></category>
            <category><![CDATA[resources]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Ankit Kumar]]></dc:creator>
            <pubDate>Wed, 13 Apr 2022 18:48:48 GMT</pubDate>
            <atom:updated>2022-08-29T18:08:16.364Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Hey folks, this article is all about using string resource through viewmodel without exposing context or resources to viewmodel</blockquote><blockquote>Credits : Philip Lackner <a href="https://www.youtube.com/watch?v=mB1Lej0aDus&amp;t=334s&amp;ab_channel=PhilippLackner">Youtube</a><br><a href="https://github.com/pseudoankit">My Github</a> , <a href="https://www.linkedin.com/in/lazycoder21/">LinkedIn</a></blockquote><blockquote>While writing code in clean architecture pattern we often face issue about how to use any resource id in viewmodel as it requires context or resources to do so<br>So , below is an wrapper class to make your life easy</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/80fbc2753502e6b954602433f95e7bb0/href">https://medium.com/media/80fbc2753502e6b954602433f95e7bb0/href</a></iframe><blockquote>Now in your ViewModel</blockquote><pre>private val _errorMessageLiveData: MutableLiveData&lt;StringHandler&gt; = MutableLiveData()<br>val errorMessageLiveData: LiveData&lt;StringHandler&gt; = _errorMessageLiveData<br><br>fun fooSomeValidation(x: Int) {<br>    val threshold = 8<br>    _errorMessageLiveData.<em>value </em>= if (x &lt; threshold) {<br>        StringHandler.ResourceString(R.string.<em>number_validation_error</em>, threshold)<br>    } else {<br>        StringHandler.NormalString(&quot;message from api response&quot;)<br>    }<br>}</pre><blockquote>string.xml</blockquote><pre>&lt;string name=&quot;number_validation_error&quot;&gt;<br>    Number should be more than %d<br>&lt;/string&gt;</pre><blockquote>To use it in UI layer</blockquote><pre>private fun observeLiveData() {<br>    viewModel.errorMessageLiveData.observe(viewLifeCycleOwner) <strong>{<br>        </strong>val error = <strong>it</strong>.getString(<em>context</em>)<br>    <strong>}<br>}</strong></pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e2d710c868b1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Publish an android library opensource with Jitpack]]></title>
            <link>https://ankitk77.medium.com/publish-an-android-library-opensource-with-jitpack-91edf3228727?source=rss-747f6e5d0c6c------2</link>
            <guid isPermaLink="false">https://medium.com/p/91edf3228727</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[publishing]]></category>
            <category><![CDATA[libraries]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[jitpack]]></category>
            <dc:creator><![CDATA[Ankit Kumar]]></dc:creator>
            <pubDate>Wed, 13 Apr 2022 18:11:04 GMT</pubDate>
            <atom:updated>2022-08-29T18:55:13.582Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>So assuming that you have already created a library and source code is pushed to github<br>You can refer to this <a href="https://github.com/pseudoankit/MultipleContactPicker">github link</a> for reference as it is already published</blockquote><blockquote>Add a file in your root project named <em>jitpack.yml <br>Below is jitpack.yml code</em></blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e5c91d91d498d14f3b0a668fcbdc65bd/href">https://medium.com/media/e5c91d91d498d14f3b0a668fcbdc65bd/href</a></iframe><figure><img alt="Project structure will look like this" src="https://cdn-images-1.medium.com/max/1024/1*w99S9zq6Yoljq6ZIkkcayw.png" /><figcaption>Project Structure after adding jitpack.yml</figcaption></figure><blockquote>Now go to build.gradle, one which you will be publishing or your library one</blockquote><pre>plugins <strong>{</strong><br>    id &#39;maven-publish&#39; //add this plugin<br><strong>}</strong></pre><pre>// add this block in build.gradle<br>afterEvaluate <strong>{<br>    </strong>publishing <strong>{<br>        </strong>publications <strong>{<br>            </strong>release(MavenPublication) <strong>{<br>                </strong>from components.release<br>                groupId = github.lostankit7&#39; //your group id<br>                artifactId = &#39;my-custom-view&#39; //put your atifact id<br>                version = &#39;1.1&#39;               //release version <br>            <strong>}<br>        }<br>    }<br>}</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TptoVn1zocb4W8rSX80Blw.png" /><figcaption>Library build.gradle</figcaption></figure><blockquote>So , now android side is done, push your code with these changes to github<br>and now the release process</blockquote><ul><li>Go to your github repository</li><li>Click on create new release</li><li>Choose a tag eg: v1.1.0</li><li>Your target branch which you want to release</li><li>Other fields are optional</li><li>Now click publish a release</li></ul><blockquote>Go to <a href="https://jitpack.io/">jitpack.io</a> , past your github repo url and check the status <br>If the status is green , 😺 yeah you are good to go</blockquote><blockquote>For others to use your library you will get guide after you press lookup in jitpack.io , all reference images below<br>note:- tag in jitpack.io refers to version of release</blockquote><pre>//In your settings.gradle<br><strong>allprojects {<br>	repositories {<br>		maven { url &#39;https://jitpack.io&#39; }<br>	}<br>}</strong></pre><pre>//add the dependency in build.gradle where you want to use the //library  ,which you get on click of lookup</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oV3HtvMEgJnnXqlsEBxOWQ.png" /><figcaption>Jitpack.io lookup</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/953/1*5dolgGQTJkEGosumEn2Etg.png" /><figcaption>Settings.gradle where you want to use the library</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=91edf3228727" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>