1 /* 2 * Copyright (C) 2017 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 android.view.inputmethod.cts.util; 18 19 import static android.view.WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN; 20 21 import android.app.Activity; 22 import android.graphics.Color; 23 import android.os.Bundle; 24 import android.view.View; 25 import android.view.ViewGroup; 26 27 /** 28 * A nop {@link Activity} to make sure that the test starts from a deterministic state. 29 * 30 * <p>Currently this {@link Activity} makes sure the following things</p> 31 * <li> 32 * <ul>Hide the software keyboard with 33 * {@link android.view.WindowManager.LayoutParams#SOFT_INPUT_STATE_ALWAYS_HIDDEN}</ul> 34 * <ul>Make sure that the navigation bar (if supported) is rendered with {@link Color#BLACK}. 35 * </ul> 36 * </li> 37 */ 38 public class StateInitializeActivity extends Activity { 39 @Override onCreate(Bundle bundle)40 protected void onCreate(Bundle bundle) { 41 super.onCreate(bundle); 42 final View view = new View(this); 43 view.setBackgroundColor(Color.WHITE); 44 view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 45 ViewGroup.LayoutParams.MATCH_PARENT)); 46 47 // Make sure that IME is hidden in the initial state 48 getWindow().setSoftInputMode(SOFT_INPUT_STATE_ALWAYS_HIDDEN); 49 50 // Make sure that navigation bar is rendered with black (if supported). 51 getWindow().setNavigationBarColor(Color.BLACK); 52 53 view.setFitsSystemWindows(true); 54 setContentView(view); 55 } 56 } 57