Commit be45ae14 authored by Shakti Sahu's avatar Shakti Sahu Committed by Commit Bot

Download home : Added max width for image and video

This CL adds a max width for image and videos to handle screens that
are too wide such as phone in landscape and tablets.

Bug: 890526
Change-Id: Icd8acbe0177761c2fd684d2ab2421419857e7be9
Reviewed-on: https://chromium-review.googlesource.com/c/1282203Reviewed-by: default avatarDavid Trainor <dtrainor@chromium.org>
Commit-Queue: Shakti Sahu <shaktisahu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#600478}
parent 438caa21
...@@ -544,6 +544,8 @@ ...@@ -544,6 +544,8 @@
<!-- Download manager dimensions --> <!-- Download manager dimensions -->
<dimen name="download_manager_ideal_image_width">150dp</dimen> <dimen name="download_manager_ideal_image_width">150dp</dimen>
<dimen name="download_manager_max_image_item_width_wide_screen">300dp</dimen>
<dimen name="download_manager_wide_screen_threshold">600dp</dimen>
<dimen name="download_manager_image_padding">2dp</dimen> <dimen name="download_manager_image_padding">2dp</dimen>
<dimen name="download_manager_prefetch_horizontal_margin">16dp</dimen> <dimen name="download_manager_prefetch_horizontal_margin">16dp</dimen>
<dimen name="download_manager_prefetch_vertical_margin">12dp</dimen> <dimen name="download_manager_prefetch_vertical_margin">12dp</dimen>
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
package org.chromium.chrome.browser.download.home.list; package org.chromium.chrome.browser.download.home.list;
import android.content.Context; import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Rect; import android.graphics.Rect;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v7.widget.DefaultItemAnimator; import android.support.v7.widget.DefaultItemAnimator;
...@@ -35,6 +36,8 @@ class DateOrderedListView { ...@@ -35,6 +36,8 @@ class DateOrderedListView {
private final int mImagePaddingPx; private final int mImagePaddingPx;
private final int mPrefetchVerticalPaddingPx; private final int mPrefetchVerticalPaddingPx;
private final int mPrefetchHorizontalPaddingPx; private final int mPrefetchHorizontalPaddingPx;
private final int mMaxWidthImageItemPx;
private final int mWideScreenThreshold;
private final RecyclerView mView; private final RecyclerView mView;
...@@ -52,8 +55,23 @@ class DateOrderedListView { ...@@ -52,8 +55,23 @@ class DateOrderedListView {
R.dimen.download_manager_prefetch_horizontal_margin); R.dimen.download_manager_prefetch_horizontal_margin);
mPrefetchVerticalPaddingPx = context.getResources().getDimensionPixelSize( mPrefetchVerticalPaddingPx = context.getResources().getDimensionPixelSize(
R.dimen.download_manager_prefetch_vertical_margin); R.dimen.download_manager_prefetch_vertical_margin);
mMaxWidthImageItemPx = context.getResources().getDimensionPixelSize(
R.dimen.download_manager_max_image_item_width_wide_screen);
mWideScreenThreshold = context.getResources().getDimensionPixelSize(
R.dimen.download_manager_wide_screen_threshold);
mView = new RecyclerView(context); mView = new RecyclerView(context) {
private int mScreenOrientation = Configuration.ORIENTATION_UNDEFINED;
@Override
protected void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if (newConfig.orientation == mScreenOrientation) return;
mScreenOrientation = newConfig.orientation;
mView.invalidateItemDecorations();
}
};
mView.setHasFixedSize(true); mView.setHasFixedSize(true);
((DefaultItemAnimator) mView.getItemAnimator()).setSupportsChangeAnimations(false); ((DefaultItemAnimator) mView.getItemAnimator()).setSupportsChangeAnimations(false);
mView.getItemAnimator().setMoveDuration(0); mView.getItemAnimator().setMoveDuration(0);
...@@ -126,6 +144,8 @@ class DateOrderedListView { ...@@ -126,6 +144,8 @@ class DateOrderedListView {
int position = parent.getChildAdapterPosition(view); int position = parent.getChildAdapterPosition(view);
if (position < 0 || position >= mModel.size()) return; if (position < 0 || position >= mModel.size()) return;
ListItem item = mModel.get(position);
boolean isFullWidthMedia = false;
switch (ListUtils.getViewTypeForItem(mModel.get(position), mConfig)) { switch (ListUtils.getViewTypeForItem(mModel.get(position), mConfig)) {
case ListUtils.ViewType.IMAGE: case ListUtils.ViewType.IMAGE:
case ListUtils.ViewType.IN_PROGRESS_IMAGE: case ListUtils.ViewType.IN_PROGRESS_IMAGE:
...@@ -133,6 +153,7 @@ class DateOrderedListView { ...@@ -133,6 +153,7 @@ class DateOrderedListView {
outRect.right = mImagePaddingPx; outRect.right = mImagePaddingPx;
outRect.top = mImagePaddingPx; outRect.top = mImagePaddingPx;
outRect.bottom = mImagePaddingPx; outRect.bottom = mImagePaddingPx;
isFullWidthMedia = ((ListItem.OfflineItemListItem) item).spanFullWidth;
break; break;
case ListUtils.ViewType.VIDEO: // Intentional fallthrough. case ListUtils.ViewType.VIDEO: // Intentional fallthrough.
case ListUtils.ViewType.IN_PROGRESS_VIDEO: case ListUtils.ViewType.IN_PROGRESS_VIDEO:
...@@ -140,6 +161,7 @@ class DateOrderedListView { ...@@ -140,6 +161,7 @@ class DateOrderedListView {
outRect.right = mPrefetchHorizontalPaddingPx; outRect.right = mPrefetchHorizontalPaddingPx;
outRect.top = mPrefetchVerticalPaddingPx / 2; outRect.top = mPrefetchVerticalPaddingPx / 2;
outRect.bottom = mPrefetchVerticalPaddingPx / 2; outRect.bottom = mPrefetchVerticalPaddingPx / 2;
isFullWidthMedia = true;
break; break;
case ListUtils.ViewType.PREFETCH: case ListUtils.ViewType.PREFETCH:
outRect.left = mPrefetchHorizontalPaddingPx; outRect.left = mPrefetchHorizontalPaddingPx;
...@@ -148,6 +170,10 @@ class DateOrderedListView { ...@@ -148,6 +170,10 @@ class DateOrderedListView {
outRect.bottom = mPrefetchVerticalPaddingPx / 2; outRect.bottom = mPrefetchVerticalPaddingPx / 2;
break; break;
} }
if (isFullWidthMedia) {
outRect.right += Math.max(mView.getWidth() - mMaxWidthImageItemPx, 0);
}
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment