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

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

Merge branch '170-Implement_separate_panorama_finish_button' into 'master'

170-Implement_separate_panorama_finish_button

See merge request !29
parents 19d25df1 3d3e17c4
Loading
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -395,6 +395,8 @@ public class MainActivity extends Activity {
        takePhotoVideoButton.setVisibility(View.GONE);
        View cancelPanoramaButton = findViewById(R.id.cancel_panorama);
        cancelPanoramaButton.setVisibility(View.GONE);
        View finishPanoramaButton = findViewById(R.id.finish_panorama);
        finishPanoramaButton.setVisibility(View.GONE);

        // We initialise optional controls to invisible/gone, so they don't show while the camera is opening - the actual visibility is
        // set in cameraSetup().
@@ -1430,6 +1432,13 @@ public class MainActivity extends Activity {
        applicationInterface.stopPanorama(true);
    }

    public void clickedFinishPanorama(View view) {
        if (MyDebug.LOG) {
            Log.d(TAG, "clickedFinishPanorama");
        }
        this.takePicture(false);
    }

    public void clickedCycleRaw(View view) {
        if( MyDebug.LOG )
            Log.d(TAG, "clickedCycleRaw");
@@ -3404,10 +3413,12 @@ public class MainActivity extends Activity {
    /** Listens for the response from the Storage Access Framework dialog to select a folder
     *  (as opened with openFolderChooserDialogSAF()).
     */
    @SuppressLint("WrongConstant")
    @TargetApi(Build.VERSION_CODES.LOLLIPOP)
    public void onActivityResult(int requestCode, int resultCode, Intent resultData) {
        if( MyDebug.LOG )
        if (MyDebug.LOG) {
            Log.d(TAG, "onActivityResult: " + requestCode);
        }
        switch( requestCode ) {
            case CHOOSE_SAVE_FOLDER_SAF_CODE:
                if( resultCode == RESULT_OK && resultData != null ) {
+2 −6
Original line number Diff line number Diff line
@@ -1720,9 +1720,7 @@ public class MyApplicationInterface extends BasicApplicationInterface {
        panorama_pic_accepted = false;
        panorama_dir_left_to_right = true;

        main_activity.getMainUI().setTakePhotoIcon();
        View cancelPanoramaButton = main_activity.findViewById(R.id.cancel_panorama);
        cancelPanoramaButton.setVisibility(View.VISIBLE);
        main_activity.getMainUI().handlePanoromaModeButtonsVisibility();
        main_activity.getMainUI().closeExposureUI(); // close seekbars if open (popup is already closed when taking a photo)
        // taking the photo will end up calling MainUI.showGUI(), which will hide the other on-screen icons
    }
@@ -1758,9 +1756,7 @@ public class MyApplicationInterface extends BasicApplicationInterface {
        if( is_cancelled ) {
            imageSaver.flushImageBatch();
        }
        main_activity.getMainUI().setTakePhotoIcon();
        View cancelPanoramaButton = main_activity.findViewById(R.id.cancel_panorama);
        cancelPanoramaButton.setVisibility(View.GONE);
        main_activity.getMainUI().handlePanoromaModeButtonsVisibility();
        main_activity.getMainUI().showGUI(); // refresh UI icons now that we've stopped panorama
    }

+41 −8
Original line number Diff line number Diff line
@@ -458,6 +458,9 @@ public class MainUI {
            view = main_activity.findViewById(R.id.cancel_panorama);
            setViewRotation(view, ui_rotation);

            view = main_activity.findViewById(R.id.finish_panorama);
            setViewRotation(view, ui_rotation);

            view = main_activity.findViewById(R.id.switch_video);
            setViewRotation(view, ui_rotation);

@@ -755,13 +758,6 @@ public class MainUI {
                        : R.drawable.ic_camera_video;
                content_description = main_activity.getPreview().isVideoRecording() ? R.string.stop_video : R.string.start_video;
                switch_video_content_description = R.string.switch_to_photo;
            } else if (main_activity.getApplicationInterface().getPhotoMode() == MyApplicationInterface.PhotoMode.Panorama &&
                    main_activity.getApplicationInterface().getGyroSensor().isRecording()) {
                if (MyDebug.LOG)
                    Log.d(TAG, "set icon to recording panorama");
                resource = R.drawable.ic_done;
                content_description = R.string.finish_panorama;
                switch_video_content_description = R.string.switch_to_video;
            } else {
                if (MyDebug.LOG)
                    Log.d(TAG, "set icon to photo");
@@ -781,6 +777,33 @@ public class MainUI {
        }
    }

    /**
     * Show/hide photoShutter, panorama cancel & finish buttons on photoMode.
     * If user save not to show photoShutter button, don't show photoShutter & panorama finish buttons.
     * If user wants to view the shutter button, update the shutterButton's icon to the appropriate one.
     */
    public void handlePanoromaModeButtonsVisibility() {
        boolean isPanoramaRunning = (main_activity.getApplicationInterface().getPhotoMode() == MyApplicationInterface.PhotoMode.Panorama &&
                main_activity.getApplicationInterface().getGyroSensor().isRecording());

        View view = main_activity.findViewById(R.id.cancel_panorama);
        view.setVisibility(isPanoramaRunning ? View.VISIBLE : View.GONE);

        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(main_activity);
        if (!sharedPreferences.getBoolean(PreferenceKeys.ShowTakePhotoPreferenceKey, true)) {
            return;
        }
        
        view = main_activity.findViewById(R.id.finish_panorama);
        view.setVisibility(isPanoramaRunning ? View.VISIBLE : View.GONE);

        view = main_activity.findViewById(R.id.take_photo);
        view.setVisibility(isPanoramaRunning ? View.INVISIBLE : View.VISIBLE);
        if (!isPanoramaRunning) {
            setTakePhotoIcon();
        }
    }

    /**
     * Set content description for switch camera button.
     */
@@ -1035,21 +1058,31 @@ public class MainUI {
                }
                String pref_immersive_mode = sharedPreferences.getString(PreferenceKeys.ImmersiveModePreferenceKey, "immersive_mode_low_profile");
                if (pref_immersive_mode.equals("immersive_mode_everything")) {
                    if (sharedPreferences.getBoolean(PreferenceKeys.ShowTakePhotoPreferenceKey, true)) {
                    final boolean showTakePhotoPreferenceKey = sharedPreferences.getBoolean(PreferenceKeys.ShowTakePhotoPreferenceKey, true);

                    if (showTakePhotoPreferenceKey) {
                        View takePhotoButton = main_activity.findViewById(R.id.take_photo);
                        takePhotoButton.setVisibility(visibility);
                    }

                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && main_activity.getPreview().isVideoRecording()) {
                        View pauseVideoButton = main_activity.findViewById(R.id.pause_video);
                        pauseVideoButton.setVisibility(visibility);
                    }

                    if (main_activity.getPreview().supportsPhotoVideoRecording() && main_activity.getApplicationInterface().usePhotoVideoRecording() && main_activity.getPreview().isVideoRecording()) {
                        View takePhotoVideoButton = main_activity.findViewById(R.id.take_photo_when_video_recording);
                        takePhotoVideoButton.setVisibility(visibility);
                    }

                    if (main_activity.getApplicationInterface().getGyroSensor().isRecording()) {
                        View cancelPanoramaButton = main_activity.findViewById(R.id.cancel_panorama);
                        cancelPanoramaButton.setVisibility(visibility);

                        if (showTakePhotoPreferenceKey) {
                            View finishPanoramaButton = main_activity.findViewById(R.id.finish_panorama);
                            finishPanoramaButton.setVisibility(visibility);
                        }
                    }
                }
                if (!immersive_mode) {
+34 −5
Original line number Diff line number Diff line
@@ -28,7 +28,21 @@
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            android:clickable="false"
            android:focusable="false"/>
            android:focusable="false"
            android:visibility="invisible"/>

        <View
            android:id="@+id/place_holder_center_view"
            android:layout_width="1dp"
            android:layout_height="1dp"
            android:background="@android:color/transparent"
            android:clickable="false"
            android:focusable="false"
            android:visibility="invisible"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintEnd_toEndOf="parent" />

        <ImageButton
            android:id="@+id/take_photo"
@@ -87,12 +101,12 @@

        <ImageButton
            android:id="@+id/cancel_panorama"
            android:layout_width="@dimen/onscreen_bottom_button_size"
            android:layout_height="@dimen/onscreen_bottom_button_size"
            app:layout_constraintTop_toBottomOf="@id/gallery"
            app:layout_constraintBottom_toTopOf="@id/take_photo"
            android:layout_width="@dimen/onscreen_bottom_panorama_button_size"
            android:layout_height="@dimen/onscreen_bottom_panorama_button_size"
            app:layout_constraintBottom_toTopOf="@id/place_holder_center_view"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            android:layout_marginBottom="13dp"
            android:background="@null"
            android:contentDescription="@string/cancel_panorama"
            android:onClick="clickedCancelPanorama"
@@ -100,6 +114,21 @@
            android:src="@drawable/ic_cancel"
            android:visibility="gone" />

        <ImageButton
            android:id="@+id/finish_panorama"
            android:layout_width="@dimen/onscreen_bottom_panorama_button_size"
            android:layout_height="@dimen/onscreen_bottom_panorama_button_size"
            app:layout_constraintTop_toBottomOf="@id/place_holder_center_view"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            android:layout_marginTop="13dp"
            android:background="@null"
            android:contentDescription="@string/finish_panorama"
            android:onClick="clickedFinishPanorama"
            android:scaleType="fitCenter"
            android:src="@drawable/ic_done"
            android:visibility="gone" />

        <ImageButton
            android:id="@+id/switch_video"
            android:layout_width="@dimen/onscreen_bottom_button_size"
+1 −0
Original line number Diff line number Diff line
@@ -9,5 +9,6 @@
    <dimen name="onscreen_button_padding">0dp</dimen>
    <dimen name="shutter_button_size">70dp</dimen>
    <dimen name="onscreen_bottom_button_size">36dp</dimen>
    <dimen name="onscreen_bottom_panorama_button_size">48dp</dimen>
    <dimen name="zoom_seekbar_hw_diff">195dp</dimen>
</resources>