Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1634)

Unified Diff: content/public/android/java/src/org/chromium/content/browser/input/ChromeDatePickerDialog.java

Issue 260903006: Dismissing of date/time dialogs should not set the value (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/public/android/java/src/org/chromium/content/browser/input/DateTimePickerDialog.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/android/java/src/org/chromium/content/browser/input/ChromeDatePickerDialog.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/input/ChromeDatePickerDialog.java b/content/public/android/java/src/org/chromium/content/browser/input/ChromeDatePickerDialog.java
new file mode 100644
index 0000000000000000000000000000000000000000..e759e8550aaa9bd25a0b5b480fdadde430717661
--- /dev/null
+++ b/content/public/android/java/src/org/chromium/content/browser/input/ChromeDatePickerDialog.java
@@ -0,0 +1,43 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.content.browser.input;
+
+import android.app.DatePickerDialog.OnDateSetListener;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.widget.DatePicker;
+
+/**
+ * The behavior of the DatePickerDialog changed after JellyBean so it now calls
+ * OndateSetListener.onDateSet() even when the dialog is dismissed (e.g. back button, tap
+ * outside). This class will call the listener instead of the DatePickerDialog only when the
+ * BUTTON_POSITIVE has been clicked.
+ */
+class ChromeDatePickerDialog extends android.app.DatePickerDialog {
+ private final OnDateSetListener mCallBack;
+
+ public ChromeDatePickerDialog(Context context,
+ OnDateSetListener callBack,
+ int year,
+ int monthOfYear,
+ int dayOfMonth) {
+ super(context, 0, null, year, monthOfYear, dayOfMonth);
+ mCallBack = callBack;
+ }
+
+ /**
+ * The superclass DatePickerDialog has null for OnDateSetListener so we need to call the
+ * listener manually.
+ */
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ if (which == BUTTON_POSITIVE && mCallBack != null) {
+ DatePicker datePicker = getDatePicker();
+ datePicker.clearFocus();
+ mCallBack.onDateSet(datePicker, datePicker.getYear(),
+ datePicker.getMonth(), datePicker.getDayOfMonth());
+ }
+ }
+}
« no previous file with comments | « no previous file | content/public/android/java/src/org/chromium/content/browser/input/DateTimePickerDialog.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698