<?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 Oleg Green on Medium]]></title>
        <description><![CDATA[Stories by Oleg Green on Medium]]></description>
        <link>https://medium.com/@oleg7green?source=rss-7b6c8800345b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*BEfzXgLIG6Z_BsMeFqoFhg.jpeg</url>
            <title>Stories by Oleg Green on Medium</title>
            <link>https://medium.com/@oleg7green?source=rss-7b6c8800345b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 10:42:28 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@oleg7green/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[The specific case of App Links on Android/iOS apps]]></title>
            <link>https://medium.com/@oleg7green/the-specific-case-of-app-links-on-android-ios-apps-47a0455f8892?source=rss-7b6c8800345b------2</link>
            <guid isPermaLink="false">https://medium.com/p/47a0455f8892</guid>
            <category><![CDATA[deep-linking]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Oleg Green]]></dc:creator>
            <pubDate>Thu, 21 Mar 2024 09:32:31 GMT</pubDate>
            <atom:updated>2024-03-21T12:23:22.877Z</atom:updated>
            <content:encoded><![CDATA[<p>Now I will tell you the store when we’ve got a new customer request for implementation and met troubles where we didn’t expect them.</p><p>First things first, what was the request?</p><p>One Radio station in Germany has a website where a user can listen to the radio, read some news, and so on. There are also Android and iOS applications where the user can also listen to the radio. But listening to the radio with the browser on mobile devices is not very useful, native applications can do it much better. So our client decided to implement the cool feature:</p><p>“<em>When a user is using a radio station website on a mobile device and decides to click on the play button to listen to the radio, the application should be opened and the radio stream should be automatically started. Or if the application is not installed then the Play Store/App Store should be opened with the application page”</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uooVnDWlKNd417czDslHYA.png" /></figure><h3><strong>Step 1: The obvious way (which didn’t work)</strong></h3><p>So the obvious solution for us(developers) was to use App Links. So we did it. We defined App Links, configured each application, and uploaded appropriate association files (<em>assetlinks.json for Android + .well-known/apple-app-site-associatio</em>n for iOS)to the backend…</p><p>Here’s the example for Android (<em>AndroidManifest.xml</em>):</p><pre>&lt;intent-filter android:autoVerify=&quot;true&quot;&gt;<br>  &lt;action android:name=&quot;android.intent.action.VIEW&quot; /&gt;<br><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><br>  &lt;data<br>    android:scheme=&quot;https&quot;<br>    android:host=&quot;www.radioname.de&quot;<br>    android:path=&quot;/play/livestream&quot; /&gt;<br>&lt;/intent-filter&gt;</pre><p>…but it didn’t work :(</p><p>The problem appeared to be that browsers (at least Chrome and Safari) didn’t allow applications to intercept control of the user if a user is navigating on the same domain.</p><blockquote>When using Applinks, Chrome will always defer to directing users on the same domain to the web instead of deep linking to the native app.</blockquote><p><a href="https://stackoverflow.com/questions/47117683/deep-link-wont-work-if-opened-from-the-same-domain">Deep link won&#39;t work if opened from the same domain</a></p><p>So for example when the user is browsing somewhere on facebook.com page finds some posts about our radio and clicks on our link <a href="http://www.radioname.de/play/livestream"><em>www.radioname.de/play/livestream</em></a><em> </em>then the app will be opened (everything works perfectly). But if the user is already on the <a href="http://www.radioname.de/play/livestream"><em>www.radioname.de/</em></a><em> </em>page and clicks on <a href="http://www.radioname.de/play/livestream"><em>www.radioname.de/play/livestream</em></a><em> </em>then neither Chrome nor Safari will allow your app to be opened and the user will stay in the browser.</p><p>Damn…</p><h3>Step 2: Looking for the solution</h3><p>The plan B came very quickly — to use <strong>custom schemes</strong>. They never let us down.</p><pre>&lt;intent-filter&gt;<br>  &lt;action android:name=&quot;android.intent.action.VIEW&quot; /&gt;<br><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><br>  &lt;data<br>    android:scheme=&quot;play&quot;<br>    android:host=&quot;www.radioname.de&quot;<br>    android:path=&quot;/livestream&quot; /&gt;<br>&lt;/intent-filter&gt;</pre><p>So the solution would be on the webpage to open a custom scheme URL when the user clicks on the play button on the mobile browser, something like this: <strong><em>play</em></strong><em>://www.radioname.de/livestream … </em>But only if your app is installed on the device. If not you are in trouble.</p><h3>Step 3: The best solution</h3><p>But the story with App Links is not done. We can make a small trick and still make it work. We should use a subdomain or another domain for the play button.</p><p>So when the user is on our website and clicks on a play button the next URL should be opened: <a href="http://www.radioname.de/play/livestream"><em>www.</em><strong><em>app</em></strong><em>.radioname.de/play/livestream</em></a><em>. </em>Since it is switching domain from Chrome/Safari point of view it will allow the app to be opened in this case. <br>The same story is with using a completely different domain for our purpose.</p><blockquote>Here is the official doc from apple about this case: <a href="https://developer.apple.com/documentation/technotes/tn3155-debugging-universal-links#Use-universal-links-on-your-site">https://developer.apple.com/documentation/technotes/tn3155-debugging-universal-links#Use-universal-links-on-your-site</a></blockquote><p>Sadly we haven’t reached it before. It has a clear receipt for our task.</p><p>But this solution has a <strong>disadvantage</strong>: Firefox/Samsung/Opera browsers don’t allow apps to be opened by default in this case….</p><p>For it to start working a user should go to the settings of for example Firefox and switch on the “Open links in apps” setting:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/362/1*_J0EmoRXxRplIfwDjVC6TA.gif" /></figure><h3>Bonus: The very best solution, but only for Android:(</h3><p>P.S. There is one way to implement this feature on Android in the best possible way.</p><p>You can use one Android feature — application scheme:</p><blockquote><strong><em>android-app://com.example.app</em></strong></blockquote><blockquote><a href="https://developer.android.com/reference/android/content/Intent#URI_ANDROID_APP_SCHEME">https://developer.android.com/reference/android/content/Intent#URI_ANDROID_APP_SCHEME</a></blockquote><p>So you can have such a URL on the website play button:</p><pre>&lt;a href=&quot;android-app://com.example.app/<br>#Intent;action=com.example.PLAY_LIVESTREAM;end&quot; target=&quot;_blank&quot;&gt;Play&lt;/a&gt;</pre><p>And in your AndroidManifest.xml:</p><pre>&lt;intent-filter&gt;<br>  &lt;action android:name=&quot;android.intent.action.VIEW&quot; /&gt;<br><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><br>  &lt;data android:scheme=&quot;android-app&quot; /&gt;<br>  &lt;data android:host=&quot;com.example.app&quot; /&gt;<br>&lt;/intent-filter&gt;</pre><p>This works like a charm. <strong>And bonus</strong>: if your app is not installed -&gt; Android automatically opens the Play Store with your application without any effort from your side. <strong>Perfect!</strong></p><p>This solution works on all browsers except Firefox. But since we chose the subdomains solution I didn’t dig into this issue.</p><p>Thank you for being on this journey with me…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=47a0455f8892" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Intrinsic measurements in Jetpack Compose]]></title>
            <link>https://medium.com/@oleg7green/intrinsic-measurements-in-jetpack-compose-f96e0d34e9e9?source=rss-7b6c8800345b------2</link>
            <guid isPermaLink="false">https://medium.com/p/f96e0d34e9e9</guid>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[layout]]></category>
            <dc:creator><![CDATA[Oleg Green]]></dc:creator>
            <pubDate>Tue, 19 Mar 2024 09:52:47 GMT</pubDate>
            <atom:updated>2024-03-19T09:58:35.811Z</atom:updated>
            <content:encoded><![CDATA[<p>Recently I’ve got a need to implement Composable which will meet next requirements:</p><ul><li>Have 2 columns</li><li>Each column has its background color</li><li>The height of both columns should be equal to the content of the maximum height. So if the left content height is bigger than the right one, the left column should wrap its content height and the right column’s height should be equal to the left one and vice versa.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*56KL0aG7OGhCVsb6Al9XaA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*Av_YlBEJXBwjMqXCw7IFJA.png" /></figure><p>It is a very common task, but the solution might not be that easy if you don’t know one specific modifier parameter.</p><p>So how it should be implemented?</p><ol><li>Maybe using <em>wrapContentHeight()</em> for parent and .<em>fillMaxHeight</em>() for children?</li></ol><pre>Row(<br>  modifier = Modifier<br>    .fillMaxWidth()<br>    .wrapContentHeight()<br>) {<br>  Column(Modifier.fillMaxHeight()) {...} //left column<br>  Column(Modifier.fillMaxHeight()) {...} //right column<br>}</pre><p>We will have the following result: All content will fill the screen height.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*d7XYQ8TBbG-d6VAf30t6vA.png" /></figure><p>2. Maybe using <em>wrapContentHeight()</em> for parent and .<em>wrapContentHeight</em>() for children?</p><pre>Row(<br>  modifier = Modifier<br>    .fillMaxWidth()<br>    .wrapContentHeight()<br>) {<br>  Column(Modifier.wrapContentHeight()) {...} //left column<br>  Column(Modifier.wrapContentHeight()) {...} //right column<br>}</pre><p>Also no, in this case each column only wrap its content size.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/578/1*ctzAOYhvAEZDOLK8x1yrEw.png" /></figure><p>3. Using fixed height. <br>For example, we can figure out what is the size of the right column and set this height for both of them. Also, we should limit the text on the left column to for example 5 lines max.</p><pre>Row(<br>  modifier = Modifier<br>    .fillMaxWidth()<br>    .wrapContentHeight()<br>) {<br>  Column(Modifier.wrapContentHeight()) {<br>    Text(<br>      text = ...,<br>      maxLines = 5,<br>      overflow = TextOverflow.Ellipsis,<br>    )<br>  } //left column<br>  Column(Modifier.wrapContentHeight()) {...} //right column<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/584/1*sixF42PbgyuJ-yzZTEEHmA.png" /></figure><p>Looks pretty good, but we have 2 drawbacks here:<br>* We are showing not all text, cutting the ending.<br>* If the device’s font scale is changed we will have troubles.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*-ARvLdA-4hIfx8i98mrfpQ.png" /></figure><p>4. Using Intrinsic measurements (the right way)</p><h3>Solution: Using .height(IntrinsicSize.Max)</h3><p>Jetpack Compose has a Modifier value specifically for this case. We can set <strong>IntrinsicSize.<em>Max </em></strong>as a parameter for <em>.height</em> or <em>.width</em> of the parent layout. This is the way for us to say: pre-measure your children and take the size of the biggest one. After that, each child can set its height as .<em>fillMaxHeight</em>(). Thats it! Very clean and bugless solution.</p><pre>Row(<br>  modifier = Modifier<br>    .fillMaxWidth()<br>    .height(IntrinsicSize.Max)<br>) {<br>  Column(Modifier.fillMaxHeight()) {...} //left column<br>  Column(Modifier.fillMaxHeight()) {...} //right column<br>}<br>    </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*56KL0aG7OGhCVsb6Al9XaA.png" /></figure><p>Here’s the full code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4af1251374c627ff23038c6bbfd53462/href">https://medium.com/media/4af1251374c627ff23038c6bbfd53462/href</a></iframe><p>More info can be found in the official documentation:<br><a href="https://developer.android.com/jetpack/compose/layouts/intrinsic-measurements">https://developer.android.com/jetpack/compose/layouts/intrinsic-measurements</a><br>And YouTube video: <a href="https://youtu.be/l6rAoph5UgI?si=53gnEW9a7oSyKxFx&amp;t=619">https://youtu.be/l6rAoph5UgI?si=53gnEW9a7oSyKxFx&amp;t=619</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f96e0d34e9e9" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>