Skip to content

Commit

Permalink
Fixed restore of events
Browse files Browse the repository at this point in the history
  • Loading branch information
Futsch1 committed Sep 14, 2024
1 parent 818d05e commit d7f5164
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/src/main/java/com/futsch1/medtimer/BackupManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.net.Uri;
import android.os.Handler;
import android.os.HandlerThread;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;
Expand Down Expand Up @@ -118,6 +119,7 @@ public void fileSelected(Uri data) {
String json = FileHelper.readFromUri(data, context.getContentResolver());
boolean restoreSuccessful = false;
if (json != null) {
Log.d("BackupManager", "Starting backup restore: " + data);
try {
JsonObject rootElement = JsonParser.parseString(json).getAsJsonObject();
if (rootElement.has(MEDICINE_KEY)) {
Expand All @@ -137,7 +139,7 @@ public void fileSelected(Uri data) {
// Try legacy backup formats
restoreSuccessful = restoreBackup(json, new JSONMedicineBackup()) || restoreBackup(json, new JSONReminderEventBackup());
}

Log.d("BackupManager", "Backup restore finished");
new AlertDialog.Builder(context)
.setMessage(restoreSuccessful ? R.string.restore_successful : R.string.restore_failed)
.setPositiveButton(R.string.ok, (dialog, which) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class Reminder {
public static final int DEFAULT_TIME = 480;
public int medicineRelId;
@PrimaryKey(autoGenerate = true)
@Expose
public int reminderId;
@Expose
public int timeInMinutes;
Expand Down

0 comments on commit d7f5164

Please sign in to comment.