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

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

Merge "Subtract the navigation bar from DisplayMetrics."

parents ac0a0d06 36412a7e
Loading
Loading
Loading
Loading
+5 −1
Original line number Original line Diff line number Diff line
@@ -32,8 +32,12 @@
    <dimen name="toast_y_offset">64dip</dimen>
    <dimen name="toast_y_offset">64dip</dimen>
    <!-- Height of the status bar -->
    <!-- Height of the status bar -->
    <dimen name="status_bar_height">25dip</dimen>
    <dimen name="status_bar_height">25dip</dimen>
    <!-- Height of the system bar -->
    <!-- Height of the system bar (combined status + navigation, used on large screens) -->
    <dimen name="system_bar_height">48dip</dimen>
    <dimen name="system_bar_height">48dip</dimen>
    <!-- Height of the horizontal navigation bar on devices that require it -->
    <dimen name="navigation_bar_height">48dp</dimen>
    <!-- Width of the vertical navigation bar on devices that require it -->
    <dimen name="navigation_bar_width">42dp</dimen>
    <!-- Height of notification icons in the status bar -->
    <!-- Height of notification icons in the status bar -->
    <dimen name="status_bar_icon_size">24dip</dimen>
    <dimen name="status_bar_icon_size">24dip</dimen>
    <!-- Size of the giant number (unread count) in the notifications -->
    <!-- Size of the giant number (unread count) in the notifications -->
+1 −1
Original line number Original line Diff line number Diff line
@@ -17,7 +17,7 @@
-->
-->
<resources>
<resources>
    <!-- thickness (width) of the navigation bar on phones that require it -->
    <!-- thickness (width) of the navigation bar on phones that require it -->
    <dimen name="navigation_bar_size">42dp</dimen>
    <dimen name="navigation_bar_size">@*android:dimen/navigation_bar_width</dimen>


    <!-- Recent Applications parameters -->
    <!-- Recent Applications parameters -->
    <!-- Width of a recent app view, including all content -->
    <!-- Width of a recent app view, including all content -->
+1 −1
Original line number Original line Diff line number Diff line
@@ -40,7 +40,7 @@
    <dimen name="peek_window_y_offset">-12dp</dimen>
    <dimen name="peek_window_y_offset">-12dp</dimen>


    <!-- thickness (height) of the navigation bar on phones that require it -->
    <!-- thickness (height) of the navigation bar on phones that require it -->
    <dimen name="navigation_bar_size">48dp</dimen>
    <dimen name="navigation_bar_size">@*android:dimen/navigation_bar_height</dimen>


    <!-- thickness (height) of the dead zone at the top of the navigation bar,
    <!-- thickness (height) of the dead zone at the top of the navigation bar,
         reducing false presses on navbar buttons; approx 2mm -->
         reducing false presses on navbar buttons; approx 2mm -->
+1 −1
Original line number Original line Diff line number Diff line
@@ -112,7 +112,7 @@ public class NavigationBarView extends LinearLayout {
            public void onAnimationEnd(Animator _a) {
            public void onAnimationEnd(Animator _a) {
                mLastAnimator = null;
                mLastAnimator = null;
                if (hide) {
                if (hide) {
                    setVisibility(View.INVISIBLE);
                    setVisibility(View.GONE);
                }
                }
            }
            }
        });
        });
+36 −22
Original line number Original line Diff line number Diff line
@@ -42,6 +42,7 @@ import android.os.ServiceManager;
import android.os.SystemClock;
import android.os.SystemClock;
import android.provider.Settings;
import android.provider.Settings;
import android.text.TextUtils;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.util.Slog;
import android.util.Slog;
import android.util.Log;
import android.util.Log;
import android.view.Display;
import android.view.Display;
@@ -85,8 +86,8 @@ import com.android.systemui.statusbar.policy.NetworkController;


public class PhoneStatusBar extends StatusBar {
public class PhoneStatusBar extends StatusBar {
    static final String TAG = "PhoneStatusBar";
    static final String TAG = "PhoneStatusBar";
    static final boolean SPEW = false;
    public static final boolean DEBUG = false;
    public static final boolean DEBUG = false;
    public static final boolean SPEW = false;


