Commit 889526f0 authored by Boris Sazonov's avatar Boris Sazonov Committed by Commit Bot

[Unity][Android] Wire up preferences in SyncAndServicesPreferences

This CL wires up 'Activity and interactions' and 'Google activity
controls' entries in SyncAndServicesPreferences. It also updates
strings used for 'Google activity controls' entry.

Bug: 814728
Change-Id: I161bdc0df44d46aba3ad795da2c2a9be5ca543c9
Reviewed-on: https://chromium-review.googlesource.com/1194038Reviewed-by: default avatarTheresa <twellington@chromium.org>
Commit-Queue: Boris Sazonov <bsazonov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#587241}
parent 330ca18c
......@@ -42,8 +42,8 @@
<Preference
android:key="google_activity_controls"
android:icon="@drawable/ic_logo_googleg_24dp"
android:title="@string/sign_in_google_activity_controls"
android:summary="@string/sign_in_google_activity_controls_message"/>
android:title="@string/sign_in_google_activity_controls_legacy"
android:summary="@string/sign_in_google_activity_controls_message_legacy"/>
<Preference
android:key="google_activity_controls_divider"
......
......@@ -61,8 +61,8 @@
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"
android:summary="@string/sign_in_google_activity_controls_message"/>
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"/>
......
......@@ -34,7 +34,9 @@ import org.chromium.base.ContextUtils;
import org.chromium.base.ThreadUtils;
import org.chromium.base.VisibleForTesting;
import org.chromium.base.metrics.RecordHistogram;
import org.chromium.base.metrics.RecordUserAction;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.AppHooks;
import org.chromium.chrome.browser.autofill.PersonalDataManager;
import org.chromium.chrome.browser.contextualsearch.ContextualSearchFieldTrial;
import org.chromium.chrome.browser.help.HelpAndFeedback;
......@@ -88,6 +90,9 @@ public class SyncAndServicesPreferences extends PreferenceFragment
private static final String PREF_SYNC_PASSWORDS = "sync_passwords";
private static final String PREF_SYNC_RECENT_TABS = "sync_recent_tabs";
private static final String PREF_SYNC_SETTINGS = "sync_settings";
private static final String PREF_SYNC_ACTIVITY_AND_INTERACTIONS =
"sync_activity_and_interactions";
private static final String PREF_GOOGLE_ACTIVITY_CONTROLS = "google_activity_controls";
private static final String PREF_ENCRYPTION = "encryption";
private static final String PREF_SYNC_MANAGE_DATA = "sync_manage_data";
private static final String PREF_SYNC_ERROR_CARD = "sync_error_card";
......@@ -136,9 +141,11 @@ public class SyncAndServicesPreferences extends PreferenceFragment
private CheckBoxPreference mSyncPasswords;
private CheckBoxPreference mSyncRecentTabs;
private CheckBoxPreference mSyncSettings;
private CheckBoxPreference mSyncActivityAndInteractions;
// Contains preferences for all sync data types.
private CheckBoxPreference[] mSyncAllTypes;
private Preference mGoogleActivityControls;
private Preference mSyncEncryption;
private Preference mManageSyncData;
private Preference mSyncErrorCard;
......@@ -191,7 +198,10 @@ public class SyncAndServicesPreferences extends PreferenceFragment
mSyncPasswords = (CheckBoxPreference) findPreference(PREF_SYNC_PASSWORDS);
mSyncRecentTabs = (CheckBoxPreference) findPreference(PREF_SYNC_RECENT_TABS);
mSyncSettings = (CheckBoxPreference) findPreference(PREF_SYNC_SETTINGS);
mSyncActivityAndInteractions =
(CheckBoxPreference) findPreference(PREF_SYNC_ACTIVITY_AND_INTERACTIONS);
mGoogleActivityControls = findPreference(PREF_GOOGLE_ACTIVITY_CONTROLS);
mSyncEncryption = findPreference(PREF_ENCRYPTION);
mSyncEncryption.setOnPreferenceClickListener(
toOnClickListener(this::onSyncEncryptionClicked));
......@@ -202,9 +212,9 @@ public class SyncAndServicesPreferences extends PreferenceFragment
mSyncErrorCard.setOnPreferenceClickListener(
toOnClickListener(this::onSyncErrorCardClicked));
mSyncAllTypes =
new CheckBoxPreference[] {mSyncAutofill, mSyncBookmarks, mSyncPaymentsIntegration,
mSyncHistory, mSyncPasswords, mSyncRecentTabs, mSyncSettings};
mSyncAllTypes = new CheckBoxPreference[] {mSyncAutofill, mSyncBookmarks,
mSyncPaymentsIntegration, mSyncHistory, mSyncPasswords, mSyncRecentTabs,
mSyncSettings, mSyncActivityAndInteractions};
for (CheckBoxPreference type : mSyncAllTypes) {
type.setOnPreferenceChangeListener(this);
}
......@@ -247,6 +257,11 @@ public class SyncAndServicesPreferences extends PreferenceFragment
mContextualSearch = null;
}
if (Profile.getLastUsedProfile().isChild()) {
mGoogleActivityControls.setSummary(
R.string.sign_in_google_activity_controls_message_child_account);
}
updatePreferences();
}
......@@ -501,6 +516,7 @@ public class SyncAndServicesPreferences extends PreferenceFragment
if (mSyncPasswords.isChecked()) types.add(ModelType.PASSWORDS);
if (mSyncRecentTabs.isChecked()) types.add(ModelType.PROXY_TABS);
if (mSyncSettings.isChecked()) types.add(ModelType.PREFERENCES);
if (mSyncActivityAndInteractions.isChecked()) types.add(ModelType.USER_EVENTS);
return types;
}
......@@ -602,6 +618,12 @@ public class SyncAndServicesPreferences extends PreferenceFragment
displayCustomPassphraseDialog();
}
private void onGoogleActivityControlsClicked(String signedInAccountName) {
AppHooks.get().createGoogleActivityController().openWebAndAppActivitySettings(
getActivity(), signedInAccountName);
RecordUserAction.record("Signin_AccountSettings_GoogleActivityControlsClicked");
}
private void onSyncEncryptionClicked() {
if (!mProfileSyncService.isEngineInitialized()) return;
......@@ -659,6 +681,7 @@ public class SyncAndServicesPreferences extends PreferenceFragment
passwordSyncConfigurable && syncTypes.contains(ModelType.PASSWORDS));
mSyncRecentTabs.setChecked(syncTypes.contains(ModelType.PROXY_TABS));
mSyncSettings.setChecked(syncTypes.contains(ModelType.PREFERENCES));
mSyncActivityAndInteractions.setChecked(syncTypes.contains(ModelType.USER_EVENTS));
}
}
......@@ -794,6 +817,9 @@ public class SyncAndServicesPreferences extends PreferenceFragment
mUseSyncAndAllServices.setChecked(useSyncAndAllServices);
mSyncGroup.setEnabled(true);
mGoogleActivityControls.setOnPreferenceClickListener(
toOnClickListener(() -> onGoogleActivityControlsClicked(signedInAccountName)));
} else {
getPreferenceScreen().addPreference(mSigninPreference);
getPreferenceScreen().removePreference(mUseSyncAndAllServices);
......
......@@ -309,15 +309,21 @@ CHAR-LIMIT guidelines:
<message name="IDS_SIGN_IN_TO_CHROME_DISABLED_SUMMARY" desc="A descriptive line of text that appears under the 'Sign in to Chrome' option, in Chrome Settings on Android. The text explains why 'Sign in to Chrome' is disabled. 'Administrator' refers to the IT administrator of the company/organization that owns the user’s device.">
Disabled by the administrator of this device
</message>
<message name="IDS_SIGN_IN_GOOGLE_ACTIVITY_CONTROLS" desc="Title of Google activity controls preference in signed in accounts settings screen">
<message name="IDS_SIGN_IN_GOOGLE_ACTIVITY_CONTROLS_LEGACY" desc="Title of Google activity controls preference in signed in accounts settings screen">
Google Activity Controls
</message>
<message name="IDS_SIGN_IN_GOOGLE_ACTIVITY_CONTROLS_MESSAGE" desc="Message of Google activity controls preference in signed in accounts settings screen">
<message name="IDS_SIGN_IN_GOOGLE_ACTIVITY_CONTROLS_MESSAGE_LEGACY" desc="Message of Google activity controls preference in signed in accounts settings screen">
Control how Google uses your browsing history to personalize Search, ads, and other Google services.
</message>
<message name="IDS_SIGN_IN_GOOGLE_ACTIVITY_CONTROLS_MESSAGE_CHILD_ACCOUNT" desc="Message of Google activity controls preference in signed in accounts settings screen for child accounts">
Control how Google uses your browsing history to personalize Search and other Google services.
</message>
<message name="IDS_SIGN_IN_GOOGLE_ACTIVITY_CONTROLS_TITLE" desc="Title of Google activity controls preference in signed in accounts settings screen">
Google activity controls
</message>
<message name="IDS_SIGN_IN_GOOGLE_ACTIVITY_CONTROLS_SUMMARY" desc="Message of Google activity controls preference in signed in accounts settings screen">
Control how your browsing history is used to personalize Search, ads, and more
</message>
<message name="IDS_SIGN_IN_SYNC_ERROR_WIDGET" desc="Accessibility description of the sync error widget in settings screen">
Sync error occurred, tap to get details.
</message>
......
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