Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4a5938e9 authored by George Mount's avatar George Mount Committed by Android (Google) Code Review
Browse files

Merge "Fix ScrollView and HorizontalScrollView overscroll retraction" into main

parents 66dafd49 3bd8d8e9
Loading
Loading
Loading
Loading
+5 −0
Original line number Original line Diff line number Diff line
@@ -1498,6 +1498,11 @@ public class HorizontalScrollView extends FrameLayout {
     * @return The unconsumed delta after the EdgeEffects have had an opportunity to consume.
     * @return The unconsumed delta after the EdgeEffects have had an opportunity to consume.
     */
     */
    private int consumeFlingInStretch(int unconsumed) {
    private int consumeFlingInStretch(int unconsumed) {
        int scrollX = getScrollX();
        if (scrollX < 0 || scrollX > getScrollRange()) {
            // We've overscrolled, so don't stretch
            return unconsumed;
        }
        if (unconsumed > 0 && mEdgeGlowLeft != null && mEdgeGlowLeft.getDistance() != 0f) {
        if (unconsumed > 0 && mEdgeGlowLeft != null && mEdgeGlowLeft.getDistance() != 0f) {
            int size = getWidth();
            int size = getWidth();
            float deltaDistance = -unconsumed * FLING_DESTRETCH_FACTOR / size;
            float deltaDistance = -unconsumed * FLING_DESTRETCH_FACTOR / size;
+5 −0
Original line number Original line Diff line number Diff line
@@ -1566,6 +1566,11 @@ public class ScrollView extends FrameLayout {
     * @return The unconsumed delta after the EdgeEffects have had an opportunity to consume.
     * @return The unconsumed delta after the EdgeEffects have had an opportunity to consume.
     */
     */
    private int consumeFlingInStretch(int unconsumed) {
    private int consumeFlingInStretch(int unconsumed) {
        int scrollY = getScrollY();
        if (scrollY < 0 || scrollY > getScrollRange()) {
            // We've overscrolled, so don't stretch
            return unconsumed;
        }
        if (unconsumed > 0 && mEdgeGlowTop != null && mEdgeGlowTop.getDistance() != 0f) {
        if (unconsumed > 0 && mEdgeGlowTop != null && mEdgeGlowTop.getDistance() != 0f) {
            int size = getHeight();
            int size = getHeight();
            float deltaDistance = -unconsumed * FLING_DESTRETCH_FACTOR / size;
            float deltaDistance = -unconsumed * FLING_DESTRETCH_FACTOR / size;
+22 −0
Original line number Original line Diff line number Diff line
@@ -231,6 +231,28 @@
            </intent-filter>
            </intent-filter>
        </activity>
        </activity>


        <activity android:name="android.widget.HorizontalScrollViewActivity"
                android:label="HorizontalScrollViewActivity"
                android:screenOrientation="portrait"
                android:exported="true"
                android:theme="@android:style/Theme.Material.Light">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
            </intent-filter>
        </activity>

        <activity android:name="android.widget.ScrollViewActivity"
                android:label="ScrollViewActivity"
                android:screenOrientation="portrait"
                android:exported="true"
                android:theme="@android:style/Theme.Material.Light">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
            </intent-filter>
        </activity>

        <activity android:name="android.widget.DatePickerActivity"
        <activity android:name="android.widget.DatePickerActivity"
                android:label="DatePickerActivity"
                android:label="DatePickerActivity"
                android:screenOrientation="portrait"
                android:screenOrientation="portrait"
+118 −0
Original line number Original line Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?><!--
  ~ Copyright (C) 2015 The Android Open Source Project
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~      http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License
  -->

<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/horizontal_scroll_view">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <View
            android:background="#F00"
            android:layout_width="100dp"
            android:layout_height="100dp" />

        <View
            android:background="#880"
            android:layout_width="100dp"
            android:layout_height="100dp" />

        <View
            android:background="#0F0"
            android:layout_width="100dp"
            android:layout_height="100dp" />

        <View
            android:background="#088"
            android:layout_width="100dp"
            android:layout_height="100dp" />

        <View
            android:background="#00F"
            android:layout_width="100dp"
            android:layout_height="100dp" />

        <View
            android:background="#808"
            android:layout_width="100dp"
            android:layout_height="100dp" />

        <View
            android:background="#F00"
            android:layout_width="100dp"
            android:layout_height="100dp" />

        <View
            android:background="#880"
            android:layout_width="100dp"
            android:layout_height="100dp" />

        <View
            android:background="#0F0"
            android:layout_width="100dp"
            android:layout_height="100dp" />

        <View
            android:background="#088"
            android:layout_width="100dp"
            android:layout_height="100dp" />

        <View
            android:background="#00F"
            android:layout_width="100dp"
            android:layout_height="100dp" />

        <View
            android:background="#808"
            android:layout_width="100dp"
            android:layout_height="100dp" />

        <View
            android:background="#F00"
            android:layout_width="100dp"
            android:layout_height="100dp" />

        <View
            android:background="#880"
            android:layout_width="100dp"
            android:layout_height="100dp" />

        <View
            android:background="#0F0"
            android:layout_width="100dp"
            android:layout_height="100dp" />

        <View
            android:background="#088"
            android:layout_width="100dp"
            android:layout_height="100dp" />

        <View
            android:background="#00F"
            android:layout_width="100dp"
            android:layout_height="100dp" />

        <View
            android:background="#808"
            android:layout_width="100dp"
            android:layout_height="100dp" />

    </LinearLayout>
</HorizontalScrollView>
+118 −0
Original line number Original line Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?><!--
  ~ Copyright (C) 2015 The Android Open Source Project
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~      http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License
  -->

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/scroll_view">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <View
            android:background="#F00"
            android:layout_width="100dp"
            android:layout_height="100dp" />

        <View
            android:background="#880"
            android:layout_width="100dp"
            android:layout_height="100dp" />

        <View
            android:background="#0F0"
            android:layout_width="100dp"
            android:layout_height="100dp" />

        <View
            android:background="#088"
            android:layout_width="100dp"
            android:layout_height="100dp" />

        <View
            android:background="#00F"
            android:layout_width="100dp"
            android:layout_height="100dp" />

        <View
            android:background="#808"
            android:layout_width="100dp"
            android:layout_height="100dp" />

        <View
            android:background="#F00"
            android:layout_width="100dp"
            android:layout_height="100dp" />

        <View
            android:background="#880"
            android:layout_width="100dp"
            android:layout_height="100dp" />

        <View
            android:background="#0F0"
            android:layout_width="100dp"
            android:layout_height="100dp" />

        <View
            android:background="#088"
            android:layout_width="100dp"
            android:layout_height="100dp" />

        <View
            android:background="#00F"
            android:layout_width="100dp"
            android:layout_height="100dp" />

        <View
            android:background="#808"
            android:layout_width="100dp"
            android:layout_height="100dp" />

        <View
            android:background="#F00"
            android:layout_width="100dp"
            android:layout_height="100dp" />

        <View
            android:background="#880"
            android:layout_width="100dp"
            android:layout_height="100dp" />

        <View
            android:background="#0F0"
            android:layout_width="100dp"
            android:layout_height="100dp" />

        <View
            android:background="#088"
            android:layout_width="100dp"
            android:layout_height="100dp" />

        <View
            android:background="#00F"
            android:layout_width="100dp"
            android:layout_height="100dp" />

        <View
            android:background="#808"
            android:layout_width="100dp"
            android:layout_height="100dp" />

    </LinearLayout>
</ScrollView>
Loading