TinyPlanet: begone

Change-Id: Ie7c65b8ae1dd41ed76d806ae267eabc6195f6f92
Signed-off-by: Alexander Martinz <amartinz@shiftphones.com>
diff --git a/Android.mk b/Android.mk
index 5704f5c..5bb34ce 100644
--- a/Android.mk
+++ b/Android.mk
@@ -58,9 +58,9 @@
 # leave them out of the APK
 
 ifneq (,$(TARGET_BUILD_APPS))
-  LOCAL_JNI_SHARED_LIBRARIES := libjni_snapmosaic libjni_snaptinyplanet libjni_snapimageutil
+  LOCAL_JNI_SHARED_LIBRARIES := libjni_snapmosaic libjni_snapimageutil
 else
-  LOCAL_REQUIRED_MODULES := libjni_snapmosaic libjni_snaptinyplanet libjni_snapimageutil
+  LOCAL_REQUIRED_MODULES := libjni_snapmosaic libjni_snapimageutil
 endif
 
 LOCAL_REQUIRED_MODULES += privapp_whitelist_org.codeaurora.snapcam.xml
diff --git a/jni/Android.mk b/jni/Android.mk
index c813453..194ef7f 100644
--- a/jni/Android.mk
+++ b/jni/Android.mk
@@ -50,21 +50,6 @@
 LOCAL_PRODUCT_MODULE := true
 include $(BUILD_SHARED_LIBRARY)
 
-# TinyPlanet
-include $(CLEAR_VARS)
-
-LOCAL_CPP_EXTENSION := .cc
-LOCAL_LDFLAGS   := -llog -ljnigraphics
-LOCAL_SDK_VERSION := 9
-LOCAL_MODULE    := libjni_snaptinyplanet
-LOCAL_PRODUCT_MODULE := true
-LOCAL_SRC_FILES := tinyplanet.cc
-
-LOCAL_CFLAGS    += -ffast-math -O3 -funroll-loops
-LOCAL_ARM_MODE := arm
-
-include $(BUILD_SHARED_LIBRARY)
-
 # ImageUtilForCamera2 with beautification
 include $(CLEAR_VARS)
 LOCAL_LDFLAGS   := -llog
diff --git a/jni/tinyplanet.cc b/jni/tinyplanet.cc
deleted file mode 100644
index b629c9f..0000000
--- a/jni/tinyplanet.cc
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <jni.h>
-#include <math.h>
-#include <android/bitmap.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#define PI_F 3.141592653589f
-
-class ImageRGBA {
- public:
-  ImageRGBA(unsigned char* image, int width, int height)
-   : image_(image), width_(width), height_(height) {
-    width_step_ = width * 4;
-  }
-
-  int Width() const {
-    return width_;
-  }
-
-  int Height() const {
-    return height_;
-  }
-
-  // Pixel accessor.
-  unsigned char* operator()(int x, int y) {
-    return image_ + y * width_step_ + x * 4;
-  }
-  const unsigned char* operator()(int x, int y) const {
-    return image_ + y * width_step_ + x * 4;
-  }
-
- private:
-  unsigned char* image_;
-  int width_;
-  int height_;
-  int width_step_;
-};
-
-// Interpolate a pixel in a 3 channel image.
-inline void InterpolatePixel(const ImageRGBA &image, float x, float y,
-                             unsigned char* dest) {
-  // Get pointers and scale factors for the source pixels.
-  float ax = x - floor(x);
-  float ay = y - floor(y);
-  float axn = 1.0f - ax;
-  float ayn = 1.0f - ay;
-  const unsigned char *p = image(x, y);
-  const unsigned char *p2 = image(x, y + 1);
-
-  // Interpolate each image color plane.
-  dest[0] = static_cast<unsigned char>(axn * ayn * p[0] + ax * ayn * p[4] +
-             ax * ay * p2[4] + axn * ay * p2[0] + 0.5f);
-  p++;
-  p2++;
-
-  dest[1] = static_cast<unsigned char>(axn * ayn * p[0] + ax * ayn * p[4] +
-             ax * ay * p2[4] + axn * ay * p2[0] + 0.5f);
-  p++;
-  p2++;
-
-  dest[2] = static_cast<unsigned char>(axn * ayn * p[0] + ax * ayn * p[4] +
-             ax * ay * p2[4] + axn * ay * p2[0] + 0.5f);
-  p++;
-  p2++;
-  dest[3] = 0xFF;
-}
-
-// Wrap circular coordinates around the globe
-inline float wrap(float value, float dimension) {
-  return value - (dimension * floor(value/dimension));
-}
-
-void StereographicProjection(float scale, float angle, unsigned char* input_image,
-                             int input_width, int input_height,
-                             unsigned char* output_image, int output_width,
-                             int output_height) {
-  ImageRGBA input(input_image, input_width, input_height);
-  ImageRGBA output(output_image, output_width, output_height);
-
-  const float image_scale = output_width * scale;
-
-  for (int x = 0; x < output_width; x++) {
-    // Center and scale x
-    float xf = (x - output_width / 2.0f) / image_scale;
-
-    for (int y = 0; y < output_height; y++) {
-      // Center and scale y
-      float yf = (y - output_height / 2.0f) / image_scale;
-
-      // Convert to polar
-      float r = hypotf(xf, yf);
-      float theta = angle+atan2(yf, xf);
-      if (theta>PI_F) theta-=2*PI_F;
-
-      // Project onto plane
-      float phi = 2 * atan(1 / r);
-      // (theta stays the same)
-
-      // Map to panorama image
-      float px = (theta / (2 * PI_F)) * input_width;
-      float py = (phi / PI_F) * input_height;
-
-      // Wrap around the globe
-      px = wrap(px, input_width);
-      py = wrap(py, input_height);
-
-      // Write the interpolated pixel
-      InterpolatePixel(input, px, py, output(x, y));
-    }
-  }
-}
-
-
-JNIEXPORT void JNICALL Java_com_android_camera_tinyplanet_TinyPlanetNative_process(JNIEnv* env, jobject obj, jobject bitmap_in, jint width, jint height, jobject bitmap_out, jint output_size, jfloat scale, jfloat angle)
-{
-    (void)obj;
-    char* source = 0;
-    char* destination = 0;
-    AndroidBitmap_lockPixels(env, bitmap_in, (void**) &source);
-    AndroidBitmap_lockPixels(env, bitmap_out, (void**) &destination);
-    unsigned char * rgb_in = (unsigned char * )source;
-    unsigned char * rgb_out = (unsigned char * )destination;
-
-    StereographicProjection(scale, angle, rgb_in, width, height, rgb_out, output_size, output_size);
-    AndroidBitmap_unlockPixels(env, bitmap_in);
-    AndroidBitmap_unlockPixels(env, bitmap_out);
-}
-
-#ifdef __cplusplus
-}
-#endif
-
-
diff --git a/res/layout/filmstrip_bottom_controls.xml b/res/layout/filmstrip_bottom_controls.xml
index ef370a3..89f4292 100644
--- a/res/layout/filmstrip_bottom_controls.xml
+++ b/res/layout/filmstrip_bottom_controls.xml
@@ -35,26 +35,4 @@
         android:src="@drawable/ic_menu_edit"
         android:visibility="gone" />
 
-    <ImageButton
-        android:id="@+id/filmstrip_bottom_control_panorama"
-        android:layout_width="70dp"
-        android:layout_height="70dp"
-        android:layout_alignParentBottom="true"
-        android:layout_centerHorizontal="true"
-        android:background="@drawable/transparent_button_background"
-        android:clickable="true"
-        android:src="@drawable/ic_view_photosphere"
-        android:visibility="gone" />
-
-    <ImageButton
-        android:id="@+id/filmstrip_bottom_control_tiny_planet"
-        android:layout_width="48dp"
-        android:layout_height="48dp"
-        android:layout_alignParentBottom="true"
-        android:layout_alignParentRight="true"
-        android:layout_alignParentEnd="true"
-        android:background="?android:attr/selectableItemBackgroundBorderless"
-        android:src="@drawable/ic_menu_tiny_planet"
-        android:visibility="gone" />
-
 </com.android.camera.ui.FilmstripBottomControls>
