ActivityBase.java revision 8608b577921acf67a5a7b7968cb3633b8f94714d
1/* 2 * Copyright (C) 2009 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 17package com.android.camera; 18 19import com.android.camera.ui.PopupManager; 20 21import android.app.Activity; 22import android.view.KeyEvent; 23import android.content.Intent; 24import android.media.AudioManager; 25import android.os.Bundle; 26 27/** 28 * Superclass of Camera and VideoCamera activities. 29 */ 30public class ActivityBase extends Activity { 31 private int mResultCodeForTesting; 32 private Intent mResultDataForTesting; 33 34 @Override 35 public void onCreate(Bundle icicle) { 36 super.onCreate(icicle); 37 setVolumeControlStream(AudioManager.STREAM_MUSIC); 38 } 39 40 @Override 41 public boolean onSearchRequested() { 42 return false; 43 } 44 45 @Override 46 public boolean onKeyDown(int keyCode, KeyEvent event) { 47 // Prevent software keyboard or voice search from showing up. 48 if (keyCode == KeyEvent.KEYCODE_SEARCH 49 || keyCode == KeyEvent.KEYCODE_MENU) { 50 if (event.isLongPress()) return true; 51 } 52 53 return super.onKeyDown(keyCode, event); 54 } 55 56 protected void setResultEx(int resultCode) { 57 mResultCodeForTesting = resultCode; 58 setResult(resultCode); 59 } 60 61 protected void setResultEx(int resultCode, Intent data) { 62 mResultCodeForTesting = resultCode; 63 mResultDataForTesting = data; 64 setResult(resultCode, data); 65 } 66 67 public int getResultCode() { 68 return mResultCodeForTesting; 69 } 70 71 public Intent getResultData() { 72 return mResultDataForTesting; 73 } 74 75 @Override 76 protected void onDestroy() { 77 PopupManager.removeInstance(this); 78 super.onDestroy(); 79 } 80} 81