Loading res/layout/accessibility_text_reading_preview.xml +2 −1 Original line number Diff line number Diff line Loading @@ -42,7 +42,8 @@ android:id="@+id/preview_pager" android:layout_width="match_parent" android:layout_height="217dp" android:contentDescription="@string/preview_pager_content_description" /> android:contentDescription="@string/preview_pager_content_description" android:nestedScrollingEnabled="true" /> <com.android.settings.widget.DotsPageIndicator android:id="@+id/page_indicator" Loading src/com/android/settings/accessibility/TextReadingPreviewPager.java +21 −9 Original line number Diff line number Diff line Loading @@ -18,8 +18,7 @@ package com.android.settings.accessibility; import android.content.Context; import android.util.AttributeSet; import android.view.MotionEvent; import android.view.ViewGroup; import android.view.View; import androidx.annotation.NonNull; import androidx.annotation.Nullable; Loading @@ -29,18 +28,31 @@ import androidx.viewpager.widget.ViewPager; * The view pager is used for displaying screen preview with different size configuration changes. */ public class TextReadingPreviewPager extends ViewPager { public TextReadingPreviewPager(@NonNull Context context, @Nullable AttributeSet attrs) { super(context, attrs); } @Override public boolean onInterceptTouchEvent(MotionEvent ev) { final ViewGroup parent = (ViewGroup) getParent(); if (parent != null) { // Avoid conflicting with the nested scroll view. parent.requestDisallowInterceptTouchEvent(true); public boolean onStartNestedScroll(View child, View target, int nestedScrollAxes) { return (nestedScrollAxes & View.SCROLL_AXIS_VERTICAL) != 0; } @Override public void onNestedScrollAccepted(View child, View target, int axes) { super.onNestedScrollAccepted(child, target, axes); // Allow the nested scrollview inside of the view pager to be scrollable. getParent().requestDisallowInterceptTouchEvent(true); } return super.onInterceptTouchEvent(ev); @Override public void onNestedScroll( View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed) { if (dyUnconsumed != 0) { // Assume dyUnconsumed != 0 means the target has been scrolled to the end vertically. // We could let the parent to consume the rest of the dyUnconsumed getParent().requestDisallowInterceptTouchEvent(false); } super.onNestedScroll(target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed); } } Loading
res/layout/accessibility_text_reading_preview.xml +2 −1 Original line number Diff line number Diff line Loading @@ -42,7 +42,8 @@ android:id="@+id/preview_pager" android:layout_width="match_parent" android:layout_height="217dp" android:contentDescription="@string/preview_pager_content_description" /> android:contentDescription="@string/preview_pager_content_description" android:nestedScrollingEnabled="true" /> <com.android.settings.widget.DotsPageIndicator android:id="@+id/page_indicator" Loading
src/com/android/settings/accessibility/TextReadingPreviewPager.java +21 −9 Original line number Diff line number Diff line Loading @@ -18,8 +18,7 @@ package com.android.settings.accessibility; import android.content.Context; import android.util.AttributeSet; import android.view.MotionEvent; import android.view.ViewGroup; import android.view.View; import androidx.annotation.NonNull; import androidx.annotation.Nullable; Loading @@ -29,18 +28,31 @@ import androidx.viewpager.widget.ViewPager; * The view pager is used for displaying screen preview with different size configuration changes. */ public class TextReadingPreviewPager extends ViewPager { public TextReadingPreviewPager(@NonNull Context context, @Nullable AttributeSet attrs) { super(context, attrs); } @Override public boolean onInterceptTouchEvent(MotionEvent ev) { final ViewGroup parent = (ViewGroup) getParent(); if (parent != null) { // Avoid conflicting with the nested scroll view. parent.requestDisallowInterceptTouchEvent(true); public boolean onStartNestedScroll(View child, View target, int nestedScrollAxes) { return (nestedScrollAxes & View.SCROLL_AXIS_VERTICAL) != 0; } @Override public void onNestedScrollAccepted(View child, View target, int axes) { super.onNestedScrollAccepted(child, target, axes); // Allow the nested scrollview inside of the view pager to be scrollable. getParent().requestDisallowInterceptTouchEvent(true); } return super.onInterceptTouchEvent(ev); @Override public void onNestedScroll( View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed) { if (dyUnconsumed != 0) { // Assume dyUnconsumed != 0 means the target has been scrolled to the end vertically. // We could let the parent to consume the rest of the dyUnconsumed getParent().requestDisallowInterceptTouchEvent(false); } super.onNestedScroll(target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed); } }