Loading app/src/main/java/net/sourceforge/opencamera/MainActivity.java +10 −6 Original line number Diff line number Diff line Loading @@ -164,6 +164,7 @@ public class MainActivity extends AppCompatActivity implements PreferenceFragmen //private final boolean edge_to_edge_mode = true; // whether running always in edge-to-edge mode private final boolean edge_to_edge_mode = Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM; // whether running always in edge-to-edge mode private boolean want_no_limits; // whether we want to run with FLAG_LAYOUT_NO_LIMITS private boolean can_draw_nav_bar = true; private boolean set_window_insets_listener; // whether we've enabled a setOnApplyWindowInsetsListener() private int navigation_gap; // gap for navigation bar along bottom (portrait) or right (landscape) private int navigation_gap_landscape; // gap for navigation bar along left (portrait) or bottom (landscape); only set for edge_to_edge_mode==true Loading Loading @@ -759,8 +760,10 @@ public class MainActivity extends AppCompatActivity implements PreferenceFragmen } } public void handleDecorFitsSystemWindows() { setDecorFitsSystemWindows(!isInFullScreenMode()); public void handleDecorFitsSystemWindows(double previewRatio, double screenRatio) { boolean decorFitsSystemWindows = screenRatio >= previewRatio; setDecorFitsSystemWindows(decorFitsSystemWindows); can_draw_nav_bar = !decorFitsSystemWindows; } /** Loading Loading @@ -3897,9 +3900,6 @@ public class MainActivity extends AppCompatActivity implements PreferenceFragmen } } /** * if sdk>=R & not in full screen, means the DecorFitsSystemWindows=true, then we can ignore navigationGap. */ public int getNavigationGap() { if (isFullScreen()) return 0; return (want_no_limits || edge_to_edge_mode) ? navigation_gap : 0; Loading @@ -3915,8 +3915,12 @@ public class MainActivity extends AppCompatActivity implements PreferenceFragmen return edge_to_edge_mode ? navigation_gap_reverse_landscape : 0; } /** * if sdk>=R & can't draw navigation bar, means the DecorFitsSystemWindows=true, then we can ignore navigationGap. */ private boolean isFullScreen() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && !isInFullScreenMode()) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && !can_draw_nav_bar) { return true; } Loading app/src/main/java/net/sourceforge/opencamera/PreferenceSubPhoto.java +1 −1 Original line number Diff line number Diff line Loading @@ -86,7 +86,7 @@ public class PreferenceSubPhoto extends PreferenceSubScreen { if( MyDebug.LOG ) Log.d(TAG, "supports_photo_video_recording: " + supports_photo_video_recording); if( false && widths != null && heights != null && supports_burst != null ) { if( widths != null && heights != null && supports_burst != null ) { CharSequence [] entries = new CharSequence[widths.length]; CharSequence [] values = new CharSequence[widths.length]; for(int i=0;i<widths.length;i++) { Loading app/src/main/java/net/sourceforge/opencamera/preview/Preview.java +8 −24 Original line number Diff line number Diff line Loading @@ -3979,21 +3979,6 @@ public class Preview implements SurfaceHolder.Callback, TextureView.SurfaceTextu return optimalSize; } private static CameraController.Size getClosestSizeForFullScreen(List<CameraController.Size> sizes, double targetRatio) { if (MyDebug.LOG) Log.d(TAG, "getClosestSize()"); CameraController.Size optimalSize = null; double minDiff = Double.MIN_VALUE; for (CameraController.Size size : sizes) { double ratio = (double) size.width / size.height; if ((ratio - targetRatio) > minDiff) { optimalSize = size; minDiff = ratio - targetRatio; } } return (optimalSize != null) ? optimalSize : getClosestSize(sizes, targetRatio, null); } public CameraController.Size getOptimalPreviewSize(List<CameraController.Size> sizes) { if( MyDebug.LOG ) Log.d(TAG, "getOptimalPreviewSize()"); Loading Loading @@ -4027,7 +4012,6 @@ public class Preview implements SurfaceHolder.Callback, TextureView.SurfaceTextu Log.d(TAG, "swapped display_size to: " + display_size.x + " x " + display_size.y); } } ((MainActivity)getContext()).handleDecorFitsSystemWindows(); double targetRatio = calculateTargetRatioForPreview(display_size); int targetHeight = Math.min(display_size.y, display_size.x); if( targetHeight <= 0 ) { Loading Loading @@ -4057,16 +4041,10 @@ public class Preview implements SurfaceHolder.Callback, TextureView.SurfaceTextu // can't find match for aspect ratio, so find closest one if( MyDebug.LOG ) Log.d(TAG, "no preview size matches the aspect ratio"); if (((MainActivity)getContext()).isInFullScreenMode()) { optimalSize = getClosestSizeForFullScreen(sizes, targetRatio); } else { optimalSize = getClosestSize(sizes, targetRatio, null); } } if (((MainActivity)getContext()).isInFullScreenMode()) { camera_controller.setPictureSize(optimalSize.width, optimalSize.height); } handleDecorFitsSystemWindows(optimalSize, display_size); if( MyDebug.LOG ) { Log.d(TAG, "chose optimalSize: " + optimalSize.width + " x " + optimalSize.height); Loading @@ -4075,6 +4053,12 @@ public class Preview implements SurfaceHolder.Callback, TextureView.SurfaceTextu return optimalSize; } private void handleDecorFitsSystemWindows(CameraController.Size optimalSize, Point display_size) { double previewRatio = (double) optimalSize.width / optimalSize.height; double screenRatio = (double) display_size.x / display_size.y; ((MainActivity)getContext()).handleDecorFitsSystemWindows(previewRatio, screenRatio); } public CameraController.Size getOptimalVideoPictureSize(List<CameraController.Size> sizes, double targetRatio) { if( MyDebug.LOG ) Log.d(TAG, "getOptimalVideoPictureSize()"); Loading app/src/main/java/net/sourceforge/opencamera/ui/PopupView.java +1 −1 Original line number Diff line number Diff line Loading @@ -374,7 +374,7 @@ public class PopupView extends LinearLayout { if( MyDebug.LOG ) Log.d(TAG, "PopupView time 8: " + (System.nanoTime() - debug_time)); if( !preview.isVideo() && photo_mode != MyApplicationInterface.PhotoMode.Panorama && !main_activity.isInFullScreenMode()) { if( !preview.isVideo() && photo_mode != MyApplicationInterface.PhotoMode.Panorama ) { // Only show photo resolutions in photo mode - even if photo snapshots whilst recording video is supported, the // resolutions for that won't match what the user has requested for photo mode resolutions. // And Panorama mode chooses its own resolution. Loading Loading
app/src/main/java/net/sourceforge/opencamera/MainActivity.java +10 −6 Original line number Diff line number Diff line Loading @@ -164,6 +164,7 @@ public class MainActivity extends AppCompatActivity implements PreferenceFragmen //private final boolean edge_to_edge_mode = true; // whether running always in edge-to-edge mode private final boolean edge_to_edge_mode = Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM; // whether running always in edge-to-edge mode private boolean want_no_limits; // whether we want to run with FLAG_LAYOUT_NO_LIMITS private boolean can_draw_nav_bar = true; private boolean set_window_insets_listener; // whether we've enabled a setOnApplyWindowInsetsListener() private int navigation_gap; // gap for navigation bar along bottom (portrait) or right (landscape) private int navigation_gap_landscape; // gap for navigation bar along left (portrait) or bottom (landscape); only set for edge_to_edge_mode==true Loading Loading @@ -759,8 +760,10 @@ public class MainActivity extends AppCompatActivity implements PreferenceFragmen } } public void handleDecorFitsSystemWindows() { setDecorFitsSystemWindows(!isInFullScreenMode()); public void handleDecorFitsSystemWindows(double previewRatio, double screenRatio) { boolean decorFitsSystemWindows = screenRatio >= previewRatio; setDecorFitsSystemWindows(decorFitsSystemWindows); can_draw_nav_bar = !decorFitsSystemWindows; } /** Loading Loading @@ -3897,9 +3900,6 @@ public class MainActivity extends AppCompatActivity implements PreferenceFragmen } } /** * if sdk>=R & not in full screen, means the DecorFitsSystemWindows=true, then we can ignore navigationGap. */ public int getNavigationGap() { if (isFullScreen()) return 0; return (want_no_limits || edge_to_edge_mode) ? navigation_gap : 0; Loading @@ -3915,8 +3915,12 @@ public class MainActivity extends AppCompatActivity implements PreferenceFragmen return edge_to_edge_mode ? navigation_gap_reverse_landscape : 0; } /** * if sdk>=R & can't draw navigation bar, means the DecorFitsSystemWindows=true, then we can ignore navigationGap. */ private boolean isFullScreen() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && !isInFullScreenMode()) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && !can_draw_nav_bar) { return true; } Loading
app/src/main/java/net/sourceforge/opencamera/PreferenceSubPhoto.java +1 −1 Original line number Diff line number Diff line Loading @@ -86,7 +86,7 @@ public class PreferenceSubPhoto extends PreferenceSubScreen { if( MyDebug.LOG ) Log.d(TAG, "supports_photo_video_recording: " + supports_photo_video_recording); if( false && widths != null && heights != null && supports_burst != null ) { if( widths != null && heights != null && supports_burst != null ) { CharSequence [] entries = new CharSequence[widths.length]; CharSequence [] values = new CharSequence[widths.length]; for(int i=0;i<widths.length;i++) { Loading
app/src/main/java/net/sourceforge/opencamera/preview/Preview.java +8 −24 Original line number Diff line number Diff line Loading @@ -3979,21 +3979,6 @@ public class Preview implements SurfaceHolder.Callback, TextureView.SurfaceTextu return optimalSize; } private static CameraController.Size getClosestSizeForFullScreen(List<CameraController.Size> sizes, double targetRatio) { if (MyDebug.LOG) Log.d(TAG, "getClosestSize()"); CameraController.Size optimalSize = null; double minDiff = Double.MIN_VALUE; for (CameraController.Size size : sizes) { double ratio = (double) size.width / size.height; if ((ratio - targetRatio) > minDiff) { optimalSize = size; minDiff = ratio - targetRatio; } } return (optimalSize != null) ? optimalSize : getClosestSize(sizes, targetRatio, null); } public CameraController.Size getOptimalPreviewSize(List<CameraController.Size> sizes) { if( MyDebug.LOG ) Log.d(TAG, "getOptimalPreviewSize()"); Loading Loading @@ -4027,7 +4012,6 @@ public class Preview implements SurfaceHolder.Callback, TextureView.SurfaceTextu Log.d(TAG, "swapped display_size to: " + display_size.x + " x " + display_size.y); } } ((MainActivity)getContext()).handleDecorFitsSystemWindows(); double targetRatio = calculateTargetRatioForPreview(display_size); int targetHeight = Math.min(display_size.y, display_size.x); if( targetHeight <= 0 ) { Loading Loading @@ -4057,16 +4041,10 @@ public class Preview implements SurfaceHolder.Callback, TextureView.SurfaceTextu // can't find match for aspect ratio, so find closest one if( MyDebug.LOG ) Log.d(TAG, "no preview size matches the aspect ratio"); if (((MainActivity)getContext()).isInFullScreenMode()) { optimalSize = getClosestSizeForFullScreen(sizes, targetRatio); } else { optimalSize = getClosestSize(sizes, targetRatio, null); } } if (((MainActivity)getContext()).isInFullScreenMode()) { camera_controller.setPictureSize(optimalSize.width, optimalSize.height); } handleDecorFitsSystemWindows(optimalSize, display_size); if( MyDebug.LOG ) { Log.d(TAG, "chose optimalSize: " + optimalSize.width + " x " + optimalSize.height); Loading @@ -4075,6 +4053,12 @@ public class Preview implements SurfaceHolder.Callback, TextureView.SurfaceTextu return optimalSize; } private void handleDecorFitsSystemWindows(CameraController.Size optimalSize, Point display_size) { double previewRatio = (double) optimalSize.width / optimalSize.height; double screenRatio = (double) display_size.x / display_size.y; ((MainActivity)getContext()).handleDecorFitsSystemWindows(previewRatio, screenRatio); } public CameraController.Size getOptimalVideoPictureSize(List<CameraController.Size> sizes, double targetRatio) { if( MyDebug.LOG ) Log.d(TAG, "getOptimalVideoPictureSize()"); Loading
app/src/main/java/net/sourceforge/opencamera/ui/PopupView.java +1 −1 Original line number Diff line number Diff line Loading @@ -374,7 +374,7 @@ public class PopupView extends LinearLayout { if( MyDebug.LOG ) Log.d(TAG, "PopupView time 8: " + (System.nanoTime() - debug_time)); if( !preview.isVideo() && photo_mode != MyApplicationInterface.PhotoMode.Panorama && !main_activity.isInFullScreenMode()) { if( !preview.isVideo() && photo_mode != MyApplicationInterface.PhotoMode.Panorama ) { // Only show photo resolutions in photo mode - even if photo snapshots whilst recording video is supported, the // resolutions for that won't match what the user has requested for photo mode resolutions. // And Panorama mode chooses its own resolution. Loading