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
Feature Request: Add Backup All After Date #975
Comments
It would also be good if it knew what has already been backed up and what hasn't. I don't think the app reads email, if it doesn't then it could just keep a record locally of the last backed up item so that it knows where to resume. It likely already does this, but seems to reset if email connection is lost. |
Digging into the code, the state of what has been synced is stored as a max date for each of the three types of data (sms,mms,call log). There is no check with the server to see if something has already been synced. It looks like it reads the timestamp of the last sms/mms/call log item and stores that for each type and then on the next sync, only syncs the items after that max date. Here is where calls are made to change the max date, including the call to clear it that gets done when re/de-authenticating an account. public boolean setMaxSyncedDate(DataType dataType, long max) {
return sharedPreferences.edit().putLong(dataType.maxSyncedPreference, max).commit();
}
public long getMostRecentSyncedDate() {
return Math.max(Math.max(
getMaxSyncedDate(DataType.SMS),
getMaxSyncedDate(DataType.CALLLOG)),
getMaxSyncedDate(DataType.MMS));
}
public void clearLastSyncData() {
SharedPreferences.Editor editor = sharedPreferences.edit();
for (DataType type : DataType.values()) {
editor.remove(type.maxSyncedPreference);
}
editor.commit();
} MaxSyncedDate could be manually entered in perhaps the advanced setting fragment as a way to force resync from a particular date. This is where it display the most recent sync date on the main screen private void idle() {
syncDetailsLabel.setText(getLastSyncText(preferences.getDataTypePreferences().getMostRecentSyncedDate()));
statusLabel.setText(R.string.status_idle);
statusLabel.setTextColor(idleColor);
statusIcon.setImageDrawable(idle);
}
private String getLastSyncText(final long lastSync) {
return getString(R.string.status_idle_details,
lastSync < 0 ? getString(R.string.status_idle_details_never) :
DateFormat.getDateTimeInstance().format(new Date(lastSync)));
} Another possible location for adding the sync start date would be in the dialog for first sync which ask you to skip or sync all. But the logic would need to be extended since it either sets the maxsyncdate to the current time and date or leaves it empty. public static class FirstSync extends BaseFragment {
static final String MAX_ITEMS_PER_SYNC = "max_items_per_sync";
static final int SKIP_BUTTON = BUTTON_NEGATIVE;
@Override @NonNull
public Dialog onCreateDialog(Bundle savedInstanceState) {
OnClickListener firstSyncListener =
new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
App.post(which == SKIP_BUTTON ? BackupSkip : Backup);
}
};
final int maxItems = getArguments().getInt(MAX_ITEMS_PER_SYNC);
final String syncMsg = maxItems < 0 ?
getString(R.string.ui_dialog_first_sync_msg) :
getString(R.string.ui_dialog_first_sync_msg_batched, maxItems);
return new AlertDialog.Builder(getContext())
.setTitle(R.string.ui_dialog_first_sync_title)
.setMessage(syncMsg)
.setPositiveButton(R.string.ui_sync, firstSyncListener)
.setNegativeButton(R.string.ui_skip, firstSyncListener)
.create();
}
} The skip backup state could be built upon by making another SkipToDate state and passing it a date to inject as a new max date private BackupState skip(Iterable<DataType> types) {
appLog(R.string.app_log_skip_backup_skip_messages);
for (DataType type : types) {
try {
preferences.getDataTypePreferences().setMaxSyncedDate(type, fetcher.getMostRecentTimestamp(type));
} catch (SecurityException e ) {
return new BackupState(ERROR, 0, 0, MANUAL, type, e);
}
}
Log.i(TAG, "All messages skipped.");
return new BackupState(FINISHED_BACKUP, 0, 0, MANUAL, null, null);
} |
"or to resync 40,000+ sms" |
@djhopkins2 Do you know where it stores the timestamp? I'm wondering if there's a way to go in and manually edit the storage to set the desired timestamp |
Given all of the issue surrounding reauthenticating due to Google's strong armed move to disallow SMS Backup + via the normal OAUTH api, it would be nice if there was an option to choose a date to start backups from.
Currently it is an all or nothing choice on what to backup when reauthenticating. Another option in that menu to backup from a particular date would be greatly appreciated either that or a way to say the local sync state. I managed to reauthenticate via the firefox browser method but I had to chose to lose message between aug 8th and now or to resync 40,000+ sms
The text was updated successfully, but these errors were encountered: