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

Commit 11f0d848 authored by Fahim Salam Chowdhury's avatar Fahim Salam Chowdhury 👽 Committed by Mohammed Althaf T
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 6181ca3c
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -63,6 +63,8 @@ dependencies {
    // appcompat version must be 1.4.0 or later to satisfy emoji policy!
    implementation 'androidx.appcompat:appcompat:1.6.1'

    implementation "org.greenrobot:eventbus:3.3.1"

    implementation 'androidx.legacy:legacy-support-v4:1.0.0'

    implementation 'androidx.exifinterface:exifinterface:1.3.7'
+19 −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
@@ -11,6 +11,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;
@@ -145,6 +149,7 @@ public class MainActivity extends AppCompatActivity implements PreferenceFragmen
    private ValueAnimator gallery_save_anim;
    private boolean last_continuous_fast_burst; // whether the last photo operation was a continuous_fast_burst
    private Future<?> update_gallery_future;
    private boolean should_run_continuous_fast_burst = false;

    private TextToSpeech textToSpeech;
    private boolean textToSpeechSuccess;
@@ -757,6 +762,12 @@ public class MainActivity extends AppCompatActivity implements PreferenceFragmen
            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
     */
@@ -1279,6 +1290,7 @@ public class MainActivity extends AppCompatActivity implements PreferenceFragmen
        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();
@@ -5337,6 +5349,7 @@ public class MainActivity extends AppCompatActivity implements PreferenceFragmen
        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);
    }

@@ -6532,7 +6545,18 @@ public class MainActivity extends AppCompatActivity implements PreferenceFragmen
    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.HDRProcessor;
import net.sourceforge.opencamera.MyDebug;

@@ -64,6 +65,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.*.
 */
@@ -1634,6 +1637,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");
        }