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

Commit 9fa01739 authored by Todd Lee's avatar Todd Lee
Browse files

Adjust splash screen icon sizes for Wear

This change moves some constant factors which are used
to determine sizing/scaling behaviour on splash screens
from inline declarations to overlayable resources that
can be customized to suit respective form factors.

Bug: b/278274396
Bug: b/277059561
Test: manual launch of splash screen apps

Change-Id: I8f04e4007d94dbd9113b3f0fdd7036bfb51bbd9b
parent cb7951b3
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
    Copyright (C) 2020 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.
-->
<resources>
    <!-- The acceptable area ratio of fg icon area/bg icon area, i.e. (48 X 48) / (72 x 72) -->
    <item type="dimen" format="float" name="splash_icon_enlarge_foreground_threshold">0.44</item>
    <!-- Scaling factor applied to splash icons without provided background i.e. (60 / 48) -->
    <item type="dimen" format="float" name="splash_icon_no_background_scale_factor">1.25</item>
</resources>
+5 −0
Original line number Diff line number Diff line
@@ -423,4 +423,9 @@
    <!-- The height of the area at the top of the screen where a freeform task will transition to
    fullscreen if dragged until the top bound of the task is within the area. -->
    <dimen name="desktop_mode_transition_area_height">16dp</dimen>

    <!-- The acceptable area ratio of fg icon area/bg icon area, i.e. (72 x 72) / (108 x 108) -->
    <item type="dimen" format="float" name="splash_icon_enlarge_foreground_threshold">0.44</item>
    <!-- Scaling factor applied to splash icons without provided background i.e. (192 / 160) -->
    <item type="dimen" format="float" name="splash_icon_no_background_scale_factor">1.2</item>
</resources>
+10 −19
Original line number Diff line number Diff line
@@ -112,28 +112,15 @@ public class SplashscreenContentDrawer {
     */
    static final long MAX_ANIMATION_DURATION = MINIMAL_ANIMATION_DURATION + TIME_WINDOW_DURATION;

    // The acceptable area ratio of foreground_icon_area/background_icon_area, if there is an
    // icon which it's non-transparent foreground area is similar to it's background area, then
    // do not enlarge the foreground drawable.
    // For example, an icon with the foreground 108*108 opaque pixels and it's background
    // also 108*108 pixels, then do not enlarge this icon if only need to show foreground icon.
    private static final float ENLARGE_FOREGROUND_ICON_THRESHOLD = (72f * 72f) / (108f * 108f);

    /**
     * If the developer doesn't specify a background for the icon, we slightly scale it up.
     *
     * The background is either manually specified in the theme or the Adaptive Icon
     * background is used if it's different from the window background.
     */
    private static final float NO_BACKGROUND_SCALE = 192f / 160;
    private final Context mContext;
    private final HighResIconProvider mHighResIconProvider;

    private int mIconSize;
    private int mDefaultIconSize;
    private int mBrandingImageWidth;
    private int mBrandingImageHeight;
    private int mMainWindowShiftLength;
    private float mEnlargeForegroundIconThreshold;
    private float mNoBackgroundScale;
    private int mLastPackageContextConfigHash;
    private final TransactionPool mTransactionPool;
    private final SplashScreenWindowAttrs mTmpAttrs = new SplashScreenWindowAttrs();
@@ -336,6 +323,10 @@ public class SplashscreenContentDrawer {
                com.android.wm.shell.R.dimen.starting_surface_brand_image_height);
        mMainWindowShiftLength = mContext.getResources().getDimensionPixelSize(
                com.android.wm.shell.R.dimen.starting_surface_exit_animation_window_shift_length);
        mEnlargeForegroundIconThreshold = mContext.getResources().getFloat(
                com.android.wm.shell.R.dimen.splash_icon_enlarge_foreground_threshold);
        mNoBackgroundScale = mContext.getResources().getFloat(
                com.android.wm.shell.R.dimen.splash_icon_no_background_scale_factor);
    }

    /**
@@ -604,14 +595,14 @@ public class SplashscreenContentDrawer {
                // There is no background below the icon, so scale the icon up
                if (mTmpAttrs.mIconBgColor == Color.TRANSPARENT
                        || mTmpAttrs.mIconBgColor == mThemeColor) {
                    mFinalIconSize *= NO_BACKGROUND_SCALE;
                    mFinalIconSize *= mNoBackgroundScale;
                }
                createIconDrawable(iconDrawable, false /* legacy */, false /* loadInDetail */);
            } else {
                final float iconScale = (float) mIconSize / (float) mDefaultIconSize;
                final int densityDpi = mContext.getResources().getConfiguration().densityDpi;
                final int scaledIconDpi =
                        (int) (0.5f + iconScale * densityDpi * NO_BACKGROUND_SCALE);
                        (int) (0.5f + iconScale * densityDpi * mNoBackgroundScale);
                Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "getIcon");
                iconDrawable = mHighResIconProvider.getIcon(
                        mActivityInfo, densityDpi, scaledIconDpi);
@@ -693,8 +684,8 @@ public class SplashscreenContentDrawer {
                // Reference AdaptiveIcon description, outer is 108 and inner is 72, so we
                // scale by 192/160 if we only draw adaptiveIcon's foreground.
                final float noBgScale =
                        iconColor.mFgNonTranslucentRatio < ENLARGE_FOREGROUND_ICON_THRESHOLD
                                ? NO_BACKGROUND_SCALE : 1f;
                        iconColor.mFgNonTranslucentRatio < mEnlargeForegroundIconThreshold
                                ? mNoBackgroundScale : 1f;
                // Using AdaptiveIconDrawable here can help keep the shape consistent with the
                // current settings.
                mFinalIconSize = (int) (0.5f + mIconSize * noBgScale);