diff --git a/res/layout/tinyplanet_editor.xml b/res/layout/tinyplanet_editor.xml
deleted file mode 100644
index f5bd5d2..0000000
--- a/res/layout/tinyplanet_editor.xml
+++ /dev/null
@@ -1,73 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-     Copyright (C) 2013 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:tools="http://schemas.android.com/tools"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:orientation="vertical" >
-
-    <com.android.camera.tinyplanet.TinyPlanetPreview
-        android:id="@+id/preview"
-        android:layout_width="match_parent"
-        android:layout_height="0dp"
-        android:layout_gravity="center_horizontal"
-        android:layout_weight="1" />
-
-    <LinearLayout
-        android:layout_width="match_parent"
-        android:layout_height="0dp"
-        android:layout_weight="1"
-        android:orientation="vertical" >
-
-        <TextView
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:text="@string/tiny_planet_zoom"
-            android:textColor="@color/white" />
-
-        <SeekBar
-            android:id="@+id/zoomSlider"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:contentDescription="@string/tiny_planet_zoom"
-            android:max="1000"
-            android:progress="500" />
-
-        <TextView
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_marginTop="5dp"
-            android:text="@string/tiny_planet_rotate"
-            android:textColor="@color/white" />
-
-        <SeekBar
-            android:id="@+id/angleSlider"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:contentDescription="@string/tiny_planet_rotate"
-            android:max="360"
-            android:progress="0" />
-
-        <Button
-            android:id="@+id/creatTinyPlanetButton"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_marginTop="5dp"
-            android:text="@string/create_tiny_planet" />
-    </LinearLayout>
-
-</LinearLayout>
diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java
index 358c44e..f6e4fe3 100755
--- a/src/com/android/camera/CameraActivity.java
+++ b/src/com/android/camera/CameraActivity.java
@@ -84,7 +84,6 @@
 import android.widget.Toast;
 
 import com.android.camera.app.AppManagerFactory;
-import com.android.camera.app.PanoramaStitchingManager;
 import com.android.camera.app.PlaceholderManager;
 import com.android.camera.crop.CropActivity;
 import com.android.camera.data.CameraDataAdapter;
@@ -98,7 +97,6 @@
 import com.android.camera.data.MediaDetails;
 import com.android.camera.data.SimpleViewData;
 import com.android.camera.exif.ExifInterface;
-import com.android.camera.tinyplanet.TinyPlanetFragment;
 import com.android.camera.ui.DetailsDialog;
 import com.android.camera.ui.FilmStripView;
 import com.android.camera.ui.FilmStripView.ImageData;
@@ -110,7 +108,6 @@
 import com.android.camera.util.GcamHelper;
 import com.android.camera.util.IntentHelper;
 import com.android.camera.util.PersistUtil;
-import com.android.camera.util.PhotoSphereHelper.PanoramaViewHelper;
 import com.android.camera.util.UsageStatistics;
 
 import org.codeaurora.snapcam.R;
@@ -200,7 +197,6 @@
     private LocalDataAdapter mWrappedDataAdapter;
 
     private Context mContext;
-    private PanoramaStitchingManager mPanoramaManager;
     private PlaceholderManager mPlaceholderManager;
     private int mCurrentModuleIndex;
     private CameraModule mCurrentModule;
@@ -217,7 +213,6 @@
     private View mCameraCaptureModuleRootView;
     private FilmStripView mFilmStripView;
     private ProgressBar mBottomProgress;
-    private View mPanoStitchingPanel;
     private int mResultCodeForTesting;
     private Intent mResultDataForTesting;
     private OnScreenHint mStorageHint;
@@ -232,7 +227,6 @@
     private int mLastRawOrientation;
     private MyOrientationEventListener mOrientationListener;
     private Handler mMainHandler;
-    private PanoramaViewHelper mPanoramaViewHelper;
     private CameraPreviewData mCameraPreviewData;
     private ActionBar mActionBar;
     private OnActionBarVisibilityListener mOnActionBarVisibilityListener = null;
@@ -501,12 +495,7 @@
                     boolean isPreview = isCameraPreview(dataID);
                     boolean isFullScreen = mFilmStripView.inFullScreen();
                     if (isFullScreen && isPreview && CameraActivity.this.hasWindowFocus()){
-                        runOnUiThread(new Runnable() {
-                            @Override
-                            public void run() {
-                                updateStorageSpaceAndHint();
-                            }
-                        });
+                        runOnUiThread(() -> updateStorageSpaceAndHint());
                     }
                     // Delay hiding action bar if there is any user interaction
                     if (mMainHandler.hasMessages(HIDE_ACTION_BAR)) {
@@ -517,49 +506,30 @@
                     // TODO: This callback is UI event callback, should always
                     // happen on UI thread. Find the reason for this
                     // runOnUiThread() and fix it.
-                    runOnUiThread(new Runnable() {
-                        @Override
-                        public void run() {
-                            LocalData currentData = mDataAdapter.getLocalData(dataID);
-                            if (currentData == null) {
-                                Log.w(TAG, "Current data ID not found.");
-                                hidePanoStitchingProgress();
-                                return;
+                    runOnUiThread(() -> {
+                        LocalData currentData = mDataAdapter.getLocalData(dataID);
+                        if (currentData == null) {
+                            Log.w(TAG, "Current data ID not found.");
+                            return;
+                        }
+                        boolean isCameraID = currentData.getLocalDataType() ==
+                                LocalData.LOCAL_CAMERA_PREVIEW;
+                        if (!focused) {
+                            if (isCameraID) {
+                                mCurrentModule.onPreviewFocusChanged(false);
+                                CameraActivity.this.setSystemBarsVisibility(true);
                             }
-                            boolean isCameraID = currentData.getLocalDataType() ==
-                                    LocalData.LOCAL_CAMERA_PREVIEW;
-                            if (!focused) {
-                                if (isCameraID) {
-                                    mCurrentModule.onPreviewFocusChanged(false);
-                                    CameraActivity.this.setSystemBarsVisibility(true);
+                        } else {
+                            if (isCameraID) {
+                                // Don't show the action bar in Camera
+                                // preview.
+                                CameraActivity.this.setSystemBarsVisibility(false);
+
+                                if (mPendingDeletion) {
+                                    performDeletion();
                                 }
-                                hidePanoStitchingProgress();
                             } else {
-                                if (isCameraID) {
-                                    // Don't show the action bar in Camera
-                                    // preview.
-                                    CameraActivity.this.setSystemBarsVisibility(false);
-
-                                    if (mPendingDeletion) {
-                                        performDeletion();
-                                    }
-                                } else {
-                                    updateActionBarMenu(dataID);
-                                }
-
-                                Uri contentUri = currentData.getContentUri();
-                                if (contentUri == null) {
-                                    hidePanoStitchingProgress();
-                                    return;
-                                }
-                                int panoStitchingProgress = mPanoramaManager.getTaskProgress(
-                                        contentUri);
-                                if (panoStitchingProgress < 0) {
-                                    hidePanoStitchingProgress();
-                                    return;
-                                }
-                                showPanoStitchingProgress();
-                                updateStitchingProgress(panoStitchingProgress);
+                                updateActionBarMenu(dataID);
                             }
                         }
                     });
@@ -709,18 +679,6 @@
         }
     }
 
-    private void hidePanoStitchingProgress() {
-        mPanoStitchingPanel.setVisibility(View.GONE);
-    }
-
-    private void showPanoStitchingProgress() {
-        mPanoStitchingPanel.setVisibility(View.VISIBLE);
-    }
-
-    private void updateStitchingProgress(int progress) {
-        mBottomProgress.setProgress(progress);
-    }
-
     @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
     private void setupNfcBeamPush() {
         NfcAdapter adapter = NfcAdapter.getDefaultAdapter(CameraActivity.this);
@@ -1134,17 +1092,6 @@
             case LocalData.LOCAL_VIDEO:
                 supported |= SUPPORT_DELETE | SUPPORT_INFO | SUPPORT_SHARE;
                 break;
-            case LocalData.LOCAL_PHOTO_SPHERE:
-                supported |= SUPPORT_DELETE | SUPPORT_ROTATE | SUPPORT_INFO
-                        | SUPPORT_CROP | SUPPORT_SETAS | SUPPORT_EDIT
-                        | SUPPORT_SHARE | SUPPORT_SHOW_ON_MAP;
-                break;
-            case LocalData.LOCAL_360_PHOTO_SPHERE:
-                supported |= SUPPORT_DELETE | SUPPORT_ROTATE | SUPPORT_INFO
-                        | SUPPORT_CROP | SUPPORT_SETAS | SUPPORT_EDIT
-                        | SUPPORT_SHARE | SUPPORT_SHARE_PANORAMA360
-                        | SUPPORT_SHOW_ON_MAP;
-                break;
             default:
                 break;
         }
@@ -1248,64 +1195,6 @@
                 }
     };
 
-    private ImageTaskManager.TaskListener mStitchingListener =
-            new ImageTaskManager.TaskListener() {
-                @Override
-                public void onTaskQueued(String filePath, final Uri imageUri) {
-                    mMainHandler.post(new Runnable() {
-                        @Override
-                        public void run() {
-                            notifyNewMedia(imageUri);
-                            int dataID = mDataAdapter.findDataByContentUri(imageUri);
-                            if (dataID != -1) {
-                                // Don't allow special UI actions (swipe to
-                                // delete, for example) on in-progress data.
-                                LocalData d = mDataAdapter.getLocalData(dataID);
-                                InProgressDataWrapper newData = new InProgressDataWrapper(d);
-                                mDataAdapter.updateData(dataID, newData);
-                            }
-                        }
-                    });
-                }
-
-                @Override
-                public void onTaskDone(String filePath, final Uri imageUri) {
-                    Log.v(TAG, "onTaskDone:" + filePath);
-                    mMainHandler.post(new Runnable() {
-                        @Override
-                        public void run() {
-                            int doneID = mDataAdapter.findDataByContentUri(imageUri);
-                            int currentDataId = mFilmStripView.getCurrentId();
-
-                            if (currentDataId == doneID) {
-                                hidePanoStitchingProgress();
-                                updateStitchingProgress(0);
-                            }
-
-                            mDataAdapter.refresh(getContentResolver(), imageUri);
-                        }
-                    });
-                }
-
-                @Override
-                public void onTaskProgress(
-                        String filePath, final Uri imageUri, final int progress) {
-                    mMainHandler.post(new Runnable() {
-                        @Override
-                        public void run() {
-                            int currentDataId = mFilmStripView.getCurrentId();
-                            if (currentDataId == -1) {
-                                return;
-                            }
-                            if (imageUri.equals(
-                                    mDataAdapter.getLocalData(currentDataId).getContentUri())) {
-                                updateStitchingProgress(progress);
-                            }
-                        }
-                    });
-                }
-            };
-
     public MediaSaveService getMediaSaveService() {
         return mMediaSaveService;
     }
@@ -1621,13 +1510,9 @@
         mAboveFilmstripControlLayout =
                 (FrameLayout) findViewById(R.id.camera_above_filmstrip_layout);
         mAboveFilmstripControlLayout.setFitsSystemWindows(true);
-        mPanoramaManager = AppManagerFactory.getInstance(this)
-                .getPanoramaStitchingManager();
         mPlaceholderManager = AppManagerFactory.getInstance(this)
                 .getGcamProcessingManager();
-        mPanoramaManager.addTaskListener(mStitchingListener);
         mPlaceholderManager.addTaskListener(mPlaceholderListener);
-        mPanoStitchingPanel = findViewById(R.id.pano_stitching_progress_panel);
         mBottomProgress = (ProgressBar) findViewById(R.id.pano_stitching_progress_bar);
         mCameraPreviewData = new CameraPreviewData(rootLayout,
                 FilmStripView.ImageData.SIZE_FULL,
@@ -1640,9 +1525,6 @@
 
         mFilmStripView.setViewGap(
                 getResources().getDimensionPixelSize(R.dimen.camera_film_strip_gap));
-        mPanoramaViewHelper = new PanoramaViewHelper(this);
-        mPanoramaViewHelper.onCreate();
-        mFilmStripView.setPanoramaViewHelper(mPanoramaViewHelper);
         // Set up the camera preview first so the preview shows up ASAP.
         mFilmStripView.setListener(mFilmStripListener);
 
@@ -1904,7 +1786,6 @@
             return;
         }
         bindMediaSaveService();
-        mPanoramaViewHelper.onStart();
     }
 
     @Override
@@ -1913,7 +1794,6 @@
         if (mSecureCamera && !hasCriticalPermissions()) {
             return;
         }
-        mPanoramaViewHelper.onStop();
         unbindMediaSaveService();
     }
 
@@ -2299,22 +2179,6 @@
         }
     }
 
