Loading app/build.gradle +2 −2 Original line number Diff line number Diff line apply plugin: 'com.android.application' android { compileSdkVersion 29 compileSdkVersion 30 compileOptions.encoding = 'UTF-8' compileOptions { Loading @@ -12,7 +12,7 @@ android { defaultConfig { applicationId "foundation.e.camera" minSdkVersion 21 targetSdkVersion 29 targetSdkVersion 30 renderscriptTargetApi 21 //renderscriptSupportModeEnabled true // don't use support library as it bloats the APK, and we don't need pre-4.4 support Loading app/src/main/java/net/sourceforge/opencamera/MainActivity.java +48 −0 Original line number Diff line number Diff line Loading @@ -651,13 +651,48 @@ public class MainActivity extends Activity { notificationManager.createNotificationChannel(channel); } calculateNavigationGap(); if( MyDebug.LOG ) Log.d(TAG, "onCreate: total time for Activity startup: " + (System.currentTimeMillis() - debug_time)); } /** * if navigationMode is no gesture, then retrieve navigationBar's height & update navigation_gap */ private void calculateNavigationGap() { int resourceId = getResources().getIdentifier("config_navBarInteractionMode", "integer", "android"); if (resourceId > 0) { int navType = getResources().getInteger(resourceId); if (navType != 2) { //gesture mode = 2 resourceId = getResources().getIdentifier("navigation_bar_height", "dimen", "android"); if (resourceId > 0) { navigation_gap = getResources().getDimensionPixelSize(resourceId); } } } } public void handleDecorFitsSystemWindows() { setDecorFitsSystemWindows(!isInFullScreenMode()); } /** * check is the preview size = maximise && is not in video mode, then return true */ public boolean isInFullScreenMode() { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); String preview_size = sharedPreferences.getString(PreferenceKeys.PreviewSizePreferenceKey, "preference_preview_size_display"); return !(preview_size.equals("preference_preview_size_wysiwyg") || preview.isVideo()); } /** * if sdk>=R & not in full screen, means the DecorFitsSystemWindows=true, then we can ignore navigationGap. */ public int getNavigationGap() { if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && !isInFullScreenMode()) { return 0; } return want_no_limits ? navigation_gap : 0; } Loading Loading @@ -2653,6 +2688,18 @@ public class MainActivity extends Activity { } } /** * setDecorFitsSystemWindows for build >=R * @return if the operation successful or not */ public boolean setDecorFitsSystemWindows(boolean decorFitsSystemWindows) { if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { getWindow().setDecorFitsSystemWindows(decorFitsSystemWindows); return true; } return false; } /** Sets the brightness level for normal operation (when camera preview is visible). * If force_max is true, this always forces maximum brightness; otherwise this depends on user preference. */ Loading Loading @@ -2823,6 +2870,7 @@ public class MainActivity extends Activity { } setImmersiveMode(false); setDecorFitsSystemWindows(true); camera_in_background = true; // we disable location listening when showing settings or a dialog etc - saves battery life, also better for privacy Loading app/src/main/java/net/sourceforge/opencamera/preview/Preview.java +24 −2 Original line number Diff line number Diff line package net.sourceforge.opencamera.preview; import net.sourceforge.opencamera.MainActivity; import net.sourceforge.opencamera.cameracontroller.RawImage; //import net.sourceforge.opencamera.MainActivity; import net.sourceforge.opencamera.MyDebug; import foundation.e.camera.R; Loading Loading @@ -3470,6 +3470,21 @@ 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 @@ -3503,6 +3518,7 @@ 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) { Loading @@ -3524,8 +3540,12 @@ 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 (MyDebug.LOG) { Log.d(TAG, "chose optimalSize: " + optimalSize.width + " x " + optimalSize.height); Log.d(TAG, "optimalSize ratio: " + ((double) optimalSize.width / optimalSize.height)); Loading Loading @@ -4315,12 +4335,14 @@ public class Preview implements SurfaceHolder.Callback, TextureView.SurfaceTextu } else { if (this.isOnTimer()) { cancelTimer(); ((MainActivity)getContext()).setDecorFitsSystemWindows(true); this.is_video = true; } else if (this.phase == PHASE_TAKING_PHOTO) { // wait until photo taken if (MyDebug.LOG) Log.d(TAG, "wait until photo taken"); } else { ((MainActivity)getContext()).setDecorFitsSystemWindows(true); this.is_video = true; } } Loading Loading
app/build.gradle +2 −2 Original line number Diff line number Diff line apply plugin: 'com.android.application' android { compileSdkVersion 29 compileSdkVersion 30 compileOptions.encoding = 'UTF-8' compileOptions { Loading @@ -12,7 +12,7 @@ android { defaultConfig { applicationId "foundation.e.camera" minSdkVersion 21 targetSdkVersion 29 targetSdkVersion 30 renderscriptTargetApi 21 //renderscriptSupportModeEnabled true // don't use support library as it bloats the APK, and we don't need pre-4.4 support Loading
app/src/main/java/net/sourceforge/opencamera/MainActivity.java +48 −0 Original line number Diff line number Diff line Loading @@ -651,13 +651,48 @@ public class MainActivity extends Activity { notificationManager.createNotificationChannel(channel); } calculateNavigationGap(); if( MyDebug.LOG ) Log.d(TAG, "onCreate: total time for Activity startup: " + (System.currentTimeMillis() - debug_time)); } /** * if navigationMode is no gesture, then retrieve navigationBar's height & update navigation_gap */ private void calculateNavigationGap() { int resourceId = getResources().getIdentifier("config_navBarInteractionMode", "integer", "android"); if (resourceId > 0) { int navType = getResources().getInteger(resourceId); if (navType != 2) { //gesture mode = 2 resourceId = getResources().getIdentifier("navigation_bar_height", "dimen", "android"); if (resourceId > 0) { navigation_gap = getResources().getDimensionPixelSize(resourceId); } } } } public void handleDecorFitsSystemWindows() { setDecorFitsSystemWindows(!isInFullScreenMode()); } /** * check is the preview size = maximise && is not in video mode, then return true */ public boolean isInFullScreenMode() { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); String preview_size = sharedPreferences.getString(PreferenceKeys.PreviewSizePreferenceKey, "preference_preview_size_display"); return !(preview_size.equals("preference_preview_size_wysiwyg") || preview.isVideo()); } /** * if sdk>=R & not in full screen, means the DecorFitsSystemWindows=true, then we can ignore navigationGap. */ public int getNavigationGap() { if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && !isInFullScreenMode()) { return 0; } return want_no_limits ? navigation_gap : 0; } Loading Loading @@ -2653,6 +2688,18 @@ public class MainActivity extends Activity { } } /** * setDecorFitsSystemWindows for build >=R * @return if the operation successful or not */ public boolean setDecorFitsSystemWindows(boolean decorFitsSystemWindows) { if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { getWindow().setDecorFitsSystemWindows(decorFitsSystemWindows); return true; } return false; } /** Sets the brightness level for normal operation (when camera preview is visible). * If force_max is true, this always forces maximum brightness; otherwise this depends on user preference. */ Loading Loading @@ -2823,6 +2870,7 @@ public class MainActivity extends Activity { } setImmersiveMode(false); setDecorFitsSystemWindows(true); camera_in_background = true; // we disable location listening when showing settings or a dialog etc - saves battery life, also better for privacy Loading
app/src/main/java/net/sourceforge/opencamera/preview/Preview.java +24 −2 Original line number Diff line number Diff line package net.sourceforge.opencamera.preview; import net.sourceforge.opencamera.MainActivity; import net.sourceforge.opencamera.cameracontroller.RawImage; //import net.sourceforge.opencamera.MainActivity; import net.sourceforge.opencamera.MyDebug; import foundation.e.camera.R; Loading Loading @@ -3470,6 +3470,21 @@ 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 @@ -3503,6 +3518,7 @@ 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) { Loading @@ -3524,8 +3540,12 @@ 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 (MyDebug.LOG) { Log.d(TAG, "chose optimalSize: " + optimalSize.width + " x " + optimalSize.height); Log.d(TAG, "optimalSize ratio: " + ((double) optimalSize.width / optimalSize.height)); Loading Loading @@ -4315,12 +4335,14 @@ public class Preview implements SurfaceHolder.Callback, TextureView.SurfaceTextu } else { if (this.isOnTimer()) { cancelTimer(); ((MainActivity)getContext()).setDecorFitsSystemWindows(true); this.is_video = true; } else if (this.phase == PHASE_TAKING_PHOTO) { // wait until photo taken if (MyDebug.LOG) Log.d(TAG, "wait until photo taken"); } else { ((MainActivity)getContext()).setDecorFitsSystemWindows(true); this.is_video = true; } } Loading