https://kotlinlang.org logo
#compose
Title
# compose
v

Vlad

03/18/2024, 9:05 AM
Is there are some fresh Compose way to determine the screen orientation (at least for mobile)? Is it weird to assume orientation based on WindowWidthSizeClass aka:
Copy code
WindowWidthSizeClass.Expanded -> // orientation is landscape in most devices including foldables (width 840dp+)
        WindowWidthSizeClass.Medium -> // Most tablets are in landscape, larger unfolded inner displays in portrait (width 600dp+)
        WindowWidthSizeClass.Compact -> // Most phones in portrait
?
I am reading that Landscape/Portrait concepts are kinda getting obsolete considering multiwindow and foldables hm
1
s

Stylianos Gakis

03/18/2024, 9:40 AM
That’s the correct answer. Just don’t care if you are in landscape or portrait. Worry about your screen size and everything should fall into place automatically
👍 1
j

John O'Reilly

03/18/2024, 10:03 AM
a

Alex Vanyo

03/20/2024, 4:51 PM
Strongly, strongly recommend not basing decisions off of orientation in the first place
Foldables + free-form windowing setups mean that aspect ratios of your windows can get really close to 1:1. I’ve seen apps that try to do something like “if landscape, use 2 columns. if portrait, use 1 column” but that leads to a really weird user experience in a situation like the following: If the window is just-barely landscape, you’d have 2 columns. If the user resizes your window by making it taller, and the window becomes just barely portrait, there would only be 1 column. But the user strictly gave the app more space to render in, yet you end up seeing less content. If there was enough horizontal space to show both columns, why did making the window taller go back to one column? There’s clearly still enough space for both columns.
😬 2
v

Vlad

03/20/2024, 5:00 PM
Yea, that was really easy call to my management and assure them having Orientation for our analytics makes no sense and it is just old term which might matter only if you actually develop the device so you need to know how user physically holds it. We design in figma by SizeClasses anyway.
a

Alex Vanyo

03/20/2024, 5:01 PM
We design in figma by SizeClasses anyway.
Great to hear! Are the breakpoints lined up with https://developer.android.com/guide/topics/large-screens/support-different-screen-sizes#window_size_classes or do you use different ones?
v

Vlad

03/20/2024, 5:06 PM
Yes, that what I gave to the designer as reference. To the analytics backend developer also, so he has clue how to adapt and how to make it useful for the BA
👍 1
a

Alex Vanyo

03/20/2024, 5:36 PM
The analytics case is interesting - the assumption that the device orientation matches your window orientation that is becoming less and less true over time
v

Vlad

03/20/2024, 5:39 PM
Do we have pure square devices yet?:D
a

Alex Vanyo

03/20/2024, 5:41 PM
Watches technically 😄
😄 2
If you are in free-form you can have a purely square window. The OnePlus Open inner screen has an aspect ratio of 1.08:1
v

Vlad

03/20/2024, 5:44 PM
Also need to note, that orientation makes no sense if the mobile app run at desktop, aka iOS. We ONLY RECENTLY (I was android dev) learned that our apps run without issue on macbooks and installed form the app store. And you can resize the app window to square without any issue. I think that also is the case for chromebooks(question mark)
a

Alex Vanyo

03/20/2024, 5:50 PM
Yep, ChromeOS, Samsung Dex, Lenovo productivity mode all result in free-form experiences for Android apps
2 Views