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

Commit 9a5505f0 authored by Daniel Sandler's avatar Daniel Sandler Committed by Android (Google) Code Review
Browse files

Merge "Fix drawing artifacts on glowing navigation buttons."

parents 351eb33d 96f4818e
Loading
Loading
Loading
Loading
+9 −10
Original line number Diff line number Diff line
@@ -44,24 +44,23 @@
                />

            <!-- navigation controls -->
            <com.android.systemui.statusbar.policy.KeyButtonView android:id="@+id/back"
                android:layout_width="80dip"
                android:layout_height="match_parent"
                android:src="@drawable/ic_sysbar_back"
                android:layout_alignParentLeft="true"
                systemui:keyCode="4"
                android:contentDescription="@string/accessibility_back"
                systemui:glowBackground="@drawable/ic_sysbar_highlight"
                />
            <LinearLayout
                android:id="@+id/navigationArea"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_toRightOf="@+id/back"
                android:layout_alignParentLeft="true"
                android:orientation="horizontal"
                android:clipChildren="false"
                android:clipToPadding="false"
                >
                <com.android.systemui.statusbar.policy.KeyButtonView android:id="@+id/back"
                    android:layout_width="80dip"
                    android:layout_height="match_parent"
                    android:src="@drawable/ic_sysbar_back"
                    systemui:keyCode="4"
                    android:contentDescription="@string/accessibility_back"
                    systemui:glowBackground="@drawable/ic_sysbar_highlight"
                    />
                <com.android.systemui.statusbar.policy.KeyButtonView android:id="@+id/home"
                    android:layout_width="80dip"
                    android:layout_height="match_parent"
+2 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@
            android:orientation="horizontal"
            android:clipChildren="false"
            android:clipToPadding="false"
            android:id="@+id/nav_buttons"
            >

            <!-- navigation controls -->
@@ -119,6 +120,7 @@
            android:orientation="vertical"
            android:clipChildren="false"
            android:clipToPadding="false"
            android:id="@+id/nav_buttons"
            >
            
            <!-- navigation controls -->
+2 −2
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ import android.view.View;

public class SwipeHelper {
    static final String TAG = "com.android.systemui.SwipeHelper";
    private static final boolean DEBUG = true;
    private static final boolean DEBUG = false;
    private static final boolean DEBUG_INVALIDATE = false;
    private static final boolean SLOW_ANIMATIONS = false; // DEBUG;

@@ -142,7 +142,7 @@ public class SwipeHelper {
    // invalidate a rectangle relative to the view's coordinate system all the way up the view
    // hierarchy
    public static void invalidateGlobalRegion(View view, RectF childBounds) {
        childBounds.offset(view.getX(), view.getY());
        //childBounds.offset(view.getTranslationX(), view.getTranslationY());
        if (DEBUG_INVALIDATE)
            Log.v(TAG, "-------------");
        while (view.getParent() != null && view.getParent() instanceof View) {
+7 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.view.Display;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.Surface;
import android.view.WindowManager;
import android.widget.LinearLayout;
@@ -67,6 +68,7 @@ public class NavigationBarView extends LinearLayout {

    public NavigationBarView(Context context, AttributeSet attrs) {
        super(context, attrs);

        mHidden = false;

        mDisplay = ((WindowManager)context.getSystemService(
@@ -129,6 +131,11 @@ public class NavigationBarView extends LinearLayout {
                                                ? findViewById(R.id.rot90)
                                                : findViewById(R.id.rot270);

        for (View v : mRotatedViews) {
            // this helps avoid drawing artifacts with glowing navigation keys 
            ViewGroup group = (ViewGroup) v.findViewById(R.id.nav_buttons);
            group.setMotionEventSplittingEnabled(false);
        }
        mCurrentView = mRotatedViews[Surface.ROTATION_0];
    }

+11 −4
Original line number Diff line number Diff line
@@ -49,6 +49,8 @@ import com.android.systemui.R;
public class KeyButtonView extends ImageView {
    private static final String TAG = "StatusBar.KeyButtonView";

    final float GLOW_MAX_SCALE_FACTOR = 1.8f;

    IWindowManager mWindowManager;
    long mDownTime;
    boolean mSending;
@@ -159,17 +161,22 @@ public class KeyButtonView extends ImageView {
        mGlowScale = x;
        final float w = getWidth();
        final float h = getHeight();
        if (x < 1.0f) {
        if (GLOW_MAX_SCALE_FACTOR <= 1.0f) {
            // this only works if we know the glow will never leave our bounds
            invalidate();
        } else {
            final float rx = (w * (x - 1.0f)) / 2.0f;
            final float ry = (h * (x - 1.0f)) / 2.0f;
            final float rx = (w * (GLOW_MAX_SCALE_FACTOR - 1.0f)) / 2.0f + 1.0f;
            final float ry = (h * (GLOW_MAX_SCALE_FACTOR - 1.0f)) / 2.0f + 1.0f;
            com.android.systemui.SwipeHelper.invalidateGlobalRegion(
                    this,
                    new RectF(getLeft() - rx,
                              getTop() - ry,
                              getRight() + rx,
                              getBottom() + ry));

            // also invalidate our immediate parent to help avoid situations where nearby glows
            // interfere
            ((View)getParent()).invalidate();
        }
    }

@@ -183,7 +190,7 @@ public class KeyButtonView extends ImageView {
                    setDrawingAlpha(1f);
                    as.playTogether(
                        ObjectAnimator.ofFloat(this, "glowAlpha", 1f),
                        ObjectAnimator.ofFloat(this, "glowScale", 1.8f)
                        ObjectAnimator.ofFloat(this, "glowScale", GLOW_MAX_SCALE_FACTOR)
                    );
                    as.setDuration(50);
                } else {
Loading