diff options
author | Flavio Lerda <flerda@google.com> | 2013-04-16 09:46:07 +0100 |
---|---|---|
committer | Flavio Lerda <flerda@google.com> | 2013-04-17 12:16:19 +0100 |
commit | db559f02b471e2a53ea7a3dba950967ac69217b1 (patch) | |
tree | dfb89b4952a2056809ff709b76ccd89f36e6cbc9 /src/com/android/gallery3d | |
parent | bff393cee9eb2fc5d3a89fbcebb2fea988ab4cb2 (diff) | |
download | android_packages_apps_Snap-db559f02b471e2a53ea7a3dba950967ac69217b1.tar.gz android_packages_apps_Snap-db559f02b471e2a53ea7a3dba950967ac69217b1.tar.bz2 android_packages_apps_Snap-db559f02b471e2a53ea7a3dba950967ac69217b1.zip |
Usage statistics for sharing.
Bug: 8433834
Change-Id: Iaec6150443258daa213395b6fb1e8d8d3e6123b3
Diffstat (limited to 'src/com/android/gallery3d')
-rw-r--r-- | src/com/android/gallery3d/app/GalleryActionBar.java | 5 | ||||
-rw-r--r-- | src/com/android/gallery3d/app/PhotoPage.java | 33 |
2 files changed, 35 insertions, 3 deletions
diff --git a/src/com/android/gallery3d/app/GalleryActionBar.java b/src/com/android/gallery3d/app/GalleryActionBar.java index 0fb5e51b4..588f5842a 100644 --- a/src/com/android/gallery3d/app/GalleryActionBar.java +++ b/src/com/android/gallery3d/app/GalleryActionBar.java @@ -422,7 +422,8 @@ public class GalleryActionBar implements OnNavigationListener { return mActionBarMenu; } - public void setShareIntents(Intent sharePanoramaIntent, Intent shareIntent) { + public void setShareIntents(Intent sharePanoramaIntent, Intent shareIntent, + ShareActionProvider.OnShareTargetSelectedListener onShareListener) { mSharePanoramaIntent = sharePanoramaIntent; if (mSharePanoramaActionProvider != null) { mSharePanoramaActionProvider.setShareIntent(sharePanoramaIntent); @@ -430,6 +431,8 @@ public class GalleryActionBar implements OnNavigationListener { mShareIntent = shareIntent; if (mShareActionProvider != null) { mShareActionProvider.setShareIntent(shareIntent); + mShareActionProvider.setOnShareTargetSelectedListener( + onShareListener); } } } diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java index 9b6f2b961..3e1835853 100644 --- a/src/com/android/gallery3d/app/PhotoPage.java +++ b/src/com/android/gallery3d/app/PhotoPage.java @@ -36,6 +36,7 @@ import android.os.SystemClock; import android.view.Menu; import android.view.MenuItem; import android.widget.RelativeLayout; +import android.widget.ShareActionProvider; import android.widget.Toast; import com.android.camera.CameraActivity; @@ -71,8 +72,12 @@ import com.android.gallery3d.ui.SynchronizedHandler; import com.android.gallery3d.util.GalleryUtils; import com.android.gallery3d.util.UsageStatistics; +import java.text.DateFormat; +import java.text.ParseException; +import java.util.Date; + public abstract class PhotoPage extends ActivityState implements - PhotoView.Listener, AppBridge.Server, + PhotoView.Listener, AppBridge.Server, ShareActionProvider.OnShareTargetSelectedListener, PhotoPageBottomControls.Delegate, GalleryActionBar.OnAlbumModeSelectedListener { private static final String TAG = "PhotoPage"; @@ -391,7 +396,7 @@ public abstract class PhotoPage extends ActivityState implements } Intent shareIntent = createShareIntent(mCurrentPhoto); - mActionBar.setShareIntents(panoramaIntent, shareIntent); + mActionBar.setShareIntents(panoramaIntent, shareIntent, PhotoPage.this); setNfcBeamPushUri(contentUri); } break; @@ -1540,4 +1545,28 @@ public abstract class PhotoPage extends ActivityState implements public void onUndoBarVisibilityChanged(boolean visible) { refreshBottomControlsWhenReady(); } + + @Override + public boolean onShareTargetSelected(ShareActionProvider source, Intent intent) { + final long timestampMillis = mCurrentPhoto.getDateInMs(); + final String mediaType = getMediaTypeString(mCurrentPhoto); + UsageStatistics.onEvent(UsageStatistics.COMPONENT_GALLERY, + UsageStatistics.ACTION_SHARE, + mediaType, + timestampMillis > 0 + ? System.currentTimeMillis() - timestampMillis + : -1); + return false; + } + + private static String getMediaTypeString(MediaItem item) { + if (item.getMediaType() == MediaObject.MEDIA_TYPE_VIDEO) { + return "Video"; + } else if (item.getMediaType() == MediaObject.MEDIA_TYPE_IMAGE) { + return "Photo"; + } else { + return "Unknown:" + item.getMediaType(); + } + } + } |