Commit 7779f482 authored by Boris Sazonov's avatar Boris Sazonov Committed by Commit Bot

[Unity][Android] Extract ManageSyncPreferences from SyncAndSevicesPreferences

This CL moves the sync data types management out of
SyncAndSevicesPreferences settings page into a new ManageSyncPreferences
page. This CL also changes the approach used by these fragments to
save/update preference values. Instead of saving the state of data types in
onStop, it is now saved on every change. This simplifies the logic around
updating the state of the preference rows that represent these data types.
This CL also removes "Use sync and all services" toggle from
SyncAndServicesPreferences.

Bug: 914056
Change-Id: I5ac5f40588b4924c4571025006d7de70d3e3d2bd
Reviewed-on: https://chromium-review.googlesource.com/c/1425497
Commit-Queue: Boris Sazonov <bsazonov@chromium.org>
Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Reviewed-by: default avatarTheresa <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#625310}
parent ee500f6d
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2019 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android">
<org.chromium.chrome.browser.preferences.ChromeSwitchPreference
android:key="sync_everything"
android:title="@string/sync_everything_pref"
android:persistent="false"/>
<org.chromium.chrome.browser.preferences.ChromeBaseCheckBoxPreference
android:key="sync_autofill"
android:title="@string/sync_autofill"
android:persistent="false"/>
<org.chromium.chrome.browser.preferences.ChromeBaseCheckBoxPreference
android:key="sync_bookmarks"
android:title="@string/sync_bookmarks"
android:persistent="false"/>
<org.chromium.chrome.browser.preferences.ChromeBaseCheckBoxPreference
android:key="sync_payments_integration"
android:title="@string/sync_payments_integration"
android:persistent="false"/>
<org.chromium.chrome.browser.preferences.ChromeBaseCheckBoxPreference
android:key="sync_history"
android:title="@string/sync_history"
android:persistent="false"/>
<org.chromium.chrome.browser.preferences.ChromeBaseCheckBoxPreference
android:key="sync_passwords"
android:title="@string/sync_passwords"
android:persistent="false"/>
<org.chromium.chrome.browser.preferences.ChromeBaseCheckBoxPreference
android:key="sync_recent_tabs"
android:title="@string/sync_recent_tabs"
android:persistent="false"/>
<org.chromium.chrome.browser.preferences.ChromeBaseCheckBoxPreference
android:key="sync_settings"
android:title="@string/sync_settings"
android:persistent="false"/>
<org.chromium.chrome.browser.preferences.ChromeBasePreference
android:key="google_activity_controls"
android:title="@string/sign_in_google_activity_controls_title"
android:summary="@string/sign_in_google_activity_controls_summary"/>
<org.chromium.chrome.browser.preferences.ChromeBasePreference
android:key="encryption"
android:title="@string/sync_encryption"/>
<org.chromium.chrome.browser.preferences.ChromeBasePreference
android:key="sync_manage_data"
android:title="@string/sync_manage_data"/>
</PreferenceScreen>
......@@ -17,53 +17,14 @@
android:icon="@drawable/sync_error"
android:title="@string/sync_error_card_title"/>
<org.chromium.chrome.browser.preferences.ChromeSwitchPreference
android:persistent="false"
android:key="use_sync_and_all_services"
android:title="@string/use_sync_and_all_services"/>
android:key="sync_requested"
android:title="@string/sync_switch_title"
android:persistent="false"/>
<org.chromium.chrome.browser.preferences.ChromeBaseCheckBoxPreference
android:key="sync_autofill"
android:persistent="false"
android:title="@string/sync_autofill"/>
<org.chromium.chrome.browser.preferences.ChromeBaseCheckBoxPreference
android:persistent="false"
android:key="sync_bookmarks"
android:title="@string/sync_bookmarks"/>
<org.chromium.chrome.browser.preferences.ChromeBaseCheckBoxPreference
android:persistent="false"
android:key="sync_payments_integration"
android:title="@string/sync_payments_integration"/>
<org.chromium.chrome.browser.preferences.ChromeBaseCheckBoxPreference
android:persistent="false"
android:key="sync_history"
android:title="@string/sync_history"/>
<org.chromium.chrome.browser.preferences.ChromeBaseCheckBoxPreference
android:persistent="false"
android:key="sync_passwords"
android:title="@string/sync_passwords"/>
<org.chromium.chrome.browser.preferences.ChromeBaseCheckBoxPreference
android:persistent="false"
android:key="sync_recent_tabs"
android:title="@string/sync_recent_tabs"/>
<org.chromium.chrome.browser.preferences.ChromeBaseCheckBoxPreference
android:persistent="false"
android:key="sync_settings"
android:title="@string/sync_settings"/>
<org.chromium.chrome.browser.preferences.ChromeBaseCheckBoxPreference
android:persistent="false"
android:key="sync_activity_and_interactions"
android:title="@string/sync_activity_and_interactions_title"
android:summary="@string/sync_activity_and_interactions_summary"/>
<org.chromium.chrome.browser.preferences.ChromeBasePreference
android:key="google_activity_controls"
android:title="@string/sign_in_google_activity_controls_title"
android:summary="@string/sign_in_google_activity_controls_summary"/>
<org.chromium.chrome.browser.preferences.ChromeBasePreference
android:key="encryption"
android:title="@string/sync_encryption"/>
<org.chromium.chrome.browser.preferences.ChromeBasePreference
android:key="sync_manage_data"
android:title="@string/sync_manage_data"/>
android:key="manage_sync"
android:title="@string/manage_sync_title"
android:fragment="org.chromium.chrome.browser.preferences.ManageSyncPreferences"/>
</PreferenceCategory>
<PreferenceCategory
......
......@@ -5,6 +5,8 @@ package org.chromium.chrome.browser.preferences;
import android.content.Context;
import android.content.res.Resources;
import android.preference.Preference;
import android.preference.PreferenceFragment;
import org.chromium.base.BuildInfo;
import org.chromium.base.metrics.RecordHistogram;
......@@ -118,4 +120,24 @@ public class SyncPreferenceUtils {
profileSyncService.requestStop();
}
}
/**
* Creates a wrapper around {@link Runnable} that calls the runnable only if
* {@link PreferenceFragment} is still in resumed state. Click events that arrive after the
* fragment has been paused will be ignored. See http://b/5983282.
* @param fragment The fragment that hosts the preference.
* @param runnable The runnable to call from {@link Preference.OnPreferenceClickListener}.
*/
static Preference.OnPreferenceClickListener toOnClickListener(
PreferenceFragment fragment, Runnable runnable) {
return preference -> {
if (!fragment.isResumed()) {
// This event could come in after onPause if the user clicks back and the preference
// at roughly the same time. See http://b/5983282.
return false;
}
runnable.run();
return false;
};
}
}
......@@ -340,12 +340,15 @@ CHAR-LIMIT guidelines:
<message name="IDS_SIGN_OUT_AND_TURN_OFF_SYNC" desc="The text for a preferences row that for signs out the user and turns off sync.">
Sign out and turn off sync
</message>
<message name="IDS_USE_SYNC_AND_ALL_SERVICES" desc="Title for switch preference which enables sync'ing of all data types and turns on all Chrome services that communicate with Google.">
Use sync and all services
</message>
<message name="IDS_SYNC_CATEGORY_TITLE" desc="Title for the group of Sync-related entries in Settings. This group contains preferences for data tied to user's Google Account.">
Sync
</message>
<message name="IDS_SYNC_SWITCH_TITLE" desc="Title for the switch preference that enables sync. Displayed in 'Sync and Google services' screen.">
Sync your Chrome data
</message>
<message name="IDS_MANAGE_SYNC_TITLE" desc="Title for the preference row that opens the screen that allows configuring separate data types. Displayed in 'Sync and Google services' screen.">
Manage sync
</message>
<message name="IDS_SERVICES_CATEGORY_TITLE" desc="Title for the group of preferences that control non-personalized Google services. This group contains preferences for data that is not tied to user's Google Account.">
Other Google services
</message>
......@@ -1626,12 +1629,6 @@ Your Google account may have other forms of browsing history like searches and a
<message name="IDS_SYNC_PAYMENTS_INTEGRATION" desc="Title for preference which enables import of Google Pay data for Autofill. 'Google Pay' should not be translated as it is the product name.">
Credit cards and addresses using Google Pay
</message>
<message name="IDS_SYNC_ACTIVITY_AND_INTERACTIONS_TITLE" desc="Title for preference which enables sync'ing of activity and interactions.">
Activity and interactions
</message>
<message name="IDS_SYNC_ACTIVITY_AND_INTERACTIONS_SUMMARY" desc="Summary for preference which enables sync'ing of activity and interactions.">
Uses content on sites you visit, plus browser activity and interactions, for personalization
</message>
<message name="IDS_SYNC_ENCRYPTION" desc="Preference category name for sync encryption. [CHAR-LIMT=32]">
Encryption
</message>
......
......@@ -1292,6 +1292,7 @@ chrome_java_sources = [
"java/src/org/chromium/chrome/browser/preferences/MainPreferences.java",
"java/src/org/chromium/chrome/browser/preferences/ManagedPreferenceDelegate.java",
"java/src/org/chromium/chrome/browser/preferences/ManagedPreferencesUtils.java",
"java/src/org/chromium/chrome/browser/preferences/ManageSyncPreferences.java",
"java/src/org/chromium/chrome/browser/preferences/NotificationsPreferences.java",
"java/src/org/chromium/chrome/browser/preferences/PrefChangeRegistrar.java",
"java/src/org/chromium/chrome/browser/preferences/PrefServiceBridge.java",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment