Commit e2b5abcc authored by Boris Sazonov's avatar Boris Sazonov Committed by Commit Bot

[Android] Adjust Sync and Google services link in Privacy settings

If MobileIdentityConsistency flag is enabled - replaces "Sync and
Google services" link in Privacy settings with:
* One "Google services" link if sync is off;
* Two separate "Sync" and "Google services" links otherwise.

Bug: 1130623
Change-Id: I0bd8db188350a5ca3ac8c8c0276eba0a3f9bc8f6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2421461
Commit-Queue: Boris Sazonov <bsazonov@chromium.org>
Reviewed-by: default avatarAlice Wang <aliceywang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#809455}
parent 7ccbcad2
......@@ -47,7 +47,7 @@
android:order="6"/>
<org.chromium.components.browser_ui.settings.TextMessagePreference
android:key="sync_and_services_link"
android:summary="@string/privacy_sync_and_services_link"
android:summary="@string/privacy_sync_and_services_link_legacy"
app:allowDividerBelow="false"
android:order="7"/>
</PreferenceScreen>
......@@ -5,6 +5,7 @@
package org.chromium.chrome.browser.privacy.settings;
import android.os.Bundle;
import android.text.SpannableString;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
......@@ -25,12 +26,16 @@ import org.chromium.chrome.browser.safe_browsing.settings.SecuritySettingsFragme
import org.chromium.chrome.browser.settings.ChromeManagedPreferenceDelegate;
import org.chromium.chrome.browser.settings.SettingsLauncher;
import org.chromium.chrome.browser.settings.SettingsLauncherImpl;
import org.chromium.chrome.browser.signin.IdentityServicesProvider;
import org.chromium.chrome.browser.sync.settings.GoogleServicesSettings;
import org.chromium.chrome.browser.sync.settings.ManageSyncSettings;
import org.chromium.chrome.browser.sync.settings.SyncAndServicesSettings;
import org.chromium.chrome.browser.usage_stats.UsageStatsConsentDialog;
import org.chromium.components.browser_ui.settings.ChromeSwitchPreference;
import org.chromium.components.browser_ui.settings.ManagedPreferenceDelegate;
import org.chromium.components.browser_ui.settings.SettingsUtils;
import org.chromium.components.prefs.PrefService;
import org.chromium.components.signin.identitymanager.ConsentLevel;
import org.chromium.components.user_prefs.UserPrefs;
import org.chromium.ui.text.NoUnderlineClickableSpan;
import org.chromium.ui.text.SpanApplier;
......@@ -107,18 +112,46 @@ public class PrivacySettings
secureDnsPref.setVisible(SecureDnsSettings.isUiEnabled());
Preference syncAndServicesLink = findPreference(PREF_SYNC_AND_SERVICES_LINK);
NoUnderlineClickableSpan linkSpan = new NoUnderlineClickableSpan(getResources(), view -> {
SettingsLauncher settingsLauncher = new SettingsLauncherImpl();
settingsLauncher.launchSettingsActivity(getActivity(), SyncAndServicesSettings.class,
SyncAndServicesSettings.createArguments(false));
});
syncAndServicesLink.setSummary(
SpanApplier.applySpans(getString(R.string.privacy_sync_and_services_link),
new SpanApplier.SpanInfo("<link>", "</link>", linkSpan)));
syncAndServicesLink.setSummary(buildSyncAndServicesLink());
updateSummaries();
}
private SpannableString buildSyncAndServicesLink() {
SettingsLauncher settingsLauncher = new SettingsLauncherImpl();
if (!ChromeFeatureList.isEnabled(ChromeFeatureList.MOBILE_IDENTITY_CONSISTENCY)) {
NoUnderlineClickableSpan syncAndServicesLink =
new NoUnderlineClickableSpan(getResources(), v -> {
settingsLauncher.launchSettingsActivity(getActivity(),
SyncAndServicesSettings.class,
SyncAndServicesSettings.createArguments(false));
});
return SpanApplier.applySpans(getString(R.string.privacy_sync_and_services_link_legacy),
new SpanApplier.SpanInfo("<link>", "</link>", syncAndServicesLink));
}
NoUnderlineClickableSpan servicesLink = new NoUnderlineClickableSpan(getResources(), v -> {
settingsLauncher.launchSettingsActivity(getActivity(), GoogleServicesSettings.class);
});
if (IdentityServicesProvider.get()
.getIdentityManager(Profile.getLastUsedRegularProfile())
.getPrimaryAccountInfo(ConsentLevel.SYNC)
== null) {
// Sync is off, show the string with one link to "Google Services".
return SpanApplier.applySpans(
getString(R.string.privacy_sync_and_services_link_sync_off),
new SpanApplier.SpanInfo("<link>", "</link>", servicesLink));
}
// Otherwise, show the string with both links to "Sync" and "Google Services".
NoUnderlineClickableSpan syncLink = new NoUnderlineClickableSpan(getResources(), v -> {
settingsLauncher.launchSettingsActivity(getActivity(), ManageSyncSettings.class,
ManageSyncSettings.createArguments(false));
});
return SpanApplier.applySpans(getString(R.string.privacy_sync_and_services_link_sync_on),
new SpanApplier.SpanInfo("<link1>", "</link1>", syncLink),
new SpanApplier.SpanInfo("<link2>", "</link2>", servicesLink));
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
String key = preference.getKey();
......
......@@ -342,9 +342,15 @@ CHAR-LIMIT guidelines:
<message name="IDS_URL_KEYED_ANONYMIZED_DATA_SUMMARY" desc="Summary for a checkbox in Settings that controls non-personalized URL collection and informs the user about the data shared by this feature.">
Sends URLs of pages you visit to Google
</message>
<message name="IDS_PRIVACY_SYNC_AND_SERVICES_LINK" desc="The text for Privacy preferences that is shown after all preference rows.">
<message name="IDS_PRIVACY_SYNC_AND_SERVICES_LINK_LEGACY" desc="The text for Privacy preferences that is shown after all preference rows.">
For more settings that relate to privacy, security, and data collection, see <ph name="BEGIN_LINK">&lt;link&gt;</ph>Sync and Google services<ph name="END_LINK">&lt;/link&gt;</ph>
</message>
<message name="IDS_PRIVACY_SYNC_AND_SERVICES_LINK_SYNC_ON" desc="The text for Privacy preferences that is shown after all preference rows. This version of the text is shown if Sync has been turned on.">
For more settings that relate to privacy, security, and data collection, see <ph name="BEGIN_LINK1">&lt;link1&gt;</ph>Sync<ph name="END_LINK1">&lt;/link1&gt;</ph> and <ph name="BEGIN_LINK2">&lt;link2&gt;</ph>Google services<ph name="END_LINK2">&lt;/link2&gt;</ph>
</message>
<message name="IDS_PRIVACY_SYNC_AND_SERVICES_LINK_SYNC_OFF" desc="The text for Privacy preferences that is shown after all preference rows. This version of the text is shown if Sync hasn't been turned on.">
For more settings that relate to privacy, security, and data collection, see <ph name="BEGIN_LINK">&lt;link&gt;</ph>Google services<ph name="END_LINK">&lt;/link&gt;</ph>
</message>
<message name="IDS_USAGE_AND_CRASH_REPORTS_TITLE" desc="Title for a preference that enables sending usage statistics and crash reports.">
Help improve Chrome's features and performance
</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