From 613e5983b0f9e12fdade72248081262e3e3a236e Mon Sep 17 00:00:00 2001 From: althafvly Date: Thu, 15 Feb 2024 22:14:43 +0530 Subject: [PATCH 1/2] camera: Turn off max brightness by default --- .../java/net/sourceforge/opencamera/MainActivity.java | 9 ++++++++- app/src/main/res/xml/preferences.xml | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/net/sourceforge/opencamera/MainActivity.java b/app/src/main/java/net/sourceforge/opencamera/MainActivity.java index 3d46eddbb..cdd0ef579 100644 --- a/app/src/main/java/net/sourceforge/opencamera/MainActivity.java +++ b/app/src/main/java/net/sourceforge/opencamera/MainActivity.java @@ -385,6 +385,13 @@ public class MainActivity extends AppCompatActivity { editor.apply(); } + boolean isFirstTimeMaxBrightness = sharedPreferences.getBoolean("isFirstTimeMaxBrightness", true); + if (isFirstTimeMaxBrightness) { + editor.putBoolean(PreferenceKeys.MaxBrightnessPreferenceKey, false); + editor.putBoolean("isFirstTimeMaxBrightness", false); + editor.apply(); + } + // set up sensors mSensorManager = (SensorManager)getSystemService(Context.SENSOR_SERVICE); @@ -3906,7 +3913,7 @@ public class MainActivity extends AppCompatActivity { // done here rather than onCreate, so that changing it in preferences takes effect without restarting app SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); final WindowManager.LayoutParams layout = getWindow().getAttributes(); - if( force_max || sharedPreferences.getBoolean(PreferenceKeys.MaxBrightnessPreferenceKey, true) ) { + if( force_max || sharedPreferences.getBoolean(PreferenceKeys.MaxBrightnessPreferenceKey, false) ) { layout.screenBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_FULL; } else { diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index d3d45529e..af7a51542 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -698,7 +698,7 @@ android:key="preference_max_brightness" android:title="@string/preference_max_brightness" android:summary="@string/preference_max_brightness_summary" - android:defaultValue="true" + android:defaultValue="false" /> -- GitLab From 818f19d396e375367d9264b93102d95157a5c836 Mon Sep 17 00:00:00 2001 From: althafvly Date: Thu, 15 Feb 2024 22:41:10 +0530 Subject: [PATCH 2/2] camera: Use a switch case for future changes --- .../sourceforge/opencamera/MainActivity.java | 42 +++++++++---------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/app/src/main/java/net/sourceforge/opencamera/MainActivity.java b/app/src/main/java/net/sourceforge/opencamera/MainActivity.java index cdd0ef579..8b0bffe86 100644 --- a/app/src/main/java/net/sourceforge/opencamera/MainActivity.java +++ b/app/src/main/java/net/sourceforge/opencamera/MainActivity.java @@ -367,30 +367,28 @@ public class MainActivity extends AppCompatActivity { Log.d(TAG, "onCreate: time after updating folder history: " + (System.currentTimeMillis() - debug_time)); SharedPreferences.Editor editor = sharedPreferences.edit(); - if (DeviceSettings.isMurenaOne()) { - boolean isFirstTime = sharedPreferences.getBoolean("isFirstTimeMurenaOne", true); - if (isFirstTime && applicationInterface.getEdgeModePref().equals("default")) { - editor.putString(PreferenceKeys.EdgeModePreferenceKey, "off"); - editor.putBoolean("isFirstTimeMurenaOne", false); - editor.apply(); - } - } - - boolean isFirstTimeSaveLocation = sharedPreferences.getBoolean("isFirstTimeSaveLocation", true); - String save_location = sharedPreferences.getString(PreferenceKeys.SaveLocationPreferenceKey, "Camera"); - - if (isFirstTimeSaveLocation && save_location.equals("OpenCamera")) { - editor.putString(PreferenceKeys.SaveLocationPreferenceKey, "Camera"); - editor.putBoolean("isFirstTimeSaveLocation", false); - editor.apply(); + int isFirstTime = sharedPreferences.getInt("isFirstTimeChange", 0); + switch (isFirstTime) { + case 0: + String edge_pref = applicationInterface.getEdgeModePref(); + if (DeviceSettings.isMurenaOne() && edge_pref.equals("default")) { + editor.putString(PreferenceKeys.EdgeModePreferenceKey, "off"); + } + String save_location = sharedPreferences.getString( + PreferenceKeys.SaveLocationPreferenceKey, "Camera"); + if (save_location.equals("OpenCamera")) { + editor.putString(PreferenceKeys.SaveLocationPreferenceKey, "Camera"); + } + isFirstTime++; + case 1: + editor.putBoolean(PreferenceKeys.MaxBrightnessPreferenceKey, false); + isFirstTime++; + break; + default: + break; } - boolean isFirstTimeMaxBrightness = sharedPreferences.getBoolean("isFirstTimeMaxBrightness", true); - if (isFirstTimeMaxBrightness) { - editor.putBoolean(PreferenceKeys.MaxBrightnessPreferenceKey, false); - editor.putBoolean("isFirstTimeMaxBrightness", false); - editor.apply(); - } + editor.putInt("isFirstTimeChange", isFirstTime).apply(); // set up sensors mSensorManager = (SensorManager)getSystemService(Context.SENSOR_SERVICE); -- GitLab