1/* 2 * Copyright (C) 2006 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package android.text.method; 18 19import android.text.InputType; 20import android.view.KeyEvent; 21 22/** 23 * For entering dates and times in the same text field. 24 */ 25public class DateTimeKeyListener extends NumberKeyListener 26{ 27 public int getInputType() { 28 return InputType.TYPE_CLASS_DATETIME 29 | InputType.TYPE_DATETIME_VARIATION_NORMAL; 30 } 31 32 @Override 33 protected char[] getAcceptedChars() 34 { 35 return CHARACTERS; 36 } 37 38 public static DateTimeKeyListener getInstance() { 39 if (sInstance != null) 40 return sInstance; 41 42 sInstance = new DateTimeKeyListener(); 43 return sInstance; 44 } 45 46 /** 47 * The characters that are used. 48 * 49 * @see KeyEvent#getMatch 50 * @see #getAcceptedChars 51 */ 52 public static final char[] CHARACTERS = new char[] { 53 '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'm', 54 'p', ':', '/', '-', ' ' 55 }; 56 57 private static DateTimeKeyListener sInstance; 58} 59