diff --git a/app/src/common/shared/org/mozilla/vrbrowser/browser/Accounts.kt b/app/src/common/shared/org/mozilla/vrbrowser/browser/Accounts.kt index 3d1cadf04..04d785140 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/browser/Accounts.kt +++ b/app/src/common/shared/org/mozilla/vrbrowser/browser/Accounts.kt @@ -25,8 +25,8 @@ import mozilla.components.service.fxa.sync.SyncStatusObserver import mozilla.components.service.fxa.sync.getLastSynced import org.mozilla.vrbrowser.R import org.mozilla.vrbrowser.VRBrowserApplication -import org.mozilla.vrbrowser.utils.BitmapCache import org.mozilla.vrbrowser.telemetry.GleanMetricsService +import org.mozilla.vrbrowser.utils.BitmapCache import org.mozilla.vrbrowser.utils.SystemUtils import org.mozilla.vrbrowser.utils.ViewUtils import java.net.URL @@ -127,8 +127,6 @@ class Accounts constructor(val context: Context) { accountStatus = AccountStatus.SIGNED_IN // Enable syncing after signing in - syncStorage.setStatus(SyncEngine.Bookmarks, SettingsStore.getInstance(context).isBookmarksSyncEnabled) - syncStorage.setStatus(SyncEngine.History, SettingsStore.getInstance(context).isHistorySyncEnabled) services.accountManager.syncNowAsync(SyncReason.EngineChange, true) // Update device list @@ -319,11 +317,9 @@ class Accounts constructor(val context: Context) { when(engine) { SyncEngine.Bookmarks -> { GleanMetricsService.FxA.bookmarksSyncStatus(value) - SettingsStore.getInstance(context).isBookmarksSyncEnabled = value } SyncEngine.History -> { GleanMetricsService.FxA.historySyncStatus(value) - SettingsStore.getInstance(context).isHistorySyncEnabled = value } } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/browser/SettingsStore.java b/app/src/common/shared/org/mozilla/vrbrowser/browser/SettingsStore.java index 0b99e4a11..8332c067d 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/browser/SettingsStore.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/browser/SettingsStore.java @@ -621,25 +621,6 @@ public void setPopUpsBlockingEnabled(boolean isEnabled) { editor.putBoolean(mContext.getString(R.string.settings_key_pop_up_blocking), isEnabled); editor.commit(); } - public void setBookmarksSyncEnabled(boolean isEnabled) { - SharedPreferences.Editor editor = mPrefs.edit(); - editor.putBoolean(mContext.getString(R.string.settings_key_bookmarks_sync), isEnabled); - editor.commit(); - } - - public boolean isBookmarksSyncEnabled() { - return mPrefs.getBoolean(mContext.getString(R.string.settings_key_bookmarks_sync), BOOKMARKS_SYNC_DEFAULT); - } - - public void setHistorySyncEnabled(boolean isEnabled) { - SharedPreferences.Editor editor = mPrefs.edit(); - editor.putBoolean(mContext.getString(R.string.settings_key_history_sync), isEnabled); - editor.commit(); - } - - public boolean isHistorySyncEnabled() { - return mPrefs.getBoolean(mContext.getString(R.string.settings_key_history_sync), HISTORY_SYNC_DEFAULT); - } public void setWhatsNewDisplayed(boolean isEnabled) { SharedPreferences.Editor editor = mPrefs.edit(); diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/FxAAccountOptionsView.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/FxAAccountOptionsView.java index 02a284f7f..1278d4b5a 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/FxAAccountOptionsView.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/FxAAccountOptionsView.java @@ -45,8 +45,6 @@ class FxAAccountOptionsView extends SettingsView { private Accounts mAccounts; private Places mPlaces; private Executor mUIThreadExecutor; - private boolean mInitialBookmarksState; - private boolean mInitialHistoryState; private SignOutDialogWidget mSignOutDialog; public FxAAccountOptionsView(Context aContext, WidgetManagerDelegate aWidgetManager) { @@ -92,11 +90,8 @@ public void onShown() { mAccounts.addAccountListener(mAccountListener); mAccounts.addSyncListener(mSyncListener); - mInitialBookmarksState = mAccounts.isEngineEnabled(SyncEngine.Bookmarks.INSTANCE); - mInitialHistoryState = mAccounts.isEngineEnabled(SyncEngine.History.INSTANCE); - - mBinding.bookmarksSyncSwitch.setValue(mInitialBookmarksState, false); - mBinding.historySyncSwitch.setValue(mInitialHistoryState, false); + mBinding.bookmarksSyncSwitch.setValue(mAccounts.isEngineEnabled(SyncEngine.Bookmarks.INSTANCE), false); + mBinding.historySyncSwitch.setValue(mAccounts.isEngineEnabled(SyncEngine.History.INSTANCE), false); updateSyncBindings(mAccounts.isSyncing()); } @@ -107,20 +102,16 @@ public void onHidden() { mAccounts.removeAccountListener(mAccountListener); mAccounts.removeSyncListener(mSyncListener); - - // We only sync engines in case the user has changed the sync engines since previous sync - if (mBinding.bookmarksSyncSwitch.isChecked() != mInitialBookmarksState || - mBinding.historySyncSwitch.isChecked() != mInitialHistoryState) { - mAccounts.syncNowAsync(SyncReason.EngineChange.INSTANCE, false); - } } private SwitchSetting.OnCheckedChangeListener mBookmarksSyncListener = (compoundButton, value, apply) -> { mAccounts.setSyncStatus(SyncEngine.Bookmarks.INSTANCE, value); + mAccounts.syncNowAsync(SyncReason.EngineChange.INSTANCE, false); }; private SwitchSetting.OnCheckedChangeListener mHistorySyncListener = (compoundButton, value, apply) -> { mAccounts.setSyncStatus(SyncEngine.History.INSTANCE, value); + mAccounts.syncNowAsync(SyncReason.EngineChange.INSTANCE, false); }; private void resetOptions() { @@ -138,6 +129,9 @@ public void onStarted() { public void onIdle() { updateSyncBindings(false); + mBinding.bookmarksSyncSwitch.setValue(mAccounts.isEngineEnabled(SyncEngine.Bookmarks.INSTANCE), false); + mBinding.historySyncSwitch.setValue(mAccounts.isEngineEnabled(SyncEngine.History.INSTANCE), false); + // This shouldn't be necessary but for some reason the buttons stays hovered after the sync. // I guess Android restoring it to the latest state (hovered) before being disabled // Probably an Android bindings bug. @@ -201,12 +195,7 @@ private void updateProfile(Profile profile) { } private void sync(View view) { - if (mBinding.bookmarksSyncSwitch.isChecked() != mInitialBookmarksState || - mBinding.historySyncSwitch.isChecked() != mInitialHistoryState) { - mAccounts.syncNowAsync(SyncReason.EngineChange.INSTANCE, false); - } else { - mAccounts.syncNowAsync(SyncReason.User.INSTANCE, false); - } + mAccounts.syncNowAsync(SyncReason.User.INSTANCE, false); mAccounts.updateProfileAsync(); }