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