blob: 48001b8d73d02c38c2955da42b159f907bd95d28 [file] [log] [blame]
The Android Open Source Projectb64d3452009-03-03 19:32:20 -08001/*
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
17package com.android.camera;
18
19
20import android.app.Activity;
Chih-Chung Chang6b270502009-04-29 11:57:06 +080021import android.content.Intent;
The Android Open Source Projectb64d3452009-03-03 19:32:20 -080022import android.content.pm.ActivityInfo;
The Android Open Source Projectb64d3452009-03-03 19:32:20 -080023import android.os.Bundle;
The Android Open Source Projectb64d3452009-03-03 19:32:20 -080024import android.provider.MediaStore;
Chih-Chung Changdf125e72009-09-30 16:40:08 -070025import android.util.Log;
The Android Open Source Projectb64d3452009-03-03 19:32:20 -080026import android.view.View;
The Android Open Source Projectb64d3452009-03-03 19:32:20 -080027
Ray Chen23c51b72009-04-10 03:41:00 -070028/**
29 * This activity plays a video from a specified URI.
30 */
Owen Lin6795ff12009-06-09 13:39:00 -070031public class MovieView extends Activity {
The Android Open Source Projectb64d3452009-03-03 19:32:20 -080032 private static final String TAG = "MovieView";
Chih-Chung Changb8af1c52009-04-01 02:48:59 -070033
Owen Lin6795ff12009-06-09 13:39:00 -070034 private MovieViewControl mControl;
Chih-Chung Changb8af1c52009-04-01 02:48:59 -070035 private boolean mFinishOnCompletion;
The Android Open Source Projectb64d3452009-03-03 19:32:20 -080036
The Android Open Source Projectb64d3452009-03-03 19:32:20 -080037 @Override
Chih-Chung Changb8af1c52009-04-01 02:48:59 -070038 public void onCreate(Bundle icicle) {
The Android Open Source Projectb64d3452009-03-03 19:32:20 -080039 super.onCreate(icicle);
The Android Open Source Projectb64d3452009-03-03 19:32:20 -080040 setContentView(R.layout.movie_view);
Owen Lin6795ff12009-06-09 13:39:00 -070041 View rootView = findViewById(R.id.root);
The Android Open Source Projectb64d3452009-03-03 19:32:20 -080042 Intent intent = getIntent();
Owen Lin6795ff12009-06-09 13:39:00 -070043 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 Projectb64d3452009-03-03 19:32:20 -080051 if (intent.hasExtra(MediaStore.EXTRA_SCREEN_ORIENTATION)) {
Chih-Chung Changb8af1c52009-04-01 02:48:59 -070052 int orientation = intent.getIntExtra(
53 MediaStore.EXTRA_SCREEN_ORIENTATION,
The Android Open Source Projectb64d3452009-03-03 19:32:20 -080054 ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
55 if (orientation != getRequestedOrientation()) {
56 setRequestedOrientation(orientation);
57 }
58 }
Chih-Chung Changb8af1c52009-04-01 02:48:59 -070059 mFinishOnCompletion = intent.getBooleanExtra(
60 MediaStore.EXTRA_FINISH_ON_COMPLETION, true);
The Android Open Source Projectb64d3452009-03-03 19:32:20 -080061 }
62
63 @Override
64 public void onPause() {
Owen Lin6795ff12009-06-09 13:39:00 -070065 mControl.onPause();
The Android Open Source Projectb64d3452009-03-03 19:32:20 -080066 super.onPause();
67 }
68
69 @Override
Marco Nelissen829e38a2009-09-03 13:41:25 -070070 public void onWindowFocusChanged(boolean hasFocus) {
71 if (hasFocus) {
Chih-Chung Changdf125e72009-09-30 16:40:08 -070072 Log.v(TAG, "hasFocus");
Marco Nelissen829e38a2009-09-03 13:41:25 -070073 mControl.onResume();
74 }
The Android Open Source Projectb64d3452009-03-03 19:32:20 -080075 }
The Android Open Source Projectb64d3452009-03-03 19:32:20 -080076}