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

Commit 086c6fc0 authored by Lucas Dupin's avatar Lucas Dupin
Browse files

Let launcher modify window corner radius

Test: Manualy launch an app
Test: Press home when activity is on top of the stack
Test: Quick scrub
Test: Swipe up on the home button, swipe down
Test: Tap on notification on the shade
Test: atest ActivityLaunchAnimatorTest
Bug: 111514493
Change-Id: Ib7e29e7e07bf2a245ff949373af700b319e273fc
parent 298c49e4
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.Resources.Theme;
import android.content.res.TypedArray;
import android.graphics.Color;
+50 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 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
 */

package com.android.internal.policy;

import com.android.internal.R;

import android.content.res.Resources;

/**
 * Utility functions for screen decorations used by both window manager and System UI.
 */
public class ScreenDecorationsUtils {

    /**
     * Corner radius that should be used on windows in order to cover the display.
     * These values are expressed in pixels because they should not respect display or font
     * scaling, this means that we don't have to reload them on config changes.
     */
    public static float getWindowCornerRadius(Resources resources) {
        // Radius that should be used in case top or bottom aren't defined.
        float defaultRadius = resources.getDimension(R.dimen.rounded_corner_radius);

        float topRadius = resources.getDimension(R.dimen.rounded_corner_radius_top);
        if (topRadius == 0) {
            topRadius = defaultRadius;
        }
        float bottomRadius = resources.getDimension(R.dimen.rounded_corner_radius_bottom);
        if (bottomRadius == 0) {
            bottomRadius = defaultRadius;
        }

        // Always use the smallest radius to make sure the rounded corners will
        // completely cover the display.
        return Math.min(topRadius, bottomRadius);
    }
}
+4 −0
Original line number Diff line number Diff line
@@ -3501,4 +3501,8 @@
  <java-symbol type="string" name="config_defaultAssistantComponentName" />

  <java-symbol type="id" name="transition_overlay_view_tag" />

  <java-symbol type="dimen" name="rounded_corner_radius" />
  <java-symbol type="dimen" name="rounded_corner_radius_top" />
  <java-symbol type="dimen" name="rounded_corner_radius_bottom" />
</resources>
+5 −0
Original line number Diff line number Diff line
@@ -71,4 +71,9 @@ interface ISystemUiProxy {
     */
    void onStatusBarMotionEvent(in MotionEvent event) = 9;

    /**
     * Get the corner radius of windows in pixels.
     */
    float getWindowCornerRadius() = 10;

}
+4 −1
Original line number Diff line number Diff line
@@ -83,6 +83,7 @@ public class SyncRtSurfaceTransactionApplier {
        t.setWindowCrop(params.surface, params.windowCrop);
        t.setAlpha(params.surface, params.alpha);
        t.setLayer(params.surface, params.layer);
        t.setCornerRadius(params.surface, params.cornerRadius);
        t.show(params.surface);
    }

@@ -98,12 +99,13 @@ public class SyncRtSurfaceTransactionApplier {
         * @param windowCrop Crop to apply.
         */
        public SurfaceParams(SurfaceControlCompat surface, float alpha, Matrix matrix,
                Rect windowCrop, int layer) {
                Rect windowCrop, int layer, float cornerRadius) {
            this.surface = surface.mSurfaceControl;
            this.alpha = alpha;
            this.matrix = new Matrix(matrix);
            this.windowCrop = new Rect(windowCrop);
            this.layer = layer;
            this.cornerRadius = cornerRadius;
        }

        final SurfaceControl surface;
@@ -111,5 +113,6 @@ public class SyncRtSurfaceTransactionApplier {
        final Matrix matrix;
        final Rect windowCrop;
        final int layer;
        final float cornerRadius;
    }
}
Loading