Loading app/src/main/java/net/sourceforge/opencamera/ImageSaver.java +32 −1 Original line number Diff line number Diff line Loading @@ -81,6 +81,11 @@ public class ImageSaver extends Thread { private final static int queue_cost_dng_c = 6; //private final static int queue_cost_dng_c = 1; // Should be same as MainActivity.app_is_paused, but we keep our own copy to make threading easier (otherwise, all // accesses of MainActivity.app_is_paused would need to be synchronized). // Access to app_is_paused should always be synchronized to this (i.e., the ImageSaver class). private boolean app_is_paused = true; // for testing; must be volatile for test project reading the state // n.b., avoid using static, as static variables are shared between different instances of an application, // and won't be reset in subsequent tests in a suite! Loading Loading @@ -436,6 +441,22 @@ public class ImageSaver extends Thread { return n_real_images_to_save; } /** Application has paused. */ void onPause() { synchronized(this) { app_is_paused = true; } } /** Application has resumed. */ void onResume() { synchronized(this) { app_is_paused = false; } } void onDestroy() { if( MyDebug.LOG ) Log.d(TAG, "onDestroy"); Loading Loading @@ -2132,9 +2153,19 @@ public class ImageSaver extends Thread { Address address = null; if( request.store_location && !request.preference_stamp_geo_address.equals("preference_stamp_geo_address_no") ) { boolean block_geocoder; synchronized(this) { block_geocoder = app_is_paused; } // try to find an address // n.b., if we update the class being used, consider whether the info on Geocoder in preference_stamp_geo_address_summary needs updating if( Geocoder.isPresent() ) { if( block_geocoder ) { // seems safer to not try to initiate potential network connections (via geocoder) if Open Camera // has paused and we're still saving images if( MyDebug.LOG ) Log.d(TAG, "don't call geocoder for photostamp as app is paused"); } else if( Geocoder.isPresent() ) { if( MyDebug.LOG ) Log.d(TAG, "geocoder is present"); Geocoder geocoder = new Geocoder(main_activity, Locale.getDefault()); Loading app/src/main/java/net/sourceforge/opencamera/MainActivity.java +2 −0 Original line number Diff line number Diff line Loading @@ -1395,6 +1395,7 @@ public class MainActivity extends Activity { speechControl.initSpeechRecognizer(); initLocation(); initGyroSensors(); applicationInterface.getImageSaver().onResume(); soundPoolManager.initSound(); soundPoolManager.loadSound(R.raw.mybeep); soundPoolManager.loadSound(R.raw.mybeep_hi); Loading Loading @@ -1485,6 +1486,7 @@ public class MainActivity extends Activity { applicationInterface.getLocationSupplier().freeLocationListeners(); applicationInterface.stopPanorama(true); // in practice not needed as we should stop panorama when camera is closed, but good to do it explicitly here, before disabling the gyro sensors applicationInterface.getGyroSensor().disableSensors(); applicationInterface.getImageSaver().onPause(); soundPoolManager.releaseSound(); applicationInterface.clearLastImages(); // this should happen when pausing the preview, but call explicitly just to be safe applicationInterface.getDrawPreview().clearGhostImage(); Loading app/src/main/java/net/sourceforge/opencamera/MyApplicationInterface.java +7 −1 Original line number Diff line number Diff line Loading @@ -2026,7 +2026,13 @@ public class MyApplicationInterface extends BasicApplicationInterface { Address address = null; if( store_location && !preference_stamp_geo_address.equals("preference_stamp_geo_address_no") ) { // try to find an address if( Geocoder.isPresent() ) { if( main_activity.isAppPaused() ) { // seems safer to not try to initiate potential network connections (via geocoder) if Open Camera // is paused - this shouldn't happen, since we stop video when paused, but just to be safe if( MyDebug.LOG ) Log.d(TAG, "don't call geocoder for video subtitles as app is paused?!"); } else if( Geocoder.isPresent() ) { if( MyDebug.LOG ) Log.d(TAG, "geocoder is present"); Geocoder geocoder = new Geocoder(main_activity, Locale.getDefault()); Loading Loading
app/src/main/java/net/sourceforge/opencamera/ImageSaver.java +32 −1 Original line number Diff line number Diff line Loading @@ -81,6 +81,11 @@ public class ImageSaver extends Thread { private final static int queue_cost_dng_c = 6; //private final static int queue_cost_dng_c = 1; // Should be same as MainActivity.app_is_paused, but we keep our own copy to make threading easier (otherwise, all // accesses of MainActivity.app_is_paused would need to be synchronized). // Access to app_is_paused should always be synchronized to this (i.e., the ImageSaver class). private boolean app_is_paused = true; // for testing; must be volatile for test project reading the state // n.b., avoid using static, as static variables are shared between different instances of an application, // and won't be reset in subsequent tests in a suite! Loading Loading @@ -436,6 +441,22 @@ public class ImageSaver extends Thread { return n_real_images_to_save; } /** Application has paused. */ void onPause() { synchronized(this) { app_is_paused = true; } } /** Application has resumed. */ void onResume() { synchronized(this) { app_is_paused = false; } } void onDestroy() { if( MyDebug.LOG ) Log.d(TAG, "onDestroy"); Loading Loading @@ -2132,9 +2153,19 @@ public class ImageSaver extends Thread { Address address = null; if( request.store_location && !request.preference_stamp_geo_address.equals("preference_stamp_geo_address_no") ) { boolean block_geocoder; synchronized(this) { block_geocoder = app_is_paused; } // try to find an address // n.b., if we update the class being used, consider whether the info on Geocoder in preference_stamp_geo_address_summary needs updating if( Geocoder.isPresent() ) { if( block_geocoder ) { // seems safer to not try to initiate potential network connections (via geocoder) if Open Camera // has paused and we're still saving images if( MyDebug.LOG ) Log.d(TAG, "don't call geocoder for photostamp as app is paused"); } else if( Geocoder.isPresent() ) { if( MyDebug.LOG ) Log.d(TAG, "geocoder is present"); Geocoder geocoder = new Geocoder(main_activity, Locale.getDefault()); Loading
app/src/main/java/net/sourceforge/opencamera/MainActivity.java +2 −0 Original line number Diff line number Diff line Loading @@ -1395,6 +1395,7 @@ public class MainActivity extends Activity { speechControl.initSpeechRecognizer(); initLocation(); initGyroSensors(); applicationInterface.getImageSaver().onResume(); soundPoolManager.initSound(); soundPoolManager.loadSound(R.raw.mybeep); soundPoolManager.loadSound(R.raw.mybeep_hi); Loading Loading @@ -1485,6 +1486,7 @@ public class MainActivity extends Activity { applicationInterface.getLocationSupplier().freeLocationListeners(); applicationInterface.stopPanorama(true); // in practice not needed as we should stop panorama when camera is closed, but good to do it explicitly here, before disabling the gyro sensors applicationInterface.getGyroSensor().disableSensors(); applicationInterface.getImageSaver().onPause(); soundPoolManager.releaseSound(); applicationInterface.clearLastImages(); // this should happen when pausing the preview, but call explicitly just to be safe applicationInterface.getDrawPreview().clearGhostImage(); Loading
app/src/main/java/net/sourceforge/opencamera/MyApplicationInterface.java +7 −1 Original line number Diff line number Diff line Loading @@ -2026,7 +2026,13 @@ public class MyApplicationInterface extends BasicApplicationInterface { Address address = null; if( store_location && !preference_stamp_geo_address.equals("preference_stamp_geo_address_no") ) { // try to find an address if( Geocoder.isPresent() ) { if( main_activity.isAppPaused() ) { // seems safer to not try to initiate potential network connections (via geocoder) if Open Camera // is paused - this shouldn't happen, since we stop video when paused, but just to be safe if( MyDebug.LOG ) Log.d(TAG, "don't call geocoder for video subtitles as app is paused?!"); } else if( Geocoder.isPresent() ) { if( MyDebug.LOG ) Log.d(TAG, "geocoder is present"); Geocoder geocoder = new Geocoder(main_activity, Locale.getDefault()); Loading