diff options
author | Flavio Lerda <flerda@google.com> | 2013-04-18 13:19:39 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-04-18 13:19:40 +0000 |
commit | c70983629903524194ad20b829894feb4ea140d5 (patch) | |
tree | 3370388ccb3830388150975b231990020ed2ce02 /src/com/android/gallery3d/app | |
parent | e9011168ade9199b2ffebee23fdee49d4be0ab8e (diff) | |
parent | db559f02b471e2a53ea7a3dba950967ac69217b1 (diff) | |
download | android_packages_apps_Snap-c70983629903524194ad20b829894feb4ea140d5.tar.gz android_packages_apps_Snap-c70983629903524194ad20b829894feb4ea140d5.tar.bz2 android_packages_apps_Snap-c70983629903524194ad20b829894feb4ea140d5.zip |
Merge "Usage statistics for sharing." into gb-ub-photos-bryce
Diffstat (limited to 'src/com/android/gallery3d/app')
-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(); + } + } + } |