From 347ecfa28aec5866d5afc58e109e6900f1b2ab2b Mon Sep 17 00:00:00 2001 From: althafvly Date: Fri, 26 May 2023 11:19:05 +0530 Subject: [PATCH] Camera: Change default camera save folder --- .../net/sourceforge/opencamera/MainActivity.java | 14 ++++++++++++-- .../opencamera/MyPreferenceFragment.java | 2 +- .../net/sourceforge/opencamera/StorageUtils.java | 2 +- app/src/main/res/xml/preferences.xml | 2 +- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/net/sourceforge/opencamera/MainActivity.java b/app/src/main/java/net/sourceforge/opencamera/MainActivity.java index fea761ff8..56b14fade 100644 --- a/app/src/main/java/net/sourceforge/opencamera/MainActivity.java +++ b/app/src/main/java/net/sourceforge/opencamera/MainActivity.java @@ -354,6 +354,16 @@ public class MainActivity extends AppCompatActivity { if( MyDebug.LOG ) Log.d(TAG, "onCreate: time after updating folder history: " + (System.currentTimeMillis() - debug_time)); + boolean isFirstTimeSaveLocation = sharedPreferences.getBoolean("isFirstTimeSaveLocation", true); + String save_location = sharedPreferences.getString(PreferenceKeys.SaveLocationPreferenceKey, "Camera"); + + if (isFirstTimeSaveLocation && save_location.equals("OpenCamera")) { + SharedPreferences.Editor editor = sharedPreferences.edit(); + editor.putString(PreferenceKeys.SaveLocationPreferenceKey, "Camera"); + editor.putBoolean("isFirstTimeSaveLocation", false); + editor.apply(); + } + // set up sensors mSensorManager = (SensorManager)getSystemService(Context.SENSOR_SERVICE); @@ -1108,7 +1118,7 @@ public class MainActivity extends AppCompatActivity { String new_folder; if( res.alt == null ) { // no alternative, fall back to default - new_folder = "OpenCamera"; + new_folder = "Camera"; } else { // replace with the alternative @@ -4710,7 +4720,7 @@ public class MainActivity extends AppCompatActivity { editText.setHint(getResources().getString(R.string.preference_save_location)); editText.setInputType(InputType.TYPE_CLASS_TEXT); SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); - editText.setText(sharedPreferences.getString(PreferenceKeys.SaveLocationPreferenceKey, "OpenCamera")); + editText.setText(sharedPreferences.getString(PreferenceKeys.SaveLocationPreferenceKey, "Camera")); InputFilter filter = new InputFilter() { // whilst Android seems to allow any characters on internal memory, SD cards are typically formatted with FAT32 final String disallowed = "|\\?*<\":>"; diff --git a/app/src/main/java/net/sourceforge/opencamera/MyPreferenceFragment.java b/app/src/main/java/net/sourceforge/opencamera/MyPreferenceFragment.java index c1f4d144d..8c91d2005 100644 --- a/app/src/main/java/net/sourceforge/opencamera/MyPreferenceFragment.java +++ b/app/src/main/java/net/sourceforge/opencamera/MyPreferenceFragment.java @@ -1315,7 +1315,7 @@ public class MyPreferenceFragment extends PreferenceFragment implements OnShared about_string.append("\nUsing SAF?: "); about_string.append(sharedPreferences.getBoolean(PreferenceKeys.UsingSAFPreferenceKey, false)); - String save_location = sharedPreferences.getString(PreferenceKeys.SaveLocationPreferenceKey, "OpenCamera"); + String save_location = sharedPreferences.getString(PreferenceKeys.SaveLocationPreferenceKey, "Camera"); about_string.append("\nSave Location: "); about_string.append(save_location); String save_location_saf = sharedPreferences.getString(PreferenceKeys.SaveLocationSAFPreferenceKey, ""); diff --git a/app/src/main/java/net/sourceforge/opencamera/StorageUtils.java b/app/src/main/java/net/sourceforge/opencamera/StorageUtils.java index 35c34f3ba..d8fdc55db 100644 --- a/app/src/main/java/net/sourceforge/opencamera/StorageUtils.java +++ b/app/src/main/java/net/sourceforge/opencamera/StorageUtils.java @@ -338,7 +338,7 @@ public class StorageUtils { // only valid if !isUsingSAF() String getSaveLocation() { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); - return sharedPreferences.getString(PreferenceKeys.SaveLocationPreferenceKey, "OpenCamera"); + return sharedPreferences.getString(PreferenceKeys.SaveLocationPreferenceKey, "Camera"); } // only valid if isUsingSAF() diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index 6019e4588..61ef20b50 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -249,7 +249,7 @@ android:dialogTitle="@string/preference_save_location" android:dialogMessage="@string/preference_save_location_summary" android:inputType="text" - android:defaultValue="OpenCamera" + android:defaultValue="Camera" /> -- GitLab