Loading AndroidManifest.xml +1 −1 Original line number Diff line number Diff line Loading @@ -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" /> Loading src/com/android/contacts/editor/CompactPhotoEditorView.java +28 −4 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading @@ -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; Loading @@ -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) { Loading Loading @@ -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 Loading @@ -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. */ Loading Loading
AndroidManifest.xml +1 −1 Original line number Diff line number Diff line Loading @@ -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" /> Loading
src/com/android/contacts/editor/CompactPhotoEditorView.java +28 −4 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading @@ -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; Loading @@ -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) { Loading Loading @@ -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 Loading @@ -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. */ Loading