import android.os.Message;
import android.provider.MediaStore;
import android.provider.Settings;
+import android.text.TextUtils;
import android.util.CameraPerformanceTracker;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
public class CameraActivity extends Activity
implements AppController, CameraManager.CameraOpenCallback,
}
@Override
+ public void onZoomAtIndexChanged(int dataId, float zoom) {
+ final LocalData localData = mDataAdapter.getLocalData(dataId);
+ long ageMillis = System.currentTimeMillis() - localData.getDateModified() * 1000;
+
+ // Do not log if items is to old or does not have a path (which is
+ // being used as a key).
+ if (TextUtils.isEmpty(localData.getPath()) ||
+ ageMillis > UsageStatistics.VIEW_TIMEOUT_MILLIS) {
+ return;
+ }
+ File localFile = new File(localData.getPath());
+ UsageStatistics.instance().mediaView(localFile.getName(),
+ TimeUnit.SECONDS.toMillis(localData.getDateModified()), zoom);
+ }
+
+ @Override
public void onDataFocusChanged(final int prevDataId, final int newDataId) {
if (!mFilmstripVisible) {
return;
import com.android.camera2.R;
import java.util.Date;
+import java.util.concurrent.TimeUnit;
/**
* This is used to represent a local data item that is in progress and not
public class LocalSessionData implements LocalData {
private Uri mUri;
+ // Units are GMT epoch milliseconds.
private long mDateTaken;
protected final Bundle mMetaData;
private int mWidth;
@Override
public long getDateModified() {
- return mDateTaken;
+ // Convert to seconds because LocalData interface specifies that this
+ // method should return seconds and mDateTaken is in milliseconds.
+ return TimeUnit.MILLISECONDS.toSeconds(mDateTaken);
}
@Override
public void onEnterZoomView(int dataID);
/**
+ * Called when current item or zoom level has changed.
+ *
+ * @param dataId The ID of the current focused image data.
+ * @param zoom Zoom level.
+ */
+ public void onZoomAtIndexChanged(int dataId, float zoom);
+
+ /**
* The callback when the data focus changed.
*
* @param prevDataId The ID of the previously focused data or {@code -1} if
/**
* The callback when we scroll.
*
- * @param firstVisiblePosition The position of the first rendered item (may be slightly offscreen depending on
+ * @param firstVisiblePosition The position of the first rendered item
+ * (may be slightly offscreen depending on
* the orientation of the device).
* @param visibleItemCount The total number of rendered items.
* @param totalItemCount The total number of items in the filmstrip.
return;
}
mListener.onFilmstripShown();
+ mFilmstripView.zoomAtIndexChanged();
FilmstripController controller = mFilmstripView.getController();
int currentId = controller.getCurrentId();
if (controller.inFilmstrip()) {
}
/**
+ * Called after current item or zoom level has changed.
+ */
+ public void zoomAtIndexChanged() {
+ int id = mViewItem[mCurrentItem].getId();
+ mListener.onZoomAtIndexChanged(id, mScale);
+ }
+
+ /**
* Checks if the data is at the center.
*
* @param id The id of the data to check.
if (nearest == -1 || nearest == mCurrentItem) {
return;
}
-
int prevDataId = (mViewItem[mCurrentItem] == null ? -1 : mViewItem[mCurrentItem].getId());
final int adjust = nearest - mCurrentItem;
if (adjust > 0) {
final int totalItemCount = mDataAdapter.getTotalNumber();
mListener.onScroll(firstVisible, visibleItemCount, totalItemCount);
}
+ zoomAtIndexChanged();
}
/**
onEnterFilmstrip();
}
}
+ zoomAtIndexChanged();
}
@Override
onEnterZoomView();
}
mZoomAnimator = null;
+ zoomAtIndexChanged();
}
@Override
@Override
public void onScaleEnd() {
+ zoomAtIndexChanged();
if (mScale > FULL_SCREEN_SCALE + TOLERANCE) {
return;
}
import java.util.HashMap;
public class UsageStatistics {
+ public static final long VIEW_TIMEOUT_MILLIS = 0;
+
private static UsageStatistics sInstance;
public static UsageStatistics instance() {
public void mediaInteraction(String ref, int interactionType, int cause, float age) {
}
+ public void mediaView(String ref, long modifiedMillis, float zoom) {
+ }
+
public void foregrounded(int source, int mode) {
}