1 /*
2  * Copyright 2024 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  *      https://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 com.android.devicediagnostics.evaluated
18 
19 import android.os.Bundle
20 import androidx.fragment.app.commit
21 import androidx.preference.Preference
22 import androidx.preference.PreferenceFragmentCompat
23 import com.android.devicediagnostics.R
24 import com.android.settingslib.collapsingtoolbar.CollapsingToolbarBaseActivity
25 
26 class TouchTestFinalizeFragment() : PreferenceFragmentCompat() {
27 
onCreatePreferencesnull28     override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
29         setPreferencesFromResource(R.xml.preferences_evaluated_touch_test_finalize, rootKey)
30 
31         val result = activity!!.intent.getBooleanExtra(TOUCH_TEST_RESULT_KEY, false)
32 
33         findPreference<Preference>("Continue")?.setOnPreferenceClickListener {
34             nextTest(activity!!) { it.setTouchTest(result) }
35             true
36         }
37         findPreference<Preference>(if (result) "Good" else "Bad")?.isVisible = true
38     }
39 }
40 
41 class TouchTestFinalizeActivity : CollapsingToolbarBaseActivity() {
onCreatenull42     override fun onCreate(savedInstanceState: Bundle?) {
43         super.onCreate(savedInstanceState)
44         setContentView(R.layout.activity_one_fragment)
45         setTitle(R.string.touch_test_title)
46 
47         if (savedInstanceState == null) {
48             supportFragmentManager.commit {
49                 setReorderingAllowed(true)
50                 add(R.id.fragment_container_view, TouchTestFinalizeFragment())
51             }
52         }
53     }
54 }
55