1 /*
2  * Copyright (C) 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 com.android.server.wm.flicker.testapp;
18 
19 import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
20 import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
21 
22 import android.content.Intent;
23 import android.widget.Button;
24 import android.widget.EditText;
25 import android.widget.ToggleButton;
26 
27 public class ImeActivityAutoFocus extends ImeActivity {
28     @Override
onStart()29     protected void onStart() {
30         super.onStart();
31 
32         Button startThemedActivityButton = findViewById(R.id.start_dialog_themed_activity_btn);
33         startThemedActivityButton.setOnClickListener(
34                 button -> startActivity(new Intent(this, DialogThemedActivity.class)));
35 
36         ToggleButton toggleFixedPortraitButton = findViewById(R.id.toggle_fixed_portrait_btn);
37         toggleFixedPortraitButton.setOnCheckedChangeListener(
38                 (button, isChecked) -> setRequestedOrientation(
39                         isChecked ? SCREEN_ORIENTATION_PORTRAIT : SCREEN_ORIENTATION_UNSPECIFIED));
40 
41         EditText editTextField = findViewById(R.id.plain_text_input);
42         editTextField.requestFocus();
43     }
44 }
45