-    /**
-     * Launch the tiny planet editor.
-     *
-     * @param data the data must be a 360 degree stereographically mapped
-     *            panoramic image. It will not be modified, instead a new item
-     *            with the result will be added to the filmstrip.
-     */
-    public void launchTinyPlanetEditor(LocalData data) {
-        TinyPlanetFragment fragment = new TinyPlanetFragment();
-        Bundle bundle = new Bundle();
-        bundle.putString(TinyPlanetFragment.ARGUMENT_URI, data.getContentUri().toString());
-        bundle.putString(TinyPlanetFragment.ARGUMENT_TITLE, data.getTitle());
-        fragment.setArguments(bundle);
-        fragment.show(getFragmentManager(), "tiny_planet");
-    }
-
     private void openModule(CameraModule module) {
         module.onResumeBeforeSuper();
         module.onResumeAfterSuper();
diff --git a/src/com/android/camera/app/AppManagerFactory.java b/src/com/android/camera/app/AppManagerFactory.java
index 5cd70a7..59aa349 100644
--- a/src/com/android/camera/app/AppManagerFactory.java
+++ b/src/com/android/camera/app/AppManagerFactory.java
@@ -18,7 +18,6 @@
 
 import android.content.Context;
 
-
 /**
  * A singleton class which provides application level utility
  * classes.
@@ -34,19 +33,13 @@
         return sFactory;
     }
 
-    private PanoramaStitchingManager mPanoramaStitchingManager;
     private PlaceholderManager mGcamProcessingManager;
 
     /** No public constructor. */
     private AppManagerFactory(Context ctx) {
-        mPanoramaStitchingManager = new PanoramaStitchingManager(ctx);
         mGcamProcessingManager = new PlaceholderManager(ctx);
     }
 
-    public PanoramaStitchingManager getPanoramaStitchingManager() {
-        return mPanoramaStitchingManager;
-    }
-
     public PlaceholderManager getGcamProcessingManager() {
         return mGcamProcessingManager;
     }
diff --git a/src/com/android/camera/data/InProgressDataWrapper.java b/src/com/android/camera/data/InProgressDataWrapper.java
index 9ce968e..3170434 100644
--- a/src/com/android/camera/data/InProgressDataWrapper.java
+++ b/src/com/android/camera/data/InProgressDataWrapper.java
@@ -24,7 +24,6 @@
 import android.view.View;
 import android.widget.FrameLayout;
 
-import com.android.camera.util.PhotoSphereHelper;
 import org.codeaurora.snapcam.R;
 
 /**
@@ -187,16 +186,6 @@
     }
 
     @Override
-    public void isPhotoSphere(Context context, PanoramaSupportCallback callback) {
-        mLocalData.isPhotoSphere(context, callback);
-    }
-
-    @Override
-    public void viewPhotoSphere(PhotoSphereHelper.PanoramaViewHelper helper) {
-        mLocalData.viewPhotoSphere(helper);
-    }
-
-    @Override
     public boolean isPhoto() {
         return mLocalData.isPhoto();
     }
diff --git a/src/com/android/camera/data/LocalData.java b/src/com/android/camera/data/LocalData.java
index da64fee..fe8417e 100644
--- a/src/com/android/camera/data/LocalData.java
+++ b/src/com/android/camera/data/LocalData.java
@@ -62,11 +62,11 @@
     /**
      * Constant for denoting a still image, with valid PhotoSphere metadata.
      */
-    public static final int LOCAL_PHOTO_SPHERE     = 5;
+    //public static final int LOCAL_PHOTO_SPHERE     = 5;
     /**
      * Constant for denoting a still image, with valid 360 PhotoSphere metadata.
      */
-    public static final int LOCAL_360_PHOTO_SPHERE = 6;
+    //public static final int LOCAL_360_PHOTO_SPHERE = 6;
     /**
      * Constant for denoting an in-progress item which should not be touched
      * before the related task is done. Data of this type should not support
diff --git a/src/com/android/camera/data/LocalMediaData.java b/src/com/android/camera/data/LocalMediaData.java
index bc3f09f..e2b16e6 100644
--- a/src/com/android/camera/data/LocalMediaData.java
+++ b/src/com/android/camera/data/LocalMediaData.java
@@ -40,7 +40,6 @@
 
 import com.android.camera.ui.FilmStripView;
 import com.android.camera.util.CameraUtil;
-import com.android.camera.util.PhotoSphereHelper;
 import org.codeaurora.snapcam.R;
 
 import java.io.File;
@@ -68,12 +67,6 @@
     protected final double mLatitude;
     protected final double mLongitude;
 
-    /** The panorama metadata information of this media data. */
-    protected PhotoSphereHelper.PanoramaMetadata mPanoramaMetadata;
-
-    /** Used to load photo sphere metadata from image files. */
-    protected PanoramaMetadataLoader mPanoramaMetadataLoader = null;
-
     /**
      * Used for thumbnail loading optimization. True if this data has a
      * corresponding visible view.
@@ -159,39 +152,6 @@
     }
 
     @Override
-    public void viewPhotoSphere(PhotoSphereHelper.PanoramaViewHelper helper) {
-        helper.showPanorama(getContentUri());
-    }
-
-    @Override
-    public void isPhotoSphere(Context context, final PanoramaSupportCallback callback) {
-        // If we already have metadata, use it.
-        if (mPanoramaMetadata != null) {
-            callback.panoramaInfoAvailable(mPanoramaMetadata.mUsePanoramaViewer,
-                    mPanoramaMetadata.mIsPanorama360);
-        }
-
-        // Otherwise prepare a loader, if we don't have one already.
-        if (mPanoramaMetadataLoader == null) {
-            mPanoramaMetadataLoader = new PanoramaMetadataLoader(getContentUri());
-        }
-
-        // Load the metadata asynchronously.
-        mPanoramaMetadataLoader.getPanoramaMetadata(context,
-                new PanoramaMetadataLoader.PanoramaMetadataCallback() {
-                    @Override
-                    public void onPanoramaMetadataLoaded(PhotoSphereHelper.PanoramaMetadata metadata) {
-                        // Store the metadata and remove the loader to free up
-                        // space.
-                        mPanoramaMetadata = metadata;
-                        mPanoramaMetadataLoader = null;
-                        callback.panoramaInfoAvailable(metadata.mUsePanoramaViewer,
-                                metadata.mIsPanorama360);
-                    }
-                });
-    }
-
-    @Override
     public void onFullScreen(boolean fullScreen) {
         // do nothing.
     }
@@ -441,13 +401,6 @@
 
         @Override
         public int getLocalDataType() {
-            if (mPanoramaMetadata != null) {
-                if (mPanoramaMetadata.mIsPanorama360) {
-                    return LOCAL_360_PHOTO_SPHERE;
-                } else if (mPanoramaMetadata.mUsePanoramaViewer) {
-                    return LOCAL_PHOTO_SPHERE;
-                }
-            }
             return LOCAL_IMAGE;
         }
 
diff --git a/src/com/android/camera/data/PanoramaMetadataLoader.java b/src/com/android/camera/data/PanoramaMetadataLoader.java
deleted file mode 100644
index fda6848..0000000
--- a/src/com/android/camera/data/PanoramaMetadataLoader.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.camera.data;
-
-import java.util.ArrayList;
-
-import android.content.Context;
-import android.net.Uri;
-
-import com.android.camera.util.PhotoSphereHelper;
-import com.android.camera.util.PhotoSphereHelper.PanoramaMetadata;
-
-/**
- * This class breaks out the off-thread panorama support.
- */
-public class PanoramaMetadataLoader {
-    /**
-     * Classes implementing this interface can get information about loaded
-     * photo sphere metadata.
-     */
-    public static interface PanoramaMetadataCallback {
-        /**
-         * Called with the loaded metadata or <code>null</code>.
-         */
-        public void onPanoramaMetadataLoaded(PanoramaMetadata metadata);
-    }
-
-    private PanoramaMetadata mPanoramaMetadata;
-    private ArrayList<PanoramaMetadataCallback> mCallbacksWaiting;
-    private Uri mMediaUri;
-
-    /**
-     * Instantiated the meta data loader for the image resource with the given
-     * URI.
-     */
-    public PanoramaMetadataLoader(Uri uri) {
-        mMediaUri = uri;
-    }
-
-    /**
-     * Asynchronously extract and return panorama metadata from the item with
-     * the given URI.
-     * <p>
-     * NOTE: This call is backed by a cache to speed up successive calls, which
-     * will return immediately. Use {@link #clearCachedValues()} is called.
-     */
-    public synchronized void getPanoramaMetadata(final Context context,
-            PanoramaMetadataCallback callback) {
-        if (mPanoramaMetadata != null) {
-            // Return the cached data right away, no need to fetch it again.
-            callback.onPanoramaMetadataLoaded(mPanoramaMetadata);
-        } else {
-            if (mCallbacksWaiting == null) {
-                mCallbacksWaiting = new ArrayList<PanoramaMetadataCallback>();
-
-                // TODO: Don't create a new thread each time, use a pool or
-                // single instance.
-                (new Thread() {
-                    @Override
-                    public void run() {
-                        onLoadingDone(PhotoSphereHelper.getPanoramaMetadata(context,
-                                mMediaUri));
-                    }
-                }).start();
-            }
-            mCallbacksWaiting.add(callback);
-        }
-    }
-
-    /**
-     * Clear cached value and stop all running loading threads.
-     */
-    public synchronized void clearCachedValues() {
-        if (mPanoramaMetadata != null) {
-            mPanoramaMetadata = null;
-        }
-
-        // TODO: Cancel running loading thread if active.
-     }
-
-    private synchronized void onLoadingDone(PanoramaMetadata metadata) {
-        mPanoramaMetadata = metadata;
-        if (mPanoramaMetadata == null) {
-            // Error getting panorama data from file. Treat as not panorama.
-            mPanoramaMetadata = PhotoSphereHelper.NOT_PANORAMA;
-        }
-        for (PanoramaMetadataCallback cb : mCallbacksWaiting) {
-            cb.onPanoramaMetadataLoaded(mPanoramaMetadata);
-        }
-        mCallbacksWaiting = null;
-    }
-}
diff --git a/src/com/android/camera/data/SimpleViewData.java b/src/com/android/camera/data/SimpleViewData.java
index ba44594..7d8504f 100644
--- a/src/com/android/camera/data/SimpleViewData.java
+++ b/src/com/android/camera/data/SimpleViewData.java
@@ -25,7 +25,6 @@
 import android.view.View;
 
 import com.android.camera.ui.FilmStripView;
-import com.android.camera.util.PhotoSphereHelper;
 
 /**
  * A LocalData that does nothing but only shows a view.
@@ -136,17 +135,6 @@
     }
 
     @Override
-    public void isPhotoSphere(Context context, PanoramaSupportCallback callback) {
-        // Not a photo sphere panorama.
-        callback.panoramaInfoAvailable(false, false);
-    }
-
-    @Override
-    public void viewPhotoSphere(PhotoSphereHelper.PanoramaViewHelper helper) {
-        // do nothing.
-    }
-
-    @Override
     public void onFullScreen(boolean fullScreen) {
         // do nothing.
     }
diff --git a/src/com/android/camera/tinyplanet/TinyPlanetFragment.java b/src/com/android/camera/tinyplanet/TinyPlanetFragment.java
deleted file mode 100644
index 5a9f739..0000000
--- a/src/com/android/camera/tinyplanet/TinyPlanetFragment.java
+++ /dev/null
@@ -1,500 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.camera.tinyplanet;
-
-import android.app.DialogFragment;
-import android.app.ProgressDialog;
-import android.graphics.Bitmap;
-import android.graphics.Bitmap.CompressFormat;
-import android.graphics.BitmapFactory;
-import android.graphics.Canvas;
-import android.graphics.Point;
-import android.graphics.RectF;
-import android.net.Uri;
-import android.os.AsyncTask;
-import android.os.Bundle;
-import android.os.Handler;
-import android.util.Log;
-import android.view.Display;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.view.ViewGroup;
-import android.view.Window;
-import android.widget.Button;
-import android.widget.SeekBar;
-import android.widget.SeekBar.OnSeekBarChangeListener;
-
-import com.adobe.xmp.XMPException;
-import com.adobe.xmp.XMPMeta;
-import com.android.camera.CameraActivity;
-import com.android.camera.MediaSaveService;
-import com.android.camera.PhotoModule;
-import com.android.camera.MediaSaveService.OnMediaSavedListener;
-import com.android.camera.exif.ExifInterface;
-import com.android.camera.tinyplanet.TinyPlanetPreview.PreviewSizeListener;
-import com.android.camera.util.XmpUtil;
-import org.codeaurora.snapcam.R;
-
-import java.io.ByteArrayOutputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Date;
-import java.util.TimeZone;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
-
-/**
- * An activity that provides an editor UI to create a TinyPlanet image from a
- * 360 degree stereographically mapped panoramic image.
- */
-public class TinyPlanetFragment extends DialogFragment implements PreviewSizeListener {
-    /** Argument to tell the fragment the URI of the original panoramic image. */
-    public static final String ARGUMENT_URI = "uri";
-    /** Argument to tell the fragment the title of the original panoramic image. */
-    public static final String ARGUMENT_TITLE = "title";
-
-    public static final String CROPPED_AREA_IMAGE_WIDTH_PIXELS =
-            "CroppedAreaImageWidthPixels";
-    public static final String CROPPED_AREA_IMAGE_HEIGHT_PIXELS =
-            "CroppedAreaImageHeightPixels";
-    public static final String CROPPED_AREA_FULL_PANO_WIDTH_PIXELS =
-            "FullPanoWidthPixels";
-    public static final String CROPPED_AREA_FULL_PANO_HEIGHT_PIXELS =
-            "FullPanoHeightPixels";
-    public static final String CROPPED_AREA_LEFT =
-            "CroppedAreaLeftPixels";
-    public static final String CROPPED_AREA_TOP =
-            "CroppedAreaTopPixels";
-    public static final String GOOGLE_PANO_NAMESPACE = "http://ns.google.com/photos/1.0/panorama/";
-
-    private static final String TAG = "TinyPlanetActivity";
-    /** Delay between a value update and the renderer running. */
-    private static final int RENDER_DELAY_MILLIS = 50;
-    /** Filename prefix to prepend to the original name for the new file. */
-    private static final String FILENAME_PREFIX = "TINYPLANET_";
-
-    private Uri mSourceImageUri;
-    private TinyPlanetPreview mPreview;
-    private int mPreviewSizePx = 0;
-    private float mCurrentZoom = 0.5f;
-    private float mCurrentAngle = 0;
-    private ProgressDialog mDialog;
-
-    /**
-     * Lock for the result preview bitmap. We can't change it while we're trying
-     * to draw it.
-     */
-    private Lock mResultLock = new ReentrantLock();
-
-    /** The title of the original panoramic image. */
-    private String mOriginalTitle = "";
-
-    /** The padded source bitmap. */
-    private Bitmap mSourceBitmap;
-    /** The resulting preview bitmap. */
-    private Bitmap mResultBitmap;
-
-    /** Used to delay-post a tiny planet rendering task. */
-    private Handler mHandler = new Handler();
-    /** Whether rendering is in progress right now. */
-    private Boolean mRendering = false;
-    /**
-     * Whether we should render one more time after the current rendering run is
-     * done. This is needed when there was an update to the values during the
-     * current rendering.
-     */
-    private Boolean mRenderOneMore = false;
-
-    /** Tiny planet data plus size. */
-    private static final class TinyPlanetImage {
-        public final byte[] mJpegData;
-        public final int mSize;
-
-        public TinyPlanetImage(byte[] jpegData, int size) {
-            mJpegData = jpegData;
-            mSize = size;
-        }
-    }
-
-    /**
-     * Creates and executes a task to create a tiny planet with the current
-     * values.
-     */
-    private final Runnable mCreateTinyPlanetRunnable = new Runnable() {
-        @Override
-        public void run() {
-            synchronized (mRendering) {
-                if (mRendering) {
-                    mRenderOneMore = true;
-                    return;
-                }
-                mRendering = true;
-            }
-
-            (new AsyncTask<Void, Void, Void>() {
-                @Override
-                protected Void doInBackground(Void... params) {
-                    mResultLock.lock();
-                    try {
-                        if (mSourceBitmap == null || mResultBitmap == null) {
-                            return null;
-                        }
-
-                        int width = mSourceBitmap.getWidth();
-                        int height = mSourceBitmap.getHeight();
-                        TinyPlanetNative.process(mSourceBitmap, width, height, mResultBitmap,
-                                mPreviewSizePx,
-                                mCurrentZoom, mCurrentAngle);
-                    } finally {
-                        mResultLock.unlock();
-                    }
-                    return null;
-                }
-
-                protected void onPostExecute(Void result) {
-                    mPreview.setBitmap(mResultBitmap, mResultLock);
-                    synchronized (mRendering) {
-                        mRendering = false;
-                        if (mRenderOneMore) {
-                            mRenderOneMore = false;
-                            scheduleUpdate();
-                        }
-                    }
-                }
-            }).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
-        }
-    };
-
-    @Override
-    public void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        setStyle(DialogFragment.STYLE_NORMAL, R.style.Theme_Camera);
-    }
-
-    @Override
-    public View onCreateView(LayoutInflater inflater, ViewGroup container,
-            Bundle savedInstanceState) {
-        getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
-        getDialog().setCanceledOnTouchOutside(true);
-
-        View view = inflater.inflate(R.layout.tinyplanet_editor,
-                container, false);
-        mPreview = (TinyPlanetPreview) view.findViewById(R.id.preview);
-        mPreview.setPreviewSizeChangeListener(this);
-
-        // Zoom slider setup.
-        SeekBar zoomSlider = (SeekBar) view.findViewById(R.id.zoomSlider);
-        zoomSlider.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
-            @Override
-            public void onStopTrackingTouch(SeekBar seekBar) {
-                // Do nothing.
-            }
-
-            @Override
-            public void onStartTrackingTouch(SeekBar seekBar) {
-                // Do nothing.
-            }
-
-            @Override
-            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
-                onZoomChange(progress);
-            }
-        });
-
-        // Rotation slider setup.
-        SeekBar angleSlider = (SeekBar) view.findViewById(R.id.angleSlider);
-        angleSlider.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
-            @Override
-            public void onStopTrackingTouch(SeekBar seekBar) {
-                // Do nothing.
-            }
-
-            @Override
-            public void onStartTrackingTouch(SeekBar seekBar) {
-                // Do nothing.
-            }
-
-            @Override
-            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
-                onAngleChange(progress);
-            }
-        });
-
-        Button createButton = (Button) view.findViewById(R.id.creatTinyPlanetButton);
-        createButton.setOnClickListener(new OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                onCreateTinyPlanet();
-            }
-        });
-
-        mOriginalTitle = getArguments().getString(ARGUMENT_TITLE);
-        mSourceImageUri = Uri.parse(getArguments().getString(ARGUMENT_URI));
-        mSourceBitmap = createPaddedSourceImage(mSourceImageUri, true);
-
-        if (mSourceBitmap == null) {
-            Log.e(TAG, "Could not decode source image.");
-            dismiss();
-        }
-        return view;
-    }
-
-    /**
-     * From the given URI this method creates a 360/180 padded image that is
-     * ready to be made a tiny planet.
-     */
-    private Bitmap createPaddedSourceImage(Uri sourceImageUri, boolean previewSize) {
-        InputStream is = getInputStream(sourceImageUri);
-        if (is == null) {
-            Log.e(TAG, "Could not create input stream for image.");
-            dismiss();
-        }
-        Bitmap sourceBitmap = BitmapFactory.decodeStream(is);
-
-        is = getInputStream(sourceImageUri);
-        XMPMeta xmp = XmpUtil.extractXMPMeta(is);
-
-        if (xmp != null) {
-            int size = previewSize ? getDisplaySize() : sourceBitmap.getWidth();
-            sourceBitmap = createPaddedBitmap(sourceBitmap, xmp, size);
-        }
-        return sourceBitmap;
-    }
-
-    /**
-     * Starts an asynchronous task to create a tiny planet. Once done, will add
-     * the new image to the filmstrip and dismisses the fragment.
-     */
-    private void onCreateTinyPlanet() {
-        // Make sure we stop rendering before we create the high-res tiny
-        // planet.
-        synchronized (mRendering) {
-            mRenderOneMore = false;
-        }
-
-        final String savingTinyPlanet = getActivity().getResources().getString(
-                R.string.saving_tiny_planet);
-        (new AsyncTask<Void, Void, TinyPlanetImage>() {
-            @Override
-            protected void onPreExecute() {
-                mDialog = ProgressDialog.show(getActivity(), null, savingTinyPlanet, true, false);
-            }
-
-            @Override
-            protected TinyPlanetImage doInBackground(Void... params) {
-                return createTinyPlanet();
-            }
-
-            @Override
-            protected void onPostExecute(TinyPlanetImage image) {
-                // Once created, store the new file and add it to the filmstrip.
-                final CameraActivity activity = (CameraActivity) getActivity();
-                MediaSaveService mediaSaveService = activity.getMediaSaveService();
-                OnMediaSavedListener doneListener =
-                        new OnMediaSavedListener() {
-                            @Override
-                            public void onMediaSaved(Uri uri) {
-                                // Add the new photo to the filmstrip and exit
-                                // the fragment.
-                                activity.notifyNewMedia(uri);
-                                mDialog.dismiss();
-                                TinyPlanetFragment.this.dismiss();
-                            }
-                        };
-                String tinyPlanetTitle = FILENAME_PREFIX + mOriginalTitle;
-                mediaSaveService.addImage(image.mJpegData, tinyPlanetTitle, (new Date()).getTime(),
-                        null,
-                        image.mSize, image.mSize, 0, null, doneListener, getActivity()
-                                .getContentResolver(),PhotoModule.PIXEL_FORMAT_JPEG);
-            }
-        }).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
-    }
-
-    /**
-     * Creates the high quality tiny planet file and adds it to the media
-     * service. Don't call this on the UI thread.
-     */
-    private TinyPlanetImage createTinyPlanet() {
-        // Free some memory we don't need anymore as we're going to dimiss the
-        // fragment after the tiny planet creation.
-        mResultLock.lock();
-        try {
-            mResultBitmap.recycle();
-            mResultBitmap = null;
-            mSourceBitmap.recycle();
-            mSourceBitmap = null;
-        } finally {
-            mResultLock.unlock();
-        }
-
-        // Create a high-resolution padded image.
-        Bitmap sourceBitmap = createPaddedSourceImage(mSourceImageUri, false);
-        int width = sourceBitmap.getWidth();
-        int height = sourceBitmap.getHeight();
-
-        int outputSize = width / 2;
-        Bitmap resultBitmap = Bitmap.createBitmap(outputSize, outputSize,
-                Bitmap.Config.ARGB_8888);
-
-        TinyPlanetNative.process(sourceBitmap, width, height, resultBitmap,
-                outputSize, mCurrentZoom, mCurrentAngle);
-
-        // Free the sourceImage memory as we don't need it and we need memory
-        // for the JPEG bytes.
-        sourceBitmap.recycle();
-        sourceBitmap = null;
-
-        ByteArrayOutputStream jpeg = new ByteArrayOutputStream();
-        resultBitmap.compress(CompressFormat.JPEG, 100, jpeg);
-        return new TinyPlanetImage(addExif(jpeg.toByteArray()), outputSize);
-    }
-
-    /**
-     * Adds basic EXIF data to the tiny planet image so it an be rewritten
-     * later.
-     *
-     * @param jpeg the JPEG data of the tiny planet.
-     * @return The JPEG data containing basic EXIF.
-     */
-    private byte[] addExif(byte[] jpeg) {
-        ExifInterface exif = new ExifInterface();
-        exif.addDateTimeStampTag(ExifInterface.TAG_DATE_TIME, System.currentTimeMillis(),
-                TimeZone.getDefault());
-        ByteArrayOutputStream jpegOut = new ByteArrayOutputStream();
-        try {
-            exif.writeExif(jpeg, jpegOut);
-        } catch (IOException e) {
-            Log.e(TAG, "Could not write EXIF", e);
-        }
-        return jpegOut.toByteArray();
-    }
-
-    private int getDisplaySize() {
-        Display display = getActivity().getWindowManager().getDefaultDisplay();
-        Point size = new Point();
-        display.getSize(size);
-        return Math.min(size.x, size.y);
-    }
-
-    @Override
-    public void onSizeChanged(int sizePx) {
-        mPreviewSizePx = sizePx;
-        mResultLock.lock();
-        try {
-            if (mResultBitmap == null || mResultBitmap.getWidth() != sizePx
-                    || mResultBitmap.getHeight() != sizePx) {
-                if (mResultBitmap != null) {
-                    mResultBitmap.recycle();
-                }
-                mResultBitmap = Bitmap.createBitmap(mPreviewSizePx, mPreviewSizePx,
-                        Bitmap.Config.ARGB_8888);
-            }
-        } finally {
-            mResultLock.unlock();
-        }
-
-        // Run directly and on this thread directly.
-        mCreateTinyPlanetRunnable.run();
-    }
-
-    private void onZoomChange(int zoom) {
-        // 1000 needs to be in sync with the max values declared in the layout
-        // xml file.
-        mCurrentZoom = zoom / 1000f;
-        scheduleUpdate();
-    }
-
-    private void onAngleChange(int angle) {
-        mCurrentAngle = (float) Math.toRadians(angle);
-        scheduleUpdate();
-    }
-
-    /**
-     * Delay-post a new preview rendering run.
-     */
-    private void scheduleUpdate() {
-        mHandler.removeCallbacks(mCreateTinyPlanetRunnable);
-        mHandler.postDelayed(mCreateTinyPlanetRunnable, RENDER_DELAY_MILLIS);
-    }
-
-    private InputStream getInputStream(Uri uri) {
-        try {
-            return getActivity().getContentResolver().openInputStream(uri);
-        } catch (FileNotFoundException e) {
-            Log.e(TAG, "Could not load source image.", e);
-        }
-        return null;
-    }
-
-    /**
-     * To create a proper TinyPlanet, the input image must be 2:1 (360:180
-     * degrees). So if needed, we pad the source image with black.
-     */
-    private static Bitmap createPaddedBitmap(Bitmap bitmapIn, XMPMeta xmp, int intermediateWidth) {
-        try {
-            int croppedAreaWidth =
-                    getInt(xmp, CROPPED_AREA_IMAGE_WIDTH_PIXELS);
-            int croppedAreaHeight =
-                    getInt(xmp, CROPPED_AREA_IMAGE_HEIGHT_PIXELS);
-            int fullPanoWidth =
-                    getInt(xmp, CROPPED_AREA_FULL_PANO_WIDTH_PIXELS);
-            int fullPanoHeight =
-                    getInt(xmp, CROPPED_AREA_FULL_PANO_HEIGHT_PIXELS);
-            int left = getInt(xmp, CROPPED_AREA_LEFT);
-            int top = getInt(xmp, CROPPED_AREA_TOP);
-
-            if (fullPanoWidth == 0 || fullPanoHeight == 0) {
-                return bitmapIn;
-            }
-            // Make sure the intermediate image has the similar size to the
-            // input.
-            Bitmap paddedBitmap = null;
-            float scale = intermediateWidth / (float) fullPanoWidth;
-            while (paddedBitmap == null) {
-                try {
-                    paddedBitmap = Bitmap.createBitmap(
-                            (int) (fullPanoWidth * scale), (int) (fullPanoHeight * scale),
-                            Bitmap.Config.ARGB_8888);
-                } catch (OutOfMemoryError e) {
-                    System.gc();
-                    scale /= 2;
-                }
-            }
-            Canvas paddedCanvas = new Canvas(paddedBitmap);
-
-            int right = left + croppedAreaWidth;
-            int bottom = top + croppedAreaHeight;
-            RectF destRect = new RectF(left * scale, top * scale, right * scale, bottom * scale);
-            paddedCanvas.drawBitmap(bitmapIn, null, destRect, null);
-            return paddedBitmap;
-        } catch (XMPException ex) {
-            // Do nothing, just use mSourceBitmap as is.
-        }
-        return bitmapIn;
-    }
-
-    private static int getInt(XMPMeta xmp, String key) throws XMPException {
-        if (xmp.doesPropertyExist(GOOGLE_PANO_NAMESPACE, key)) {
-            return xmp.getPropertyInteger(GOOGLE_PANO_NAMESPACE, key);
-        } else {
-            return 0;
-        }
-    }
-}
diff --git a/src/com/android/camera/tinyplanet/TinyPlanetNative.java b/src/com/android/camera/tinyplanet/TinyPlanetNative.java
deleted file mode 100644
index 8f320a9..0000000
--- a/src/com/android/camera/tinyplanet/TinyPlanetNative.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.camera.tinyplanet;
-
-import android.graphics.Bitmap;
-
-/**
- * TinyPlanet native interface.
- */
-public class TinyPlanetNative {
-    static {
-        System.loadLibrary("jni_snaptinyplanet");
-    }
-
-    /**
-     * Create a tiny planet.
-     *
-     * @param in the 360 degree stereographically mapped panoramic input image.
-     * @param width the width of the input image.
-     * @param height the height of the input image.
-     * @param out the resulting tiny planet.
-     * @param outputSize the width and height of the square output image.
-     * @param scale the scale factor (used for fast previews).
-     * @param angleRadians the angle of the tiny planet in radians.
-     */
-    public static native void process(Bitmap in, int width, int height, Bitmap out, int outputSize,
-            float scale, float angleRadians);
-}
diff --git a/src/com/android/camera/tinyplanet/TinyPlanetPreview.java b/src/com/android/camera/tinyplanet/TinyPlanetPreview.java
deleted file mode 100644
index 153d266..0000000
--- a/src/com/android/camera/tinyplanet/TinyPlanetPreview.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.camera.tinyplanet;
-
-import android.content.Context;
-import android.graphics.Bitmap;
-import android.graphics.Canvas;
-import android.graphics.Paint;
-import android.util.AttributeSet;
-import android.view.View;
-
-import java.util.concurrent.locks.Lock;
-
-/**
- * Shows a preview of the TinyPlanet on the screen while editing.
- */
-public class TinyPlanetPreview extends View {
-    /**
-     * Classes implementing this interface get informed about changes to the
-     * preview size.
-     */
-    public static interface PreviewSizeListener {
-        /**
-         * Called when the preview size has changed.
-         *
-         * @param sizePx the size in pixels of the square preview area
-         */
-        public void onSizeChanged(int sizePx);
-    }
-
-    private Paint mPaint = new Paint();
-    private Bitmap mPreview;
-    private Lock mLock;
-    private PreviewSizeListener mPreviewSizeListener;
-    private int mSize = 0;
-
-    public TinyPlanetPreview(Context context) {
-        super(context);
-    }
-
-    public TinyPlanetPreview(Context context, AttributeSet attrs) {
-        super(context, attrs);
-    }
-
-    public TinyPlanetPreview(Context context, AttributeSet attrs, int defStyle) {
-        super(context, attrs, defStyle);
-    }
-
-    /**
-     * Sets the bitmap and waits for a draw to happen before returning.
-     */
-    public void setBitmap(Bitmap preview, Lock lock) {
-        mPreview = preview;
-        mLock = lock;
-        invalidate();
-    }
-
-    public void setPreviewSizeChangeListener(PreviewSizeListener listener) {
-        mPreviewSizeListener = listener;
-        if (mSize > 0) {
-            mPreviewSizeListener.onSizeChanged(mSize);
-        }
-    }
-
-    @Override
-    protected void onDraw(Canvas canvas) {
-        super.onDraw(canvas);
-        if (mLock != null && mLock.tryLock()) {
-            try {
-                if (mPreview != null && !mPreview.isRecycled()) {
-                    canvas.drawBitmap(mPreview, 0, 0, mPaint);
-                }
-            } finally {
-                mLock.unlock();
-            }
-        }
-    }
-
-    @Override
-    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
-        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
-
-        // Make sure the view is square
-        int size = Math.min(getMeasuredWidth(), getMeasuredHeight());
-        setMeasuredDimension(size, size);
-    }
-
-    @Override
-    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
-        super.onLayout(changed, left, top, right, bottom);
-        if (changed && mPreviewSizeListener != null) {
-            int width = right - left;
-            int height = bottom - top;
-
-            // These should be the same as we enforce a square layout, but let's
-            // be safe.
-            int mSize = Math.min(width, height);
-
-            // Tell the listener about our new size so the renderer can adapt.
-            if (mSize > 0 && mPreviewSizeListener != null) {
-                mPreviewSizeListener.onSizeChanged(mSize);
-            }
-        }
-    }
-}
diff --git a/src/com/android/camera/ui/FilmStripView.java b/src/com/android/camera/ui/FilmStripView.java
index 6a76786..7f46d79 100644
--- a/src/com/android/camera/ui/FilmStripView.java
+++ b/src/com/android/camera/ui/FilmStripView.java
@@ -42,12 +42,7 @@
 import com.android.camera.PreviewGestures;
 import com.android.camera.CameraActivity;
 import com.android.camera.data.LocalData;
