summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/CameraActivity.java
diff options
context:
space:
mode:
authorSteve Kondik <steve@cyngn.com>2016-11-07 16:50:48 -0800
committerMichael Bestas <mikeioannina@gmail.com>2017-01-04 22:00:39 +0200
commitd6162483d308b8d796d8fcec975437376c3bb868 (patch)
treea59496db1af01971f83b66e98659a5027c555162 /src/com/android/camera/CameraActivity.java
parentd1351bbb3e79ebbfe82e9e596ab76cf839a5fd1b (diff)
downloadandroid_packages_apps_Snap-d6162483d308b8d796d8fcec975437376c3bb868.tar.gz
android_packages_apps_Snap-d6162483d308b8d796d8fcec975437376c3bb868.tar.bz2
android_packages_apps_Snap-d6162483d308b8d796d8fcec975437376c3bb868.zip
Reenable left swipe for Filmstrip
* These commits are from the CameraNext application in COS. * Credits: Ed Carrigan, Ed Mancebo, Wilhelm Fitzpatrick Revert "SnapdragonCamera: Fix preview broken when coming back from gallery" This reverts commit 5b8948f83a65e8f9bd1b419bd11511e48dc34887. Revert "SnapdragonCamera: fix crash after photo deletion" This reverts commit 171d2b253a752ca104ccf4a58f4e9d6d82bd7b28. CameraNext: Fix camera crash on device unlock This patch from the plugin branch also fixes CYNGNOS-1878 Due to the bug below, when the camera is fore-grounded when device is unlocked, the SurfaceView is getting recreated, which caused it to be in a weird state when we were trying to reattach the preview to it. ----- Fixed Black Screen On Back. The issue was that mCameraView was not being populated when it should have been (after it had been added to the view hierarchy). The problem was the SurfaceView was being removed from the hierarchy when it shouldn't have been. Issue-Id: CP-129 (cherry picked from commit 4010462fe0b4cf1c15624cfca7d6a3d4d380613a) CameraNext: avoid scaling camera preview in filmstrip (cherry picked from commit 823ed983c4dccac3959635f1a14fcfe47cd7b120) CameraNext: fade camera preview to black during film strip transition Instead of scaling and translating the camera preview to make room for film strip images, we leave the preview in place and cover it gradually with the black preview cover. CameraNext : Add offset calculation for left navbar Also prevent preview from translating while hidden - was causing occasional glimpses of it in filmstrip. CameraNext : Ensure vertical/horizontal swipes don't conflict Ensure that the user can't swipe horizontally while trying to delete the image. Avoids all sorts of synching issues between mViewItem and the data adapter since the buffer is trying to constantly keep its center to be the current visible item CYNGNOS-1069 CameraNext: fix crash on entering filmstrip via thumbnail tap mVerticalViewId was getting initialized in onUp, but if filmstrip was entered without a swipe, no onUp occurred. Fixed by directly initializing the field on object creation. CameraNext: Fix ZoomView in the filmstrip The ZoomView was getting covered in the Z axis while scrolling. issue-id: SAMBAR-862 Revert "SnapdragonCamera: fix camera preview broken when resume from gallery" This reverts commit 0acc1f027637c4f0126883be68f97817d7306032. Change-Id: If4dd591c5c752a7fa33c669c15875c0077446a37
Diffstat (limited to 'src/com/android/camera/CameraActivity.java')
-rw-r--r--[-rwxr-xr-x]src/com/android/camera/CameraActivity.java73
1 files changed, 31 insertions, 42 deletions
diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java
index f7aa35a43..6b1d8d13f 100755..100644
--- a/src/com/android/camera/CameraActivity.java
+++ b/src/com/android/camera/CameraActivity.java
@@ -53,6 +53,7 @@ import android.graphics.RectF;
import android.graphics.Shader;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
+import android.graphics.Point;
import android.net.Uri;
import android.media.ThumbnailUtils;
import android.nfc.NfcAdapter;
@@ -228,8 +229,6 @@ public class CameraActivity extends Activity
private ViewGroup mUndoDeletionBar;
private boolean mIsUndoingDeletion = false;
private boolean mIsEditActivityInProgress = false;
- private View mPreviewCover;
- private FrameLayout mPreviewContentLayout;
private boolean mPaused = true;
private boolean mHasCriticalPermissions;
private boolean mForceReleaseCamera = false;
@@ -263,6 +262,7 @@ public class CameraActivity extends Activity
private WakeLock mWakeLock;
private static final int REFOCUS_ACTIVITY_CODE = 1;
+ private int mDisplayWidth;
private class MyOrientationEventListener
extends OrientationEventListener {
@@ -473,7 +473,6 @@ public class CameraActivity extends Activity
if(!arePreviewControlsVisible()) {
setPreviewControlsVisibility(true);
CameraActivity.this.setSystemBarsVisibility(false);
- mFilmStripView.getController().goToFullScreen();
}
}
@@ -577,6 +576,25 @@ public class CameraActivity extends Activity
public void setSystemDecorsVisibility(boolean visible) {
CameraActivity.this.setSystemBarsVisibility(visible);
}
+
+ private boolean stripHasScrolled = false;
+
+ @Override
+ public void onFilmStripScroll(int offset) {
+ if (offset == 0) {
+ if (stripHasScrolled) {
+ mCurrentModule.hidePreviewCover();
+ mCurrentModule.setPreviewCoverAlpha(1.0f);
+ }
+ } else {
+ // preview cover becomes fully opaque when the film strip has
+ // scrolled half the width of the screen
+ float rangePx = mDisplayWidth / 2f;
+ mCurrentModule.setPreviewCoverAlpha((float)Math.min(1.0, offset/rangePx));
+ mCurrentModule.showPreviewCover();
+ stripHasScrolled = true;
+ }
+ }
};
public void gotoGallery() {
@@ -604,45 +622,7 @@ public class CameraActivity extends Activity
return;
}
}
- try {
- Intent intent = IntentHelper.getGalleryIntent(this);
- intent.setAction(Intent.ACTION_VIEW);
- intent.setData(uri);
- intent.putExtra(KEY_FROM_SNAPCAM, true);
- intent.putExtra(KEY_TOTAL_NUMBER, (adapter.getTotalNumber() -1));
- startActivity(intent);
- } catch (ActivityNotFoundException ex) {
- gotoReviewPhoto(uri);
- } catch (IllegalArgumentException ex) {
- gotoReviewPhoto(uri);
- }
- }
-
- private void gotoReviewPhoto(Uri uri) {
- try {
- Log.w(TAG, "Gallery not found");
- Intent intent = new Intent(CameraUtil.REVIEW_ACTION, uri);
- startActivity(intent);
- intent.putExtra(KEY_FROM_SNAPCAM, true);
- intent.putExtra(KEY_TOTAL_NUMBER, getDataAdapter().getTotalNumber() - 1);
- } catch (ActivityNotFoundException e) {
- gotoViewPhoto(uri);
- } catch (IllegalArgumentException e) {
- gotoViewPhoto(uri);
- }
- }
-
- private void gotoViewPhoto(Uri uri) {
- try {
- Log.w(TAG, "Gallery not found");
- Intent intent = new Intent(Intent.ACTION_VIEW, uri);
- startActivity(intent);
- intent.putExtra(KEY_FROM_SNAPCAM, true);
- } catch (ActivityNotFoundException e) {
- Log.w(TAG, "No Activity could be found to open image or video");
- } catch (IllegalArgumentException e) {
- Log.w(TAG, "No Activity could be found to open image or video");
- }
+ mFilmStripView.getController().goToNextItem();
}
/**
@@ -1496,6 +1476,8 @@ public class CameraActivity extends Activity
mCameraPanoModuleRootView = rootLayout.findViewById(R.id.camera_pano_root);
mCameraCaptureModuleRootView = rootLayout.findViewById(R.id.camera_capture_root);
+ calculateDisplayWidth();
+
int moduleIndex = -1;
if (MediaStore.INTENT_ACTION_VIDEO_CAMERA.equals(getIntent().getAction())
|| MediaStore.ACTION_VIDEO_CAPTURE.equals(getIntent().getAction())) {
@@ -1844,6 +1826,7 @@ public class CameraActivity extends Activity
public void onConfigurationChanged(Configuration config) {
super.onConfigurationChanged(config);
mCurrentModule.onConfigurationChanged(config);
+ calculateDisplayWidth();
}
@Override
@@ -2083,6 +2066,12 @@ public class CameraActivity extends Activity
prefs.edit().putInt(CameraSettings.KEY_STARTUP_MODULE_INDEX, moduleIndex).apply();
}
+ private void calculateDisplayWidth() {
+ Point size = new Point();
+ getWindowManager().getDefaultDisplay().getSize(size);
+ mDisplayWidth = size.x;
+ }
+
/**
* Sets the mCurrentModuleIndex, creates a new module instance for the given
* index an sets it as mCurrentModule.