1 /* 2 * Copyright 2019 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 17 package androidx.compose.ui.text.input 18 19 import androidx.compose.runtime.Stable 20 21 /** Values representing the different available Keyboard Types. */ 22 @kotlin.jvm.JvmInline 23 value class KeyboardType private constructor(@Suppress("unused") private val value: Int) { 24 toStringnull25 override fun toString(): String { 26 return when (this) { 27 Unspecified -> "Unspecified" 28 Text -> "Text" 29 Ascii -> "Ascii" 30 Number -> "Number" 31 Phone -> "Phone" 32 Uri -> "Uri" 33 Email -> "Email" 34 Password -> "Password" 35 NumberPassword -> "NumberPassword" 36 Decimal -> "Decimal" 37 else -> "Invalid" 38 } 39 } 40 41 companion object { 42 /** The keyboard type is not specified. */ 43 @Stable val Unspecified: KeyboardType = KeyboardType(0) 44 45 /** A keyboard type used to request an IME that shows regular keyboard. */ 46 @Stable val Text: KeyboardType = KeyboardType(1) 47 48 /** A keyboard type used to request an IME that is capable of inputting ASCII characters. */ 49 @Stable val Ascii: KeyboardType = KeyboardType(2) 50 51 /** 52 * A keyboard type used to request an IME that is capable of inputting digits. IME may 53 * provide inputs other than digits but it is not guaranteed. 54 * 55 * @see KeyboardType.Decimal 56 */ 57 @Stable val Number: KeyboardType = KeyboardType(3) 58 59 /** A keyboard type used to request an IME that is capable of inputting phone numbers. */ 60 @Stable val Phone: KeyboardType = KeyboardType(4) 61 62 /** A keyboard type used to request an IME that is capable of inputting URIs. */ 63 @Stable val Uri: KeyboardType = KeyboardType(5) 64 65 /** A keyboard type used to request an IME that is capable of inputting email addresses. */ 66 @Stable val Email: KeyboardType = KeyboardType(6) 67 68 /** A keyboard type used to request an IME that is capable of inputting password. */ 69 @Stable val Password: KeyboardType = KeyboardType(7) 70 71 /** A keyboard type used to request an IME that is capable of inputting number password. */ 72 @Stable val NumberPassword: KeyboardType = KeyboardType(8) 73 74 /** 75 * A keyboard type used to request an IME that is capable of inputting decimals. IME should 76 * explicitly provide a decimal separator as input, which is not assured by 77 * [KeyboardType.Number]. 78 */ 79 @Stable val Decimal: KeyboardType = KeyboardType(9) 80 } 81 } 82