-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Google Drive daily backup mobile data option #3083
Google Drive daily backup mobile data option #3083
Conversation
Will this default to not allowing backup via mobile data? |
@jamorham Thanks for looking at this and thanks for catching that. Thanks |
Would having the preference disabled by default change the default behavior though, so if someone installs a new version then it will stop backing up over mobile data where as it prior to this change by default it would have done? I don't think changing the UI checked flag is the way to set the default value to true because as far as I know the value is only written to preference store on change. |
@jamorham |
To answer your question: Because it defaults to true and is handled via a preferences xml rather than a databinding activity. There are a couple of different ways you can handle this issue depending of course on whether you think the existing behavior should be maintained which in this case I think it probably should. Either invert the logic of the preference so that you can have it defaulting to false but that is a bit backward or when you read it in Backup you can default it to true if not set and the in the UI component you can initialize it if not set. You can use This needs to happen before the screen starts rendering as I don't think the prefsview is observable. To keep it clean you want encapsulate that behavior and so I think create a static public method in Otherwise we could extend the prefsview to perhaps understand defaults but that is potentially a bigger change but the main reason you're having this problem is it doesn't support unset booleans being true. One other way to achieve the same is to actually define your setting inside the regular preferences as then it will go through an initialization stage but as far as I'm aware (without checking) all of these backup settings are handled within the backup selector activity and there is no place in the preferences xml for related settings. But I'm just giving you an overview of the constraints and various possible solutions. |
Thanks for the guidance. |
@@ -5,7 +5,7 @@ | |||
|
|||
<variable | |||
name="vm" | |||
type="com.eveningoutpost.dexdrip.cloud.backup.BackupActivity.ViewModel" /> | |||
type="com.eveningoutpost.dexdrip.cloud.backup.BackupActivity.ViewModel" />Changed default to true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this supposed to be here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, sorry about that
<CheckBox | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:checked="true" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this checked = true could interfere with the one which follows the preference
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean by "the one which follows the preference"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought that's how I can have it enabled by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean "False" in this?
Pref.getBooleanDefaultFalse(PREF_AUTO_BACKUP_WIFI)
Can I do this then? |
Well I think this is getting very confusing now. The whole point of you inverting the logic was so that you could default the preference to being true. Am I to understand it that you want the checkbox to show checked when the preference is false? If so you can often invert the logic on display but this is a two way binding so I'm not sure about that. Surely from my previous comment you just remove it being checked and let it follow the preference which should default to false and the checkbox should be unchecked by default representing false? |
No, |
If someone doesn't mind uploading using mobile, they need to disable the new setting. If they leave it at default, it will only upload when there is WiFi. If there is no WiFi, it will not upload the daily backup by default. This is the opposite of REST_API, where by default, it uses mobile and one has to disable it if they want WiFi only. |
Let's say I have a service that charges a lot for mobile data and I want to minimize mobile data use. |
I created a new method that sets the preference's default to true. |
To be clear, I would prefer not to change the existing default behavior. If I understand this correctly (and there have been changes and possibly double negatives) then merging this will cause anyone who isn't using wifi to cease having backups occur. I would prefer that the default remains as it is and when users are setting up the backup they can make it wifi only if they want. |
I misunderstood. Thanks. I now understand you don't want me to change the default to not use mobile data. My database backup size, on Google Drive, is 35MB. 35MB x 30 > 1GB There are individuals who subscribe to cell phone services with limited data amount. Looking at the other side of the coin, if you approve this PR, I can see someone can install xDrip and enable daily backups but miss the clear note "WiFi only". In 2 months, their phone breaks. They buy a new phone and go to Google drive and see no backup because they never had access to WiFi over the past 2 months. I see both of those as bad scenarios we should avoid. I will add a notification that comes up when someone enables daily backups. It will say something like "xDrip by default will use WiFi only for daily backups. If you want to also use mobile data for daily backups, please disable the setting Will you consider that? |
If the only way to move forward with this is to have mobile data enabled by default, can I add a notification when daily backup is enabled to inform the user that by default mobile data will be used? |
android:gravity="center" | ||
android:layout_marginBottom="20dp" | ||
android:text="@string/daily_backup_even_mobile" | ||
app:checked="@={prefs[`backup-automatic-mobile`]}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still don't think this will work properly because even though you've changed the logic to default to true, the prefsview I don't think will handle that and will default to false and without a significant rewrite of that component which carries its own risks I don't think its easily solvable. I could take a look at that though as it would be better if we were not constrained by that. For other activities we rely on the XML settings to set the defaults.
For things as they are, the only alternative options are I think you either need to set the setting to true if it isn't currently set so that new users get this defaulted true setting or invert your logic so that it is something like "Back up over WiFi only" which then defaults to false and then you don't need to worry about presetting it to true.
I will take a look at PrefsView and get back to you on whether its easily solvable that way.
See af3a008 this should allow you to specify like |
@@ -111,11 +111,12 @@ | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:dependency="backup-automatic-enabled" | |||
android:checked="true" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this shouldn't be specified as it should be handled by the prefsview
Should I squash the commits? |
This allows user to limit daily backups to WiFi and exclude mobile data.
Fixes: #3082