diff --git a/app/src/main/java/net/sourceforge/opencamera/MainActivity.java b/app/src/main/java/net/sourceforge/opencamera/MainActivity.java index 7d1a2f517c9cc0e1c886436d500fd870d959519f..257b507e8dac4bc0974500f332a6dee5bd9ed3a3 100644 --- a/app/src/main/java/net/sourceforge/opencamera/MainActivity.java +++ b/app/src/main/java/net/sourceforge/opencamera/MainActivity.java @@ -139,6 +139,7 @@ public class MainActivity extends Activity { //private boolean ui_placement_right = true; 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; public static volatile boolean test_preview_want_no_limits; // test flag, if set to true then instead use test_preview_want_no_limits_value; needs to be static, as it needs to be set before activity is created to take effect @@ -652,8 +653,10 @@ public class MainActivity extends Activity { } } - public void handleDecorFitsSystemWindows() { - setDecorFitsSystemWindows(!isInFullScreenMode()); + public void handleDecorFitsSystemWindows(double previewRatio, double screenRatio) { + boolean decorFitsSystemWindows = screenRatio >= previewRatio; + setDecorFitsSystemWindows(decorFitsSystemWindows); + can_draw_nav_bar = !decorFitsSystemWindows; } /** @@ -666,10 +669,10 @@ public class MainActivity extends Activity { } /** - * if sdk>=R & not in full screen, means the DecorFitsSystemWindows=true, then we can ignore navigationGap. + * if sdk>=R & can't draw navigation bar, means the DecorFitsSystemWindows=true, then we can ignore navigationGap. */ public int getNavigationGap() { - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && !isInFullScreenMode()) { + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && !can_draw_nav_bar) { return 0; } return want_no_limits ? navigation_gap : 0; diff --git a/app/src/main/java/net/sourceforge/opencamera/MyPreferenceFragment.java b/app/src/main/java/net/sourceforge/opencamera/MyPreferenceFragment.java index d2d206a087a38edcc1dd0f8ef457a507e8a4ef02..aa236cdf9581d1b2d3682054102896a25bc0216d 100644 --- a/app/src/main/java/net/sourceforge/opencamera/MyPreferenceFragment.java +++ b/app/src/main/java/net/sourceforge/opencamera/MyPreferenceFragment.java @@ -222,10 +222,29 @@ public class MyPreferenceFragment extends PreferenceFragment implements OnShared final int [] widths = bundle.getIntArray("resolution_widths"); final int [] heights = bundle.getIntArray("resolution_heights"); final boolean [] supports_burst = bundle.getBooleanArray("resolution_supports_burst"); - - Preference pref1 = findPreference("preference_resolution"); - PreferenceGroup pg1 = (PreferenceGroup)this.findPreference("preference_screen_photo_settings"); - pg1.removePreference(pref1); + 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 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 sizes) { if (MyDebug.LOG) Log.d(TAG, "getOptimalPreviewSize()"); @@ -3518,7 +3503,6 @@ public class Preview implements SurfaceHolder.Callback, TextureView.SurfaceTextu if (MyDebug.LOG) Log.d(TAG, "display_size: " + 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) { @@ -3540,17 +3524,9 @@ 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); + optimalSize = getClosestSize(sizes, targetRatio, null); } - + handleDecorFitsSystemWindows(optimalSize, display_size); if (MyDebug.LOG) { Log.d(TAG, "chose optimalSize: " + optimalSize.width + " x " + optimalSize.height); Log.d(TAG, "optimalSize ratio: " + ((double) optimalSize.width / optimalSize.height)); @@ -3558,6 +3534,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 sizes, double targetRatio) { if (MyDebug.LOG) Log.d(TAG, "getOptimalVideoPictureSize()"); diff --git a/app/src/main/java/net/sourceforge/opencamera/ui/PopupView.java b/app/src/main/java/net/sourceforge/opencamera/ui/PopupView.java index 9705996e058a70310239fd64b033d61a338d2dd8..875dc0385ae31e6b52e5fbab282aa8fa2811584b 100644 --- a/app/src/main/java/net/sourceforge/opencamera/ui/PopupView.java +++ b/app/src/main/java/net/sourceforge/opencamera/ui/PopupView.java @@ -349,7 +349,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.