Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c720b8b9 authored by Mark Harman's avatar Mark Harman
Browse files

Show current save location in preferences.

parent d97506e8
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -62,6 +62,7 @@ UPDATED Smooth zoom transition when using zoom seekbar (for Camera2 API).
UPDATED Removed -/+ controls for zoom and exposure compensation (these "zoom controls" are now
        deprecated in Android).
UPDATED Also hide settings icon when taking a photo.
UPDATED Show current save location in preferences.
UPDATED Don't block UI thread when starting camera preview (for Camera2 API with Android 14+).

Version 1.54.1 (2025/04/07)
+1 −1
Original line number Diff line number Diff line
@@ -5399,7 +5399,7 @@ public class MainActivity extends AppCompatActivity implements PreferenceFragmen

    /** Returns a human readable string for the save_folder (as stored in the preferences).
     */
    private String getHumanReadableSaveFolder(String save_folder) {
    String getHumanReadableSaveFolder(String save_folder) {
        if( applicationInterface.getStorageUtils().isUsingSAF() ) {
            // try to get human readable form if possible
            String file_name = applicationInterface.getStorageUtils().getFilePathFromDocumentUriSAF(Uri.parse(save_folder), true);
+18 −3
Original line number Diff line number Diff line
@@ -1035,7 +1035,6 @@ public class MyPreferenceFragment extends PreferenceFragment implements OnShared
     *  summary.
     */
    static void setSummary(Preference pref) {
        //noinspection DuplicateCondition
        if( pref instanceof EditTextPreference ) {
            /* We have a runtime check for using EditTextPreference - we don't want these due to importance of
             * supporting the Google Play emoji policy (see comment in MyEditTextPreference.java) - and this
@@ -1046,8 +1045,24 @@ public class MyPreferenceFragment extends PreferenceFragment implements OnShared
            throw new RuntimeException("detected an EditTextPreference: " + pref.getKey() + " pref: " + pref);
        }

        //noinspection DuplicateCondition
        if( pref instanceof EditTextPreference || pref instanceof MyEditTextPreference) {
        if( pref.getKey().equals("preference_save_location") ) {
            // can't use %s (as only supported for ListPreference), so handle this directly
            MainActivity main_activity = (MainActivity)pref.getContext();
            String folder_name;
            if( main_activity.getStorageUtils().isUsingSAF() ) {
                folder_name = main_activity.getStorageUtils().getSaveLocationSAF();
            }
            else {
                folder_name = main_activity.getStorageUtils().getSaveLocation();
            }
            folder_name = main_activity.getHumanReadableSaveFolder(folder_name);
            String summary = main_activity.getResources().getString(R.string.preference_save_location_summary);
            if( !folder_name.isEmpty() ) {
                summary += "\n" + folder_name;
            }
            pref.setSummary(summary);
        }
        else if( pref instanceof EditTextPreference || pref instanceof MyEditTextPreference ) {
            // %s only supported for ListPreference
            // we also display the usual summary if no preference value is set
            if( pref.getKey().equals("preference_exif_artist") ||
+11 −0
Original line number Diff line number Diff line
@@ -127,6 +127,8 @@ public class PreferenceSubCameraControlsMore extends PreferenceSubScreen {
                        else {
                            if( MyDebug.LOG )
                                Log.d(TAG, "saf is now disabled");
                            // need to update the summary, as switching back to non-SAF folder
                            MyPreferenceFragment.setSummary(findPreference("preference_save_location"));
                        }
                    }
                    return false;
@@ -191,6 +193,7 @@ public class PreferenceSubCameraControlsMore extends PreferenceSubScreen {
            });
        }

        // preference_save_location done in onResume
        MyPreferenceFragment.setSummary(findPreference("preference_save_photo_prefix"));
        MyPreferenceFragment.setSummary(findPreference("preference_save_video_prefix"));

@@ -200,6 +203,14 @@ public class PreferenceSubCameraControlsMore extends PreferenceSubScreen {
            Log.d(TAG, "onCreate done");
    }

    @Override
    public void onResume() {
        super.onResume();

        // we need to call this onResume too, to handle updating the summary when changing location via SAF dialoga
        MyPreferenceFragment.setSummary(findPreference("preference_save_location"));
    }

    /** Programmatically set up dependencies for preference types (e.g., ListPreference) that don't
     *  support this in xml (such as SwitchPreference and CheckBoxPreference), or where this depends
     *  on the device (e.g., Android version).