@Override
public void onDelete() {
final int currentDataId = getCurrentDataId();
- UsageStatistics.photoInteraction(
+ UsageStatistics.instance().photoInteraction(
UsageStatistics.hashFileName(fileNameFromDataID(currentDataId)),
eventprotos.CameraEvent.InteractionType.DELETE,
InteractionCause.BUTTON);
@Override
public void onCameraDisabled(int cameraId) {
- UsageStatistics.cameraFailure(eventprotos.CameraFailure.FailureReason.SECURITY);
-
+ UsageStatistics.instance().cameraFailure(
+ eventprotos.CameraFailure.FailureReason.SECURITY);
CameraUtil.showErrorAndFinish(this, R.string.camera_disabled);
}
@Override
public void onDeviceOpenFailure(int cameraId) {
- UsageStatistics.cameraFailure(eventprotos.CameraFailure.FailureReason.OPEN_FAILURE);
-
+ UsageStatistics.instance().cameraFailure(
+ eventprotos.CameraFailure.FailureReason.OPEN_FAILURE);
CameraUtil.showErrorAndFinish(this, R.string.cannot_connect_camera);
}
@Override
public void onReconnectionFailure(CameraManager mgr) {
- UsageStatistics.cameraFailure(eventprotos.CameraFailure.FailureReason.RECONNECT_FAILURE);
-
+ UsageStatistics.instance().cameraFailure(
+ eventprotos.CameraFailure.FailureReason.RECONNECT_FAILURE);
CameraUtil.showErrorAndFinish(this, R.string.cannot_connect_camera);
}
@Override
public void onSwipeOut() {
- UsageStatistics.changeScreen(eventprotos.NavigationChange.Mode.PHOTO_CAPTURE,
+ UsageStatistics.instance().changeScreen(
+ eventprotos.NavigationChange.Mode.PHOTO_CAPTURE,
eventprotos.CameraEvent.InteractionCause.SWIPE_RIGHT);
}
@Override
public void onFocusedDataPromoted(int dataID) {
- UsageStatistics.photoInteraction(
+ UsageStatistics.instance().photoInteraction(
UsageStatistics.hashFileName(fileNameFromDataID(dataID)),
eventprotos.CameraEvent.InteractionType.DELETE,
InteractionCause.SWIPE_UP);
@Override
public void onFocusedDataDemoted(int dataID) {
- UsageStatistics.photoInteraction(
+ UsageStatistics.instance().photoInteraction(
UsageStatistics.hashFileName(fileNameFromDataID(dataID)),
eventprotos.CameraEvent.InteractionType.DELETE,
InteractionCause.SWIPE_DOWN);
};
public void gotoGallery() {
- UsageStatistics.changeScreen(NavigationChange.Mode.FILMSTRIP,
+ UsageStatistics.instance().changeScreen(NavigationChange.Mode.FILMSTRIP,
InteractionCause.BUTTON);
mFilmstripController.goToNextItem();
if (currentDataId < 0) {
return false;
}
- UsageStatistics.photoInteraction(
+ UsageStatistics.instance().photoInteraction(
UsageStatistics.hashFileName(fileNameFromDataID(currentDataId)),
eventprotos.CameraEvent.InteractionType.SHARE,
InteractionCause.BUTTON);
// Foreground event caused by lock screen startup.
// It is necessary to log this in onCreate, to avoid the
// onResume->onPause->onResume sequence.
- UsageStatistics.foregrounded(
+ UsageStatistics.instance().foregrounded(
eventprotos.ForegroundEvent.ForegroundSource.LOCK_SCREEN);
// Change the window flags so that secure camera can show when
v.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
- UsageStatistics.changeScreen(NavigationChange.Mode.GALLERY,
+ UsageStatistics.instance().changeScreen(NavigationChange.Mode.GALLERY,
InteractionCause.BUTTON);
startGallery();
finish();
if (isCaptureIntent()) {
// Foreground event caused by photo or video capure intent.
- UsageStatistics.foregrounded(
+ UsageStatistics.instance().foregrounded(
eventprotos.ForegroundEvent.ForegroundSource.INTENT_PICKER);
} else if (!mSecureCamera) {
// Foreground event that is not caused by an intent.
- UsageStatistics.foregrounded(
+ UsageStatistics.instance().foregrounded(
eventprotos.ForegroundEvent.ForegroundSource.ICON_LAUNCHER);
}
return false;
}
try {
- UsageStatistics.changeScreen(NavigationChange.Mode.GALLERY, InteractionCause.BUTTON);
+ UsageStatistics.instance().changeScreen(NavigationChange.Mode.GALLERY,
+ InteractionCause.BUTTON);
Intent startGalleryIntent = new Intent(mGalleryIntent);
int currentDataId = mFilmstripController.getCurrentId();
LocalData currentLocalData = mDataAdapter.getLocalData(currentDataId);
Dialog detailDialog = DetailsDialog.create(CameraActivity.this, details);
detailDialog.show();
- UsageStatistics.photoInteraction(
+ UsageStatistics.instance().photoInteraction(
UsageStatistics.hashFileName(fileNameFromDataID(dataId)),
eventprotos.CameraEvent.InteractionType.DETAILS,
InteractionCause.BUTTON);
public void onSingleTapUp(int x, int y) {
if (!mInitialized || mState == STATE_FOCUSING_SNAP_ON_FINISH) return;
- UsageStatistics.tapToFocus();
+ UsageStatistics.instance().tapToFocus();
// Let users be able to cancel previous touch focus.
if ((mFocusArea != null) && (mState == STATE_FOCUSING ||
SharedPreferences.Editor editor = preferences.edit();
editor.putString(mKey, value);
editor.apply();
- UsageStatistics.changePreference(mKey, value, oldValue);
+ UsageStatistics.instance().changePreference(mKey, value, oldValue);
return true;
}
mFaceDetectionStarted = false;
setCameraState(SNAPSHOT_IN_PROGRESS);
- UsageStatistics.captureEvent(eventprotos.NavigationChange.Mode.PHOTO_CAPTURE,
+ UsageStatistics.instance().captureEvent(eventprotos.NavigationChange.Mode.PHOTO_CAPTURE,
UsageStatistics.hashFileName(mNamedImages.mQueue.lastElement().title + ".jpg"),
mParameters, null);
return true;
initializeSecondTime();
}
- UsageStatistics.changeScreen(eventprotos.NavigationChange.Mode.PHOTO_CAPTURE,
+ UsageStatistics.instance().changeScreen(eventprotos.NavigationChange.Mode.PHOTO_CAPTURE,
eventprotos.CameraEvent.InteractionCause.BUTTON);
Sensor gsensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
import com.android.camera.module.ModuleController;
import com.android.camera.settings.SettingsManager;
import com.android.camera.settings.SettingsUtil;
-import com.android.camera.util.AccessibilityUtils;
import com.android.camera.util.ApiHelper;
import com.android.camera.util.CameraUtil;
import com.android.camera.util.UsageStatistics;
null, null, null, new JpegPictureCallback(loc));
showVideoSnapshotUI(true);
mSnapshotInProgress = true;
- UsageStatistics.captureEvent(eventprotos.NavigationChange.Mode.VIDEO_STILL,
- null, null, null);
+ UsageStatistics.instance().captureEvent(
+ eventprotos.NavigationChange.Mode.VIDEO_STILL, null, null, null);
}
}
String statisticFilename = (mCurrentVideoFilename == null
? "INTENT"
: mCurrentVideoFilename);
- UsageStatistics.captureEvent(eventprotos.NavigationChange.Mode.VIDEO_CAPTURE,
- statisticFilename, mParameters, duration);
+ UsageStatistics.instance().captureEvent(
+ eventprotos.NavigationChange.Mode.VIDEO_CAPTURE, statisticFilename,
+ mParameters, duration);
} catch (RuntimeException e) {
Log.e(TAG, "stop fail", e);
if (mVideoFilename != null) {
mHandler.sendEmptyMessageDelayed(MSG_CHECK_DISPLAY_ROTATION, 100);
}
- UsageStatistics.changeScreen(eventprotos.NavigationChange.Mode.VIDEO_CAPTURE,
+ UsageStatistics.instance().changeScreen(eventprotos.NavigationChange.Mode.VIDEO_CAPTURE,
eventprotos.CameraEvent.InteractionCause.BUTTON);
getServices().getMemoryManager().addListener(this);
}
public void onCreate() {
super.onCreate();
- UsageStatistics.initialize(this);
+ UsageStatistics.instance().initialize(this);
CameraUtil.initialize(this);
Context context = getApplicationContext();
}
} else if (swipeState == SWIPE_LEFT) {
// Pass the touch sequence to filmstrip layout.
- UsageStatistics.changeScreen(eventprotos.NavigationChange.Mode.FILMSTRIP,
- eventprotos.CameraEvent.InteractionCause.SWIPE_LEFT);
+ UsageStatistics.instance().changeScreen(
+ eventprotos.NavigationChange.Mode.FILMSTRIP,
+ eventprotos.CameraEvent.InteractionCause.SWIPE_LEFT);
mAppRootView.redirectTouchEventsTo(mFilmstripLayout);
} else if (swipeState == SWIPE_RIGHT) {
// Pass the touch to mode switcher
mFocusOverlay = mCameraRootView.findViewById(R.id.focus_overlay);
mTutorialsPlaceholder = (FrameLayout) mCameraRootView
.findViewById(R.id.tutorials_placeholder);
- mIndicatorBottomBarWrapper = (View) mAppRootView
+ mIndicatorBottomBarWrapper = mAppRootView
.findViewById(R.id.indicator_bottombar_wrapper);
mTextureViewHelper.addPreviewAreaSizeChangedListener(
import com.android.camera.util.UsageStatistics;
import com.android.camera.widget.FilmstripLayout;
import com.android.camera2.R;
-
import com.google.common.logging.eventprotos;
public class MainActivityLayout extends FrameLayout {
// Intercept left swipe
else if (deltaX < -Math.abs(deltaY) * 2) {
mTouchReceiver = mFilmstripLayout;
- UsageStatistics.changeScreen(eventprotos.NavigationChange.Mode.FILMSTRIP,
+ UsageStatistics.instance().changeScreen(
+ eventprotos.NavigationChange.Mode.FILMSTRIP,
eventprotos.CameraEvent.InteractionCause.SWIPE_LEFT);
onTouchEvent(mDown);
return true;
* limitations under the License.
*/
+
package com.android.camera.util;
+
import android.content.Context;
-import android.hardware.Camera;
+import android.hardware.Camera.Parameters;
public class UsageStatistics {
- public static void initialize(Context context) {}
- public static void photoInteraction(String fileNameHash, int interactionType, int cause) {}
- public static void foregrounded(int source) {}
- public static void captureEvent(int mode, String fileNameHash,
- Camera.Parameters parameters, Float duration) {}
- public static void changePreference(String preference, String newValue, String oldValue) {}
- public static void cameraFailure(int cause) {}
- public static void tapToFocus() {}
- public static void changeScreen(int newScreen, Integer interactionCause) {}
+ private static UsageStatistics sInstance;
+
+ public static UsageStatistics instance() {
+ if (sInstance == null) {
+ sInstance = new UsageStatistics();
+ }
+ return sInstance;
+ }
+
+ public void initialize(Context context) {
+ }
+
+ public void photoInteraction(String fileNameHash, int interactionType, int cause) {
+ }
+
+ public void foregrounded(int source) {
+ }
+
+ public void captureEvent(int mode, String fileNameHash, Parameters parameters, Float duration) {
+ }
+
+ public void changePreference(String preference, String newValue, String oldValue) {
+ }
+
+ public void cameraFailure(int cause) {
+ }
+
+ public void tapToFocus() {
+ }
+
+ public void changeScreen(int newScreen, Integer interactionCause) {
+ }
public static String hashFileName(String fileName) {
- return "";
+ return fileName;
}
}