import com.android.camera.util.IntentHelper;
import com.android.camera.util.PhotoSphereHelper;
import com.android.camera.util.PhotoSphereHelper.PanoramaViewHelper;
+import com.android.camera.util.UsageStatistics;
import com.android.camera2.R;
+import java.io.File;
+
import static com.android.camera.CameraManager.CameraOpenErrorCallback;
public class CameraActivity extends Activity
implements ModuleSwitcher.ModuleSwitchListener,
- ActionBar.OnMenuVisibilityListener {
+ ActionBar.OnMenuVisibilityListener,
+ ShareActionProvider.OnShareTargetSelectedListener {
private static final String TAG = "CAM_Activity";
new CameraOpenErrorCallback() {
@Override
public void onCameraDisabled(int cameraId) {
+ UsageStatistics.onEvent(UsageStatistics.COMPONENT_CAMERA,
+ UsageStatistics.ACTION_OPEN_FAIL, "security");
+
CameraUtil.showErrorAndFinish(CameraActivity.this,
R.string.camera_disabled);
}
@Override
public void onDeviceOpenFailure(int cameraId) {
+ UsageStatistics.onEvent(UsageStatistics.COMPONENT_CAMERA,
+ UsageStatistics.ACTION_OPEN_FAIL, "open");
+
CameraUtil.showErrorAndFinish(CameraActivity.this,
R.string.cannot_connect_camera);
}
@Override
public void onReconnectionFailure(CameraManager mgr) {
+ UsageStatistics.onEvent(UsageStatistics.COMPONENT_CAMERA,
+ UsageStatistics.ACTION_OPEN_FAIL, "reconnect");
+
CameraUtil.showErrorAndFinish(CameraActivity.this,
R.string.cannot_connect_camera);
}
sFirstStartAfterScreenOn = false;
}
+ private String fileNameFromDataID(int dataID) {
+ final LocalData localData = mDataAdapter.getLocalData(dataID);
+
+ File localFile = new File(localData.getPath());
+ return localFile.getName();
+ }
+
private FilmStripView.Listener mFilmStripListener =
new FilmStripView.Listener() {
@Override
public void onDataPromoted(int dataID) {
+ UsageStatistics.onEvent(UsageStatistics.COMPONENT_CAMERA,
+ UsageStatistics.ACTION_DELETE, "promoted", 0,
+ UsageStatistics.hashFileName(fileNameFromDataID(dataID)));
+
removeData(dataID);
}
@Override
public void onDataDemoted(int dataID) {
+ UsageStatistics.onEvent(UsageStatistics.COMPONENT_CAMERA,
+ UsageStatistics.ACTION_DELETE, "demoted", 0,
+ UsageStatistics.hashFileName(fileNameFromDataID(dataID)));
+
removeData(dataID);
}
};
public void gotoGallery() {
+ UsageStatistics.onEvent(UsageStatistics.COMPONENT_CAMERA, UsageStatistics.ACTION_FILMSTRIP,
+ "thumbnailTap");
+
mFilmStripView.getController().goToNextItem();
}
}
}
+ @Override
+ public boolean onShareTargetSelected(ShareActionProvider shareActionProvider, Intent intent) {
+ int currentDataId = mFilmStripView.getCurrentId();
+ if (currentDataId < 0) {
+ return false;
+ }
+ UsageStatistics.onEvent(UsageStatistics.COMPONENT_CAMERA, UsageStatistics.ACTION_SHARE,
+ intent.getComponent().getPackageName(), 0,
+ UsageStatistics.hashFileName(fileNameFromDataID(currentDataId)));
+ return true;
+ }
+
/**
* According to the data type, make the menu items for supported operations
* visible.
mPanoramaShareActionProvider.setShareIntent(mPanoramaShareIntent);
}
+ mStandardShareActionProvider.setOnShareTargetSelectedListener(this);
+ mPanoramaShareActionProvider.setOnShareTargetSelectedListener(this);
+
return super.onCreateOptionsMenu(menu);
}
finish();
}
case R.id.action_delete:
+ UsageStatistics.onEvent(UsageStatistics.COMPONENT_CAMERA,
+ UsageStatistics.ACTION_DELETE, null, 0,
+ UsageStatistics.hashFileName(fileNameFromDataID(currentDataId)));
removeData(currentDataId);
return true;
case R.id.action_edit:
+ UsageStatistics.onEvent(UsageStatistics.COMPONENT_CAMERA,
+ UsageStatistics.ACTION_EDIT, null, 0,
+ UsageStatistics.hashFileName(fileNameFromDataID(currentDataId)));
launchEditor(localData);
return true;
case R.id.action_trim: {
localData.rotate90Degrees(this, mDataAdapter, currentDataId, true);
return true;
case R.id.action_crop: {
+ UsageStatistics.onEvent(UsageStatistics.COMPONENT_CAMERA,
+ UsageStatistics.ACTION_CROP, null, 0,
+ UsageStatistics.hashFileName(fileNameFromDataID(currentDataId)));
Intent intent = new Intent(CropActivity.CROP_ACTION);
intent.setClass(this, CropActivity.class);
intent.setDataAndType(localData.getContentUri(), localData.getMimeType())
@Override
public void onClick(View view) {
try {
+ UsageStatistics.onEvent(UsageStatistics.COMPONENT_CAMERA,
+ UsageStatistics.ACTION_GALLERY, null);
startActivity(IntentHelper.getGalleryIntent(CameraActivity.this));
} catch (ActivityNotFoundException e) {
Log.w(TAG, "Failed to launch gallery activity, closing");
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR);
mAutoRotateScreen = true;
}
+
+ UsageStatistics.onEvent(UsageStatistics.COMPONENT_CAMERA,
+ UsageStatistics.ACTION_FOREGROUNDED, this.getClass().getSimpleName());
+
mOrientationListener.enable();
mCurrentModule.onResumeBeforeSuper();
super.onResume();
public static final String COMPONENT_CAMERA = "Camera";
public static final String COMPONENT_EDITOR = "Editor";
public static final String COMPONENT_IMPORTER = "Importer";
+ public static final String COMPONENT_LIGHTCYCLE = "Lightcycle";
+ public static final String COMPONENT_PANORAMA = "Panorama";
+ public static final String COMPONENT_GCAM = "GCam";
public static final String TRANSITION_BACK_BUTTON = "BackButton";
public static final String TRANSITION_UP_BUTTON = "UpButton";
public static final String ACTION_CAPTURE_START = "CaptureStart";
public static final String ACTION_CAPTURE_FAIL = "CaptureFail";
public static final String ACTION_CAPTURE_DONE = "CaptureDone";
- public static final String ACTION_SHARE = "Share";
+
+ public static final String ACTION_STITCHING_START = "StitchingStart";
+ public static final String ACTION_STITCHING_DONE = "StitchingDone";
+
+ public static final String ACTION_FOREGROUNDED = "Foregrounded";
+ public static final String ACTION_OPEN_FAIL = "OpenFailure";
+ public static final String ACTION_SCREEN_CHANGED = "ScreenChanged";
+ public static final String ACTION_FILMSTRIP = "Filmstrip";
+ public static final String ACTION_TOUCH_FOCUS= "TouchFocus";
+ public static final String ACTION_DELETE = "Delete";
+ public static final String ACTION_GALLERY = "Gallery";
+ public static final String ACTION_EDIT= "Edit";
+ public static final String ACTION_CROP= "Crop";
+ public static final String ACTION_PLAY_VIDEO= "PlayVideo";
public static final String CATEGORY_LIFECYCLE = "AppLifecycle";
public static final String CATEGORY_BUTTON_PRESS = "ButtonPress";
public static final String LIFECYCLE_START = "Start";
+ public static final String ACTION_SHARE = "Share";
+
public static void initialize(Context context) {}
public static void setPendingTransitionCause(String cause) {}
public static void onContentViewChanged(String screenComponent, String screenName) {}
public static void onEvent(String category, String action, String label) {};
public static void onEvent(String category, String action, String label, long optional_value) {};
+ public static void onEvent(String category, String action, String label, long optional_value,
+ String fileNameHash) {};
+
+ public static String hashFileName(String fileName) {
+ return "";
+ }
}