diff --git a/app/src/main/java/org/shadowice/flocke/andotp/Activities/SettingsActivity.java b/app/src/main/java/org/shadowice/flocke/andotp/Activities/SettingsActivity.java index bb8e45e5..0f9f05d8 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/Activities/SettingsActivity.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/Activities/SettingsActivity.java @@ -40,6 +40,7 @@ import android.preference.PreferenceManager; import androidx.appcompat.widget.Toolbar; import android.provider.DocumentsContract; +import android.util.Log; import android.view.ViewStub; import android.widget.Toast; @@ -166,6 +167,13 @@ public class SettingsActivity extends BaseActivity if (fragment.useAndroidSync != null) fragment.useAndroidSync.setEnabled(true); } + } else if(key.equals(getString(R.string.settings_key_enable_android_backup_service))) + { + Log.d(SettingsActivity.class.getSimpleName(), "onSharedPreferenceChanged called modifying settings_key_enable_android_backup_service service is now: " + + (settings.getAndroidBackupServiceEnabled() ? "enabled" : "disabled")); + + int message = settings.getAndroidBackupServiceEnabled() ? R.string.settings_toast_android_sync_enabled : R.string.settings_toast_android_sync_disabled; + Toast.makeText(this, message, Toast.LENGTH_SHORT).show(); } fragment.updateAutoBackup(); diff --git a/app/src/main/java/org/shadowice/flocke/andotp/Utilities/BackupAgent.java b/app/src/main/java/org/shadowice/flocke/andotp/Utilities/BackupAgent.java index ead9e95f..9d154eb9 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/Utilities/BackupAgent.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/Utilities/BackupAgent.java @@ -29,6 +29,8 @@ import android.app.backup.BackupDataOutput; import android.app.backup.FileBackupHelper; import android.app.backup.SharedPreferencesBackupHelper; import android.os.ParcelFileDescriptor; +import android.util.Log; + import java.io.IOException; @@ -44,19 +46,29 @@ public class BackupAgent extends BackupAgentHelper { @Override public void onBackup(ParcelFileDescriptor oldState, BackupDataOutput data, ParcelFileDescriptor newState) throws IOException { Settings settings = new Settings(this); + StringBuilder stringBuilder = new StringBuilder("onBackup called with the backup service set to "); + stringBuilder.append(settings.getAndroidBackupServiceEnabled() ? "enabled" : "disabled"); if(settings.getAndroidBackupServiceEnabled()) { synchronized (DatabaseHelper.DatabaseFileLock) { + stringBuilder.append(" calling parent onBackup"); super.onBackup(oldState, data, newState); } } + Log.d(BackupAgent.class.getSimpleName(), stringBuilder.toString()); } @Override public void onRestore(BackupDataInput data, int appVersionCode, ParcelFileDescriptor newState) throws IOException { + Settings settings = new Settings(this); + StringBuilder stringBuilder = new StringBuilder("onRestore called with the backup service set to "); + stringBuilder.append(settings.getAndroidBackupServiceEnabled() ? "enabled" : "disabled"); + synchronized (DatabaseHelper.DatabaseFileLock) { + stringBuilder.append(" but restore happens regardless, calling parent onRestore"); super.onRestore(data, appVersionCode, newState); } + Log.d(BackupAgent.class.getSimpleName(), stringBuilder.toString()); } @Override diff --git a/app/src/main/res/values/strings_settings.xml b/app/src/main/res/values/strings_settings.xml index c2720231..cbfbd159 100644 --- a/app/src/main/res/values/strings_settings.xml +++ b/app/src/main/res/values/strings_settings.xml @@ -134,6 +134,9 @@ Failed to silently upgrade your password / PIN to the new encryption, please manually reset it in the Settings! + Android sync enabled + Android sync disabled + Warning Error Clear the KeyStore?