Angus Kong | fd4fc0e | 2013-11-07 15:38:09 -0800 | [diff] [blame^] | 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 | |
| 17 | package com.android.camera.app; |
| 18 | |
| 19 | import android.content.ContentResolver; |
| 20 | import android.content.ContentValues; |
| 21 | import android.location.Location; |
| 22 | import android.net.Uri; |
| 23 | |
| 24 | import com.android.camera.exif.ExifInterface; |
| 25 | |
| 26 | /** |
| 27 | * An interface defining the media saver which saves media files in the |
| 28 | * background. |
| 29 | */ |
| 30 | public interface MediaSaver { |
| 31 | |
| 32 | /** |
| 33 | * An interface defining the callback for task queue status changes. |
| 34 | */ |
| 35 | public interface QueueListener { |
| 36 | /** |
| 37 | * The callback when the queue status changes. Every time a new |
| 38 | * {@link com.android.camera.app.MediaSaver.QueueListener} is set by |
| 39 | * {@link #setQueueListener(com.android.camera.app.MediaSaver.QueueListener)} |
| 40 | * this callback will be invoked to notify the current status of the |
| 41 | * queue. |
| 42 | * |
| 43 | * @param full Whether the queue is full. |
| 44 | */ |
| 45 | public void onQueueStatus(boolean full); |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * An interface defining the callback when a media is saved. |
| 50 | */ |
| 51 | public interface OnMediaSavedListener { |
| 52 | /** |
| 53 | * The callback when the saving is done in the background. |
| 54 | * @param uri The final content Uri of the saved media. |
| 55 | */ |
| 56 | public void onMediaSaved(Uri uri); |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * Checks whether the queue is full. |
| 61 | */ |
| 62 | boolean isQueueFull(); |
| 63 | |
| 64 | /** |
| 65 | * Adds an image into {@link android.content.ContentResolver} and also |
| 66 | * saves the file to the storage in the background. |
| 67 | * |
| 68 | * @param data The JPEG image data. |
| 69 | * @param title The title of the image. |
| 70 | * @param date The date when the image is created. |
| 71 | * @param loc The location where the image is created. Can be {@code null}. |
| 72 | * @param width The width of the image data before the orientation is |
| 73 | * applied. |
| 74 | * @param height The height of the image data before the orientation is |
| 75 | * applied. |
| 76 | * @param orientation The orientation of the image. The value should be a |
| 77 | * degree of rotation in clockwise. Valid values are |
| 78 | * 0, 90, 180 and 270. |
| 79 | * @param exif The EXIF data of this image. |
| 80 | * @param l A callback object used when the saving is done. |
| 81 | * @param resolver The {@link android.content.ContentResolver} to be |
| 82 | * updated. |
| 83 | */ |
| 84 | void addImage(byte[] data, String title, long date, Location loc, int width, int height, |
| 85 | int orientation, ExifInterface exif, OnMediaSavedListener l, ContentResolver resolver); |
| 86 | |
| 87 | /** |
| 88 | * Adds an image into {@link android.content.ContentResolver} and also |
| 89 | * saves the file to the storage in the background. The width and height |
| 90 | * will be obtained directly from the image data. |
| 91 | * |
| 92 | * @param data The JPEG image data. |
| 93 | * @param title The title of the image. |
| 94 | * @param date The date when the image is created. |
| 95 | * @param loc The location where the image is created. Can be {@code null}. |
| 96 | * @param orientation The orientation of the image. The value should be a |
| 97 | * degree of rotation in clockwise. Valid values are |
| 98 | * 0, 90, 180 and 270. |
| 99 | * @param exif The EXIF data of this image. |
| 100 | * @param l A callback object used when the saving is done. |
| 101 | * @param resolver The {@link android.content.ContentResolver} to be |
| 102 | * updated. |
| 103 | */ |
| 104 | void addImage(byte[] data, String title, long date, Location loc, int orientation, |
| 105 | ExifInterface exif, OnMediaSavedListener l, ContentResolver resolver); |
| 106 | |
| 107 | /** |
| 108 | * Adds an image into {@link android.content.ContentResolver} and also |
| 109 | * saves the file to the storage in the background. The time will be set by |
| 110 | * {@link System#currentTimeMillis()}. |
| 111 | * will be obtained directly from the image data. |
| 112 | * |
| 113 | * @param data The JPEG image data. |
| 114 | * @param title The title of the image. |
| 115 | * @param loc The location where the image is created. Can be {@code null}. |
| 116 | * @param width The width of the image data before the orientation is |
| 117 | * applied. |
| 118 | * @param height The height of the image data before the orientation is |
| 119 | * applied. |
| 120 | * @param orientation |
| 121 | * @param exif The EXIF data of this image. |
| 122 | * @param l A callback object used when the saving is done. |
| 123 | * @param resolver The {@link android.content.ContentResolver} to be |
| 124 | * updated. |
| 125 | */ |
| 126 | void addImage(byte[] data, String title, Location loc, int width, int height, int orientation, |
| 127 | ExifInterface exif, OnMediaSavedListener l, ContentResolver resolver); |
| 128 | |
| 129 | /** |
| 130 | * Adds the video data into the {@link android.content.ContentResolver} in |
| 131 | * the background. Only the database is updated here. The file should |
| 132 | * already be created by {@link android.media.MediaRecorder}. |
| 133 | * |
| 134 | * @param path The path of the video file on the storage. |
| 135 | * @param duration The length of the video in millisecond. |
| 136 | * @param values The values to be stored in the database. |
| 137 | * @param l A callback object used when the saving is done. |
| 138 | * @param resolver The {@link android.content.ContentResolver} to be |
| 139 | * updated. |
| 140 | */ |
| 141 | void addVideo(String path, long duration, ContentValues values, OnMediaSavedListener l, |
| 142 | ContentResolver resolver); |
| 143 | |
| 144 | /** |
| 145 | * Sets the queue listener. |
| 146 | */ |
| 147 | void setQueueListener(QueueListener l); |
| 148 | } |