am 28a27279: Revert moving between the compact and full editors (E5)
* commit '28a27279554af7b1e5ff664d3da97954c462a797':
Revert moving between the compact and full editors (E5)
diff --git a/src/com/android/contacts/ContactSaveService.java b/src/com/android/contacts/ContactSaveService.java
index 634e29a..1989606 100755
--- a/src/com/android/contacts/ContactSaveService.java
+++ b/src/com/android/contacts/ContactSaveService.java
@@ -313,7 +313,7 @@
Bundle bundle = new Bundle();
bundle.putParcelable(String.valueOf(rawContactId), updatedPhotoPath);
return createSaveContactIntent(context, state, saveModeExtraKey, saveMode, isProfile,
- callbackActivity, callbackAction, bundle, /* backPressed =*/ false);
+ callbackActivity, callbackAction, bundle);
}
/**
@@ -322,13 +322,11 @@
* This variant is used when multiple contacts' photos may be updated, as in the
* Contact Editor.
* @param updatedPhotos maps each raw-contact's ID to the file-path of the new photo.
- * @param backPressed whether the save was initiated as a result of a back button press
- * or because the framework stopped the editor Activity
*/
public static Intent createSaveContactIntent(Context context, RawContactDeltaList state,
String saveModeExtraKey, int saveMode, boolean isProfile,
Class<? extends Activity> callbackActivity, String callbackAction,
- Bundle updatedPhotos, boolean backPressed) {
+ Bundle updatedPhotos) {
Intent serviceIntent = new Intent(
context, ContactSaveService.class);
serviceIntent.setAction(ContactSaveService.ACTION_SAVE_CONTACT);
@@ -347,11 +345,6 @@
Intent callbackIntent = new Intent(context, callbackActivity);
callbackIntent.putExtra(saveModeExtraKey, saveMode);
callbackIntent.setAction(callbackAction);
- if (updatedPhotos != null) {
- callbackIntent.putExtra(EXTRA_UPDATED_PHOTOS, (Parcelable) updatedPhotos);
- }
- callbackIntent.putExtra(ContactEditorFragment.INTENT_EXTRA_SAVE_BACK_PRESSED,
- backPressed);
serviceIntent.putExtra(ContactSaveService.EXTRA_CALLBACK_INTENT, callbackIntent);
}
return serviceIntent;
diff --git a/src/com/android/contacts/activities/CompactContactEditorActivity.java b/src/com/android/contacts/activities/CompactContactEditorActivity.java
index 082bb74..28dd8a5 100644
--- a/src/com/android/contacts/activities/CompactContactEditorActivity.java
+++ b/src/com/android/contacts/activities/CompactContactEditorActivity.java
@@ -56,11 +56,4 @@
final Uri uri = Intent.ACTION_EDIT.equals(action) ? getIntent().getData() : null;
mFragment.load(action, uri, getIntent().getExtras());
}
-
- @Override
- public void onBackPressed() {
- if (mFragment != null) {
- mFragment.revert();
- }
- }
}
diff --git a/src/com/android/contacts/activities/ContactEditorActivity.java b/src/com/android/contacts/activities/ContactEditorActivity.java
index 800a267..293e8c0 100644
--- a/src/com/android/contacts/activities/ContactEditorActivity.java
+++ b/src/com/android/contacts/activities/ContactEditorActivity.java
@@ -50,11 +50,4 @@
|| Intent.ACTION_EDIT.equals(action) ? getIntent().getData() : null;
mFragment.load(action, uri, getIntent().getExtras());
}
-
- @Override
- public void onBackPressed() {
- if (mFragment != null) {
- mFragment.save(ContactEditor.SaveMode.COMPACT, /* backPressed =*/ true);
- }
- }
}
diff --git a/src/com/android/contacts/activities/ContactEditorBaseActivity.java b/src/com/android/contacts/activities/ContactEditorBaseActivity.java
index 12f1e96..18ff30f 100644
--- a/src/com/android/contacts/activities/ContactEditorBaseActivity.java
+++ b/src/com/android/contacts/activities/ContactEditorBaseActivity.java
@@ -155,11 +155,8 @@
/**
* Saves or creates the contact based on the mode, and if successful
* finishes the activity.
- *
- * @param backPressed whether the save was initiated as a result of a back button press
- * or because the framework stopped the editor Activity
*/
- boolean save(int saveMode, boolean backPressed);
+ boolean save(int saveMode);
/**
* If there are no unsaved changes, just close the editor, otherwise the user is prompted
@@ -171,8 +168,7 @@
* Invoked after the contact is saved.
*/
void onSaveCompleted(boolean hadChanges, int saveMode, boolean saveSucceeded,
- Uri contactLookupUri, Bundle updatedPhotos, boolean backPressed, long photoId,
- long nameId);
+ Uri contactLookupUri);
/**
* Invoked after the contact is joined.
@@ -259,12 +255,7 @@
intent.getIntExtra(ContactEditorFragment.SAVE_MODE_EXTRA_KEY,
ContactEditor.SaveMode.CLOSE),
intent.getBooleanExtra(ContactSaveService.EXTRA_SAVE_SUCCEEDED, false),
- intent.getData(),
- (Bundle) intent.getParcelableExtra(ContactSaveService.EXTRA_UPDATED_PHOTOS),
- intent.getBooleanExtra(ContactEditorFragment.INTENT_EXTRA_SAVE_BACK_PRESSED,
- false),
- intent.getLongExtra(ContactEditorFragment.INTENT_EXTRA_PHOTO_ID, -1),
- intent.getLongExtra(ContactEditorFragment.INTENT_EXTRA_NAME_ID, -1));
+ intent.getData());
} else if (ACTION_JOIN_COMPLETED.equals(action)) {
mFragment.onJoinCompleted(intent.getData());
}
@@ -279,6 +270,13 @@
return null;
}
+ @Override
+ public void onBackPressed() {
+ if (mFragment != null) {
+ mFragment.save(ContactEditor.SaveMode.CLOSE);
+ }
+ }
+
protected final ContactEditorBaseFragment.Listener mFragmentListener =
new ContactEditorBaseFragment.Listener() {
@@ -294,15 +292,11 @@
@Override
public void onSaveFinished(Intent resultIntent) {
- final boolean backPressed = resultIntent == null ? false : resultIntent.getBooleanExtra(
- ContactEditorBaseFragment.INTENT_EXTRA_SAVE_BACK_PRESSED, false);
if (mFinishActivityOnSaveCompleted) {
setResult(resultIntent == null ? RESULT_CANCELED : RESULT_OK, resultIntent);
} else if (resultIntent != null) {
- if (backPressed) {
- ImplicitIntentsUtil.startActivityInApp(ContactEditorBaseActivity.this,
- resultIntent);
- }
+ ImplicitIntentsUtil.startActivityInApp(ContactEditorBaseActivity.this,
+ resultIntent);
}
finish();
}
diff --git a/src/com/android/contacts/editor/CompactContactEditorFragment.java b/src/com/android/contacts/editor/CompactContactEditorFragment.java
index df47fe4..9b79e7a 100644
--- a/src/com/android/contacts/editor/CompactContactEditorFragment.java
+++ b/src/com/android/contacts/editor/CompactContactEditorFragment.java
@@ -25,7 +25,6 @@
import com.android.contacts.common.model.ValuesDelta;
import com.android.contacts.common.model.account.AccountType;
import com.android.contacts.common.model.account.AccountWithDataSet;
-import com.android.contacts.common.util.ImplicitIntentsUtil;
import com.android.contacts.detail.PhotoSelectionHandler;
import com.android.contacts.util.ContactPhotoUtils;
@@ -52,6 +51,7 @@
private static final String KEY_PHOTO_URI = "photo_uri";
private static final String KEY_PHOTO_RAW_CONTACT_ID = "photo_raw_contact_id";
+ private static final String KEY_UPDATED_PHOTOS = "updated_photos";
/**
* Displays a PopupWindow with photo edit options.
@@ -80,10 +80,6 @@
}
getContent().setPhoto(bitmap);
- // Clear any previously saved full resolution photos under negative raw contact IDs
- // so that we will use the newly selected photo, instead of an old one on rotations.
- removeNewRawContactPhotos();
-
// If a new photo was chosen but not yet saved,
// we need to update the UI immediately
mUpdatedPhotos.putParcelable(String.valueOf(mPhotoRawContactId), uri);
@@ -142,6 +138,7 @@
private PhotoHandler mPhotoHandler;
private Uri mPhotoUri;
private long mPhotoRawContactId;
+ private Bundle mUpdatedPhotos = new Bundle();
@Override
public void onCreate(Bundle savedState) {
@@ -150,6 +147,7 @@
if (savedState != null) {
mPhotoUri = savedState.getParcelable(KEY_PHOTO_URI);
mPhotoRawContactId = savedState.getLong(KEY_PHOTO_RAW_CONTACT_ID);
+ mUpdatedPhotos = savedState.getParcelable(KEY_UPDATED_PHOTOS);
}
}
@@ -167,6 +165,7 @@
public void onSaveInstanceState(Bundle outState) {
outState.putParcelable(KEY_PHOTO_URI, mPhotoUri);
outState.putLong(KEY_PHOTO_RAW_CONTACT_ID, mPhotoRawContactId);
+ outState.putParcelable(KEY_UPDATED_PHOTOS, mUpdatedPhotos);
super.onSaveInstanceState(outState);
}
@@ -188,7 +187,7 @@
// If anything was left unsaved, save it now
if (!getActivity().isChangingConfigurations() && mStatus == Status.EDITING) {
- save(SaveMode.RELOAD, /* backPressed =*/ false);
+ save(SaveMode.RELOAD);
}
}
@@ -218,19 +217,7 @@
// Set up the photo widget
mPhotoHandler = createPhotoHandler();
mPhotoRawContactId = editorView.getPhotoRawContactId();
- if (mPhotoRawContactId < 0) {
- // Since the raw contact IDs for new contacts are random negative numbers
- // we consider any negative key a match
- for (String key : mUpdatedPhotos.keySet()) {
- try {
- if (Integer.parseInt(key) < 0) {
- editorView.setFullSizePhoto((Uri) mUpdatedPhotos.getParcelable(key));
- break;
- }
- } catch (NumberFormatException ignored) {
- }
- }
- } else if (mUpdatedPhotos.containsKey(String.valueOf(mPhotoRawContactId))) {
+ if (mUpdatedPhotos.containsKey(String.valueOf(mPhotoRawContactId))) {
editorView.setFullSizePhoto((Uri) mUpdatedPhotos.getParcelable(
String.valueOf(mPhotoRawContactId)));
}
@@ -309,12 +296,11 @@
}
@Override
- protected boolean doSaveAction(int saveMode, boolean backPressed) {
- // Save contact. No need to pass the palette since we are finished editing after the save.
+ protected boolean doSaveAction(int saveMode) {
final Intent intent = ContactSaveService.createSaveContactIntent(mContext, mState,
SAVE_MODE_EXTRA_KEY, saveMode, isEditingUserProfile(),
((Activity) mContext).getClass(),
- CompactContactEditorActivity.ACTION_SAVE_COMPLETED, mUpdatedPhotos, backPressed);
+ CompactContactEditorActivity.ACTION_SAVE_COMPLETED, mUpdatedPhotos);
mContext.startService(intent);
return true;
@@ -368,22 +354,6 @@
rebindEditorsForNewContact(oldState, oldAccount, newAccount);
}
- @Override
- public String getDisplayName() {
- final StructuredNameEditorView structuredNameEditorView =
- getContent().getStructuredNameEditorView();
- return structuredNameEditorView == null
- ? null : structuredNameEditorView.getDisplayName();
- }
-
- @Override
- public String getPhoneticName() {
- final PhoneticNameEditorView phoneticNameEditorView =
- getContent().getFirstPhoneticNameEditorView();
- return phoneticNameEditorView == null
- ? null : phoneticNameEditorView.getPhoneticName();
- }
-
private CompactRawContactsEditorView getContent() {
return (CompactRawContactsEditorView) mContent;
}
diff --git a/src/com/android/contacts/editor/CompactRawContactsEditorView.java b/src/com/android/contacts/editor/CompactRawContactsEditorView.java
index c51e47a..bf8a29c 100644
--- a/src/com/android/contacts/editor/CompactRawContactsEditorView.java
+++ b/src/com/android/contacts/editor/CompactRawContactsEditorView.java
@@ -344,25 +344,6 @@
return mDefaultNameEditorView;
}
- public StructuredNameEditorView getStructuredNameEditorView() {
- // We only ever show one StructuredName
- return mNames.getChildCount() == 0
- ? null : (StructuredNameEditorView) mNames.getChildAt(0);
- }
-
- public PhoneticNameEditorView getFirstPhoneticNameEditorView() {
- // There should only ever be one phonetic name, it is enforced by dataKind.typeOverallMax
- final CompactKindSectionView kindSectionView = (CompactKindSectionView)
- mKindSectionViewsMap.get(DataKind.PSEUDO_MIME_TYPE_PHONETIC_NAME);
- if (kindSectionView != null && kindSectionView.getChildCount() > 0) {
- final View editorView = kindSectionView.getEditorView(0);
- if (editorView instanceof PhoneticNameEditorView) {
- return ((PhoneticNameEditorView) editorView);
- }
- }
- return null;
- }
-
public View getAggregationAnchorView() {
// Since there is only one structured name we can just return it as the anchor for
// the aggregation suggestions popup
diff --git a/src/com/android/contacts/editor/ContactEditorBaseFragment.java b/src/com/android/contacts/editor/ContactEditorBaseFragment.java
index 4e5fff4..011377d 100644
--- a/src/com/android/contacts/editor/ContactEditorBaseFragment.java
+++ b/src/com/android/contacts/editor/ContactEditorBaseFragment.java
@@ -145,8 +145,6 @@
// 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;
@@ -179,12 +177,6 @@
"material_palette_secondary_color";
/**
- * 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 key to pass the ID of the photo to display on the editor.
*/
public static final String INTENT_EXTRA_PHOTO_ID = "photo_id";
@@ -200,12 +192,6 @@
public static final String SAVE_MODE_EXTRA_KEY = "saveMode";
/**
- * Intent extra to specify whether the save was initiated as a result of a back button press
- * or because the framework stopped the editor Activity.
- */
- public static final String INTENT_EXTRA_SAVE_BACK_PRESSED = "saveBackPressed";
-
- /**
* Callbacks for Activities that host contact editors Fragments.
*/
public interface Listener {
@@ -382,9 +368,6 @@
// Join Activity
protected long mContactIdForJoin;
- // Full resolution photo URIs
- protected Bundle mUpdatedPhotos = new Bundle();
-
//
// Not saved/restored on rotates
//
@@ -520,9 +503,6 @@
// 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
@@ -648,9 +628,6 @@
// Join Activity
outState.putLong(KEY_CONTACT_ID_FOR_JOIN, mContactIdForJoin);
- // Full resolution photo URIs
- outState.putParcelable(KEY_UPDATED_PHOTOS, mUpdatedPhotos);
-
super.onSaveInstanceState(outState);
}
@@ -659,6 +636,11 @@
super.onStop();
UiClosables.closeQuietly(mAggregationSuggestionPopup);
+
+ // If anything was left unsaved, save it now but keep the editor open.
+ if (!getActivity().isChangingConfigurations() && mStatus == Status.EDITING) {
+ save(SaveMode.RELOAD);
+ }
}
@Override
@@ -824,7 +806,7 @@
switch (item.getItemId()) {
case R.id.menu_save:
- return save(SaveMode.CLOSE, /* backPressed =*/ true);
+ return save(SaveMode.CLOSE);
case R.id.menu_discard:
return revert();
case R.id.menu_delete:
@@ -881,7 +863,7 @@
}
mState.markRawContactsForSplitting();
- save(SaveMode.SPLIT, /* backPressed =*/ false);
+ save(SaveMode.SPLIT);
}
private boolean doSplitContactAction() {
@@ -899,13 +881,13 @@
// If we just started creating a new contact and haven't added any data, it's too
// early to do a join
if (mState.size() == 1 && mState.get(0).isContactInsert()
- && !hasPendingRawContactChanges()) {
+ && !hasPendingChanges()) {
Toast.makeText(mContext, R.string.toast_join_with_empty_contact,
Toast.LENGTH_LONG).show();
return true;
}
- return save(SaveMode.JOIN, /* backPressed =*/ false);
+ return save(SaveMode.JOIN);
}
private void doPickRingtone() {
@@ -941,7 +923,7 @@
}
@Override
- public boolean save(int saveMode, boolean backPressed) {
+ public boolean save(int saveMode) {
if (!hasValidState() || mStatus != Status.EDITING) {
return false;
}
@@ -965,31 +947,19 @@
return true;
}
onSaveCompleted(/* hadChanges =*/ false, saveMode,
- /* saveSucceeded =*/ mLookupUri != null, mLookupUri,
- /* updatedPhotos =*/ null, backPressed, mPhotoId, mNameId);
+ /* saveSucceeded =*/ mLookupUri != null, mLookupUri);
return true;
}
setEnabled(false);
- if (isInsert(getActivity().getIntent()) && saveMode == SaveMode.COMPACT
- && mListener != null && backPressed) {
- // 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(), getPhoneticName(), mUpdatedPhotos, mNewLocalProfile);
- resultIntent.putExtra(INTENT_EXTRA_SAVE_BACK_PRESSED, backPressed);
- mListener.onSaveFinished(resultIntent);
- return true;
- }
- // Otherwise this is an edit or a back press so do an actual save
- return doSaveAction(saveMode, backPressed);
+ return doSaveAction(saveMode);
}
/**
* Persist the accumulated editor deltas.
*/
- abstract protected boolean doSaveAction(int saveMode, boolean backPressed);
+ abstract protected boolean doSaveAction(int saveMode);
//
// State accessor methods
@@ -1011,42 +981,12 @@
* Return true if there are any edits to the current contact which need to
* be saved.
*/
- protected boolean hasPendingRawContactChanges() {
+ protected boolean hasPendingChanges() {
final AccountTypeManager accountTypes = AccountTypeManager.getInstance(mContext);
return RawContactModifier.hasChanges(mState, accountTypes);
}
/**
- * Determines if changes were made in the editor that need to be saved, while taking into
- * account that name changes are not realfor read-only contacts.
- * See go/editing-read-only-contacts
- */
- protected boolean hasPendingChanges() {
- if (mReadOnlyNameEditorView == null || mReadOnlyDisplayName == null) {
- return hasPendingRawContactChanges();
- }
- // We created a new raw contact delta with a default display name.
- // We must test for pending changes while ignoring the default display name.
- final String displayName = mReadOnlyNameEditorView.getDisplayName();
- if (mReadOnlyDisplayName.equals(displayName)) {
- // The user did not modify the default display name, erase it and
- // check if the user made any other changes
- mReadOnlyNameEditorView.setDisplayName(null);
- if (hasPendingRawContactChanges()) {
- // Other changes were made to the aggregate contact, restore
- // the display name and proceed.
- mReadOnlyNameEditorView.setDisplayName(displayName);
- return true;
- } else {
- // No other changes were made to the aggregate contact. Don't add back
- // the displayName so that a "bogus" contact is not created.
- return false;
- }
- }
- return true;
- }
-
- /**
* Whether editor inputs and the options menu should be enabled.
*/
protected boolean isEnabled() {
@@ -1060,16 +1000,6 @@
return mMaterialPalette;
}
- /**
- * Returns the currently displayed display name.
- */
- abstract protected String getDisplayName();
-
- /**
- * Returns the currently displayed phonetic name.
- */
- abstract protected String getPhoneticName();
-
//
// Account creation
//
@@ -1400,9 +1330,6 @@
mIntentExtras.getInt(INTENT_EXTRA_MATERIAL_PALETTE_PRIMARY_COLOR),
mIntentExtras.getInt(INTENT_EXTRA_MATERIAL_PALETTE_SECONDARY_COLOR));
}
- if (mIntentExtras.containsKey(INTENT_EXTRA_UPDATED_PHOTOS)) {
- mUpdatedPhotos = mIntentExtras.getParcelable(INTENT_EXTRA_UPDATED_PHOTOS);
- }
mPhotoId = mIntentExtras.getLong(INTENT_EXTRA_PHOTO_ID);
mNameId = mIntentExtras.getLong(INTENT_EXTRA_NAME_ID);
}
@@ -1427,14 +1354,12 @@
@Override
public void onJoinCompleted(Uri uri) {
- onSaveCompleted(false, SaveMode.RELOAD, uri != null, uri, /* updatedPhotos =*/ null,
- /* backPressed =*/ false, mPhotoId, mNameId);
+ onSaveCompleted(false, SaveMode.RELOAD, uri != null, uri);
}
@Override
public void onSaveCompleted(boolean hadChanges, int saveMode, boolean saveSucceeded,
- Uri contactLookupUri, Bundle updatedPhotos, boolean backPressed, long photoId,
- long nameId) {
+ Uri contactLookupUri) {
if (hadChanges) {
if (saveSucceeded) {
if (saveMode != SaveMode.JOIN) {
@@ -1445,43 +1370,22 @@
}
}
switch (saveMode) {
- case SaveMode.CLOSE: {
+ case SaveMode.CLOSE:
+ case SaveMode.COMPACT: {
final Intent resultIntent;
if (saveSucceeded && contactLookupUri != null) {
final Uri lookupUri = maybeConvertToLegacyLookupUri(
mContext, contactLookupUri, mLookupUri);
resultIntent = ImplicitIntentsUtil.composeQuickContactIntent(lookupUri,
QuickContactActivity.MODE_FULLY_EXPANDED);
- resultIntent.putExtra(INTENT_EXTRA_SAVE_BACK_PRESSED, backPressed);
} else {
resultIntent = null;
}
+ // It is already saved, so prevent it from being saved again
mStatus = Status.CLOSING;
if (mListener != null) mListener.onSaveFinished(resultIntent);
break;
}
- case SaveMode.COMPACT: {
- if (!hadChanges && !backPressed && isInsert(getActivity().getIntent())) {
- // Reload the empty editor when the Contacts app is resumed
- mStatus = Status.EDITING;
- } else if (backPressed) {
- final Uri lookupUri = maybeConvertToLegacyLookupUri(
- mContext, contactLookupUri, mLookupUri);
- final Intent resultIntent = isInsert(getActivity().getIntent())
- ? EditorIntents.createCompactInsertContactIntent(
- mState, getDisplayName(), getPhoneticName(), updatedPhotos,
- mNewLocalProfile)
- : EditorIntents.createCompactEditContactIntent(
- lookupUri, getMaterialPalette(), updatedPhotos, photoId,
- nameId);
- resultIntent.putExtra(INTENT_EXTRA_SAVE_BACK_PRESSED, true);
- mStatus = Status.CLOSING;
- if (mListener != null) mListener.onSaveFinished(resultIntent);
- } else {
- reloadFullEditor(contactLookupUri);
- }
- break;
- }
case SaveMode.RELOAD:
case SaveMode.JOIN:
if (saveSucceeded && contactLookupUri != null) {
@@ -1489,7 +1393,13 @@
if (saveMode == SaveMode.JOIN && hasValidState()) {
showJoinAggregateActivity(contactLookupUri);
}
- reloadFullEditor(contactLookupUri);
+
+ // If this was in INSERT, we are changing into an EDIT now.
+ // If it already was an EDIT, we are changing to the new Uri now
+ mState = new RawContactDeltaList();
+ load(Intent.ACTION_EDIT, contactLookupUri, null);
+ mStatus = Status.LOADING;
+ getLoaderManager().restartLoader(LOADER_DATA, null, mDataLoaderListener);
}
break;
@@ -1504,13 +1414,6 @@
}
}
- private void reloadFullEditor(Uri contactLookupUri) {
- mState = new RawContactDeltaList();
- load(ContactEditorBaseActivity.ACTION_EDIT, contactLookupUri, null);
- mStatus = Status.LOADING;
- getLoaderManager().restartLoader(LOADER_DATA, null, mDataLoaderListener);
- }
-
/**
* Shows a list of aggregates that can be joined into the currently viewed aggregate.
*
@@ -1646,7 +1549,7 @@
}
mState.setJoinWithRawContacts(rawContactIds);
- save(SaveMode.RELOAD, /* backPressed =*/ false);
+ save(SaveMode.RELOAD);
}
@Override
@@ -1677,25 +1580,6 @@
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
//
diff --git a/src/com/android/contacts/editor/ContactEditorFragment.java b/src/com/android/contacts/editor/ContactEditorFragment.java
index 186640a..da6eeb1 100644
--- a/src/com/android/contacts/editor/ContactEditorFragment.java
+++ b/src/com/android/contacts/editor/ContactEditorFragment.java
@@ -26,7 +26,6 @@
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
-import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
@@ -64,6 +63,7 @@
private static final String KEY_RAW_CONTACT_ID_REQUESTING_PHOTO = "photorequester";
private static final String KEY_CURRENT_PHOTO_URI = "currentphotouri";
+ private static final String KEY_UPDATED_PHOTOS = "updatedPhotos";
// Used to store which raw contact editors have been expanded. Keyed on raw contact ids.
private HashMap<Long, Boolean> mExpandedEditors = new HashMap<Long, Boolean>();
@@ -84,6 +84,7 @@
*/
private PhotoHandler mCurrentPhotoHandler;
private Uri mCurrentPhotoUri;
+ private Bundle mUpdatedPhotos = new Bundle();
public ContactEditorFragment() {
}
@@ -109,16 +110,7 @@
mRawContactIdRequestingPhoto = savedState.getLong(
KEY_RAW_CONTACT_ID_REQUESTING_PHOTO);
mCurrentPhotoUri = savedState.getParcelable(KEY_CURRENT_PHOTO_URI);
- }
- }
-
- @Override
- public void onStop() {
- super.onStop();
-
- // If anything was left unsaved, save it now and return to the compact editor.
- if (!getActivity().isChangingConfigurations() && mStatus == Status.EDITING) {
- save(SaveMode.COMPACT, /* backPressed =*/ false);
+ mUpdatedPhotos = savedState.getParcelable(KEY_UPDATED_PHOTOS);
}
}
@@ -130,14 +122,6 @@
}
@Override
- public boolean onOptionsItemSelected(MenuItem item) {
- if (item.getItemId() == android.R.id.home) {
- return save(SaveMode.COMPACT, /* backPressed =*/ true);
- }
- return super.onOptionsItemSelected(item);
- }
-
- @Override
public void onEditorExpansionChanged() {
updatedExpandedEditorsMap();
}
@@ -261,8 +245,7 @@
final StructuredNameEditorView nameEditor = rawContactEditor.getNameEditor();
nameEditor.setEditorListener(structuredNameListener);
- if (TextUtils.isEmpty(nameEditor.getDisplayName()) &&
- !TextUtils.isEmpty(mReadOnlyDisplayName)) {
+ if (!TextUtils.isEmpty(mReadOnlyDisplayName)) {
nameEditor.setDisplayName(mReadOnlyDisplayName);
mReadOnlyNameEditorView = nameEditor;
}
@@ -306,60 +289,6 @@
}
}
- @Override
- public String getDisplayName() {
- // Return the super primary name if it is non-empty
- for (int i = 0; i < mContent.getChildCount(); i++) {
- final View view = mContent.getChildAt(i);
- if (view instanceof RawContactEditorView) {
- final RawContactEditorView rawContactEditorView = (RawContactEditorView) view;
- final StructuredNameEditorView nameEditorView =
- rawContactEditorView.getNameEditor();
- if (nameEditorView != null) {
- final String displayName = nameEditorView.getDisplayName();
- if (!TextUtils.isEmpty(displayName)) {
- return displayName;
- }
- }
- }
- }
- // Return the first non-empty name
- for (int i = 0; i < mContent.getChildCount(); i++) {
- final View view = mContent.getChildAt(i);
- if (view instanceof RawContactEditorView) {
- final RawContactEditorView rawContactEditorView = (RawContactEditorView) view;
- final StructuredNameEditorView nameEditorView =
- rawContactEditorView.getNameEditor();
- if (nameEditorView != null) {
- final String displayName = nameEditorView.getDisplayName();
- if (!TextUtils.isEmpty(displayName)) {
- return displayName;
- }
- }
- }
- }
- return null;
- }
-
- @Override
- public String getPhoneticName() {
- for (int i = 0; i < mContent.getChildCount(); i++) {
- final View view = mContent.getChildAt(i);
- if (view instanceof RawContactEditorView) {
- final RawContactEditorView rawContactEditorView = (RawContactEditorView) view;
- final PhoneticNameEditorView phoneticNameEditorView =
- (PhoneticNameEditorView) rawContactEditorView.getPhoneticNameEditor();
- if (phoneticNameEditorView != null) {
- final String phoneticName = phoneticNameEditorView.getPhoneticName();
- if (!TextUtils.isEmpty(phoneticName)) {
- return phoneticName;
- }
- }
- }
- }
- return null;
- }
-
/**
* Update the values in {@link #mExpandedEditors}.
*/
@@ -457,21 +386,12 @@
}
@Override
- protected boolean doSaveAction(int saveMode, boolean backPressed) {
- // Save contact and reload the compact editor after saving.
- // Note, the full resolution photos Bundle must be passed to the ContactSaveService
- // and then passed along in the result Intent in order for the compact editor to
- // receive it, instead of mUpdatedPhotos being accessed directly in onSaveCompleted,
- // because we clear mUpdatedPhotos after starting the save service below.
- Intent intent = ContactSaveService.createSaveContactIntent(mContext, mState,
+ protected boolean doSaveAction(int saveMode) {
+ final Intent intent = ContactSaveService.createSaveContactIntent(mContext, mState,
SAVE_MODE_EXTRA_KEY, saveMode, isEditingUserProfile(),
((Activity) mContext).getClass(), ContactEditorActivity.ACTION_SAVE_COMPLETED,
- mUpdatedPhotos, backPressed);
+ mUpdatedPhotos);
mContext.startService(intent);
-
- // Don't try to save the same photos twice.
- mUpdatedPhotos = new Bundle();
-
return true;
}
@@ -480,6 +400,7 @@
outState.putSerializable(KEY_EXPANDED_EDITORS, mExpandedEditors);
outState.putLong(KEY_RAW_CONTACT_ID_REQUESTING_PHOTO, mRawContactIdRequestingPhoto);
outState.putParcelable(KEY_CURRENT_PHOTO_URI, mCurrentPhotoUri);
+ outState.putParcelable(KEY_UPDATED_PHOTOS, mUpdatedPhotos);
super.onSaveInstanceState(outState);
}
@@ -534,12 +455,6 @@
Log.w(TAG, "The contact that requested the photo is no longer present.");
}
- // For inserts where the raw contact ID is a negative number, we must clear any previously
- // saved full resolution photos under negative raw contact IDs so that the compact editor
- // will use the newly selected photo, instead of an old one.
- if (isInsert(getActivity().getIntent()) && rawContact < 0) {
- removeNewRawContactPhotos();
- }
mUpdatedPhotos.putParcelable(String.valueOf(rawContact), photoUri);
}
diff --git a/src/com/android/contacts/editor/EditorIntents.java b/src/com/android/contacts/editor/EditorIntents.java
index 68ce76f..e923c43 100644
--- a/src/com/android/contacts/editor/EditorIntents.java
+++ b/src/com/android/contacts/editor/EditorIntents.java
@@ -44,10 +44,9 @@
* existing contact.
*/
public static Intent createCompactEditContactIntent(Uri contactLookupUri,
- MaterialPalette materialPalette, Bundle updatedPhotos, long photoId, long nameId) {
+ MaterialPalette materialPalette, long photoId, long nameId) {
final Intent intent = new Intent(Intent.ACTION_EDIT, contactLookupUri);
putMaterialPalette(intent, materialPalette);
- putUpdatedPhotos(intent, updatedPhotos);
putPhotoId(intent, photoId);
putNameId(intent, nameId);
return intent;
@@ -58,7 +57,7 @@
*/
public static Intent createCompactInsertContactIntent() {
return createCompactInsertContactIntent(/* rawContactDeltaList =*/ null,
- /* displayName =*/ null, /* phoneticName =*/ null, /* updatedPhotos =*/ null,
+ /* displayName =*/ null, /* phoneticName =*/ null,
/* isNewLocalProfile =*/ false);
}
@@ -67,14 +66,13 @@
* the field values specified by rawContactDeltaList pre-populate in the form.
*/
public static Intent createCompactInsertContactIntent(RawContactDeltaList rawContactDeltaList,
- String displayName, String phoneticName, Bundle updatedPhotos,
+ String displayName, String phoneticName, /* Bundle updatedPhotos, */
boolean isNewLocalProfile) {
final Intent intent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI);
intent.putExtra(ContactEditorFragment.INTENT_EXTRA_NEW_LOCAL_PROFILE, isNewLocalProfile);
if (rawContactDeltaList != null || displayName != null || phoneticName != null) {
putRawContactDeltaValues(intent, rawContactDeltaList, displayName, phoneticName);
}
- putUpdatedPhotos(intent, updatedPhotos);
return intent;
}
@@ -97,8 +95,8 @@
}
/**
- * Returns an Intent to start the fully expanded {@link ContactEditorActivity} for a
- * new contact.
+ * Returns an Intent to start the fully expanded {@link ContactEditorActivity} for an
+ * existing contact.
*/
public static Intent createEditContactIntent(Uri contactLookupUri,
MaterialPalette materialPalette, long photoId, long nameId) {
@@ -111,8 +109,8 @@
}
/**
- * Returns an Intent to start the fully expanded {@link ContactEditorActivity} for an
- * existing contact.
+ * Returns an Intent to start the fully expanded {@link ContactEditorActivity} for a
+ * new contact.
*/
public static Intent createInsertContactIntent(RawContactDeltaList rawContactDeltaList,
String displayName, String phoneticName, Bundle updatedPhotos,
@@ -122,11 +120,9 @@
intent.putExtra(ContactEditorFragment.INTENT_EXTRA_NEW_LOCAL_PROFILE, isNewLocalProfile);
addContactIntentFlags(intent);
putRawContactDeltaValues(intent, rawContactDeltaList, displayName, phoneticName);
- putUpdatedPhotos(intent, updatedPhotos);
return intent;
}
-
private static void addContactIntentFlags(Intent intent) {
intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
| Intent.FLAG_ACTIVITY_FORWARD_RESULT);
@@ -141,12 +137,6 @@
}
}
- private static void putUpdatedPhotos(Intent intent, Bundle updatedPhotos) {
- if (updatedPhotos != null && !updatedPhotos.isEmpty()) {
- intent.putExtra(ContactEditorBaseFragment.INTENT_EXTRA_UPDATED_PHOTOS, updatedPhotos);
- }
- }
-
private static void putPhotoId(Intent intent, long photoId) {
if (photoId >= 0) {
intent.putExtra(ContactEditorBaseFragment.INTENT_EXTRA_PHOTO_ID, photoId);
diff --git a/src/com/android/contacts/editor/KindSectionView.java b/src/com/android/contacts/editor/KindSectionView.java
index a75c2e4..23b0c21 100644
--- a/src/com/android/contacts/editor/KindSectionView.java
+++ b/src/com/android/contacts/editor/KindSectionView.java
@@ -57,15 +57,6 @@
private DataKind mKind;
private RawContactDelta mState;
private boolean mReadOnly;
- private boolean mShowOneEmptyEditor;
-
- /**
- * Whether this KindSectionView will be removed from the layout.
- * We need this because we want to animate KindSectionViews away (which takes time),
- * but calculate which KindSectionViews will be visible immediately after starting removal
- * animations.
- */
- private boolean mMarkedForRemoval;
private ViewIdGenerator mViewIdGenerator;
@@ -112,7 +103,7 @@
@Override
public void onDeleteRequested(Editor editor) {
- if (mShowOneEmptyEditor && getEditorCount() == 1) {
+ if (getEditorCount() == 1) {
// If there is only 1 editor in the section, then don't allow the user to delete it.
// Just clear the fields in the editor.
editor.clearAllFields();
@@ -128,25 +119,6 @@
}
}
- /**
- * Calling this signifies that this entire section view is intended to be removed from the
- * layout. Note, calling this does not change the deleted state of any underlying
- * {@link Editor}, i.e. {@link com.android.contacts.common.model.ValuesDelta#markDeleted()}
- * is not invoked on any editor in this section. It is purely marked for higher level UI
- * layers to manipulate the layout w/o introducing jank.
- * See b/22228718 for context.
- */
- public void markForRemoval() {
- mMarkedForRemoval = true;
- }
-
- /**
- * Whether the entire section view is intended to be removed from the layout.
- */
- public boolean isMarkedForRemoval() {
- return mMarkedForRemoval;
- }
-
@Override
public void onRequest(int request) {
// If a field has become empty or non-empty, then check if another row
@@ -156,22 +128,10 @@
}
}
- /**
- * @param showOneEmptyEditor If true, one empty input will always be displayed,
- * otherwise an empty input will only be displayed if there is no non-empty value.
- */
- public void setShowOneEmptyEditor(boolean showOneEmptyEditor) {
- mShowOneEmptyEditor = showOneEmptyEditor;
- }
-
public void setListener(Listener listener) {
mListener = listener;
}
- public void setIconVisibility(boolean visible) {
- mIcon.setVisibility(visible ? View.VISIBLE : View.INVISIBLE);
- }
-
public void setState(DataKind kind, RawContactDelta state, boolean readOnly,
ViewIdGenerator vig) {
mKind = kind;
@@ -301,7 +261,7 @@
} else if (emptyEditors.size() == 1) {
// We have already reached the maximum number of empty editors. Lets not add any more.
return;
- } else if (mShowOneEmptyEditor) {
+ } else {
final ValuesDelta values = RawContactModifier.insertChild(mState, mKind);
final View newField = createEditorView(values);
if (shouldAnimate) {
@@ -325,16 +285,6 @@
return emptyEditorViews;
}
- public boolean areAllEditorsEmpty() {
- for (int i = 0; i < mEditors.getChildCount(); i++) {
- final View view = mEditors.getChildAt(i);
- if (!((Editor) view).isEmpty()) {
- return false;
- }
- }
- return true;
- }
-
public int getEditorCount() {
return mEditors.getChildCount();
}
diff --git a/src/com/android/contacts/editor/PhoneticNameEditorView.java b/src/com/android/contacts/editor/PhoneticNameEditorView.java
index f094d55..420575c 100644
--- a/src/com/android/contacts/editor/PhoneticNameEditorView.java
+++ b/src/com/android/contacts/editor/PhoneticNameEditorView.java
@@ -151,8 +151,4 @@
return !TextUtils.isEmpty(family) || !TextUtils.isEmpty(middle)
|| !TextUtils.isEmpty(given);
}
-
- public String getPhoneticName() {
- return getEntry().getAsString(DataKind.PSEUDO_COLUMN_PHONETIC_NAME);
- }
}
diff --git a/src/com/android/contacts/editor/RawContactEditorView.java b/src/com/android/contacts/editor/RawContactEditorView.java
index f021ec7..1832ce2 100644
--- a/src/com/android/contacts/editor/RawContactEditorView.java
+++ b/src/com/android/contacts/editor/RawContactEditorView.java
@@ -282,7 +282,6 @@
if (kind.fieldList == null) continue;
final KindSectionView section = (KindSectionView)mInflater.inflate(
R.layout.item_kind_section, mFields, false);
- section.setShowOneEmptyEditor(true);
section.setEnabled(isEnabled());
section.setState(kind, state, /* readOnly =*/ false, vig);
mFields.addView(section);
diff --git a/src/com/android/contacts/editor/StructuredNameEditorView.java b/src/com/android/contacts/editor/StructuredNameEditorView.java
index c0463b0..bef62e3 100644
--- a/src/com/android/contacts/editor/StructuredNameEditorView.java
+++ b/src/com/android/contacts/editor/StructuredNameEditorView.java
@@ -207,34 +207,6 @@
super.setValue(0, name);
}
- /**
- * Returns the display name currently displayed in the editor.
- */
- public String getDisplayName() {
- final ValuesDelta valuesDelta = getValues();
- if (hasShortAndLongForms()) {
- if (areOptionalFieldsVisible()) {
- final Map<String, String> structuredNameMap = valuesToStructuredNameMap(valuesDelta);
- final String displayName = NameConverter.structuredNameToDisplayName(
- getContext(), structuredNameMap);
- if (!TextUtils.isEmpty(displayName)) {
- return displayName;
- }
- } else {
- final String displayName = valuesDelta.getDisplayName();
- if (!TextUtils.isEmpty(displayName)) {
- return displayName;
- }
- }
- }
- return valuesDelta.getDisplayName();
- }
-
- @Override
- public boolean isEmpty() {
- return TextUtils.isEmpty(getDisplayName());
- }
-
@Override
protected Parcelable onSaveInstanceState() {
SavedState state = new SavedState(super.onSaveInstanceState());
diff --git a/src/com/android/contacts/quickcontact/InvisibleContactUtil.java b/src/com/android/contacts/quickcontact/InvisibleContactUtil.java
index de70424..3609fbc 100644
--- a/src/com/android/contacts/quickcontact/InvisibleContactUtil.java
+++ b/src/com/android/contacts/quickcontact/InvisibleContactUtil.java
@@ -94,7 +94,7 @@
final Intent intent = ContactSaveService.createSaveContactIntent(
context,
contactDeltaList, "", 0, false, QuickContactActivity.class,
- Intent.ACTION_VIEW, null, /* backPressed =*/ false);
+ Intent.ACTION_VIEW, null);
context.startService(intent);
}
diff --git a/src/com/android/contacts/quickcontact/QuickContactActivity.java b/src/com/android/contacts/quickcontact/QuickContactActivity.java
index 8bb6976..eaadc3d 100644
--- a/src/com/android/contacts/quickcontact/QuickContactActivity.java
+++ b/src/com/android/contacts/quickcontact/QuickContactActivity.java
@@ -2267,7 +2267,6 @@
mContactData.getLookupUri(),
mHasComputedThemeColor
? new MaterialPalette(mColorFilterColor, mStatusBarColor) : null,
- /* updatedPhotos =*/ null,
mContactData.getPhotoId(),
mContactData.getNameRawContactId());
}