Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: option to choose backup target directory #1354

Merged
merged 3 commits into from
Oct 13, 2024

Conversation

zzjjaayy
Copy link
Contributor

@zzjjaayy zzjjaayy commented Sep 26, 2024

Fixes: #1152 and #1106

  • Settings option to choose backup target directory only in PHONE {Currently saved in the open in Downloads/}
  • I don't recommend having a different default directory since that fails in TVs and choosers are anyways not present in most of them.

Screenshot_2024-09-27-09-38-58-27_bba4627ecec1346e77f282610a5b88e8

Copy link
Contributor Author

@zzjjaayy zzjjaayy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Questions/ThingsToLookAt for the reviewer.
Thanks.

override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
hideKeyboard()
setPreferencesFromResource(R.xml.settings_updates, rootKey)
//val settingsManager = PreferenceManager.getDefaultSharedPreferences(requireContext())
val settingsManager = PreferenceManager.getDefaultSharedPreferences(requireContext())
Copy link
Contributor Author

@zzjjaayy zzjjaayy Sep 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using this top level declaration instead of in each listener. any reason to use separate calls previously?

Copy link
Contributor

@CranberrySoup CranberrySoup Sep 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is not, good thinking!
I presume it was like that because using it.context removed the need for requireContext() which can crash even when it should not.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it? if thats the case we could have a null check usage of it.context.

Copy link
Contributor

@CranberrySoup CranberrySoup Sep 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, you misunderstand.

requireContext(): can crash, but no wet code
it.context: can't crash, but wet code

In this case requireContext() should be relatively safe because it is in onCreatePreferences.


// No access rights after restore data from backup
"download_path_key",
"download_path_pref",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added download_path_pref in ignoreForBackup list, check if that is something we left deliberately.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also check this value in strings.xml, why are we not keeping it translatable=false?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a big mistake, download_path_pref is used both as a display string and as a key, it should never be used as both.

Copy link
Contributor Author

@zzjjaayy zzjjaayy Sep 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct, I would fix it but would let one of the maintainers comment on this.

Copy link
Contributor

@CranberrySoup CranberrySoup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good 👍

@@ -371,7 +351,7 @@ class SettingsGeneral : PreferenceFragmentCompat() {
?: context?.let { ctx -> VideoDownloadManager.getDefaultDir(ctx)?.filePath() }

activity?.showBottomDialog(
dirs + listOf("Custom"),
dirs + listOf(getString(R.string.custom)),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good!

override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
hideKeyboard()
setPreferencesFromResource(R.xml.settings_updates, rootKey)
//val settingsManager = PreferenceManager.getDefaultSharedPreferences(requireContext())
val settingsManager = PreferenceManager.getDefaultSharedPreferences(requireContext())
Copy link
Contributor

@CranberrySoup CranberrySoup Sep 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is not, good thinking!
I presume it was like that because using it.context removed the need for requireContext() which can crash even when it should not.


// No access rights after restore data from backup
"download_path_key",
"download_path_pref",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a big mistake, download_path_pref is used both as a display string and as a key, it should never be used as both.

@zzjjaayy
Copy link
Contributor Author

zzjjaayy commented Oct 2, 2024

fixed conflicts, clean for review again.

@fire-light42 fire-light42 merged commit 54f2213 into recloudstream:master Oct 13, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Save backups in a subdirectory
3 participants