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

Google Drive daily backup mobile data option #3083

Merged
merged 11 commits into from
Oct 24, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public class Backup {
private static final String TAG = "xDrip-Backup";
private static final String PREF_BACKUP_URI = "backup-document-uri";
public static final String PREF_AUTO_BACKUP = "backup-automatic-enabled";
public static final String PREF_AUTO_BACKUP_WIFI = "backup-automatic-wifionly";
private static final String XDRIP_CONTENT_TYPE = "xDripBackup://";
private static final String[] dbSuffix = {"-journal", "-shm", "-wal"};

Expand Down Expand Up @@ -298,7 +299,7 @@ public static boolean isBackupSuitableForAutomatic() {

public static void doCompleteBackupIfEnabled() {
if (Pref.getBooleanDefaultFalse(PREF_AUTO_BACKUP)
&& isBackupSuitableForAutomatic()) {
&& isBackupSuitableForAutomatic() && ((!Pref.getBooleanDefaultFalse(PREF_AUTO_BACKUP_WIFI)) || (JoH.isLANConnected()))) {
UserError.Log.e(TAG, "Attempting automatic backup");
val success = doCompleteBackup(new LogStatus());
if (!success) {
Expand Down
12 changes: 12 additions & 0 deletions app/src/main/res/layout/activity_backup_picker.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,18 @@
app:checked="@={prefs[`backup-automatic-enabled`]}"
app:showIfTrueAnimatedFastOff="@{vm.showAuto}" />

<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
Copy link
Collaborator

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

Copy link
Collaborator Author

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"?

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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)

Copy link
Collaborator

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

android:dependency="backup-automatic-enabled"
android:layout_gravity="center"
android:layout_marginBottom="20dp"
android:gravity="center"
android:text="@string/use_wifi_only"
app:checked="@={prefs[`backup-automatic-wifionly`]}"
app:showIfTrueAnimatedFastOff="@{vm.showAuto}" />

<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1203,6 +1203,7 @@
<string name="manual_overwrite_not_possible">Manual overwrite not possible!</string>
<string name="upload_even_when_using_mobile_data">Upload even when using mobile data</string>
<string name="use_mobile_data">Use mobile data</string>
<string name="use_wifi_only">WiFi only (avoid mobile data)</string>
<string name="summary_cloud_storage_api_download_enable">Also try to download treatments from Nightscout</string>
<string name="title_cloud_storage_api_download_enable">Download treatments</string>
<string name="summary_bluetooth_meter_for_calibrations_auto">Calibrate using new blood glucose readings if the conditions appear right to do so without asking confirmation (experimental)</string>
Expand Down
Loading