CaptureSession.java revision a63dbb6231f06031204fe20b19a87d0440bd1661
1/* 2 * Copyright (C) 2013 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.session; 18 19import android.location.Location; 20import android.net.Uri; 21 22import com.android.camera.app.MediaSaver.OnMediaSavedListener; 23import com.android.camera.exif.ExifInterface; 24 25/** 26 * A session is an item that is in progress of being created and saved, such as 27 * a photo sphere or HDR+ photo. 28 */ 29public interface CaptureSession { 30 31 /** 32 * Set the progress in percent for the current session. If set to or left at 33 * 0, no progress bar is shown. 34 */ 35 public void setProgress(int percent); 36 37 /** 38 * Returns the progress of this session in percent. 39 */ 40 public int getProgress(); 41 42 /** 43 * Returns the current progress message. 44 */ 45 public CharSequence getProgressMessage(); 46 47 /** 48 * Starts the session by adding a placeholder to the filmstrip and adding 49 * notifications. 50 * 51 * @param placeholder a valid encoded bitmap to be used as the placeholder. 52 * @param progressMessage the message to be used to the progress 53 * notification initially. This can later be changed using 54 * {@link #setProgressMessage(CharSequence)}. 55 */ 56 public void startSession(byte[] placeholder, CharSequence progressMessage); 57 58 /** 59 * Starts the session by marking the item as in-progress and adding 60 * notifications. 61 * 62 * @param uri the URI of the item to be re-processed. 63 * @param progressMessage the message to be used to the progress 64 * notification initially. This can later be changed using 65 * {@link #setProgressMessage(CharSequence)}. 66 */ 67 public void startSession(Uri uri, CharSequence progressMessage); 68 69 /** 70 * Cancel the session without a final result. The session will be removed 71 * from the film strip, progress notifications will be cancelled. 72 */ 73 public void cancel(); 74 75 /** 76 * Changes the progress status message of this session. 77 * 78 * @param message the new message 79 */ 80 public void setProgressMessage(CharSequence message); 81 82 /** 83 * Finish the session by saving the image to disk. Will add the final item 84 * in the film strip and remove the progress notifications. 85 */ 86 public void saveAndFinish(byte[] data, Location loc, int width, int height, int orientation, 87 ExifInterface exif, OnMediaSavedListener listener); 88 89 /** 90 * Finishes the session. 91 */ 92 public void finish(); 93 94 /** 95 * Returns the path to the final output of this session. This is only 96 * available after startSession has been called. 97 */ 98 public String getPath(); 99 100 /** 101 * Whether this session already has a path. This is the case once it has 102 * been started. False is returned, if the session has not been started yet 103 * and no path is available 104 */ 105 public boolean hasPath(); 106 107 /** 108 * Called when the underlying media file has been changed and the session 109 * should update itself. 110 */ 111 public void onMediaChanged(); 112} 113