Fix AND-449

This commit is contained in:
Alexey Kulish 2016-04-11 10:35:07 +03:00
parent 8f1b872c58
commit a2214426df
6 changed files with 143 additions and 9 deletions

View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="270"
android:toDegrees="270">
<shape
android:shape="ring"
android:innerRadius="22dp"
android:thickness="2dp"
android:useLevel="true"> <!-- Just add this line -->
<solid android:color="#ffffff"/>
</shape>
</rotate>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="270"
android:toDegrees="270">
<shape
android:shape="ring"
android:innerRadius="22dp"
android:thickness="2dp">
<solid android:color="#ffffff"/>
</shape>
</rotate>

View file

@ -21,6 +21,13 @@
</LinearLayout> </LinearLayout>
<ImageView
android:id="@+id/imageview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitCenter"
android:visibility="gone"/>
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -80,14 +87,29 @@
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:gravity="center"> android:gravity="center">
<ImageView <FrameLayout
android:id="@+id/centerButtonIcon"
android:layout_width="48dp" android:layout_width="48dp"
android:layout_height="48dp" android:layout_height="48dp"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical">
android:background="@drawable/orange_circle_background_style"
android:scaleType="center" <ImageView
android:src="@drawable/ic_action_done"/> android:id="@+id/centerButtonIcon"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/orange_circle_background_style"
android:scaleType="center"
android:src="@drawable/ic_action_done"/>
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:max="500"
android:progress="0"
android:progressDrawable="@drawable/progress_photo_circular"/>
</FrameLayout>
<TextView <TextView
android:id="@+id/centerButtonText" android:id="@+id/centerButtonText"

View file

@ -325,4 +325,11 @@ public class AudioVideoNoteRecordingMenu {
recTimer = null; recTimer = null;
} }
} }
public void showFinalPhoto(final byte[] data, long duration) {
}
public void hideFinalPhoto() {
}
} }

View file

@ -1,7 +1,18 @@
package net.osmand.plus.audionotes; package net.osmand.plus.audionotes;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.support.v4.animation.AnimatorCompatHelper;
import android.support.v4.animation.AnimatorUpdateListenerCompat;
import android.support.v4.animation.ValueAnimatorCompat;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.view.ViewCompat;
import android.util.DisplayMetrics;
import android.view.View; import android.view.View;
import android.view.animation.Interpolator;
import android.view.animation.LinearInterpolator;
import android.widget.ImageView;
import android.widget.ProgressBar;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
@ -10,8 +21,14 @@ import java.lang.ref.WeakReference;
public class AudioVideoNoteRecordingMenuFullScreen extends AudioVideoNoteRecordingMenu { public class AudioVideoNoteRecordingMenuFullScreen extends AudioVideoNoteRecordingMenu {
protected ImageView imageview;
protected ProgressBar progressBar;
protected ValueAnimatorCompat animatorCompat;
public AudioVideoNoteRecordingMenuFullScreen(AudioVideoNotesPlugin plugin, double lat, double lon) { public AudioVideoNoteRecordingMenuFullScreen(AudioVideoNotesPlugin plugin, double lat, double lon) {
super(plugin, lat, lon); super(plugin, lat, lon);
imageview = (ImageView) view.findViewById(R.id.imageview);
progressBar = (ProgressBar) view.findViewById(R.id.progressBar);
} }
protected void initView(MapActivity mapActivity) { protected void initView(MapActivity mapActivity) {
@ -28,12 +45,15 @@ public class AudioVideoNoteRecordingMenuFullScreen extends AudioVideoNoteRecordi
@Override @Override
protected void applyViewfinderVisibility() { protected void applyViewfinderVisibility() {
imageview.setVisibility(View.GONE);
progressBar.setVisibility(View.INVISIBLE);
} }
public void show() { public void show() {
} }
public void hide() { public void hide() {
stopProgress();
plugin.stopCamera(); plugin.stopCamera();
WeakReference<AudioVideoNoteRecordingMenuFullScreenFragment> fragmentRef = findMenuFragment(); WeakReference<AudioVideoNoteRecordingMenuFullScreenFragment> fragmentRef = findMenuFragment();
if (fragmentRef != null) { if (fragmentRef != null) {
@ -54,6 +74,7 @@ public class AudioVideoNoteRecordingMenuFullScreen extends AudioVideoNoteRecordi
centerButtonView.setOnClickListener(new View.OnClickListener() { centerButtonView.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
stopProgress();
finishRecording(); finishRecording();
} }
}); });
@ -82,4 +103,58 @@ public class AudioVideoNoteRecordingMenuFullScreen extends AudioVideoNoteRecordi
} }
return null; 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);
}
} }

View file

@ -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_INFINITY = 3;
public static final int AV_CAMERA_FOCUS_MACRO = 4; public static final int AV_CAMERA_FOCUS_MACRO = 4;
public static final int AV_CAMERA_FOCUS_CONTINUOUS = 5; public static final int AV_CAMERA_FOCUS_CONTINUOUS = 5;
// shoto shot: // photo shot:
private static int shotId = 0; private static int shotId = 0;
private SoundPool sp = null; private SoundPool sp = null;
public static final int FULL_SCEEN_RESULT_DELAY_MS = 5000;
public final CommonPreference<Integer> AV_CAMERA_PICTURE_SIZE; public final CommonPreference<Integer> AV_CAMERA_PICTURE_SIZE;
public final CommonPreference<Integer> AV_CAMERA_FOCUS_TYPE; public final CommonPreference<Integer> 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(); startPhotoTimer();
} }
} }
@ -1923,7 +1927,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
public void run() { public void run() {
finishPhotoRecording(false); finishPhotoRecording(false);
} }
}, 4000); }, FULL_SCEEN_RESULT_DELAY_MS);
} }
private void cancelPhotoTimer() { private void cancelPhotoTimer() {
@ -1940,6 +1944,9 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
try { try {
cam.cancelAutoFocus(); cam.cancelAutoFocus();
cam.stopPreview(); cam.stopPreview();
if (recordingMenu != null) {
recordingMenu.hideFinalPhoto();
}
cam.startPreview(); cam.startPreview();
internalShoot(); internalShoot();