| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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.content.Context; | 7 import android.content.Context; |
| 8 | 8 |
| 9 import org.chromium.base.CalledByNative; | 9 import org.chromium.base.CalledByNative; |
| 10 import org.chromium.base.JNINamespace; | 10 import org.chromium.base.JNINamespace; |
| 11 import org.chromium.content.browser.ContentViewCore; | 11 import org.chromium.content.browser.ContentViewCore; |
| 12 | 12 |
| 13 /** | 13 /** |
| 14 * Plumbing for the different date/time dialog adapters. | 14 * Plumbing for the different date/time dialog adapters. |
| 15 */ | 15 */ |
| 16 @JNINamespace("content") | 16 @JNINamespace("content") |
| 17 class DateTimeChooserAndroid { | 17 class DateTimeChooserAndroid { |
| 18 | 18 |
| 19 private final long mNativeDateTimeChooserAndroid; | 19 private final long mNativeDateTimeChooserAndroid; |
| 20 private final InputDialogContainer mInputDialogContainer; | 20 private final InputDialogContainer mInputDialogContainer; |
| 21 | 21 |
| 22 private DateTimeChooserAndroid(Context context, | 22 private DateTimeChooserAndroid(Context context, |
| 23 long nativeDateTimeChooserAndroid) { | 23 long nativeDateTimeChooserAndroid) { |
| 24 mNativeDateTimeChooserAndroid = nativeDateTimeChooserAndroid; | 24 mNativeDateTimeChooserAndroid = nativeDateTimeChooserAndroid; |
| 25 mInputDialogContainer = new InputDialogContainer(context, | 25 mInputDialogContainer = new InputDialogContainer(context, |
| 26 new InputDialogContainer.InputActionDelegate() { | 26 new InputDialogContainer.InputActionDelegate() { |
| 27 | 27 |
| 28 @Override | 28 @Override |
| 29 public void replaceDateTime( | 29 public void replaceDateTime(double value) { |
| 30 int dialogType, | 30 nativeReplaceDateTime(mNativeDateTimeChooserAndroid, value); |
| 31 int year, int month, int day, int hour, int minute, | |
| 32 int second, int milli, int week) { | |
| 33 nativeReplaceDateTime(mNativeDateTimeChooserAndroid, | |
| 34 dialogType, | |
| 35 year, month, day, hour, minute, second, milli, week); | |
| 36 } | 31 } |
| 37 | 32 |
| 38 @Override | 33 @Override |
| 39 public void cancelDateTimeDialog() { | 34 public void cancelDateTimeDialog() { |
| 40 nativeCancelDialog(mNativeDateTimeChooserAndroid); | 35 nativeCancelDialog(mNativeDateTimeChooserAndroid); |
| 41 } | 36 } |
| 42 }); | 37 }); |
| 43 } | 38 } |
| 44 | 39 |
| 45 private void showDialog(int dialogType, int year, int month, int monthDay, | 40 private void showDialog(int dialogType, double dialogValue, |
| 46 int hour, int minute, int second, int milli, | 41 double min, double max, double step) { |
| 47 int week, double min, double max, double step) { | 42 mInputDialogContainer.showDialog(dialogType, dialogValue, min, max, step
); |
| 48 mInputDialogContainer.showDialog( | |
| 49 dialogType, year, month, monthDay, | |
| 50 hour, minute, second, milli, week, min, max, step); | |
| 51 } | 43 } |
| 52 | 44 |
| 53 @CalledByNative | 45 @CalledByNative |
| 54 private static DateTimeChooserAndroid createDateTimeChooser( | 46 private static DateTimeChooserAndroid createDateTimeChooser( |
| 55 ContentViewCore contentViewCore, | 47 ContentViewCore contentViewCore, |
| 56 long nativeDateTimeChooserAndroid, int dialogType, | 48 long nativeDateTimeChooserAndroid, |
| 57 int year, int month, int day, | 49 int dialogType, double dialogValue, |
| 58 int hour, int minute, int second, int milli, int week, | |
| 59 double min, double max, double step) { | 50 double min, double max, double step) { |
| 60 DateTimeChooserAndroid chooser = | 51 DateTimeChooserAndroid chooser = |
| 61 new DateTimeChooserAndroid( | 52 new DateTimeChooserAndroid( |
| 62 contentViewCore.getContext(), | 53 contentViewCore.getContext(), |
| 63 nativeDateTimeChooserAndroid); | 54 nativeDateTimeChooserAndroid); |
| 64 chooser.showDialog( | 55 chooser.showDialog(dialogType, dialogValue, min, max, step); |
| 65 dialogType, year, month, day, hour, minute, second, milli, | |
| 66 week, min, max, step); | |
| 67 return chooser; | 56 return chooser; |
| 68 } | 57 } |
| 69 | 58 |
| 70 @CalledByNative | 59 @CalledByNative |
| 71 private static void initializeDateInputTypes( | 60 private static void initializeDateInputTypes( |
| 72 int textInputTypeDate, int textInputTypeDateTime, | 61 int textInputTypeDate, int textInputTypeDateTime, |
| 73 int textInputTypeDateTimeLocal, int textInputTypeMonth, | 62 int textInputTypeDateTimeLocal, int textInputTypeMonth, |
| 74 int textInputTypeTime, int textInputTypeWeek) { | 63 int textInputTypeTime, int textInputTypeWeek) { |
| 75 InputDialogContainer.initializeInputTypes(textInputTypeDate, | 64 InputDialogContainer.initializeInputTypes(textInputTypeDate, |
| 76 textInputTypeDateTime, textInputTypeDateTimeLocal, | 65 textInputTypeDateTime, textInputTypeDateTimeLocal, |
| 77 textInputTypeMonth, textInputTypeTime, textInputTypeWeek); | 66 textInputTypeMonth, textInputTypeTime, textInputTypeWeek); |
| 78 } | 67 } |
| 79 | 68 |
| 80 private native void nativeReplaceDateTime( | 69 private native void nativeReplaceDateTime(long nativeDateTimeChooserAndroid, |
| 81 long nativeDateTimeChooserAndroid, int dialogType, | 70 double dialogValue); |
| 82 int year, int month, int day, int hour, int minute, | |
| 83 int second, int milli, int week); | |
| 84 | 71 |
| 85 private native void nativeCancelDialog(long nativeDateTimeChooserAndroid); | 72 private native void nativeCancelDialog(long nativeDateTimeChooserAndroid); |
| 86 } | 73 } |
| OLD | NEW |