Disable state save/restore for inflated date/time picker views
Fix a bug where the internal date/time picker views reused view IDs
causing state save/restore bugs when placed within AlertDialogs and
other places. Since the pickers already save/restore their state at a
higher level leaving this enabled was redundant.
Bug 32654446
Test: manual
Change-Id: I3df2fc932ac5296ab6eb0a5013dddef8d1117635
diff --git a/core/java/android/widget/DatePickerCalendarDelegate.java b/core/java/android/widget/DatePickerCalendarDelegate.java
index ca1bf58..636519b 100755
--- a/core/java/android/widget/DatePickerCalendarDelegate.java
+++ b/core/java/android/widget/DatePickerCalendarDelegate.java
@@ -112,6 +112,7 @@
// Set up and attach container.
mContainer = (ViewGroup) inflater.inflate(layoutResourceId, mDelegator, false);
+ mContainer.setSaveFromParentEnabled(false);
mDelegator.addView(mContainer);
// Set up header views.
diff --git a/core/java/android/widget/DatePickerSpinnerDelegate.java b/core/java/android/widget/DatePickerSpinnerDelegate.java
index fc2d1fa..4f9316f 100644
--- a/core/java/android/widget/DatePickerSpinnerDelegate.java
+++ b/core/java/android/widget/DatePickerSpinnerDelegate.java
@@ -115,7 +115,8 @@
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- inflater.inflate(layoutResourceId, mDelegator, true);
+ final View view = inflater.inflate(layoutResourceId, mDelegator, true);
+ view.setSaveFromParentEnabled(false);
OnValueChangeListener onChangeListener = new OnValueChangeListener() {
public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
diff --git a/core/java/android/widget/TimePickerClockDelegate.java b/core/java/android/widget/TimePickerClockDelegate.java
index 05d0f96..d3c83ee 100644
--- a/core/java/android/widget/TimePickerClockDelegate.java
+++ b/core/java/android/widget/TimePickerClockDelegate.java
@@ -137,6 +137,7 @@
final int layoutResourceId = a.getResourceId(R.styleable.TimePicker_internalLayout,
R.layout.time_picker_material);
final View mainView = inflater.inflate(layoutResourceId, delegator);
+ mainView.setSaveFromParentEnabled(false);
mRadialTimePickerHeader = mainView.findViewById(R.id.time_header);
mRadialTimePickerHeader.setOnTouchListener(new NearestTouchDelegate());
diff --git a/core/java/android/widget/TimePickerSpinnerDelegate.java b/core/java/android/widget/TimePickerSpinnerDelegate.java
index 813c30e3..7a7d9a9 100644
--- a/core/java/android/widget/TimePickerSpinnerDelegate.java
+++ b/core/java/android/widget/TimePickerSpinnerDelegate.java
@@ -83,7 +83,8 @@
a.recycle();
final LayoutInflater inflater = LayoutInflater.from(mContext);
- inflater.inflate(layoutResourceId, mDelegator, true);
+ final View view = inflater.inflate(layoutResourceId, mDelegator, true);
+ view.setSaveFromParentEnabled(false);
// hour
mHourSpinner = delegator.findViewById(R.id.hour);