diff options
author | Mangesh Ghiware <mghiware@google.com> | 2013-09-19 09:24:23 -0700 |
---|---|---|
committer | Mangesh Ghiware <mghiware@google.com> | 2013-09-19 10:58:53 -0700 |
commit | a5682ab08e1d42fe272ec877929478b4adb769f5 (patch) | |
tree | 50d398bb9eced4a525a4a801ee10d7caa7dc7e1c /src/com/android/camera | |
parent | 0374e092eb6fdb33cb6edcb7724601928283dd47 (diff) | |
download | android_packages_apps_Snap-a5682ab08e1d42fe272ec877929478b4adb769f5.tar.gz android_packages_apps_Snap-a5682ab08e1d42fe272ec877929478b4adb769f5.tar.bz2 android_packages_apps_Snap-a5682ab08e1d42fe272ec877929478b4adb769f5.zip |
Bring back NFC beam support to filmstrip
Bug: 10805211
Change-Id: I457d47625c69fcdaba663e53f46d461d29c7cb92
Diffstat (limited to 'src/com/android/camera')
-rw-r--r-- | src/com/android/camera/CameraActivity.java | 36 | ||||
-rw-r--r-- | src/com/android/camera/util/ApiHelper.java | 19 |
2 files changed, 48 insertions, 7 deletions
diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java index a0e137b64..b8947e1b6 100644 --- a/src/com/android/camera/CameraActivity.java +++ b/src/com/android/camera/CameraActivity.java @@ -17,6 +17,7 @@ package com.android.camera; import android.animation.Animator; +import android.annotation.TargetApi; import android.app.ActionBar; import android.app.Activity; import android.content.BroadcastReceiver; @@ -31,7 +32,11 @@ import android.content.pm.ActivityInfo; import android.content.res.Configuration; import android.graphics.drawable.ColorDrawable; import android.net.Uri; +import android.nfc.NfcAdapter; +import android.nfc.NfcAdapter.CreateBeamUrisCallback; +import android.nfc.NfcEvent; import android.os.AsyncTask; +import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; @@ -163,6 +168,8 @@ public class CameraActivity extends Activity private ViewGroup mUndoDeletionBar; private boolean mIsUndoingDeletion = false; + private Uri[] mNfcPushUris = new Uri[1]; + private ShareActionProvider mStandardShareActionProvider; private Intent mStandardShareIntent; private ShareActionProvider mPanoramaShareActionProvider; @@ -406,6 +413,32 @@ public class CameraActivity extends Activity mBottomProgress.setProgress(progress); } + @TargetApi(Build.VERSION_CODES.JELLY_BEAN) + private void setupNfcBeamPush() { + NfcAdapter adapter = NfcAdapter.getDefaultAdapter(CameraActivity.this); + if (adapter == null) { + return; + } + + if (!ApiHelper.HAS_SET_BEAM_PUSH_URIS) { + // Disable beaming + adapter.setNdefPushMessage(null, CameraActivity.this); + return; + } + + adapter.setBeamPushUris(null, CameraActivity.this); + adapter.setBeamPushUrisCallback(new CreateBeamUrisCallback() { + @Override + public Uri[] createBeamUris(NfcEvent event) { + return mNfcPushUris; + } + }, CameraActivity.this); + } + + private void setNfcBeamPushUri(Uri uri) { + mNfcPushUris[0] = uri; + } + private void setStandardShareIntent(Uri contentUri, String mimeType) { mStandardShareIntent = getShareIntentFromType(mimeType); if (mStandardShareIntent != null) { @@ -538,6 +571,7 @@ public class CameraActivity extends Activity } } setStandardShareIntent(currentData.getContentUri(), currentData.getMimeType()); + setNfcBeamPushUri(currentData.getContentUri()); } boolean itemHasLocation = currentData.getLatLong() != null; @@ -877,6 +911,8 @@ public class CameraActivity extends Activity mDataAdapter.flush(); mFilmStripView.setDataAdapter(mDataAdapter); } + + setupNfcBeamPush(); } private void setRotationAnimation() { diff --git a/src/com/android/camera/util/ApiHelper.java b/src/com/android/camera/util/ApiHelper.java index a54477c93..994687f84 100644 --- a/src/com/android/camera/util/ApiHelper.java +++ b/src/com/android/camera/util/ApiHelper.java @@ -22,27 +22,32 @@ import java.lang.reflect.Field; public class ApiHelper { public static final boolean AT_LEAST_16 = Build.VERSION.SDK_INT >= 16; + public static final boolean HAS_APP_GALLERY = Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1; - public static final boolean HAS_MEDIA_COLUMNS_WIDTH_AND_HEIGHT = + + public static final boolean HAS_ANNOUNCE_FOR_ACCESSIBILITY = Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN; public static final boolean HAS_AUTO_FOCUS_MOVE_CALLBACK = Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN; public static final boolean HAS_MEDIA_ACTION_SOUND = Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN; + public static final boolean HAS_MEDIA_COLUMNS_WIDTH_AND_HEIGHT = + Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN; + public static final boolean HAS_SET_BEAM_PUSH_URIS = + Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN; public static final boolean HAS_SURFACE_TEXTURE_RECORDING = Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN; + public static final boolean HAS_CAMERA_HDR = Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1; - public static final boolean HAS_ANNOUNCE_FOR_ACCESSIBILITY = - Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN; - public static final boolean HAS_ROTATION_ANIMATION = - Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2; + public static final boolean HAS_DISPLAY_LISTENER = + Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1; public static final boolean HAS_ORIENTATION_LOCK = Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2; - public static final boolean HAS_DISPLAY_LISTENER = - Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1; + public static final boolean HAS_ROTATION_ANIMATION = + Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2; public static final boolean HAS_HIDEYBARS = isKitKatOrHigher(); |