Commit 0768b3ab authored by Mei Liang's avatar Mei Liang Committed by Commit Bot

[TabSelectionEditor] Support landscape mode

Change-Id: I392609674b2c2b624a247e9c7bc2c19651f13692
Bug: 987160
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1766004Reviewed-by: default avatarWei-Yin Chen (陳威尹) <wychen@chromium.org>
Commit-Queue: Mei Liang <meiliang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#689674}
parent 7122c699
...@@ -169,11 +169,12 @@ public class TabListCoordinator implements Destroyable { ...@@ -169,11 +169,12 @@ public class TabListCoordinator implements Destroyable {
gridCardOnClickListenerProvider, dialogHandler, componentName); gridCardOnClickListenerProvider, dialogHandler, componentName);
if (mMode == TabListMode.GRID) { if (mMode == TabListMode.GRID) {
mRecyclerView.setLayoutManager( GridLayoutManager gridLayoutManager =
new GridLayoutManager(context, GRID_LAYOUT_SPAN_COUNT_PORTRAIT)); new GridLayoutManager(context, GRID_LAYOUT_SPAN_COUNT_PORTRAIT);
mRecyclerView.setLayoutManager(gridLayoutManager);
mMediator.registerOrientationListener(gridLayoutManager);
mMediator.updateSpanCountForOrientation( mMediator.updateSpanCountForOrientation(
(GridLayoutManager) mRecyclerView.getLayoutManager(), gridLayoutManager, context.getResources().getConfiguration().orientation);
context.getResources().getConfiguration().orientation);
} else if (mMode == TabListMode.STRIP || mMode == TabListMode.CAROUSEL) { } else if (mMode == TabListMode.STRIP || mMode == TabListMode.CAROUSEL) {
mRecyclerView.setLayoutManager( mRecyclerView.setLayoutManager(
new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)); new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false));
...@@ -186,8 +187,6 @@ public class TabListCoordinator implements Destroyable { ...@@ -186,8 +187,6 @@ public class TabListCoordinator implements Destroyable {
context.getResources().getDimension(R.dimen.bottom_sheet_peek_height), context.getResources().getDimension(R.dimen.bottom_sheet_peek_height),
tabModelSelector.getCurrentModel().getProfile())); tabModelSelector.getCurrentModel().getProfile()));
touchHelper.attachToRecyclerView(mRecyclerView); touchHelper.attachToRecyclerView(mRecyclerView);
mMediator.registerOrientationListener(
(GridLayoutManager) mRecyclerView.getLayoutManager());
// TODO(crbug.com/964406): unregister the listener when we don't need it. // TODO(crbug.com/964406): unregister the listener when we don't need it.
mRecyclerView.getViewTreeObserver().addOnGlobalLayoutListener( mRecyclerView.getViewTreeObserver().addOnGlobalLayoutListener(
......
...@@ -7,10 +7,9 @@ package org.chromium.chrome.browser.tasks.tab_management; ...@@ -7,10 +7,9 @@ package org.chromium.chrome.browser.tasks.tab_management;
import android.content.Context; import android.content.Context;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.view.Gravity; import android.view.Gravity;
import android.view.View; import android.view.View;
import android.view.WindowManager; import android.view.ViewGroup;
import android.widget.PopupWindow; import android.widget.PopupWindow;
import org.chromium.chrome.browser.widget.selection.SelectableListLayout; import org.chromium.chrome.browser.widget.selection.SelectableListLayout;
...@@ -30,12 +29,8 @@ class TabSelectionEditorLayout extends SelectableListLayout<Integer> { ...@@ -30,12 +29,8 @@ class TabSelectionEditorLayout extends SelectableListLayout<Integer> {
// TabSelectionEditorCoordinator. // TabSelectionEditorCoordinator.
public TabSelectionEditorLayout(Context context, AttributeSet attrs) { public TabSelectionEditorLayout(Context context, AttributeSet attrs) {
super(context, attrs); super(context, attrs);
mWindow = new PopupWindow(
DisplayMetrics displayMetrics = new DisplayMetrics(); this, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
((WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE))
.getDefaultDisplay()
.getMetrics(displayMetrics);
mWindow = new PopupWindow(this, displayMetrics.widthPixels, displayMetrics.heightPixels);
} }
/** /**
......
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