2 * Copyright (c) 2010-2020 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 /* This file is based on:
18 * Copyright (c) 2014 LG Electronics.
19 * Created by Hyun Kook Khang on 19 Jan 2014
21 * Licensed under the Apache License, Version 2.0 (the "License");
22 * you may not use this file except in compliance with the License.
23 * You may obtain a copy of the License at
25 * http://www.apache.org/licenses/LICENSE-2.0
27 * Unless required by applicable law or agreed to in writing, software
28 * distributed under the License is distributed on an "AS IS" BASIS,
29 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
30 * See the License for the specific language governing permissions and
31 * limitations under the License.
34 package org.openhab.binding.lgwebos.internal.handler.core;
36 import com.google.gson.JsonObject;
39 * Normalized reference object for information about a text input event.
41 * @author Hyun Kook Khang - Connect SDK initial contribution
42 * @author Sebastian Prehn - Adoption for openHAB
44 public class TextInputStatusInfo {
46 public enum TextInputType {
54 boolean focused = false;
55 String contentType = null;
56 boolean predictionEnabled = false;
57 boolean correctionEnabled = false;
58 boolean autoCapitalization = false;
59 boolean hiddenText = false;
60 boolean focusChanged = false;
65 public TextInputStatusInfo() {
68 public boolean isFocused() {
72 public void setFocused(boolean focused) {
73 this.focused = focused;
77 * Gets the type of keyboard that should be displayed to the user.
79 * @return the keyboard type
81 public TextInputType getTextInputType() {
82 TextInputType textInputType = TextInputType.DEFAULT;
84 if (contentType != null) {
85 if (contentType.equals("number")) {
86 textInputType = TextInputType.NUMBER;
87 } else if (contentType.equals("phonenumber")) {
88 textInputType = TextInputType.PHONE_NUMBER;
89 } else if (contentType.equals("url")) {
90 textInputType = TextInputType.URL;
91 } else if (contentType.equals("email")) {
92 textInputType = TextInputType.EMAIL;
100 * Sets the type of keyboard that should be displayed to the user.
102 * @param textInputType the keyboard type
104 public void setTextInputType(TextInputType textInputType) {
105 switch (textInputType) {
107 contentType = "number";
110 contentType = "phonenumber";
116 contentType = "number";
120 contentType = "email";
125 public void setContentType(String contentType) {
126 this.contentType = contentType;
129 public boolean isPredictionEnabled() {
130 return predictionEnabled;
133 public void setPredictionEnabled(boolean predictionEnabled) {
134 this.predictionEnabled = predictionEnabled;
137 public boolean isCorrectionEnabled() {
138 return correctionEnabled;
141 public void setCorrectionEnabled(boolean correctionEnabled) {
142 this.correctionEnabled = correctionEnabled;
145 public boolean isAutoCapitalization() {
146 return autoCapitalization;
149 public void setAutoCapitalization(boolean autoCapitalization) {
150 this.autoCapitalization = autoCapitalization;
153 public boolean isHiddenText() {
157 public void setHiddenText(boolean hiddenText) {
158 this.hiddenText = hiddenText;
161 /** @return the raw data from the first screen device about the text input status. */
162 public JsonObject getRawData() {
166 /** @param data the raw data from the first screen device about the text input status. */
167 public void setRawData(JsonObject data) {
171 public boolean isFocusChanged() {
175 public void setFocusChanged(boolean focusChanged) {
176 this.focusChanged = focusChanged;