Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b5fd8145 authored by Fahim Salam Chowdhury's avatar Fahim Salam Chowdhury 👽
Browse files

5664-continuous_burst_mode_not_stopping_issue

issue: e/backlog#5664

When user long press capture button & start continuousBrustMode &
remove touch before cameraController start taking image, causes
unwanted behavior where burst-mode doesn't stop.

Here when user remove the touch should_run_continuous_fast_burst is
maintained. When 1 burst image is taken an event is passed EventBus to
the MainActivity. On listening the event, the flag is checked &
burst-mode stop called if necessary.
parent 392d671b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -57,5 +57,6 @@ dependencies {
    //noinspection GradleCompatible
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation "androidx.constraintlayout:constraintlayout:2.1.3"
    implementation "org.greenrobot:eventbus:3.3.1"
    testImplementation 'junit:junit:4.13'
}
+20 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022  E FOUNDATION
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

package net.sourceforge.opencamera;

public class ContinuousBurstImageRunningAction {
}
+25 −1
Original line number Diff line number Diff line
@@ -77,6 +77,10 @@ import net.sourceforge.opencamera.ui.FolderChooserDialog;
import net.sourceforge.opencamera.ui.MainUI;
import net.sourceforge.opencamera.ui.ManualSeekbars;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
@@ -130,6 +134,7 @@ public class MainActivity extends Activity {
    private final Map<Integer, Bitmap> preloaded_bitmap_resources = new HashMap<>();
    private ValueAnimator gallery_save_anim;
    private boolean last_continuous_fast_burst; // whether the last photo operation was a continuous_fast_burst
    private boolean should_run_continuous_fast_burst = false;

    private TextToSpeech textToSpeech;
    private boolean textToSpeechSuccess;
@@ -637,6 +642,12 @@ public class MainActivity extends Activity {
            Log.d(TAG, "onCreate: total time for Activity startup: " + (System.currentTimeMillis() - debug_time));
    }

    @Override
    protected void onStart() {
        super.onStart();
        EventBus.getDefault().register(this);
    }

    /**
     * if navigationMode is no gesture, then retrieve navigationBar's height & update navigation_gap
     */
@@ -971,6 +982,7 @@ public class MainActivity extends Activity {
        if( MyDebug.LOG )
            Log.d(TAG, "onStop");
        super.onStop();
        EventBus.getDefault().unregister(this);

        // we stop location listening in onPause, but done here again just to be certain!
        applicationInterface.getLocationSupplier().freeLocationListeners();
@@ -3822,6 +3834,7 @@ public class MainActivity extends Activity {
        closePopup();

        this.last_continuous_fast_burst = continuous_fast_burst;
        this.should_run_continuous_fast_burst = continuous_fast_burst;
        this.preview.takePicturePressed(photo_snapshot, continuous_fast_burst);
    }

@@ -4935,7 +4948,18 @@ public class MainActivity extends Activity {
    public void takePhotoButtonLongClickCancelled() {
        if( MyDebug.LOG )
            Log.d(TAG, "takePhotoButtonLongClickCancelled");
        if( preview.getCameraController() != null && preview.getCameraController().isContinuousBurstInProgress() ) {
        if (preview.getCameraController() == null) {
            return;
        }
        if (preview.getCameraController().isContinuousBurstInProgress()) {
            preview.getCameraController().stopContinuousBurst();
        }
        should_run_continuous_fast_burst = false;
    }

    @Subscribe(threadMode = ThreadMode.MAIN_ORDERED)
    public void onContinuousBurstImageRunningAction(ContinuousBurstImageRunningAction action) {
        if (!should_run_continuous_fast_burst && preview.getCameraController() != null && preview.getCameraController().isContinuousBurstInProgress()) {
            preview.getCameraController().stopContinuousBurst();
        }
    }
+6 −0
Original line number Diff line number Diff line
package net.sourceforge.opencamera.cameracontroller;

import net.sourceforge.opencamera.ContinuousBurstImageRunningAction;
import net.sourceforge.opencamera.MyDebug;

import java.nio.ByteBuffer;
@@ -54,6 +55,8 @@ import android.view.Surface;
import android.view.SurfaceHolder;
import android.view.TextureView;

import org.greenrobot.eventbus.EventBus;

/** Provides support using Android 5's Camera 2 API
 *  android.hardware.camera2.*.
 */
@@ -1346,6 +1349,9 @@ public class CameraController2 extends CameraController {
                takePhotoCompleted();
            }

            if (n_burst_taken == 1) {
                EventBus.getDefault().post(new ContinuousBurstImageRunningAction());
            }
            if( MyDebug.LOG )
                Log.d(TAG, "done onImageAvailable");
        }