diff --git a/app/src/androidTest/java/net/sourceforge/opencamera/test/MainActivityTest.java b/app/src/androidTest/java/net/sourceforge/opencamera/test/MainActivityTest.java index fe0b6853338ec7505033cedaed43bb41b1bd386d..95a0289533fe8d3d1fd550a317eea9b6ec40afb9 100644 --- a/app/src/androidTest/java/net/sourceforge/opencamera/test/MainActivityTest.java +++ b/app/src/androidTest/java/net/sourceforge/opencamera/test/MainActivityTest.java @@ -4696,275 +4696,6 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2 1 ? View.VISIBLE : View.GONE)); - assertEquals(switchMultiCameraButton.getVisibility(), (mActivity.showSwitchMultiCamIcon() ? View.VISIBLE : View.GONE)); - assertEquals(switchVideoButton.getVisibility(), View.VISIBLE); - int exposureVisibility = exposureButton.getVisibility(); - int exposureLockVisibility = exposureLockButton.getVisibility(); - assertEquals(audioControlButton.getVisibility(), (has_audio_control_button ? View.VISIBLE : View.GONE)); - assertEquals(popupButton.getVisibility(), View.VISIBLE); - assertEquals(trashButton.getVisibility(), View.GONE); - assertEquals(shareButton.getVisibility(), View.GONE); - assertEquals(zoomSeekBar.getVisibility(), View.VISIBLE); - assertEquals(takePhotoButton.getVisibility(), View.VISIBLE); - assertEquals(pauseVideoButton.getVisibility(), View.GONE); - assertEquals(takePhotoVideoButton.getVisibility(), View.GONE); - - // now wait for immersive mode to kick in - Thread.sleep(6000); - assertEquals(switchCameraButton.getVisibility(), View.GONE); - assertEquals(switchMultiCameraButton.getVisibility(), View.GONE); - assertEquals(switchVideoButton.getVisibility(), View.GONE); - assertEquals(exposureButton.getVisibility(), View.GONE); - assertEquals(exposureLockButton.getVisibility(), View.GONE); - assertEquals(audioControlButton.getVisibility(), View.GONE); - assertEquals(popupButton.getVisibility(), View.GONE); - assertEquals(trashButton.getVisibility(), View.GONE); - assertEquals(shareButton.getVisibility(), View.GONE); - assertEquals(zoomSeekBar.getVisibility(), View.GONE); - assertEquals(takePhotoButton.getVisibility(), View.VISIBLE); - assertEquals(pauseVideoButton.getVisibility(), View.GONE); - assertEquals(takePhotoVideoButton.getVisibility(), View.GONE); - - subTestTakePhoto(false, true, true, true, false, false, false, false); - - // test now exited immersive mode - assertEquals(switchCameraButton.getVisibility(), (mPreview.getCameraControllerManager().getNumberOfCameras() > 1 ? View.VISIBLE : View.GONE)); - assertEquals(switchMultiCameraButton.getVisibility(), (mActivity.showSwitchMultiCamIcon() ? View.VISIBLE : View.GONE)); - assertEquals(switchVideoButton.getVisibility(), View.VISIBLE); - assertEquals(exposureButton.getVisibility(), exposureVisibility); - assertEquals(exposureLockButton.getVisibility(), exposureLockVisibility); - assertEquals(audioControlButton.getVisibility(), (has_audio_control_button ? View.VISIBLE : View.GONE)); - assertEquals(popupButton.getVisibility(), View.VISIBLE); - assertEquals(trashButton.getVisibility(), View.GONE); - assertEquals(shareButton.getVisibility(), View.GONE); - assertEquals(zoomSeekBar.getVisibility(), View.VISIBLE); - assertEquals(takePhotoButton.getVisibility(), View.VISIBLE); - assertEquals(pauseVideoButton.getVisibility(), View.GONE); - assertEquals(takePhotoVideoButton.getVisibility(), View.GONE); - - // wait for immersive mode to kick in again - Thread.sleep(6000); - assertEquals(switchCameraButton.getVisibility(), View.GONE); - assertEquals(switchMultiCameraButton.getVisibility(), View.GONE); - assertEquals(switchVideoButton.getVisibility(), View.GONE); - assertEquals(exposureButton.getVisibility(), View.GONE); - assertEquals(exposureLockButton.getVisibility(), View.GONE); - assertEquals(audioControlButton.getVisibility(), View.GONE); - assertEquals(popupButton.getVisibility(), View.GONE); - assertEquals(trashButton.getVisibility(), View.GONE); - assertEquals(shareButton.getVisibility(), View.GONE); - assertEquals(zoomSeekBar.getVisibility(), View.GONE); - assertEquals(takePhotoButton.getVisibility(), View.VISIBLE); - assertEquals(pauseVideoButton.getVisibility(), View.GONE); - assertEquals(takePhotoVideoButton.getVisibility(), View.GONE); - - subTestTakePhotoPreviewPaused(true, false); - - // test now exited immersive mode - assertEquals(switchCameraButton.getVisibility(), (mPreview.getCameraControllerManager().getNumberOfCameras() > 1 ? View.VISIBLE : View.GONE)); - assertEquals(switchMultiCameraButton.getVisibility(), (mActivity.showSwitchMultiCamIcon() ? View.VISIBLE : View.GONE)); - assertEquals(switchVideoButton.getVisibility(), View.VISIBLE); - assertEquals(exposureButton.getVisibility(), exposureVisibility); - assertEquals(exposureLockButton.getVisibility(), exposureLockVisibility); - assertEquals(audioControlButton.getVisibility(), (has_audio_control_button ? View.VISIBLE : View.GONE)); - assertEquals(popupButton.getVisibility(), View.VISIBLE); - assertEquals(trashButton.getVisibility(), View.GONE); - assertEquals(shareButton.getVisibility(), View.GONE); - assertEquals(zoomSeekBar.getVisibility(), View.VISIBLE); - assertEquals(takePhotoButton.getVisibility(), View.VISIBLE); - assertEquals(pauseVideoButton.getVisibility(), View.GONE); - assertEquals(takePhotoVideoButton.getVisibility(), View.GONE); - - // need to switch video before going back to immersive mode - if( !mPreview.isVideo() ) { - clickView(switchVideoButton); - waitUntilCameraOpened(); - } - // test now exited immersive mode - assertEquals(switchCameraButton.getVisibility(), (mPreview.getCameraControllerManager().getNumberOfCameras() > 1 ? View.VISIBLE : View.GONE)); - assertEquals(switchMultiCameraButton.getVisibility(), (mActivity.showSwitchMultiCamIcon() ? View.VISIBLE : View.GONE)); - assertEquals(switchVideoButton.getVisibility(), View.VISIBLE); - assertEquals(exposureButton.getVisibility(), exposureVisibility); - assertEquals(exposureLockButton.getVisibility(), exposureLockVisibility); - assertEquals(audioControlButton.getVisibility(), (has_audio_control_button ? View.VISIBLE : View.GONE)); - assertEquals(popupButton.getVisibility(), View.VISIBLE); - assertEquals(trashButton.getVisibility(), View.GONE); - assertEquals(shareButton.getVisibility(), View.GONE); - assertEquals(zoomSeekBar.getVisibility(), View.VISIBLE); - assertEquals(takePhotoButton.getVisibility(), View.VISIBLE); - assertEquals(pauseVideoButton.getVisibility(), View.GONE); - assertEquals(takePhotoVideoButton.getVisibility(), View.GONE); - - // wait for immersive mode to kick in again - Thread.sleep(6000); - assertEquals(switchCameraButton.getVisibility(), View.GONE); - assertEquals(switchMultiCameraButton.getVisibility(), View.GONE); - assertEquals(switchVideoButton.getVisibility(), View.GONE); - assertEquals(exposureButton.getVisibility(), View.GONE); - assertEquals(exposureLockButton.getVisibility(), View.GONE); - assertEquals(audioControlButton.getVisibility(), View.GONE); - assertEquals(popupButton.getVisibility(), View.GONE); - assertEquals(trashButton.getVisibility(), View.GONE); - assertEquals(shareButton.getVisibility(), View.GONE); - assertEquals(zoomSeekBar.getVisibility(), View.GONE); - assertEquals(takePhotoButton.getVisibility(), View.VISIBLE); - assertEquals(pauseVideoButton.getVisibility(), View.GONE); - assertEquals(takePhotoVideoButton.getVisibility(), View.GONE); - - subTestTakeVideo(false, false, false, true, null, 5000, false, 0); - - // test touch exits immersive mode - TouchUtils.clickView(MainActivityTest.this, mPreview.getView()); - assertEquals(switchCameraButton.getVisibility(), (mPreview.getCameraControllerManager().getNumberOfCameras() > 1 ? View.VISIBLE : View.GONE)); - assertEquals(switchMultiCameraButton.getVisibility(), (mActivity.showSwitchMultiCamIcon() ? View.VISIBLE : View.GONE)); - assertEquals(switchVideoButton.getVisibility(), View.VISIBLE); - assertEquals(exposureButton.getVisibility(), exposureVisibility); - assertEquals(exposureLockButton.getVisibility(), exposureLockVisibility); - assertEquals(audioControlButton.getVisibility(), (has_audio_control_button ? View.VISIBLE : View.GONE)); - assertEquals(popupButton.getVisibility(), View.VISIBLE); - assertEquals(trashButton.getVisibility(), View.GONE); - assertEquals(shareButton.getVisibility(), View.GONE); - assertEquals(zoomSeekBar.getVisibility(), View.VISIBLE); - assertEquals(takePhotoButton.getVisibility(), View.VISIBLE); - assertEquals(pauseVideoButton.getVisibility(), View.GONE); - assertEquals(takePhotoVideoButton.getVisibility(), View.GONE); - - // switch back to photo mode - if( mPreview.isVideo() ) { - clickView(switchVideoButton); - waitUntilCameraOpened(); - } - - if( mPreview.usingCamera2API() && mPreview.supportsISORange() ) { - // now test exposure button disappears when in manual ISO mode - switchToISO(100); - - // wait for immersive mode to kick in again - Thread.sleep(6000); - assertEquals(switchCameraButton.getVisibility(), View.GONE); - assertEquals(switchMultiCameraButton.getVisibility(), View.GONE); - assertEquals(switchVideoButton.getVisibility(), View.GONE); - assertEquals(exposureButton.getVisibility(), View.GONE); - assertEquals(exposureLockButton.getVisibility(), View.GONE); - assertEquals(audioControlButton.getVisibility(), View.GONE); - assertEquals(popupButton.getVisibility(), View.GONE); - assertEquals(trashButton.getVisibility(), View.GONE); - assertEquals(shareButton.getVisibility(), View.GONE); - assertEquals(zoomSeekBar.getVisibility(), View.GONE); - assertEquals(takePhotoButton.getVisibility(), View.VISIBLE); - assertEquals(pauseVideoButton.getVisibility(), View.GONE); - assertEquals(takePhotoVideoButton.getVisibility(), View.GONE); - } - } - - // See note under testImmersiveMode() if this fails with a SecurityException about needing INJECT_EVENTS permission. - public void testImmersiveModeEverything() throws InterruptedException { - Log.d(TAG, "testImmersiveModeEverything"); - - if( Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT ) { - Log.d(TAG, "immersive mode requires Android Kitkat or better"); - return; - } - - setToDefault(); - SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(mActivity); - SharedPreferences.Editor editor = settings.edit(); - editor.putString(PreferenceKeys.ImmersiveModePreferenceKey, "immersive_mode_everything"); - editor.apply(); - updateForSettings(); - - View switchCameraButton = mActivity.findViewById(net.sourceforge.opencamera.R.id.switch_camera); - View switchMultiCameraButton = mActivity.findViewById(net.sourceforge.opencamera.R.id.switch_multi_camera); - View switchVideoButton = mActivity.findViewById(net.sourceforge.opencamera.R.id.switch_video); - View exposureButton = mActivity.findViewById(net.sourceforge.opencamera.R.id.exposure); - View exposureLockButton = mActivity.findViewById(net.sourceforge.opencamera.R.id.exposure_lock); - View popupButton = mActivity.findViewById(net.sourceforge.opencamera.R.id.popup); - View trashButton = mActivity.findViewById(net.sourceforge.opencamera.R.id.trash); - View shareButton = mActivity.findViewById(net.sourceforge.opencamera.R.id.share); - View takePhotoButton = mActivity.findViewById(net.sourceforge.opencamera.R.id.take_photo); - View pauseVideoButton = mActivity.findViewById(net.sourceforge.opencamera.R.id.pause_video); - View takePhotoVideoButton = mActivity.findViewById(net.sourceforge.opencamera.R.id.take_photo_when_video_recording); - View zoomSeekBar = mActivity.findViewById(net.sourceforge.opencamera.R.id.zoom_seekbar); - assertEquals(switchCameraButton.getVisibility(), (mPreview.getCameraControllerManager().getNumberOfCameras() > 1 ? View.VISIBLE : View.GONE)); - assertEquals(switchMultiCameraButton.getVisibility(), (mActivity.showSwitchMultiCamIcon() ? View.VISIBLE : View.GONE)); - assertEquals(switchVideoButton.getVisibility(), View.VISIBLE); - int exposureVisibility = exposureButton.getVisibility(); - int exposureLockVisibility = exposureLockButton.getVisibility(); - assertEquals(popupButton.getVisibility(), View.VISIBLE); - assertEquals(trashButton.getVisibility(), View.GONE); - assertEquals(shareButton.getVisibility(), View.GONE); - assertEquals(zoomSeekBar.getVisibility(), View.VISIBLE); - assertEquals(takePhotoButton.getVisibility(), View.VISIBLE); - assertEquals(pauseVideoButton.getVisibility(), View.GONE); - assertEquals(takePhotoVideoButton.getVisibility(), View.GONE); - - // now wait for immersive mode to kick in - Thread.sleep(6000); - assertEquals(switchCameraButton.getVisibility(), View.GONE); - assertEquals(switchMultiCameraButton.getVisibility(), View.GONE); - assertEquals(switchVideoButton.getVisibility(), View.GONE); - assertEquals(exposureButton.getVisibility(), View.GONE); - assertEquals(exposureLockButton.getVisibility(), View.GONE); - assertEquals(popupButton.getVisibility(), View.GONE); - assertEquals(trashButton.getVisibility(), View.GONE); - assertEquals(shareButton.getVisibility(), View.GONE); - assertEquals(zoomSeekBar.getVisibility(), View.GONE); - assertEquals(takePhotoButton.getVisibility(), View.GONE); - assertEquals(pauseVideoButton.getVisibility(), View.GONE); - assertEquals(takePhotoVideoButton.getVisibility(), View.GONE); - - // now touch to exit immersive mode - TouchUtils.clickView(MainActivityTest.this, mPreview.getView()); - Thread.sleep(500); - - // test now exited immersive mode - assertEquals(switchCameraButton.getVisibility(), (mPreview.getCameraControllerManager().getNumberOfCameras() > 1 ? View.VISIBLE : View.GONE)); - assertEquals(switchMultiCameraButton.getVisibility(), (mActivity.showSwitchMultiCamIcon() ? View.VISIBLE : View.GONE)); - assertEquals(switchVideoButton.getVisibility(), View.VISIBLE); - assertEquals(exposureButton.getVisibility(), exposureVisibility); - assertEquals(exposureLockButton.getVisibility(), exposureLockVisibility); - assertEquals(popupButton.getVisibility(), View.VISIBLE); - assertEquals(trashButton.getVisibility(), View.GONE); - assertEquals(shareButton.getVisibility(), View.GONE); - assertEquals(zoomSeekBar.getVisibility(), View.VISIBLE); - assertEquals(takePhotoButton.getVisibility(), View.VISIBLE); - assertEquals(pauseVideoButton.getVisibility(), View.GONE); - assertEquals(takePhotoVideoButton.getVisibility(), View.GONE); - } - /** Tests the use of the FLAG_LAYOUT_NO_LIMITS flag introduced in 1.48. */ public void testLayoutNoLimits() throws InterruptedException { diff --git a/app/src/main/java/net/sourceforge/opencamera/MainActivity.java b/app/src/main/java/net/sourceforge/opencamera/MainActivity.java index 632cb693c5b808c862bb380028cf1a58df502080..adf98555d7bc73f9b42fc27c32fc6bc0ca7d3875 100644 --- a/app/src/main/java/net/sourceforge/opencamera/MainActivity.java +++ b/app/src/main/java/net/sourceforge/opencamera/MainActivity.java @@ -1,34 +1,29 @@ package net.sourceforge.opencamera; -import net.sourceforge.opencamera.cameracontroller.CameraController; -import net.sourceforge.opencamera.cameracontroller.CameraControllerManager; -import net.sourceforge.opencamera.cameracontroller.CameraControllerManager2; -import net.sourceforge.opencamera.preview.Preview; -import net.sourceforge.opencamera.preview.VideoProfile; -import net.sourceforge.opencamera.remotecontrol.BluetoothRemoteControl; -import net.sourceforge.opencamera.ui.CircleImageView; -import net.sourceforge.opencamera.ui.FolderChooserDialog; -import net.sourceforge.opencamera.ui.MainUI; -import net.sourceforge.opencamera.ui.ManualSeekbars; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.text.DecimalFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; - import android.Manifest; +import android.animation.ArgbEvaluator; +import android.animation.ValueAnimator; +import android.annotation.SuppressLint; +import android.annotation.TargetApi; +import android.app.Activity; +import android.app.ActivityManager; +import android.app.AlertDialog; +import android.app.KeyguardManager; import android.app.Notification; import android.app.NotificationChannel; import android.app.NotificationManager; +import android.content.ActivityNotFoundException; import android.content.BroadcastReceiver; +import android.content.ContentResolver; +import android.content.Context; +import android.content.DialogInterface; +import android.content.Intent; import android.content.IntentFilter; +import android.content.SharedPreferences; +import android.content.pm.ActivityInfo; import android.content.pm.PackageInfo; +import android.content.pm.PackageManager; +import android.content.res.Configuration; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Color; @@ -47,28 +42,8 @@ import android.os.Handler; import android.os.ParcelFileDescriptor; import android.preference.PreferenceManager; import android.provider.MediaStore; -import android.animation.ArgbEvaluator; -import android.animation.ValueAnimator; -import android.annotation.SuppressLint; -import android.annotation.TargetApi; -import android.app.Activity; -import android.app.ActivityManager; -import android.app.AlertDialog; -import android.app.KeyguardManager; -import android.content.ActivityNotFoundException; -import android.content.ContentResolver; -import android.content.Context; -import android.content.DialogInterface; -import android.content.Intent; -import android.content.SharedPreferences; -import android.content.pm.ActivityInfo; -import android.content.pm.PackageManager; -import android.content.res.Configuration; import android.renderscript.RenderScript; import android.speech.tts.TextToSpeech; -import androidx.annotation.ColorInt; -import androidx.annotation.NonNull; -import androidx.core.content.ContextCompat; import android.util.Log; import android.view.Display; import android.view.GestureDetector; @@ -87,11 +62,36 @@ import android.widget.EditText; import android.widget.ImageButton; import android.widget.SeekBar; import android.widget.SeekBar.OnSeekBarChangeListener; -import android.widget.ZoomControls; + +import androidx.annotation.NonNull; +import androidx.core.content.ContextCompat; + +import net.sourceforge.opencamera.cameracontroller.CameraController; +import net.sourceforge.opencamera.cameracontroller.CameraControllerManager; +import net.sourceforge.opencamera.cameracontroller.CameraControllerManager2; +import net.sourceforge.opencamera.preview.Preview; +import net.sourceforge.opencamera.preview.VideoProfile; +import net.sourceforge.opencamera.remotecontrol.BluetoothRemoteControl; +import net.sourceforge.opencamera.ui.CircleImageView; +import net.sourceforge.opencamera.ui.FolderChooserDialog; +import net.sourceforge.opencamera.ui.MainUI; +import net.sourceforge.opencamera.ui.ManualSeekbars; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; import foundation.e.camera.R; -/** The main Activity for Open Camera. +/** + * The main Activity for Open Camera. */ public class MainActivity extends Activity { private static final String TAG = "MainActivity"; @@ -509,44 +509,6 @@ public class MainActivity extends Activity { } }); } - - // set up listener to handle immersive mode options - decorView.setOnSystemUiVisibilityChangeListener - (new View.OnSystemUiVisibilityChangeListener() { - @Override - public void onSystemUiVisibilityChange(int visibility) { - // Note that system bars will only be "visible" if none of the - // LOW_PROFILE, HIDE_NAVIGATION, or FULLSCREEN flags are set. - if( !usingKitKatImmersiveMode() ) - return; - if( MyDebug.LOG ) - Log.d(TAG, "onSystemUiVisibilityChange: " + visibility); - - SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(MainActivity.this); - String immersive_mode = sharedPreferences.getString(PreferenceKeys.ImmersiveModePreferenceKey, "immersive_mode_low_profile"); - boolean hide_ui = immersive_mode.equals("immersive_mode_gui") || immersive_mode.equals("immersive_mode_everything"); - - if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) { - if( MyDebug.LOG ) - Log.d(TAG, "system bars now visible"); - // The system bars are visible. Make any desired - // adjustments to your UI, such as showing the action bar or - // other navigational controls. - if( hide_ui ) - mainUI.setImmersiveMode(false); - setImmersiveTimer(); - } - else { - if( MyDebug.LOG ) - Log.d(TAG, "system bars now NOT visible"); - // The system bars are NOT visible. Make any desired - // adjustments to your UI, such as hiding the action bar or - // other navigational controls. - if( hide_ui ) - mainUI.setImmersiveMode(true); - } - } - }); if( MyDebug.LOG ) Log.d(TAG, "onCreate: time after setting immersive mode listener: " + (System.currentTimeMillis() - debug_time)); @@ -2676,82 +2638,19 @@ public class MainActivity extends Activity { super.onBackPressed(); } - public boolean usingKitKatImmersiveMode() { - // whether we are using a Kit Kat style immersive mode (either hiding GUI, or everything) - if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT ) { - SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); - String immersive_mode = sharedPreferences.getString(PreferenceKeys.ImmersiveModePreferenceKey, "immersive_mode_low_profile"); - if( immersive_mode.equals("immersive_mode_navigation") || immersive_mode.equals("immersive_mode_gui") || immersive_mode.equals("immersive_mode_everything") ) - return true; - } - return false; - } - public boolean usingKitKatImmersiveModeEverything() { - // whether we are using a Kit Kat style immersive mode for everything - if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT ) { - SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); - String immersive_mode = sharedPreferences.getString(PreferenceKeys.ImmersiveModePreferenceKey, "immersive_mode_low_profile"); - if( immersive_mode.equals("immersive_mode_everything") ) - return true; - } - return false; - } - - - private Handler immersive_timer_handler = null; - private Runnable immersive_timer_runnable = null; - - private void setImmersiveTimer() { - if( immersive_timer_handler != null && immersive_timer_runnable != null ) { - immersive_timer_handler.removeCallbacks(immersive_timer_runnable); - } - immersive_timer_handler = new Handler(); - immersive_timer_handler.postDelayed(immersive_timer_runnable = new Runnable(){ - @Override - public void run(){ - if( MyDebug.LOG ) - Log.d(TAG, "setImmersiveTimer: run"); - if( !camera_in_background && !popupIsOpen() && usingKitKatImmersiveMode() ) - setImmersiveMode(true); - } - }, 5000); - } - public void initImmersiveMode() { - if( !usingKitKatImmersiveMode() ) { - setImmersiveMode(true); - } - else { - // don't start in immersive mode, only after a timer - setImmersiveTimer(); - } + setImmersiveMode(true); } void setImmersiveMode(boolean on) { if( MyDebug.LOG ) Log.d(TAG, "setImmersiveMode: " + on); // n.b., preview.setImmersiveMode() is called from onSystemUiVisibilityChange() - if( on ) { - if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && usingKitKatImmersiveMode() ) { - if( applicationInterface.getPhotoMode() == MyApplicationInterface.PhotoMode.Panorama ) { - // don't allow the kitkat-style immersive mode for panorama mode (problem that in "full" immersive mode, the gyro spot can't be seen - we could fix this, but simplest to just disallow) - getWindow().getDecorView().setSystemUiVisibility(0); - } - else { - getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_IMMERSIVE | View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN); - } - } - else { - SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); - String immersive_mode = sharedPreferences.getString(PreferenceKeys.ImmersiveModePreferenceKey, "immersive_mode_low_profile"); - if( immersive_mode.equals("immersive_mode_low_profile") ) - getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE); - else - getWindow().getDecorView().setSystemUiVisibility(0); - } - } - else + if (on) { + getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE); + } else { getWindow().getDecorView().setSystemUiVisibility(0); + } } /** Sets the brightness level for normal operation (when camera preview is visible). diff --git a/app/src/main/java/net/sourceforge/opencamera/MyApplicationInterface.java b/app/src/main/java/net/sourceforge/opencamera/MyApplicationInterface.java index 4e1a180da3579cea88139974e77483855484770c..3623718d81733ed616489f907aa1e9efe03dddfd 100644 --- a/app/src/main/java/net/sourceforge/opencamera/MyApplicationInterface.java +++ b/app/src/main/java/net/sourceforge/opencamera/MyApplicationInterface.java @@ -1,33 +1,10 @@ package net.sourceforge.opencamera; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileWriter; -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Date; -import java.util.List; -import java.util.Locale; -import java.util.Timer; -import java.util.TimerTask; - -import net.sourceforge.opencamera.cameracontroller.CameraController; -import net.sourceforge.opencamera.cameracontroller.RawImage; -import net.sourceforge.opencamera.preview.ApplicationInterface; -import net.sourceforge.opencamera.preview.BasicApplicationInterface; -import net.sourceforge.opencamera.preview.Preview; -import net.sourceforge.opencamera.preview.VideoProfile; -import net.sourceforge.opencamera.ui.CircleImageView; -import net.sourceforge.opencamera.ui.DrawPreview; - import android.annotation.TargetApi; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; -import android.content.res.ColorStateList; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Color; @@ -55,6 +32,28 @@ import android.view.MotionEvent; import android.view.View; import android.widget.ImageButton; +import net.sourceforge.opencamera.cameracontroller.CameraController; +import net.sourceforge.opencamera.cameracontroller.RawImage; +import net.sourceforge.opencamera.preview.ApplicationInterface; +import net.sourceforge.opencamera.preview.BasicApplicationInterface; +import net.sourceforge.opencamera.preview.Preview; +import net.sourceforge.opencamera.preview.VideoProfile; +import net.sourceforge.opencamera.ui.CircleImageView; +import net.sourceforge.opencamera.ui.DrawPreview; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileWriter; +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; +import java.util.Locale; +import java.util.Timer; +import java.util.TimerTask; + import foundation.e.camera.R; /** Our implementation of ApplicationInterface, see there for details. @@ -1854,9 +1853,6 @@ public class MyApplicationInterface extends BasicApplicationInterface { public void touchEvent(MotionEvent event) { main_activity.getMainUI().closeExposureUI(); main_activity.getMainUI().closePopup(); - if( main_activity.usingKitKatImmersiveMode() ) { - main_activity.setImmersiveMode(false); - } } @Override @@ -1876,18 +1872,14 @@ public class MyApplicationInterface extends BasicApplicationInterface { public void startedVideo() { if( MyDebug.LOG ) Log.d(TAG, "startedVideo()"); - if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.N ) { - if( !( main_activity.getMainUI().inImmersiveMode() && main_activity.usingKitKatImmersiveModeEverything() ) ) { - View pauseVideoButton = main_activity.findViewById(R.id.pause_video); - pauseVideoButton.setVisibility(View.VISIBLE); - } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + View pauseVideoButton = main_activity.findViewById(R.id.pause_video); + pauseVideoButton.setVisibility(View.VISIBLE); main_activity.getMainUI().setPauseVideoContentDescription(); } - if( main_activity.getPreview().supportsPhotoVideoRecording() && this.usePhotoVideoRecording() ) { - if( !( main_activity.getMainUI().inImmersiveMode() && main_activity.usingKitKatImmersiveModeEverything() ) ) { - View takePhotoVideoButton = main_activity.findViewById(R.id.take_photo_when_video_recording); - takePhotoVideoButton.setVisibility(View.VISIBLE); - } + if (main_activity.getPreview().supportsPhotoVideoRecording() && this.usePhotoVideoRecording()) { + View takePhotoVideoButton = main_activity.findViewById(R.id.take_photo_when_video_recording); + takePhotoVideoButton.setVisibility(View.VISIBLE); } if( main_activity.getMainUI().isExposureUIOpen() ) { if( MyDebug.LOG ) diff --git a/app/src/main/java/net/sourceforge/opencamera/MyPreferenceFragment.java b/app/src/main/java/net/sourceforge/opencamera/MyPreferenceFragment.java index 4785f3f1c7ed29172e068b8de00ad92826a203ee..aa236cdf9581d1b2d3682054102896a25bc0216d 100644 --- a/app/src/main/java/net/sourceforge/opencamera/MyPreferenceFragment.java +++ b/app/src/main/java/net/sourceforge/opencamera/MyPreferenceFragment.java @@ -597,13 +597,6 @@ public class MyPreferenceFragment extends PreferenceFragment implements OnShared pg.removePreference(pref); } - if( Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT ) { - // Some immersive modes require KITKAT - simpler to require Kitkat for any of the menu options - Preference pref = findPreference("preference_immersive_mode"); - PreferenceGroup pg = (PreferenceGroup)this.findPreference("preference_screen_gui"); - pg.removePreference(pref); - } - if( !using_android_l ) { Preference pref = findPreference("preference_focus_assist"); PreferenceGroup pg = (PreferenceGroup)this.findPreference("preference_preview"); diff --git a/app/src/main/java/net/sourceforge/opencamera/PreferenceKeys.java b/app/src/main/java/net/sourceforge/opencamera/PreferenceKeys.java index bb283902b0fcedfeb4828127c5935282853c2207..bb590c8e59e4b44c4f9b4444261468afa7a8af67 100644 --- a/app/src/main/java/net/sourceforge/opencamera/PreferenceKeys.java +++ b/app/src/main/java/net/sourceforge/opencamera/PreferenceKeys.java @@ -350,6 +350,5 @@ public class PreferenceKeys { public static final String ShutterSoundPreferenceKey = "preference_shutter_sound"; - public static final String ImmersiveModePreferenceKey = "preference_immersive_mode"; public static final String AddYPRToComments="preference_comment_ypr"; } diff --git a/app/src/main/java/net/sourceforge/opencamera/ui/DrawPreview.java b/app/src/main/java/net/sourceforge/opencamera/ui/DrawPreview.java index 5b60afc36bef08943b9b33207c36d3023f152ae7..269cf8813a051819f501678b11e8454869e9a016 100644 --- a/app/src/main/java/net/sourceforge/opencamera/ui/DrawPreview.java +++ b/app/src/main/java/net/sourceforge/opencamera/ui/DrawPreview.java @@ -84,7 +84,6 @@ public class DrawPreview { private boolean show_angle_line_pref; private boolean show_pitch_lines_pref; private boolean show_geo_direction_lines_pref; - private boolean immersive_mode_everything_pref; private boolean has_stamp_pref; private boolean is_raw_pref; // whether in RAW+JPEG or RAW only mode private boolean is_raw_only_pref; // whether in RAW only mode @@ -545,9 +544,6 @@ public class DrawPreview { show_pitch_lines_pref = sharedPreferences.getBoolean(PreferenceKeys.ShowPitchLinesPreferenceKey, false); show_geo_direction_lines_pref = sharedPreferences.getBoolean(PreferenceKeys.ShowGeoDirectionLinesPreferenceKey, false); - String immersive_mode = sharedPreferences.getString(PreferenceKeys.ImmersiveModePreferenceKey, "immersive_mode_low_profile"); - immersive_mode_everything_pref = immersive_mode.equals("immersive_mode_everything"); - has_stamp_pref = applicationInterface.getStampPref().equals("preference_stamp_yes"); is_raw_pref = applicationInterface.getRawPref() != ApplicationInterface.RawPref.RAWPREF_JPEG_ONLY; is_raw_only_pref = applicationInterface.isRawOnly(); @@ -2613,15 +2609,6 @@ public class DrawPreview { p.setAlpha(255); } - if( main_activity.getMainUI().inImmersiveMode() ) { - if( immersive_mode_everything_pref ) { - // exit, to ensure we don't display anything! - // though note we still should do the front screen flash (since the user can take photos via volume keys when - // in immersive_mode_everything mode) - return; - } - } - if( camera_controller != null && taking_picture && !front_screen_flash && take_photo_border_pref ) { p.setColor(Color.WHITE); p.setStyle(Paint.Style.STROKE); 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 f8bde7dacbcb66e977a6dc6cbd0b25c728208e37..043fcade5a7065ebac4b9f10cf1963a75eac0a22 100644 --- a/app/src/main/java/net/sourceforge/opencamera/ui/MainUI.java +++ b/app/src/main/java/net/sourceforge/opencamera/ui/MainUI.java @@ -1,16 +1,5 @@ package net.sourceforge.opencamera.ui; -import net.sourceforge.opencamera.MyApplicationInterface; -import net.sourceforge.opencamera.ScaleUtils; -import net.sourceforge.opencamera.cameracontroller.CameraController; -import net.sourceforge.opencamera.MainActivity; -import net.sourceforge.opencamera.MyDebug; -import net.sourceforge.opencamera.PreferenceKeys; -import net.sourceforge.opencamera.preview.ApplicationInterface; -import net.sourceforge.opencamera.preview.Preview; - -import foundation.e.camera.R; - import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; @@ -42,11 +31,22 @@ import android.widget.LinearLayout; import android.widget.RelativeLayout; import android.widget.SeekBar; +import net.sourceforge.opencamera.MainActivity; +import net.sourceforge.opencamera.MyApplicationInterface; +import net.sourceforge.opencamera.MyDebug; +import net.sourceforge.opencamera.PreferenceKeys; +import net.sourceforge.opencamera.ScaleUtils; +import net.sourceforge.opencamera.cameracontroller.CameraController; +import net.sourceforge.opencamera.preview.ApplicationInterface; +import net.sourceforge.opencamera.preview.Preview; + import java.util.ArrayList; import java.util.Hashtable; import java.util.List; import java.util.Map; +import foundation.e.camera.R; + /** * This contains functionality related to the main UI. */ @@ -378,7 +378,7 @@ public class MainUI { }*/ int total_button_size = count * button_size; int margin = 0; - int topMargin = (int)ScaleUtils.convertDpToPx(main_activity, 8.0f); + int topMargin = (int) ScaleUtils.convertDpToPx(main_activity, 8.0f); if (total_button_size > display_height) { if (MyDebug.LOG) Log.d(TAG, "need to reduce button size"); @@ -792,7 +792,7 @@ public class MainUI { if (!sharedPreferences.getBoolean(PreferenceKeys.ShowTakePhotoPreferenceKey, true)) { return; } - + view = main_activity.findViewById(R.id.finish_panorama); view.setVisibility(isPanoramaRunning ? View.VISIBLE : View.GONE); @@ -1055,35 +1055,6 @@ public class MainUI { zoomSeekBar.setVisibility(visibility); zoomSeekbarIcon.setVisibility(visibility); } - String pref_immersive_mode = sharedPreferences.getString(PreferenceKeys.ImmersiveModePreferenceKey, "immersive_mode_low_profile"); - if (pref_immersive_mode.equals("immersive_mode_everything")) { - 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) { // make sure the GUI is set up as expected showGUI(); @@ -1116,10 +1087,6 @@ public class MainUI { } if (inImmersiveMode()) return; - if ((show_gui_photo || show_gui_video) && main_activity.usingKitKatImmersiveMode()) { - // call to reset the timer - main_activity.initImmersiveMode(); - } main_activity.runOnUiThread(new Runnable() { public void run() { final boolean is_panorama_recording = main_activity.getApplicationInterface().getGyroSensor().isRecording(); diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index f78323f6797d6fb21a2ba917e83634845daf80b7..d941e947cd98d6de404ffcba7cfe42d655744062 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -563,16 +563,6 @@ android:icon="@drawable/ic_preference_on_screen_gui" android:persistent="false"> - - -