import com.android.camera.Storage;
import com.android.camera.async.MainThread;
import com.android.camera.remote.RemoteShutterListener;
+import com.android.camera.session.CaptureSessionFactory;
+import com.android.camera.session.CaptureSessionFactoryImpl;
import com.android.camera.session.CaptureSessionManager;
import com.android.camera.session.CaptureSessionManagerImpl;
import com.android.camera.session.PlaceholderManager;
StackSaverFactory mStackSaverFactory = new StackSaverFactory(Storage.DIRECTORY,
context.getContentResolver());
- mSessionManager = new CaptureSessionManagerImpl(mMediaSaver, mPlaceHolderManager,
- mSessionStorageManager, mStackSaverFactory, MainThread.create());
+ CaptureSessionFactory captureSessionFactory = new CaptureSessionFactoryImpl(
+ mMediaSaver, mPlaceHolderManager, mSessionStorageManager, mStackSaverFactory);
+ mSessionManager = new CaptureSessionManagerImpl(
+ captureSessionFactory, mSessionStorageManager, MainThread.create());
mMemoryManager = MemoryManagerImpl.create(context, mMediaSaver);
mRemoteShutterListener = RemoteShutterHelper.create(context);
mSettingsManager = new SettingsManager(context);
--- /dev/null
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.camera.session;
+
+import android.location.Location;
+
+public interface CaptureSessionFactory {
+ /**
+ * Creates a new capture session.
+ *
+ * @param sessionManager the capture session manager.
+ * @param title the title of the new session.
+ * @param sessionStartMillis the start time of the new session (millis since epoch).
+ * @param location the location of the new session.
+ */
+ public CaptureSession createNewSession(CaptureSessionManager sessionManager, String title,
+ long sessionStartMillis, Location location);
+}
--- /dev/null
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.camera.session;
+
+import com.android.camera.app.MediaSaver;
+
+import android.location.Location;
+
+public class CaptureSessionFactoryImpl implements CaptureSessionFactory {
+ /** Sub-directory for storing temporary session files. */
+ private static final String TEMP_SESSIONS = "TEMP_SESSIONS";
+
+ private final MediaSaver mMediaSaver;
+ private final PlaceholderManager mPlaceholderManager;
+ private final SessionStorageManager mSessionStorageManager;
+ private final StackSaverFactory mStackSaverFactory;
+
+ public CaptureSessionFactoryImpl(MediaSaver mediaSaver, PlaceholderManager placeholderManager,
+ SessionStorageManager sessionStorageManager, StackSaverFactory stackSaverFactory) {
+ mMediaSaver = mediaSaver;
+ mPlaceholderManager = placeholderManager;
+ mSessionStorageManager = sessionStorageManager;
+ mStackSaverFactory = stackSaverFactory;
+ }
+
+ @Override
+ public CaptureSession createNewSession(CaptureSessionManager sessionManager, String title,
+ long sessionStartTime, Location location) {
+ TemporarySessionFile temporarySessionFile = new TemporarySessionFile(
+ mSessionStorageManager, TEMP_SESSIONS, title);
+ return new CaptureSessionImpl(title, sessionStartTime, location, temporarySessionFile,
+ (CaptureSessionManagerImpl) sessionManager, mPlaceholderManager, mMediaSaver,
+ mStackSaverFactory.create(title, location));
+ }
+}
* @param sessionStartMillis the start time of the new session (millis since epoch).
* @param location the location of the new session.
*/
- CaptureSession createNewSession(String title, long sessionStartMillis, Location location);
+ public CaptureSession createNewSession(String title, long sessionStartMillis, Location location);
/**
* Returns a session by session Uri or null if it is not found.
*
* @return The corresponding CaptureSession.
*/
- CaptureSession getSession(Uri sessionUri);
+ public CaptureSession getSession(Uri sessionUri);
/**
* Add a listener to be informed about capture session updates.
import android.location.Location;
import android.net.Uri;
-import com.android.camera.app.MediaSaver;
import com.android.camera.async.MainThread;
import com.android.camera.debug.Log;
*/
public class CaptureSessionManagerImpl implements CaptureSessionManager {
private static final Log.Tag TAG = new Log.Tag("CaptureSessMgrImpl");
- /** Sub-directory for storing temporary session files. */
- private static final String TEMP_SESSIONS = "TEMP_SESSIONS";
- private final MediaSaver mMediaSaver;
- private final PlaceholderManager mPlaceholderManager;
+ private final CaptureSessionFactory mSessionFactory;
private final SessionStorageManager mSessionStorageManager;
- private final StackSaverFactory mStackSaverFactory;
/** Failed session messages. Uri -> message. */
private final HashMap<Uri, CharSequence> mFailedSessionMessages = new HashMap<>();
/**
* Initializes a new {@link CaptureSessionManager} implementation.
*
- * @param mediaSaver used to store the resulting media item
- * @param placeholderManager used to manage placeholders in the filmstrip
- * before the final result is ready
+ * @param sessionFactory used to create new capture session objects.
* @param sessionStorageManager used to tell modules where to store
* temporary session data
+ * @param mainHandler the main handler which listener callback is executed on.
*/
- public CaptureSessionManagerImpl(MediaSaver mediaSaver, PlaceholderManager placeholderManager,
- SessionStorageManager sessionStorageManager, StackSaverFactory stackSaverProvider,
+ public CaptureSessionManagerImpl(
+ CaptureSessionFactory sessionFactory,
+ SessionStorageManager sessionStorageManager,
MainThread mainHandler) {
+ mSessionFactory = sessionFactory;
mSessions = new HashMap<>();
- mMediaSaver = mediaSaver;
- mPlaceholderManager = placeholderManager;
mSessionStorageManager = sessionStorageManager;
- mStackSaverFactory = stackSaverProvider;
mMainHandler = mainHandler;
}
- @Override
- public CaptureSession createNewSession(String title, long sessionStartTime, Location location) {
- TemporarySessionFile temporarySessionFile = new TemporarySessionFile(
- mSessionStorageManager, TEMP_SESSIONS, title);
- return new CaptureSessionImpl(title, sessionStartTime, location, temporarySessionFile,
- this, mPlaceholderManager, mMediaSaver, mStackSaverFactory.create(title, location));
+ public CaptureSession createNewSession(String title, long sessionStartMillis, Location location) {
+ return mSessionFactory.createNewSession(this, title, sessionStartMillis, location);
}
+
@Override
public void putSession(Uri sessionUri, CaptureSession session) {
synchronized (mSessions) {