1 /* 2 * Copyright (C) 2008 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.cts; 18 19 import android.app.Activity; 20 import android.os.Bundle; 21 import android.view.KeyEvent; 22 import android.view.Menu; 23 import android.view.Window; 24 25 public class WindowCtsActivity extends Activity { 26 27 private static boolean mIsOnCreateOptionsMenuCalled; 28 private static boolean mIsOnOptionsMenuClosedCalled; 29 private static boolean mIsOnKeyDownCalled; 30 31 @Override onCreate(Bundle savedInstanceState)32 protected void onCreate(Bundle savedInstanceState) { 33 super.onCreate(savedInstanceState); 34 getWindow().requestFeature(Window.FEATURE_LEFT_ICON); 35 setContentView(R.layout.windowstub_layout); 36 } 37 38 @Override onCreateOptionsMenu(Menu menu)39 public boolean onCreateOptionsMenu(Menu menu) { 40 menu.add(Menu.NONE, Menu.NONE, Menu.NONE, "Quit").setShortcut('1', 'q'); 41 menu.add(Menu.NONE, Menu.NONE, Menu.NONE, "Action").setShortcut('2', 'a'); 42 mIsOnCreateOptionsMenuCalled = true; 43 return super.onCreateOptionsMenu(menu); 44 } 45 46 @Override onOptionsMenuClosed(Menu menu)47 public void onOptionsMenuClosed(Menu menu) { 48 super.onOptionsMenuClosed(menu); 49 mIsOnOptionsMenuClosedCalled = true; 50 } 51 52 @Override onKeyDown(int keyCode, KeyEvent event)53 public boolean onKeyDown(int keyCode, KeyEvent event) { 54 mIsOnKeyDownCalled = true; 55 return super.onKeyDown(keyCode, event); 56 } 57 isOnCreateOptionsMenuCalled()58 public boolean isOnCreateOptionsMenuCalled() { 59 return mIsOnCreateOptionsMenuCalled; 60 } 61 isOnOptionsMenuClosedCalled()62 public boolean isOnOptionsMenuClosedCalled() { 63 return mIsOnOptionsMenuClosedCalled; 64 } 65 isOnKeyDownCalled()66 public boolean isOnKeyDownCalled() { 67 return mIsOnKeyDownCalled; 68 } 69 setFlagFalse()70 public void setFlagFalse() { 71 mIsOnCreateOptionsMenuCalled = false; 72 mIsOnOptionsMenuClosedCalled = false; 73 } 74 } 75