    // additional instrumentation for testing purposes; intended to be left on during development
    // additional instrumentation for testing purposes; intended to be left on during development
    public static final boolean CHATTY = DEBUG || true;
    public static final boolean CHATTY = DEBUG || true;
@@ -201,11 +202,11 @@ public class PhoneStatusBar extends StatusBar {
    // tracking calls to View.setSystemUiVisibility()
    // tracking calls to View.setSystemUiVisibility()
    int mSystemUiVisibility = View.SYSTEM_UI_FLAG_VISIBLE;
    int mSystemUiVisibility = View.SYSTEM_UI_FLAG_VISIBLE;


    final Point mDisplaySize = new Point();
    DisplayMetrics mDisplayMetrics = new DisplayMetrics();


    private class ExpandedDialog extends Dialog {
    private class ExpandedDialog extends Dialog {
        ExpandedDialog(Context context) {
        ExpandedDialog(Context context) {
            super(context, com.android.internal.R.style.Theme_Light_NoTitleBar);
            super(context, com.android.internal.R.style.Theme_Translucent_NoTitleBar);
        }
        }


        @Override
        @Override
@@ -248,7 +249,12 @@ public class PhoneStatusBar extends StatusBar {


        Resources res = context.getResources();
        Resources res = context.getResources();


        mDisplay.getSize(mDisplaySize);
        mDisplay.getMetrics(mDisplayMetrics);
        if (DEBUG) {
            Slog.d(TAG, "makeStatusBarView: mDisplayMetrics=" + mDisplayMetrics);
            mDisplayMetrics = res.getDisplayMetrics();
            Slog.d(TAG, "makeStatusBarView: mDisplayMetrics2=" + mDisplayMetrics);
        }
        loadDimens();
        loadDimens();


        mIconSize = res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_icon_size);
        mIconSize = res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_icon_size);
@@ -1110,6 +1116,9 @@ public class PhoneStatusBar extends StatusBar {
        updateExpandedViewPos(EXPANDED_LEAVE_ALONE);
        updateExpandedViewPos(EXPANDED_LEAVE_ALONE);
        mExpandedParams.flags &= ~WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
        mExpandedParams.flags &= ~WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
        mExpandedParams.flags |= WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
        mExpandedParams.flags |= WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
        if (DEBUG) {
            Slog.d(TAG, "makeExpandedVisible: expanded params = " + mExpandedParams);
        }
        mExpandedDialog.getWindow().setAttributes(mExpandedParams);
        mExpandedDialog.getWindow().setAttributes(mExpandedParams);
        mExpandedView.requestFocus(View.FOCUS_FORWARD);
        mExpandedView.requestFocus(View.FOCUS_FORWARD);
        mTrackingView.setVisibility(View.VISIBLE);
        mTrackingView.setVisibility(View.VISIBLE);
@@ -1155,7 +1164,7 @@ public class PhoneStatusBar extends StatusBar {
        if (mAnimating) {
        if (mAnimating) {
            y = (int)mAnimY;
            y = (int)mAnimY;
        } else {
        } else {
            y = mDisplaySize.y-1;
            y = mDisplayMetrics.heightPixels-1;
        }
        }
        // Let the fling think that we're open so it goes in the right direction
        // Let the fling think that we're open so it goes in the right direction
        // and doesn't try to re-open the windowshade.
        // and doesn't try to re-open the windowshade.
@@ -1210,7 +1219,7 @@ public class PhoneStatusBar extends StatusBar {
            if (SPEW) Slog.d(TAG, "doAnimation before mAnimY=" + mAnimY);
            if (SPEW) Slog.d(TAG, "doAnimation before mAnimY=" + mAnimY);
            incrementAnim();
            incrementAnim();
            if (SPEW) Slog.d(TAG, "doAnimation after  mAnimY=" + mAnimY);
            if (SPEW) Slog.d(TAG, "doAnimation after  mAnimY=" + mAnimY);
            if (mAnimY >= mDisplaySize.y-1) {
            if (mAnimY >= mDisplayMetrics.heightPixels-1) {
                if (SPEW) Slog.d(TAG, "Animation completed to expanded state.");
                if (SPEW) Slog.d(TAG, "Animation completed to expanded state.");
                mAnimating = false;
                mAnimating = false;
                updateExpandedViewPos(EXPANDED_FULL_OPEN);
                updateExpandedViewPos(EXPANDED_FULL_OPEN);
@@ -1317,7 +1326,7 @@ public class PhoneStatusBar extends StatusBar {
        if (mExpanded) {
        if (mExpanded) {
            if (!always && (
            if (!always && (
                    vel > 200.0f
                    vel > 200.0f
                    || (y > (mDisplaySize.y-25) && vel > -200.0f))) {
                    || (y > (mDisplayMetrics.heightPixels-25) && vel > -200.0f))) {
                // We are expanded, but they didn't move sufficiently to cause
                // We are expanded, but they didn't move sufficiently to cause
                // us to retract.  Animate back to the expanded position.
                // us to retract.  Animate back to the expanded position.
                mAnimAccel = 2000.0f;
                mAnimAccel = 2000.0f;
@@ -1335,7 +1344,7 @@ public class PhoneStatusBar extends StatusBar {
        } else {
        } else {
            if (always || (
            if (always || (
                    vel > 200.0f
                    vel > 200.0f
                    || (y > (mDisplaySize.y/2) && vel > -200.0f))) {
                    || (y > (mDisplayMetrics.heightPixels/2) && vel > -200.0f))) {
                // We are collapsed, and they moved enough to allow us to
                // We are collapsed, and they moved enough to allow us to
                // expand.  Animate in the notifications.
                // expand.  Animate in the notifications.
                mAnimAccel = 2000.0f;
                mAnimAccel = 2000.0f;
@@ -1393,14 +1402,14 @@ public class PhoneStatusBar extends StatusBar {
                mViewDelta = mAbsPos[1] + mTrackingView.getHeight() - y;
                mViewDelta = mAbsPos[1] + mTrackingView.getHeight() - y;
            }
            }
            if ((!mExpanded && y < hitSize) ||
            if ((!mExpanded && y < hitSize) ||
                    (mExpanded && y > (mDisplaySize.y-hitSize))) {
                    (mExpanded && y > (mDisplayMetrics.heightPixels-hitSize))) {


                // We drop events at the edge of the screen to make the windowshade come
                // We drop events at the edge of the screen to make the windowshade come
                // down by accident less, especially when pushing open a device with a keyboard
                // down by accident less, especially when pushing open a device with a keyboard
                // that rotates (like g1 and droid)
                // that rotates (like g1 and droid)
                int x = (int)event.getRawX();
                int x = (int)event.getRawX();
                final int edgeBorder = mEdgeBorder;
                final int edgeBorder = mEdgeBorder;
                if (x >= edgeBorder && x < mDisplaySize.x - edgeBorder) {
                if (x >= edgeBorder && x < mDisplayMetrics.widthPixels - edgeBorder) {
                    prepareTracking(y, !mExpanded);// opening if we're not already fully visible
                    prepareTracking(y, !mExpanded);// opening if we're not already fully visible
                    mVelocityTracker.addMovement(event);
                    mVelocityTracker.addMovement(event);
                }
                }
@@ -1641,7 +1650,7 @@ public class PhoneStatusBar extends StatusBar {
                    + " mAnimLastTime=" + mAnimLastTime);
                    + " mAnimLastTime=" + mAnimLastTime);
            pw.println("  mAnimatingReveal=" + mAnimatingReveal
            pw.println("  mAnimatingReveal=" + mAnimatingReveal
                    + " mViewDelta=" + mViewDelta);
                    + " mViewDelta=" + mViewDelta);
            pw.println("  mDisplaySize=" + mDisplaySize);
            pw.println("  mDisplayMetrics=" + mDisplayMetrics);
            pw.println("  mExpandedParams: " + mExpandedParams);
            pw.println("  mExpandedParams: " + mExpandedParams);
            pw.println("  mExpandedView: " + viewInfo(mExpandedView));
            pw.println("  mExpandedView: " + viewInfo(mExpandedView));
            pw.println("  mExpandedDialog: " + mExpandedDialog);
            pw.println("  mExpandedDialog: " + mExpandedDialog);
@@ -1717,7 +1726,8 @@ public class PhoneStatusBar extends StatusBar {
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT,
                WindowManager.LayoutParams.TYPE_STATUS_BAR_SUB_PANEL,
                WindowManager.LayoutParams.TYPE_STATUS_BAR_SUB_PANEL,
                WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
                0
                | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
                | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
                | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
                | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM,
                | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM,
                pixelFormat);
                pixelFormat);
@@ -1739,9 +1749,10 @@ public class PhoneStatusBar extends StatusBar {


        lp = mExpandedDialog.getWindow().getAttributes();
        lp = mExpandedDialog.getWindow().getAttributes();
        lp.x = 0;
        lp.x = 0;
        mTrackingPosition = lp.y = mDisplaySize.y; // sufficiently large negative
        mTrackingPosition = lp.y = mDisplayMetrics.heightPixels; // sufficiently large negative
        lp.type = WindowManager.LayoutParams.TYPE_STATUS_BAR_SUB_PANEL;
        lp.type = WindowManager.LayoutParams.TYPE_STATUS_BAR_SUB_PANEL;
        lp.flags = WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
        lp.flags = 0
                | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
                | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
                | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
                | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
                | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
                | WindowManager.LayoutParams.FLAG_DITHER
                | WindowManager.LayoutParams.FLAG_DITHER
@@ -1772,14 +1783,14 @@ public class PhoneStatusBar extends StatusBar {


    void updateExpandedInvisiblePosition() {
    void updateExpandedInvisiblePosition() {
        if (mTrackingView != null) {
        if (mTrackingView != null) {
            mTrackingPosition = -mDisplaySize.y;
            mTrackingPosition = -mDisplayMetrics.heightPixels;
            if (mTrackingParams != null) {
            if (mTrackingParams != null) {
                mTrackingParams.y = mTrackingPosition;
                mTrackingParams.y = mTrackingPosition;
                WindowManagerImpl.getDefault().updateViewLayout(mTrackingView, mTrackingParams);
                WindowManagerImpl.getDefault().updateViewLayout(mTrackingView, mTrackingParams);
            }
            }
        }
        }
        if (mExpandedParams != null) {
        if (mExpandedParams != null) {
            mExpandedParams.y = -mDisplaySize.y;
            mExpandedParams.y = -mDisplayMetrics.heightPixels;
            mExpandedDialog.getWindow().setAttributes(mExpandedParams);
            mExpandedDialog.getWindow().setAttributes(mExpandedParams);
        }
        }
    }
    }
@@ -1792,7 +1803,7 @@ public class PhoneStatusBar extends StatusBar {
        }
        }


        int h = mStatusBarView.getHeight();
        int h = mStatusBarView.getHeight();
        int disph = mDisplaySize.y;
        int disph = mDisplayMetrics.heightPixels;


        // If the expanded view is not visible, make sure they're still off screen.
        // If the expanded view is not visible, make sure they're still off screen.
        // Maybe the view was resized.
        // Maybe the view was resized.
@@ -1845,7 +1856,7 @@ public class PhoneStatusBar extends StatusBar {
                // If the tracking view is not yet visible, then we can't have
                // If the tracking view is not yet visible, then we can't have
                // a good value of the close view location.  We need to wait for
                // a good value of the close view location.  We need to wait for
                // it to be visible to do a layout.
                // it to be visible to do a layout.
                mExpandedParams.y = -mDisplaySize.y;
                mExpandedParams.y = -mDisplayMetrics.heightPixels;
            }
            }
            int max = h;
            int max = h;
            if (mExpandedParams.y > max) {
            if (mExpandedParams.y > max) {
@@ -1891,7 +1902,10 @@ public class PhoneStatusBar extends StatusBar {
    }
    }


    void updateDisplaySize() {
    void updateDisplaySize() {
        mDisplay.getSize(mDisplaySize);
        mDisplay.getMetrics(mDisplayMetrics);
        if (DEBUG) {
            Slog.d(TAG, "updateDisplaySize: " + mDisplayMetrics);
        }
        updateExpandedSize();
        updateExpandedSize();
    }
    }


@@ -1899,9 +1913,9 @@ public class PhoneStatusBar extends StatusBar {
        if (DEBUG) {
        if (DEBUG) {
            Slog.d(TAG, "updateExpandedSize()");
            Slog.d(TAG, "updateExpandedSize()");
        }
        }
        if (mExpandedDialog != null && mExpandedParams != null && mDisplaySize != null) {
        if (mExpandedDialog != null && mExpandedParams != null && mDisplayMetrics != null) {
            mExpandedParams.width = mDisplaySize.x;
            mExpandedParams.width = mDisplayMetrics.widthPixels;
            mExpandedParams.height = getExpandedHeight(mDisplaySize.y);
            mExpandedParams.height = getExpandedHeight(mDisplayMetrics.heightPixels);
            if (!mExpandedVisible) {
            if (!mExpandedVisible) {
                updateExpandedInvisiblePosition();
                updateExpandedInvisiblePosition();
            } else {
            } else {
Loading