Merge "Import translations. DO NOT MERGE" into jb-mr2-dev
diff --git a/src/com/android/calendar/CalendarEventModel.java b/src/com/android/calendar/CalendarEventModel.java
index ef04368..8f6507e 100644
--- a/src/com/android/calendar/CalendarEventModel.java
+++ b/src/com/android/calendar/CalendarEventModel.java
@@ -941,5 +941,4 @@
         }
         return -1;
     }
-
 }
diff --git a/src/com/android/calendar/event/EditEventFragment.java b/src/com/android/calendar/event/EditEventFragment.java
index 70c9bc0..6b350b0 100644
--- a/src/com/android/calendar/event/EditEventFragment.java
+++ b/src/com/android/calendar/event/EditEventFragment.java
@@ -81,6 +81,7 @@
     private static final String BUNDLE_KEY_EVENT = "key_event";
     private static final String BUNDLE_KEY_READ_ONLY = "key_read_only";
     private static final String BUNDLE_KEY_EDIT_ON_LAUNCH = "key_edit_on_launch";
+    private static final String BUNDLE_KEY_SHOW_COLOR_PALETTE = "show_color_palette";
 
     private static final String BUNDLE_KEY_DATE_BUTTON_CLICKED = "date_button_clicked";
 
@@ -131,6 +132,7 @@
     private boolean mSaveOnDetach = true;
     private boolean mIsReadOnly = false;
     public boolean mShowModifyDialogOnLaunch = false;
+    private boolean mShowColorPalette = false;
 
     private boolean mTimeSelectedWasStartTime;
     private boolean mDateSelectedWasStartDate;
@@ -365,7 +367,16 @@
                     if (cursor != null) {
                         cursor.close();
                     }
-                    mView.setColorPickerButtonStates(mModel.getCalendarEventColors());
+
+                    // If the account name/type is null, the calendar event colors cannot be
+                    // determined, so take the default/savedInstanceState value.
+                    if (mModel.mCalendarAccountName == null
+                           || mModel.mCalendarAccountType == null) {
+                        mView.setColorPickerButtonStates(mShowColorPalette);
+                    } else {
+                        mView.setColorPickerButtonStates(mModel.getCalendarEventColors());
+                    }
+
                     setModelIfDone(TOKEN_COLORS);
                     break;
                 default:
@@ -605,6 +616,9 @@
                 mDateSelectedWasStartDate = savedInstanceState.getBoolean(
                         BUNDLE_KEY_DATE_BUTTON_CLICKED);
             }
+            if (savedInstanceState.containsKey(BUNDLE_KEY_SHOW_COLOR_PALETTE)) {
+                mShowColorPalette = savedInstanceState.getBoolean(BUNDLE_KEY_SHOW_COLOR_PALETTE);
+            }
 
         }
     }
@@ -928,6 +942,7 @@
         outState.putBoolean(BUNDLE_KEY_EDIT_ON_LAUNCH, mShowModifyDialogOnLaunch);
         outState.putSerializable(BUNDLE_KEY_EVENT, mEventBundle);
         outState.putBoolean(BUNDLE_KEY_READ_ONLY, mIsReadOnly);
+        outState.putBoolean(BUNDLE_KEY_SHOW_COLOR_PALETTE, mView.isColorPaletteVisible());
 
         outState.putBoolean("EditEventView_timebuttonclicked", mView.mTimeSelectedWasStartTime);
         outState.putBoolean(BUNDLE_KEY_DATE_BUTTON_CLICKED, mView.mDateSelectedWasStartDate);
diff --git a/src/com/android/calendar/event/EditEventView.java b/src/com/android/calendar/event/EditEventView.java
index 2ec8f67..09daa0c 100644
--- a/src/com/android/calendar/event/EditEventView.java
+++ b/src/com/android/calendar/event/EditEventView.java
@@ -1354,8 +1354,8 @@
         CalendarsAdapter adapter = new CalendarsAdapter(mActivity,
             R.layout.calendars_spinner_item, cursor);
         mCalendarsSpinner.setAdapter(adapter);
-        mCalendarsSpinner.setSelection(selection);
         mCalendarsSpinner.setOnItemSelectedListener(this);
+        mCalendarsSpinner.setSelection(selection);
 
         if (mSaveAfterQueryComplete) {
             mLoadingCalendarsDialog.cancel();
@@ -1691,16 +1691,25 @@
         updateHomeTime();
     }
 
-    public void setColorPickerButtonStates(int[] eventColors) {
-        if (eventColors == null || eventColors.length == 0) {
-            mColorPickerNewEvent.setVisibility(View.INVISIBLE);
-            mColorPickerExistingEvent.setVisibility(View.GONE);
-        } else {
+    public void setColorPickerButtonStates(int[] colorArray) {
+        setColorPickerButtonStates(colorArray != null && colorArray.length > 0);
+    }
+
+    public void setColorPickerButtonStates(boolean showColorPalette) {
+        if (showColorPalette) {
             mColorPickerNewEvent.setVisibility(View.VISIBLE);
             mColorPickerExistingEvent.setVisibility(View.VISIBLE);
+        } else {
+            mColorPickerNewEvent.setVisibility(View.INVISIBLE);
+            mColorPickerExistingEvent.setVisibility(View.GONE);
         }
     }
 
+    public boolean isColorPaletteVisible() {
+        return mColorPickerNewEvent.getVisibility() == View.VISIBLE ||
+                mColorPickerExistingEvent.getVisibility() == View.VISIBLE;
+    }
+
     @Override
     public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
         // This is only used for the Calendar spinner in new events, and only fires when the