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

Side by Side Diff: content/public/android/java/src/org/chromium/content/browser/input/DateTimeChooserAndroid.java

Issue 23623019: Support datalist for date/time input types on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Used double to transfer value Created 7 years, 2 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 unified diff | Download patch
OLDNEW
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 org.chromium.base.CalledByNative; 7 import org.chromium.base.CalledByNative;
8 import org.chromium.base.JNINamespace; 8 import org.chromium.base.JNINamespace;
9 import org.chromium.content.browser.ContentViewCore; 9 import org.chromium.content.browser.ContentViewCore;
10 10
11 import android.content.Context; 11 import android.content.Context;
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 int mNativeDateTimeChooserAndroid; 19 private final int mNativeDateTimeChooserAndroid;
20 private final InputDialogContainer mInputDialogContainer; 20 private final InputDialogContainer mInputDialogContainer;
21 21
22 private DateTimeChooserAndroid(Context context, 22 private DateTimeChooserAndroid(Context context,
23 int nativeDateTimeChooserAndroid) { 23 int 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 value,
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 DateTimeSuggestion[] suggestions) {
48 mInputDialogContainer.showDialog( 43 mInputDialogContainer.showDialog(
49 dialogType, year, month, monthDay, 44 dialogType, value, min, max, step, suggestions);
50 hour, minute, second, milli, week, min, max, step);
51 } 45 }
52 46
53 @CalledByNative 47 @CalledByNative
54 private static DateTimeChooserAndroid createDateTimeChooser( 48 private static DateTimeChooserAndroid createDateTimeChooser(
55 ContentViewCore contentViewCore, 49 ContentViewCore contentViewCore,
56 int nativeDateTimeChooserAndroid, int dialogType, 50 int nativeDateTimeChooserAndroid,
57 int year, int month, int day, 51 int dialogType, double value,
58 int hour, int minute, int second, int milli, int week, 52 double min, double max, double step,
59 double min, double max, double step) { 53 DateTimeSuggestion[] suggestions) {
60 DateTimeChooserAndroid chooser = 54 DateTimeChooserAndroid chooser =
61 new DateTimeChooserAndroid( 55 new DateTimeChooserAndroid(
62 contentViewCore.getContext(), 56 contentViewCore.getContext(),
63 nativeDateTimeChooserAndroid); 57 nativeDateTimeChooserAndroid);
64 chooser.showDialog( 58 chooser.showDialog(dialogType, value, min, max, step, suggestions);
65 dialogType, year, month, day, hour, minute, second, milli,
66 week, min, max, step);
67 return chooser; 59 return chooser;
68 } 60 }
69 61
62 /**
63 * @param value Value of the suggestion.
64 * @param localizedValue Localized value of the suggestion.
65 * @param label Label of the suggestion.
66 */
67 @CalledByNative
68 private static DateTimeSuggestion createDateTimeSuggestion(
69 double value, String localizedValue, String label) {
70 return new DateTimeSuggestion(value, localizedValue, label);
71 }
72
70 @CalledByNative 73 @CalledByNative
71 private static void initializeDateInputTypes( 74 private static void initializeDateInputTypes(
72 int textInputTypeDate, int textInputTypeDateTime, 75 int textInputTypeDate, int textInputTypeDateTime,
73 int textInputTypeDateTimeLocal, int textInputTypeMonth, 76 int textInputTypeDateTimeLocal, int textInputTypeMonth,
74 int textInputTypeTime, int textInputTypeWeek) { 77 int textInputTypeTime, int textInputTypeWeek) {
75 InputDialogContainer.initializeInputTypes(textInputTypeDate, 78 InputDialogContainer.initializeInputTypes(
79 textInputTypeDate,
76 textInputTypeDateTime, textInputTypeDateTimeLocal, 80 textInputTypeDateTime, textInputTypeDateTimeLocal,
77 textInputTypeMonth, textInputTypeTime, textInputTypeWeek); 81 textInputTypeMonth, textInputTypeTime, textInputTypeWeek);
78 } 82 }
79 83
80 private native void nativeReplaceDateTime( 84 private native void nativeReplaceDateTime(
81 int nativeDateTimeChooserAndroid, int dialogType, 85 int nativeDateTimeChooserAndroid, double value);
82 int year, int month, int day, int hour, int minute,
83 int second, int milli, int week);
84 86
85 private native void nativeCancelDialog(int nativeDateTimeChooserAndroid); 87 private native void nativeCancelDialog(int nativeDateTimeChooserAndroid);
86 } 88 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698