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

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: Created 7 years 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 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 DateTimeSuggestion[] suggestions) {
48 mInputDialogContainer.showDialog( 43 mInputDialogContainer.showDialog(dialogType, dialogValue, min, max, step , suggestions);
49 dialogType, year, month, monthDay,
50 hour, minute, second, milli, week, min, max, step);
51 } 44 }
52 45
53 @CalledByNative 46 @CalledByNative
54 private static DateTimeChooserAndroid createDateTimeChooser( 47 private static DateTimeChooserAndroid createDateTimeChooser(
55 ContentViewCore contentViewCore, 48 ContentViewCore contentViewCore,
56 long nativeDateTimeChooserAndroid, int dialogType, 49 long nativeDateTimeChooserAndroid,
57 int year, int month, int day, 50 int dialogType, double dialogValue,
58 int hour, int minute, int second, int milli, int week, 51 double min, double max, double step,
59 double min, double max, double step) { 52 DateTimeSuggestion[] suggestions) {
60 DateTimeChooserAndroid chooser = 53 DateTimeChooserAndroid chooser =
61 new DateTimeChooserAndroid( 54 new DateTimeChooserAndroid(
62 contentViewCore.getContext(), 55 contentViewCore.getContext(),
63 nativeDateTimeChooserAndroid); 56 nativeDateTimeChooserAndroid);
64 chooser.showDialog( 57 chooser.showDialog(dialogType, dialogValue, min, max, step, suggestions) ;
65 dialogType, year, month, day, hour, minute, second, milli,
66 week, min, max, step);
67 return chooser; 58 return chooser;
68 } 59 }
69 60
61 @CalledByNative
bulach 2013/12/04 10:37:54 nit: unindent
keishi 2013/12/04 12:21:24 Done.
62 private static DateTimeSuggestion[] createSuggestionsArray(int size) {
63 return new DateTimeSuggestion[size];
64 }
65
66 /**
67 * @param array ColorSuggestion array that should get a new suggestion added .
bulach 2013/12/04 10:37:54 nit: s/Color/DateTime/ :)
keishi 2013/12/04 12:21:24 Done.
68 * @param index Index in the array where to place a new suggestion.
69 * @param value Value of the suggestion.
70 * @param localizedValue Localized value of the suggestion.
71 * @param label Label of the suggestion.
72 */
73 @CalledByNative
74 private static void setDateTimeSuggestionAt(DateTimeSuggestion[] array, int index,
75 double value, String localizedValue, String label) {
76 array[index] = new DateTimeSuggestion(value, localizedValue, label);
77 }
78
70 @CalledByNative 79 @CalledByNative
71 private static void initializeDateInputTypes( 80 private static void initializeDateInputTypes(
72 int textInputTypeDate, int textInputTypeDateTime, 81 int textInputTypeDate, int textInputTypeDateTime,
73 int textInputTypeDateTimeLocal, int textInputTypeMonth, 82 int textInputTypeDateTimeLocal, int textInputTypeMonth,
74 int textInputTypeTime, int textInputTypeWeek) { 83 int textInputTypeTime, int textInputTypeWeek) {
75 InputDialogContainer.initializeInputTypes(textInputTypeDate, 84 InputDialogContainer.initializeInputTypes(
85 textInputTypeDate,
76 textInputTypeDateTime, textInputTypeDateTimeLocal, 86 textInputTypeDateTime, textInputTypeDateTimeLocal,
77 textInputTypeMonth, textInputTypeTime, textInputTypeWeek); 87 textInputTypeMonth, textInputTypeTime, textInputTypeWeek);
78 } 88 }
79 89
80 private native void nativeReplaceDateTime( 90 private native void nativeReplaceDateTime(long nativeDateTimeChooserAndroid,
81 long nativeDateTimeChooserAndroid, int dialogType, 91 double dialogValue);
82 int year, int month, int day, int hour, int minute,
83 int second, int milli, int week);
84 92
85 private native void nativeCancelDialog(long nativeDateTimeChooserAndroid); 93 private native void nativeCancelDialog(long nativeDateTimeChooserAndroid);
86 } 94 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698