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

Commit 8a357e88 authored by Brian Attwell's avatar Brian Attwell Committed by Natiq Ahmed
Browse files

Avoid Resources$NotFoundException

I'm guessing that this bug was being caused by doOnPreDraw()
callbacks occuring after rotation (the monkey links 404, so it
is hard to do more than conjecture)? To fix this: define the
resource for both landscape and profile. To make this more
testable: load quickcontact_landscape_photo_ratio during
contruction instead of inside an asynchronous callback.

Additional cleanup: don't use two different ways to determine
whether we are in landscape mode. This wasn't causing a bug
that we know of.

Bug: 18102632
Change-Id: I1f27d873ca71be28de7a1e59aa628c4696cb4c89
parent 2e045050
Loading
Loading
Loading
Loading

res/values-land/vals.xml

deleted100644 → 0
+0 −19
Original line number Diff line number Diff line
<?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>
+2 −0
Original line number Diff line number Diff line
@@ -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>
+8 −7
Original line number Diff line number Diff line
@@ -142,6 +142,7 @@ public class MultiShrinkScroller extends FrameLayout {
    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
@@ -251,6 +252,11 @@ public class MultiShrinkScroller extends FrameLayout {
        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);
@@ -317,9 +323,7 @@ public class MultiShrinkScroller extends FrameLayout {
                    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();
@@ -329,13 +333,10 @@ public class MultiShrinkScroller extends FrameLayout {
                    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.