summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--AndroidManifest.xml2
-rw-r--r--src/com/android/contacts/editor/CompactPhotoEditorView.java32
2 files changed, 29 insertions, 5 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 536d543bf..d7ee9c87e 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -341,7 +341,7 @@
android:name=".activities.CompactContactEditorActivity"
android:label="@string/launcherActivityLabel"
android:theme="@style/EditorActivityTheme"
- android:windowSoftInputMode="stateHidden|adjustPan">
+ android:windowSoftInputMode="stateHidden|adjustResize">
<intent-filter android:label="@string/editContactDescription">
<action android:name="android.intent.action.EDIT" />
diff --git a/src/com/android/contacts/editor/CompactPhotoEditorView.java b/src/com/android/contacts/editor/CompactPhotoEditorView.java
index 7483af676..0b1cbe826 100644
--- a/src/com/android/contacts/editor/CompactPhotoEditorView.java
+++ b/src/com/android/contacts/editor/CompactPhotoEditorView.java
@@ -31,7 +31,9 @@ import com.android.contacts.util.ContactPhotoUtils;
import com.android.contacts.util.SchedulingUtils;
import com.android.contacts.widget.QuickContactImageView;
+import android.app.Activity;
import android.content.Context;
+import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.GradientDrawable;
@@ -40,6 +42,7 @@ import android.provider.ContactsContract;
import android.provider.ContactsContract.CommonDataKinds.Photo;
import android.provider.ContactsContract.DisplayPhoto;
import android.util.AttributeSet;
+import android.util.DisplayMetrics;
import android.util.Log;
import android.util.TypedValue;
import android.view.View;
@@ -61,6 +64,9 @@ public class CompactPhotoEditorView extends RelativeLayout implements View.OnCli
private final float mPortraitPhotoRatio;
private final boolean mIsTwoPanel;
+ private final int mActionBarHeight;
+ private final int mStatusBarHeight;
+
private ValuesDelta mValuesDelta;
private boolean mReadOnly;
private boolean mIsPhotoSet;
@@ -78,6 +84,15 @@ public class CompactPhotoEditorView extends RelativeLayout implements View.OnCli
mLandscapePhotoRatio = getTypedFloat(R.dimen.quickcontact_landscape_photo_ratio);
mPortraitPhotoRatio = getTypedFloat(R.dimen.editor_portrait_photo_ratio);
mIsTwoPanel = getResources().getBoolean(R.bool.quickcontact_two_panel);
+
+ final TypedArray styledAttributes = getContext().getTheme().obtainStyledAttributes(
+ new int[] { android.R.attr.actionBarSize });
+ mActionBarHeight = (int) styledAttributes.getDimension(0, 0);
+ styledAttributes.recycle();
+
+ final int resourceId = getResources().getIdentifier(
+ "status_bar_height", "dimen", "android");
+ mStatusBarHeight = resourceId > 0 ? getResources().getDimensionPixelSize(resourceId) : 0;
}
private float getTypedFloat(int resourceId) {
@@ -144,15 +159,13 @@ public class CompactPhotoEditorView extends RelativeLayout implements View.OnCli
setDefaultPhotoTint();
}
- // Adjust the photo dimensions following the same logic as in
- // MultiShrinkScroll.initialize
+ // Adjust the photo dimensions following the same logic as MultiShrinkScroll.initialize
SchedulingUtils.doOnPreDraw(this, /* drawNextFrame =*/ false, new Runnable() {
@Override
public void run() {
final int photoHeight, photoWidth;
if (mIsTwoPanel) {
- // Make the photo slightly more narrow than it is tall
- photoHeight = getHeight();
+ photoHeight = getContentViewHeight();
photoWidth = (int) (photoHeight * mLandscapePhotoRatio);
} else {
// Make the photo slightly shorter that it is wide
@@ -167,6 +180,17 @@ public class CompactPhotoEditorView extends RelativeLayout implements View.OnCli
});
}
+ // We're calculating the height the hard way because using the height of the content view
+ // (found using android.view.Window.ID_ANDROID_CONTENT) with the soft keyboard up when
+ // going from portrait to landscape mode results in a very small height value.
+ // See b/20526470
+ private int getContentViewHeight() {
+ final Activity activity = (Activity) getContext();
+ final DisplayMetrics displayMetrics = new DisplayMetrics();
+ activity.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
+ return displayMetrics.heightPixels - mActionBarHeight - mStatusBarHeight;
+ }
+
/**
* Set the {@link PhotoHandler} to forward clicks (i.e. requests to edit the photo) to.
*/