Merge "Avoid Resources$NotFoundException" into lmp-mr1-dev
diff --git a/res/values-land/vals.xml b/res/values-land/vals.xml
deleted file mode 100644
index ebcae31..0000000
--- a/res/values-land/vals.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2011 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 ratio of width:height for the contact's photo -->
- <item name="quickcontact_photo_ratio" type="vals" format="float">0.7</item>
-</resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index cd9795c..857045c 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -22,6 +22,8 @@
<dimen name="quickcontact_maximum_title_size">36dp</dimen>
<!-- When QC is uncollapsed, the title has this much margin on its left, right and bottom -->
<dimen name="quickcontact_title_initial_margin">16dp</dimen>
+ <!-- The ratio of width:height for the contact's photo in landscape -->
+ <item name="quickcontact_landscape_photo_ratio" type="dimen" format="float">0.7</item>
<!-- Top padding of the entire contact editor -->
<dimen name="editor_padding_top">0dip</dimen>
diff --git a/src/com/android/contacts/widget/MultiShrinkScroller.java b/src/com/android/contacts/widget/MultiShrinkScroller.java
index ce654e9..20bc5b1 100644
--- a/src/com/android/contacts/widget/MultiShrinkScroller.java
+++ b/src/com/android/contacts/widget/MultiShrinkScroller.java
@@ -143,6 +143,7 @@
private final int mMaximumTitleMargin;
private final float mToolbarElevation;
private final boolean mIsTwoPanel;
+ private final float mLandscapePhotoRatio;
private final int mActionBarSize;
// Objects used to perform color filtering on the header. These are stored as fields for
@@ -252,6 +253,11 @@
mMaximumTitleMargin = (int) getResources().getDimension(
R.dimen.quickcontact_title_initial_margin);
+ final TypedValue photoRatio = new TypedValue();
+ getResources().getValue(R.dimen.quickcontact_landscape_photo_ratio, photoRatio,
+ /* resolveRefs = */ true);
+ mLandscapePhotoRatio = photoRatio.getFloat();
+
final TypedArray attributeArray = context.obtainStyledAttributes(
new int[]{android.R.attr.actionBarSize});
mActionBarSize = attributeArray.getDimensionPixelSize(0, 0);
@@ -319,9 +325,7 @@
mIntermediateHeaderHeight = (int) (mMaximumHeaderHeight
* INTERMEDIATE_HEADER_HEIGHT_RATIO);
}
- final boolean isLandscape = getResources().getConfiguration().orientation
- == Configuration.ORIENTATION_LANDSCAPE;
- mMaximumPortraitHeaderHeight = isLandscape ? getHeight()
+ mMaximumPortraitHeaderHeight = mIsTwoPanel ? getHeight()
: mPhotoViewContainer.getWidth();
setHeaderHeight(getMaximumScrollableHeaderHeight());
mMaximumHeaderTextSize = mLargeTextView.getHeight();
@@ -331,13 +335,10 @@
mIntermediateHeaderHeight = mMaximumHeaderHeight;
// Permanently set photo width and height.
- final TypedValue photoRatio = new TypedValue();
- getResources().getValue(R.vals.quickcontact_photo_ratio, photoRatio,
- /* resolveRefs = */ true);
final ViewGroup.LayoutParams photoLayoutParams
= mPhotoViewContainer.getLayoutParams();
photoLayoutParams.height = mMaximumHeaderHeight;
- photoLayoutParams.width = (int) (mMaximumHeaderHeight * photoRatio.getFloat());
+ photoLayoutParams.width = (int) (mMaximumHeaderHeight * mLandscapePhotoRatio);
mPhotoViewContainer.setLayoutParams(photoLayoutParams);
// Permanently set title width and margin.