-
Notifications
You must be signed in to change notification settings - Fork 521
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #2652: Add dimensions for splash screen logo #2894
Conversation
@rt4914 PTAL. |
@ArpitShukIa were you able to produce this issue in any device |
Thanks for confirming. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ArpitShukIa Thanks. suggested few things.
<item android:drawable="@color/oppiaPrimaryLight" /> | ||
<item | ||
android:width="@dimen/splash_screen_logo_width" | ||
android:height="@dimen/splash_screen_logo_height" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The width and height works only for API 23+. Have you checked on API 19 or 20?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked and it's not working for API below 23. The logo gets stretched in lower apis.
I tried searching but couldn't find any good solution.
One solution can be to use a png logo for those lower APIs instead of a vector drawable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use ConstraintLayout
Guidelines as mentioned in the issues-mocks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if this is possible. We need to set a drawable for android:windowBackground
. I don't think we can set a layout as windowBackground.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If any other approach works, that's also fine. Can you investigate and come with possible solutions for this?
@rt4914 For API 23 and above, display is the same as in screenshots send above. For API below 23: (I used API 19 here)Pixel 2 5" (Portrait)Pixel 2 5" (Land)Pixel 4 XL 6.3" (Port)Pixel 4 XL 6.3" (Land)Nexus 9 Tablet 8.86" (Port)Nexus 9 Tablet 8.86" (Land) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The solution does look good but still adding @BenHenning as it might lead to added apk size.
WDYT @BenHenning about this implementation?
The combined size of the 4 PNGs that I added is 65.39 kB. |
Thanks @ArpitShukIa. One thing that's unclear to me: why do we need to load PNGs here? The Oppia logo drawable is a vector drawable and should therefore be scalable to different densities. Can you provide a bit more detail about why the vector drawable isn't sufficient? |
@BenHenning PTAL at this stackoverflow answer. |
@BenHenning The problem with just using vector drawable is that the drawable contains the logo as well as the green background in the height to width ratio of 640dp to 360dp. What we desire is that the green background should stretch to cover the whole screen but the white logo should maintain its aspect ratio. This is not possible, since both are part of a single vector drawable. A solution to this is to use a layered-list with the background as one layer and the white logo as another. Here we need to provide The only problem with the above solution is that the |
Thanks @ArpitShukIa. That's really interesting...I'll need to think on this a bit more before reviewing it. It seems like this might be our only option, but I want to be sure before we introduce binary files to the codebase. |
@BenHenning Did you review this? Does it look good? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ArpitShukIa. Apologies for pushing this back, and thanks for your patience. I left two comments, but I'm also wondering: is it possible for us to add splash tests for different configurations in Robolectric to verify that a bitmap vs. a picture drawable is used? I think you might even be able to verify the bitmap's dimensions for different configurations, so we can actually have tests for each of the new images and the drawable. Roboletric also lets you configure SDK per-test so you can validate the v23 qualifier.
Other than that, I still want to check this out locally and inspect the new bitmap images before signing off. It seems like this is the best solution available (quite possibly the only), and I think we can afford adding a few more small binary files into the repository since we are unlikely to change them.
<item | ||
android:width="@dimen/splash_screen_logo_width" | ||
android:height="@dimen/splash_screen_logo_height" | ||
android:drawable="@drawable/oppia_logo" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we maybe rename this to be 'oppia_logo_svg' and the png version 'oppia_logo_bitmap' to contrast?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
<item> | ||
<bitmap | ||
android:gravity="center" | ||
android:src="@drawable/oppia_png_logo" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you upload webp versions of the images instead of png? webp are often smaller.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
<!-- Splash Screen--> | ||
<dimen name="splash_screen_logo_width">360dp</dimen> | ||
<dimen name="splash_screen_logo_height">640dp</dimen> | ||
<dimen name="splash_screen_logo_margin_top">100dp</dimen> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this & others: how did you come up with these margins? Also, will these work correctly for both the bitmap & vector drawable (given that they're both used in landscape/other scenarios depending on SDK version).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this & others: how did you come up with these margins?
I figured out these margins just by hit and trial. I used multiple devices (phones & tablets) to find the best fits.
These height and width are in the same ratio as that of the svg logo.
Also, will these work correctly for both the bitmap & vector drawable
Currently, these margins are just for the svg drawable. For the bitmap, I haven't set any margin yet. As a result, it is centred vertically as of now. To get the behaviour as shown in the mock we will have to provide a bottom margin to the bitmap. (I think different bottom margins will be required for mobile and tablet layouts.)
I wanted to confirm that is it necessary for the logo (in portrait mode) to sit above the central horizontal axis as shown in the mocks. Like, how bad do these vertically centred logos look?
If we place the logo at the centre (as shown above), we can get rid of those top and bottom margins.
Another point is that I think we should update the path data for svg logo to only contain the logo and no extra space. Right now it has a viewportWidth=360dp and viewportHeight=640dp but the logo is only in a small portion of this area. This blank area was earlier required when that green background was a part of this svg but we don't need this now. Also, removing the blank area will allow us to use the same dimensions (and margins) for both the svg and the bitmaps.
Unfortunately, I won't be able to do this part as I don't have any prior experience in editing svgs.
Mocks for reference:
(Plz ignore the percentage values in the mocks, I don't think it's possible to set percentage margins in a drawable. Also, please let me know if there's actually some way to achieve this.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the really detailed response @ArpitShukIa!
@mschanteltc do you have any thoughts on how we should relatively position the logo? Should it be center-center? Also, might it be possible to provide us with a new version of the Oppia logo SVG that doesn't include any padding around it? I think we need to reimport this, and convert that exact SVG to WEBP so that we can make sure the bitmap/vector images are exactly the same so that positioning is consistent for both.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For (mobile, tablet) landscape views, we would vertically center the logo. For (mobile, tablet) portrait views, we should place the icon on top of the vertical center.
The svg in the Android Images folder should already be fit to bounds, so there shouldn't be any padding around it. Is there a specific way I should export the file? Should I try to convert it to a WEBP file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BenHenning I have updated the svg logo and created new webp images of different sizes for the new svg. Also, updated the dimens.xml with new values.
The results are pretty much the same as those in the screenshots in the above comments.
Should I send the new screenshots for different screen sizes or will you, as you said, check out the changes locally by yourself?
@BenHenning I understand what needs to be done but am having little trouble figuring out how to do it. @Test
@Config(qualifiers = "port")
fun testSplashScreen_correctBitmapIsLoaded() {
val context = ApplicationProvider.getApplicationContext<Application>()
val drawable = context.resources.getDrawable(R.drawable.oppia_logo_bitmap)
val expectedWidth = context.resources.getDimension(R.dimen.splash_screen_logo_width)
val expectedHeight = context.resources.getDimension(R.dimen.splash_screen_logo_height)
assertThat(drawable.intrinsicWidth).isEqualTo(expectedWidth.toInt())
assertThat(drawable.intrinsicHeight).isEqualTo(expectedHeight.toInt())
} I am not sure if this is the right way or not. This test verifies that the bitmap present for that config is of the same dimensions as those of the svg (for that config). And, I need some help with that "verify webp images are used below API 23 and vector drawable is used for API>=23" part. |
@BenHenning PTAL at this (comment) and this (comment) |
Sorry, been really busy with non-work items this week. Will need to take a look later in the week. |
I'm currently traveling & won't be available next week for this review. I will take a look soon after I returned on or after 24th of May. I haven't lost track of this PR, I just haven't been able to look at it quite yet. I appreciate your continued patience @ArpitShukIa. |
Explanation
Fixes #2652 : Added dimensions for splash screen logo for different screen sizes.
Screenshots:
Device: Realme 3 Pro (Landscape)
Other device models:
Checklist