-import com.android.camera.ui.FilmStripView.ImageData.PanoramaSupportCallback;
 import com.android.camera.ui.FilmstripBottomControls.BottomControlsListener;
-import com.android.camera.ui.RenderOverlay;
-import com.android.camera.util.CameraUtil;
-import com.android.camera.util.PhotoSphereHelper.PanoramaViewHelper;
-import com.android.camera.util.UsageStatistics;
 import org.codeaurora.snapcam.R;
 
 import java.util.Arrays;
@@ -91,7 +86,6 @@
     private TimeInterpolator mViewAnimInterpolator;
 
     private FilmstripBottomControls mBottomControls;
-    private PanoramaViewHelper mPanoramaViewHelper;
     private long mLastItemId = -1;
 
     // This is true if and only if the user is scrolling,
@@ -114,22 +108,6 @@
      */
     public interface ImageData {
 
-        /**
-         * Interface that is used to tell the caller whether an image is a photo
-         * sphere.
-         */
-        public static interface PanoramaSupportCallback {
-            /**
-             * Called then photo sphere info has been loaded.
-             *
-             * @param isPanorama whether the image is a valid photo sphere
-             * @param isPanorama360 whether the photo sphere is a full 360
-             *            degree horizontal panorama
-             */
-            void panoramaInfoAvailable(boolean isPanorama,
-                    boolean isPanorama360);
-        }
-
         // View types.
         public static final int VIEW_TYPE_NONE = 0;
         public static final int VIEW_TYPE_STICKY = 1;
@@ -216,18 +194,6 @@
          */
         public void recycle();
 
-        /**
-         * Asynchronously checks if the image is a photo sphere. Notified the
-         * callback when the results are available.
-         */
-        public void isPhotoSphere(Context context, PanoramaSupportCallback callback);
-
-        /**
-         * If the item is a valid photo sphere panorama, this method will launch
-         * the viewer.
-         */
-        public void viewPhotoSphere(PanoramaViewHelper helper);
-
         /** Whether this item is a photo. */
         public boolean isPhoto();
 
@@ -745,13 +711,6 @@
     }
 
     /**
-     * Sets the helper that's to be used to open photo sphere panoramas.
-     */
-    public void setPanoramaViewHelper(PanoramaViewHelper helper) {
-        mPanoramaViewHelper = helper;
-    }
-
-    /**
      * Checks if the data is at the center.
      *
      * @param id The id of the data to check.
@@ -1050,18 +1009,6 @@
         bringChildToFront(mZoomView);
     }
 
-    /**
-     * If the current photo is a photo sphere, this will launch the Photo Sphere
-     * panorama viewer.
-     */
-    @Override
-    public void onViewPhotoSphere() {
-        ViewItem curr = mViewItem[mCurrentItem];
-        if (curr != null) {
-            mDataAdapter.getImageData(curr.getId()).viewPhotoSphere(mPanoramaViewHelper);
-        }
-    }
-
     @Override
     public void onEdit() {
         ImageData data = mDataAdapter.getImageData(getCurrentId());
@@ -1071,15 +1018,6 @@
         mActivity.launchEditor((LocalData) data);
     }
 
