Loading src/com/android/contacts/activities/AttachPhotoActivity.java +23 −23 Original line number Diff line number Diff line Loading @@ -69,6 +69,8 @@ public class AttachPhotoActivity extends ContactsActivity { // Height and width (in pixels) to request for the photo - queried from the provider. private static int mPhotoDim; // Default photo dimension to use if unable to query the provider. private static final int mDefaultPhotoDim = 720; private Uri mContactUri; Loading @@ -91,9 +93,13 @@ public class AttachPhotoActivity extends ContactsActivity { mContentResolver = getContentResolver(); // Load the photo dimension to request. // Load the photo dimension to request. mPhotoDim is a static class // member varible so only need to load this if this is the first time // through. if (mPhotoDim == 0) { Cursor c = mContentResolver.query(DisplayPhoto.CONTENT_MAX_DIMENSIONS_URI, new String[]{DisplayPhoto.DISPLAY_MAX_DIM}, null, null, null); if (c != null) { try { c.moveToFirst(); mPhotoDim = c.getInt(0); Loading @@ -101,6 +107,8 @@ public class AttachPhotoActivity extends ContactsActivity { c.close(); } } } } @Override protected void onSaveInstanceState(Bundle outState) { Loading Loading @@ -128,28 +136,20 @@ public class AttachPhotoActivity extends ContactsActivity { final Intent myIntent = getIntent(); final Uri inputUri = myIntent.getData(); final int perm = checkUriPermission(inputUri, android.os.Process.myPid(), android.os.Process.myUid(), Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); final Uri toCrop; if (perm == PackageManager.PERMISSION_DENIED) { // Work around to save a read-only URI into a temporary file provider URI so that // Save the URI into a temporary file provider URI so that // we can add the FLAG_GRANT_WRITE_URI_PERMISSION flag to the eventual // crop intent b/10837468 // crop intent for read-only URI's. // TODO: With b/10837468 fixed should be able to avoid this copy. ContactPhotoUtils.savePhotoFromUriToUri(this, inputUri, mTempPhotoUri, false); toCrop = mTempPhotoUri; } else { toCrop = inputUri; } final Intent intent = new Intent("com.android.camera.action.CROP", toCrop); if (myIntent.getStringExtra("mimeType") != null) { intent.setDataAndType(toCrop, myIntent.getStringExtra("mimeType")); } ContactPhotoUtils.addPhotoPickerExtras(intent, mCroppedPhotoUri); ContactPhotoUtils.addCropExtras(intent, mPhotoDim); ContactPhotoUtils.addCropExtras(intent, mPhotoDim != 0 ? mPhotoDim : mDefaultPhotoDim); startActivityForResult(intent, REQUEST_CROP_PHOTO); Loading Loading
src/com/android/contacts/activities/AttachPhotoActivity.java +23 −23 Original line number Diff line number Diff line Loading @@ -69,6 +69,8 @@ public class AttachPhotoActivity extends ContactsActivity { // Height and width (in pixels) to request for the photo - queried from the provider. private static int mPhotoDim; // Default photo dimension to use if unable to query the provider. private static final int mDefaultPhotoDim = 720; private Uri mContactUri; Loading @@ -91,9 +93,13 @@ public class AttachPhotoActivity extends ContactsActivity { mContentResolver = getContentResolver(); // Load the photo dimension to request. // Load the photo dimension to request. mPhotoDim is a static class // member varible so only need to load this if this is the first time // through. if (mPhotoDim == 0) { Cursor c = mContentResolver.query(DisplayPhoto.CONTENT_MAX_DIMENSIONS_URI, new String[]{DisplayPhoto.DISPLAY_MAX_DIM}, null, null, null); if (c != null) { try { c.moveToFirst(); mPhotoDim = c.getInt(0); Loading @@ -101,6 +107,8 @@ public class AttachPhotoActivity extends ContactsActivity { c.close(); } } } } @Override protected void onSaveInstanceState(Bundle outState) { Loading Loading @@ -128,28 +136,20 @@ public class AttachPhotoActivity extends ContactsActivity { final Intent myIntent = getIntent(); final Uri inputUri = myIntent.getData(); final int perm = checkUriPermission(inputUri, android.os.Process.myPid(), android.os.Process.myUid(), Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); final Uri toCrop; if (perm == PackageManager.PERMISSION_DENIED) { // Work around to save a read-only URI into a temporary file provider URI so that // Save the URI into a temporary file provider URI so that // we can add the FLAG_GRANT_WRITE_URI_PERMISSION flag to the eventual // crop intent b/10837468 // crop intent for read-only URI's. // TODO: With b/10837468 fixed should be able to avoid this copy. ContactPhotoUtils.savePhotoFromUriToUri(this, inputUri, mTempPhotoUri, false); toCrop = mTempPhotoUri; } else { toCrop = inputUri; } final Intent intent = new Intent("com.android.camera.action.CROP", toCrop); if (myIntent.getStringExtra("mimeType") != null) { intent.setDataAndType(toCrop, myIntent.getStringExtra("mimeType")); } ContactPhotoUtils.addPhotoPickerExtras(intent, mCroppedPhotoUri); ContactPhotoUtils.addCropExtras(intent, mPhotoDim); ContactPhotoUtils.addCropExtras(intent, mPhotoDim != 0 ? mPhotoDim : mDefaultPhotoDim); startActivityForResult(intent, REQUEST_CROP_PHOTO); Loading