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

Commit 84c3310e authored by Mark Harman's avatar Mark Harman
Browse files

Don't show on-screen flash icon in video mode (since this icon doesn't show...

Don't show on-screen flash icon in video mode (since this icon doesn't show torch, and flash auto/on not supported in video mode); also fix Preview.cycleFlash to behave sensibly in video mode anyway.
parent f0a7af43
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -71,6 +71,8 @@ FIXED Was incorrectly offering manual white balance even if camera didn't supp
        balance temperature seekbar wasn't shown).
FIXED   Option on-screen icons (such as flash, RAW) weren't updating correctly if switching to a
        camera that didn't support that feature.
FIXED   Don't show on-screen flash icon in video mode (since this icon doesn't show torch, and flash
        auto/on not supported in video mode).
ADDED   New icon for switching between multiple cameras. If your device has multiple front and/or
        back cameras, then the existing icon to switch cameras will switch between the first front
        and back camera; the new icon will instead cycle between the multiple front or back cameras.
+32 −5
Original line number Diff line number Diff line
@@ -4554,14 +4554,41 @@ public class Preview implements SurfaceHolder.Callback, TextureView.SurfaceTextu
            Log.d(TAG, "cycleFlash()");
        if( supported_flash_values != null ) {
            int new_flash_index = (current_flash_index+1) % supported_flash_values.size();
            int start_index = new_flash_index;
            boolean done = false;
            while( !done ) {
                done = true;

                if( skip_torch && supported_flash_values.get(new_flash_index).equals("flash_torch") ) {
                    if( MyDebug.LOG )
                        Log.d(TAG, "cycle past torch");
                    new_flash_index = (new_flash_index+1) % supported_flash_values.size();
                    // don't bother setting done to false as we shouldn't have two torches in a row...
                }

                if( is_video ) {
                    // check supported for video
                    String new_flash_value = supported_flash_values.get(new_flash_index);
                    if( !isFlashSupportedForVideo(new_flash_value) ) {
                        if( MyDebug.LOG )
                            Log.d(TAG, "cycle past flash mode not supported for video: " + new_flash_value);
                        new_flash_index = (new_flash_index+1) % supported_flash_values.size();
                        done = false;
                    }
                }

                if( !done && new_flash_index == start_index ) {
                    // just in case, prevent infinite loop
                    Log.e(TAG, "flash looped to start - couldn't find valid flash!");
                    break;
                }
            }

            if( done ) {
                updateFlash(new_flash_index, save);
            }
        }
    }

    private void updateFlash(int new_flash_index, boolean save) {
        if( MyDebug.LOG )
+2 −0
Original line number Diff line number Diff line
@@ -1010,6 +1010,8 @@ public class MainUI {
    public boolean showCycleFlashIcon() {
        if( !main_activity.getPreview().supportsFlash() )
            return false;
        if( main_activity.getPreview().isVideo() )
            return false; // no point showing flash icon in video mode, as we only allow flash auto and flash torch, and we don't support torch on the on-screen cycle flash icon
        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(main_activity);
        return sharedPreferences.getBoolean(PreferenceKeys.ShowCycleFlashPreferenceKey, false);
    }