-    @Override
-    public void onTinyPlanet() {
-        ImageData data = mDataAdapter.getImageData(getCurrentId());
-        if (data == null || !(data instanceof LocalData)) {
-            return;
-        }
-        mActivity.launchTinyPlanetEditor((LocalData) data);
-    }
-
     /**
      * @return The ID of the current item, or -1.
      */
@@ -1131,32 +1069,6 @@
 
         // We can only edit photos, not videos.
         mBottomControls.setEditButtonVisibility(data.isPhoto());
-
-        // If this is a photo sphere, show the button to view it. If it's a full
-        // 360 photo sphere, show the tiny planet button.
-        if (data.getViewType() == ImageData.VIEW_TYPE_STICKY) {
-            // This is a workaround to prevent an unnecessary update of
-            // PhotoSphere metadata which fires a data focus change callback
-            // at a weird timing.
-            return;
-        }
-        // TODO: Remove this from FilmstripView as it breaks the design.
-        data.isPhotoSphere(mActivity, new PanoramaSupportCallback() {
-            @Override
-            public void panoramaInfoAvailable(final boolean isPanorama,
-                    boolean isPanorama360) {
-                // Make sure the returned data is for the current image.
-                if (requestId == getCurrentId()) {
-                    if (mListener != null) {
-                        // TODO: Remove this hack since there is no data focus
-                        // change actually.
-                        mListener.onDataFocusChanged(requestId, true);
-                    }
-                    mBottomControls.setViewPhotoSphereButtonVisibility(isPanorama);
-                    mBottomControls.setTinyPlanetButtonVisibility(isPanorama360);
-                }
-            }
-        });
     }
 
     /**
diff --git a/src/com/android/camera/ui/FilmstripBottomControls.java b/src/com/android/camera/ui/FilmstripBottomControls.java
index 521fd50..960bb42 100644
--- a/src/com/android/camera/ui/FilmstripBottomControls.java
+++ b/src/com/android/camera/ui/FilmstripBottomControls.java
@@ -37,26 +37,15 @@
      * controls.
      */
     public static interface BottomControlsListener {
-        /**
-         * Called when the user pressed the "view photosphere" button.
-         */
-        public void onViewPhotoSphere();
 
         /**
          * Called when the user pressed the "edit" button.
          */
         public void onEdit();
-
-        /**
-         * Called when the user pressed the "tiny planet" button.
-         */
-        public void onTinyPlanet();
     }
 
     private BottomControlsListener mListener;
     private ImageButton mEditButton;
