The Android Open Source Project | b64d345 | 2009-03-03 19:32:20 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007 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.camera; |
| 18 | |
| 19 | |
| 20 | import android.app.Activity; |
Chih-Chung Chang | 6b27050 | 2009-04-29 11:57:06 +0800 | [diff] [blame] | 21 | import android.content.Intent; |
The Android Open Source Project | b64d345 | 2009-03-03 19:32:20 -0800 | [diff] [blame] | 22 | import android.content.pm.ActivityInfo; |
The Android Open Source Project | b64d345 | 2009-03-03 19:32:20 -0800 | [diff] [blame] | 23 | import android.os.Bundle; |
The Android Open Source Project | b64d345 | 2009-03-03 19:32:20 -0800 | [diff] [blame] | 24 | import android.provider.MediaStore; |
Chih-Chung Chang | df125e7 | 2009-09-30 16:40:08 -0700 | [diff] [blame] | 25 | import android.util.Log; |
The Android Open Source Project | b64d345 | 2009-03-03 19:32:20 -0800 | [diff] [blame] | 26 | import android.view.View; |
The Android Open Source Project | b64d345 | 2009-03-03 19:32:20 -0800 | [diff] [blame] | 27 | |
Ray Chen | 23c51b7 | 2009-04-10 03:41:00 -0700 | [diff] [blame] | 28 | /** |
| 29 | * This activity plays a video from a specified URI. |
| 30 | */ |
Owen Lin | 6795ff1 | 2009-06-09 13:39:00 -0700 | [diff] [blame] | 31 | public class MovieView extends Activity { |
The Android Open Source Project | b64d345 | 2009-03-03 19:32:20 -0800 | [diff] [blame] | 32 | private static final String TAG = "MovieView"; |
Chih-Chung Chang | b8af1c5 | 2009-04-01 02:48:59 -0700 | [diff] [blame] | 33 | |
Owen Lin | 6795ff1 | 2009-06-09 13:39:00 -0700 | [diff] [blame] | 34 | private MovieViewControl mControl; |
Chih-Chung Chang | b8af1c5 | 2009-04-01 02:48:59 -0700 | [diff] [blame] | 35 | private boolean mFinishOnCompletion; |
The Android Open Source Project | b64d345 | 2009-03-03 19:32:20 -0800 | [diff] [blame] | 36 | |
The Android Open Source Project | b64d345 | 2009-03-03 19:32:20 -0800 | [diff] [blame] | 37 | @Override |
Chih-Chung Chang | b8af1c5 | 2009-04-01 02:48:59 -0700 | [diff] [blame] | 38 | public void onCreate(Bundle icicle) { |
The Android Open Source Project | b64d345 | 2009-03-03 19:32:20 -0800 | [diff] [blame] | 39 | super.onCreate(icicle); |
The Android Open Source Project | b64d345 | 2009-03-03 19:32:20 -0800 | [diff] [blame] | 40 | setContentView(R.layout.movie_view); |
Owen Lin | 6795ff1 | 2009-06-09 13:39:00 -0700 | [diff] [blame] | 41 | View rootView = findViewById(R.id.root); |
The Android Open Source Project | b64d345 | 2009-03-03 19:32:20 -0800 | [diff] [blame] | 42 | Intent intent = getIntent(); |
Owen Lin | 6795ff1 | 2009-06-09 13:39:00 -0700 | [diff] [blame] | 43 | mControl = new MovieViewControl(rootView, this, intent.getData()) { |
| 44 | @Override |
| 45 | public void onCompletion() { |
| 46 | if (mFinishOnCompletion) { |
| 47 | finish(); |
| 48 | } |
| 49 | } |
| 50 | }; |
The Android Open Source Project | b64d345 | 2009-03-03 19:32:20 -0800 | [diff] [blame] | 51 | if (intent.hasExtra(MediaStore.EXTRA_SCREEN_ORIENTATION)) { |
Chih-Chung Chang | b8af1c5 | 2009-04-01 02:48:59 -0700 | [diff] [blame] | 52 | int orientation = intent.getIntExtra( |
| 53 | MediaStore.EXTRA_SCREEN_ORIENTATION, |
The Android Open Source Project | b64d345 | 2009-03-03 19:32:20 -0800 | [diff] [blame] | 54 | ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); |
| 55 | if (orientation != getRequestedOrientation()) { |
| 56 | setRequestedOrientation(orientation); |
| 57 | } |
| 58 | } |
Chih-Chung Chang | b8af1c5 | 2009-04-01 02:48:59 -0700 | [diff] [blame] | 59 | mFinishOnCompletion = intent.getBooleanExtra( |
| 60 | MediaStore.EXTRA_FINISH_ON_COMPLETION, true); |
The Android Open Source Project | b64d345 | 2009-03-03 19:32:20 -0800 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | @Override |
| 64 | public void onPause() { |
Owen Lin | 6795ff1 | 2009-06-09 13:39:00 -0700 | [diff] [blame] | 65 | mControl.onPause(); |
The Android Open Source Project | b64d345 | 2009-03-03 19:32:20 -0800 | [diff] [blame] | 66 | super.onPause(); |
| 67 | } |
| 68 | |
| 69 | @Override |
Marco Nelissen | 829e38a | 2009-09-03 13:41:25 -0700 | [diff] [blame] | 70 | public void onWindowFocusChanged(boolean hasFocus) { |
| 71 | if (hasFocus) { |
Chih-Chung Chang | df125e7 | 2009-09-30 16:40:08 -0700 | [diff] [blame] | 72 | Log.v(TAG, "hasFocus"); |
Marco Nelissen | 829e38a | 2009-09-03 13:41:25 -0700 | [diff] [blame] | 73 | mControl.onResume(); |
| 74 | } |
The Android Open Source Project | b64d345 | 2009-03-03 19:32:20 -0800 | [diff] [blame] | 75 | } |
The Android Open Source Project | b64d345 | 2009-03-03 19:32:20 -0800 | [diff] [blame] | 76 | } |