Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabRecyclerView.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabScrollView.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabRecyclerView.java |
| similarity index 67% |
| copy from chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabScrollView.java |
| copy to chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabRecyclerView.java |
| index b354d6b00cccdc02a1f9ef036d3ba66bb0bab505..2e3953023517d509c12a24d2c8f6af5db2d75ffc 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabScrollView.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabRecyclerView.java |
| @@ -1,4 +1,4 @@ |
| -// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| @@ -7,25 +7,23 @@ package org.chromium.chrome.browser.ntp; |
| import android.content.Context; |
| import android.graphics.Canvas; |
| import android.os.Build; |
| +import android.support.v7.widget.LinearLayoutManager; |
| +import android.support.v7.widget.RecyclerView; |
| import android.util.AttributeSet; |
| -import android.util.Log; |
| import android.view.GestureDetector; |
| -import android.view.KeyEvent; |
| import android.view.MotionEvent; |
| -import android.view.View; |
| import android.view.inputmethod.EditorInfo; |
| import android.view.inputmethod.InputConnection; |
| -import android.widget.ScrollView; |
| +import org.chromium.base.Log; |
| import org.chromium.chrome.R; |
| import org.chromium.chrome.browser.widget.FadingShadow; |
| /** |
| - * Simple wrapper on top of a ScrollView that will acquire focus when tapped. Ensures the |
| + * Simple wrapper on top of a RecyclerView that will acquire focus when tapped. Ensures the |
| * New Tab page receives focus when clicked. |
| */ |
| -public class NewTabScrollView extends ScrollView { |
| - |
| +public class NewTabRecyclerView extends RecyclerView { |
| private static final String TAG = "NewTabScrollView"; |
| /** |
| @@ -42,18 +40,16 @@ public class NewTabScrollView extends ScrollView { |
| private GestureDetector mGestureDetector; |
| private OnScrollListener mOnScrollListener; |
| - private NewTabPageLayout mNewTabPageLayout; |
| - |
| private FadingShadow mFadingShadow; |
| /** |
| * Constructor needed to inflate from XML. |
| */ |
| - public NewTabScrollView(Context context, AttributeSet attrs) { |
| + public NewTabRecyclerView(Context context, AttributeSet attrs) { |
| super(context, attrs); |
| - mGestureDetector = new GestureDetector( |
| - getContext(), new GestureDetector.SimpleOnGestureListener() { |
| + mGestureDetector = |
| + new GestureDetector(getContext(), new GestureDetector.SimpleOnGestureListener() { |
| @Override |
| public boolean onSingleTapUp(MotionEvent e) { |
| boolean retVal = super.onSingleTapUp(e); |
| @@ -61,6 +57,7 @@ public class NewTabScrollView extends ScrollView { |
| return retVal; |
| } |
| }); |
| + setLayoutManager(new LinearLayoutManager(getContext())); |
| } |
| /** |
| @@ -76,23 +73,6 @@ public class NewTabScrollView extends ScrollView { |
| } |
| @Override |
| - protected void onFinishInflate() { |
| - super.onFinishInflate(); |
| - |
| - View child = getChildAt(0); |
| - if (child instanceof NewTabPageLayout) mNewTabPageLayout = (NewTabPageLayout) child; |
| - } |
| - |
| - @Override |
| - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { |
| - if (mNewTabPageLayout != null) { |
| - mNewTabPageLayout.setParentScrollViewportHeight( |
| - MeasureSpec.getSize(heightMeasureSpec)); |
| - } |
| - super.onMeasure(widthMeasureSpec, heightMeasureSpec); |
| - } |
| - |
| - @Override |
| public boolean onInterceptTouchEvent(MotionEvent ev) { |
| mGestureDetector.onTouchEvent(ev); |
| return super.onInterceptTouchEvent(ev); |
| @@ -136,29 +116,6 @@ public class NewTabScrollView extends ScrollView { |
| } |
| @Override |
| - public void focusableViewAvailable(View v) { |
|
newt (away)
2016/03/23 05:29:38
Are you sure it's OK to remove (i.e. not add) this
May
2016/03/23 19:22:57
Looks fine to me. See video:
https://drive.google.
newt (away)
2016/03/24 19:47:38
This code is still needed.
See https://gerrit-int
|
| - // To avoid odd jumps during NTP animation transitions, we do not attempt to give focus |
| - // to child views if this scroll view already has focus. |
| - if (hasFocus()) return; |
| - super.focusableViewAvailable(v); |
| - } |
| - |
| - @Override |
| - public boolean executeKeyEvent(KeyEvent event) { |
| - // Ignore all key events except arrow keys and spacebar. Otherwise, the ScrollView consumes |
| - // unwanted events (including the hardware menu button and app-level keyboard shortcuts). |
| - // http://crbug.com/308322 |
| - switch (event.getKeyCode()) { |
| - case KeyEvent.KEYCODE_DPAD_UP: |
| - case KeyEvent.KEYCODE_DPAD_DOWN: |
| - case KeyEvent.KEYCODE_SPACE: |
| - return super.executeKeyEvent(event); |
| - default: |
| - return false; |
| - } |
| - } |
| - |
| - @Override |
| public InputConnection onCreateInputConnection(EditorInfo outAttrs) { |
| // Fixes lanscape transitions when unfocusing the URL bar: crbug.com/288546 |
| outAttrs.imeOptions = EditorInfo.IME_FLAG_NO_FULLSCREEN; |
| @@ -173,8 +130,8 @@ public class NewTabScrollView extends ScrollView { |
| float shadowStrength = getBottomFadingEdgeStrength(); |
| float shadowHeight = getVerticalFadingEdgeLength(); |
| setVerticalFadingEdgeEnabled(false); |
| - mFadingShadow.drawShadow(this, canvas, FadingShadow.POSITION_BOTTOM, |
| - shadowHeight, shadowStrength); |
| + mFadingShadow.drawShadow( |
| + this, canvas, FadingShadow.POSITION_BOTTOM, shadowHeight, shadowStrength); |
| } |
| } |
| } |