Prevent scrollView to scroll with dpad when scrollEnabled property is set to false. (#25309)
Summary: ScrollView doesn't handle the scrollEnabled property using dpad. When set to false, the directionnal pad still allows to scroll in the view. ## Changelog [ANDROID] [ADDED] - Prevent scrollView to scroll with dpad when scrollEnabled property is set to false. Pull Request resolved: https://github.com/facebook/react-native/pull/25309 Test Plan: Add P67680731 to Playground.js and start the Catalyst Android app: ```buck install -r catalyst``` Send the following adb commands to the device/emulator: ```adb shell input keyevent DPAD_RIGHT_LEFT``` ```adb shell input keyevent DPAD_RIGHT_RIGHT``` Make sure the ScrollView doesn't scroll to the left and right. Add ```horizontal={true}``` to ScrollView and send the following adb commands to the device/emulator: ```adb shell input keyevent DPAD_RIGHT_TOP``` ```adb shell input keyevent DPAD_RIGHT_BOTTOM``` Make sure the ScrollView doesn't scroll to the top and bottom. Reviewed By: mdvacca Differential Revision: D15983785 Pulled By: makovkastar fbshipit-source-id: 678cc801a168531d71c8651b986c99ecd9da400e
This commit is contained in:
Родитель
01d0cd540c
Коммит
00c8b3cd09
|
@ -18,6 +18,7 @@ import android.hardware.SensorManager;
|
||||||
import androidx.core.view.ViewCompat;
|
import androidx.core.view.ViewCompat;
|
||||||
import androidx.core.text.TextUtilsCompat;
|
import androidx.core.text.TextUtilsCompat;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.KeyEvent;
|
||||||
import android.view.FocusFinder;
|
import android.view.FocusFinder;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -411,6 +412,16 @@ public class ReactHorizontalScrollView extends HorizontalScrollView implements
|
||||||
return super.onTouchEvent(ev);
|
return super.onTouchEvent(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean executeKeyEvent(KeyEvent event) {
|
||||||
|
int eventKeyCode = event.getKeyCode();
|
||||||
|
if (!mScrollEnabled && (eventKeyCode == KeyEvent.KEYCODE_DPAD_LEFT ||
|
||||||
|
eventKeyCode == KeyEvent.KEYCODE_DPAD_RIGHT)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return super.executeKeyEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fling(int velocityX) {
|
public void fling(int velocityX) {
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ import android.graphics.drawable.ColorDrawable;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import androidx.core.view.ViewCompat;
|
import androidx.core.view.ViewCompat;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.KeyEvent;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
@ -300,6 +301,16 @@ public class ReactScrollView extends ScrollView implements ReactClippingViewGrou
|
||||||
return super.onTouchEvent(ev);
|
return super.onTouchEvent(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean executeKeyEvent(KeyEvent event) {
|
||||||
|
int eventKeyCode = event.getKeyCode();
|
||||||
|
if (!mScrollEnabled && (eventKeyCode == KeyEvent.KEYCODE_DPAD_UP ||
|
||||||
|
eventKeyCode == KeyEvent.KEYCODE_DPAD_DOWN)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return super.executeKeyEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setRemoveClippedSubviews(boolean removeClippedSubviews) {
|
public void setRemoveClippedSubviews(boolean removeClippedSubviews) {
|
||||||
if (removeClippedSubviews && mClippingRect == null) {
|
if (removeClippedSubviews && mClippingRect == null) {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче