From a2214426dfa134ce8ef988cb0ba45ce1cb007e27 Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Mon, 11 Apr 2016 10:35:07 +0300 Subject: [PATCH] Fix AND-449 --- .../drawable-v21/progress_photo_circular.xml | 12 +++ .../res/drawable/progress_photo_circular.xml | 11 +++ .../recording_note_fragment_fullscreen.xml | 34 +++++++-- .../AudioVideoNoteRecordingMenu.java | 9 ++- ...AudioVideoNoteRecordingMenuFullScreen.java | 75 +++++++++++++++++++ .../audionotes/AudioVideoNotesPlugin.java | 11 ++- 6 files changed, 143 insertions(+), 9 deletions(-) create mode 100644 OsmAnd/res/drawable-v21/progress_photo_circular.xml create mode 100644 OsmAnd/res/drawable/progress_photo_circular.xml diff --git a/OsmAnd/res/drawable-v21/progress_photo_circular.xml b/OsmAnd/res/drawable-v21/progress_photo_circular.xml new file mode 100644 index 0000000000..04165bdc0f --- /dev/null +++ b/OsmAnd/res/drawable-v21/progress_photo_circular.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/drawable/progress_photo_circular.xml b/OsmAnd/res/drawable/progress_photo_circular.xml new file mode 100644 index 0000000000..7e0a4cb693 --- /dev/null +++ b/OsmAnd/res/drawable/progress_photo_circular.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/layout/recording_note_fragment_fullscreen.xml b/OsmAnd/res/layout/recording_note_fragment_fullscreen.xml index 05c5be3d9f..9098c51b4f 100644 --- a/OsmAnd/res/layout/recording_note_fragment_fullscreen.xml +++ b/OsmAnd/res/layout/recording_note_fragment_fullscreen.xml @@ -21,6 +21,13 @@ + + - + android:layout_gravity="center_vertical"> + + + + + + fragmentRef = findMenuFragment(); if (fragmentRef != null) { @@ -54,6 +74,7 @@ public class AudioVideoNoteRecordingMenuFullScreen extends AudioVideoNoteRecordi centerButtonView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { + stopProgress(); finishRecording(); } }); @@ -82,4 +103,58 @@ public class AudioVideoNoteRecordingMenuFullScreen extends AudioVideoNoteRecordi } return null; } + + public void showFinalPhoto(final byte[] data, long duration) { + setImage(data); + imageview.setVisibility(View.VISIBLE); + viewfinder.setVisibility(View.GONE); + + startProgress(duration); + } + + public void hideFinalPhoto() { + stopProgress(); + + AudioVideoNotesPlugin.CurrentRecording recording = plugin.getCurrentRecording(); + boolean show = showViewfinder && recording != null && recording.getType() != AudioVideoNotesPlugin.AVActionType.REC_AUDIO; + imageview.setVisibility(View.GONE); + progressBar.setVisibility(View.INVISIBLE); + viewfinder.setVisibility(show ? View.VISIBLE : View.GONE); + } + + private void startProgress(long duration) { + stopProgress(); + + progressBar.setProgress(0); + ViewCompat.setAlpha(progressBar, 1f); + progressBar.setVisibility(View.VISIBLE); + + animatorCompat = AnimatorCompatHelper.emptyValueAnimator(); + final Interpolator interpolator = new LinearInterpolator(); + animatorCompat.setDuration(duration); + animatorCompat.setTarget(progressBar); + animatorCompat.addUpdateListener(new AnimatorUpdateListenerCompat() { + @Override + public void onAnimationUpdate(ValueAnimatorCompat animation) { + float fraction = interpolator.getInterpolation(animation.getAnimatedFraction()); + progressBar.setProgress((int)(500 * fraction)); + } + }); + animatorCompat.start(); + } + + private void stopProgress() { + if (animatorCompat != null) + animatorCompat.cancel(); + } + + private void setImage(final byte[] data) { + Bitmap bm = BitmapFactory.decodeByteArray(data, 0, data.length); + DisplayMetrics dm = new DisplayMetrics(); + getMapActivity().getWindowManager().getDefaultDisplay().getMetrics(dm); + + //imageview.setMinimumHeight(dm.heightPixels); + //imageview.setMinimumWidth(dm.widthPixels); + imageview.setImageBitmap(bm); + } } diff --git a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java index c677a60fc2..16a2c7feb1 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java @@ -137,9 +137,10 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { public static final int AV_CAMERA_FOCUS_INFINITY = 3; public static final int AV_CAMERA_FOCUS_MACRO = 4; public static final int AV_CAMERA_FOCUS_CONTINUOUS = 5; - // shoto shot: + // photo shot: private static int shotId = 0; private SoundPool sp = null; + public static final int FULL_SCEEN_RESULT_DELAY_MS = 5000; public final CommonPreference AV_CAMERA_PICTURE_SIZE; public final CommonPreference AV_CAMERA_FOCUS_TYPE; @@ -1909,6 +1910,9 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { } } + if (recordingMenu != null) { + recordingMenu.showFinalPhoto(data, FULL_SCEEN_RESULT_DELAY_MS); + } startPhotoTimer(); } } @@ -1923,7 +1927,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { public void run() { finishPhotoRecording(false); } - }, 4000); + }, FULL_SCEEN_RESULT_DELAY_MS); } private void cancelPhotoTimer() { @@ -1940,6 +1944,9 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { try { cam.cancelAutoFocus(); cam.stopPreview(); + if (recordingMenu != null) { + recordingMenu.hideFinalPhoto(); + } cam.startPreview(); internalShoot();