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

Commit f68ab266 authored by Andrii Kulian's avatar Andrii Kulian Committed by Automerger Merge Worker
Browse files

Merge "Report bounds instead of size in WindowMetrics" into rvc-dev am:...

Merge "Report bounds instead of size in WindowMetrics" into rvc-dev am: 363edf44 am: f8bb4fef am: 7e9a4c2f

Change-Id: I83bbc0144791a6ed63df16d689a060e6c116b6d2
parents 38b51544 7e9a4c2f
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -55767,8 +55767,8 @@ package android.view {
  }
  public final class WindowMetrics {
    ctor public WindowMetrics(@NonNull android.util.Size, @NonNull android.view.WindowInsets);
    method @NonNull public android.util.Size getSize();
    ctor public WindowMetrics(@NonNull android.graphics.Rect, @NonNull android.view.WindowInsets);
    method @NonNull public android.graphics.Rect getBounds();
    method @NonNull public android.view.WindowInsets getWindowInsets();
  }
+2 −3
Original line number Diff line number Diff line
@@ -60,7 +60,6 @@ import android.text.method.MovementMethod;
import android.util.Log;
import android.util.PrintWriterPrinter;
import android.util.Printer;
import android.util.Size;
import android.view.Gravity;
import android.view.KeyCharacterMap;
import android.view.KeyEvent;
@@ -1480,8 +1479,8 @@ public class InputMethodService extends AbstractInputMethodService {
     */
    public int getMaxWidth() {
        final WindowManager windowManager = getSystemService(WindowManager.class);
        final Size windowSize = windowManager.getCurrentWindowMetrics().getSize();
        return windowSize.getWidth();
        final Rect windowBounds = windowManager.getCurrentWindowMetrics().getBounds();
        return windowBounds.width();
    }
    
    /**
+7 −7
Original line number Diff line number Diff line
@@ -57,8 +57,8 @@ import java.util.List;
 * <li>The application display area specifies the part of the display that may contain
 * an application window, excluding the system decorations.  The application display area may
 * be smaller than the real display area because the system subtracts the space needed
 * for decor elements such as the status bar.  Use {@link WindowMetrics#getSize()} to query the
 * application window size.</li>
 * for decor elements such as the status bar.  Use {@link WindowMetrics#getBounds()} to query the
 * application window bounds.</li>
 * <li>The real display area specifies the part of the display that contains content
 * including the system decorations.  Even so, the real display area may be smaller than the
 * physical size of the display if the window manager is emulating a smaller display
@@ -673,7 +673,7 @@ public final class Display {
     *
     * @param outSize A {@link Point} object to receive the size information.
     * @deprecated Use {@link WindowManager#getCurrentWindowMetrics()} to obtain an instance of
     * {@link WindowMetrics} and use {@link WindowMetrics#getSize()} instead.
     * {@link WindowMetrics} and use {@link WindowMetrics#getBounds()} instead.
     */
    @Deprecated
    public void getSize(Point outSize) {
@@ -689,7 +689,7 @@ public final class Display {
     * Gets the size of the display as a rectangle, in pixels.
     *
     * @param outSize A {@link Rect} object to receive the size information.
     * @deprecated Use {@link WindowMetrics#getSize()} to get the dimensions of the application
     * @deprecated Use {@link WindowMetrics#getBounds()} to get the dimensions of the application
     * window area.
     */
    @Deprecated
@@ -755,7 +755,7 @@ public final class Display {
    }

    /**
     * @deprecated Use {@link WindowMetrics#getSize()} instead.
     * @deprecated Use {@link WindowMetrics#getBounds#width()} instead.
     */
    @Deprecated
    public int getWidth() {
@@ -766,7 +766,7 @@ public final class Display {
    }

    /**
     * @deprecated Use {@link WindowMetrics#getSize()} instead.
     * @deprecated Use {@link WindowMetrics#getBounds()#height()} instead.
     */
    @Deprecated
    public int getHeight() {
@@ -1105,7 +1105,7 @@ public final class Display {
     * </p>
     *
     * @param outMetrics A {@link DisplayMetrics} object to receive the metrics.
     * @deprecated Use {@link WindowMetrics#getSize()} to get the dimensions of the application
     * @deprecated Use {@link WindowMetrics#getBounds()} to get the dimensions of the application
     * window area, and {@link Configuration#densityDpi} to get the current density.
     */
    @Deprecated
+3 −3
Original line number Diff line number Diff line
@@ -23,11 +23,11 @@ import android.compat.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Rect;
import android.os.Build;
import android.os.RemoteException;
import android.provider.Settings;
import android.util.DisplayMetrics;
import android.util.Size;
import android.util.SparseArray;
import android.util.TypedValue;

@@ -410,8 +410,8 @@ public class ViewConfiguration {

        // Size of the screen in bytes, in ARGB_8888 format
        final WindowManager windowManager = context.getSystemService(WindowManager.class);
        final Size maxWindowSize = windowManager.getMaximumWindowMetrics().getSize();
        mMaximumDrawingCacheSize = 4 * maxWindowSize.getWidth() * maxWindowSize.getHeight();
        final Rect maxWindowBounds = windowManager.getMaximumWindowMetrics().getBounds();
        mMaximumDrawingCacheSize = 4 * maxWindowBounds.width() * maxWindowBounds.height();

        mOverscrollDistance = (int) (sizeAndDensity * OVERSCROLL_DISTANCE + 0.5f);
        mOverflingDistance = (int) (sizeAndDensity * OVERFLING_DISTANCE + 0.5f);
+2 −7
Original line number Diff line number Diff line
@@ -35,7 +35,6 @@ import android.graphics.Region;
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Size;

import com.android.internal.os.IResultReceiver;

@@ -220,7 +219,7 @@ public final class WindowManagerImpl implements WindowManager {
        final Context context = mParentWindow != null ? mParentWindow.getContext() : mContext;
        final Rect bounds = getCurrentBounds(context);

        return new WindowMetrics(toSize(bounds), computeWindowInsets(bounds));
        return new WindowMetrics(bounds, computeWindowInsets(bounds));
    }

    private static Rect getCurrentBounds(Context context) {
@@ -232,11 +231,7 @@ public final class WindowManagerImpl implements WindowManager {
    @Override
    public WindowMetrics getMaximumWindowMetrics() {
        final Rect maxBounds = getMaximumBounds();
        return new WindowMetrics(toSize(maxBounds), computeWindowInsets(maxBounds));
    }

    private Size toSize(Rect frame) {
        return new Size(frame.width(), frame.height());
        return new WindowMetrics(maxBounds, computeWindowInsets(maxBounds));
    }

    private Rect getMaximumBounds() {
Loading