summaryrefslogtreecommitdiffstats
path: root/src/com/android/contacts/editor/ContactEditorBaseFragment.java
diff options
context:
space:
mode:
authorWalter Jang <wjang@google.com>2015-03-10 15:57:05 -0700
committerWalter Jang <wjang@google.com>2015-03-11 12:40:15 -0700
commit1e8801bc9bc60bdd1c95f582c460590272cfad64 (patch)
treec55cfa9429955d8250bc266327731f5cd68f7e88 /src/com/android/contacts/editor/ContactEditorBaseFragment.java
parent0554998975eccfe77440e6dc2200f08adfd45473 (diff)
downloadpackages_apps_Contacts-1e8801bc9bc60bdd1c95f582c460590272cfad64.tar.gz
packages_apps_Contacts-1e8801bc9bc60bdd1c95f582c460590272cfad64.tar.bz2
packages_apps_Contacts-1e8801bc9bc60bdd1c95f582c460590272cfad64.zip
Pass full res contact photos between the compact and full editors
Bug 19624360 Bug 19655206 Change-Id: I590ec7ecec75a9af95b824f5db9cda8f8aeda675
Diffstat (limited to 'src/com/android/contacts/editor/ContactEditorBaseFragment.java')
-rw-r--r--src/com/android/contacts/editor/ContactEditorBaseFragment.java55
1 files changed, 47 insertions, 8 deletions
diff --git a/src/com/android/contacts/editor/ContactEditorBaseFragment.java b/src/com/android/contacts/editor/ContactEditorBaseFragment.java
index 258747d57..5e9a98724 100644
--- a/src/com/android/contacts/editor/ContactEditorBaseFragment.java
+++ b/src/com/android/contacts/editor/ContactEditorBaseFragment.java
@@ -142,6 +142,8 @@ abstract public class ContactEditorBaseFragment extends Fragment implements
// Join Activity
private static final String KEY_CONTACT_ID_FOR_JOIN = "contactidforjoin";
+ private static final String KEY_UPDATED_PHOTOS = "updatedPhotos";
+
protected static final int REQUEST_CODE_JOIN = 0;
protected static final int REQUEST_CODE_ACCOUNTS_CHANGED = 1;
protected static final int REQUEST_CODE_PICK_RINGTONE = 2;
@@ -165,6 +167,12 @@ abstract public class ContactEditorBaseFragment extends Fragment implements
public static final String INTENT_EXTRA_MATERIAL_PALETTE = "material_palette";
/**
+ * Intent key to pass a Bundle of raw contact IDs to photos URIs between the compact editor
+ * and the fully expanded one.
+ */
+ public static final String INTENT_EXTRA_UPDATED_PHOTOS = "updated_photos";
+
+ /**
* Intent extra to specify a {@link ContactEditor.SaveMode}.
*/
public static final String SAVE_MODE_EXTRA_KEY = "saveMode";
@@ -342,6 +350,9 @@ abstract public class ContactEditorBaseFragment extends Fragment implements
// Join Activity
protected long mContactIdForJoin;
+ // Full resolution photo URIs
+ protected Bundle mUpdatedPhotos = new Bundle();
+
//
// Editor state for {@link ContactEditorView}.
// (Not saved/restored on rotates)
@@ -474,6 +485,9 @@ abstract public class ContactEditorBaseFragment extends Fragment implements
// Join Activity
mContactIdForJoin = savedState.getLong(KEY_CONTACT_ID_FOR_JOIN);
+
+ // Full resolution photo URIs
+ mUpdatedPhotos = savedState.getParcelable(KEY_UPDATED_PHOTOS);
}
// mState can still be null because it may not have have finished loading before
@@ -594,6 +608,9 @@ abstract public class ContactEditorBaseFragment extends Fragment implements
// Join Activity
outState.putLong(KEY_CONTACT_ID_FOR_JOIN, mContactIdForJoin);
+ // Full resolution photo URIs
+ outState.putParcelable(KEY_UPDATED_PHOTOS, mUpdatedPhotos);
+
super.onSaveInstanceState(outState);
}
@@ -888,7 +905,8 @@ abstract public class ContactEditorBaseFragment extends Fragment implements
mStatus = Status.EDITING;
return true;
}
- onSaveCompleted(false, saveMode, /* saveSucceeded =*/ mLookupUri != null, mLookupUri);
+ onSaveCompleted(false, saveMode, /* saveSucceeded =*/ mLookupUri != null, mLookupUri,
+ /* updatedPhotos =*/ null);
return true;
}
@@ -902,7 +920,7 @@ abstract public class ContactEditorBaseFragment extends Fragment implements
// If we're coming back from the fully expanded editor and this is an insert, just
// pass any values entered by the user back to the compact editor without doing a save
final Intent resultIntent = EditorIntents.createCompactInsertContactIntent(
- mState, getDisplayName());
+ mState, getDisplayName(), mUpdatedPhotos);
mListener.onSaveFinished(resultIntent);
return true;
}
@@ -1277,8 +1295,10 @@ abstract public class ContactEditorBaseFragment extends Fragment implements
mIntentExtras.getBoolean(INTENT_EXTRA_NEW_LOCAL_PROFILE);
mDisableDeleteMenuOption =
mIntentExtras.getBoolean(INTENT_EXTRA_DISABLE_DELETE_MENU_OPTION);
- mMaterialPalette =
- mIntentExtras.getParcelable(INTENT_EXTRA_MATERIAL_PALETTE);
+ mMaterialPalette = mIntentExtras.getParcelable(INTENT_EXTRA_MATERIAL_PALETTE);
+ if (mIntentExtras.containsKey(INTENT_EXTRA_UPDATED_PHOTOS)) {
+ mUpdatedPhotos = mIntentExtras.getParcelable(INTENT_EXTRA_UPDATED_PHOTOS);
+ }
}
}
@@ -1301,12 +1321,12 @@ abstract public class ContactEditorBaseFragment extends Fragment implements
@Override
public void onJoinCompleted(Uri uri) {
- onSaveCompleted(false, SaveMode.RELOAD, uri != null, uri);
+ onSaveCompleted(false, SaveMode.RELOAD, uri != null, uri, /* updatedPhotos =*/ null);
}
@Override
public void onSaveCompleted(boolean hadChanges, int saveMode, boolean saveSucceeded,
- Uri contactLookupUri) {
+ Uri contactLookupUri, Bundle updatedPhotos) {
if (hadChanges) {
if (saveSucceeded) {
if (saveMode != SaveMode.JOIN && showToastAfterSave()) {
@@ -1329,10 +1349,10 @@ abstract public class ContactEditorBaseFragment extends Fragment implements
} else if (saveMode == SaveMode.COMPACT) {
if (isInsert(getActivity().getIntent())) {
resultIntent = EditorIntents.createCompactInsertContactIntent(
- mState, getDisplayName());
+ mState, getDisplayName(), updatedPhotos);
} else {
resultIntent = EditorIntents.createCompactEditContactIntent(
- lookupUri, getMaterialPalette());
+ lookupUri, getMaterialPalette(), updatedPhotos);
}
} else {
resultIntent = null;
@@ -1564,6 +1584,25 @@ abstract public class ContactEditorBaseFragment extends Fragment implements
abstract protected void joinAggregate(long contactId);
//
+ // Photos
+ //
+
+ /**
+ * Removes the full resolution photo URIs for new raw contacts (identified by negative raw
+ * contact IDs) from the member Bundle of updated photos.
+ */
+ protected void removeNewRawContactPhotos() {
+ for (String key : mUpdatedPhotos.keySet()) {
+ try {
+ if (Integer.parseInt(key) < 0) {
+ mUpdatedPhotos.remove(key);
+ }
+ } catch (NumberFormatException ignored) {
+ }
+ }
+ }
+
+ //
// Utility methods
//