Removed PhotoLayout and made actionbar an overlay.

Change-Id: I3d3aacca2d55e3ae9eb34780af8f3febb5020cd0
diff --git a/res/layout/photo_fragment_view.xml b/res/layout/photo_fragment_view.xml
index 05babdf..926ca69 100644
--- a/res/layout/photo_fragment_view.xml
+++ b/res/layout/photo_fragment_view.xml
@@ -20,19 +20,11 @@
     android:layout_height="match_parent"
     android:background="@color/solid_black"
     >
-    <com.android.mail.photo.views.PhotoLayout
-        android:id="@+id/photo_layout"
+    <com.android.mail.photo.views.PhotoView
+        android:id="@+id/photo_view"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
-        android:orientation="vertical"
-        >
-        <com.android.mail.photo.views.PhotoView
-            android:id="@+id/photo_view"
-            android:layout_width="match_parent"
-            android:layout_height="match_parent"
-            />
-    </com.android.mail.photo.views.PhotoLayout>
-
+        />
 
     <FrameLayout
         android:id="@id/android:empty"
diff --git a/res/values/themes.xml b/res/values/themes.xml
index b62c714..a3d0162 100644
--- a/res/values/themes.xml
+++ b/res/values/themes.xml
@@ -20,6 +20,7 @@
     <style name="PhotoViewTheme" parent="android:Theme.Holo">
         <item name="android:windowNoTitle">false</item>
         <item name="android:windowContentOverlay">@null</item>
+        <item name="android:windowActionBarOverlay">true</item>
         <item name="android:windowBackground">@drawable/photo_view_background</item>
     </style>
 </resources>
diff --git a/src/com/android/mail/photo/fragments/PhotoViewFragment.java b/src/com/android/mail/photo/fragments/PhotoViewFragment.java
index 6d3a7ef..fc39d7b 100644
--- a/src/com/android/mail/photo/fragments/PhotoViewFragment.java
+++ b/src/com/android/mail/photo/fragments/PhotoViewFragment.java
@@ -39,7 +39,6 @@
 import android.view.View;
 import android.view.View.OnClickListener;
 import android.view.ViewGroup;
-import android.view.ViewParent;
 import android.view.WindowManager;
 import android.widget.AdapterView;
 import android.widget.ProgressBar;
@@ -53,7 +52,6 @@
 import com.android.mail.photo.PhotoViewActivity.OnScreenListener;
 import com.android.mail.photo.loaders.PhotoBitmapLoader;
 import com.android.mail.photo.util.ImageUtils;
-import com.android.mail.photo.views.PhotoLayout;
 import com.android.mail.photo.views.PhotoView;
 
 import java.io.File;
@@ -199,7 +197,6 @@
     /** Whether or not the photo is a place holder */
     private boolean mIsPlaceHolder = true;
 
-    private PhotoLayout mPhotoLayout;
     private PhotoView mPhotoView;
 
     /** The height of the action bar; may be {@code 0} if there is no action bar available */
@@ -289,15 +286,11 @@
         final View view = super.onCreateView(inflater, container, savedInstanceState,
                 R.layout.photo_fragment_view);
 
-        mPhotoLayout = (PhotoLayout) view.findViewById(R.id.photo_layout);
         mPhotoView = (PhotoView) view.findViewById(R.id.photo_view);
 
         mIsPlaceHolder = true;
         mPhotoView.setPhotoLoading(true);
 
-        // Bind the photo data
-        setPhotoLayoutFixedHeight();
-
         mPhotoView.setOnClickListener(this);
         mPhotoView.setFullScreen(mFullScreen, false);
 //        mPhotoView.setVideoBlob(videoData);
@@ -339,11 +332,6 @@
             mPhotoView = null;
         }
 
-        if (mPhotoLayout != null) {
-            mPhotoLayout.clear();
-            mPhotoLayout = null;
-        }
-
         super.onDestroyView();
     }
 
@@ -510,22 +498,6 @@
 
     @Override
     public void onActionBarHeightCalculated(int actionBarHeight) {
-        final boolean heightChanged = (actionBarHeight != mActionBarHeight);
-        mActionBarHeight = actionBarHeight;
-        if (heightChanged && mActionBarHeight > 0) {
-            setPhotoLayoutFixedHeight();
-        }
-    }
-
-    private void setPhotoLayoutFixedHeight() {
-        if (mPhotoLayout != null) {
-            ViewParent viewParent = mPhotoLayout.getParent();
-            if (viewParent instanceof View) {
-                mPhotoLayout.setFixedHeight(
-                        ((View) mPhotoLayout.getParent()).getMeasuredHeight() -
-                        (mDisableSpacer ? 0 : mActionBarHeight));
-            }
-        }
     }
 
     @Override
diff --git a/src/com/android/mail/photo/views/PhotoLayout.java b/src/com/android/mail/photo/views/PhotoLayout.java
deleted file mode 100644
index 30c8b42..0000000
--- a/src/com/android/mail/photo/views/PhotoLayout.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (C) 2011 Google Inc.
- * Licensed to 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.
- */
-
-package com.android.mail.photo.views;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.view.View;
-import android.widget.LinearLayout;
-
-import com.android.mail.R;
-
-/**
- * Custom layout for the photo view.
- * <p>
- * The photo view gives the photo a dynamic height -- it always takes up whatever's left of the
- * screen. A normal {@link LinearLayout} does not allow this [at least not in the context of a
- * list]. So, we create a layout that can fix it's height and ensures its children [such as the
- * photo itself] are sized appropriately.
- */
-public class PhotoLayout extends LinearLayout {
-    /** The fixed height of this view. If {@code -1}, calculate the height */
-    private int mFixedHeight = -1;
-    /** The view containing primary photo information */
-    private PhotoView mPhotoView;
-
-    public PhotoLayout(Context context) {
-        super(context);
-    }
-
-    public PhotoLayout(Context context, AttributeSet attrs) {
-        super(context, attrs);
-    }
-
-    public PhotoLayout(Context context, AttributeSet attrs, int defStyle) {
-        super(context, attrs, defStyle);
-    }
-
-    @Override
-    public void addView(View child, int index, android.view.ViewGroup.LayoutParams params) {
-        super.addView(child, index, params);
-
-        if (child.getId() == R.id.photo_view) {
-            mPhotoView = (PhotoView) child;
-        }
-    }
-
-    @Override
-    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
-        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
-        setFixedHeight(mFixedHeight);
-    }
-
-    /**
-     * Clears any state or resources from the views. The layout cannot be used after this method
-     * is called.
-     */
-    public void clear() {
-        removeAllViews();
-        mPhotoView = null;
-    }
-
-    /**
-     * Sets the fixed height for this layout. If the given height is <= 0, it is ignored.
-     */
-    public void setFixedHeight(int fixedHeight) {
-        if (fixedHeight <= 0) {
-            return;
-        }
-
-        final boolean adjustBounds = (fixedHeight != mFixedHeight);
-        mFixedHeight = fixedHeight;
-
-        if (mPhotoView != null) {
-            int adjustHeight = 0;
-            mPhotoView.setFixedHeight(mFixedHeight - adjustHeight);
-        }
-        setMeasuredDimension(getMeasuredWidth(), mFixedHeight);
-
-        if (adjustBounds) {
-            requestLayout();
-        }
-    }
-}