Closed Bug 1083263 Opened 11 years ago Closed 11 years ago

Sort out aspect ratio of thumbnails for new tablet UI

Categories

(Firefox for Android Graveyard :: General, defect)

All
Android
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
Firefox 36

People

(Reporter: mhaigh, Assigned: mhaigh)

References

Details

Attachments

(3 files, 4 obsolete files)

The thumbnails in the grid view are at the wrong aspect ratio in the new tablet UI.
This patch fixes the size of the thumbnail in the new gridview, introduces a new asset (xhdpi & hdpi sizes) and sorts out the aspect ratio for the thumbnail, whilst retaining existing functionality for non new tablet UI.
Attachment #8510337 - Flags: feedback?(lucasr.at.mozilla)
I'm probably going to need a new empty tab asset in xhdpi (202 x 180) and hdpi (152 x 135) as the one I've done looks a bit blocky
Flags: needinfo?(alam)
Attachment #8510338 - Attachment description: media-20141023.png → Screenshot of grid view with new assets and styles. The new tab asset is blocky.
Comment on attachment 8510337 [details] [diff] [review] Sort out aspect ratio of thumbnails for new tablet UI Review of attachment 8510337 [details] [diff] [review]: ----------------------------------------------------------------- Looks good. Please test this on phones and old tablet UI to make sure it doesn't cause regressions. Also, look out for weird thumbnails on top sites grid in the new tablet UI. ::: mobile/android/base/home/TopSitesGridItemView.java @@ +231,5 @@ > Favicons.cancelFaviconLoad(mLoadId); > ImageLoader.with(getContext()).cancelRequest(mThumbnailView); > > + if(NewTabletUI.isEnabled(getContext())) { > + mThumbnailView.setScaleType(NEW_TABLET_SCALE_TYPE_THUMBNAIL); How does this look on thumbnail images? Does it crop the top/bottom of the image? Shouldn't it be FIT_START or something?
Attachment #8510337 - Flags: feedback?(lucasr.at.mozilla) → feedback+
Do you need the whole image (globe + background color as one image) or just the globe? I remember Ian went through some of this last time we were in London back in May... But, I can't recall how we implemented these.
Flags: needinfo?(alam) → needinfo?(mhaigh)
Anthony: We've currently using an asset which is the entire image.
Flags: needinfo?(mhaigh) → needinfo?(alam)
Ok, I'll just make those for you to get this bug moving! :) But, keep in mind that we wanted to look at more dynamic solutions for things like Private browsing tabs in the near future. E.g. blurring these screenshots just in PB (can't find the bug number now). NI-ing Lucas to get his take on this^ too.
Flags: needinfo?(alam) → needinfo?(lucasr.at.mozilla)
Attached file img_tabtab_default.zip
^ check these out! :)
Flags: needinfo?(mhaigh)
In case there are questions why the aspect ratio is a bit different to our current tabs in Android... I've noticed that with newer devices and websites/ browsing in general, the content is actually getting "taller". What this means from a practical standpoint for us is that when we design something like these "website previews", we need to be aware of trying to show more meaningful content so the user can make those mental connections easier ("Oh! that WAS exactly what I was looking for!"). tl;dr : Between orientations, browsing habits, and general market trends, it'd be useful to show more content in the previews so I've made them taller too. On an encouraging note: "The Nexus 9 is a premium 8.9” tablet with a screen size of 2048 x 1536 pixels (288 ppi), which translates to 1024 x 768 dip. This is a 4:3 aspect ratio, which is unique compared to earlier tablets. The Nexus 9 falls into the xhdpi density bucket, and you should already have assets in the drawable-xhdpi folder. " :)
Blocks: 1091558
Current working patch - this replaces the old patch completely as the top sites weren't working properly in that patch. This one fixes the aspect ratio in the tabs tray and top sites (this is the matrix related code), but the issues left remaining is that the globe icon is being scaled despite following the Android guidelines of how to now get an image to scale in a LayerList. Can you spot what I'm doing wrong?
Attachment #8510337 - Attachment is obsolete: true
Flags: needinfo?(mhaigh)
Attachment #8514286 - Flags: feedback?(lucasr.at.mozilla)
Comment on attachment 8514286 [details] [diff] [review] Sort out aspect ratio of thumbnails for new tablet UI Review of attachment 8514286 [details] [diff] [review]: ----------------------------------------------------------------- Looks good overall. I still don't understand why the image gets scaled up. Digging. This new_tablet_tab_thumbnail_default is not used anywhere, remove it. ::: mobile/android/base/ThumbnailHelper.java @@ +33,5 @@ > > public static final float THUMBNAIL_ASPECT_RATIO = 0.571f; // this is a 4:7 ratio (as per UX decision) > > + // Should actually be more like 0.83 (140/168) but various roundings mean that 0.9 works better > + public static final float NEW_TABLET_THUMBNAIL_ASPECT_RATIO = 0.9f; Changes to ThumbnailHelper look good. ::: mobile/android/base/home/TopSitesGridItemView.java @@ +280,4 @@ > } > > mThumbnailView.setScaleType(SCALE_TYPE_FAVICON); > + mThumbnailView.setImageBitmap(favicon, false); Why isn't scaletype enough here? ::: mobile/android/base/home/TopSitesThumbnailView.java @@ +39,4 @@ > // Paint for drawing the border. > private final Paint mBorderPaint; > > + private boolean mResize = false; This is looking a bit smelly. Can you clarify why a simple scaletype is not working? @@ +97,5 @@ > final int height = (int) (width * ThumbnailHelper.THUMBNAIL_ASPECT_RATIO); > setMeasuredDimension(width, height); > + > + > + if(NewTabletUI.isEnabled(getContext()) && mResize) { fitStart doesn't work in this case? ::: mobile/android/base/resources/values/dimens.xml @@ +128,5 @@ > <dimen name="history_tab_indicator_height">50dp</dimen> > > > + <dimen name="new_tablet_tab_thumbnail_height">140dp</dimen> > + <dimen name="new_tablet_tab_thumbnail_width">168dp</dimen> This is just because you don't have the patch from bug 1064415, right? ::: mobile/android/base/tabs/TabsLayoutItemView.java @@ +100,5 @@ > } else { > + if(NewTabletUI.isEnabled(getContext())) { > + mThumbnail.setImageResource(R.drawable.new_tablet_tab_background); > + } else { > + mThumbnail.setImageResource(R.drawable.tab_thumbnail_default); The layer drawable should be applicable in all UIs, no? You can even remove tab_thumbnail_default from the tree.
So the issue is that currently the new globe drawable asset isn't scaling properly - the globe is now the correct size, but the surrounding background only covers behind the globe.
Attachment #8514286 - Attachment is obsolete: true
Attachment #8514286 - Flags: feedback?(lucasr.at.mozilla)
Attachment #8514411 - Flags: feedback?(lucasr.at.mozilla)
Moved the globes and associated files to the normal res folder to add compatibility with non tablet devices.
Attachment #8514411 - Attachment is obsolete: true
Attachment #8514411 - Flags: feedback?(lucasr.at.mozilla)
Attachment #8514445 - Flags: review?(lucasr.at.mozilla)
Comment on attachment 8514445 [details] [diff] [review] Sort out aspect ratio of thumbnails for new tablet UI and implement new empty tab globes Review of attachment 8514445 [details] [diff] [review]: ----------------------------------------------------------------- *Awesome*. I assume you can remove tab_thumbnail_default now? Giving r+, please apply suggested changes before landing and test this patch with phones and old tablet UI. ::: mobile/android/base/home/TopSitesThumbnailView.java @@ +102,5 @@ > + setScaleType(ScaleType.MATRIX); > + RectF rect = new RectF(0, 0, width, height); > + Matrix matrix = new Matrix(); > + matrix.setRectToRect(rect, rect, Matrix.ScaleToFit.CENTER); > + setImageMatrix(matrix); You should be doing this in onLayout(), as onMeasure() is often called multiple times in each layout traversal. ::: mobile/android/base/resources/values/dimens.xml @@ +128,5 @@ > <dimen name="history_tab_indicator_height">50dp</dimen> > > > + <dimen name="new_tablet_tab_thumbnail_height">140dp</dimen> > + <dimen name="new_tablet_tab_thumbnail_width">168dp</dimen> This is not necessary once you rebase on top of bug 1064415, right? ::: mobile/android/base/widget/ThumbnailView.java @@ +34,4 @@ > @Override > public void onDraw(Canvas canvas) { > Drawable d = getDrawable(); > + if (mLayoutChanged && mScale) { It's more like: public void onDraw(Canvas canvas) { if (!mScale) { super.onDraw(canvas); return; } Drawable d = getDrawable(); ... } @@ +72,5 @@ > + mScale = false; > + } else { > + mScale = true; > + setScaleType(ScaleType.FIT_CENTER); > + } nit: add empty line here.
Attachment #8514445 - Flags: review?(lucasr.at.mozilla) → review+
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 36
Flags: needinfo?(lucasr.at.mozilla)
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: