<?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 Amal Soltani on Medium]]></title>
        <description><![CDATA[Stories by Amal Soltani on Medium]]></description>
        <link>https://medium.com/@amal.soltani_30660?source=rss-d53725ee3a06------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*9HLN38iHbKY8sUrk5yM0Tw.png</url>
            <title>Stories by Amal Soltani on Medium</title>
            <link>https://medium.com/@amal.soltani_30660?source=rss-d53725ee3a06------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 11:03:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@amal.soltani_30660/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[⚔️ Lottie or Native? The Animation Face-off]]></title>
            <link>https://engineering.backmarket.com/%EF%B8%8F-lottie-or-native-the-animation-face-off-6cc5ce94739f?source=rss-d53725ee3a06------2</link>
            <guid isPermaLink="false">https://medium.com/p/6cc5ce94739f</guid>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[mobile]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[lottie]]></category>
            <category><![CDATA[compose-animation]]></category>
            <dc:creator><![CDATA[Amal Soltani]]></dc:creator>
            <pubDate>Tue, 21 Oct 2025 10:07:51 GMT</pubDate>
            <atom:updated>2025-10-21T10:07:51.862Z</atom:updated>
            <content:encoded><![CDATA[<h4>Because not every animation deserves a Lottie file. A practical guide to choose between Compose and Lottie for Android animations.</h4><p>As Android developers, we’ve all been there: you want to make your app feel more alive, add some smooth transitions, or delight your users with a bit of motion.<br>But then comes the question: <strong>should you build the animation natively in Compose, or import it with Lottie?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*fJNXAHiIcGDD5hrxjoX83g.gif" /><figcaption><em>Image generated with AI</em></figcaption></figure><h3>Why Animations Matter</h3><p>Animations aren’t just decoration, they communicate state changes, guide attention, and create a sense of polish. But choosing the <em>wrong</em> animation implementation can lead to performance issues, maintenance headaches or unnecessary complexity.</p><p>In Android today, there are two main paths:</p><ul><li><strong>Native animations</strong> using Jetpack Compose, MotionLayout, View animations, or other Android framework APIs</li><li><strong>Lottie animations</strong>, exported from After Effects as JSON.</li></ul><p>Let’s break down how to decide which one to use.</p><h3>Animation Approaches Explained</h3><h4>1. Native Compose Animations</h4><p>Jetpack Compose provides a modern, declarative way to animate UI elements using state and transitions.</p><p><strong>🔑 Core APIs</strong></p><ul><li>animate*AsState() — animate a single property like color, size, or alpha</li><li>AnimatedVisibility() — handle appear/disappear animations</li><li>updateTransition() — coordinate multiple animations from one state</li><li>rememberInfiniteTransition() — for looping loaders or background motion</li><li>Animatable — manual control for advanced use cases</li></ul><p><strong>🚀 Pros</strong></p><ul><li>Seamless integration with UI state</li><li>Lightweight and GPU-optimized</li><li>Fully dynamic and reactive</li><li>Perfect for micro-interactions</li><li>No external dependencies</li></ul><p><strong>⚠️ Cons</strong></p><ul><li>More work for complex designer animations</li><li>Limited visual effects compared to After Effects</li><li>Requires close collaboration with designers</li></ul><blockquote><em>📝 </em><strong><em>Note: </em></strong><em>Native animations offer excellent backward compatibility across Android versions.</em></blockquote><h4>2. Lottie Animations</h4><p><a href="https://airbnb.io/lottie/#/"><strong>Lottie</strong></a> / <a href="https://lottiefiles.com/runtimes"><strong>dotLottie</strong></a> exports designer animations as files (.json or .lottie) and plays them through a runtime library. It’s an elegant solution that bridges design and development until you need dynamic behavior, real-time interaction, or platform-specific performance tuning.</p><p><strong>🚀 Pros</strong></p><ul><li>Ideal for rich visual storytelling</li><li>Designers can create iterations without developers&#39; intervention</li><li>Cross-platform consistency (Android, iOS)</li></ul><p><strong>⚠️ Cons</strong></p><ul><li>Larger asset size</li><li>Limited real-time customization</li><li>Some effects are not supported</li><li>Performance overhead on low-end devices</li><li>Some After Effects features are not supported</li></ul><p><strong>What about dotLottie?</strong></p><p>dotLottie introduced the .lottie format, a compressed file format containing animations, assets, and metadata in a single file.</p><p>It’s a welcomed improvement for organization and performance, but doesn’t address the main limitations. Interactive animations and state-driven behavior still face the same constraints as traditional Lottie. Enhanced packaging is great, but when you need tight UI-state coupling, Compose remains the better path.</p><h3>Real-World Example: When Lottie Became a Problem</h3><p>In one of our projects, designers proposed a <strong>Lottie animation</strong> for the “<strong>Favorite</strong>” button, a heart that beats when users add or remove favorites.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/342/1*YqFMiTom2dd5mFI9bLXTnA.gif" /><figcaption>Favorite Button Animation with Lottie</figcaption></figure><h4>🎭 The Integration Issues</h4><p>We displayed the Lottie file <strong>on top of the original button</strong>, which caused:</p><ul><li>The <strong>ripple effect</strong> from the underlying button to disappear.</li><li>Difficulty handling <strong>loading</strong> and <strong>error</strong> states , we couldn’t tell if the animation was done, if the API was still pending, or if it failed.</li><li>The <strong>actual button state</strong> (active/inactive) became hidden behind the animation.</li></ul><p>We had to manage several tricky cases:</p><ol><li>Animation finished, but API response not yet received.</li><li>Animation still running, but API returned success or failure.</li><li>Animation finished, but API returned failure.</li></ol><p>In Compose, this would have been much simpler: the animation could react directly to the UI state, without being decoupled from the logic.</p><h4>🧠 The Compose Way: Simpler, Reactive, Native</h4><p>We decided to challenge the classic approach and build a <strong>reactive, fully state-driven favorite button in Compose</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/342/1*fKp7KABTQ6J9MKOQpRkX-Q.gif" /><figcaption>Favorite Button Animation with Compose</figcaption></figure><p>Here’s how it works:</p><p><strong>1. State-driven logic with loading</strong></p><p>Animations are triggered based on both the <strong>favorite state</strong> and the <strong>loading state</strong>. We use flags to ensure that each loading action triggers the animation only once.</p><pre>var localIconState by remember { mutableIntStateOf(state.revolveButtonIconState.icon) }<br>var isAnimating by remember { mutableStateOf(false) }<br>var hasAnimatedForCurrentLoading by remember { mutableStateOf(false) }<br><br>LaunchedEffect(state.revolveButtonIconState.loading, state.revolveButtonIconState.icon) {<br>    val isLoading = state.revolveButtonIconState.loading<br><br>    if (!isLoading) {<br>        hasAnimatedForCurrentLoading = false<br>        localIconState = state.revolveButtonIconState.icon<br>    }<br><br>    if (isLoading &amp;&amp; !hasAnimatedForCurrentLoading) {<br>        isAnimating = true<br>        scope.launch {<br>            if (state.isFavorite) {<br>                launchUnfavoriteAnimation(heartScale)<br>            } else {<br>                launchFavoriteAnimation(heartScale, particleProgress, scope)<br>            }<br>            localIconState = state.endOfAnimationIcon<br>            isAnimating = false<br>            hasAnimatedForCurrentLoading = true<br>        }<br>    }<br>}</pre><p><strong>2. Particles for visual flair</strong></p><p>Particles are generated once and animated outward when the item is favorited: particleProgress controls both <strong>distance and fade-out</strong>, computed entirely in Compose’s Canvas:</p><pre>Canvas(modifier = Modifier.fillMaxSize()) {<br>    val center = size.center<br>    particles.forEach { p -&gt;<br>        val pos = Offset(<br>            center.x + cos(p.angle) * p.distance.toPx() * particleProgress.value,<br>            center.y + sin(p.angle) * p.distance.toPx() * particleProgress.value<br>        )<br>        drawCircle(color = color, radius = p.radius.toPx(), center = pos, alpha = 1f - particleProgress.value)<br>    }<br>}</pre><p><strong>3. Smooth scaling transitions</strong></p><p>The heart icon scales up or down depending on favorite/unfavorite actions:</p><pre>heartScale.snapTo(1f)<br>heartScale.animateTo(0.6f, animationSpec = tween(120))<br>heartScale.animateTo(0.7f, animationSpec = tween(80))<br>heartScale.animateTo(1f, animationSpec = tween(200))</pre><p>This creates a <strong>natural, satisfying pop effect</strong> that stays in sync with API responses.</p><h3>The Hidden Complexity of Lottie</h3><p>At first, Lottie feels like magic: <em>“Just drop the JSON and call </em><em>LottieAnimation().”</em><br>But when you move beyond simple vector motions, reality quickly catches up.</p><p>In one of our projects, the design team created a <strong>3D-style Lottie animation</strong> with depth effects, lighting, and multiple overlapping layers.<br>It looked beautiful in After Effects, smooth, dynamic, full of life.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*58l9TV0h-Ir4XYknxzJuuA.gif" /><figcaption>The 3D-style animation</figcaption></figure><p>But when we tried to integrate it, we hit a wall.</p><p>We couldn’t import the animation at all, neither on Android nor on iOS.<br>It turned out that several effects used in the composition (3D layers, shadows, and certain blend modes) simply weren’t supported by Lottie’s renderer.</p><p>What started as a “quick import” became a week of iteration and debugging.</p><p>That experience taught us a clear lesson:</p><p>💡 <strong>Lottie is great for cinematic, decorative, or brand-driven animations, but not for complex or interactive ones.</strong></p><p>💡 <strong>Whenever the animation depends on user input, dynamic state, or cross-platform precision, it’s better to go native.</strong></p><h3>Decision Framework: When to Choose What</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_TcJHY-JgUYxidLDVRT5zA.png" /><figcaption>Native vs Lottie comparison</figcaption></figure><h4>🚀 Choose Native Compose when:</h4><ul><li>Animation responds to user interactions</li><li>State changes drive the animation</li><li>Performance is critical</li><li>You need precise control over timing</li><li>Animation integrates with existing UI components</li></ul><h4>🎨 Choose Lottie when:</h4><ul><li>Complex visual storytelling (onboarding, marketing)</li><li>Designer-created animations that are hard to replicate</li><li>Decorative animations on static content</li><li>Brand consistency across platforms is crucial</li><li>Animation doesn’t need real-time interaction</li></ul><h3>Collaborating with Designers</h3><p>Building great motion experiences isn’t just about code, it’s about <strong>communication</strong>.<br>Sync early with designers before deciding between native or Lottie.</p><p><strong>Things to align on:</strong></p><ul><li><strong>Key moments:</strong> What exactly changes, color, shape, opacity, position?</li><li><strong>Timings:</strong> Easing curves, durations, delays.</li><li><strong>Layers:</strong> Which elements are interactive vs decorative?</li><li><strong>Fallbacks:</strong> What happens on failure or a slow network?</li></ul><p>This avoids surprises later (“that wasn’t supposed to loop forever!”) and ensures the animation is realistic to implement and performant on devices.</p><p><strong><em>💬 A quick 10-minute design-dev sync often saves hours of rework.</em></strong></p><h3>🎯 The golden rule: Start native, scale to Lottie when needed.</h3><blockquote><strong>Most animations in your app should be native Compose animations.</strong></blockquote><p>They’re lightweight, performant, and integrate seamlessly with your UI state. Use them for:</p><ul><li>Button interactions and micro-animations</li><li>State-driven transitions</li><li>Performance-critical scenarios</li></ul><p>Reserve Lottie for the 20% of cases where designer complexity justifies the overhead:</p><ul><li>Onboarding flows with rich storytelling</li><li>Marketing content that needs pixel-perfect brand consistency</li><li>Complex visual effects are impossible to recreate natively</li></ul><p>🔑 <strong>The Key Insight: </strong>Communication beats implementation. The right conversation with your designer upfront will save hours of rework and guide you toward the right technical choice.</p><p><strong>💡Remember</strong>: The best animation enhances user experience without sacrificing performance. Both Native and Lottie have their place — the key is knowing when to use each one.</p><p>And like we say at Back Market: <em>“Bon chance” </em>👋</p><p><strong>If you want to join our Bureau of Technology or any other Back Market department, </strong><a href="https://jobs.ashbyhq.com/backmarket?utm_source=vY2aeGpABr"><strong>take a look here, we’re hiring!</strong></a><strong> <em>🦄</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dN8pq4gD02DscqwS.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6cc5ce94739f" width="1" height="1" alt=""><hr><p><a href="https://engineering.backmarket.com/%EF%B8%8F-lottie-or-native-the-animation-face-off-6cc5ce94739f">⚔️ Lottie or Native? The Animation Face-off</a> was originally published in <a href="https://engineering.backmarket.com/">Back Market Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Default to Distinctive: How to Change Your Android App Icon]]></title>
            <link>https://engineering.backmarket.com/from-default-to-distinctive-how-to-change-your-android-app-icon-1698158a51f5?source=rss-d53725ee3a06------2</link>
            <guid isPermaLink="false">https://medium.com/p/1698158a51f5</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[mobile]]></category>
            <category><![CDATA[android-development]]></category>
            <dc:creator><![CDATA[Amal Soltani]]></dc:creator>
            <pubDate>Mon, 02 Dec 2024 07:02:10 GMT</pubDate>
            <atom:updated>2024-12-02T07:02:10.668Z</atom:updated>
            <content:encoded><![CDATA[<h4>Learn how to make this iOS feature work smoothly on Android</h4><p>At <a href="https://www.backmarket.com/en-us">Back Market</a>, we attach a lot of importance to the user experience. Since we’re looking for ergonomics between the home page and the application icon, we’ve decided to set up a new feature we entitled App Icon Customization x Home Page.</p><p>This article dives into our journey, exploring the technical approach, the challenges we encountered, and the solutions we developed to deliver a seamless and satisfying user experience.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/701/1*QOayIl1s99wCfq8CBHRl0A.png" /><figcaption>Available app icons in Back Market app</figcaption></figure><h3>Implementation Steps</h3><h4><strong>1- Preparing the manifest</strong></h4><p>After adding different icons to your resources directory, you need to add several activity-alias to your app’s AndroidManifest.xml. Each alias corresponds to a unique app icon, allowing users to choose their preferred one.</p><pre>&lt;application&gt;<br><br>    &lt;!-- Dynamically sets the value of &quot;android:enabled&quot; based on the ${launcher.isEnabled} placeholder --&gt;<br>    &lt;activity-alias<br>        android:name=&quot;com.backmarket.Launcher&quot;<br>        android:enabled=&quot;true&quot;<br>        android:exported=&quot;true&quot;<br>        android:targetActivity=&quot;.LauncherActivity&quot;&gt;<br>        &lt;intent-filter&gt;<br>            &lt;action android:name=&quot;android.intent.action.MAIN&quot; /&gt;<br>            &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot; /&gt;<br>        &lt;/intent-filter&gt;<br><br>        &lt;!-- Android Deep Links --&gt;<br>        &lt;intent-filter&gt;<br>            &lt;data android:scheme=&quot;${deeplink.uriScheme}&quot; /&gt;<br>            &lt;action android:name=&quot;android.intent.action.VIEW&quot; /&gt;<br>            &lt;category android:name=&quot;android.intent.category.DEFAULT&quot; /&gt;<br>            &lt;category android:name=&quot;android.intent.category.BROWSABLE&quot; /&gt;<br>         &lt;/intent-filter&gt;<br>    &lt;/activity-alias&gt;<br>            <br>    &lt;activity-alias<br>        android:name=&quot;com.backmarket.Launcher1&quot;<br>        android:enabled=&quot;true&quot;<br>        android:exported=&quot;true&quot;<br>        android:icon=&quot;@mipmap/ic_launcher_1&quot;<br>        android:targetActivity=&quot;.LauncherActivity&quot;&gt;<br>        &lt;intent-filter&gt;<br>            &lt;action android:name=&quot;android.intent.action.MAIN&quot; /&gt;<br>            &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot; /&gt;<br>        &lt;/intent-filter&gt;<br>     &lt;/activity-alias&gt;<br>&lt;/application&gt;</pre><p>As you can see, both activity-aliases were initially enabled. If you launch the app you’ll have this result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/270/1*0qqn3IsPEGKV-43SXPg5eg.png" /><figcaption>The two application’s aliases are displayed on the launching menu</figcaption></figure><p>So we need to set the main one to true and the secondary one to <strong>false:</strong></p><pre>&lt;activity-alias<br>   android:name=&quot;com.backmarket.Launcher1&quot;<br>   android:enabled=&quot;false&quot;/&gt;</pre><h4>2- Storing preferences</h4><p>We used SharedPrefences to store the currently active icon and the user’s selected icon. This allowed us to validate whether an update was necessary or if the icon already matched the user’s preference.</p><h4><strong>3- Changing the app icon</strong></h4><p>To switch app icons dynamically, we toggled the states of activity-alias entries. The current alias was disabled, and the newly chosen alias was enabled, so on the launching menu, the current activity-alias<strong> </strong>will be hidden, and the new one will be shown to the user.</p><pre>// Disable old icon<br>context.packageManager.setComponentEnabledSetting(<br>   ComponentName(context, &quot;$packageName.$currentLauncher&quot;),<br>   PackageManager.COMPONENT_ENABLED_STATE_DISABLED,<br>   PackageManager.DONT_KILL_APP,<br>)<br><br>// Enable new icon<br>context.packageManager.setComponentEnabledSetting(<br>   ComponentName(context, &quot;$packageName.$selectedLauncher&quot;),<br>   PackageManager.COMPONENT_ENABLED_STATE_ENABLED,<br>   PackageManager.DONT_KILL_APP,<br>)</pre><p>You can now build your App, and you’ll have the same result as the picture below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*zZLgjkrS27ytMN8f-nTtZA.gif" /><figcaption>App icon successfully changed</figcaption></figure><p><strong><em>Congratulations, your App Icon is updated successfully.</em></strong></p><p>But unfortunately, we are now facing some issues :</p><ul><li><strong>The app closes after changing the icon</strong></li><li><strong>The app is no longer launching from Android Studio</strong></li><li><strong>The Deeplinks are not working with multi activity-alias.</strong></li></ul><h3>Challenges and solutions</h3><h4>1- App closure during icon update</h4><p>Each time the icon changed, the app would close due to the lifecycle changes triggered by activity-alias. To solve this, we used a foreground service that launched when the icon was updated, and then the service was stopped when the app’s lifecycle transitioned to the stop state, ensuring a smooth user experience without disruptions.</p><pre>class IconUpdateService : Service() {<br>   override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int = START_STICKY<br>   override fun onBind(intent: Intent?): IBinder? = null<br>   override fun onDestroy() {<br>       // Here you can put the code that disable old icon and enable the new one<br>       super.onDestroy()<br>   }<br>}</pre><h4>2- Application isn’t launching from Android Studio</h4><p>You’re trying to relaunch the app from Android Studio but unfortunately, this error message appears, and the app is not launching anymore:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CNYwz8zmvba6qUAu4XwekQ.png" /><figcaption>Launching app from Android Studio Failing</figcaption></figure><p>The main reason is that you have set up the main activity-alias to true in the Manifest. Then, we disabled it and enabled a different one programmatically. So, the intent’s component has an enabled property set to false.</p><p>If you’re facing this issue, this solution is for you. To avoid this kind of error message, you need to make some adjustments to your manifest.</p><pre>&lt;application&gt;<br><br>    &lt;activity-alias<br>        android:name=&quot;com.backmarket.Launcher&quot;<br>        android:enabled=&quot;${launcher.isEnabled}&quot;<br>        android:exported=&quot;true&quot;<br>        android:targetActivity=&quot;.LauncherActivity&quot;&gt;<br>        &lt;intent-filter&gt;<br>            &lt;action android:name=&quot;android.intent.action.MAIN&quot; /&gt;<br>            &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot; /&gt;<br>         &lt;/intent-filter&gt;<br>     &lt;/activity-alias&gt;<br><br>     &lt;activity-alias<br>         android:name=&quot;com.backmarket.Launcher1&quot;<br>         android:enabled=&quot;false&quot;<br>         android:exported=&quot;true&quot;<br>         android:icon=&quot;@mipmap/ic_launcher_1&quot;<br>         android:targetActivity=&quot;.LauncherActivity&quot;&gt;<br>         &lt;intent-filter&gt;<br>             &lt;action android:name=&quot;android.intent.action.MAIN&quot; /&gt;<br>             &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot; /&gt;<br>         &lt;/intent-filter&gt;<br>     &lt;/activity-alias&gt;<br>&lt;/application&gt;</pre><p>The main activity-alias must use a build-time variable launcher.isEnabled to control whether this alias is active depending on BuildType in the Gradle:</p><pre>buildTypes {<br>    release {<br>        manifestPlaceholders[&quot;launcher.isEnabled&quot;] = true<br>    }<br>    debug {<br>        manifestPlaceholders[&quot;launcher.isEnabled&quot;] = false<br>    }<br>}</pre><p>After that, in your Application class at the onCreate function, you need to retrieve the new app icon stored in SharedPreference and then set it as the component of the launcher’s intent:</p><pre>class BMApplication : BaseApplication() {<br><br>    override fun onCreate() {<br>        super.onCreate()<br>        if (BuildConfig.DEBUG) {<br>            val componentName = ComponentName(this, &quot;$packageName.$currentLauncher&quot;)<br>            packageManager.setComponentEnabledSetting(<br>                componentName,<br>                PackageManager.COMPONENT_ENABLED_STATE_ENABLED,<br>                PackageManager.DONT_KILL_APP,<br>            )<br>            val selector = Intent(Intent.ACTION_MAIN)<br>            selector.addCategory(Intent.CATEGORY_LAUNCHER)<br>            selector.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)<br>            selector.setComponent(componentName)<br>            startActivity(selector)<br>        }<br>    }<br>}</pre><h4>3- Deeplinks break after icon change</h4><p>If you’re setting your deeplinks in the main activity-alias and the user changes the icon, those deeplinks will no longer work.</p><p>The quick solution is to put all the deeplinks in the launcher activity.</p><pre>&lt;activity<br>    android:name=&quot;.LauncherActivity&quot;<br>    android:exported=&quot;true&quot;<br>    android:theme=&quot;@style/AppTheme.Launcher&quot;&gt;<br>    &lt;intent-filter&gt;<br>        &lt;action android:name=&quot;android.intent.action.MAIN&quot; /&gt;<br>        &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot; /&gt;<br>    &lt;/intent-filter&gt;<br><br>    &lt;!-- Android Deep Links --&gt;<br>    &lt;intent-filter&gt;<br>        &lt;data android:scheme=&quot;${deeplink.uriScheme}&quot; /&gt;<br>        &lt;action android:name=&quot;android.intent.action.VIEW&quot; /&gt;<br>        &lt;category android:name=&quot;android.intent.category.DEFAULT&quot; /&gt;<br>        &lt;category android:name=&quot;android.intent.category.BROWSABLE&quot; /&gt;<br>    &lt;/intent-filter&gt;<br>&lt;/activity&gt;</pre><p>The problem with this solution is that the foreground icon will not match the app icon like in the picture below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*QzoE_08LWMCASaSVxxBFfQ.png" /><figcaption>The foreground icon is not matching the app icon when launching from deeplink</figcaption></figure><p>As we’re looking for the best user experience, we thought about adding a <strong>gradle plugin</strong> to auto-generate the manifest using a shell script that will be launched from Android Studio if needed. By doing that, we will add the deeplinks for each activity-alias and avoid manual duplication and errors.</p><p>Here are the steps of the <strong>Gradle plugin:</strong></p><ul><li>Create a file containing all the intent-filters</li></ul><pre>&lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;<br>    xmlns:tools=&quot;http://schemas.android.com/tools&quot;&gt;<br><br>    &lt;intent-filter&gt;<br>        &lt;action android:name=&quot;android.intent.action.MAIN&quot; /&gt;<br>        &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot; /&gt;<br>    &lt;/intent-filter&gt;<br><br>    &lt;!-- Android Deep Links --&gt;<br>    &lt;intent-filter&gt;<br>        &lt;data android:scheme=&quot;${deeplink.uriScheme}&quot; /&gt;<br>        &lt;action android:name=&quot;android.intent.action.VIEW&quot; /&gt;<br>        &lt;category android:name=&quot;android.intent.category.DEFAULT&quot; /&gt;<br>        &lt;category android:name=&quot;android.intent.category.BROWSABLE&quot; /&gt;<br>    &lt;/intent-filter&gt;<br>&lt;/manifest&gt;</pre><ul><li>Create two properties, one for the final manifest and one for the intent-filter file</li></ul><pre>@get:OutputFile<br>abstract val manifestFile: RegularFileProperty<br><br><br>@get:InputFile<br>abstract val intentFile: RegularFileProperty<br><br><br>init {<br>   manifestFile.set(File(project.projectDir, GENERATED_MANIFEST_PATH))<br>   intentFile.set(File(project.projectDir, INTENT_FILE_PATH))<br>}</pre><ul><li>Retrieve the intent-filters into a list of Node</li></ul><pre>fun retrieveIntentFiles(): List&lt;Node&gt; {<br>   val intentFilterDocument = parseXml(intentFile.get().asFile)<br><br>   // Access elements and attributes<br>   intentFilterDocument.documentElement.normalize()<br>   val root = intentFilterDocument.documentElement<br>   val elementsList = mutableListOf&lt;Node&gt;()<br><br>   val nodeList = root.childNodes<br>   for (i in 0 until nodeList.length) {<br>       val node = nodeList.item(i)<br><br>       if (node.nodeType == Document.ELEMENT_NODE) {<br>           val element = node as Element<br>           if (element.tagName != &quot;manifest&quot;) {<br>               elementsList.add(node)<br>           }<br>       }<br>   }<br>   return elementsList<br>}</pre><ul><li>Add the list of nodes to the manifest nodes</li></ul><p>First, retrieve all nodes of type Element:</p><pre>private fun getAsElement(node: Node): Element? {<br>        return if (node.nodeType == Document.ELEMENT_NODE) {<br>            node as Element<br>        } else {<br>            null<br>        }<br>    }</pre><p>Then, use it to add the elements to the manifest node:</p><pre>for (i in 0 until root.childNodes.length) {<br>       getAsElement(root.childNodes.item(i))?.let { manifestElements -&gt;<br>           for (j in 0 until manifestElements.childNodes.length) {<br>               getAsElement(manifestElements.childNodes.item(j))?.let { activityAlias -&gt;<br>                   if (activityAlias.tagName == ACTIVITY_ALIAS) {<br>                       deleteOldNodes(activityAlias)<br>                       intentFilters.forEach {<br>                           val newNode = document.importNode(it, true)<br>                           activityAlias.appendChild(newNode)<br>                       }<br>                   }<br>               }<br>           }<br>       }<br>   }</pre><p>To avoid having a script failing with this error:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E0wTVkjJmgVziBubHmm97w.png" /></figure><p>we need to import the nodes to the document before appending them to the activity-alias nodes:</p><pre>val newNode = document.importNode(it, true)</pre><ul><li>Transform the document into a String to write it inside the manifest file</li></ul><pre>val transformerFactory = TransformerFactory.newInstance()<br>val transformer = transformerFactory.newTransformer()<br>transformer.setOutputProperty(OutputKeys.INDENT, &quot;yes&quot;)<br>transformer.setOutputProperty(&quot;{http://xml.apache.org/xslt}indent-amount&quot;, &quot;1&quot;)<br>val source = DOMSource(document)<br>val writer = StringWriter()<br>val result = StreamResult(writer)<br>transformer.transform(source, result)<br>val manifesttWriter =  writer.toString()<br>manifestFile.get().asFile.writeText(manifesttWriter)</pre><ul><li>Add the plugin to the needed Gradle:</li></ul><pre>id(&quot;update-manifest-config&quot;)</pre><p>Once the plugin is ready, you can now run the auto-generation manifest script ./gradlew updateManifestConfig<strong><em> </em></strong>and<strong><em> </em></strong>your manifest will be updated</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/261/1*4GJt_kFnP3fSX7sCYvi9Rw.png" /></figure><p>And now, if you launch the application from a deeplink you’ll have a match between the foreground icon and the app icon when you launch the application from deeplink:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*WMKGh3uTGyfPd8a91ykadA.png" /><figcaption>The foreground icon is matching the app icon when launching from deeplink</figcaption></figure><p>This feature wouldn’t have been possible without the collaborative effort of our amazing team. A heartfelt thanks to <a href="https://medium.com/u/329af30a5334">Ahmed Salem</a> for his support throughout the development process.</p><p><strong>Thank you for reading! </strong>We hope you enjoyed this post and found it helpful in navigating the challenges you might encounter when implementing app icon customization. If you have any questions, thoughts, or additional insights, feel free to share them in the comments. We’d love to hear about your experience and help in any way we can.</p><p>And like we say at Back Market: <em>“Bon chance” </em>👋</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*YfQIGyjdSmp0pXDNghMjvg.gif" /></figure><p><strong>If you want to join our Bureau of Technology or any other Back Market department, </strong><a href="https://jobs.backmarket.com/job-search-results/"><strong>take a look here, we’re hiring!</strong></a><strong> <em>🦄</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Et8n4VywyIG2tgXovTvLiQ.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1698158a51f5" width="1" height="1" alt=""><hr><p><a href="https://engineering.backmarket.com/from-default-to-distinctive-how-to-change-your-android-app-icon-1698158a51f5">From Default to Distinctive: How to Change Your Android App Icon</a> was originally published in <a href="https://engineering.backmarket.com/">Back Market Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>