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
diff --git a/src/com/android/contacts/editor/CompactPhotoEditorView.java b/src/com/android/contacts/editor/CompactPhotoEditorView.java
index 1cb4538..5f3e9af 100644
--- a/src/com/android/contacts/editor/CompactPhotoEditorView.java
+++ b/src/com/android/contacts/editor/CompactPhotoEditorView.java
@@ -278,7 +278,7 @@
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 32c3d37..18b1381 100644
--- a/src/com/android/contacts/editor/ContactEditorBaseFragment.java
+++ b/src/com/android/contacts/editor/ContactEditorBaseFragment.java
@@ -163,11 +163,20 @@
"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 @@
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 1ec6db9..a3c29fc 100644
--- a/src/com/android/contacts/editor/EditorIntents.java
+++ b/src/com/android/contacts/editor/EditorIntents.java
@@ -129,8 +129,10 @@
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);
}
}