From b3aa8b64087ecf64254134208b0fa0be7bd43800 Mon Sep 17 00:00:00 2001 From: Sascha Haeberling Date: Wed, 24 Apr 2013 10:58:58 -0700 Subject: Store location for SRI panoramas. Bug: 8692005 Change-Id: I1499de0103e518ee321ebb0c566b9fb4a7a853d3 --- src/com/android/camera/PanoramaModule.java | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/com/android/camera/PanoramaModule.java b/src/com/android/camera/PanoramaModule.java index c83bf825d..007ea7a4c 100644 --- a/src/com/android/camera/PanoramaModule.java +++ b/src/com/android/camera/PanoramaModule.java @@ -35,6 +35,7 @@ import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.hardware.Camera.Parameters; import android.hardware.Camera.Size; +import android.location.Location; import android.net.Uri; import android.os.AsyncTask; import android.os.Handler; @@ -176,6 +177,9 @@ public class PanoramaModule implements CameraModule, private boolean mPaused; private boolean mIsCreatingRenderer; + private LocationManager mLocationManager; + private ComboPreferences mPreferences; + private class MosaicJpeg { public MosaicJpeg(byte[] data, int width, int height) { this.data = data; @@ -279,6 +283,10 @@ public class PanoramaModule implements CameraModule, mGLRootView = (GLRootView) mActivity.getGLRoot(); + mPreferences = new ComboPreferences(mActivity); + CameraSettings.upgradeGlobalPreferences(mPreferences.getGlobal()); + mLocationManager = new LocationManager(mActivity, null); + mMainHandler = new Handler() { @Override public void handleMessage(Message msg) { @@ -902,6 +910,7 @@ public class PanoramaModule implements CameraModule, mActivity.getResources().getString(R.string.pano_file_name_format), mTimeTaken); String filepath = Storage.generateFilepath(filename); + Location loc = mLocationManager.getCurrentLocation(); ExifInterface exif = new ExifInterface(); try { exif.readExif(jpegData); @@ -910,19 +919,27 @@ public class PanoramaModule implements CameraModule, TimeZone.getDefault()); exif.setTag(exif.buildTag(ExifInterface.TAG_ORIENTATION, ExifInterface.getOrientationValueForRotation(orientation))); + writeLocation(loc, exif); exif.writeExif(jpegData, filepath); } catch (IOException e) { Log.e(TAG, "Cannot set exif for " + filepath, e); Storage.writeFile(filepath, jpegData); } - int jpegLength = (int) (new File(filepath).length()); return Storage.addImage(mContentResolver, filename, mTimeTaken, - null, orientation, jpegLength, filepath, width, height); + loc, orientation, jpegLength, filepath, width, height); } return null; } + private static void writeLocation(Location location, ExifInterface exif) { + if (location == null) { + return; + } + exif.addGpsTags(location.getLatitude(), location.getLongitude()); + exif.setTag(exif.buildTag(ExifInterface.TAG_GPS_PROCESSING_METHOD, location.getProvider())); + } + private void clearMosaicFrameProcessorIfNeeded() { if (!mPaused || mThreadRunning) return; // Only clear the processor if it is initialized by this activity @@ -943,6 +960,7 @@ public class PanoramaModule implements CameraModule, @Override public void onPauseBeforeSuper() { mPaused = true; + if (mLocationManager != null) mLocationManager.recordLocation(false); } @Override @@ -1059,6 +1077,11 @@ public class PanoramaModule implements CameraModule, } keepScreenOnAwhile(); + // Initialize location service. + boolean recordLocation = RecordLocationPreference.get(mPreferences, + mContentResolver); + mLocationManager.recordLocation(recordLocation); + // Dismiss open menu if exists. PopupManager.getInstance(mActivity).notifyShowPopup(null); mRootView.requestLayout(); -- cgit v1.2.3