Search in sources :

Example 1 with CurrentRecording

use of net.osmand.plus.audionotes.AudioVideoNotesPlugin.CurrentRecording in project Osmand by osmandapp.

the class AudioVideoNoteRecordingMenu method restartRecordingIfNeeded.

public boolean restartRecordingIfNeeded() {
    boolean restart = false;
    CurrentRecording recording = plugin.getCurrentRecording();
    if (recording != null && recording.getType() == AVActionType.REC_VIDEO && plugin.AV_RECORDER_SPLIT.get()) {
        int clipLength = plugin.AV_RS_CLIP_LENGTH.get() * 60;
        int duration = (int) ((System.currentTimeMillis() - startTime) / 1000);
        restart = duration >= clipLength;
        if (restart) {
            rec(getMapActivity(), true);
        }
    }
    return restart;
}
Also used : CurrentRecording(net.osmand.plus.audionotes.AudioVideoNotesPlugin.CurrentRecording)

Example 2 with CurrentRecording

use of net.osmand.plus.audionotes.AudioVideoNotesPlugin.CurrentRecording in project Osmand by osmandapp.

the class AudioVideoNoteRecordingMenu method rec.

public void rec(final MapActivity mapActivity, final boolean restart) {
    stopCounter();
    final CurrentRecording recording = plugin.getCurrentRecording();
    int delay;
    if (recording != null && recording.getType() == AVActionType.REC_PHOTO) {
        delay = 200;
    } else {
        delay = 1;
    }
    handler.postDelayed(new Runnable() {

        @Override
        public void run() {
            if (recording != null) {
                if (recording.getType() == AVActionType.REC_PHOTO) {
                    plugin.shoot();
                } else {
                    plugin.stopRecording(mapActivity, restart);
                    if (restart) {
                        startCounter();
                    }
                }
            }
        }
    }, delay);
}
Also used : CurrentRecording(net.osmand.plus.audionotes.AudioVideoNotesPlugin.CurrentRecording)

Example 3 with CurrentRecording

use of net.osmand.plus.audionotes.AudioVideoNotesPlugin.CurrentRecording in project Osmand by osmandapp.

the class AudioVideoNoteRecordingMenu method getViewfinderWidth.

public int getViewfinderWidth() {
    int res;
    CurrentRecording recording = plugin.getCurrentRecording();
    if (recording.getType() == AVActionType.REC_PHOTO) {
        DisplayMetrics dm = new DisplayMetrics();
        getMapActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
        res = dm.widthPixels;
    } else {
        if (isLandscapeLayout()) {
            res = AndroidUtils.dpToPx(getMapActivity(), 320 - 16f);
        } else {
            res = AndroidUtils.dpToPx(getMapActivity(), 240f);
        }
    }
    return res;
}
Also used : CurrentRecording(net.osmand.plus.audionotes.AudioVideoNotesPlugin.CurrentRecording) DisplayMetrics(android.util.DisplayMetrics)

Example 4 with CurrentRecording

use of net.osmand.plus.audionotes.AudioVideoNotesPlugin.CurrentRecording in project Osmand by osmandapp.

the class AudioVideoNoteRecordingMenu method update.

public void update() {
    CurrentRecording recording = plugin.getCurrentRecording();
    IconsCache iconsCache = plugin.getMapActivity().getMyApplication().getIconsCache();
    ImageView leftButtonIcon = (ImageView) view.findViewById(R.id.leftButtonIcon);
    View leftButtonView = view.findViewById(R.id.leftButtonView);
    if (recording.getType() != AVActionType.REC_AUDIO) {
        leftButtonIcon.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_minimize));
        TextView showHideText = (TextView) view.findViewById(R.id.leftButtonText);
        showHideText.setText(showViewfinder ? view.getResources().getString(R.string.shared_string_hide) : view.getResources().getString(R.string.shared_string_show));
        leftButtonView.setVisibility(View.VISIBLE);
        viewfinder.setVisibility(showViewfinder ? View.VISIBLE : View.GONE);
    } else {
        leftButtonView.setVisibility(View.INVISIBLE);
        viewfinder.setVisibility(View.GONE);
    }
    leftButtonView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            showHideViewfinder();
        }
    });
    View centerButtonView = view.findViewById(R.id.centerButtonView);
    ImageView recIcon = (ImageView) view.findViewById(R.id.centerButtonIcon);
    TextView recText = (TextView) view.findViewById(R.id.centerButtonText);
    View timeView = view.findViewById(R.id.timeView);
    switch(recording.getType()) {
        case REC_AUDIO:
        case REC_VIDEO:
            recIcon.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_rec_stop));
            recText.setText(view.getResources().getString(R.string.shared_string_control_stop));
            recText.setVisibility(View.VISIBLE);
            updateDuration();
            timeView.setVisibility(View.VISIBLE);
            break;
        case REC_PHOTO:
            recIcon.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_photo_dark));
            recText.setVisibility(View.GONE);
            timeView.setVisibility(View.INVISIBLE);
            break;
    }
    centerButtonView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            rec(plugin.getMapActivity(), false);
        }
    });
    applyViewfinderVisibility();
}
Also used : CurrentRecording(net.osmand.plus.audionotes.AudioVideoNotesPlugin.CurrentRecording) TextView(android.widget.TextView) IconsCache(net.osmand.plus.IconsCache) ImageView(android.widget.ImageView) SurfaceView(android.view.SurfaceView) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View)

Example 5 with CurrentRecording

use of net.osmand.plus.audionotes.AudioVideoNotesPlugin.CurrentRecording in project Osmand by osmandapp.

the class AudioVideoNoteRecordingMenu method getViewfinderHeight.

public int getViewfinderHeight() {
    int res;
    CurrentRecording recording = plugin.getCurrentRecording();
    if (recording.getType() == AVActionType.REC_PHOTO) {
        DisplayMetrics dm = new DisplayMetrics();
        getMapActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
        res = dm.heightPixels;
    } else {
        if (isLandscapeLayout()) {
            res = screenHeight - statusBarHeight - buttonsHeight;
        } else {
            res = AndroidUtils.dpToPx(getMapActivity(), 240f);
        }
    }
    return res;
}
Also used : CurrentRecording(net.osmand.plus.audionotes.AudioVideoNotesPlugin.CurrentRecording) DisplayMetrics(android.util.DisplayMetrics)

Aggregations

CurrentRecording (net.osmand.plus.audionotes.AudioVideoNotesPlugin.CurrentRecording)6 DisplayMetrics (android.util.DisplayMetrics)2 SurfaceView (android.view.SurfaceView)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 LinearLayout (android.widget.LinearLayout)1 TextView (android.widget.TextView)1 IconsCache (net.osmand.plus.IconsCache)1 MapActivity (net.osmand.plus.activities.MapActivity)1