Merge "Use the current dimensions instead of relying on onConfigurationChanged" into sc-v2-dev
This commit is contained in:
@@ -270,8 +270,6 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
|
|||||||
private Drawable mCaptionBackgroundDrawable;
|
private Drawable mCaptionBackgroundDrawable;
|
||||||
private Drawable mUserCaptionBackgroundDrawable;
|
private Drawable mUserCaptionBackgroundDrawable;
|
||||||
|
|
||||||
private float mAvailableWidth;
|
|
||||||
|
|
||||||
String mLogTag = TAG;
|
String mLogTag = TAG;
|
||||||
private final Rect mFloatingInsets = new Rect();
|
private final Rect mFloatingInsets = new Rect();
|
||||||
private boolean mApplyFloatingVerticalInsets = false;
|
private boolean mApplyFloatingVerticalInsets = false;
|
||||||
@@ -315,8 +313,6 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
|
|||||||
mSemiTransparentBarColor = context.getResources().getColor(
|
mSemiTransparentBarColor = context.getResources().getColor(
|
||||||
R.color.system_bar_background_semi_transparent, null /* theme */);
|
R.color.system_bar_background_semi_transparent, null /* theme */);
|
||||||
|
|
||||||
updateAvailableWidth();
|
|
||||||
|
|
||||||
setWindow(window);
|
setWindow(window);
|
||||||
|
|
||||||
updateLogTag(params);
|
updateLogTag(params);
|
||||||
@@ -697,7 +693,8 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||||
final DisplayMetrics metrics = getContext().getResources().getDisplayMetrics();
|
final Resources res = getContext().getResources();
|
||||||
|
final DisplayMetrics metrics = res.getDisplayMetrics();
|
||||||
final boolean isPortrait =
|
final boolean isPortrait =
|
||||||
getResources().getConfiguration().orientation == ORIENTATION_PORTRAIT;
|
getResources().getConfiguration().orientation == ORIENTATION_PORTRAIT;
|
||||||
|
|
||||||
@@ -767,17 +764,19 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
|
|||||||
|
|
||||||
if (!fixedWidth && widthMode == AT_MOST) {
|
if (!fixedWidth && widthMode == AT_MOST) {
|
||||||
final TypedValue tv = isPortrait ? mWindow.mMinWidthMinor : mWindow.mMinWidthMajor;
|
final TypedValue tv = isPortrait ? mWindow.mMinWidthMinor : mWindow.mMinWidthMajor;
|
||||||
|
final float availableWidth = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
|
||||||
|
res.getConfiguration().screenWidthDp, metrics);
|
||||||
if (tv.type != TypedValue.TYPE_NULL) {
|
if (tv.type != TypedValue.TYPE_NULL) {
|
||||||
final int min;
|
final int min;
|
||||||
if (tv.type == TypedValue.TYPE_DIMENSION) {
|
if (tv.type == TypedValue.TYPE_DIMENSION) {
|
||||||
min = (int)tv.getDimension(metrics);
|
min = (int) tv.getDimension(metrics);
|
||||||
} else if (tv.type == TypedValue.TYPE_FRACTION) {
|
} else if (tv.type == TypedValue.TYPE_FRACTION) {
|
||||||
min = (int)tv.getFraction(mAvailableWidth, mAvailableWidth);
|
min = (int) tv.getFraction(availableWidth, availableWidth);
|
||||||
} else {
|
} else {
|
||||||
min = 0;
|
min = 0;
|
||||||
}
|
}
|
||||||
if (DEBUG_MEASURE) Log.d(mLogTag, "Adjust for min width: " + min + ", value::"
|
if (DEBUG_MEASURE) Log.d(mLogTag, "Adjust for min width: " + min + ", value::"
|
||||||
+ tv.coerceToString() + ", mAvailableWidth=" + mAvailableWidth);
|
+ tv.coerceToString() + ", mAvailableWidth=" + availableWidth);
|
||||||
|
|
||||||
if (width < min) {
|
if (width < min) {
|
||||||
widthMeasureSpec = MeasureSpec.makeMeasureSpec(min, EXACTLY);
|
widthMeasureSpec = MeasureSpec.makeMeasureSpec(min, EXACTLY);
|
||||||
@@ -2144,7 +2143,6 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
|
|||||||
|
|
||||||
updateDecorCaptionStatus(newConfig);
|
updateDecorCaptionStatus(newConfig);
|
||||||
|
|
||||||
updateAvailableWidth();
|
|
||||||
initializeElevation();
|
initializeElevation();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2616,12 +2614,6 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
|
|||||||
mLogTag = TAG + "[" + getTitleSuffix(params) + "]";
|
mLogTag = TAG + "[" + getTitleSuffix(params) + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateAvailableWidth() {
|
|
||||||
Resources res = getResources();
|
|
||||||
mAvailableWidth = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
|
|
||||||
res.getConfiguration().screenWidthDp, res.getDisplayMetrics());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user