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

Commit 5094552f 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 1f961a49
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -62,6 +62,8 @@ dependencies {
    // needed to fix errors since upgrading to appcompat:1.7.0, see https://stackoverflow.com/questions/75263047/duplicate-class-in-kotlin-android
    implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.9.0"))

    implementation "org.greenrobot:eventbus:3.3.1"

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

    implementation 'androidx.exifinterface:exifinterface:1.4.1'
+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;
@@ -152,6 +156,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;
@@ -744,6 +749,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
     */
@@ -1275,6 +1286,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();
@@ -5718,6 +5730,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);
    }

@@ -6992,7 +7005,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;

@@ -70,6 +71,8 @@ import android.view.SurfaceHolder;
import android.view.TextureView;
import android.view.WindowMetrics;

import org.greenrobot.eventbus.EventBus;

/** Provides support using Android 5's Camera 2 API
 *  android.hardware.camera2.*.
 */
@@ -1691,6 +1694,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");
        }