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