OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.content.browser.input; | 5 package org.chromium.content.browser.input; |
6 | 6 |
7 import android.app.AlertDialog; | 7 import android.app.AlertDialog; |
8 import android.app.DatePickerDialog; | 8 import android.app.DatePickerDialog; |
9 import android.app.TimePickerDialog; | 9 import android.app.TimePickerDialog; |
10 import android.app.DatePickerDialog.OnDateSetListener; | 10 import android.app.DatePickerDialog.OnDateSetListener; |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 mDialog = new WeekPickerDialog(mContext, new MonthOrWeekListener(dia
logType), | 161 mDialog = new WeekPickerDialog(mContext, new MonthOrWeekListener(dia
logType), |
162 year, week, minTime, maxTime); | 162 year, week, minTime, maxTime); |
163 } | 163 } |
164 | 164 |
165 mDialog.setButton(DialogInterface.BUTTON_POSITIVE, | 165 mDialog.setButton(DialogInterface.BUTTON_POSITIVE, |
166 mContext.getText(R.string.date_picker_dialog_set), | 166 mContext.getText(R.string.date_picker_dialog_set), |
167 (DialogInterface.OnClickListener) mDialog); | 167 (DialogInterface.OnClickListener) mDialog); |
168 | 168 |
169 mDialog.setButton(DialogInterface.BUTTON_NEGATIVE, | 169 mDialog.setButton(DialogInterface.BUTTON_NEGATIVE, |
170 mContext.getText(android.R.string.cancel), | 170 mContext.getText(android.R.string.cancel), |
171 new DialogInterface.OnClickListener() { | 171 (DialogInterface.OnClickListener) null); |
172 @Override | |
173 public void onClick(DialogInterface dialog, int which) { | |
174 mDialogAlreadyDismissed = true; | |
175 mInputActionDelegate.cancelDateTimeDialog(); | |
176 } | |
177 }); | |
178 | 172 |
179 mDialog.setButton(DialogInterface.BUTTON_NEUTRAL, | 173 mDialog.setButton(DialogInterface.BUTTON_NEUTRAL, |
180 mContext.getText(R.string.date_picker_dialog_clear), | 174 mContext.getText(R.string.date_picker_dialog_clear), |
181 new DialogInterface.OnClickListener() { | 175 new DialogInterface.OnClickListener() { |
182 @Override | 176 @Override |
183 public void onClick(DialogInterface dialog, int which) { | 177 public void onClick(DialogInterface dialog, int which) { |
184 mDialogAlreadyDismissed = true; | 178 mDialogAlreadyDismissed = true; |
185 mInputActionDelegate.replaceDateTime(dialogType, 0, 0, 0
, 0, 0, 0, 0, 0); | 179 mInputActionDelegate.replaceDateTime(dialogType, 0, 0, 0
, 0, 0, 0, 0, 0); |
186 } | 180 } |
187 }); | 181 }); |
188 | 182 |
| 183 mDialog.setOnDismissListener( |
| 184 new OnDismissListener() { |
| 185 public void onDismiss(final DialogInterface dialog) { |
| 186 if (!mDialogAlreadyDismissed) { |
| 187 mDialogAlreadyDismissed = true; |
| 188 mInputActionDelegate.cancelDateTimeDialog(); |
| 189 } |
| 190 } |
| 191 }); |
| 192 |
189 mDialogAlreadyDismissed = false; | 193 mDialogAlreadyDismissed = false; |
190 mDialog.show(); | 194 mDialog.show(); |
191 } | 195 } |
192 | 196 |
193 boolean isDialogShowing() { | 197 boolean isDialogShowing() { |
194 return mDialog != null && mDialog.isShowing(); | 198 return mDialog != null && mDialog.isShowing(); |
195 } | 199 } |
196 | 200 |
197 void dismissDialog() { | 201 void dismissDialog() { |
198 if (isDialogShowing()) mDialog.dismiss(); | 202 if (isDialogShowing()) mDialog.dismiss(); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 int year, int month, int monthDay, int hourOfDay, | 311 int year, int month, int monthDay, int hourOfDay, |
308 int minute, int second, int milli, int week, String dateFormat) { | 312 int minute, int second, int milli, int week, String dateFormat) { |
309 // Prevents more than one callback being sent to the native | 313 // Prevents more than one callback being sent to the native |
310 // side when the dialog triggers multiple events. | 314 // side when the dialog triggers multiple events. |
311 mDialogAlreadyDismissed = true; | 315 mDialogAlreadyDismissed = true; |
312 | 316 |
313 mInputActionDelegate.replaceDateTime( | 317 mInputActionDelegate.replaceDateTime( |
314 dialogType, year, month, monthDay, hourOfDay, minute, second, milli,
week); | 318 dialogType, year, month, monthDay, hourOfDay, minute, second, milli,
week); |
315 } | 319 } |
316 } | 320 } |
OLD | NEW |