1 /**
2  * Copyright (C) 2022 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5  * in compliance with the License. You may obtain a copy of the License at
6  *
7  * ```
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  * ```
10  *
11  * Unless required by applicable law or agreed to in writing, software distributed under the License
12  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
13  * or implied. See the License for the specific language governing permissions and limitations under
14  * the License.
15  */
16 package com.android.healthconnect.testapps.toolbox.fieldviews
17 
18 import android.annotation.SuppressLint
19 import android.content.Context
20 import android.view.View
21 import android.widget.EditText
22 import android.widget.TextView
23 import com.android.healthconnect.testapps.toolbox.R
24 
25 @SuppressLint("ViewConstructor")
26 class EditableTextView(context: Context, fieldName: String?, inputType: Int) :
27     InputFieldView(context) {
28 
29     init {
30         inflate(context, R.layout.fragment_editable_field, this)
31         val textView = findViewById<TextView>(R.id.title)
32         if (fieldName == null) {
33             textView.visibility = View.GONE
34         } else {
35             textView.text = fieldName
36         }
37 
38         findViewById<EditText>(R.id.input_field).inputType = inputType
39     }
40 
getFieldValuenull41     override fun getFieldValue(): Any {
42         return findViewById<EditText>(R.id.input_field).text.toString()
43     }
44 
isEmptynull45     override fun isEmpty(): Boolean {
46         return findViewById<EditText>(R.id.input_field).text.isEmpty()
47     }
48 }
49