Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jamorham committed Oct 24, 2023
2 parents 8a05919 + 286323e commit e34ebac
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
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_MOBILE = "backup-automatic-mobile";
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.getBoolean(PREF_AUTO_BACKUP_MOBILE, true)) || (JoH.isLANConnected()))) {
UserError.Log.e(TAG, "Attempting automatic backup");
val success = doCompleteBackup(new LogStatus());
if (!success) {
Expand Down
28 changes: 22 additions & 6 deletions app/src/main/res/layout/activity_backup_picker.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,23 @@
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_marginHorizontal="10dp"
android:layout_marginBottom="15dp"
android:enabled="@{vm.idle}"
android:onClick="@{() -> vm.selectFile()}"
android:text="@string/select_backup_location" />
android:text="@string/select_backup_location"
android:textAllCaps="false"/>

<Button
android:id="@+id/button30"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_marginHorizontal="10dp"
android:layout_marginBottom="15dp"
android:enabled="@{vm.idle}"
android:onClick="@{() -> vm.backupNow()}"
android:text="@string/do_backup_now" />
android:text="@string/do_backup_now"
android:textAllCaps="false"/>

<CheckBox
android:layout_width="wrap_content"
Expand All @@ -103,13 +107,25 @@
app:checked="@={prefs[`backup-automatic-enabled`]}"
app:showIfTrueAnimatedFastOff="@{vm.showAuto}" />

<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:dependency="backup-automatic-enabled"
android:layout_gravity="center"
android:gravity="center"
android:layout_marginBottom="20dp"
android:text="@string/daily_backup_even_mobile"
app:checked="@={prefs[`backup-automatic-mobile:true`]}"
app:showIfTrueAnimatedFastOff="@{vm.showAuto}" />

<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_marginHorizontal="10dp"
android:enabled="@{vm.idle}"
android:onClick="@{() -> vm.restoreNow()}"
android:text="@string/restore_from_backup" />
android:text="@string/restore_from_backup"
android:textAllCaps="false"/>
</LinearLayout>
</ScrollView>
</layout>
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="overwrite_intercept_engineering_only">Overwrite Intercept (engineering only!)</string>
<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="daily_backup_even_mobile">Daily backup even on mobile data</string>
<string name="use_mobile_data">Use 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>
Expand Down

0 comments on commit e34ebac

Please sign in to comment.