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

[Unity][Android] Update AccountManagementFragment for UNIFIED_CONSENT

This CL changes the appearance of AccountManagementFragment if
UNIFIED_CONSENT feature is enabled. Some preference rows are hidden in
this case and a different title is used for the sign-out button. It also
changes TextView in the modified XML file to use textAppearance (to fix
presubmit error).

Bug: 814728
Change-Id: Id0bdb938e31acc3bbcd7eb7ddf6747fe0d748cb8
Reviewed-on: https://chromium-review.googlesource.com/1185591Reviewed-by: default avatarTheresa <twellington@chromium.org>
Commit-Queue: Boris Sazonov <bsazonov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#585445}
parent 9e6b7c8a
......@@ -38,8 +38,7 @@
<TextView android:id="@android:id/summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorSecondary"/>
android:textAppearance="@style/BlackBody"/>
<LinearLayout android:id="@android:id/widget_frame"
android:layout_width="wrap_content"
......@@ -62,6 +61,7 @@
android:title="@string/sign_in_sync"/>
<Preference
android:key="sync_settings_divider"
android:layout="@layout/divider_preference"/>
<Preference
......@@ -71,6 +71,7 @@
android:summary="@string/sign_in_google_activity_controls_message"/>
<Preference
android:key="google_activity_controls_divider"
android:layout="@layout/divider_preference"/>
<Preference
......
......@@ -34,6 +34,7 @@ import org.chromium.base.ContextUtils;
import org.chromium.base.metrics.RecordUserAction;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.AppHooks;
import org.chromium.chrome.browser.ChromeFeatureList;
import org.chromium.chrome.browser.preferences.ChromeBasePreference;
import org.chromium.chrome.browser.preferences.PrefServiceBridge;
import org.chromium.chrome.browser.preferences.Preferences;
......@@ -87,7 +88,10 @@ public class AccountManagementFragment extends PreferenceFragment
public static final String PREF_CHILD_CONTENT = "child_content";
public static final String PREF_CHILD_CONTENT_DIVIDER = "child_content_divider";
public static final String PREF_GOOGLE_ACTIVITY_CONTROLS = "google_activity_controls";
public static final String PREF_GOOGLE_ACTIVITY_CONTROLS_DIVIDER =
"google_activity_controls_divider";
public static final String PREF_SYNC_SETTINGS = "sync_settings";
public static final String PREF_SYNC_SETTINGS_DIVIDER = "sync_settings_divider";
public static final String PREF_SIGN_OUT = "sign_out";
public static final String PREF_SIGN_OUT_DIVIDER = "sign_out_divider";
......@@ -221,6 +225,10 @@ public class AccountManagementFragment extends PreferenceFragment
getPreferenceScreen().removePreference(signOutSwitch);
getPreferenceScreen().removePreference(findPreference(PREF_SIGN_OUT_DIVIDER));
} else {
signOutSwitch.setTitle(ChromeFeatureList.isEnabled(ChromeFeatureList.UNIFIED_CONSENT)
? R.string.sign_out_and_turn_off_sync
: R.string.account_management_sign_out);
signOutSwitch.setEnabled(getSignOutAllowedPreferenceValue());
signOutSwitch.setOnPreferenceClickListener(preference -> {
if (!isVisible() || !isResumed()) return false;
......@@ -260,8 +268,14 @@ public class AccountManagementFragment extends PreferenceFragment
}
private void configureSyncSettings() {
Preference syncSettings = findPreference(PREF_SYNC_SETTINGS);
if (ChromeFeatureList.isEnabled(ChromeFeatureList.UNIFIED_CONSENT)) {
getPreferenceScreen().removePreference(syncSettings);
getPreferenceScreen().removePreference(findPreference(PREF_SYNC_SETTINGS_DIVIDER));
return;
}
final Preferences preferences = (Preferences) getActivity();
findPreference(PREF_SYNC_SETTINGS).setOnPreferenceClickListener(preference -> {
syncSettings.setOnPreferenceClickListener(preference -> {
if (!isVisible() || !isResumed()) return false;
if (ProfileSyncService.get() == null) return true;
......@@ -273,6 +287,12 @@ public class AccountManagementFragment extends PreferenceFragment
private void configureGoogleActivityControls() {
Preference pref = findPreference(PREF_GOOGLE_ACTIVITY_CONTROLS);
if (ChromeFeatureList.isEnabled(ChromeFeatureList.UNIFIED_CONSENT)) {
getPreferenceScreen().removePreference(pref);
getPreferenceScreen().removePreference(
findPreference(PREF_GOOGLE_ACTIVITY_CONTROLS_DIVIDER));
return;
}
if (mProfile.isChild()) {
pref.setSummary(R.string.sign_in_google_activity_controls_message_child_account);
}
......
......@@ -313,6 +313,9 @@ CHAR-LIMIT guidelines:
Sync error occurred, tap to get details.
</message>
<!-- Unified consent preferences -->
<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>
......
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