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

Commit 2275f935 authored by Ankit Verma's avatar Ankit Verma Committed by ktanojo
Browse files

Applying Fading and Scaling animation to ViewGroupFader

To add polish to the scrolling experience in ViewGroupFader, this
change adds fading and scaling. See bug for more details.
Note that, the ViewGroupFader is currently used for use cases in
Wear OS, so the impact of this change will be limited to to Wear
devices.

Bug: 348515581
Change-Id: I2415bc9597711b2af2602c154b289c4f1e2f790a
parent 6043d7c2
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
package: "android.widget.flags"
container: "system"
flag {
  name: "enable_fading_view_group"
  namespace: "system_performance"
  description: "FRP screen during OOBE must have fading and scaling animation in Wear Watches"
  bug: "348515581"
  metadata {
      purpose: PURPOSE_BUGFIX
    }
}
 No newline at end of file
+16 −7
Original line number Diff line number Diff line
@@ -16,12 +16,14 @@

package com.android.internal.widget;

import android.content.res.Resources;
import android.graphics.Rect;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.MarginLayoutParams;
import android.view.animation.BaseInterpolator;
import android.view.animation.PathInterpolator;
import android.widget.flags.Flags;

/**
 * This class is ported from
@@ -36,7 +38,7 @@ import android.view.animation.PathInterpolator;
 * height of the child. When not in the top or bottom regions, children have their default alpha and
 * scale.
 */
class ViewGroupFader {
public class ViewGroupFader {

    private static final float SCALE_LOWER_BOUND = 0.7f;
    private float mScaleLowerBound = SCALE_LOWER_BOUND;
@@ -68,7 +70,7 @@ class ViewGroupFader {
    private BaseInterpolator mBottomInterpolator = new PathInterpolator(0.3f, 0f, 0.7f, 1f);

    /** Callback which is called when attempting to fade a view. */
    interface AnimationCallback {
    public interface AnimationCallback {
        boolean shouldFadeFromTop(View view);

        boolean shouldFadeFromBottom(View view);
@@ -82,7 +84,7 @@ class ViewGroupFader {
     * of the current position.
     */
    // TODO(b/182846214): Clean up the interface design to avoid exposing too much details to users.
    interface ChildViewBoundsProvider {
    public interface ChildViewBoundsProvider {
        /**
         * Provide the bounds of the child view.
         *
@@ -168,7 +170,7 @@ class ViewGroupFader {
        }
    }

    ViewGroupFader(
    public ViewGroupFader(
            ViewGroup parent,
            AnimationCallback callback,
            ChildViewBoundsProvider childViewBoundsProvider) {
@@ -212,7 +214,7 @@ class ViewGroupFader {
        this.mContainerBoundsProvider = boundsProvider;
    }

    void updateFade() {
    public void updateFade() {
        mContainerBoundsProvider.provideBounds(mParent, mContainerBounds);
        mTopBoundPixels = mContainerBounds.height() * mChainedBoundsTop;
        mBottomBoundPixels = mContainerBounds.height() * mChainedBoundsBottom;
@@ -221,13 +223,20 @@ class ViewGroupFader {
    }

    /** For each list element, calculate and adjust the scale and alpha based on its position */
    private void updateListElementFades(ViewGroup parent, boolean shouldFade) {
    public void updateListElementFades(ViewGroup parent, boolean shouldFade) {
        for (int i = 0; i < parent.getChildCount(); i++) {
            View child = parent.getChildAt(i);
            if (child.getVisibility() != View.VISIBLE) {
                continue;
            }

            if (Flags.enableFadingViewGroup() && Resources.getSystem().getBoolean(
                    com.android.internal.R.bool.config_enableViewGroupScalingFading)) {
                if (child instanceof ViewGroup) {
                    updateListElementFades((ViewGroup) child, true);
                }
            }

            if (shouldFade) {
                fadeElement(parent, child);
            }
+4 −0
Original line number Diff line number Diff line
@@ -96,4 +96,8 @@

    <!-- True if the device supports system decorations on secondary displays. -->
    <bool name="config_supportsSystemDecorsOnSecondaryDisplays">false</bool>

    <!-- Whether to enable scaling and fading animation to scrollviews while scrolling.
         P.S this is a change only intended for wear devices. -->
    <bool name="config_enableViewGroupScalingFading">true</bool>
</resources>
+4 −0
Original line number Diff line number Diff line
@@ -7121,4 +7121,8 @@
    <!-- The maximum number of call log entries for each sim card that can be stored in the call log
         provider on the device. -->
    <integer name="config_maximumCallLogEntriesPerSim">500</integer>

    <!-- Whether to enable scaling and fading animation to scrollviews while scrolling.
         P.S this is a change only intended for wear devices. -->
    <bool name="config_enableViewGroupScalingFading">false</bool>
</resources>
+2 −0
Original line number Diff line number Diff line
@@ -5601,4 +5601,6 @@

  <!-- Fingerprint loe notification string -->
  <java-symbol type="string" name="fingerprint_loe_notification_msg" />

  <java-symbol type="bool" name="config_enableViewGroupScalingFading"/>
</resources>
Loading