From 03debc685e254b85df07fc9d213f17967a5fca9a Mon Sep 17 00:00:00 2001 From: Walter Jang Date: Mon, 20 Jul 2015 09:36:07 -0700 Subject: Pass MaterialPalete colors to contact editor as ints not Parcelable The MaterialPalette class is not public and crashes the edit contact app selector if any third party app also has a filter for android.intent.action.EDIT in their manifest. Bug 22564102 Change-Id: I0926108bf83431e4c80412571062f7bc561c3de5 --- .../contacts/editor/CompactPhotoEditorView.java | 2 +- .../contacts/editor/ContactEditorBaseFragment.java | 24 +++++++++++++++++----- src/com/android/contacts/editor/EditorIntents.java | 6 ++++-- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/com/android/contacts/editor/CompactPhotoEditorView.java b/src/com/android/contacts/editor/CompactPhotoEditorView.java index 1cb45380d..5f3e9afad 100644 --- a/src/com/android/contacts/editor/CompactPhotoEditorView.java +++ b/src/com/android/contacts/editor/CompactPhotoEditorView.java @@ -278,7 +278,7 @@ public class CompactPhotoEditorView extends RelativeLayout implements View.OnCli private void setDefaultPhotoTint() { final int color = mMaterialPalette == null ? MaterialColorMapUtils.getDefaultPrimaryAndSecondaryColors( - getResources()).mPrimaryColor + getResources()).mPrimaryColor : mMaterialPalette.mPrimaryColor; mPhotoImageView.setTint(color); } diff --git a/src/com/android/contacts/editor/ContactEditorBaseFragment.java b/src/com/android/contacts/editor/ContactEditorBaseFragment.java index 32c3d3784..18b138190 100644 --- a/src/com/android/contacts/editor/ContactEditorBaseFragment.java +++ b/src/com/android/contacts/editor/ContactEditorBaseFragment.java @@ -163,11 +163,20 @@ abstract public class ContactEditorBaseFragment extends Fragment implements "disableDeleteMenuOption"; /** - * Intent key to pass the photo palette calculated by - * {@link com.android.contacts.quickcontact.QuickContactActivity} to and between the compact - * editor and fully expanded editor. + * Intent key to pass the photo palette primary color calculated by + * {@link com.android.contacts.quickcontact.QuickContactActivity} to the editor and between + * the compact and fully expanded editors. */ - public static final String INTENT_EXTRA_MATERIAL_PALETTE = "material_palette"; + public static final String INTENT_EXTRA_MATERIAL_PALETTE_PRIMARY_COLOR = + "material_palette_primary_color"; + + /** + * Intent key to pass the photo palette secondary color calculated by + * {@link com.android.contacts.quickcontact.QuickContactActivity} to the editor and between + * the compact and fully expanded editors. + */ + public static final String INTENT_EXTRA_MATERIAL_PALETTE_SECONDARY_COLOR = + "material_palette_secondary_color"; /** * Intent key to pass a Bundle of raw contact IDs to photos URIs between the compact editor @@ -1358,7 +1367,12 @@ 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); + if (mIntentExtras.containsKey(INTENT_EXTRA_MATERIAL_PALETTE_PRIMARY_COLOR) + && mIntentExtras.containsKey(INTENT_EXTRA_MATERIAL_PALETTE_SECONDARY_COLOR)) { + mMaterialPalette = new MaterialColorMapUtils.MaterialPalette( + 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); } diff --git a/src/com/android/contacts/editor/EditorIntents.java b/src/com/android/contacts/editor/EditorIntents.java index 1ec6db945..a3c29fc8c 100644 --- a/src/com/android/contacts/editor/EditorIntents.java +++ b/src/com/android/contacts/editor/EditorIntents.java @@ -129,8 +129,10 @@ public class EditorIntents { private static void putMaterialPalette(Intent intent, MaterialPalette materialPalette) { if (materialPalette != null) { - intent.putExtra(ContactEditorBaseFragment.INTENT_EXTRA_MATERIAL_PALETTE, - materialPalette); + intent.putExtra(ContactEditorBaseFragment.INTENT_EXTRA_MATERIAL_PALETTE_PRIMARY_COLOR, + materialPalette.mPrimaryColor); + intent.putExtra(ContactEditorBaseFragment.INTENT_EXTRA_MATERIAL_PALETTE_SECONDARY_COLOR, + materialPalette.mSecondaryColor); } } -- cgit v1.2.3