-    private ImageButton mViewPhotoSphereButton;
-    private ImageButton mTinyPlanetButton;
 
     public FilmstripBottomControls(Context context, AttributeSet attrs) {
         super(context, attrs);
@@ -65,36 +54,10 @@
     @Override
     protected void onFinishInflate() {
         super.onFinishInflate();
-        mEditButton = (ImageButton)
-                findViewById(R.id.filmstrip_bottom_control_edit);
-        mEditButton.setOnClickListener(new OnClickListener() {
-            @Override
-            public void onClick(View view) {
-                if (mListener != null) {
-                    mListener.onEdit();
-                }
-            }
-        });
-
-        mViewPhotoSphereButton = (ImageButton)
-                findViewById(R.id.filmstrip_bottom_control_panorama);
-        mViewPhotoSphereButton.setOnClickListener(new OnClickListener() {
-            @Override
-            public void onClick(View view) {
-                if (mListener != null) {
-                    mListener.onViewPhotoSphere();
-                }
-            }
-        });
-
-        mTinyPlanetButton = (ImageButton)
-                findViewById(R.id.filmstrip_bottom_control_tiny_planet);
-        mTinyPlanetButton.setOnClickListener(new OnClickListener() {
-            @Override
-            public void onClick(View view) {
-                if (mListener != null) {
-                    mListener.onTinyPlanet();
-                }
+        mEditButton = findViewById(R.id.filmstrip_bottom_control_edit);
+        mEditButton.setOnClickListener(view -> {
+            if (mListener != null) {
+                mListener.onEdit();
             }
         });
     }
@@ -114,30 +77,10 @@
     }
 
     /**
-     * Sets the visibility of the view-photosphere button.
-     */
-    public void setViewPhotoSphereButtonVisibility(boolean visible) {
-        setVisibility(mViewPhotoSphereButton, visible);
-    }
-
-    /**
-     * Sets the visibility of the tiny-planet button.
-     */
-    public void setTinyPlanetButtonVisibility(final boolean visible) {
-        setVisibility(mTinyPlanetButton, visible);
-    }
-
-    /**
      * Sets the visibility of the given view.
      */
     private static void setVisibility(final View view, final boolean visible) {
-        view.post(new Runnable() {
-            @Override
-            public void run() {
-                view.setVisibility(visible ? View.VISIBLE
-                        : View.INVISIBLE);
-            }
-        });
+        view.post(() -> view.setVisibility(visible ? View.VISIBLE : View.INVISIBLE));
     }
 
     @Override
diff --git a/src/com/android/camera/ui/ModuleSwitcher.java b/src/com/android/camera/ui/ModuleSwitcher.java
index 058e64d..ae061d5 100644
--- a/src/com/android/camera/ui/ModuleSwitcher.java
+++ b/src/com/android/camera/ui/ModuleSwitcher.java
@@ -28,7 +28,6 @@
 import android.view.LayoutInflater;
 import android.view.MotionEvent;
 import android.view.View;
-import android.view.View.OnClickListener;
 import android.view.View.OnTouchListener;
 import android.view.ViewGroup;
 import android.widget.FrameLayout.LayoutParams;
@@ -36,8 +35,6 @@
 import android.widget.ImageView;
 
 import com.android.camera.util.CameraUtil;
-import com.android.camera.util.GcamHelper;
-import com.android.camera.util.PhotoSphereHelper;
 import com.android.camera.util.UsageStatistics;
 import org.codeaurora.snapcam.R;
 
@@ -111,7 +108,7 @@
     public void initializeDrawables(Context context) {
         int numDrawIds = DRAW_IDS.length;
 
-        if (!PhotoSphereHelper.hasLightCycleCapture(context)) {
+        if (true /*!PhotoSphereHelper.hasLightCycleCapture(context)*/) {
             --numDrawIds;
         }
 
@@ -122,7 +119,7 @@
         int[] moduleids = new int[numDrawIds];
         int ix = 0;
         for (int i = 0; i < DRAW_IDS.length; i++) {
-            if (i == LIGHTCYCLE_MODULE_INDEX && !PhotoSphereHelper.hasLightCycleCapture(context)) {
+            if (i == LIGHTCYCLE_MODULE_INDEX) {
                 continue; // not enabled, so don't add to UI
             }
             if (i == GCAM_MODULE_INDEX) {
diff --git a/src_pd/com/android/camera/app/PanoramaStitchingManager.java b/src_pd/com/android/camera/app/PanoramaStitchingManager.java
deleted file mode 100644
index 9d6e796..0000000
--- a/src_pd/com/android/camera/app/PanoramaStitchingManager.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.camera.app;
-
-import android.content.Context;
-import android.net.Uri;
-
-import com.android.camera.ImageTaskManager;
-
-public class PanoramaStitchingManager implements ImageTaskManager {
-
-    public PanoramaStitchingManager(Context ctx) {
-    }
-
-    @Override
-    public void addTaskListener(TaskListener l) {
-        // do nothing.
-    }
-
-    @Override
-    public void removeTaskListener(TaskListener l) {
-        // do nothing.
-    }
-
-    @Override
-    public int getTaskProgress(Uri uri) {
-        return -1;
-    }
-}
diff --git a/src_pd/com/android/camera/util/HelpUtils.java b/src_pd/com/android/camera/util/HelpUtils.java
deleted file mode 100644
index 2ed3dca..0000000
--- a/src_pd/com/android/camera/util/HelpUtils.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.camera.util;
-
-import android.content.Context;
-import android.content.Intent;
-
-public class HelpUtils {
-
-    public static Intent getHelpIntent(Context context) {
-		return null;
-	}
-
-}
diff --git a/src_pd/com/android/camera/util/PhotoSphereHelper.java b/src_pd/com/android/camera/util/PhotoSphereHelper.java
deleted file mode 100644
index c537910..0000000
--- a/src_pd/com/android/camera/util/PhotoSphereHelper.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.camera.util;
-
-import android.app.Activity;
-import android.content.ContentResolver;
-import android.content.Context;
-import android.net.Uri;
-
-import com.android.camera.CameraModule;
-
-public class PhotoSphereHelper {
-    public static class PanoramaMetadata {
-        // Whether a panorama viewer should be used
-        public final boolean mUsePanoramaViewer;
-        // Whether a panorama is 360 degrees
-        public final boolean mIsPanorama360;
-
-        public PanoramaMetadata(boolean usePanoramaViewer, boolean isPanorama360) {
-            mUsePanoramaViewer = usePanoramaViewer;
-            mIsPanorama360 = isPanorama360;
-        }
-    }
-
-    public static class PanoramaViewHelper {
-
-        public PanoramaViewHelper(Activity activity) {
-            /* Do nothing */
-        }
-
-        public void onStart() {
-            /* Do nothing */
-        }
-
-        public void onCreate() {
-            /* Do nothing */
-        }
-
-        public void onStop() {
-            /* Do nothing */
-        }
-
-        public void showPanorama(Uri uri) {
-            /* Do nothing */
-        }
-    }
-
-    public static final PanoramaMetadata NOT_PANORAMA = new PanoramaMetadata(false, false);
-
-    public static boolean hasLightCycleCapture(Context context) {
-        return false;
-    }
-
-    public static PanoramaMetadata getPanoramaMetadata(Context context, Uri uri) {
-        return NOT_PANORAMA;
-    }
-
-    public static CameraModule createPanoramaModule() {
-        return null;
-    }
-
-    /**
-     * Get the file path from a Media storage URI.
-     */
-    public static String getPathFromURI(ContentResolver contentResolver, Uri contentUri) {
-        return null;
-    }
-
-    /**
-     * Get the modified time from a Media storage URI.
-     */
-    public static long getModifiedTimeFromURI(ContentResolver contentResolver, Uri contentUri) {
-        return 0;
-    }
-}