Source:
<code>public void onCreate(@Nullable final Bundle savedInstanceState) { super.onCreate(savedInstanceState); downloadPathVideoPreference = getString(R.string.download_path_video_key); downloadPathAudioPreference = getString(R.string.download_path_audio_key); storageUseSafPreference = getString(R.string.storage_use_saf); final String downloadStorageAsk = getString(R.string.downloads_storage_ask); prefPathVideo = findPreference(downloadPathVideoPreference); prefPathAudio = findPreference(downloadPathAudioPreference); prefStorageAsk = findPreference(downloadStorageAsk); final SwitchPreference prefUseSaf = findPreference(storageUseSafPreference); <START> final boolean usingSaf = NewPipeSettings.useStorageAccessFramework(ctx); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { prefUseSaf.setDefaultValue(true); prefUseSaf.setChecked(usingSaf); } else { prefUseSaf.setDefaultValue(false); prefUseSaf.setChecked(usingSaf); } <END> if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q || Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { prefUseSaf.setEnabled(false); } updatePreferencesSummary(); updatePathPickers(!defaultPreferences.getBoolean(downloadStorageAsk, false)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { prefStorageAsk.setSummary(R.string.downloads_storage_ask_summary); } if (hasInvalidPath(downloadPathVideoPreference) || hasInvalidPath(downloadPathAudioPreference)) { updatePreferencesSummary(); } prefStorageAsk.setOnPreferenceChangeListener((preference, value) -> { updatePathPickers(!(boolean) value); return true; }); }</code><technical_language>suggestion prefUseSaf.setChecked(NewPipeSettings.useStorageAccessFramework(ctx)); prefUseSaf.setDefaultValue(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP);</technical_language>

Target:
public void onCreate(@Nullable final Bundle savedInstanceState) { super.onCreate(savedInstanceState); downloadPathVideoPreference = getString(R.string.download_path_video_key); downloadPathAudioPreference = getString(R.string.download_path_audio_key); storageUseSafPreference = getString(R.string.storage_use_saf); final String downloadStorageAsk = getString(R.string.downloads_storage_ask); prefPathVideo = findPreference(downloadPathVideoPreference); prefPathAudio = findPreference(downloadPathAudioPreference); prefStorageAsk = findPreference(downloadStorageAsk); final SwitchPreference prefUseSaf = findPreference(storageUseSafPreference); prefUseSaf.setDefaultValue(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP); prefUseSaf.setChecked(NewPipeSettings.useStorageAccessFramework(ctx)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q || Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { prefUseSaf.setEnabled(false); } updatePreferencesSummary(); updatePathPickers(!defaultPreferences.getBoolean(downloadStorageAsk, false)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { prefStorageAsk.setSummary(R.string.downloads_storage_ask_summary); } if (hasInvalidPath(downloadPathVideoPreference) || hasInvalidPath(downloadPathAudioPreference)) { updatePreferencesSummary(); } prefStorageAsk.setOnPreferenceChangeListener((preference, value) -> { updatePathPickers(!(boolean) value); return true; }); }