Fix AND-449
This commit is contained in:
parent
8f1b872c58
commit
a2214426df
6 changed files with 143 additions and 9 deletions
12
OsmAnd/res/drawable-v21/progress_photo_circular.xml
Normal file
12
OsmAnd/res/drawable-v21/progress_photo_circular.xml
Normal 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>
|
11
OsmAnd/res/drawable/progress_photo_circular.xml
Normal file
11
OsmAnd/res/drawable/progress_photo_circular.xml
Normal 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>
|
|
@ -21,6 +21,13 @@
|
|||
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="fitCenter"
|
||||
android:visibility="gone"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
|
@ -80,14 +87,29 @@
|
|||
android:layout_gravity="center_vertical"
|
||||
android:gravity="center">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/centerButtonIcon"
|
||||
<FrameLayout
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:background="@drawable/orange_circle_background_style"
|
||||
android:scaleType="center"
|
||||
android:src="@drawable/ic_action_done"/>
|
||||
android:layout_gravity="center_vertical">
|
||||
|
||||
<ImageView
|
||||
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
|
||||
android:id="@+id/centerButtonText"
|
||||
|
|
|
@ -325,4 +325,11 @@ public class AudioVideoNoteRecordingMenu {
|
|||
recTimer = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void showFinalPhoto(final byte[] data, long duration) {
|
||||
}
|
||||
|
||||
public void hideFinalPhoto() {
|
||||
}
|
||||
|
||||
}
|
|
@ -1,7 +1,18 @@
|
|||
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.view.ViewCompat;
|
||||
import android.util.DisplayMetrics;
|
||||
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.activities.MapActivity;
|
||||
|
@ -10,8 +21,14 @@ import java.lang.ref.WeakReference;
|
|||
|
||||
public class AudioVideoNoteRecordingMenuFullScreen extends AudioVideoNoteRecordingMenu {
|
||||
|
||||
protected ImageView imageview;
|
||||
protected ProgressBar progressBar;
|
||||
protected ValueAnimatorCompat animatorCompat;
|
||||
|
||||
public AudioVideoNoteRecordingMenuFullScreen(AudioVideoNotesPlugin plugin, double lat, double lon) {
|
||||
super(plugin, lat, lon);
|
||||
imageview = (ImageView) view.findViewById(R.id.imageview);
|
||||
progressBar = (ProgressBar) view.findViewById(R.id.progressBar);
|
||||
}
|
||||
|
||||
protected void initView(MapActivity mapActivity) {
|
||||
|
@ -28,12 +45,15 @@ public class AudioVideoNoteRecordingMenuFullScreen extends AudioVideoNoteRecordi
|
|||
|
||||
@Override
|
||||
protected void applyViewfinderVisibility() {
|
||||
imageview.setVisibility(View.GONE);
|
||||
progressBar.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
public void show() {
|
||||
}
|
||||
|
||||
public void hide() {
|
||||
stopProgress();
|
||||
plugin.stopCamera();
|
||||
WeakReference<AudioVideoNoteRecordingMenuFullScreenFragment> 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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<Integer> AV_CAMERA_PICTURE_SIZE;
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
|
||||
|
|
Loading…
Reference in a new issue