From 246de3fa0a8c13c0b3fbdeb606a07415187038fc Mon Sep 17 00:00:00 2001 From: Fahim Salam Chowdhury Date: Wed, 6 Apr 2022 12:58:55 +0600 Subject: [PATCH 1/4] 170-Implement_separate_panorama_finish_button issue: https://gitlab.e.foundation/e/os/backlog/-/issues/170 Panorama finish operation is using `take_photo` button. To update according to the new design, we neeseparate button for panorama finish operation. This commit do the following: - add `finish_panorama` button on activity_main - remove panorama icon logic from `MainUI.setTakePhotoIcon()` method - move panorama mode butto visibility logic to `MainUI.handlePanoromaModeButtonsVisibility()` method - code refactor --- .../sourceforge/opencamera/MainActivity.java | 9 ++++ .../opencamera/MyApplicationInterface.java | 8 +--- .../net/sourceforge/opencamera/ui/MainUI.java | 47 +++++++++++++++---- app/src/main/res/layout/activity_main.xml | 39 +++++++++++++-- app/src/main/res/values/dimens.xml | 1 + 5 files changed, 85 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/net/sourceforge/opencamera/MainActivity.java b/app/src/main/java/net/sourceforge/opencamera/MainActivity.java index 2d612a3f7..2a91457fd 100644 --- a/app/src/main/java/net/sourceforge/opencamera/MainActivity.java +++ b/app/src/main/java/net/sourceforge/opencamera/MainActivity.java @@ -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,12 @@ 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,6 +3412,7 @@ 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 ) diff --git a/app/src/main/java/net/sourceforge/opencamera/MyApplicationInterface.java b/app/src/main/java/net/sourceforge/opencamera/MyApplicationInterface.java index d52ed9330..4e1a180da 100644 --- a/app/src/main/java/net/sourceforge/opencamera/MyApplicationInterface.java +++ b/app/src/main/java/net/sourceforge/opencamera/MyApplicationInterface.java @@ -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 } diff --git a/app/src/main/java/net/sourceforge/opencamera/ui/MainUI.java b/app/src/main/java/net/sourceforge/opencamera/ui/MainUI.java index d34ce58b0..ea3d2423f 100644 --- a/app/src/main/java/net/sourceforge/opencamera/ui/MainUI.java +++ b/app/src/main/java/net/sourceforge/opencamera/ui/MainUI.java @@ -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,31 @@ 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)) { + 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 +1056,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) { diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 092274048..24b654ffd 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -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"/> + + + + 0dp 70dp 36dp + 48dp 195dp -- GitLab From 3823db84b809c0038a43f992b17fb559e2ac609c Mon Sep 17 00:00:00 2001 From: Jonathan Klee Date: Wed, 6 Apr 2022 13:00:37 +0000 Subject: [PATCH 2/4] Apply 1 suggestion(s) to 1 file(s) --- app/src/main/java/net/sourceforge/opencamera/MainActivity.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/net/sourceforge/opencamera/MainActivity.java b/app/src/main/java/net/sourceforge/opencamera/MainActivity.java index 2a91457fd..02816b6b9 100644 --- a/app/src/main/java/net/sourceforge/opencamera/MainActivity.java +++ b/app/src/main/java/net/sourceforge/opencamera/MainActivity.java @@ -3415,8 +3415,9 @@ public class MainActivity extends Activity { @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 ) { -- GitLab From 8525a51dfd4a0e9286553cd063e94cc21bebabec Mon Sep 17 00:00:00 2001 From: Jonathan Klee Date: Wed, 6 Apr 2022 13:00:48 +0000 Subject: [PATCH 3/4] Apply 1 suggestion(s) to 1 file(s) --- app/src/main/java/net/sourceforge/opencamera/MainActivity.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/net/sourceforge/opencamera/MainActivity.java b/app/src/main/java/net/sourceforge/opencamera/MainActivity.java index 02816b6b9..eae8cc046 100644 --- a/app/src/main/java/net/sourceforge/opencamera/MainActivity.java +++ b/app/src/main/java/net/sourceforge/opencamera/MainActivity.java @@ -1433,8 +1433,9 @@ public class MainActivity extends Activity { } public void clickedFinishPanorama(View view) { - if( MyDebug.LOG ) + if (MyDebug.LOG) { Log.d(TAG, "clickedFinishPanorama"); + } this.takePicture(false); } -- GitLab From d168ac8acbd559d3a3bab380603aadf0091a7e28 Mon Sep 17 00:00:00 2001 From: Fahim Salam Chowdhury Date: Wed, 6 Apr 2022 13:07:29 +0000 Subject: [PATCH 4/4] remove nested if condition from handlePanoromaModeButtonsVisibility method --- .../net/sourceforge/opencamera/ui/MainUI.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/net/sourceforge/opencamera/ui/MainUI.java b/app/src/main/java/net/sourceforge/opencamera/ui/MainUI.java index ea3d2423f..cbee3a3c4 100644 --- a/app/src/main/java/net/sourceforge/opencamera/ui/MainUI.java +++ b/app/src/main/java/net/sourceforge/opencamera/ui/MainUI.java @@ -790,15 +790,17 @@ public class MainUI { view.setVisibility(isPanoramaRunning ? View.VISIBLE : View.GONE); SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(main_activity); - if (sharedPreferences.getBoolean(PreferenceKeys.ShowTakePhotoPreferenceKey, true)) { - view = main_activity.findViewById(R.id.finish_panorama); - view.setVisibility(isPanoramaRunning ? View.VISIBLE : View.GONE); + 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(); - } + view = main_activity.findViewById(R.id.take_photo); + view.setVisibility(isPanoramaRunning ? View.INVISIBLE : View.VISIBLE); + if (!isPanoramaRunning) { + setTakePhotoIcon(); } } -- GitLab